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