7
|
1 /* vi:set ts=8 sts=4 sw=4:
|
|
2 *
|
|
3 * VIM - Vi IMproved by Bram Moolenaar
|
|
4 * GUI/Motif support by Robert Webb
|
|
5 *
|
|
6 * Do ":help uganda" in Vim to read copying and usage conditions.
|
|
7 * Do ":help credits" in Vim to see a list of people who contributed.
|
|
8 * See README.txt for an overview of the Vim source code.
|
|
9 */
|
|
10
|
|
11 #include <Xm/Form.h>
|
|
12 #include <Xm/RowColumn.h>
|
|
13 #include <Xm/PushB.h>
|
|
14 #include <Xm/Text.h>
|
|
15 #include <Xm/TextF.h>
|
|
16 #include <Xm/Separator.h>
|
|
17 #include <Xm/Label.h>
|
|
18 #include <Xm/CascadeB.h>
|
|
19 #include <Xm/ScrollBar.h>
|
|
20 #include <Xm/MenuShell.h>
|
|
21 #include <Xm/DrawingA.h>
|
|
22 #if (XmVersion >= 1002)
|
|
23 # include <Xm/RepType.h>
|
|
24 #endif
|
|
25 #include <Xm/Frame.h>
|
|
26 #include <Xm/LabelG.h>
|
|
27 #include <Xm/ToggleBG.h>
|
|
28 #include <Xm/SeparatoG.h>
|
824
|
29 #include <Xm/XmP.h>
|
7
|
30
|
|
31 #include <X11/keysym.h>
|
|
32 #include <X11/Xatom.h>
|
|
33 #include <X11/StringDefs.h>
|
|
34 #include <X11/Intrinsic.h>
|
|
35
|
|
36 #include "vim.h"
|
|
37
|
|
38 #ifdef HAVE_X11_XPM_H
|
|
39 # include <X11/xpm.h>
|
|
40 #else
|
|
41 # ifdef HAVE_XM_XPMP_H
|
|
42 # include <Xm/XpmP.h>
|
|
43 # endif
|
|
44 #endif
|
838
|
45 #ifdef HAVE_XM_NOTEBOOK_H
|
|
46 # include <Xm/Notebook.h>
|
|
47 #endif
|
7
|
48
|
48
|
49 #include "gui_xmebw.h" /* for our Enhanced Button Widget */
|
|
50
|
7
|
51 #if defined(FEAT_GUI_DIALOG) && defined(HAVE_XPM)
|
|
52 # include "../pixmaps/alert.xpm"
|
|
53 # include "../pixmaps/error.xpm"
|
|
54 # include "../pixmaps/generic.xpm"
|
|
55 # include "../pixmaps/info.xpm"
|
|
56 # include "../pixmaps/quest.xpm"
|
|
57 #endif
|
|
58
|
|
59 #define MOTIF_POPUP
|
|
60
|
|
61 extern Widget vimShell;
|
|
62
|
|
63 static Widget vimForm;
|
|
64 static Widget textAreaForm;
|
|
65 Widget textArea;
|
|
66 #ifdef FEAT_TOOLBAR
|
|
67 static Widget toolBarFrame;
|
|
68 static Widget toolBar;
|
|
69 #endif
|
819
|
70 #ifdef FEAT_GUI_TABLINE
|
|
71 static Widget tabLine;
|
|
72 static Widget tabLine_menu = 0;
|
|
73 static int showing_tabline = 0;
|
|
74 #endif
|
7
|
75 #ifdef FEAT_FOOTER
|
|
76 static Widget footer;
|
|
77 #endif
|
|
78 #ifdef FEAT_MENU
|
|
79 # if (XmVersion >= 1002)
|
|
80 /* remember the last set value for the tearoff item */
|
|
81 static int tearoff_val = (int)XmTEAR_OFF_ENABLED;
|
|
82 # endif
|
|
83 static Widget menuBar;
|
|
84 #endif
|
|
85
|
|
86 static void scroll_cb __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
819
|
87 #ifdef FEAT_GUI_TABLINE
|
|
88 static void tabline_cb __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
89 static void tabline_button_cb __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
90 static void tabline_menu_cb __ARGS((Widget w, XtPointer closure, XEvent *e, Boolean *continue_dispatch));
|
844
|
91 static void tabline_balloon_cb __ARGS((BalloonEval *beval, int state));
|
819
|
92 #endif
|
7
|
93 #ifdef FEAT_TOOLBAR
|
|
94 # ifdef FEAT_FOOTER
|
|
95 static void toolbarbutton_enter_cb __ARGS((Widget, XtPointer, XEvent *, Boolean *));
|
|
96 static void toolbarbutton_leave_cb __ARGS((Widget, XtPointer, XEvent *, Boolean *));
|
|
97 # endif
|
54
|
98 static void reset_focus __ARGS((void));
|
7
|
99 #endif
|
|
100 #ifdef FEAT_FOOTER
|
|
101 static int gui_mch_compute_footer_height __ARGS((void));
|
|
102 #endif
|
|
103 #ifdef WSDEBUG
|
|
104 static void attachDump(Widget, char *);
|
|
105 #endif
|
|
106
|
|
107 static void gui_motif_menu_colors __ARGS((Widget id));
|
|
108 static void gui_motif_scroll_colors __ARGS((Widget id));
|
|
109
|
|
110 #if (XmVersion >= 1002)
|
|
111 # define STRING_TAG XmFONTLIST_DEFAULT_TAG
|
|
112 #else
|
|
113 # define STRING_TAG XmSTRING_DEFAULT_CHARSET
|
|
114 #endif
|
|
115
|
|
116 /*
|
|
117 * Call-back routines.
|
|
118 */
|
|
119
|
|
120 /* ARGSUSED */
|
|
121 static void
|
|
122 scroll_cb(w, client_data, call_data)
|
|
123 Widget w;
|
|
124 XtPointer client_data, call_data;
|
|
125 {
|
|
126 scrollbar_T *sb;
|
|
127 long value;
|
|
128 int dragging;
|
|
129
|
|
130 sb = gui_find_scrollbar((long)client_data);
|
|
131
|
|
132 value = ((XmScrollBarCallbackStruct *)call_data)->value;
|
|
133 dragging = (((XmScrollBarCallbackStruct *)call_data)->reason ==
|
|
134 (int)XmCR_DRAG);
|
|
135 gui_drag_scrollbar(sb, value, dragging);
|
|
136 }
|
|
137
|
819
|
138 #ifdef FEAT_GUI_TABLINE
|
|
139 /*ARGSUSED*/
|
|
140 static void
|
|
141 tabline_cb(w, client_data, call_data)
|
|
142 Widget w;
|
|
143 XtPointer client_data, call_data;
|
|
144 {
|
|
145 XmNotebookCallbackStruct *nptr;
|
|
146
|
|
147 nptr = (XmNotebookCallbackStruct *)call_data;
|
|
148 if (nptr->reason != (int)XmCR_NONE)
|
|
149 send_tabline_event(nptr->page_number);
|
|
150 }
|
|
151
|
|
152 /*ARGSUSED*/
|
|
153 static void
|
|
154 tabline_button_cb(w, client_data, call_data)
|
|
155 Widget w;
|
|
156 XtPointer client_data, call_data;
|
|
157 {
|
|
158 int cmd, tab_idx;
|
|
159
|
|
160 XtVaGetValues(w, XmNuserData, &cmd, NULL);
|
|
161 XtVaGetValues(tabLine_menu, XmNuserData, &tab_idx, NULL);
|
|
162
|
824
|
163 send_tabline_menu_event(tab_idx, cmd);
|
|
164 }
|
|
165
|
|
166 /*
|
|
167 * Tabline single mouse click timeout handler
|
|
168 */
|
|
169 /*ARGSUSED*/
|
|
170 static void
|
|
171 motif_tabline_timer_cb (timed_out, interval_id)
|
|
172 XtPointer timed_out;
|
|
173 XtIntervalId *interval_id;
|
|
174 {
|
|
175 *((int *)timed_out) = TRUE;
|
|
176 }
|
|
177
|
|
178 /*
|
|
179 * check if the tabline tab scroller is clicked
|
|
180 */
|
|
181 static int
|
|
182 tabline_scroller_clicked(scroller_name, event)
|
|
183 char *scroller_name;
|
|
184 XButtonPressedEvent *event;
|
|
185 {
|
|
186 Widget tab_scroll_w;
|
|
187 Position pos_x, pos_y;
|
|
188 Dimension width, height;
|
|
189
|
|
190 tab_scroll_w = XtNameToWidget(tabLine, scroller_name);
|
|
191 if (tab_scroll_w != (Widget)0) {
|
|
192 XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth,
|
|
193 &width, XmNheight, &height, NULL);
|
|
194 if (pos_x >= 0) {
|
|
195 /* Tab scroller (next) is visible */
|
|
196 if ((event->x >= pos_x) && (event->x <= pos_x + width) &&
|
|
197 (event->y >= pos_y) && (event->y <= pos_y + height)) {
|
|
198 /* Clicked on the scroller */
|
|
199 return TRUE;
|
|
200 }
|
|
201 }
|
|
202 }
|
|
203 return FALSE;
|
819
|
204 }
|
|
205
|
|
206 /*ARGSUSED*/
|
|
207 static void
|
|
208 tabline_menu_cb(w, closure, e, continue_dispatch)
|
|
209 Widget w;
|
|
210 XtPointer closure;
|
|
211 XEvent *e;
|
|
212 Boolean *continue_dispatch;
|
|
213 {
|
|
214 Widget tab_w;
|
|
215 XButtonPressedEvent *event;
|
|
216 int tab_idx = 0;
|
|
217 WidgetList children;
|
|
218 Cardinal numChildren;
|
824
|
219 static XtIntervalId timer = (XtIntervalId)0;
|
|
220 static int timed_out = TRUE;
|
819
|
221
|
|
222 event = (XButtonPressedEvent *)e;
|
|
223
|
824
|
224 if (event->button == Button1)
|
|
225 {
|
|
226 if (tabline_scroller_clicked("MajorTabScrollerNext", event)
|
|
227 || tabline_scroller_clicked("MajorTabScrollerPrevious", event))
|
|
228 return;
|
|
229
|
|
230 if (!timed_out)
|
|
231 {
|
|
232 XtRemoveTimeOut(timer);
|
|
233 timed_out = TRUE;
|
|
234
|
|
235 /*
|
|
236 * Double click on the tabline gutter, add a new tab
|
|
237 */
|
|
238 send_tabline_menu_event(0, TABLINE_MENU_NEW);
|
|
239 }
|
|
240 else
|
|
241 {
|
|
242 /*
|
|
243 * Single click on the tabline gutter, start a timer to check
|
|
244 * for double clicks
|
|
245 */
|
|
246 timer = XtAppAddTimeOut(app_context, (long_u)p_mouset,
|
|
247 motif_tabline_timer_cb, &timed_out);
|
|
248 timed_out = FALSE;
|
|
249 }
|
|
250 return;
|
|
251 }
|
|
252
|
819
|
253 if (event->button != Button3)
|
|
254 return;
|
|
255
|
844
|
256 /* When ignoring events don't show the menu. */
|
|
257 if (hold_gui_events
|
|
258 # ifdef FEAT_CMDWIN
|
|
259 || cmdwin_type != 0
|
|
260 # endif
|
|
261 )
|
|
262 return;
|
|
263
|
819
|
264 if (event->subwindow != None)
|
|
265 {
|
|
266 tab_w = XtWindowToWidget(XtDisplay(w), event->subwindow);
|
824
|
267 /* LINTED: avoid warning: dubious operation on enum */
|
819
|
268 if (tab_w != (Widget)0 && XmIsPushButton(tab_w))
|
|
269 XtVaGetValues(tab_w, XmNpageNumber, &tab_idx, NULL);
|
|
270 }
|
|
271
|
|
272 XtVaSetValues(tabLine_menu, XmNuserData, tab_idx, NULL);
|
|
273 XtVaGetValues(tabLine_menu, XmNchildren, &children, XmNnumChildren,
|
|
274 &numChildren, NULL);
|
|
275 XtManageChildren(children, numChildren);
|
|
276 XmMenuPosition(tabLine_menu, (XButtonPressedEvent *)e) ;
|
|
277 XtManageChild(tabLine_menu);
|
|
278 }
|
844
|
279
|
|
280 /*ARGSUSED*/
|
|
281 static void
|
|
282 tabline_balloon_cb(beval, state)
|
|
283 BalloonEval *beval;
|
|
284 int state;
|
|
285 {
|
|
286 int nr;
|
|
287 tabpage_T *tp;
|
|
288
|
|
289 if (beval->target == (Widget)0)
|
|
290 return;
|
|
291
|
|
292 XtVaGetValues(beval->target, XmNpageNumber, &nr, NULL);
|
|
293 tp = find_tabpage(nr);
|
|
294 if (tp == NULL)
|
|
295 return;
|
|
296
|
|
297 get_tabline_label(tp, TRUE);
|
|
298 gui_mch_post_balloon(beval, NameBuff);
|
|
299 }
|
|
300
|
819
|
301 #endif
|
|
302
|
7
|
303 /*
|
|
304 * End of call-back routines
|
|
305 */
|
|
306
|
44
|
307 /*
|
|
308 * Implement three dimensional shading of insensitive labels.
|
66
|
309 * By Marcin Dalecki.
|
44
|
310 */
|
|
311
|
|
312 #include <Xm/XmP.h>
|
|
313 #include <Xm/LabelP.h>
|
|
314
|
|
315 static XtExposeProc old_label_expose = NULL;
|
|
316
|
|
317 static void label_expose __ARGS((Widget _w, XEvent *_event, Region _region));
|
|
318
|
|
319 static void
|
|
320 label_expose(_w, _event, _region)
|
|
321 Widget _w;
|
|
322 XEvent *_event;
|
|
323 Region _region;
|
|
324 {
|
|
325 GC insensitiveGC;
|
|
326 XmLabelWidget lw = (XmLabelWidget)_w;
|
48
|
327 unsigned char label_type = (int)XmSTRING;
|
44
|
328
|
|
329 XtVaGetValues(_w, XmNlabelType, &label_type, (XtPointer)0);
|
|
330
|
48
|
331 if (XtIsSensitive(_w) || label_type != (int)XmSTRING)
|
44
|
332 (*old_label_expose)(_w, _event, _region);
|
|
333 else
|
|
334 {
|
|
335 XGCValues values;
|
|
336 XtGCMask mask;
|
|
337 XtGCMask dynamic;
|
|
338 XFontStruct *fs;
|
|
339
|
|
340 _XmFontListGetDefaultFont(lw->label.font, &fs);
|
|
341
|
|
342 /* FIXME: we should be doing the whole drawing ourself here. */
|
|
343 insensitiveGC = lw->label.insensitive_GC;
|
|
344
|
|
345 mask = GCForeground | GCBackground | GCGraphicsExposures;
|
|
346 dynamic = GCClipMask | GCClipXOrigin | GCClipYOrigin;
|
|
347 values.graphics_exposures = False;
|
|
348
|
|
349 if (fs != 0)
|
|
350 {
|
|
351 mask |= GCFont;
|
|
352 values.font = fs->fid;
|
|
353 }
|
|
354
|
|
355 if (lw->primitive.top_shadow_pixmap != None
|
|
356 && lw->primitive.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
|
|
357 {
|
|
358 mask |= GCFillStyle | GCTile;
|
|
359 values.fill_style = FillTiled;
|
|
360 values.tile = lw->primitive.top_shadow_pixmap;
|
|
361 }
|
|
362
|
|
363 lw->label.TextRect.x += 1;
|
|
364 lw->label.TextRect.y += 1;
|
|
365 if (lw->label._acc_text != 0)
|
|
366 {
|
|
367 lw->label.acc_TextRect.x += 1;
|
|
368 lw->label.acc_TextRect.y += 1;
|
|
369 }
|
|
370
|
|
371 values.foreground = lw->primitive.top_shadow_color;
|
|
372 values.background = lw->core.background_pixel;
|
|
373
|
48
|
374 lw->label.insensitive_GC = XtAllocateGC((Widget)lw, 0, mask,
|
|
375 &values, dynamic, (XtGCMask)0);
|
44
|
376 (*old_label_expose)(_w, _event, _region);
|
|
377 XtReleaseGC(_w, lw->label.insensitive_GC);
|
|
378
|
|
379 lw->label.TextRect.x -= 1;
|
|
380 lw->label.TextRect.y -= 1;
|
|
381 if (lw->label._acc_text != 0)
|
|
382 {
|
|
383 lw->label.acc_TextRect.x -= 1;
|
|
384 lw->label.acc_TextRect.y -= 1;
|
|
385 }
|
|
386
|
|
387 values.foreground = lw->primitive.bottom_shadow_color;
|
|
388 values.background = lw->core.background_pixel;
|
|
389
|
48
|
390 lw->label.insensitive_GC = XtAllocateGC((Widget) lw, 0, mask,
|
|
391 &values, dynamic, (XtGCMask)0);
|
44
|
392 (*old_label_expose)(_w, _event, _region);
|
|
393 XtReleaseGC(_w, lw->label.insensitive_GC);
|
|
394
|
|
395 lw->label.insensitive_GC = insensitiveGC;
|
|
396 }
|
|
397 }
|
|
398
|
7
|
399 /*
|
|
400 * Create all the motif widgets necessary.
|
|
401 */
|
|
402 void
|
|
403 gui_x11_create_widgets()
|
|
404 {
|
819
|
405 #ifdef FEAT_GUI_TABLINE
|
827
|
406 Widget button, scroller;
|
819
|
407 Arg args[10];
|
|
408 int n;
|
|
409 XmString xms;
|
|
410 #endif
|
|
411
|
44
|
412 /*
|
|
413 * Install the 3D shade effect drawing routines.
|
|
414 */
|
|
415 if (old_label_expose == NULL)
|
|
416 {
|
|
417 old_label_expose = xmLabelWidgetClass->core_class.expose;
|
|
418 xmLabelWidgetClass->core_class.expose = label_expose;
|
|
419 }
|
|
420
|
7
|
421 /*
|
|
422 * Start out by adding the configured border width into the border offset
|
|
423 */
|
|
424 gui.border_offset = gui.border_width;
|
|
425
|
|
426 /*
|
|
427 * Install the tearOffModel resource converter.
|
|
428 */
|
|
429 #if (XmVersion >= 1002)
|
|
430 XmRepTypeInstallTearOffModelConverter();
|
|
431 #endif
|
|
432
|
|
433 /* Make sure the "Quit" menu entry of the window manager is ignored */
|
|
434 XtVaSetValues(vimShell, XmNdeleteResponse, XmDO_NOTHING, NULL);
|
|
435
|
|
436 vimForm = XtVaCreateManagedWidget("vimForm",
|
|
437 xmFormWidgetClass, vimShell,
|
|
438 XmNborderWidth, 0,
|
|
439 XmNhighlightThickness, 0,
|
|
440 XmNshadowThickness, 0,
|
|
441 XmNmarginWidth, 0,
|
|
442 XmNmarginHeight, 0,
|
|
443 XmNresizePolicy, XmRESIZE_ANY,
|
|
444 NULL);
|
|
445 gui_motif_menu_colors(vimForm);
|
|
446
|
|
447 #ifdef FEAT_MENU
|
|
448 {
|
|
449 Arg al[7]; /* Make sure there is enough room for arguments! */
|
|
450 int ac = 0;
|
|
451
|
|
452 # if (XmVersion >= 1002)
|
|
453 XtSetArg(al[ac], XmNtearOffModel, tearoff_val); ac++;
|
|
454 # endif
|
|
455 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
|
|
456 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
|
|
457 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
|
|
458 # ifndef FEAT_TOOLBAR
|
|
459 /* Always stick to right hand side. */
|
|
460 XtSetArg(al[ac], XmNrightOffset, 0); ac++;
|
|
461 # endif
|
48
|
462 XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
|
7
|
463 menuBar = XmCreateMenuBar(vimForm, "menuBar", al, ac);
|
|
464 XtManageChild(menuBar);
|
|
465
|
|
466 /* Remember the default colors, needed for ":hi clear". */
|
|
467 XtVaGetValues(menuBar,
|
|
468 XmNbackground, &gui.menu_def_bg_pixel,
|
|
469 XmNforeground, &gui.menu_def_fg_pixel,
|
|
470 NULL);
|
|
471 gui_motif_menu_colors(menuBar);
|
|
472 }
|
|
473 #endif
|
|
474
|
|
475 #ifdef FEAT_TOOLBAR
|
|
476 /*
|
|
477 * Create an empty ToolBar. We should get buttons defined from menu.vim.
|
|
478 */
|
|
479 toolBarFrame = XtVaCreateWidget("toolBarFrame",
|
|
480 xmFrameWidgetClass, vimForm,
|
|
481 XmNshadowThickness, 0,
|
|
482 XmNmarginHeight, 0,
|
|
483 XmNmarginWidth, 0,
|
|
484 XmNleftAttachment, XmATTACH_FORM,
|
|
485 XmNrightAttachment, XmATTACH_FORM,
|
|
486 NULL);
|
|
487 gui_motif_menu_colors(toolBarFrame);
|
|
488
|
|
489 toolBar = XtVaCreateManagedWidget("toolBar",
|
|
490 xmRowColumnWidgetClass, toolBarFrame,
|
|
491 XmNchildType, XmFRAME_WORKAREA_CHILD,
|
|
492 XmNrowColumnType, XmWORK_AREA,
|
|
493 XmNorientation, XmHORIZONTAL,
|
|
494 XmNtraversalOn, False,
|
|
495 XmNisHomogeneous, False,
|
|
496 XmNpacking, XmPACK_TIGHT,
|
|
497 XmNspacing, 0,
|
|
498 XmNshadowThickness, 0,
|
|
499 XmNhighlightThickness, 0,
|
|
500 XmNmarginHeight, 0,
|
|
501 XmNmarginWidth, 0,
|
|
502 XmNadjustLast, True,
|
|
503 NULL);
|
|
504 gui_motif_menu_colors(toolBar);
|
|
505
|
|
506 #endif
|
|
507
|
819
|
508 #ifdef FEAT_GUI_TABLINE
|
|
509 /* Create the Vim GUI tabline */
|
|
510 n = 0;
|
|
511 XtSetArg(args[n], XmNbindingType, XmNONE); n++;
|
|
512 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
|
|
513 XtSetArg(args[n], XmNbackPageSize, XmNONE); n++;
|
|
514 XtSetArg(args[n], XmNbackPageNumber, 0); n++;
|
|
515 XtSetArg(args[n], XmNbackPagePlacement, XmTOP_RIGHT); n++;
|
|
516 XtSetArg(args[n], XmNmajorTabSpacing, 0); n++;
|
|
517 XtSetArg(args[n], XmNshadowThickness, 0); n++;
|
|
518 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
|
519 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
|
520 tabLine = XmCreateNotebook(vimForm, "Vim tabline", args, n);
|
|
521
|
|
522 XtAddCallback(tabLine, XmNpageChangedCallback, (XtCallbackProc)tabline_cb,
|
|
523 NULL);
|
|
524 XtAddEventHandler(tabLine, ButtonPressMask, False,
|
|
525 (XtEventHandler)tabline_menu_cb, NULL);
|
|
526
|
843
|
527 gui.tabline_height = TABLINE_HEIGHT;
|
|
528
|
827
|
529 /*
|
|
530 * Set the size of the minor next/prev scrollers to zero, so
|
|
531 * that they are not displayed. Due to a bug in OpenMotif 2.3,
|
|
532 * even if these children widget are unmanaged, they are again
|
|
533 * managed by the Notebook widget and the notebook widget geometry
|
|
534 * is adjusted to account for the minor scroller widgets.
|
|
535 */
|
|
536 scroller = XtNameToWidget(tabLine, "MinorTabScrollerNext");
|
|
537 XtVaSetValues(scroller, XmNwidth, 0, XmNresizable, False,
|
|
538 XmNtraversalOn, False, NULL);
|
|
539 scroller = XtNameToWidget(tabLine, "MinorTabScrollerPrevious");
|
|
540 XtVaSetValues(scroller, XmNwidth, 0, XmNresizable, False,
|
|
541 XmNtraversalOn, False, NULL);
|
|
542
|
819
|
543 /* Create the tabline popup menu */
|
|
544 tabLine_menu = XmCreatePopupMenu(tabLine, "tabline popup", NULL, 0);
|
|
545
|
|
546 /* Add the buttons to the menu */
|
|
547 n = 0;
|
|
548 XtSetArg(args[n], XmNuserData, TABLINE_MENU_CLOSE); n++;
|
|
549 xms = XmStringCreate((char *)"Close tab", STRING_TAG);
|
|
550 XtSetArg(args[n], XmNlabelString, xms); n++;
|
|
551 button = XmCreatePushButton(tabLine_menu, "Close", args, n);
|
|
552 XtAddCallback(button, XmNactivateCallback,
|
|
553 (XtCallbackProc)tabline_button_cb, NULL);
|
|
554 XmStringFree(xms);
|
|
555
|
|
556 n = 0;
|
|
557 XtSetArg(args[n], XmNuserData, TABLINE_MENU_NEW); n++;
|
|
558 xms = XmStringCreate((char *)"New Tab", STRING_TAG);
|
|
559 XtSetArg(args[n], XmNlabelString, xms); n++;
|
|
560 button = XmCreatePushButton(tabLine_menu, "New Tab", args, n);
|
|
561 XtAddCallback(button, XmNactivateCallback,
|
|
562 (XtCallbackProc)tabline_button_cb, NULL);
|
|
563 XmStringFree(xms);
|
|
564
|
|
565 n = 0;
|
|
566 XtSetArg(args[n], XmNuserData, TABLINE_MENU_OPEN); n++;
|
|
567 xms = XmStringCreate((char *)"Open tab...", STRING_TAG);
|
|
568 XtSetArg(args[n], XmNlabelString, xms); n++;
|
|
569 button = XmCreatePushButton(tabLine_menu, "Open tab...", args, n);
|
|
570 XtAddCallback(button, XmNactivateCallback,
|
|
571 (XtCallbackProc)tabline_button_cb, NULL);
|
|
572 XmStringFree(xms);
|
|
573 #endif
|
|
574
|
7
|
575 textAreaForm = XtVaCreateManagedWidget("textAreaForm",
|
|
576 xmFormWidgetClass, vimForm,
|
|
577 XmNleftAttachment, XmATTACH_FORM,
|
|
578 XmNrightAttachment, XmATTACH_FORM,
|
|
579 XmNbottomAttachment, XmATTACH_FORM,
|
|
580 XmNtopAttachment, XmATTACH_FORM,
|
|
581 XmNmarginWidth, 0,
|
|
582 XmNmarginHeight, 0,
|
|
583 XmNresizePolicy, XmRESIZE_ANY,
|
|
584 NULL);
|
|
585 gui_motif_scroll_colors(textAreaForm);
|
|
586
|
|
587 textArea = XtVaCreateManagedWidget("textArea",
|
|
588 xmDrawingAreaWidgetClass, textAreaForm,
|
|
589 XmNforeground, gui.norm_pixel,
|
|
590 XmNbackground, gui.back_pixel,
|
|
591 XmNleftAttachment, XmATTACH_FORM,
|
|
592 XmNtopAttachment, XmATTACH_FORM,
|
|
593 XmNrightAttachment, XmATTACH_FORM,
|
|
594 XmNbottomAttachment, XmATTACH_FORM,
|
|
595
|
|
596 /*
|
|
597 * These take some control away from the user, but avoids making them
|
|
598 * add resources to get a decent looking setup.
|
|
599 */
|
|
600 XmNborderWidth, 0,
|
|
601 XmNhighlightThickness, 0,
|
|
602 XmNshadowThickness, 0,
|
|
603 NULL);
|
|
604
|
|
605 #ifdef FEAT_FOOTER
|
|
606 /*
|
|
607 * Create the Footer.
|
|
608 */
|
|
609 footer = XtVaCreateWidget("footer",
|
|
610 xmLabelGadgetClass, vimForm,
|
|
611 XmNalignment, XmALIGNMENT_BEGINNING,
|
|
612 XmNmarginHeight, 0,
|
|
613 XmNmarginWidth, 0,
|
|
614 XmNtraversalOn, False,
|
|
615 XmNrecomputeSize, False,
|
|
616 XmNleftAttachment, XmATTACH_FORM,
|
|
617 XmNleftOffset, 5,
|
|
618 XmNrightAttachment, XmATTACH_FORM,
|
|
619 XmNbottomAttachment, XmATTACH_FORM,
|
|
620 NULL);
|
|
621 gui_mch_set_footer((char_u *) "");
|
|
622 #endif
|
|
623
|
|
624 /*
|
|
625 * Install the callbacks.
|
|
626 */
|
|
627 gui_x11_callbacks(textArea, vimForm);
|
|
628
|
|
629 /* Pretend we don't have input focus, we will get an event if we do. */
|
|
630 gui.in_focus = FALSE;
|
|
631 }
|
|
632
|
|
633 /*
|
|
634 * Called when the GUI is not going to start after all.
|
|
635 */
|
|
636 void
|
|
637 gui_x11_destroy_widgets()
|
|
638 {
|
|
639 textArea = NULL;
|
|
640 #ifdef FEAT_MENU
|
|
641 menuBar = NULL;
|
|
642 #endif
|
|
643 }
|
|
644
|
|
645 /*ARGSUSED*/
|
|
646 void
|
|
647 gui_mch_set_text_area_pos(x, y, w, h)
|
|
648 int x;
|
|
649 int y;
|
|
650 int w;
|
|
651 int h;
|
|
652 {
|
|
653 #ifdef FEAT_TOOLBAR
|
|
654 /* Give keyboard focus to the textArea instead of the toolbar. */
|
54
|
655 reset_focus();
|
7
|
656 #endif
|
|
657 }
|
|
658
|
|
659 void
|
|
660 gui_x11_set_back_color()
|
|
661 {
|
|
662 if (textArea != NULL)
|
|
663 #if (XmVersion >= 1002)
|
|
664 XmChangeColor(textArea, gui.back_pixel);
|
|
665 #else
|
|
666 XtVaSetValues(textArea,
|
|
667 XmNbackground, gui.back_pixel,
|
|
668 NULL);
|
|
669 #endif
|
|
670 }
|
|
671
|
|
672 /*
|
|
673 * Manage dialog centered on pointer. This could be used by the Athena code as
|
|
674 * well.
|
|
675 */
|
44
|
676 void
|
7
|
677 manage_centered(dialog_child)
|
|
678 Widget dialog_child;
|
|
679 {
|
|
680 Widget shell = XtParent(dialog_child);
|
|
681 Window root, child;
|
|
682 unsigned int mask;
|
|
683 unsigned int width, height, border_width, depth;
|
|
684 int x, y, win_x, win_y, maxX, maxY;
|
|
685 Boolean mappedWhenManaged;
|
|
686
|
|
687 /* Temporarily set value of XmNmappedWhenManaged
|
|
688 to stop the dialog from popping up right away */
|
|
689 XtVaGetValues(shell, XmNmappedWhenManaged, &mappedWhenManaged, 0);
|
|
690 XtVaSetValues(shell, XmNmappedWhenManaged, False, 0);
|
|
691
|
|
692 XtManageChild(dialog_child);
|
|
693
|
|
694 /* Get the pointer position (x, y) */
|
|
695 XQueryPointer(XtDisplay(shell), XtWindow(shell), &root, &child,
|
|
696 &x, &y, &win_x, &win_y, &mask);
|
|
697
|
|
698 /* Translate the pointer position (x, y) into a position for the new
|
|
699 window that will place the pointer at its center */
|
|
700 XGetGeometry(XtDisplay(shell), XtWindow(shell), &root, &win_x, &win_y,
|
|
701 &width, &height, &border_width, &depth);
|
|
702 width += 2 * border_width;
|
|
703 height += 2 * border_width;
|
|
704 x -= width / 2;
|
|
705 y -= height / 2;
|
|
706
|
|
707 /* Ensure that the dialog remains on screen */
|
|
708 maxX = XtScreen(shell)->width - width;
|
|
709 maxY = XtScreen(shell)->height - height;
|
|
710 if (x < 0)
|
|
711 x = 0;
|
|
712 if (x > maxX)
|
|
713 x = maxX;
|
|
714 if (y < 0)
|
|
715 y = 0;
|
|
716 if (y > maxY)
|
|
717 y = maxY;
|
|
718
|
|
719 /* Set desired window position in the DialogShell */
|
|
720 XtVaSetValues(shell, XmNx, x, XmNy, y, NULL);
|
|
721
|
|
722 /* Map the widget */
|
|
723 XtMapWidget(shell);
|
|
724
|
|
725 /* Restore the value of XmNmappedWhenManaged */
|
|
726 XtVaSetValues(shell, XmNmappedWhenManaged, mappedWhenManaged, 0);
|
|
727 }
|
|
728
|
|
729 #if defined(FEAT_MENU) || defined(FEAT_SUN_WORKSHOP) \
|
|
730 || defined(FEAT_GUI_DIALOG) || defined(PROTO)
|
|
731
|
|
732 /*
|
|
733 * Encapsulate the way an XmFontList is created.
|
|
734 */
|
|
735 XmFontList
|
|
736 gui_motif_create_fontlist(font)
|
|
737 XFontStruct *font;
|
|
738 {
|
|
739 XmFontList font_list;
|
|
740
|
|
741 # if (XmVersion <= 1001)
|
|
742 /* Motif 1.1 method */
|
|
743 font_list = XmFontListCreate(font, STRING_TAG);
|
|
744 # else
|
|
745 /* Motif 1.2 method */
|
|
746 XmFontListEntry font_list_entry;
|
|
747
|
|
748 font_list_entry = XmFontListEntryCreate(STRING_TAG, XmFONT_IS_FONT,
|
|
749 (XtPointer)font);
|
|
750 font_list = XmFontListAppendEntry(NULL, font_list_entry);
|
|
751 XmFontListEntryFree(&font_list_entry);
|
|
752 # endif
|
|
753 return font_list;
|
|
754 }
|
|
755
|
|
756 # if ((XmVersion > 1001) && defined(FEAT_XFONTSET)) || defined(PROTO)
|
|
757 XmFontList
|
|
758 gui_motif_fontset2fontlist(fontset)
|
|
759 XFontSet *fontset;
|
|
760 {
|
|
761 XmFontList font_list;
|
|
762
|
|
763 /* Motif 1.2 method */
|
|
764 XmFontListEntry font_list_entry;
|
|
765
|
|
766 font_list_entry = XmFontListEntryCreate(STRING_TAG,
|
|
767 XmFONT_IS_FONTSET,
|
|
768 (XtPointer)*fontset);
|
|
769 font_list = XmFontListAppendEntry(NULL, font_list_entry);
|
|
770 XmFontListEntryFree(&font_list_entry);
|
|
771 return font_list;
|
|
772 }
|
|
773 # endif
|
|
774
|
|
775 #endif
|
|
776
|
|
777 #if defined(FEAT_MENU) || defined(PROTO)
|
|
778 /*
|
|
779 * Menu stuff.
|
|
780 */
|
|
781
|
|
782 static void gui_motif_add_actext __ARGS((vimmenu_T *menu));
|
|
783 #if (XmVersion >= 1002)
|
|
784 static void toggle_tearoff __ARGS((Widget wid));
|
|
785 static void gui_mch_recurse_tearoffs __ARGS((vimmenu_T *menu));
|
|
786 #endif
|
54
|
787 static void submenu_change __ARGS((vimmenu_T *mp, int colors));
|
7
|
788
|
|
789 static void do_set_mnemonics __ARGS((int enable));
|
|
790 static int menu_enabled = TRUE;
|
|
791
|
|
792 void
|
|
793 gui_mch_enable_menu(flag)
|
|
794 int flag;
|
|
795 {
|
|
796 if (flag)
|
|
797 {
|
|
798 XtManageChild(menuBar);
|
|
799 #ifdef FEAT_TOOLBAR
|
|
800 if (XtIsManaged(XtParent(toolBar)))
|
|
801 {
|
|
802 /* toolBar is attached to top form */
|
|
803 XtVaSetValues(XtParent(toolBar),
|
|
804 XmNtopAttachment, XmATTACH_WIDGET,
|
|
805 XmNtopWidget, menuBar,
|
|
806 NULL);
|
819
|
807 #ifdef FEAT_GUI_TABLINE
|
|
808 if (showing_tabline)
|
|
809 {
|
|
810 XtVaSetValues(tabLine,
|
|
811 XmNtopAttachment, XmATTACH_WIDGET,
|
|
812 XmNtopWidget, XtParent(toolBar),
|
|
813 NULL);
|
|
814 XtVaSetValues(textAreaForm,
|
|
815 XmNtopAttachment, XmATTACH_WIDGET,
|
|
816 XmNtopWidget, tabLine,
|
|
817 NULL);
|
|
818 }
|
|
819 else
|
|
820 #endif
|
|
821 XtVaSetValues(textAreaForm,
|
|
822 XmNtopAttachment, XmATTACH_WIDGET,
|
|
823 XmNtopWidget, XtParent(toolBar),
|
|
824 NULL);
|
7
|
825 }
|
|
826 else
|
|
827 #endif
|
|
828 {
|
819
|
829 #ifdef FEAT_GUI_TABLINE
|
|
830 if (showing_tabline)
|
|
831 {
|
|
832 XtVaSetValues(tabLine,
|
|
833 XmNtopAttachment, XmATTACH_WIDGET,
|
|
834 XmNtopWidget, menuBar,
|
|
835 NULL);
|
|
836 XtVaSetValues(textAreaForm,
|
|
837 XmNtopAttachment, XmATTACH_WIDGET,
|
|
838 XmNtopWidget, tabLine,
|
|
839 NULL);
|
|
840 }
|
|
841 else
|
|
842 #endif
|
|
843 XtVaSetValues(textAreaForm,
|
|
844 XmNtopAttachment, XmATTACH_WIDGET,
|
|
845 XmNtopWidget, menuBar,
|
|
846 NULL);
|
7
|
847 }
|
|
848 }
|
|
849 else
|
|
850 {
|
|
851 XtUnmanageChild(menuBar);
|
|
852 #ifdef FEAT_TOOLBAR
|
|
853 if (XtIsManaged(XtParent(toolBar)))
|
|
854 {
|
|
855 XtVaSetValues(XtParent(toolBar),
|
|
856 XmNtopAttachment, XmATTACH_FORM,
|
|
857 NULL);
|
819
|
858 #ifdef FEAT_GUI_TABLINE
|
|
859 if (showing_tabline)
|
|
860 {
|
|
861 XtVaSetValues(tabLine,
|
|
862 XmNtopAttachment, XmATTACH_WIDGET,
|
|
863 XmNtopWidget, XtParent(toolBar),
|
|
864 NULL);
|
|
865 XtVaSetValues(textAreaForm,
|
|
866 XmNtopAttachment, XmATTACH_WIDGET,
|
|
867 XmNtopWidget, tabLine,
|
|
868 NULL);
|
|
869 }
|
|
870 else
|
|
871 #endif
|
|
872 XtVaSetValues(textAreaForm,
|
|
873 XmNtopAttachment, XmATTACH_WIDGET,
|
|
874 XmNtopWidget, XtParent(toolBar),
|
|
875 NULL);
|
7
|
876 }
|
|
877 else
|
|
878 #endif
|
|
879 {
|
819
|
880 #ifdef FEAT_GUI_TABLINE
|
|
881 if (showing_tabline)
|
|
882 {
|
|
883 XtVaSetValues(tabLine,
|
|
884 XmNtopAttachment, XmATTACH_FORM,
|
|
885 NULL);
|
|
886 XtVaSetValues(textAreaForm,
|
|
887 XmNtopAttachment, XmATTACH_WIDGET,
|
|
888 XmNtopWidget, tabLine,
|
|
889 NULL);
|
|
890 }
|
|
891 else
|
|
892 #endif
|
|
893 XtVaSetValues(textAreaForm,
|
|
894 XmNtopAttachment, XmATTACH_FORM,
|
|
895 NULL);
|
7
|
896 }
|
|
897 }
|
|
898
|
|
899 }
|
|
900
|
|
901 /*
|
|
902 * Enable or disable mnemonics for the toplevel menus.
|
|
903 */
|
|
904 void
|
|
905 gui_motif_set_mnemonics(enable)
|
|
906 int enable;
|
|
907 {
|
|
908 /*
|
|
909 * Don't enable menu mnemonics when the menu bar is disabled, LessTif
|
|
910 * crashes when using a mnemonic then.
|
|
911 */
|
|
912 if (!menu_enabled)
|
|
913 enable = FALSE;
|
|
914 do_set_mnemonics(enable);
|
|
915 }
|
|
916
|
|
917 static void
|
|
918 do_set_mnemonics(enable)
|
|
919 int enable;
|
|
920 {
|
|
921 vimmenu_T *menu;
|
|
922
|
|
923 for (menu = root_menu; menu != NULL; menu = menu->next)
|
|
924 if (menu->id != (Widget)0)
|
|
925 XtVaSetValues(menu->id,
|
|
926 XmNmnemonic, enable ? menu->mnemonic : NUL,
|
|
927 NULL);
|
|
928 }
|
|
929
|
|
930 void
|
|
931 gui_mch_add_menu(menu, idx)
|
|
932 vimmenu_T *menu;
|
|
933 int idx;
|
|
934 {
|
|
935 XmString label;
|
|
936 Widget shell;
|
|
937 vimmenu_T *parent = menu->parent;
|
|
938
|
|
939 #ifdef MOTIF_POPUP
|
|
940 if (menu_is_popup(menu->name))
|
|
941 {
|
|
942 Arg arg[2];
|
|
943 int n = 0;
|
|
944
|
|
945 /* Only create the popup menu when it's actually used, otherwise there
|
|
946 * is a delay when using the right mouse button. */
|
|
947 # if (XmVersion <= 1002)
|
|
948 if (mouse_model_popup())
|
|
949 # endif
|
|
950 {
|
|
951 if (gui.menu_bg_pixel != INVALCOLOR)
|
|
952 {
|
|
953 XtSetArg(arg[0], XmNbackground, gui.menu_bg_pixel); n++;
|
|
954 }
|
|
955 if (gui.menu_fg_pixel != INVALCOLOR)
|
|
956 {
|
|
957 XtSetArg(arg[1], XmNforeground, gui.menu_fg_pixel); n++;
|
|
958 }
|
|
959 menu->submenu_id = XmCreatePopupMenu(textArea, "contextMenu",
|
|
960 arg, n);
|
|
961 menu->id = (Widget)0;
|
|
962 }
|
|
963 return;
|
|
964 }
|
|
965 #endif
|
|
966
|
|
967 if (!menu_is_menubar(menu->name)
|
|
968 || (parent != NULL && parent->submenu_id == (Widget)0))
|
|
969 return;
|
|
970
|
|
971 label = XmStringCreate((char *)menu->dname, STRING_TAG);
|
|
972 if (label == NULL)
|
|
973 return;
|
|
974 menu->id = XtVaCreateWidget("subMenu",
|
|
975 xmCascadeButtonWidgetClass,
|
|
976 (parent == NULL) ? menuBar : parent->submenu_id,
|
|
977 XmNlabelString, label,
|
|
978 XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic,
|
|
979 #if (XmVersion >= 1002)
|
|
980 /* submenu: count the tearoff item (needed for LessTif) */
|
|
981 XmNpositionIndex, idx + (parent != NULL
|
|
982 && tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0),
|
|
983 #endif
|
|
984 NULL);
|
|
985 gui_motif_menu_colors(menu->id);
|
|
986 gui_motif_menu_fontlist(menu->id);
|
|
987 XmStringFree(label);
|
|
988
|
|
989 if (menu->id == (Widget)0) /* failed */
|
|
990 return;
|
|
991
|
|
992 /* add accelerator text */
|
|
993 gui_motif_add_actext(menu);
|
|
994
|
|
995 shell = XtVaCreateWidget("subMenuShell",
|
|
996 xmMenuShellWidgetClass, menu->id,
|
|
997 XmNwidth, 1,
|
|
998 XmNheight, 1,
|
|
999 NULL);
|
|
1000 gui_motif_menu_colors(shell);
|
|
1001 menu->submenu_id = XtVaCreateWidget("rowColumnMenu",
|
|
1002 xmRowColumnWidgetClass, shell,
|
|
1003 XmNrowColumnType, XmMENU_PULLDOWN,
|
|
1004 NULL);
|
|
1005 gui_motif_menu_colors(menu->submenu_id);
|
|
1006
|
|
1007 if (menu->submenu_id == (Widget)0) /* failed */
|
|
1008 return;
|
|
1009
|
|
1010 #if (XmVersion >= 1002)
|
|
1011 /* Set the colors for the tear off widget */
|
|
1012 toggle_tearoff(menu->submenu_id);
|
|
1013 #endif
|
|
1014
|
|
1015 XtVaSetValues(menu->id,
|
|
1016 XmNsubMenuId, menu->submenu_id,
|
|
1017 NULL);
|
|
1018
|
|
1019 /*
|
|
1020 * The "Help" menu is a special case, and should be placed at the far
|
|
1021 * right hand side of the menu-bar. It's recognized by its high priority.
|
|
1022 */
|
|
1023 if (parent == NULL && menu->priority >= 9999)
|
|
1024 XtVaSetValues(menuBar,
|
|
1025 XmNmenuHelpWidget, menu->id,
|
|
1026 NULL);
|
|
1027
|
|
1028 /*
|
|
1029 * When we add a top-level item to the menu bar, we can figure out how
|
|
1030 * high the menu bar should be.
|
|
1031 */
|
|
1032 if (parent == NULL)
|
|
1033 gui_mch_compute_menu_height(menu->id);
|
|
1034 }
|
|
1035
|
|
1036
|
|
1037 /*
|
|
1038 * Add mnemonic and accelerator text to a menu button.
|
|
1039 */
|
|
1040 static void
|
|
1041 gui_motif_add_actext(menu)
|
|
1042 vimmenu_T *menu;
|
|
1043 {
|
|
1044 XmString label;
|
|
1045
|
|
1046 /* Add accelrator text, if there is one */
|
|
1047 if (menu->actext != NULL && menu->id != (Widget)0)
|
|
1048 {
|
|
1049 label = XmStringCreate((char *)menu->actext, STRING_TAG);
|
|
1050 if (label == NULL)
|
|
1051 return;
|
|
1052 XtVaSetValues(menu->id, XmNacceleratorText, label, NULL);
|
|
1053 XmStringFree(label);
|
|
1054 }
|
|
1055 }
|
|
1056
|
|
1057 void
|
|
1058 gui_mch_toggle_tearoffs(enable)
|
|
1059 int enable;
|
|
1060 {
|
|
1061 #if (XmVersion >= 1002)
|
|
1062 if (enable)
|
|
1063 tearoff_val = (int)XmTEAR_OFF_ENABLED;
|
|
1064 else
|
|
1065 tearoff_val = (int)XmTEAR_OFF_DISABLED;
|
|
1066 toggle_tearoff(menuBar);
|
|
1067 gui_mch_recurse_tearoffs(root_menu);
|
|
1068 #endif
|
|
1069 }
|
|
1070
|
|
1071 #if (XmVersion >= 1002)
|
|
1072 /*
|
|
1073 * Set the tearoff for one menu widget on or off, and set the color of the
|
|
1074 * tearoff widget.
|
|
1075 */
|
|
1076 static void
|
|
1077 toggle_tearoff(wid)
|
|
1078 Widget wid;
|
|
1079 {
|
|
1080 Widget w;
|
|
1081
|
|
1082 XtVaSetValues(wid, XmNtearOffModel, tearoff_val, NULL);
|
|
1083 if (tearoff_val == (int)XmTEAR_OFF_ENABLED
|
|
1084 && (w = XmGetTearOffControl(wid)) != (Widget)0)
|
|
1085 gui_motif_menu_colors(w);
|
|
1086 }
|
|
1087
|
|
1088 static void
|
|
1089 gui_mch_recurse_tearoffs(menu)
|
|
1090 vimmenu_T *menu;
|
|
1091 {
|
|
1092 while (menu != NULL)
|
|
1093 {
|
|
1094 if (!menu_is_popup(menu->name))
|
|
1095 {
|
|
1096 if (menu->submenu_id != (Widget)0)
|
|
1097 toggle_tearoff(menu->submenu_id);
|
|
1098 gui_mch_recurse_tearoffs(menu->children);
|
|
1099 }
|
|
1100 menu = menu->next;
|
|
1101 }
|
|
1102 }
|
|
1103 #endif
|
|
1104
|
|
1105 int
|
|
1106 gui_mch_text_area_extra_height()
|
|
1107 {
|
|
1108 Dimension shadowHeight;
|
|
1109
|
|
1110 XtVaGetValues(textAreaForm, XmNshadowThickness, &shadowHeight, NULL);
|
|
1111 return shadowHeight;
|
|
1112 }
|
|
1113
|
|
1114 /*
|
|
1115 * Compute the height of the menu bar.
|
|
1116 * We need to check all the items for their position and height, for the case
|
|
1117 * there are several rows, and/or some characters extend higher or lower.
|
|
1118 */
|
|
1119 void
|
|
1120 gui_mch_compute_menu_height(id)
|
|
1121 Widget id; /* can be NULL when deleting menu */
|
|
1122 {
|
|
1123 Dimension y, maxy;
|
|
1124 Dimension margin, shadow;
|
|
1125 vimmenu_T *mp;
|
|
1126 static Dimension height = 21; /* normal height of a menu item */
|
|
1127
|
|
1128 /*
|
|
1129 * Get the height of the new item, before managing it, because it will
|
|
1130 * still reflect the font size. After managing it depends on the menu
|
|
1131 * height, which is what we just wanted to get!.
|
|
1132 */
|
|
1133 if (id != (Widget)0)
|
|
1134 XtVaGetValues(id, XmNheight, &height, NULL);
|
|
1135
|
|
1136 /* Find any menu Widget, to be able to call XtManageChild() */
|
|
1137 else
|
|
1138 for (mp = root_menu; mp != NULL; mp = mp->next)
|
|
1139 if (mp->id != (Widget)0 && menu_is_menubar(mp->name))
|
|
1140 {
|
|
1141 id = mp->id;
|
|
1142 break;
|
|
1143 }
|
|
1144
|
|
1145 /*
|
|
1146 * Now manage the menu item, to make them all be positioned (makes an
|
|
1147 * extra row when needed, removes it when not needed).
|
|
1148 */
|
|
1149 if (id != (Widget)0)
|
|
1150 XtManageChild(id);
|
|
1151
|
|
1152 /*
|
|
1153 * Now find the menu item that is the furthest down, and get it's position.
|
|
1154 */
|
|
1155 maxy = 0;
|
|
1156 for (mp = root_menu; mp != NULL; mp = mp->next)
|
|
1157 {
|
|
1158 if (mp->id != (Widget)0 && menu_is_menubar(mp->name))
|
|
1159 {
|
|
1160 XtVaGetValues(mp->id, XmNy, &y, NULL);
|
|
1161 if (y > maxy)
|
|
1162 maxy = y;
|
|
1163 }
|
|
1164 }
|
|
1165
|
|
1166 XtVaGetValues(menuBar,
|
|
1167 XmNmarginHeight, &margin,
|
|
1168 XmNshadowThickness, &shadow,
|
|
1169 NULL);
|
|
1170
|
|
1171 /*
|
|
1172 * This computation is the result of trial-and-error:
|
|
1173 * maxy = The maximum position of an item; required for when there are
|
|
1174 * two or more rows
|
|
1175 * height = height of an item, before managing it; Hopefully this will
|
|
1176 * change with the font height. Includes shadow-border.
|
|
1177 * shadow = shadow-border; must be subtracted from the height.
|
|
1178 * margin = margin around the menu buttons; Must be added.
|
|
1179 * Add 4 for the underlining of shortcut keys.
|
|
1180 */
|
|
1181 gui.menu_height = maxy + height - 2 * shadow + 2 * margin + 4;
|
|
1182
|
|
1183 /* Somehow the menu bar doesn't resize automatically. Set it here,
|
|
1184 * even though this is a catch 22. Don't do this when starting up,
|
|
1185 * somehow the menu gets very high then. */
|
|
1186 if (gui.shell_created)
|
|
1187 XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL);
|
48
|
1188 }
|
|
1189
|
147
|
1190 #ifdef FEAT_TOOLBAR
|
|
1191
|
48
|
1192 /*
|
|
1193 * Icons used by the toolbar code.
|
|
1194 */
|
|
1195 #include "gui_x11_pm.h"
|
|
1196
|
|
1197 static int check_xpm __ARGS((char_u *path));
|
161
|
1198 static char **get_toolbar_pixmap __ARGS((vimmenu_T *menu, char **fname));
|
|
1199 static int add_pixmap_args __ARGS((vimmenu_T *menu, Arg *args, int n));
|
48
|
1200
|
|
1201 /*
|
|
1202 * Read an Xpm file. Return OK or FAIL.
|
|
1203 */
|
|
1204 static int
|
|
1205 check_xpm(path)
|
|
1206 char_u *path;
|
|
1207 {
|
|
1208 XpmAttributes attrs;
|
|
1209 int status;
|
|
1210 Pixmap mask;
|
|
1211 Pixmap map;
|
|
1212
|
|
1213 attrs.valuemask = 0;
|
|
1214
|
|
1215 /* Create the "sensitive" pixmap */
|
|
1216 status = XpmReadFileToPixmap(gui.dpy,
|
|
1217 RootWindow(gui.dpy, DefaultScreen(gui.dpy)),
|
|
1218 (char *)path, &map, &mask, &attrs);
|
|
1219 XpmFreeAttributes(&attrs);
|
|
1220
|
|
1221 if (status == XpmSuccess)
|
|
1222 return OK;
|
|
1223 return FAIL;
|
|
1224 }
|
|
1225
|
|
1226
|
|
1227 /*
|
|
1228 * Allocated a pixmap for toolbar menu "menu".
|
161
|
1229 * When it's to be read from a file, "fname" is set to the file name
|
|
1230 * (in allocated memory).
|
48
|
1231 * Return a blank pixmap if it fails.
|
|
1232 */
|
|
1233 static char **
|
161
|
1234 get_toolbar_pixmap(menu, fname)
|
48
|
1235 vimmenu_T *menu;
|
161
|
1236 char **fname;
|
48
|
1237 {
|
|
1238 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */
|
|
1239 char **xpm = NULL; /* xpm array */
|
|
1240 int res;
|
|
1241
|
161
|
1242 *fname = NULL;
|
48
|
1243 buf[0] = NUL; /* start with NULL path */
|
|
1244
|
|
1245 if (menu->iconfile != NULL)
|
|
1246 {
|
|
1247 /* Use the "icon=" argument. */
|
|
1248 gui_find_iconfile(menu->iconfile, buf, "xpm");
|
|
1249 res = check_xpm(buf);
|
|
1250
|
|
1251 /* If it failed, try using the menu name. */
|
|
1252 if (res == FAIL && gui_find_bitmap(menu->name, buf, "xpm") == OK)
|
|
1253 res = check_xpm(buf);
|
|
1254 if (res == OK)
|
161
|
1255 {
|
|
1256 *fname = (char *)vim_strsave(buf);
|
48
|
1257 return tb_blank_xpm;
|
161
|
1258 }
|
48
|
1259 }
|
|
1260
|
|
1261 if (menu->icon_builtin || gui_find_bitmap(menu->name, buf, "xpm") == FAIL)
|
|
1262 {
|
|
1263 if (menu->iconidx >= 0 && menu->iconidx
|
|
1264 < (sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0])))
|
|
1265 xpm = built_in_pixmaps[menu->iconidx];
|
|
1266 else
|
|
1267 xpm = tb_blank_xpm;
|
|
1268 }
|
|
1269
|
|
1270 return xpm;
|
7
|
1271 }
|
161
|
1272
|
|
1273 /*
|
|
1274 * Add arguments for the toolbar pixmap to a menu item.
|
|
1275 */
|
|
1276 static int
|
|
1277 add_pixmap_args(menu, args, n)
|
|
1278 vimmenu_T *menu;
|
|
1279 Arg *args;
|
|
1280 int n;
|
|
1281 {
|
|
1282 vim_free(menu->xpm_fname);
|
|
1283 menu->xpm = get_toolbar_pixmap(menu, &menu->xpm_fname);
|
|
1284 if (menu->xpm == NULL)
|
|
1285 {
|
|
1286 XtSetArg(args[n], XmNlabelType, XmSTRING); n++;
|
|
1287 }
|
|
1288 else
|
|
1289 {
|
|
1290 if (menu->xpm_fname != NULL)
|
|
1291 {
|
|
1292 XtSetArg(args[n], XmNpixmapFile, menu->xpm_fname); n++;
|
|
1293 }
|
|
1294 XtSetArg(args[n], XmNpixmapData, menu->xpm); n++;
|
|
1295 XtSetArg(args[n], XmNlabelLocation, XmBOTTOM); n++;
|
|
1296 }
|
|
1297 return n;
|
|
1298 }
|
147
|
1299 #endif /* FEAT_TOOLBAR */
|
7
|
1300
|
|
1301 void
|
|
1302 gui_mch_add_menu_item(menu, idx)
|
|
1303 vimmenu_T *menu;
|
|
1304 int idx;
|
|
1305 {
|
|
1306 XmString label;
|
|
1307 vimmenu_T *parent = menu->parent;
|
|
1308
|
|
1309 # ifdef EBCDIC
|
|
1310 menu->mnemonic = 0;
|
|
1311 # endif
|
|
1312
|
|
1313 # if (XmVersion <= 1002)
|
|
1314 /* Don't add Popup menu items when the popup menu isn't used. */
|
|
1315 if (menu_is_child_of_popup(menu) && !mouse_model_popup())
|
|
1316 return;
|
|
1317 # endif
|
|
1318
|
|
1319 # ifdef FEAT_TOOLBAR
|
|
1320 if (menu_is_toolbar(parent->name))
|
|
1321 {
|
|
1322 WidgetClass type;
|
|
1323 XmString xms = NULL; /* fallback label if pixmap not found */
|
|
1324 int n;
|
|
1325 Arg args[18];
|
|
1326
|
|
1327 n = 0;
|
|
1328 if (menu_is_separator(menu->name))
|
|
1329 {
|
|
1330 char *cp;
|
|
1331 Dimension wid;
|
|
1332
|
|
1333 /*
|
|
1334 * A separator has the format "-sep%d[:%d]-". The optional :%d is
|
|
1335 * a width specifier. If no width is specified then we choose one.
|
|
1336 */
|
|
1337 cp = (char *)vim_strchr(menu->name, ':');
|
|
1338 if (cp != NULL)
|
|
1339 wid = (Dimension)atoi(++cp);
|
|
1340 else
|
|
1341 wid = 4;
|
|
1342
|
|
1343 #if 0
|
|
1344 /* We better use a FormWidget here, since it's far more
|
|
1345 * flexible in terms of size. */
|
|
1346 type = xmFormWidgetClass;
|
|
1347 XtSetArg(args[n], XmNwidth, wid); n++;
|
|
1348 #else
|
|
1349 type = xmSeparatorWidgetClass;
|
|
1350 XtSetArg(args[n], XmNwidth, wid); n++;
|
|
1351 XtSetArg(args[n], XmNminWidth, wid); n++;
|
|
1352 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
|
48
|
1353 XtSetArg(args[n], XmNseparatorType, XmSHADOW_ETCHED_IN); n++;
|
7
|
1354 #endif
|
|
1355 }
|
|
1356 else
|
|
1357 {
|
|
1358 /* Without shadows one can't sense whatever the button has been
|
|
1359 * pressed or not! However we wan't to save a bit of space...
|
44
|
1360 * Need the highlightThickness to see the focus.
|
7
|
1361 */
|
44
|
1362 XtSetArg(args[n], XmNhighlightThickness, 1); n++;
|
7
|
1363 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
|
|
1364 XtSetArg(args[n], XmNmarginWidth, 0); n++;
|
|
1365 XtSetArg(args[n], XmNmarginHeight, 0); n++;
|
54
|
1366 XtSetArg(args[n], XmNtraversalOn, False); n++;
|
48
|
1367 /* Set the label here, so that we can switch between icons/text
|
|
1368 * by changing the XmNlabelType resource. */
|
|
1369 xms = XmStringCreate((char *)menu->dname, STRING_TAG);
|
|
1370 XtSetArg(args[n], XmNlabelString, xms); n++;
|
|
1371
|
161
|
1372 n = add_pixmap_args(menu, args, n);
|
|
1373
|
48
|
1374 type = xmEnhancedButtonWidgetClass;
|
7
|
1375 }
|
|
1376
|
|
1377 XtSetArg(args[n], XmNpositionIndex, idx); n++;
|
|
1378 if (menu->id == NULL)
|
|
1379 {
|
|
1380 menu->id = XtCreateManagedWidget((char *)menu->dname,
|
|
1381 type, toolBar, args, n);
|
48
|
1382 if (menu->id != NULL && type == xmEnhancedButtonWidgetClass)
|
7
|
1383 {
|
|
1384 XtAddCallback(menu->id,
|
|
1385 XmNactivateCallback, gui_x11_menu_cb, menu);
|
|
1386 # ifdef FEAT_FOOTER
|
|
1387 XtAddEventHandler(menu->id, EnterWindowMask, False,
|
|
1388 toolbarbutton_enter_cb, menu);
|
|
1389 XtAddEventHandler(menu->id, LeaveWindowMask, False,
|
|
1390 toolbarbutton_leave_cb, menu);
|
|
1391 # endif
|
|
1392 }
|
|
1393 }
|
|
1394 else
|
|
1395 XtSetValues(menu->id, args, n);
|
|
1396 if (xms != NULL)
|
|
1397 XmStringFree(xms);
|
|
1398
|
844
|
1399 # ifdef FEAT_BEVAL
|
7
|
1400 gui_mch_menu_set_tip(menu);
|
844
|
1401 # endif
|
7
|
1402
|
|
1403 menu->parent = parent;
|
|
1404 menu->submenu_id = NULL;
|
|
1405 /* When adding first item to toolbar it might have to be enabled .*/
|
|
1406 if (!XtIsManaged(XtParent(toolBar))
|
|
1407 && vim_strchr(p_go, GO_TOOLBAR) != NULL)
|
|
1408 gui_mch_show_toolbar(TRUE);
|
|
1409 gui.toolbar_height = gui_mch_compute_toolbar_height();
|
|
1410 return;
|
|
1411 } /* toolbar menu item */
|
|
1412 # endif
|
|
1413
|
|
1414 /* No parent, must be a non-menubar menu */
|
|
1415 if (parent->submenu_id == (Widget)0)
|
|
1416 return;
|
|
1417
|
|
1418 menu->submenu_id = (Widget)0;
|
|
1419
|
|
1420 /* Add menu separator */
|
|
1421 if (menu_is_separator(menu->name))
|
|
1422 {
|
|
1423 menu->id = XtVaCreateWidget("subMenu",
|
|
1424 xmSeparatorGadgetClass, parent->submenu_id,
|
|
1425 #if (XmVersion >= 1002)
|
|
1426 /* count the tearoff item (needed for LessTif) */
|
|
1427 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
|
|
1428 ? 1 : 0),
|
|
1429 #endif
|
|
1430 NULL);
|
|
1431 gui_motif_menu_colors(menu->id);
|
|
1432 return;
|
|
1433 }
|
|
1434
|
|
1435 label = XmStringCreate((char *)menu->dname, STRING_TAG);
|
|
1436 if (label == NULL)
|
|
1437 return;
|
|
1438 menu->id = XtVaCreateWidget("subMenu",
|
|
1439 xmPushButtonWidgetClass, parent->submenu_id,
|
|
1440 XmNlabelString, label,
|
|
1441 XmNmnemonic, menu->mnemonic,
|
|
1442 #if (XmVersion >= 1002)
|
|
1443 /* count the tearoff item (needed for LessTif) */
|
|
1444 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
|
|
1445 ? 1 : 0),
|
|
1446 #endif
|
|
1447 NULL);
|
|
1448 gui_motif_menu_colors(menu->id);
|
|
1449 gui_motif_menu_fontlist(menu->id);
|
|
1450 XmStringFree(label);
|
|
1451
|
|
1452 if (menu->id != (Widget)0)
|
|
1453 {
|
|
1454 XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb,
|
|
1455 (XtPointer)menu);
|
|
1456 /* add accelerator text */
|
|
1457 gui_motif_add_actext(menu);
|
|
1458 }
|
|
1459 }
|
|
1460
|
|
1461 #if (XmVersion <= 1002) || defined(PROTO)
|
|
1462 /*
|
|
1463 * This function will destroy/create the popup menus dynamically,
|
|
1464 * according to the value of 'mousemodel'.
|
|
1465 * This will fix the "right mouse button freeze" that occurs when
|
|
1466 * there exists a popup menu but it isn't managed.
|
|
1467 */
|
|
1468 void
|
|
1469 gui_motif_update_mousemodel(menu)
|
|
1470 vimmenu_T *menu;
|
|
1471 {
|
|
1472 int idx = 0;
|
|
1473
|
|
1474 /* When GUI hasn't started the menus have not been created. */
|
|
1475 if (!gui.in_use)
|
|
1476 return;
|
|
1477
|
|
1478 while (menu)
|
|
1479 {
|
|
1480 if (menu->children != NULL)
|
|
1481 {
|
|
1482 if (menu_is_popup(menu->name))
|
|
1483 {
|
|
1484 if (mouse_model_popup())
|
|
1485 {
|
|
1486 /* Popup menu will be used. Create the popup menus. */
|
|
1487 gui_mch_add_menu(menu, idx);
|
|
1488 gui_motif_update_mousemodel(menu->children);
|
|
1489 }
|
|
1490 else
|
|
1491 {
|
|
1492 /* Popup menu will not be used. Destroy the popup menus. */
|
|
1493 gui_motif_update_mousemodel(menu->children);
|
|
1494 gui_mch_destroy_menu(menu);
|
|
1495 }
|
|
1496 }
|
|
1497 }
|
|
1498 else if (menu_is_child_of_popup(menu))
|
|
1499 {
|
|
1500 if (mouse_model_popup())
|
|
1501 gui_mch_add_menu_item(menu, idx);
|
|
1502 else
|
|
1503 gui_mch_destroy_menu(menu);
|
|
1504 }
|
|
1505 menu = menu->next;
|
|
1506 ++idx;
|
|
1507 }
|
|
1508 }
|
|
1509 #endif
|
|
1510
|
|
1511 void
|
|
1512 gui_mch_new_menu_colors()
|
|
1513 {
|
|
1514 if (menuBar == (Widget)0)
|
|
1515 return;
|
|
1516 gui_motif_menu_colors(menuBar);
|
|
1517 #ifdef FEAT_TOOLBAR
|
|
1518 gui_motif_menu_colors(toolBarFrame);
|
|
1519 gui_motif_menu_colors(toolBar);
|
|
1520 #endif
|
|
1521
|
54
|
1522 submenu_change(root_menu, TRUE);
|
7
|
1523 }
|
|
1524
|
|
1525 void
|
|
1526 gui_mch_new_menu_font()
|
|
1527 {
|
|
1528 if (menuBar == (Widget)0)
|
|
1529 return;
|
54
|
1530 submenu_change(root_menu, FALSE);
|
7
|
1531 {
|
|
1532 Dimension height;
|
|
1533 Position w, h;
|
|
1534
|
|
1535 XtVaGetValues(menuBar, XmNheight, &height, NULL);
|
|
1536 gui.menu_height = height;
|
|
1537
|
|
1538 XtVaGetValues(vimShell, XtNwidth, &w, XtNheight, &h, NULL);
|
|
1539 gui_resize_shell(w, h
|
|
1540 #ifdef FEAT_XIM
|
|
1541 - xim_get_status_area_height()
|
|
1542 #endif
|
|
1543 );
|
|
1544 }
|
811
|
1545 gui_set_shellsize(FALSE, TRUE, RESIZE_VERT);
|
7
|
1546 ui_new_shellsize();
|
|
1547 }
|
|
1548
|
|
1549 #if defined(FEAT_BEVAL) || defined(PROTO)
|
|
1550 void
|
|
1551 gui_mch_new_tooltip_font()
|
|
1552 {
|
|
1553 # ifdef FEAT_TOOLBAR
|
|
1554 vimmenu_T *menu;
|
|
1555
|
|
1556 if (toolBar == (Widget)0)
|
|
1557 return;
|
|
1558
|
|
1559 menu = gui_find_menu((char_u *)"ToolBar");
|
|
1560 if (menu != NULL)
|
54
|
1561 submenu_change(menu, FALSE);
|
7
|
1562 # endif
|
|
1563 }
|
|
1564
|
|
1565 void
|
|
1566 gui_mch_new_tooltip_colors()
|
|
1567 {
|
|
1568 # ifdef FEAT_TOOLBAR
|
|
1569 vimmenu_T *toolbar;
|
|
1570
|
|
1571 if (toolBar == (Widget)0)
|
|
1572 return;
|
|
1573
|
|
1574 toolbar = gui_find_menu((char_u *)"ToolBar");
|
|
1575 if (toolbar != NULL)
|
54
|
1576 submenu_change(toolbar, TRUE);
|
7
|
1577 # endif
|
|
1578 }
|
|
1579 #endif
|
|
1580
|
|
1581 static void
|
54
|
1582 submenu_change(menu, colors)
|
7
|
1583 vimmenu_T *menu;
|
|
1584 int colors; /* TRUE for colors, FALSE for font */
|
|
1585 {
|
|
1586 vimmenu_T *mp;
|
|
1587
|
|
1588 for (mp = menu; mp != NULL; mp = mp->next)
|
|
1589 {
|
|
1590 if (mp->id != (Widget)0)
|
|
1591 {
|
|
1592 if (colors)
|
|
1593 {
|
|
1594 gui_motif_menu_colors(mp->id);
|
|
1595 #ifdef FEAT_TOOLBAR
|
|
1596 /* For a toolbar item: Free the pixmap and allocate a new one,
|
|
1597 * so that the background color is right. */
|
48
|
1598 if (mp->xpm != NULL)
|
7
|
1599 {
|
48
|
1600 int n = 0;
|
|
1601 Arg args[18];
|
|
1602
|
161
|
1603 n = add_pixmap_args(mp, args, n);
|
48
|
1604 XtSetValues(mp->id, args, n);
|
7
|
1605 }
|
|
1606 # ifdef FEAT_BEVAL
|
|
1607 /* If we have a tooltip, then we need to change it's font */
|
|
1608 if (mp->tip != NULL)
|
|
1609 {
|
|
1610 Arg args[2];
|
|
1611
|
|
1612 args[0].name = XmNbackground;
|
|
1613 args[0].value = gui.tooltip_bg_pixel;
|
|
1614 args[1].name = XmNforeground;
|
|
1615 args[1].value = gui.tooltip_fg_pixel;
|
|
1616 XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
|
|
1617 }
|
|
1618 # endif
|
|
1619 #endif
|
|
1620 }
|
|
1621 else
|
|
1622 {
|
|
1623 gui_motif_menu_fontlist(mp->id);
|
|
1624 #ifdef FEAT_BEVAL
|
|
1625 /* If we have a tooltip, then we need to change it's font */
|
|
1626 if (mp->tip != NULL)
|
|
1627 {
|
|
1628 Arg args[1];
|
|
1629
|
|
1630 args[0].name = XmNfontList;
|
|
1631 args[0].value = (XtArgVal)gui_motif_fontset2fontlist(
|
|
1632 &gui.tooltip_fontset);
|
|
1633 XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
|
|
1634 }
|
|
1635 #endif
|
|
1636 }
|
|
1637 }
|
|
1638
|
|
1639 if (mp->children != NULL)
|
|
1640 {
|
|
1641 #if (XmVersion >= 1002)
|
|
1642 /* Set the colors/font for the tear off widget */
|
|
1643 if (mp->submenu_id != (Widget)0)
|
|
1644 {
|
|
1645 if (colors)
|
|
1646 gui_motif_menu_colors(mp->submenu_id);
|
|
1647 else
|
|
1648 gui_motif_menu_fontlist(mp->submenu_id);
|
|
1649 toggle_tearoff(mp->submenu_id);
|
|
1650 }
|
|
1651 #endif
|
|
1652 /* Set the colors for the children */
|
54
|
1653 submenu_change(mp->children, colors);
|
7
|
1654 }
|
|
1655 }
|
|
1656 }
|
|
1657
|
|
1658 /*
|
|
1659 * Destroy the machine specific menu widget.
|
|
1660 */
|
|
1661 void
|
|
1662 gui_mch_destroy_menu(menu)
|
|
1663 vimmenu_T *menu;
|
|
1664 {
|
|
1665 /* Please be sure to destroy the parent widget first (i.e. menu->id).
|
|
1666 * On the other hand, problems have been reported that the submenu must be
|
|
1667 * deleted first...
|
|
1668 *
|
|
1669 * This code should be basically identical to that in the file gui_athena.c
|
|
1670 * because they are both Xt based.
|
|
1671 */
|
|
1672 if (menu->submenu_id != (Widget)0)
|
|
1673 {
|
|
1674 XtDestroyWidget(menu->submenu_id);
|
|
1675 menu->submenu_id = (Widget)0;
|
|
1676 }
|
|
1677
|
|
1678 if (menu->id != (Widget)0)
|
|
1679 {
|
|
1680 Widget parent;
|
|
1681
|
|
1682 parent = XtParent(menu->id);
|
|
1683 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL)
|
216
|
1684 if (parent == toolBar && menu->tip != NULL)
|
7
|
1685 {
|
|
1686 /* We try to destroy this before the actual menu, because there are
|
|
1687 * callbacks, etc. that will be unregistered during the tooltip
|
|
1688 * destruction.
|
|
1689 *
|
|
1690 * If you call "gui_mch_destroy_beval_area()" after destroying
|
|
1691 * menu->id, then the tooltip's window will have already been
|
|
1692 * deallocated by Xt, and unknown behaviour will ensue (probably
|
|
1693 * a core dump).
|
|
1694 */
|
|
1695 gui_mch_destroy_beval_area(menu->tip);
|
|
1696 menu->tip = NULL;
|
|
1697 }
|
|
1698 #endif
|
|
1699 XtDestroyWidget(menu->id);
|
|
1700 menu->id = (Widget)0;
|
|
1701 if (parent == menuBar)
|
|
1702 gui_mch_compute_menu_height((Widget)0);
|
|
1703 #ifdef FEAT_TOOLBAR
|
|
1704 else if (parent == toolBar)
|
|
1705 {
|
|
1706 Cardinal num_children;
|
|
1707
|
|
1708 /* When removing last toolbar item, don't display the toolbar. */
|
|
1709 XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL);
|
|
1710 if (num_children == 0)
|
|
1711 gui_mch_show_toolbar(FALSE);
|
|
1712 else
|
|
1713 gui.toolbar_height = gui_mch_compute_toolbar_height();
|
|
1714 }
|
|
1715 #endif
|
|
1716 }
|
|
1717 }
|
|
1718
|
|
1719 /* ARGSUSED */
|
|
1720 void
|
|
1721 gui_mch_show_popupmenu(menu)
|
|
1722 vimmenu_T *menu;
|
|
1723 {
|
|
1724 #ifdef MOTIF_POPUP
|
|
1725 XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event());
|
|
1726 XtManageChild(menu->submenu_id);
|
|
1727 #endif
|
|
1728 }
|
|
1729
|
|
1730 #endif /* FEAT_MENU */
|
|
1731
|
|
1732 /*
|
|
1733 * Set the menu and scrollbar colors to their default values.
|
|
1734 */
|
|
1735 void
|
|
1736 gui_mch_def_colors()
|
|
1737 {
|
|
1738 if (gui.in_use)
|
|
1739 {
|
|
1740 /* Use the values saved when starting up. These should come from the
|
|
1741 * window manager or a resources file. */
|
|
1742 gui.menu_fg_pixel = gui.menu_def_fg_pixel;
|
|
1743 gui.menu_bg_pixel = gui.menu_def_bg_pixel;
|
|
1744 gui.scroll_fg_pixel = gui.scroll_def_fg_pixel;
|
|
1745 gui.scroll_bg_pixel = gui.scroll_def_bg_pixel;
|
|
1746 #ifdef FEAT_BEVAL
|
|
1747 gui.tooltip_fg_pixel =
|
|
1748 gui_get_color((char_u *)gui.rsrc_tooltip_fg_name);
|
|
1749 gui.tooltip_bg_pixel =
|
|
1750 gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
|
|
1751 #endif
|
|
1752 }
|
|
1753 }
|
|
1754
|
|
1755
|
|
1756 /*
|
|
1757 * Scrollbar stuff.
|
|
1758 */
|
|
1759
|
|
1760 void
|
|
1761 gui_mch_set_scrollbar_thumb(sb, val, size, max)
|
|
1762 scrollbar_T *sb;
|
|
1763 long val;
|
|
1764 long size;
|
|
1765 long max;
|
|
1766 {
|
|
1767 if (sb->id != (Widget)0)
|
|
1768 XtVaSetValues(sb->id,
|
|
1769 XmNvalue, val,
|
|
1770 XmNsliderSize, size,
|
|
1771 XmNpageIncrement, (size > 2 ? size - 2 : 1),
|
|
1772 XmNmaximum, max + 1, /* Motif has max one past the end */
|
|
1773 NULL);
|
|
1774 }
|
|
1775
|
|
1776 void
|
|
1777 gui_mch_set_scrollbar_pos(sb, x, y, w, h)
|
|
1778 scrollbar_T *sb;
|
|
1779 int x;
|
|
1780 int y;
|
|
1781 int w;
|
|
1782 int h;
|
|
1783 {
|
|
1784 if (sb->id != (Widget)0)
|
|
1785 {
|
|
1786 if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT)
|
|
1787 {
|
|
1788 if (y == 0)
|
|
1789 h -= gui.border_offset;
|
|
1790 else
|
|
1791 y -= gui.border_offset;
|
|
1792 XtVaSetValues(sb->id,
|
|
1793 XmNtopOffset, y,
|
|
1794 XmNbottomOffset, -y - h,
|
|
1795 XmNwidth, w,
|
|
1796 NULL);
|
|
1797 }
|
|
1798 else
|
|
1799 XtVaSetValues(sb->id,
|
|
1800 XmNtopOffset, y,
|
|
1801 XmNleftOffset, x,
|
|
1802 XmNrightOffset, gui.which_scrollbars[SBAR_RIGHT]
|
|
1803 ? gui.scrollbar_width : 0,
|
|
1804 XmNheight, h,
|
|
1805 NULL);
|
|
1806 XtManageChild(sb->id);
|
|
1807 }
|
|
1808 }
|
|
1809
|
|
1810 void
|
|
1811 gui_mch_enable_scrollbar(sb, flag)
|
|
1812 scrollbar_T *sb;
|
|
1813 int flag;
|
|
1814 {
|
|
1815 Arg args[16];
|
|
1816 int n;
|
|
1817
|
|
1818 if (sb->id != (Widget)0)
|
|
1819 {
|
|
1820 n = 0;
|
|
1821 if (flag)
|
|
1822 {
|
|
1823 switch (sb->type)
|
|
1824 {
|
|
1825 case SBAR_LEFT:
|
|
1826 XtSetArg(args[n], XmNleftOffset, gui.scrollbar_width); n++;
|
|
1827 break;
|
|
1828
|
|
1829 case SBAR_RIGHT:
|
|
1830 XtSetArg(args[n], XmNrightOffset, gui.scrollbar_width); n++;
|
|
1831 break;
|
|
1832
|
|
1833 case SBAR_BOTTOM:
|
|
1834 XtSetArg(args[n], XmNbottomOffset, gui.scrollbar_height);n++;
|
|
1835 break;
|
|
1836 }
|
|
1837 XtSetValues(textArea, args, n);
|
|
1838 XtManageChild(sb->id);
|
|
1839 }
|
|
1840 else
|
|
1841 {
|
|
1842 if (!gui.which_scrollbars[sb->type])
|
|
1843 {
|
|
1844 /* The scrollbars of this type are all disabled, adjust the
|
|
1845 * textArea attachment offset. */
|
|
1846 switch (sb->type)
|
|
1847 {
|
|
1848 case SBAR_LEFT:
|
|
1849 XtSetArg(args[n], XmNleftOffset, 0); n++;
|
|
1850 break;
|
|
1851
|
|
1852 case SBAR_RIGHT:
|
|
1853 XtSetArg(args[n], XmNrightOffset, 0); n++;
|
|
1854 break;
|
|
1855
|
|
1856 case SBAR_BOTTOM:
|
|
1857 XtSetArg(args[n], XmNbottomOffset, 0);n++;
|
|
1858 break;
|
|
1859 }
|
|
1860 XtSetValues(textArea, args, n);
|
|
1861 }
|
|
1862 XtUnmanageChild(sb->id);
|
|
1863 }
|
|
1864 }
|
|
1865 }
|
|
1866
|
|
1867 void
|
|
1868 gui_mch_create_scrollbar(sb, orient)
|
|
1869 scrollbar_T *sb;
|
|
1870 int orient; /* SBAR_VERT or SBAR_HORIZ */
|
|
1871 {
|
|
1872 Arg args[16];
|
|
1873 int n;
|
|
1874
|
|
1875 n = 0;
|
|
1876 XtSetArg(args[n], XmNminimum, 0); n++;
|
|
1877 XtSetArg(args[n], XmNorientation,
|
|
1878 (orient == SBAR_VERT) ? XmVERTICAL : XmHORIZONTAL); n++;
|
|
1879
|
|
1880 switch (sb->type)
|
|
1881 {
|
|
1882 case SBAR_LEFT:
|
|
1883 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
|
1884 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_FORM); n++;
|
|
1885 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
|
1886 break;
|
|
1887
|
|
1888 case SBAR_RIGHT:
|
|
1889 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
|
1890 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_FORM); n++;
|
|
1891 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
|
1892 break;
|
|
1893
|
|
1894 case SBAR_BOTTOM:
|
|
1895 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
|
1896 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
|
1897 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
|
1898 break;
|
|
1899 }
|
|
1900
|
|
1901 sb->id = XtCreateWidget("scrollBar",
|
|
1902 xmScrollBarWidgetClass, textAreaForm, args, n);
|
|
1903
|
|
1904 /* Remember the default colors, needed for ":hi clear". */
|
|
1905 if (gui.scroll_def_bg_pixel == (guicolor_T)0
|
|
1906 && gui.scroll_def_fg_pixel == (guicolor_T)0)
|
|
1907 XtVaGetValues(sb->id,
|
|
1908 XmNbackground, &gui.scroll_def_bg_pixel,
|
|
1909 XmNforeground, &gui.scroll_def_fg_pixel,
|
|
1910 NULL);
|
|
1911
|
|
1912 if (sb->id != (Widget)0)
|
|
1913 {
|
|
1914 gui_mch_set_scrollbar_colors(sb);
|
|
1915 XtAddCallback(sb->id, XmNvalueChangedCallback,
|
|
1916 scroll_cb, (XtPointer)sb->ident);
|
|
1917 XtAddCallback(sb->id, XmNdragCallback,
|
|
1918 scroll_cb, (XtPointer)sb->ident);
|
|
1919 XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb,
|
|
1920 (XtPointer)0);
|
|
1921 }
|
|
1922 }
|
|
1923
|
|
1924 #if defined(FEAT_WINDOWS) || defined(PROTO)
|
|
1925 void
|
|
1926 gui_mch_destroy_scrollbar(sb)
|
|
1927 scrollbar_T *sb;
|
|
1928 {
|
|
1929 if (sb->id != (Widget)0)
|
|
1930 XtDestroyWidget(sb->id);
|
|
1931 }
|
|
1932 #endif
|
|
1933
|
|
1934 void
|
|
1935 gui_mch_set_scrollbar_colors(sb)
|
|
1936 scrollbar_T *sb;
|
|
1937 {
|
|
1938 if (sb->id != (Widget)0)
|
|
1939 {
|
|
1940 if (gui.scroll_bg_pixel != INVALCOLOR)
|
|
1941 {
|
|
1942 #if (XmVersion>=1002)
|
|
1943 XmChangeColor(sb->id, gui.scroll_bg_pixel);
|
|
1944 #else
|
|
1945 XtVaSetValues(sb->id,
|
|
1946 XmNtroughColor, gui.scroll_bg_pixel,
|
|
1947 NULL);
|
|
1948 #endif
|
|
1949 }
|
|
1950
|
|
1951 if (gui.scroll_fg_pixel != INVALCOLOR)
|
|
1952 XtVaSetValues(sb->id,
|
|
1953 XmNforeground, gui.scroll_fg_pixel,
|
|
1954 #if (XmVersion<1002)
|
|
1955 XmNbackground, gui.scroll_fg_pixel,
|
|
1956 #endif
|
|
1957 NULL);
|
|
1958 }
|
|
1959
|
|
1960 /* This is needed for the rectangle below the vertical scrollbars. */
|
|
1961 if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0)
|
|
1962 gui_motif_scroll_colors(textAreaForm);
|
|
1963 }
|
|
1964
|
|
1965 /*
|
|
1966 * Miscellaneous stuff:
|
|
1967 */
|
|
1968
|
|
1969 Window
|
|
1970 gui_x11_get_wid()
|
|
1971 {
|
|
1972 return(XtWindow(textArea));
|
|
1973 }
|
|
1974
|
44
|
1975 /*
|
|
1976 * Look for a widget in the widget tree w, with a mnemonic matching keycode.
|
|
1977 * When one is found, simulate a button press on that widget and give it the
|
|
1978 * keyboard focus. If the mnemonic is on a label, look in the userData field
|
|
1979 * of the label to see if it points to another widget, and give that the focus.
|
|
1980 */
|
|
1981 static void
|
|
1982 do_mnemonic(Widget w, unsigned int keycode)
|
|
1983 {
|
|
1984 WidgetList children;
|
|
1985 int numChildren, i;
|
|
1986 Boolean isMenu;
|
|
1987 KeySym mnemonic = '\0';
|
|
1988 char mneString[2];
|
|
1989 Widget userData;
|
|
1990 unsigned char rowColType;
|
|
1991
|
|
1992 if (XtIsComposite(w))
|
|
1993 {
|
|
1994 if (XtClass(w) == xmRowColumnWidgetClass)
|
|
1995 {
|
|
1996 XtVaGetValues(w, XmNrowColumnType, &rowColType, 0);
|
|
1997 isMenu = (rowColType != (unsigned char)XmWORK_AREA);
|
|
1998 }
|
|
1999 else
|
|
2000 isMenu = False;
|
|
2001 if (!isMenu)
|
|
2002 {
|
|
2003 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren,
|
|
2004 &numChildren, 0);
|
|
2005 for (i = 0; i < numChildren; i++)
|
|
2006 do_mnemonic(children[i], keycode);
|
|
2007 }
|
|
2008 }
|
|
2009 else
|
|
2010 {
|
|
2011 XtVaGetValues(w, XmNmnemonic, &mnemonic, 0);
|
|
2012 if (mnemonic != '\0')
|
|
2013 {
|
|
2014 mneString[0] = mnemonic;
|
|
2015 mneString[1] = '\0';
|
|
2016 if (XKeysymToKeycode(XtDisplay(XtParent(w)),
|
|
2017 XStringToKeysym(mneString)) == keycode)
|
|
2018 {
|
|
2019 if (XtClass(w) == xmLabelWidgetClass
|
|
2020 || XtClass(w) == xmLabelGadgetClass)
|
|
2021 {
|
|
2022 XtVaGetValues(w, XmNuserData, &userData, 0);
|
|
2023 if (userData != NULL && XtIsWidget(userData))
|
|
2024 XmProcessTraversal(userData, XmTRAVERSE_CURRENT);
|
|
2025 }
|
|
2026 else
|
|
2027 {
|
|
2028 XKeyPressedEvent keyEvent;
|
|
2029
|
|
2030 XmProcessTraversal(w, XmTRAVERSE_CURRENT);
|
|
2031
|
|
2032 memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent));
|
|
2033 keyEvent.type = KeyPress;
|
|
2034 keyEvent.serial = 1;
|
|
2035 keyEvent.send_event = True;
|
|
2036 keyEvent.display = XtDisplay(w);
|
|
2037 keyEvent.window = XtWindow(w);
|
|
2038 XtCallActionProc(w, "Activate", (XEvent *) & keyEvent,
|
|
2039 NULL, 0);
|
|
2040 }
|
|
2041 }
|
|
2042 }
|
|
2043 }
|
|
2044 }
|
|
2045
|
|
2046 /*
|
|
2047 * Callback routine for dialog mnemonic processing.
|
|
2048 */
|
|
2049 /*ARGSUSED*/
|
|
2050 static void
|
|
2051 mnemonic_event(Widget w, XtPointer call_data, XKeyEvent *event)
|
|
2052 {
|
|
2053 do_mnemonic(w, event->keycode);
|
|
2054 }
|
|
2055
|
|
2056
|
|
2057 /*
|
|
2058 * Search the widget tree under w for widgets with mnemonics. When found, add
|
|
2059 * a passive grab to the dialog widget for the mnemonic character, thus
|
|
2060 * directing mnemonic events to the dialog widget.
|
|
2061 */
|
|
2062 static void
|
|
2063 add_mnemonic_grabs(Widget dialog, Widget w)
|
|
2064 {
|
|
2065 char mneString[2];
|
|
2066 WidgetList children;
|
|
2067 int numChildren, i;
|
|
2068 Boolean isMenu;
|
|
2069 KeySym mnemonic = '\0';
|
|
2070 unsigned char rowColType;
|
|
2071
|
|
2072 if (XtIsComposite(w))
|
|
2073 {
|
|
2074 if (XtClass(w) == xmRowColumnWidgetClass)
|
|
2075 {
|
|
2076 XtVaGetValues(w, XmNrowColumnType, &rowColType, 0);
|
|
2077 isMenu = (rowColType != (unsigned char)XmWORK_AREA);
|
|
2078 }
|
|
2079 else
|
|
2080 isMenu = False;
|
|
2081 if (!isMenu)
|
|
2082 {
|
|
2083 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren,
|
|
2084 &numChildren, 0);
|
|
2085 for (i = 0; i < numChildren; i++)
|
|
2086 add_mnemonic_grabs(dialog, children[i]);
|
|
2087 }
|
|
2088 }
|
|
2089 else
|
|
2090 {
|
|
2091 XtVaGetValues(w, XmNmnemonic, &mnemonic, 0);
|
|
2092 if (mnemonic != '\0')
|
|
2093 {
|
|
2094 mneString[0] = mnemonic;
|
|
2095 mneString[1] = '\0';
|
|
2096 XtGrabKey(dialog, XKeysymToKeycode(XtDisplay(dialog),
|
|
2097 XStringToKeysym(mneString)),
|
|
2098 Mod1Mask, True, GrabModeAsync, GrabModeAsync);
|
|
2099 }
|
|
2100 }
|
|
2101 }
|
|
2102
|
|
2103 /*
|
|
2104 * Add a handler for mnemonics in a dialog. Motif itself only handles
|
|
2105 * mnemonics in menus. Mnemonics added or changed after this call will be
|
|
2106 * ignored.
|
|
2107 *
|
|
2108 * To add a mnemonic to a text field or list, set the XmNmnemonic resource on
|
|
2109 * the appropriate label and set the XmNuserData resource of the label to the
|
|
2110 * widget to get the focus when the mnemonic is typed.
|
|
2111 */
|
|
2112 static void
|
|
2113 activate_dialog_mnemonics(Widget dialog)
|
|
2114 {
|
|
2115 if (!dialog)
|
|
2116 return;
|
|
2117
|
|
2118 XtAddEventHandler(dialog, KeyPressMask, False,
|
|
2119 (XtEventHandler) mnemonic_event, (XtPointer) NULL);
|
|
2120 add_mnemonic_grabs(dialog, dialog);
|
|
2121 }
|
|
2122
|
|
2123 /*
|
|
2124 * Removes the event handler and key-grabs for dialog mnemonic handling.
|
|
2125 */
|
|
2126 static void
|
|
2127 suppress_dialog_mnemonics(Widget dialog)
|
|
2128 {
|
|
2129 if (!dialog)
|
|
2130 return;
|
|
2131
|
|
2132 XtUngrabKey(dialog, AnyKey, Mod1Mask);
|
|
2133 XtRemoveEventHandler(dialog, KeyPressMask, False,
|
|
2134 (XtEventHandler) mnemonic_event, (XtPointer) NULL);
|
|
2135 }
|
|
2136
|
|
2137 #if defined(FEAT_BROWSE) || defined(FEAT_GUI_DIALOG)
|
|
2138 static void set_fontlist __ARGS((Widget wg));
|
|
2139
|
|
2140 /*
|
|
2141 * Use the 'guifont' or 'guifontset' as a fontlist for a dialog widget.
|
|
2142 */
|
|
2143 static void
|
|
2144 set_fontlist(id)
|
|
2145 Widget id;
|
|
2146 {
|
|
2147 XmFontList fl;
|
|
2148
|
|
2149 #ifdef FONTSET_ALWAYS
|
48
|
2150 if (gui.fontset != NOFONTSET)
|
|
2151 {
|
44
|
2152 fl = gui_motif_fontset2fontlist((XFontSet *)&gui.fontset);
|
|
2153 if (fl != NULL)
|
|
2154 {
|
|
2155 if (XtIsManaged(id))
|
|
2156 {
|
|
2157 XtUnmanageChild(id);
|
|
2158 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
2159 /* We should force the widget to recalculate it's
|
|
2160 * geometry now. */
|
|
2161 XtManageChild(id);
|
|
2162 }
|
|
2163 else
|
|
2164 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
2165 XmFontListFree(fl);
|
|
2166 }
|
|
2167 }
|
|
2168 #else
|
48
|
2169 if (gui.norm_font != NOFONT)
|
|
2170 {
|
44
|
2171 fl = gui_motif_create_fontlist((XFontStruct *)gui.norm_font);
|
|
2172 if (fl != NULL)
|
|
2173 {
|
|
2174 if (XtIsManaged(id))
|
|
2175 {
|
|
2176 XtUnmanageChild(id);
|
|
2177 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
2178 /* We should force the widget to recalculate it's
|
|
2179 * geometry now. */
|
|
2180 XtManageChild(id);
|
|
2181 }
|
|
2182 else
|
|
2183 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
2184 XmFontListFree(fl);
|
|
2185 }
|
|
2186 }
|
|
2187 #endif
|
|
2188 }
|
|
2189 #endif
|
7
|
2190
|
|
2191 #if defined(FEAT_BROWSE) || defined(PROTO)
|
|
2192
|
|
2193 /*
|
|
2194 * file selector related stuff
|
|
2195 */
|
|
2196
|
|
2197 #include <Xm/FileSB.h>
|
|
2198 #include <Xm/XmStrDefs.h>
|
|
2199
|
|
2200 typedef struct dialog_callback_arg
|
|
2201 {
|
|
2202 char * args; /* not used right now */
|
|
2203 int id;
|
|
2204 } dcbarg_T;
|
|
2205
|
|
2206 static Widget dialog_wgt;
|
|
2207 static char *browse_fname = NULL;
|
|
2208 static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
|
|
2209 /* used to set up XmStrings */
|
|
2210
|
|
2211 static void DialogCancelCB __ARGS((Widget, XtPointer, XtPointer));
|
|
2212 static void DialogAcceptCB __ARGS((Widget, XtPointer, XtPointer));
|
|
2213
|
|
2214 /*
|
|
2215 * This function is used to translate the predefined label text of the
|
|
2216 * precomposed dialogs. We do this explicitly to allow:
|
|
2217 *
|
|
2218 * - usage of gettext for translation, as in all the other places.
|
|
2219 *
|
|
2220 * - equalize the messages between different GUI implementations as far as
|
|
2221 * possible.
|
|
2222 */
|
44
|
2223 static void set_predefined_label __ARGS((Widget parent, String name, char *new_label));
|
7
|
2224
|
|
2225 static void
|
|
2226 set_predefined_label(parent, name, new_label)
|
44
|
2227 Widget parent;
|
|
2228 String name;
|
|
2229 char *new_label;
|
7
|
2230 {
|
44
|
2231 XmString str;
|
|
2232 Widget w;
|
|
2233 char_u *p, *next;
|
|
2234 KeySym mnemonic = NUL;
|
7
|
2235
|
|
2236 w = XtNameToWidget(parent, name);
|
|
2237
|
|
2238 if (!w)
|
|
2239 return;
|
|
2240
|
44
|
2241 p = vim_strsave((char_u *)new_label);
|
|
2242 if (p == NULL)
|
|
2243 return;
|
|
2244 for (next = p; *next; ++next)
|
7
|
2245 {
|
44
|
2246 if (*next == DLG_HOTKEY_CHAR)
|
|
2247 {
|
|
2248 int len = STRLEN(next);
|
|
2249
|
|
2250 if (len > 0)
|
|
2251 {
|
|
2252 mch_memmove(next, next + 1, len);
|
|
2253 mnemonic = next[0];
|
|
2254 }
|
|
2255 }
|
|
2256 }
|
|
2257
|
|
2258 str = XmStringCreate((char *)p, STRING_TAG);
|
|
2259 vim_free(p);
|
|
2260
|
|
2261 if (str != NULL)
|
|
2262 {
|
|
2263 XtVaSetValues(w,
|
|
2264 XmNlabelString, str,
|
|
2265 XmNmnemonic, mnemonic,
|
|
2266 NULL);
|
7
|
2267 XmStringFree(str);
|
|
2268 }
|
44
|
2269 gui_motif_menu_fontlist(w);
|
|
2270 }
|
|
2271
|
|
2272 static void
|
|
2273 set_predefined_fontlist(parent, name)
|
|
2274 Widget parent;
|
|
2275 String name;
|
|
2276 {
|
|
2277 Widget w;
|
|
2278 w = XtNameToWidget(parent, name);
|
|
2279
|
|
2280 if (!w)
|
|
2281 return;
|
|
2282
|
|
2283 set_fontlist(w);
|
7
|
2284 }
|
|
2285
|
|
2286 /*
|
|
2287 * Put up a file requester.
|
|
2288 * Returns the selected name in allocated memory, or NULL for Cancel.
|
|
2289 */
|
|
2290 /* ARGSUSED */
|
|
2291 char_u *
|
|
2292 gui_mch_browse(saving, title, dflt, ext, initdir, filter)
|
|
2293 int saving; /* select file to write */
|
|
2294 char_u *title; /* title for the window */
|
|
2295 char_u *dflt; /* default name */
|
|
2296 char_u *ext; /* not used (extension added) */
|
|
2297 char_u *initdir; /* initial directory, NULL for current dir */
|
|
2298 char_u *filter; /* file name filter */
|
|
2299 {
|
|
2300 char_u dirbuf[MAXPATHL];
|
|
2301 char_u dfltbuf[MAXPATHL];
|
|
2302 char_u *pattern;
|
|
2303 char_u *tofree = NULL;
|
|
2304
|
44
|
2305 /* There a difference between the resource name and value, Therefore, we
|
|
2306 * avoid to (ab-)use the (maybe internationalized!) dialog title as a
|
|
2307 * dialog name.
|
|
2308 */
|
|
2309
|
|
2310 dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0);
|
7
|
2311
|
|
2312 if (initdir == NULL || *initdir == NUL)
|
|
2313 {
|
|
2314 mch_dirname(dirbuf, MAXPATHL);
|
|
2315 initdir = dirbuf;
|
|
2316 }
|
|
2317
|
|
2318 if (dflt == NULL)
|
|
2319 dflt = (char_u *)"";
|
|
2320 else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL)
|
|
2321 {
|
|
2322 /* The default selection should be the full path, "dflt" is only the
|
|
2323 * file name. */
|
|
2324 STRCPY(dfltbuf, initdir);
|
|
2325 add_pathsep(dfltbuf);
|
|
2326 STRCAT(dfltbuf, dflt);
|
|
2327 dflt = dfltbuf;
|
|
2328 }
|
|
2329
|
|
2330 /* Can only use one pattern for a file name. Get the first pattern out of
|
|
2331 * the filter. An empty pattern means everything matches. */
|
|
2332 if (filter == NULL)
|
|
2333 pattern = (char_u *)"";
|
|
2334 else
|
|
2335 {
|
|
2336 char_u *s, *p;
|
|
2337
|
|
2338 s = filter;
|
|
2339 for (p = filter; *p != NUL; ++p)
|
|
2340 {
|
|
2341 if (*p == '\t') /* end of description, start of pattern */
|
|
2342 s = p + 1;
|
|
2343 if (*p == ';' || *p == '\n') /* end of (first) pattern */
|
|
2344 break;
|
|
2345 }
|
|
2346 pattern = vim_strnsave(s, p - s);
|
|
2347 tofree = pattern;
|
|
2348 if (pattern == NULL)
|
|
2349 pattern = (char_u *)"";
|
|
2350 }
|
|
2351
|
|
2352 XtVaSetValues(dialog_wgt,
|
|
2353 XtVaTypedArg,
|
|
2354 XmNdirectory, XmRString, (char *)initdir, STRLEN(initdir) + 1,
|
|
2355 XtVaTypedArg,
|
|
2356 XmNdirSpec, XmRString, (char *)dflt, STRLEN(dflt) + 1,
|
|
2357 XtVaTypedArg,
|
|
2358 XmNpattern, XmRString, (char *)pattern, STRLEN(pattern) + 1,
|
|
2359 XtVaTypedArg,
|
|
2360 XmNdialogTitle, XmRString, (char *)title, STRLEN(title) + 1,
|
|
2361 NULL);
|
|
2362
|
44
|
2363 set_predefined_label(dialog_wgt, "Apply", _("&Filter"));
|
|
2364 set_predefined_label(dialog_wgt, "Cancel", _("&Cancel"));
|
7
|
2365 set_predefined_label(dialog_wgt, "Dir", _("Directories"));
|
|
2366 set_predefined_label(dialog_wgt, "FilterLabel", _("Filter"));
|
44
|
2367 set_predefined_label(dialog_wgt, "Help", _("&Help"));
|
7
|
2368 set_predefined_label(dialog_wgt, "Items", _("Files"));
|
44
|
2369 set_predefined_label(dialog_wgt, "OK", _("&OK"));
|
7
|
2370 set_predefined_label(dialog_wgt, "Selection", _("Selection"));
|
|
2371
|
44
|
2372 /* This is to save us from silly external settings using not fixed with
|
|
2373 * fonts for file selection.
|
|
2374 */
|
|
2375 set_predefined_fontlist(dialog_wgt, "DirListSW.DirList");
|
|
2376 set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList");
|
|
2377
|
7
|
2378 gui_motif_menu_colors(dialog_wgt);
|
|
2379 if (gui.scroll_bg_pixel != INVALCOLOR)
|
|
2380 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL);
|
|
2381
|
|
2382 XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0);
|
|
2383 XtAddCallback(dialog_wgt, XmNcancelCallback, DialogCancelCB, (XtPointer)0);
|
|
2384 /* We have no help in this window, so hide help button */
|
|
2385 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt,
|
|
2386 (unsigned char)XmDIALOG_HELP_BUTTON));
|
|
2387
|
|
2388 manage_centered(dialog_wgt);
|
44
|
2389 activate_dialog_mnemonics(dialog_wgt);
|
7
|
2390
|
|
2391 /* sit in a loop until the dialog box has gone away */
|
|
2392 do
|
|
2393 {
|
|
2394 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt),
|
|
2395 (XtInputMask)XtIMAll);
|
|
2396 } while (XtIsManaged(dialog_wgt));
|
|
2397
|
44
|
2398 suppress_dialog_mnemonics(dialog_wgt);
|
7
|
2399 XtDestroyWidget(dialog_wgt);
|
|
2400 vim_free(tofree);
|
|
2401
|
|
2402 if (browse_fname == NULL)
|
|
2403 return NULL;
|
|
2404 return vim_strsave((char_u *)browse_fname);
|
|
2405 }
|
|
2406
|
|
2407 /*
|
|
2408 * The code below was originally taken from
|
|
2409 * /usr/examples/motif/xmsamplers/xmeditor.c
|
|
2410 * on Digital Unix 4.0d, but heavily modified.
|
|
2411 */
|
|
2412
|
|
2413 /*
|
|
2414 * Process callback from Dialog cancel actions.
|
|
2415 */
|
|
2416 /* ARGSUSED */
|
|
2417 static void
|
|
2418 DialogCancelCB(w, client_data, call_data)
|
|
2419 Widget w; /* widget id */
|
|
2420 XtPointer client_data; /* data from application */
|
|
2421 XtPointer call_data; /* data from widget class */
|
|
2422 {
|
|
2423 if (browse_fname != NULL)
|
|
2424 {
|
|
2425 XtFree(browse_fname);
|
|
2426 browse_fname = NULL;
|
|
2427 }
|
|
2428 XtUnmanageChild(dialog_wgt);
|
|
2429 }
|
|
2430
|
|
2431 /*
|
|
2432 * Process callback from Dialog actions.
|
|
2433 */
|
|
2434 /* ARGSUSED */
|
|
2435 static void
|
|
2436 DialogAcceptCB(w, client_data, call_data)
|
|
2437 Widget w; /* widget id */
|
|
2438 XtPointer client_data; /* data from application */
|
|
2439 XtPointer call_data; /* data from widget class */
|
|
2440 {
|
|
2441 XmFileSelectionBoxCallbackStruct *fcb;
|
|
2442
|
|
2443 if (browse_fname != NULL)
|
|
2444 {
|
|
2445 XtFree(browse_fname);
|
|
2446 browse_fname = NULL;
|
|
2447 }
|
|
2448 fcb = (XmFileSelectionBoxCallbackStruct *)call_data;
|
|
2449
|
|
2450 /* get the filename from the file selection box */
|
|
2451 XmStringGetLtoR(fcb->value, charset, &browse_fname);
|
|
2452
|
|
2453 /* popdown the file selection box */
|
|
2454 XtUnmanageChild(dialog_wgt);
|
|
2455 }
|
|
2456
|
|
2457 #endif /* FEAT_BROWSE */
|
|
2458
|
|
2459 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
|
|
2460
|
|
2461 static int dialogStatus;
|
|
2462
|
|
2463 static void keyhit_callback __ARGS((Widget w, XtPointer client_data, XEvent *event, Boolean *cont));
|
|
2464 static void butproc __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
2465
|
|
2466 /*
|
|
2467 * Callback function for the textfield. When CR is hit this works like
|
|
2468 * hitting the "OK" button, ESC like "Cancel".
|
|
2469 */
|
|
2470 /* ARGSUSED */
|
|
2471 static void
|
|
2472 keyhit_callback(w, client_data, event, cont)
|
|
2473 Widget w;
|
|
2474 XtPointer client_data;
|
|
2475 XEvent *event;
|
|
2476 Boolean *cont;
|
|
2477 {
|
|
2478 char buf[2];
|
|
2479 KeySym key_sym;
|
|
2480
|
|
2481 if (XLookupString(&(event->xkey), buf, 2, &key_sym, NULL) == 1)
|
|
2482 {
|
|
2483 if (*buf == CAR)
|
|
2484 dialogStatus = 1;
|
|
2485 else if (*buf == ESC)
|
|
2486 dialogStatus = 2;
|
|
2487 }
|
|
2488 if ((key_sym == XK_Left || key_sym == XK_Right)
|
|
2489 && !(event->xkey.state & ShiftMask))
|
|
2490 XmTextFieldClearSelection(w, XtLastTimestampProcessed(gui.dpy));
|
|
2491 }
|
|
2492
|
|
2493 /* ARGSUSED */
|
|
2494 static void
|
|
2495 butproc(w, client_data, call_data)
|
|
2496 Widget w;
|
|
2497 XtPointer client_data;
|
|
2498 XtPointer call_data;
|
|
2499 {
|
|
2500 dialogStatus = (int)(long)client_data + 1;
|
|
2501 }
|
|
2502
|
|
2503 #ifdef HAVE_XPM
|
|
2504
|
|
2505 static Widget create_pixmap_label(Widget parent, String name, char **data, ArgList args, Cardinal arg);
|
|
2506
|
|
2507 static Widget
|
|
2508 create_pixmap_label(parent, name, data, args, arg)
|
|
2509 Widget parent;
|
|
2510 String name;
|
|
2511 char **data;
|
|
2512 ArgList args;
|
|
2513 Cardinal arg;
|
|
2514 {
|
|
2515 Widget label;
|
|
2516 Display *dsp;
|
|
2517 Screen *scr;
|
|
2518 int depth;
|
|
2519 Pixmap pixmap = 0;
|
|
2520 XpmAttributes attr;
|
|
2521 Boolean rs;
|
|
2522 XpmColorSymbol color[5] =
|
|
2523 {
|
|
2524 {"none", NULL, 0},
|
|
2525 {"iconColor1", NULL, 0},
|
|
2526 {"bottomShadowColor", NULL, 0},
|
|
2527 {"topShadowColor", NULL, 0},
|
|
2528 {"selectColor", NULL, 0}
|
|
2529 };
|
|
2530
|
|
2531 label = XmCreateLabelGadget(parent, name, args, arg);
|
|
2532
|
|
2533 /*
|
|
2534 * We need to be carefull here, since in case of gadgets, there is
|
|
2535 * no way to get the background color directly from the widget itself.
|
|
2536 * In such cases we get it from The Core part of his parent instead.
|
|
2537 */
|
|
2538 dsp = XtDisplayOfObject(label);
|
|
2539 scr = XtScreenOfObject(label);
|
|
2540 XtVaGetValues(XtIsSubclass(label, coreWidgetClass)
|
|
2541 ? label : XtParent(label),
|
|
2542 XmNdepth, &depth,
|
|
2543 XmNbackground, &color[0].pixel,
|
|
2544 XmNforeground, &color[1].pixel,
|
|
2545 XmNbottomShadowColor, &color[2].pixel,
|
|
2546 XmNtopShadowColor, &color[3].pixel,
|
|
2547 XmNhighlight, &color[4].pixel,
|
|
2548 NULL);
|
|
2549
|
|
2550 attr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
|
|
2551 attr.colorsymbols = color;
|
|
2552 attr.numsymbols = 5;
|
|
2553 attr.closeness = 65535;
|
|
2554 attr.depth = depth;
|
|
2555 XpmCreatePixmapFromData(dsp, RootWindowOfScreen(scr),
|
|
2556 data, &pixmap, NULL, &attr);
|
|
2557
|
|
2558 XtVaGetValues(label, XmNrecomputeSize, &rs, NULL);
|
|
2559 XtVaSetValues(label, XmNrecomputeSize, True, NULL);
|
|
2560 XtVaSetValues(label,
|
|
2561 XmNlabelType, XmPIXMAP,
|
|
2562 XmNlabelPixmap, pixmap,
|
|
2563 NULL);
|
|
2564 XtVaSetValues(label, XmNrecomputeSize, rs, NULL);
|
|
2565
|
|
2566 return label;
|
|
2567 }
|
|
2568 #endif
|
|
2569
|
|
2570 /* ARGSUSED */
|
|
2571 int
|
|
2572 gui_mch_dialog(type, title, message, button_names, dfltbutton, textfield)
|
|
2573 int type;
|
|
2574 char_u *title;
|
|
2575 char_u *message;
|
|
2576 char_u *button_names;
|
|
2577 int dfltbutton;
|
|
2578 char_u *textfield; /* buffer of size IOSIZE */
|
|
2579 {
|
|
2580 char_u *buts;
|
|
2581 char_u *p, *next;
|
|
2582 XtAppContext app;
|
|
2583 XmString label;
|
|
2584 int butcount;
|
44
|
2585 Widget w;
|
7
|
2586 Widget dialogform = NULL;
|
|
2587 Widget form = NULL;
|
|
2588 Widget dialogtextfield = NULL;
|
|
2589 Widget *buttons;
|
|
2590 Widget sep_form = NULL;
|
|
2591 Boolean vertical;
|
|
2592 Widget separator = NULL;
|
|
2593 int n;
|
|
2594 Arg args[6];
|
|
2595 #ifdef HAVE_XPM
|
|
2596 char **icon_data = NULL;
|
|
2597 Widget dialogpixmap = NULL;
|
|
2598 #endif
|
|
2599
|
|
2600 if (title == NULL)
|
|
2601 title = (char_u *)_("Vim dialog");
|
|
2602
|
|
2603 /* if our pointer is currently hidden, then we should show it. */
|
|
2604 gui_mch_mousehide(FALSE);
|
|
2605
|
|
2606 dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0);
|
|
2607
|
|
2608 /* Check 'v' flag in 'guioptions': vertical button placement. */
|
|
2609 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
|
|
2610
|
|
2611 /* Set the title of the Dialog window */
|
|
2612 label = XmStringCreateSimple((char *)title);
|
|
2613 if (label == NULL)
|
|
2614 return -1;
|
|
2615 XtVaSetValues(dialogform,
|
|
2616 XmNdialogTitle, label,
|
|
2617 XmNhorizontalSpacing, 4,
|
|
2618 XmNverticalSpacing, vertical ? 0 : 4,
|
|
2619 NULL);
|
|
2620 XmStringFree(label);
|
|
2621
|
|
2622 /* make a copy, so that we can insert NULs */
|
|
2623 buts = vim_strsave(button_names);
|
|
2624 if (buts == NULL)
|
|
2625 return -1;
|
|
2626
|
|
2627 /* Count the number of buttons and allocate buttons[]. */
|
|
2628 butcount = 1;
|
|
2629 for (p = buts; *p; ++p)
|
|
2630 if (*p == DLG_BUTTON_SEP)
|
|
2631 ++butcount;
|
|
2632 buttons = (Widget *)alloc((unsigned)(butcount * sizeof(Widget)));
|
|
2633 if (buttons == NULL)
|
|
2634 {
|
|
2635 vim_free(buts);
|
|
2636 return -1;
|
|
2637 }
|
|
2638
|
|
2639 /*
|
|
2640 * Create the buttons.
|
|
2641 */
|
|
2642 sep_form = (Widget) 0;
|
|
2643 p = buts;
|
|
2644 for (butcount = 0; *p; ++butcount)
|
|
2645 {
|
44
|
2646 KeySym mnemonic = NUL;
|
|
2647
|
7
|
2648 for (next = p; *next; ++next)
|
|
2649 {
|
|
2650 if (*next == DLG_HOTKEY_CHAR)
|
44
|
2651 {
|
|
2652 int len = STRLEN(next);
|
|
2653
|
|
2654 if (len > 0)
|
|
2655 {
|
|
2656 mch_memmove(next, next + 1, len);
|
|
2657 mnemonic = next[0];
|
|
2658 }
|
|
2659 }
|
7
|
2660 if (*next == DLG_BUTTON_SEP)
|
|
2661 {
|
|
2662 *next++ = NUL;
|
|
2663 break;
|
|
2664 }
|
|
2665 }
|
|
2666 label = XmStringCreate(_((char *)p), STRING_TAG);
|
|
2667 if (label == NULL)
|
|
2668 break;
|
|
2669
|
|
2670 buttons[butcount] = XtVaCreateManagedWidget("button",
|
|
2671 xmPushButtonWidgetClass, dialogform,
|
|
2672 XmNlabelString, label,
|
44
|
2673 XmNmnemonic, mnemonic,
|
7
|
2674 XmNbottomAttachment, XmATTACH_FORM,
|
|
2675 XmNbottomOffset, 4,
|
|
2676 XmNshowAsDefault, butcount == dfltbutton - 1,
|
|
2677 XmNdefaultButtonShadowThickness, 1,
|
|
2678 NULL);
|
|
2679 XmStringFree(label);
|
44
|
2680 gui_motif_menu_fontlist(buttons[butcount]);
|
7
|
2681
|
|
2682 /* Layout properly. */
|
|
2683
|
|
2684 if (butcount > 0)
|
|
2685 {
|
|
2686 if (vertical)
|
|
2687 XtVaSetValues(buttons[butcount],
|
|
2688 XmNtopWidget, buttons[butcount - 1],
|
|
2689 NULL);
|
|
2690 else
|
|
2691 {
|
|
2692 if (*next == NUL)
|
|
2693 {
|
|
2694 XtVaSetValues(buttons[butcount],
|
|
2695 XmNrightAttachment, XmATTACH_FORM,
|
|
2696 XmNrightOffset, 4,
|
|
2697 NULL);
|
|
2698
|
|
2699 /* fill in a form as invisible separator */
|
|
2700 sep_form = XtVaCreateWidget("separatorForm",
|
|
2701 xmFormWidgetClass, dialogform,
|
|
2702 XmNleftAttachment, XmATTACH_WIDGET,
|
|
2703 XmNleftWidget, buttons[butcount - 1],
|
|
2704 XmNrightAttachment, XmATTACH_WIDGET,
|
|
2705 XmNrightWidget, buttons[butcount],
|
|
2706 XmNbottomAttachment, XmATTACH_FORM,
|
|
2707 XmNbottomOffset, 4,
|
|
2708 NULL);
|
|
2709 XtManageChild(sep_form);
|
|
2710 }
|
|
2711 else
|
|
2712 {
|
|
2713 XtVaSetValues(buttons[butcount],
|
|
2714 XmNleftAttachment, XmATTACH_WIDGET,
|
|
2715 XmNleftWidget, buttons[butcount - 1],
|
|
2716 NULL);
|
|
2717 }
|
|
2718 }
|
|
2719 }
|
|
2720 else if (!vertical)
|
|
2721 {
|
|
2722 if (*next == NUL)
|
|
2723 {
|
|
2724 XtVaSetValues(buttons[0],
|
|
2725 XmNrightAttachment, XmATTACH_FORM,
|
|
2726 XmNrightOffset, 4,
|
|
2727 NULL);
|
|
2728
|
|
2729 /* fill in a form as invisible separator */
|
|
2730 sep_form = XtVaCreateWidget("separatorForm",
|
|
2731 xmFormWidgetClass, dialogform,
|
|
2732 XmNleftAttachment, XmATTACH_FORM,
|
|
2733 XmNleftOffset, 4,
|
|
2734 XmNrightAttachment, XmATTACH_WIDGET,
|
|
2735 XmNrightWidget, buttons[0],
|
|
2736 XmNbottomAttachment, XmATTACH_FORM,
|
|
2737 XmNbottomOffset, 4,
|
|
2738 NULL);
|
|
2739 XtManageChild(sep_form);
|
|
2740 }
|
|
2741 else
|
|
2742 XtVaSetValues(buttons[0],
|
|
2743 XmNleftAttachment, XmATTACH_FORM,
|
|
2744 XmNleftOffset, 4,
|
|
2745 NULL);
|
|
2746 }
|
|
2747
|
|
2748 XtAddCallback(buttons[butcount], XmNactivateCallback,
|
|
2749 (XtCallbackProc)butproc, (XtPointer)(long)butcount);
|
|
2750 p = next;
|
|
2751 }
|
|
2752 vim_free(buts);
|
|
2753
|
|
2754 separator = (Widget) 0;
|
|
2755 if (butcount > 0)
|
|
2756 {
|
|
2757 /* Create the separator for beauty. */
|
|
2758 n = 0;
|
|
2759 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
|
|
2760 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
|
|
2761 XtSetArg(args[n], XmNbottomWidget, buttons[0]); n++;
|
|
2762 XtSetArg(args[n], XmNbottomOffset, 4); n++;
|
|
2763 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
|
2764 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
|
2765 separator = XmCreateSeparatorGadget(dialogform, "separator", args, n);
|
|
2766 XtManageChild(separator);
|
|
2767 }
|
|
2768
|
|
2769 if (textfield != NULL)
|
|
2770 {
|
|
2771 dialogtextfield = XtVaCreateWidget("textField",
|
|
2772 xmTextFieldWidgetClass, dialogform,
|
|
2773 XmNleftAttachment, XmATTACH_FORM,
|
|
2774 XmNrightAttachment, XmATTACH_FORM,
|
|
2775 NULL);
|
|
2776 if (butcount > 0)
|
|
2777 XtVaSetValues(dialogtextfield,
|
|
2778 XmNbottomAttachment, XmATTACH_WIDGET,
|
|
2779 XmNbottomWidget, separator,
|
|
2780 NULL);
|
|
2781 else
|
|
2782 XtVaSetValues(dialogtextfield,
|
|
2783 XmNbottomAttachment, XmATTACH_FORM,
|
|
2784 NULL);
|
|
2785
|
44
|
2786 set_fontlist(dialogtextfield);
|
7
|
2787 XmTextFieldSetString(dialogtextfield, (char *)textfield);
|
|
2788 XtManageChild(dialogtextfield);
|
|
2789 XtAddEventHandler(dialogtextfield, KeyPressMask, False,
|
|
2790 (XtEventHandler)keyhit_callback, (XtPointer)NULL);
|
|
2791 }
|
|
2792
|
|
2793 /* Form holding both message and pixmap labels */
|
|
2794 form = XtVaCreateWidget("separatorForm",
|
|
2795 xmFormWidgetClass, dialogform,
|
|
2796 XmNleftAttachment, XmATTACH_FORM,
|
|
2797 XmNrightAttachment, XmATTACH_FORM,
|
|
2798 XmNtopAttachment, XmATTACH_FORM,
|
|
2799 NULL);
|
|
2800 XtManageChild(form);
|
|
2801
|
|
2802 #ifdef HAVE_XPM
|
|
2803 /* Add a pixmap, left of the message. */
|
|
2804 switch (type)
|
|
2805 {
|
|
2806 case VIM_GENERIC:
|
|
2807 icon_data = generic_xpm;
|
|
2808 break;
|
|
2809 case VIM_ERROR:
|
|
2810 icon_data = error_xpm;
|
|
2811 break;
|
|
2812 case VIM_WARNING:
|
|
2813 icon_data = alert_xpm;
|
|
2814 break;
|
|
2815 case VIM_INFO:
|
|
2816 icon_data = info_xpm;
|
|
2817 break;
|
|
2818 case VIM_QUESTION:
|
|
2819 icon_data = quest_xpm;
|
|
2820 break;
|
|
2821 default:
|
|
2822 icon_data = generic_xpm;
|
|
2823 }
|
|
2824
|
|
2825 n = 0;
|
|
2826 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
|
2827 XtSetArg(args[n], XmNtopOffset, 8); n++;
|
|
2828 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
|
2829 XtSetArg(args[n], XmNbottomOffset, 8); n++;
|
|
2830 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
|
2831 XtSetArg(args[n], XmNleftOffset, 8); n++;
|
|
2832
|
|
2833 dialogpixmap = create_pixmap_label(form, "dialogPixmap",
|
|
2834 icon_data, args, n);
|
|
2835 XtManageChild(dialogpixmap);
|
|
2836 #endif
|
|
2837
|
44
|
2838 /* Create the dialog message.
|
|
2839 * Since LessTif is apparently having problems with the creation of
|
|
2840 * properly localized string, we use LtoR here. The symptom is that the
|
|
2841 * string sill not show properly in multiple lines as it does in native
|
|
2842 * Motif.
|
|
2843 */
|
|
2844 label = XmStringCreateLtoR((char *)message, STRING_TAG);
|
7
|
2845 if (label == NULL)
|
|
2846 return -1;
|
44
|
2847 w = XtVaCreateManagedWidget("dialogMessage",
|
7
|
2848 xmLabelGadgetClass, form,
|
|
2849 XmNlabelString, label,
|
44
|
2850 XmNalignment, XmALIGNMENT_BEGINNING,
|
7
|
2851 XmNtopAttachment, XmATTACH_FORM,
|
|
2852 XmNtopOffset, 8,
|
|
2853 #ifdef HAVE_XPM
|
|
2854 XmNleftAttachment, XmATTACH_WIDGET,
|
|
2855 XmNleftWidget, dialogpixmap,
|
|
2856 #else
|
|
2857 XmNleftAttachment, XmATTACH_FORM,
|
|
2858 #endif
|
|
2859 XmNleftOffset, 8,
|
|
2860 XmNrightAttachment, XmATTACH_FORM,
|
|
2861 XmNrightOffset, 8,
|
|
2862 XmNbottomAttachment, XmATTACH_FORM,
|
|
2863 XmNbottomOffset, 8,
|
|
2864 NULL);
|
|
2865 XmStringFree(label);
|
44
|
2866 set_fontlist(w);
|
7
|
2867
|
|
2868 if (textfield != NULL)
|
|
2869 {
|
|
2870 XtVaSetValues(form,
|
|
2871 XmNbottomAttachment, XmATTACH_WIDGET,
|
|
2872 XmNbottomWidget, dialogtextfield,
|
|
2873 NULL);
|
|
2874 }
|
|
2875 else
|
|
2876 {
|
|
2877 if (butcount > 0)
|
|
2878 XtVaSetValues(form,
|
|
2879 XmNbottomAttachment, XmATTACH_WIDGET,
|
|
2880 XmNbottomWidget, separator,
|
|
2881 NULL);
|
|
2882 else
|
|
2883 XtVaSetValues(form,
|
|
2884 XmNbottomAttachment, XmATTACH_FORM,
|
|
2885 NULL);
|
|
2886 }
|
|
2887
|
|
2888 if (dfltbutton < 1)
|
|
2889 dfltbutton = 1;
|
|
2890 if (dfltbutton > butcount)
|
|
2891 dfltbutton = butcount;
|
|
2892 XtVaSetValues(dialogform,
|
|
2893 XmNdefaultButton, buttons[dfltbutton - 1], NULL);
|
|
2894 if (textfield != NULL)
|
|
2895 XtVaSetValues(dialogform, XmNinitialFocus, dialogtextfield, NULL);
|
|
2896 else
|
|
2897 XtVaSetValues(dialogform, XmNinitialFocus, buttons[dfltbutton - 1],
|
|
2898 NULL);
|
|
2899
|
|
2900 manage_centered(dialogform);
|
44
|
2901 activate_dialog_mnemonics(dialogform);
|
7
|
2902
|
|
2903 if (textfield != NULL && *textfield != NUL)
|
|
2904 {
|
|
2905 /* This only works after the textfield has been realised. */
|
|
2906 XmTextFieldSetSelection(dialogtextfield,
|
|
2907 (XmTextPosition)0, (XmTextPosition)STRLEN(textfield),
|
|
2908 XtLastTimestampProcessed(gui.dpy));
|
|
2909 XmTextFieldSetCursorPosition(dialogtextfield,
|
|
2910 (XmTextPosition)STRLEN(textfield));
|
|
2911 }
|
|
2912
|
|
2913 app = XtWidgetToApplicationContext(dialogform);
|
|
2914
|
|
2915 /* Loop until a button is pressed or the dialog is killed somehow. */
|
|
2916 dialogStatus = -1;
|
|
2917 for (;;)
|
|
2918 {
|
|
2919 XtAppProcessEvent(app, (XtInputMask)XtIMAll);
|
|
2920 if (dialogStatus >= 0 || !XtIsManaged(dialogform))
|
|
2921 break;
|
|
2922 }
|
|
2923
|
|
2924 vim_free(buttons);
|
|
2925
|
|
2926 if (textfield != NULL)
|
|
2927 {
|
|
2928 p = (char_u *)XmTextGetString(dialogtextfield);
|
|
2929 if (p == NULL || dialogStatus < 0)
|
|
2930 *textfield = NUL;
|
|
2931 else
|
418
|
2932 vim_strncpy(textfield, p, IOSIZE - 1);
|
7
|
2933 }
|
|
2934
|
44
|
2935 suppress_dialog_mnemonics(dialogform);
|
7
|
2936 XtDestroyWidget(dialogform);
|
|
2937
|
|
2938 return dialogStatus;
|
|
2939 }
|
|
2940 #endif /* FEAT_GUI_DIALOG */
|
|
2941
|
|
2942 #if defined(FEAT_FOOTER) || defined(PROTO)
|
|
2943
|
|
2944 static int
|
|
2945 gui_mch_compute_footer_height()
|
|
2946 {
|
|
2947 Dimension height; /* total Toolbar height */
|
|
2948 Dimension top; /* XmNmarginTop */
|
|
2949 Dimension bottom; /* XmNmarginBottom */
|
|
2950 Dimension shadow; /* XmNshadowThickness */
|
|
2951
|
|
2952 XtVaGetValues(footer,
|
|
2953 XmNheight, &height,
|
|
2954 XmNmarginTop, &top,
|
|
2955 XmNmarginBottom, &bottom,
|
|
2956 XmNshadowThickness, &shadow,
|
|
2957 NULL);
|
|
2958
|
|
2959 return (int) height + top + bottom + (shadow << 1);
|
|
2960 }
|
|
2961
|
|
2962 #if 0 /* not used */
|
|
2963 void
|
|
2964 gui_mch_set_footer_pos(h)
|
|
2965 int h; /* textArea height */
|
|
2966 {
|
|
2967 XtVaSetValues(footer,
|
|
2968 XmNtopOffset, h + 7,
|
|
2969 NULL);
|
|
2970 }
|
|
2971 #endif
|
|
2972
|
|
2973 void
|
|
2974 gui_mch_enable_footer(showit)
|
|
2975 int showit;
|
|
2976 {
|
|
2977 if (showit)
|
|
2978 {
|
|
2979 gui.footer_height = gui_mch_compute_footer_height();
|
|
2980 XtManageChild(footer);
|
|
2981 }
|
|
2982 else
|
|
2983 {
|
|
2984 gui.footer_height = 0;
|
|
2985 XtUnmanageChild(footer);
|
|
2986 }
|
|
2987 XtVaSetValues(textAreaForm, XmNbottomOffset, gui.footer_height, NULL);
|
|
2988 }
|
|
2989
|
|
2990 void
|
|
2991 gui_mch_set_footer(s)
|
|
2992 char_u *s;
|
|
2993 {
|
|
2994 XmString xms;
|
|
2995
|
|
2996 xms = XmStringCreate((char *)s, STRING_TAG);
|
44
|
2997 if (xms != NULL)
|
|
2998 {
|
|
2999 XtVaSetValues(footer, XmNlabelString, xms, NULL);
|
|
3000 XmStringFree(xms);
|
|
3001 }
|
7
|
3002 }
|
|
3003
|
|
3004 #endif
|
|
3005
|
|
3006
|
|
3007 #if defined(FEAT_TOOLBAR) || defined(PROTO)
|
|
3008 void
|
|
3009 gui_mch_show_toolbar(int showit)
|
|
3010 {
|
|
3011 Cardinal numChildren; /* how many children toolBar has */
|
|
3012
|
|
3013 if (toolBar == (Widget)0)
|
|
3014 return;
|
|
3015 XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL);
|
|
3016 if (showit && numChildren > 0)
|
|
3017 {
|
|
3018 /* Assume that we want to show the toolbar if p_toolbar contains
|
|
3019 * valid option settings, therefore p_toolbar must not be NULL.
|
|
3020 */
|
|
3021 WidgetList children;
|
|
3022
|
|
3023 XtVaGetValues(toolBar, XmNchildren, &children, NULL);
|
|
3024 {
|
|
3025 void (*action)(BalloonEval *);
|
|
3026 int text = 0;
|
|
3027
|
|
3028 if (strstr((const char *)p_toolbar, "tooltips"))
|
|
3029 action = &gui_mch_enable_beval_area;
|
|
3030 else
|
|
3031 action = &gui_mch_disable_beval_area;
|
|
3032 if (strstr((const char *)p_toolbar, "text"))
|
|
3033 text = 1;
|
|
3034 else if (strstr((const char *)p_toolbar, "icons"))
|
|
3035 text = -1;
|
|
3036 if (text != 0)
|
|
3037 {
|
|
3038 vimmenu_T *toolbar;
|
|
3039 vimmenu_T *cur;
|
|
3040
|
|
3041 for (toolbar = root_menu; toolbar; toolbar = toolbar->next)
|
|
3042 if (menu_is_toolbar(toolbar->dname))
|
|
3043 break;
|
|
3044 /* Assumption: toolbar is NULL if there is no toolbar,
|
|
3045 * otherwise it contains the toolbar menu structure.
|
|
3046 *
|
|
3047 * Assumption: "numChildren" == the number of items in the list
|
|
3048 * of items beginning with toolbar->children.
|
|
3049 */
|
|
3050 if (toolbar)
|
|
3051 {
|
|
3052 for (cur = toolbar->children; cur; cur = cur->next)
|
|
3053 {
|
|
3054 Arg args[1];
|
|
3055 int n = 0;
|
|
3056
|
|
3057 /* Enable/Disable tooltip (OK to enable while
|
844
|
3058 * currently enabled). */
|
7
|
3059 if (cur->tip != NULL)
|
|
3060 (*action)(cur->tip);
|
|
3061 if (!menu_is_separator(cur->name))
|
|
3062 {
|
48
|
3063 if (text == 1 || cur->xpm == NULL)
|
|
3064 {
|
7
|
3065 XtSetArg(args[n], XmNlabelType, XmSTRING);
|
48
|
3066 ++n;
|
|
3067 }
|
7
|
3068 if (cur->id != NULL)
|
|
3069 {
|
|
3070 XtUnmanageChild(cur->id);
|
|
3071 XtSetValues(cur->id, args, n);
|
|
3072 XtManageChild(cur->id);
|
|
3073 }
|
|
3074 }
|
|
3075 }
|
|
3076 }
|
|
3077 }
|
|
3078 }
|
|
3079 gui.toolbar_height = gui_mch_compute_toolbar_height();
|
|
3080 XtManageChild(XtParent(toolBar));
|
819
|
3081 #ifdef FEAT_GUI_TABLINE
|
|
3082 if (showing_tabline)
|
|
3083 {
|
|
3084 XtVaSetValues(tabLine,
|
|
3085 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3086 XmNtopWidget, XtParent(toolBar),
|
|
3087 NULL);
|
|
3088 XtVaSetValues(textAreaForm,
|
|
3089 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3090 XmNtopWidget, tabLine,
|
|
3091 NULL);
|
|
3092 }
|
|
3093 else
|
|
3094 #endif
|
|
3095 XtVaSetValues(textAreaForm,
|
|
3096 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3097 XmNtopWidget, XtParent(toolBar),
|
|
3098 NULL);
|
7
|
3099 if (XtIsManaged(menuBar))
|
|
3100 XtVaSetValues(XtParent(toolBar),
|
|
3101 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3102 XmNtopWidget, menuBar,
|
|
3103 NULL);
|
|
3104 else
|
|
3105 XtVaSetValues(XtParent(toolBar),
|
|
3106 XmNtopAttachment, XmATTACH_FORM,
|
|
3107 NULL);
|
|
3108 }
|
|
3109 else
|
|
3110 {
|
|
3111 gui.toolbar_height = 0;
|
|
3112 if (XtIsManaged(menuBar))
|
819
|
3113 {
|
|
3114 #ifdef FEAT_GUI_TABLINE
|
|
3115 if (showing_tabline)
|
|
3116 {
|
|
3117 XtVaSetValues(tabLine,
|
|
3118 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3119 XmNtopWidget, menuBar,
|
|
3120 NULL);
|
|
3121 XtVaSetValues(textAreaForm,
|
|
3122 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3123 XmNtopWidget, tabLine,
|
|
3124 NULL);
|
|
3125 }
|
|
3126 else
|
|
3127 #endif
|
|
3128 XtVaSetValues(textAreaForm,
|
|
3129 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3130 XmNtopWidget, menuBar,
|
|
3131 NULL);
|
|
3132 }
|
7
|
3133 else
|
819
|
3134 {
|
|
3135 #ifdef FEAT_GUI_TABLINE
|
|
3136 if (showing_tabline)
|
|
3137 {
|
|
3138 XtVaSetValues(tabLine,
|
|
3139 XmNtopAttachment, XmATTACH_FORM,
|
|
3140 NULL);
|
|
3141 XtVaSetValues(textAreaForm,
|
|
3142 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3143 XmNtopWidget, tabLine,
|
|
3144 NULL);
|
|
3145 }
|
|
3146 else
|
|
3147 #endif
|
|
3148 XtVaSetValues(textAreaForm,
|
|
3149 XmNtopAttachment, XmATTACH_FORM,
|
|
3150 NULL);
|
|
3151 }
|
7
|
3152
|
|
3153 XtUnmanageChild(XtParent(toolBar));
|
|
3154 }
|
811
|
3155 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
|
7
|
3156 }
|
|
3157
|
|
3158 /*
|
|
3159 * A toolbar button has been pushed; now reset the input focus
|
|
3160 * such that the user can type page up/down etc. and have the
|
|
3161 * input go to the editor window, not the button
|
|
3162 */
|
|
3163 static void
|
54
|
3164 reset_focus()
|
7
|
3165 {
|
|
3166 if (textArea != NULL)
|
|
3167 XmProcessTraversal(textArea, XmTRAVERSE_CURRENT);
|
|
3168 }
|
|
3169
|
|
3170 int
|
|
3171 gui_mch_compute_toolbar_height()
|
|
3172 {
|
48
|
3173 Dimension borders;
|
7
|
3174 Dimension height; /* total Toolbar height */
|
|
3175 Dimension whgt; /* height of each widget */
|
|
3176 WidgetList children; /* list of toolBar's children */
|
|
3177 Cardinal numChildren; /* how many children toolBar has */
|
|
3178 int i;
|
|
3179
|
48
|
3180 borders = 0;
|
7
|
3181 height = 0;
|
|
3182 if (toolBar != (Widget)0 && toolBarFrame != (Widget)0)
|
|
3183 { /* get height of XmFrame parent */
|
48
|
3184 Dimension fst;
|
|
3185 Dimension fmh;
|
|
3186 Dimension tst;
|
|
3187 Dimension tmh;
|
|
3188
|
7
|
3189 XtVaGetValues(toolBarFrame,
|
48
|
3190 XmNshadowThickness, &fst,
|
|
3191 XmNmarginHeight, &fmh,
|
7
|
3192 NULL);
|
48
|
3193 borders += fst + fmh;
|
7
|
3194 XtVaGetValues(toolBar,
|
48
|
3195 XmNshadowThickness, &tst,
|
|
3196 XmNmarginHeight, &tmh,
|
7
|
3197 XmNchildren, &children,
|
|
3198 XmNnumChildren, &numChildren, NULL);
|
48
|
3199 borders += tst + tmh;
|
7
|
3200 for (i = 0; i < numChildren; i++)
|
|
3201 {
|
|
3202 whgt = 0;
|
|
3203 XtVaGetValues(children[i], XmNheight, &whgt, NULL);
|
|
3204 if (height < whgt)
|
|
3205 height = whgt;
|
|
3206 }
|
|
3207 }
|
48
|
3208 #ifdef LESSTIF_VERSION
|
|
3209 /* Hack: When starting up we get wrong dimensions. */
|
|
3210 if (height < 10)
|
|
3211 height = 24;
|
|
3212 #endif
|
|
3213
|
|
3214 return (int)(height + (borders << 1));
|
7
|
3215 }
|
|
3216
|
161
|
3217 void
|
|
3218 motif_get_toolbar_colors(bgp, fgp, bsp, tsp, hsp)
|
|
3219 Pixel *bgp;
|
|
3220 Pixel *fgp;
|
|
3221 Pixel *bsp;
|
|
3222 Pixel *tsp;
|
|
3223 Pixel *hsp;
|
|
3224 {
|
|
3225 XtVaGetValues(toolBar,
|
856
|
3226 XmNbackground, bgp,
|
|
3227 XmNforeground, fgp,
|
|
3228 XmNbottomShadowColor, bsp,
|
|
3229 XmNtopShadowColor, tsp,
|
|
3230 XmNhighlightColor, hsp,
|
|
3231 NULL);
|
161
|
3232 }
|
|
3233
|
7
|
3234 # ifdef FEAT_FOOTER
|
|
3235 /*
|
|
3236 * The next toolbar enter/leave callbacks should really do balloon help. But
|
|
3237 * I have to use footer help for backwards compatability. Hopefully both will
|
|
3238 * get implemented and the user will have a choice.
|
|
3239 */
|
|
3240 /*ARGSUSED*/
|
|
3241 static void
|
|
3242 toolbarbutton_enter_cb(w, client_data, event, cont)
|
|
3243 Widget w;
|
|
3244 XtPointer client_data;
|
|
3245 XEvent *event;
|
|
3246 Boolean *cont;
|
|
3247 {
|
|
3248 vimmenu_T *menu = (vimmenu_T *) client_data;
|
|
3249
|
|
3250 if (menu->strings[MENU_INDEX_TIP] != NULL)
|
|
3251 {
|
|
3252 if (vim_strchr(p_go, GO_FOOTER) != NULL)
|
|
3253 gui_mch_set_footer(menu->strings[MENU_INDEX_TIP]);
|
|
3254 }
|
|
3255 }
|
|
3256
|
|
3257 /*ARGSUSED*/
|
|
3258 static void
|
|
3259 toolbarbutton_leave_cb(w, client_data, event, cont)
|
|
3260 Widget w;
|
|
3261 XtPointer client_data;
|
|
3262 XEvent *event;
|
|
3263 Boolean *cont;
|
|
3264 {
|
|
3265 gui_mch_set_footer((char_u *) "");
|
|
3266 }
|
|
3267 # endif
|
|
3268 #endif
|
|
3269
|
819
|
3270 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
|
|
3271 /*
|
|
3272 * Show or hide the tabline.
|
|
3273 */
|
|
3274 void
|
|
3275 gui_mch_show_tabline(int showit)
|
|
3276 {
|
|
3277 if (tabLine == (Widget)0)
|
|
3278 return;
|
|
3279
|
|
3280 if (!showit != !showing_tabline)
|
|
3281 {
|
|
3282 if (showit)
|
|
3283 {
|
|
3284 XtManageChild(tabLine);
|
|
3285 XtUnmanageChild(XtNameToWidget(tabLine, "PageScroller"));
|
824
|
3286 XtUnmanageChild(XtNameToWidget(tabLine, "MinorTabScrollerNext"));
|
|
3287 XtUnmanageChild(XtNameToWidget(tabLine,
|
|
3288 "MinorTabScrollerPrevious"));
|
819
|
3289 #ifdef FEAT_MENU
|
|
3290 # ifdef FEAT_TOOLBAR
|
|
3291 if (XtIsManaged(XtParent(toolBar)))
|
|
3292 XtVaSetValues(tabLine,
|
|
3293 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3294 XmNtopWidget, XtParent(toolBar), NULL);
|
|
3295 else
|
|
3296 # endif
|
|
3297 if (XtIsManaged(menuBar))
|
|
3298 XtVaSetValues(tabLine,
|
|
3299 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3300 XmNtopWidget, menuBar, NULL);
|
|
3301 else
|
|
3302 #endif
|
|
3303 XtVaSetValues(tabLine,
|
|
3304 XmNtopAttachment, XmATTACH_FORM, NULL);
|
|
3305 XtVaSetValues(textAreaForm,
|
|
3306 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3307 XmNtopWidget, tabLine,
|
|
3308 NULL);
|
|
3309 }
|
|
3310 else
|
|
3311 {
|
|
3312 XtUnmanageChild(tabLine);
|
|
3313 #ifdef FEAT_MENU
|
|
3314 # ifdef FEAT_TOOLBAR
|
|
3315 if (XtIsManaged(XtParent(toolBar)))
|
|
3316 XtVaSetValues(textAreaForm,
|
|
3317 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3318 XmNtopWidget, XtParent(toolBar), NULL);
|
|
3319 else
|
|
3320 # endif
|
|
3321 if (XtIsManaged(menuBar))
|
|
3322 XtVaSetValues(textAreaForm,
|
|
3323 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3324 XmNtopWidget, menuBar, NULL);
|
|
3325 else
|
|
3326 #endif
|
|
3327 XtVaSetValues(textAreaForm,
|
|
3328 XmNtopAttachment, XmATTACH_FORM, NULL);
|
|
3329 }
|
|
3330 showing_tabline = showit;
|
|
3331 }
|
|
3332 }
|
|
3333
|
|
3334 /*
|
|
3335 * Return TRUE when tabline is displayed.
|
|
3336 */
|
|
3337 int
|
|
3338 gui_mch_showing_tabline(void)
|
|
3339 {
|
|
3340 return tabLine != (Widget)0 && showing_tabline;
|
|
3341 }
|
|
3342
|
|
3343 /*
|
|
3344 * Update the labels of the tabline.
|
|
3345 */
|
|
3346 void
|
|
3347 gui_mch_update_tabline(void)
|
|
3348 {
|
|
3349 tabpage_T *tp;
|
|
3350 int nr = 1, n;
|
|
3351 Arg args[10];
|
|
3352 int curtabidx = 0, currentpage;
|
|
3353 Widget tab;
|
|
3354 XmNotebookPageInfo page_info;
|
|
3355 XmNotebookPageStatus page_status;
|
|
3356 int last_page, tab_count;
|
824
|
3357 XmString label_str;
|
|
3358 char *label_cstr;
|
844
|
3359 BalloonEval *beval;
|
819
|
3360
|
|
3361 if (tabLine == (Widget)0)
|
|
3362 return;
|
|
3363
|
|
3364 /* Add a label for each tab page. They all contain the same text area. */
|
|
3365 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
|
|
3366 {
|
|
3367 if (tp == curtab)
|
|
3368 curtabidx = nr;
|
|
3369
|
|
3370 page_status = XmNotebookGetPageInfo(tabLine, nr, &page_info);
|
|
3371 if (page_status == XmPAGE_INVALID
|
844
|
3372 || page_info.major_tab_widget == (Widget)0)
|
819
|
3373 {
|
|
3374 /* Add the tab */
|
|
3375 n = 0;
|
|
3376 XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++;
|
|
3377 XtSetArg(args[n], XmNtraversalOn, False); n++;
|
|
3378 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
|
|
3379 XtSetArg(args[n], XmNhighlightThickness, 1); n++;
|
|
3380 XtSetArg(args[n], XmNshadowThickness , 1); n++;
|
|
3381 tab = XmCreatePushButton(tabLine, "-Empty-", args, n);
|
|
3382 XtManageChild(tab);
|
844
|
3383 beval = gui_mch_create_beval_area(tab, NULL, tabline_balloon_cb,
|
|
3384 NULL);
|
|
3385 XtVaSetValues(tab, XmNuserData, beval, NULL);
|
819
|
3386 }
|
|
3387 else
|
|
3388 tab = page_info.major_tab_widget;
|
|
3389
|
|
3390 XtVaSetValues(tab, XmNpageNumber, nr, NULL);
|
824
|
3391
|
|
3392 /*
|
|
3393 * Change the label text only if it is different
|
|
3394 */
|
|
3395 XtVaGetValues(tab, XmNlabelString, &label_str, NULL);
|
|
3396 if (XmStringGetLtoR(label_str, XmSTRING_DEFAULT_CHARSET, &label_cstr))
|
|
3397 {
|
839
|
3398 get_tabline_label(tp, FALSE);
|
|
3399 if (STRCMP(label_cstr, NameBuff) != 0)
|
|
3400 {
|
824
|
3401 XtVaSetValues(tab, XtVaTypedArg, XmNlabelString, XmRString,
|
|
3402 NameBuff, STRLEN(NameBuff) + 1, NULL);
|
|
3403 /*
|
|
3404 * Force a resize of the tab label button
|
|
3405 */
|
|
3406 XtUnmanageChild(tab);
|
|
3407 XtManageChild(tab);
|
|
3408 }
|
|
3409 XtFree(label_cstr);
|
|
3410 }
|
819
|
3411 }
|
|
3412
|
|
3413 tab_count = nr - 1;
|
|
3414
|
|
3415 XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL);
|
|
3416
|
|
3417 /* Remove any old labels. */
|
|
3418 while (nr <= last_page)
|
|
3419 {
|
|
3420 if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID
|
|
3421 && page_info.page_number == nr
|
|
3422 && page_info.major_tab_widget != (Widget)0)
|
|
3423 {
|
844
|
3424 XtVaGetValues(page_info.major_tab_widget, XmNuserData, &beval, NULL);
|
|
3425 if (beval != NULL)
|
|
3426 gui_mch_destroy_beval_area(beval);
|
819
|
3427 XtUnmanageChild(page_info.major_tab_widget);
|
|
3428 XtDestroyWidget(page_info.major_tab_widget);
|
|
3429 }
|
|
3430 nr++;
|
|
3431 }
|
|
3432
|
|
3433 XtVaSetValues(tabLine, XmNlastPageNumber, tab_count, NULL);
|
|
3434
|
|
3435 XtVaGetValues(tabLine, XmNcurrentPageNumber, ¤tpage, NULL);
|
|
3436 if (currentpage != curtabidx)
|
|
3437 XtVaSetValues(tabLine, XmNcurrentPageNumber, curtabidx, NULL);
|
|
3438 }
|
|
3439
|
|
3440 /*
|
|
3441 * Set the current tab to "nr". First tab is 1.
|
|
3442 */
|
|
3443 void
|
|
3444 gui_mch_set_curtab(nr)
|
|
3445 int nr;
|
|
3446 {
|
|
3447 int currentpage;
|
|
3448
|
|
3449 if (tabLine == (Widget)0)
|
|
3450 return;
|
|
3451
|
|
3452 XtVaGetValues(tabLine, XmNcurrentPageNumber, ¤tpage, NULL);
|
|
3453 if (currentpage != nr)
|
|
3454 XtVaSetValues(tabLine, XmNcurrentPageNumber, nr, NULL);
|
|
3455 }
|
|
3456 #endif
|
|
3457
|
7
|
3458 /*
|
|
3459 * Set the colors of Widget "id" to the menu colors.
|
|
3460 */
|
|
3461 static void
|
|
3462 gui_motif_menu_colors(id)
|
|
3463 Widget id;
|
|
3464 {
|
|
3465 if (gui.menu_bg_pixel != INVALCOLOR)
|
|
3466 #if (XmVersion >= 1002)
|
|
3467 XmChangeColor(id, gui.menu_bg_pixel);
|
|
3468 #else
|
|
3469 XtVaSetValues(id, XmNbackground, gui.menu_bg_pixel, NULL);
|
|
3470 #endif
|
|
3471 if (gui.menu_fg_pixel != INVALCOLOR)
|
|
3472 XtVaSetValues(id, XmNforeground, gui.menu_fg_pixel, NULL);
|
|
3473 }
|
|
3474
|
|
3475 /*
|
|
3476 * Set the colors of Widget "id" to the scrollbar colors.
|
|
3477 */
|
|
3478 static void
|
|
3479 gui_motif_scroll_colors(id)
|
|
3480 Widget id;
|
|
3481 {
|
|
3482 if (gui.scroll_bg_pixel != INVALCOLOR)
|
|
3483 #if (XmVersion >= 1002)
|
|
3484 XmChangeColor(id, gui.scroll_bg_pixel);
|
|
3485 #else
|
|
3486 XtVaSetValues(id, XmNbackground, gui.scroll_bg_pixel, NULL);
|
|
3487 #endif
|
|
3488 if (gui.scroll_fg_pixel != INVALCOLOR)
|
|
3489 XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL);
|
|
3490 }
|
|
3491
|
|
3492 /*
|
|
3493 * Set the fontlist for Widget "id" to use gui.menu_fontset or gui.menu_font.
|
|
3494 */
|
44
|
3495 /*ARGSUSED*/
|
|
3496 void
|
7
|
3497 gui_motif_menu_fontlist(id)
|
|
3498 Widget id;
|
|
3499 {
|
44
|
3500 #ifdef FEAT_MENU
|
7
|
3501 #ifdef FONTSET_ALWAYS
|
|
3502 if (gui.menu_fontset != NOFONTSET)
|
|
3503 {
|
|
3504 XmFontList fl;
|
|
3505
|
|
3506 fl = gui_motif_fontset2fontlist((XFontSet *)&gui.menu_fontset);
|
|
3507 if (fl != NULL)
|
|
3508 {
|
|
3509 if (XtIsManaged(id))
|
|
3510 {
|
|
3511 XtUnmanageChild(id);
|
|
3512 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
3513 /* We should force the widget to recalculate it's
|
|
3514 * geometry now. */
|
|
3515 XtManageChild(id);
|
|
3516 }
|
|
3517 else
|
|
3518 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
3519 XmFontListFree(fl);
|
|
3520 }
|
|
3521 }
|
|
3522 #else
|
|
3523 if (gui.menu_font != NOFONT)
|
|
3524 {
|
|
3525 XmFontList fl;
|
|
3526
|
|
3527 fl = gui_motif_create_fontlist((XFontStruct *)gui.menu_font);
|
|
3528 if (fl != NULL)
|
|
3529 {
|
|
3530 if (XtIsManaged(id))
|
|
3531 {
|
|
3532 XtUnmanageChild(id);
|
|
3533 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
3534 /* We should force the widget to recalculate it's
|
|
3535 * geometry now. */
|
|
3536 XtManageChild(id);
|
|
3537 }
|
|
3538 else
|
|
3539 XtVaSetValues(id, XmNfontList, fl, NULL);
|
|
3540 XmFontListFree(fl);
|
|
3541 }
|
|
3542 }
|
|
3543 #endif
|
44
|
3544 #endif
|
7
|
3545 }
|
|
3546
|
|
3547
|
|
3548 /*
|
|
3549 * We don't create it twice for the sake of speed.
|
|
3550 */
|
|
3551
|
|
3552 typedef struct _SharedFindReplace
|
|
3553 {
|
|
3554 Widget dialog; /* the main dialog widget */
|
|
3555 Widget wword; /* 'Exact match' check button */
|
|
3556 Widget mcase; /* 'match case' check button */
|
|
3557 Widget up; /* search direction 'Up' radio button */
|
|
3558 Widget down; /* search direction 'Down' radio button */
|
|
3559 Widget what; /* 'Find what' entry text widget */
|
|
3560 Widget with; /* 'Replace with' entry text widget */
|
|
3561 Widget find; /* 'Find Next' action button */
|
|
3562 Widget replace; /* 'Replace With' action button */
|
|
3563 Widget all; /* 'Replace All' action button */
|
|
3564 Widget undo; /* 'Undo' action button */
|
|
3565
|
|
3566 Widget cancel;
|
|
3567 } SharedFindReplace;
|
|
3568
|
|
3569 static SharedFindReplace find_widgets = { NULL };
|
|
3570 static SharedFindReplace repl_widgets = { NULL };
|
|
3571
|
|
3572 static void find_replace_destroy_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
3573 static void find_replace_dismiss_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
3574 static void entry_activate_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
3575 static void find_replace_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
|
|
3576 static void find_replace_keypress __ARGS((Widget w, SharedFindReplace * frdp, XKeyEvent * event));
|
|
3577 static void find_replace_dialog_create __ARGS((char_u *entry_text, int do_replace));
|
|
3578
|
|
3579 /*ARGSUSED*/
|
|
3580 static void
|
|
3581 find_replace_destroy_callback(w, client_data, call_data)
|
|
3582 Widget w;
|
|
3583 XtPointer client_data;
|
|
3584 XtPointer call_data;
|
|
3585 {
|
|
3586 SharedFindReplace *cd = (SharedFindReplace *)client_data;
|
|
3587
|
48
|
3588 if (cd != NULL)
|
44
|
3589 /* suppress_dialog_mnemonics(cd->dialog); */
|
7
|
3590 cd->dialog = (Widget)0;
|
|
3591 }
|
|
3592
|
|
3593 /*ARGSUSED*/
|
|
3594 static void
|
|
3595 find_replace_dismiss_callback(w, client_data, call_data)
|
|
3596 Widget w;
|
|
3597 XtPointer client_data;
|
|
3598 XtPointer call_data;
|
|
3599 {
|
|
3600 SharedFindReplace *cd = (SharedFindReplace *)client_data;
|
|
3601
|
|
3602 if (cd != NULL)
|
|
3603 XtUnmanageChild(cd->dialog);
|
|
3604 }
|
|
3605
|
|
3606 /*ARGSUSED*/
|
|
3607 static void
|
|
3608 entry_activate_callback(w, client_data, call_data)
|
|
3609 Widget w;
|
|
3610 XtPointer client_data;
|
|
3611 XtPointer call_data;
|
|
3612 {
|
|
3613 XmProcessTraversal((Widget)client_data, XmTRAVERSE_CURRENT);
|
|
3614 }
|
|
3615
|
|
3616 /*ARGSUSED*/
|
|
3617 static void
|
|
3618 find_replace_callback(w, client_data, call_data)
|
|
3619 Widget w;
|
|
3620 XtPointer client_data;
|
|
3621 XtPointer call_data;
|
|
3622 {
|
|
3623 long_u flags = (long_u)client_data;
|
|
3624 char *find_text, *repl_text;
|
|
3625 Boolean direction_down = TRUE;
|
|
3626 Boolean wword;
|
|
3627 Boolean mcase;
|
|
3628 SharedFindReplace *sfr;
|
|
3629
|
|
3630 if (flags == FRD_UNDO)
|
|
3631 {
|
|
3632 char_u *save_cpo = p_cpo;
|
|
3633
|
|
3634 /* No need to be Vi compatible here. */
|
|
3635 p_cpo = (char_u *)"";
|
|
3636 u_undo(1);
|
|
3637 p_cpo = save_cpo;
|
|
3638 gui_update_screen();
|
|
3639 return;
|
|
3640 }
|
|
3641
|
|
3642 /* Get the search/replace strings from the dialog */
|
|
3643 if (flags == FRD_FINDNEXT)
|
|
3644 {
|
|
3645 repl_text = NULL;
|
|
3646 sfr = &find_widgets;
|
|
3647 }
|
|
3648 else
|
|
3649 {
|
|
3650 repl_text = XmTextFieldGetString(repl_widgets.with);
|
|
3651 sfr = &repl_widgets;
|
|
3652 }
|
|
3653 find_text = XmTextFieldGetString(sfr->what);
|
|
3654 XtVaGetValues(sfr->down, XmNset, &direction_down, NULL);
|
|
3655 XtVaGetValues(sfr->wword, XmNset, &wword, NULL);
|
|
3656 XtVaGetValues(sfr->mcase, XmNset, &mcase, NULL);
|
|
3657 if (wword)
|
|
3658 flags |= FRD_WHOLE_WORD;
|
|
3659 if (mcase)
|
|
3660 flags |= FRD_MATCH_CASE;
|
|
3661
|
|
3662 (void)gui_do_findrepl((int)flags, (char_u *)find_text, (char_u *)repl_text,
|
|
3663 direction_down);
|
|
3664
|
|
3665 if (find_text != NULL)
|
|
3666 XtFree(find_text);
|
|
3667 if (repl_text != NULL)
|
|
3668 XtFree(repl_text);
|
|
3669 }
|
|
3670
|
|
3671 /*ARGSUSED*/
|
|
3672 static void
|
|
3673 find_replace_keypress(w, frdp, event)
|
|
3674 Widget w;
|
|
3675 SharedFindReplace *frdp;
|
|
3676 XKeyEvent *event;
|
|
3677 {
|
|
3678 KeySym keysym;
|
|
3679
|
|
3680 if (frdp == NULL)
|
|
3681 return;
|
|
3682
|
|
3683 keysym = XLookupKeysym(event, 0);
|
|
3684
|
|
3685 /* the scape key pops the whole dialog down */
|
|
3686 if (keysym == XK_Escape)
|
|
3687 XtUnmanageChild(frdp->dialog);
|
|
3688 }
|
|
3689
|
|
3690 static void
|
44
|
3691 set_label(w, label)
|
|
3692 Widget w;
|
|
3693 char_u *label;
|
|
3694 {
|
|
3695 XmString str;
|
|
3696 char_u *p, *next;
|
|
3697 KeySym mnemonic = NUL;
|
|
3698
|
|
3699 if (!w)
|
|
3700 return;
|
|
3701
|
|
3702 p = vim_strsave(label);
|
|
3703 if (p == NULL)
|
|
3704 return;
|
|
3705 for (next = p; *next; ++next)
|
|
3706 {
|
|
3707 if (*next == DLG_HOTKEY_CHAR)
|
|
3708 {
|
|
3709 int len = STRLEN(next);
|
|
3710
|
|
3711 if (len > 0)
|
|
3712 {
|
|
3713 mch_memmove(next, next + 1, len);
|
|
3714 mnemonic = next[0];
|
|
3715 }
|
|
3716 }
|
|
3717 }
|
|
3718
|
|
3719 str = XmStringCreateSimple((char *)p);
|
|
3720 vim_free(p);
|
|
3721 if (str)
|
|
3722 {
|
|
3723 XtVaSetValues(w,
|
|
3724 XmNlabelString, str,
|
|
3725 XmNmnemonic, mnemonic,
|
|
3726 NULL);
|
|
3727 XmStringFree(str);
|
|
3728 }
|
|
3729 gui_motif_menu_fontlist(w);
|
|
3730 }
|
|
3731
|
|
3732 static void
|
7
|
3733 find_replace_dialog_create(arg, do_replace)
|
|
3734 char_u *arg;
|
|
3735 int do_replace;
|
|
3736 {
|
|
3737 SharedFindReplace *frdp;
|
|
3738 Widget separator;
|
|
3739 Widget input_form;
|
|
3740 Widget button_form;
|
|
3741 Widget toggle_form;
|
|
3742 Widget frame;
|
|
3743 XmString str;
|
|
3744 int n;
|
|
3745 Arg args[6];
|
|
3746 int wword = FALSE;
|
|
3747 int mcase = !p_ic;
|
|
3748 Dimension width;
|
|
3749 Dimension widest;
|
|
3750 char_u *entry_text;
|
|
3751
|
|
3752 frdp = do_replace ? &repl_widgets : &find_widgets;
|
|
3753
|
|
3754 /* Get the search string to use. */
|
|
3755 entry_text = get_find_dialog_text(arg, &wword, &mcase);
|
|
3756
|
|
3757 /* If the dialog already exists, just raise it. */
|
|
3758 if (frdp->dialog)
|
|
3759 {
|
44
|
3760 gui_motif_synch_fonts();
|
|
3761
|
7
|
3762 /* If the window is already up, just pop it to the top */
|
|
3763 if (XtIsManaged(frdp->dialog))
|
|
3764 XMapRaised(XtDisplay(frdp->dialog),
|
|
3765 XtWindow(XtParent(frdp->dialog)));
|
|
3766 else
|
|
3767 XtManageChild(frdp->dialog);
|
|
3768 XtPopup(XtParent(frdp->dialog), XtGrabNone);
|
|
3769 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT);
|
|
3770
|
|
3771 if (entry_text != NULL)
|
|
3772 XmTextFieldSetString(frdp->what, (char *)entry_text);
|
|
3773 vim_free(entry_text);
|
|
3774
|
|
3775 XtVaSetValues(frdp->wword, XmNset, wword, NULL);
|
|
3776 return;
|
|
3777 }
|
|
3778
|
|
3779 /* Create a fresh new dialog window */
|
|
3780 if (do_replace)
|
|
3781 str = XmStringCreateSimple(_("VIM - Search and Replace..."));
|
|
3782 else
|
|
3783 str = XmStringCreateSimple(_("VIM - Search..."));
|
|
3784
|
|
3785 n = 0;
|
|
3786 XtSetArg(args[n], XmNautoUnmanage, False); n++;
|
|
3787 XtSetArg(args[n], XmNnoResize, True); n++;
|
|
3788 XtSetArg(args[n], XmNdialogTitle, str); n++;
|
|
3789
|
|
3790 frdp->dialog = XmCreateFormDialog(vimShell, "findReplaceDialog", args, n);
|
|
3791 XmStringFree(str);
|
|
3792 XtAddCallback(frdp->dialog, XmNdestroyCallback,
|
|
3793 find_replace_destroy_callback, frdp);
|
|
3794
|
|
3795 button_form = XtVaCreateWidget("buttonForm",
|
|
3796 xmFormWidgetClass, frdp->dialog,
|
|
3797 XmNrightAttachment, XmATTACH_FORM,
|
|
3798 XmNrightOffset, 4,
|
|
3799 XmNtopAttachment, XmATTACH_FORM,
|
|
3800 XmNtopOffset, 4,
|
|
3801 XmNbottomAttachment, XmATTACH_FORM,
|
|
3802 XmNbottomOffset, 4,
|
|
3803 NULL);
|
|
3804
|
|
3805 frdp->find = XtVaCreateManagedWidget("findButton",
|
|
3806 xmPushButtonWidgetClass, button_form,
|
|
3807 XmNsensitive, True,
|
|
3808 XmNtopAttachment, XmATTACH_FORM,
|
|
3809 XmNleftAttachment, XmATTACH_FORM,
|
|
3810 XmNrightAttachment, XmATTACH_FORM,
|
|
3811 NULL);
|
44
|
3812 set_label(frdp->find, _("Find &Next"));
|
7
|
3813
|
|
3814 XtAddCallback(frdp->find, XmNactivateCallback,
|
|
3815 find_replace_callback,
|
|
3816 (XtPointer) (do_replace ? FRD_R_FINDNEXT : FRD_FINDNEXT));
|
|
3817
|
|
3818 if (do_replace)
|
|
3819 {
|
|
3820 frdp->replace = XtVaCreateManagedWidget("replaceButton",
|
|
3821 xmPushButtonWidgetClass, button_form,
|
|
3822 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3823 XmNtopWidget, frdp->find,
|
|
3824 XmNleftAttachment, XmATTACH_FORM,
|
|
3825 XmNrightAttachment, XmATTACH_FORM,
|
|
3826 NULL);
|
44
|
3827 set_label(frdp->replace, _("&Replace"));
|
7
|
3828 XtAddCallback(frdp->replace, XmNactivateCallback,
|
|
3829 find_replace_callback, (XtPointer)FRD_REPLACE);
|
|
3830
|
|
3831 frdp->all = XtVaCreateManagedWidget("replaceAllButton",
|
|
3832 xmPushButtonWidgetClass, button_form,
|
|
3833 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3834 XmNtopWidget, frdp->replace,
|
|
3835 XmNleftAttachment, XmATTACH_FORM,
|
|
3836 XmNrightAttachment, XmATTACH_FORM,
|
|
3837 NULL);
|
44
|
3838 set_label(frdp->all, _("Replace &All"));
|
7
|
3839 XtAddCallback(frdp->all, XmNactivateCallback,
|
|
3840 find_replace_callback, (XtPointer)FRD_REPLACEALL);
|
|
3841
|
|
3842 frdp->undo = XtVaCreateManagedWidget("undoButton",
|
|
3843 xmPushButtonWidgetClass, button_form,
|
|
3844 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3845 XmNtopWidget, frdp->all,
|
|
3846 XmNleftAttachment, XmATTACH_FORM,
|
|
3847 XmNrightAttachment, XmATTACH_FORM,
|
|
3848 NULL);
|
44
|
3849 set_label(frdp->undo, _("&Undo"));
|
7
|
3850 XtAddCallback(frdp->undo, XmNactivateCallback,
|
|
3851 find_replace_callback, (XtPointer)FRD_UNDO);
|
|
3852 }
|
|
3853
|
|
3854 frdp->cancel = XtVaCreateManagedWidget("closeButton",
|
|
3855 xmPushButtonWidgetClass, button_form,
|
|
3856 XmNleftAttachment, XmATTACH_FORM,
|
|
3857 XmNrightAttachment, XmATTACH_FORM,
|
|
3858 XmNbottomAttachment, XmATTACH_FORM,
|
|
3859 NULL);
|
44
|
3860 set_label(frdp->cancel, _("&Cancel"));
|
7
|
3861 XtAddCallback(frdp->cancel, XmNactivateCallback,
|
|
3862 find_replace_dismiss_callback, frdp);
|
44
|
3863 gui_motif_menu_fontlist(frdp->cancel);
|
7
|
3864
|
|
3865 XtManageChild(button_form);
|
|
3866
|
|
3867 n = 0;
|
|
3868 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
|
|
3869 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
|
|
3870 XtSetArg(args[n], XmNrightWidget, button_form); n++;
|
|
3871 XtSetArg(args[n], XmNrightOffset, 4); n++;
|
|
3872 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
|
3873 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
|
3874 separator = XmCreateSeparatorGadget(frdp->dialog, "separator", args, n);
|
|
3875 XtManageChild(separator);
|
|
3876
|
|
3877 input_form = XtVaCreateWidget("inputForm",
|
|
3878 xmFormWidgetClass, frdp->dialog,
|
|
3879 XmNleftAttachment, XmATTACH_FORM,
|
|
3880 XmNleftOffset, 4,
|
|
3881 XmNrightAttachment, XmATTACH_WIDGET,
|
|
3882 XmNrightWidget, separator,
|
|
3883 XmNrightOffset, 4,
|
|
3884 XmNtopAttachment, XmATTACH_FORM,
|
|
3885 XmNtopOffset, 4,
|
|
3886 NULL);
|
|
3887
|
|
3888 {
|
|
3889 Widget label_what;
|
|
3890 Widget label_with = (Widget)0;
|
|
3891
|
|
3892 str = XmStringCreateSimple(_("Find what:"));
|
|
3893 label_what = XtVaCreateManagedWidget("whatLabel",
|
|
3894 xmLabelGadgetClass, input_form,
|
|
3895 XmNlabelString, str,
|
|
3896 XmNleftAttachment, XmATTACH_FORM,
|
|
3897 XmNtopAttachment, XmATTACH_FORM,
|
|
3898 XmNtopOffset, 4,
|
|
3899 NULL);
|
|
3900 XmStringFree(str);
|
44
|
3901 gui_motif_menu_fontlist(label_what);
|
7
|
3902
|
|
3903 frdp->what = XtVaCreateManagedWidget("whatText",
|
|
3904 xmTextFieldWidgetClass, input_form,
|
|
3905 XmNtopAttachment, XmATTACH_FORM,
|
|
3906 XmNrightAttachment, XmATTACH_FORM,
|
|
3907 XmNleftAttachment, XmATTACH_FORM,
|
|
3908 NULL);
|
|
3909
|
|
3910 if (do_replace)
|
|
3911 {
|
|
3912 frdp->with = XtVaCreateManagedWidget("withText",
|
|
3913 xmTextFieldWidgetClass, input_form,
|
|
3914 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3915 XmNtopWidget, frdp->what,
|
|
3916 XmNtopOffset, 4,
|
|
3917 XmNleftAttachment, XmATTACH_FORM,
|
|
3918 XmNrightAttachment, XmATTACH_FORM,
|
|
3919 XmNbottomAttachment, XmATTACH_FORM,
|
|
3920 NULL);
|
|
3921
|
|
3922 XtAddCallback(frdp->with, XmNactivateCallback,
|
|
3923 find_replace_callback, (XtPointer) FRD_R_FINDNEXT);
|
|
3924
|
|
3925 str = XmStringCreateSimple(_("Replace with:"));
|
|
3926 label_with = XtVaCreateManagedWidget("withLabel",
|
|
3927 xmLabelGadgetClass, input_form,
|
|
3928 XmNlabelString, str,
|
|
3929 XmNleftAttachment, XmATTACH_FORM,
|
|
3930 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3931 XmNtopWidget, frdp->what,
|
|
3932 XmNtopOffset, 4,
|
|
3933 XmNbottomAttachment, XmATTACH_FORM,
|
|
3934 NULL);
|
|
3935 XmStringFree(str);
|
44
|
3936 gui_motif_menu_fontlist(label_with);
|
7
|
3937
|
|
3938 /*
|
|
3939 * Make the entry activation only change the input focus onto the
|
|
3940 * with item.
|
|
3941 */
|
|
3942 XtAddCallback(frdp->what, XmNactivateCallback,
|
|
3943 entry_activate_callback, frdp->with);
|
|
3944 XtAddEventHandler(frdp->with, KeyPressMask, False,
|
|
3945 (XtEventHandler)find_replace_keypress,
|
|
3946 (XtPointer) frdp);
|
|
3947
|
|
3948 }
|
|
3949 else
|
|
3950 {
|
|
3951 /*
|
|
3952 * Make the entry activation do the search.
|
|
3953 */
|
|
3954 XtAddCallback(frdp->what, XmNactivateCallback,
|
|
3955 find_replace_callback, (XtPointer)FRD_FINDNEXT);
|
|
3956 }
|
|
3957 XtAddEventHandler(frdp->what, KeyPressMask, False,
|
|
3958 (XtEventHandler)find_replace_keypress,
|
|
3959 (XtPointer)frdp);
|
|
3960
|
|
3961 /* Get the maximum width between the label widgets and line them up.
|
|
3962 */
|
|
3963 n = 0;
|
|
3964 XtSetArg(args[n], XmNwidth, &width); n++;
|
|
3965 XtGetValues(label_what, args, n);
|
|
3966 widest = width;
|
|
3967 if (do_replace)
|
|
3968 {
|
|
3969 XtGetValues(label_with, args, n);
|
|
3970 if (width > widest)
|
|
3971 widest = width;
|
|
3972 }
|
|
3973
|
|
3974 XtVaSetValues(frdp->what, XmNleftOffset, widest, NULL);
|
|
3975 if (do_replace)
|
|
3976 XtVaSetValues(frdp->with, XmNleftOffset, widest, NULL);
|
|
3977
|
|
3978 }
|
|
3979
|
|
3980 XtManageChild(input_form);
|
|
3981
|
|
3982 {
|
|
3983 Widget radio_box;
|
44
|
3984 Widget w;
|
7
|
3985
|
|
3986 frame = XtVaCreateWidget("directionFrame",
|
|
3987 xmFrameWidgetClass, frdp->dialog,
|
|
3988 XmNtopAttachment, XmATTACH_WIDGET,
|
|
3989 XmNtopWidget, input_form,
|
|
3990 XmNtopOffset, 4,
|
|
3991 XmNbottomAttachment, XmATTACH_FORM,
|
|
3992 XmNbottomOffset, 4,
|
|
3993 XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET,
|
|
3994 XmNrightWidget, input_form,
|
|
3995 NULL);
|
|
3996
|
|
3997 str = XmStringCreateSimple(_("Direction"));
|
44
|
3998 w = XtVaCreateManagedWidget("directionFrameLabel",
|
7
|
3999 xmLabelGadgetClass, frame,
|
|
4000 XmNlabelString, str,
|
|
4001 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
|
|
4002 XmNchildType, XmFRAME_TITLE_CHILD,
|
|
4003 NULL);
|
|
4004 XmStringFree(str);
|
44
|
4005 gui_motif_menu_fontlist(w);
|
7
|
4006
|
|
4007 radio_box = XmCreateRadioBox(frame, "radioBox",
|
|
4008 (ArgList)NULL, 0);
|
|
4009
|
|
4010 str = XmStringCreateSimple( _("Up"));
|
|
4011 frdp->up = XtVaCreateManagedWidget("upRadioButton",
|
|
4012 xmToggleButtonGadgetClass, radio_box,
|
|
4013 XmNlabelString, str,
|
|
4014 XmNset, False,
|
|
4015 NULL);
|
|
4016 XmStringFree(str);
|
44
|
4017 gui_motif_menu_fontlist(frdp->up);
|
7
|
4018
|
|
4019 str = XmStringCreateSimple(_("Down"));
|
|
4020 frdp->down = XtVaCreateManagedWidget("downRadioButton",
|
|
4021 xmToggleButtonGadgetClass, radio_box,
|
|
4022 XmNlabelString, str,
|
|
4023 XmNset, True,
|
|
4024 NULL);
|
|
4025 XmStringFree(str);
|
44
|
4026 gui_motif_menu_fontlist(frdp->down);
|
7
|
4027
|
|
4028 XtManageChild(radio_box);
|
|
4029 XtManageChild(frame);
|
|
4030 }
|
|
4031
|
|
4032 toggle_form = XtVaCreateWidget("toggleForm",
|
|
4033 xmFormWidgetClass, frdp->dialog,
|
|
4034 XmNleftAttachment, XmATTACH_FORM,
|
|
4035 XmNleftOffset, 4,
|
|
4036 XmNrightAttachment, XmATTACH_WIDGET,
|
|
4037 XmNrightWidget, frame,
|
|
4038 XmNrightOffset, 4,
|
|
4039 XmNtopAttachment, XmATTACH_WIDGET,
|
|
4040 XmNtopWidget, input_form,
|
|
4041 XmNtopOffset, 4,
|
|
4042 XmNbottomAttachment, XmATTACH_FORM,
|
|
4043 XmNbottomOffset, 4,
|
|
4044 NULL);
|
|
4045
|
|
4046 str = XmStringCreateSimple(_("Match whole word only"));
|
|
4047 frdp->wword = XtVaCreateManagedWidget("wordToggle",
|
|
4048 xmToggleButtonGadgetClass, toggle_form,
|
|
4049 XmNlabelString, str,
|
|
4050 XmNtopAttachment, XmATTACH_FORM,
|
|
4051 XmNtopOffset, 4,
|
|
4052 XmNleftAttachment, XmATTACH_FORM,
|
|
4053 XmNleftOffset, 4,
|
|
4054 XmNset, wword,
|
|
4055 NULL);
|
|
4056 XmStringFree(str);
|
|
4057
|
|
4058 str = XmStringCreateSimple(_("Match case"));
|
|
4059 frdp->mcase = XtVaCreateManagedWidget("caseToggle",
|
|
4060 xmToggleButtonGadgetClass, toggle_form,
|
|
4061 XmNlabelString, str,
|
|
4062 XmNleftAttachment, XmATTACH_FORM,
|
|
4063 XmNleftOffset, 4,
|
|
4064 XmNtopAttachment, XmATTACH_WIDGET,
|
|
4065 XmNtopWidget, frdp->wword,
|
|
4066 XmNtopOffset, 4,
|
|
4067 XmNset, mcase,
|
|
4068 NULL);
|
|
4069 XmStringFree(str);
|
44
|
4070 gui_motif_menu_fontlist(frdp->wword);
|
|
4071 gui_motif_menu_fontlist(frdp->mcase);
|
7
|
4072
|
|
4073 XtManageChild(toggle_form);
|
|
4074
|
|
4075 if (entry_text != NULL)
|
|
4076 XmTextFieldSetString(frdp->what, (char *)entry_text);
|
|
4077 vim_free(entry_text);
|
|
4078
|
44
|
4079 gui_motif_synch_fonts();
|
|
4080
|
|
4081 manage_centered(frdp->dialog);
|
|
4082 activate_dialog_mnemonics(frdp->dialog);
|
7
|
4083 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT);
|
|
4084 }
|
|
4085
|
|
4086 void
|
|
4087 gui_mch_find_dialog(eap)
|
|
4088 exarg_T *eap;
|
|
4089 {
|
|
4090 if (!gui.in_use)
|
|
4091 return;
|
|
4092
|
|
4093 find_replace_dialog_create(eap->arg, FALSE);
|
|
4094 }
|
|
4095
|
|
4096
|
|
4097 void
|
|
4098 gui_mch_replace_dialog(eap)
|
|
4099 exarg_T *eap;
|
|
4100 {
|
|
4101 if (!gui.in_use)
|
|
4102 return;
|
|
4103
|
|
4104 find_replace_dialog_create(eap->arg, TRUE);
|
|
4105 }
|
44
|
4106
|
|
4107 /*
|
|
4108 * Synchronize all gui elements, which are dependant upon the
|
|
4109 * main text font used. Those are in esp. the find/replace dialogs.
|
|
4110 * If you don't understand why this should be needed, please try to
|
|
4111 * search for "pięść" in iso8859-2.
|
|
4112 */
|
|
4113 void
|
|
4114 gui_motif_synch_fonts(void)
|
|
4115 {
|
|
4116 SharedFindReplace *frdp;
|
|
4117 int do_replace;
|
|
4118 XFontStruct *font;
|
|
4119 XmFontList font_list;
|
|
4120
|
|
4121 /* FIXME: Unless we find out how to create a XmFontList from a XFontSet,
|
|
4122 * we just give up here on font synchronization. */
|
|
4123 font = (XFontStruct *)gui.norm_font;
|
|
4124 if (font == NULL)
|
|
4125 return;
|
|
4126
|
|
4127 font_list = gui_motif_create_fontlist(font);
|
|
4128
|
|
4129 /* OK this loop is a bit tricky... */
|
|
4130 for (do_replace = 0; do_replace <= 1; ++do_replace)
|
|
4131 {
|
|
4132 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets);
|
|
4133 if (frdp->dialog)
|
|
4134 {
|
|
4135 XtVaSetValues(frdp->what, XmNfontList, font_list, NULL);
|
|
4136 if (do_replace)
|
|
4137 XtVaSetValues(frdp->with, XmNfontList, font_list, NULL);
|
|
4138 }
|
|
4139 }
|
|
4140
|
|
4141 XmFontListFree(font_list);
|
|
4142 }
|