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