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