Mercurial > vim
annotate src/gui_motif.c @ 21085:bc81b275d4d6 v8.2.1094
patch 8.2.1094: dead code in libvterm
Commit: https://github.com/vim/vim/commit/a53618dd1dd91c7bb67b5dfc83dc29371b47f55b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 29 23:14:02 2020 +0200
patch 8.2.1094: dead code in libvterm
Problem: Dead code in libvterm.
Solution: Remove condition that is always true.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 29 Jun 2020 23:15:05 +0200 |
parents | 8590a462ad46 |
children | fcccc29bd386 |
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 { | |
20421
8590a462ad46
patch 8.2.0765: In the GUI can't use all the modifiers.
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1241 # if 0 // DISABLED - this causes a crash when running "make test_gui" in |
8590a462ad46
patch 8.2.0765: In the GUI can't use all the modifiers.
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1242 // Test_colorscheme() |
161 | 1243 if (menu->xpm_fname != NULL) |
1244 XtSetArg(args[n], XmNpixmapFile, menu->xpm_fname); n++; | |
20421
8590a462ad46
patch 8.2.0765: In the GUI can't use all the modifiers.
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1245 # endif |
161 | 1246 XtSetArg(args[n], XmNpixmapData, menu->xpm); n++; |
1247 XtSetArg(args[n], XmNlabelLocation, XmBOTTOM); n++; | |
1248 } | |
1249 return n; | |
1250 } | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1251 #endif // FEAT_TOOLBAR |
7 | 1252 |
1253 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1254 gui_mch_add_menu_item(vimmenu_T *menu, int idx) |
7 | 1255 { |
1256 XmString label; | |
1257 vimmenu_T *parent = menu->parent; | |
1258 | |
1259 # ifdef EBCDIC | |
1260 menu->mnemonic = 0; | |
1261 # endif | |
1262 | |
1263 # if (XmVersion <= 1002) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1264 // Don't add Popup menu items when the popup menu isn't used. |
7 | 1265 if (menu_is_child_of_popup(menu) && !mouse_model_popup()) |
1266 return; | |
1267 # endif | |
1268 | |
1269 # ifdef FEAT_TOOLBAR | |
1270 if (menu_is_toolbar(parent->name)) | |
1271 { | |
1272 WidgetClass type; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1273 XmString xms = NULL; // fallback label if pixmap not found |
7 | 1274 int n; |
1275 Arg args[18]; | |
1276 | |
1277 n = 0; | |
1278 if (menu_is_separator(menu->name)) | |
1279 { | |
1280 char *cp; | |
1281 Dimension wid; | |
1282 | |
1283 /* | |
1284 * A separator has the format "-sep%d[:%d]-". The optional :%d is | |
1285 * a width specifier. If no width is specified then we choose one. | |
1286 */ | |
1287 cp = (char *)vim_strchr(menu->name, ':'); | |
1288 if (cp != NULL) | |
1289 wid = (Dimension)atoi(++cp); | |
1290 else | |
1291 wid = 4; | |
1292 | |
1293 type = xmSeparatorWidgetClass; | |
1294 XtSetArg(args[n], XmNwidth, wid); n++; | |
1295 XtSetArg(args[n], XmNminWidth, wid); n++; | |
1296 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; | |
48 | 1297 XtSetArg(args[n], XmNseparatorType, XmSHADOW_ETCHED_IN); n++; |
7 | 1298 } |
1299 else | |
1300 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1301 // 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
|
1302 // 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
|
1303 // Need the highlightThickness to see the focus. |
44 | 1304 XtSetArg(args[n], XmNhighlightThickness, 1); n++; |
7 | 1305 XtSetArg(args[n], XmNhighlightOnEnter, True); n++; |
1306 XtSetArg(args[n], XmNmarginWidth, 0); n++; | |
1307 XtSetArg(args[n], XmNmarginHeight, 0); n++; | |
54 | 1308 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
|
1309 // 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
|
1310 // by changing the XmNlabelType resource. |
48 | 1311 xms = XmStringCreate((char *)menu->dname, STRING_TAG); |
1312 XtSetArg(args[n], XmNlabelString, xms); n++; | |
1313 | |
161 | 1314 n = add_pixmap_args(menu, args, n); |
1315 | |
48 | 1316 type = xmEnhancedButtonWidgetClass; |
7 | 1317 } |
1318 | |
1319 XtSetArg(args[n], XmNpositionIndex, idx); n++; | |
1320 if (menu->id == NULL) | |
1321 { | |
1322 menu->id = XtCreateManagedWidget((char *)menu->dname, | |
1323 type, toolBar, args, n); | |
48 | 1324 if (menu->id != NULL && type == xmEnhancedButtonWidgetClass) |
7 | 1325 { |
1326 XtAddCallback(menu->id, | |
1327 XmNactivateCallback, gui_x11_menu_cb, menu); | |
1328 # ifdef FEAT_FOOTER | |
1329 XtAddEventHandler(menu->id, EnterWindowMask, False, | |
1330 toolbarbutton_enter_cb, menu); | |
1331 XtAddEventHandler(menu->id, LeaveWindowMask, False, | |
1332 toolbarbutton_leave_cb, menu); | |
1333 # endif | |
1334 } | |
1335 } | |
1336 else | |
1337 XtSetValues(menu->id, args, n); | |
1338 if (xms != NULL) | |
1339 XmStringFree(xms); | |
1340 | |
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
|
1341 # ifdef FEAT_BEVAL_GUI |
7 | 1342 gui_mch_menu_set_tip(menu); |
844 | 1343 # endif |
7 | 1344 |
1345 menu->parent = parent; | |
1346 menu->submenu_id = NULL; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1347 // When adding first item to toolbar it might have to be enabled . |
7 | 1348 if (!XtIsManaged(XtParent(toolBar)) |
1349 && vim_strchr(p_go, GO_TOOLBAR) != NULL) | |
1350 gui_mch_show_toolbar(TRUE); | |
1351 gui.toolbar_height = gui_mch_compute_toolbar_height(); | |
1352 return; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1353 } // toolbar menu item |
7 | 1354 # endif |
1355 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1356 // No parent, must be a non-menubar menu |
7 | 1357 if (parent->submenu_id == (Widget)0) |
1358 return; | |
1359 | |
1360 menu->submenu_id = (Widget)0; | |
1361 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1362 // Add menu separator |
7 | 1363 if (menu_is_separator(menu->name)) |
1364 { | |
1365 menu->id = XtVaCreateWidget("subMenu", | |
1366 xmSeparatorGadgetClass, parent->submenu_id, | |
1367 #if (XmVersion >= 1002) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1368 // count the tearoff item (needed for LessTif) |
7 | 1369 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED |
1370 ? 1 : 0), | |
1371 #endif | |
1372 NULL); | |
1373 gui_motif_menu_colors(menu->id); | |
1374 return; | |
1375 } | |
1376 | |
1377 label = XmStringCreate((char *)menu->dname, STRING_TAG); | |
1378 if (label == NULL) | |
1379 return; | |
1380 menu->id = XtVaCreateWidget("subMenu", | |
1381 xmPushButtonWidgetClass, parent->submenu_id, | |
1382 XmNlabelString, label, | |
1383 XmNmnemonic, menu->mnemonic, | |
1384 #if (XmVersion >= 1002) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1385 // count the tearoff item (needed for LessTif) |
7 | 1386 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED |
1387 ? 1 : 0), | |
1388 #endif | |
1389 NULL); | |
1390 gui_motif_menu_colors(menu->id); | |
1391 gui_motif_menu_fontlist(menu->id); | |
1392 XmStringFree(label); | |
1393 | |
1394 if (menu->id != (Widget)0) | |
1395 { | |
1396 XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb, | |
1397 (XtPointer)menu); | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1398 // add accelerator text |
7 | 1399 gui_motif_add_actext(menu); |
1400 } | |
1401 } | |
1402 | |
1403 #if (XmVersion <= 1002) || defined(PROTO) | |
1404 /* | |
1405 * This function will destroy/create the popup menus dynamically, | |
1406 * according to the value of 'mousemodel'. | |
1407 * This will fix the "right mouse button freeze" that occurs when | |
1408 * there exists a popup menu but it isn't managed. | |
1409 */ | |
1410 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1411 gui_motif_update_mousemodel(vimmenu_T *menu) |
7 | 1412 { |
1413 int idx = 0; | |
1414 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1415 // When GUI hasn't started the menus have not been created. |
7 | 1416 if (!gui.in_use) |
1417 return; | |
1418 | |
1419 while (menu) | |
1420 { | |
1421 if (menu->children != NULL) | |
1422 { | |
1423 if (menu_is_popup(menu->name)) | |
1424 { | |
1425 if (mouse_model_popup()) | |
1426 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1427 // Popup menu will be used. Create the popup menus. |
7 | 1428 gui_mch_add_menu(menu, idx); |
1429 gui_motif_update_mousemodel(menu->children); | |
1430 } | |
1431 else | |
1432 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1433 // Popup menu will not be used. Destroy the popup menus. |
7 | 1434 gui_motif_update_mousemodel(menu->children); |
1435 gui_mch_destroy_menu(menu); | |
1436 } | |
1437 } | |
1438 } | |
1439 else if (menu_is_child_of_popup(menu)) | |
1440 { | |
1441 if (mouse_model_popup()) | |
1442 gui_mch_add_menu_item(menu, idx); | |
1443 else | |
1444 gui_mch_destroy_menu(menu); | |
1445 } | |
1446 menu = menu->next; | |
1447 ++idx; | |
1448 } | |
1449 } | |
1450 #endif | |
1451 | |
1452 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1453 gui_mch_new_menu_colors(void) |
7 | 1454 { |
1455 if (menuBar == (Widget)0) | |
1456 return; | |
1457 gui_motif_menu_colors(menuBar); | |
1458 #ifdef FEAT_TOOLBAR | |
1459 gui_motif_menu_colors(toolBarFrame); | |
1460 gui_motif_menu_colors(toolBar); | |
1461 #endif | |
1462 | |
54 | 1463 submenu_change(root_menu, TRUE); |
7 | 1464 } |
1465 | |
1466 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1467 gui_mch_new_menu_font(void) |
7 | 1468 { |
1469 if (menuBar == (Widget)0) | |
1470 return; | |
54 | 1471 submenu_change(root_menu, FALSE); |
7 | 1472 { |
1473 Dimension height; | |
1474 Position w, h; | |
1475 | |
1476 XtVaGetValues(menuBar, XmNheight, &height, NULL); | |
1477 gui.menu_height = height; | |
1478 | |
1479 XtVaGetValues(vimShell, XtNwidth, &w, XtNheight, &h, NULL); | |
1480 gui_resize_shell(w, h | |
1481 #ifdef FEAT_XIM | |
1482 - xim_get_status_area_height() | |
1483 #endif | |
1484 ); | |
1485 } | |
811 | 1486 gui_set_shellsize(FALSE, TRUE, RESIZE_VERT); |
7 | 1487 ui_new_shellsize(); |
1488 } | |
1489 | |
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
|
1490 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) |
7 | 1491 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1492 gui_mch_new_tooltip_font(void) |
7 | 1493 { |
1494 # ifdef FEAT_TOOLBAR | |
1495 vimmenu_T *menu; | |
1496 | |
1497 if (toolBar == (Widget)0) | |
1498 return; | |
1499 | |
1500 menu = gui_find_menu((char_u *)"ToolBar"); | |
1501 if (menu != NULL) | |
54 | 1502 submenu_change(menu, FALSE); |
7 | 1503 # endif |
1504 } | |
1505 | |
1506 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1507 gui_mch_new_tooltip_colors(void) |
7 | 1508 { |
1509 # ifdef FEAT_TOOLBAR | |
1510 vimmenu_T *toolbar; | |
1511 | |
1512 if (toolBar == (Widget)0) | |
1513 return; | |
1514 | |
1515 toolbar = gui_find_menu((char_u *)"ToolBar"); | |
1516 if (toolbar != NULL) | |
54 | 1517 submenu_change(toolbar, TRUE); |
7 | 1518 # endif |
1519 } | |
1520 #endif | |
1521 | |
1522 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1523 submenu_change( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1524 vimmenu_T *menu, |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1525 int colors) // TRUE for colors, FALSE for font |
7 | 1526 { |
1527 vimmenu_T *mp; | |
1528 | |
1529 for (mp = menu; mp != NULL; mp = mp->next) | |
1530 { | |
1531 if (mp->id != (Widget)0) | |
1532 { | |
1533 if (colors) | |
1534 { | |
1535 gui_motif_menu_colors(mp->id); | |
1536 #ifdef FEAT_TOOLBAR | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1537 // 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
|
1538 // so that the background color is right. |
48 | 1539 if (mp->xpm != NULL) |
7 | 1540 { |
48 | 1541 int n = 0; |
1542 Arg args[18]; | |
1543 | |
161 | 1544 n = add_pixmap_args(mp, args, n); |
48 | 1545 XtSetValues(mp->id, args, n); |
7 | 1546 } |
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
|
1547 # ifdef FEAT_BEVAL_GUI |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1548 // If we have a tooltip, then we need to change its font |
7 | 1549 if (mp->tip != NULL) |
1550 { | |
1551 Arg args[2]; | |
1552 | |
1553 args[0].name = XmNbackground; | |
1554 args[0].value = gui.tooltip_bg_pixel; | |
1555 args[1].name = XmNforeground; | |
1556 args[1].value = gui.tooltip_fg_pixel; | |
1557 XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args)); | |
1558 } | |
1559 # endif | |
1560 #endif | |
1561 } | |
1562 else | |
1563 { | |
1564 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
|
1565 #ifdef FEAT_BEVAL_GUI |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1566 // If we have a tooltip, then we need to change its font |
7 | 1567 if (mp->tip != NULL) |
1568 { | |
1569 Arg args[1]; | |
1570 | |
1571 args[0].name = XmNfontList; | |
1572 args[0].value = (XtArgVal)gui_motif_fontset2fontlist( | |
1573 &gui.tooltip_fontset); | |
1574 XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args)); | |
1575 } | |
1576 #endif | |
1577 } | |
1578 } | |
1579 | |
1580 if (mp->children != NULL) | |
1581 { | |
1582 #if (XmVersion >= 1002) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1583 // Set the colors/font for the tear off widget |
7 | 1584 if (mp->submenu_id != (Widget)0) |
1585 { | |
1586 if (colors) | |
1587 gui_motif_menu_colors(mp->submenu_id); | |
1588 else | |
1589 gui_motif_menu_fontlist(mp->submenu_id); | |
1590 toggle_tearoff(mp->submenu_id); | |
1591 } | |
1592 #endif | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1593 // Set the colors for the children |
54 | 1594 submenu_change(mp->children, colors); |
7 | 1595 } |
1596 } | |
1597 } | |
1598 | |
1599 /* | |
1600 * Destroy the machine specific menu widget. | |
1601 */ | |
1602 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1603 gui_mch_destroy_menu(vimmenu_T *menu) |
7 | 1604 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1605 // 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
|
1606 // 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
|
1607 // deleted first... |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1608 // |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1609 // 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
|
1610 // because they are both Xt based. |
7 | 1611 if (menu->submenu_id != (Widget)0) |
1612 { | |
1613 XtDestroyWidget(menu->submenu_id); | |
1614 menu->submenu_id = (Widget)0; | |
1615 } | |
1616 | |
1617 if (menu->id != (Widget)0) | |
1618 { | |
1619 Widget parent; | |
1620 | |
1621 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
|
1622 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) |
216 | 1623 if (parent == toolBar && menu->tip != NULL) |
7 | 1624 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1625 // 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
|
1626 // 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
|
1627 // destruction. |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1628 // |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1629 // 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
|
1630 // 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
|
1631 // 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
|
1632 // a core dump). |
7 | 1633 gui_mch_destroy_beval_area(menu->tip); |
1634 menu->tip = NULL; | |
1635 } | |
1636 #endif | |
1637 XtDestroyWidget(menu->id); | |
1638 menu->id = (Widget)0; | |
1639 if (parent == menuBar) | |
1640 gui_mch_compute_menu_height((Widget)0); | |
1641 #ifdef FEAT_TOOLBAR | |
1642 else if (parent == toolBar) | |
1643 { | |
1644 Cardinal num_children; | |
1645 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1646 // When removing last toolbar item, don't display the toolbar. |
7 | 1647 XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL); |
1648 if (num_children == 0) | |
1649 gui_mch_show_toolbar(FALSE); | |
1650 else | |
1651 gui.toolbar_height = gui_mch_compute_toolbar_height(); | |
1652 } | |
1653 #endif | |
1654 } | |
1655 } | |
1656 | |
1657 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1658 gui_mch_show_popupmenu(vimmenu_T *menu UNUSED) |
7 | 1659 { |
1660 #ifdef MOTIF_POPUP | |
1661 XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event()); | |
1662 XtManageChild(menu->submenu_id); | |
1663 #endif | |
1664 } | |
1665 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1666 #endif // FEAT_MENU |
7 | 1667 |
1668 /* | |
1669 * Set the menu and scrollbar colors to their default values. | |
1670 */ | |
1671 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1672 gui_mch_def_colors(void) |
7 | 1673 { |
1674 if (gui.in_use) | |
1675 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1676 // 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
|
1677 // window manager or a resources file. |
7 | 1678 gui.menu_fg_pixel = gui.menu_def_fg_pixel; |
1679 gui.menu_bg_pixel = gui.menu_def_bg_pixel; | |
1680 gui.scroll_fg_pixel = gui.scroll_def_fg_pixel; | |
1681 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
|
1682 #ifdef FEAT_BEVAL_GUI |
7 | 1683 gui.tooltip_fg_pixel = |
1684 gui_get_color((char_u *)gui.rsrc_tooltip_fg_name); | |
1685 gui.tooltip_bg_pixel = | |
1686 gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); | |
1687 #endif | |
1688 } | |
1689 } | |
1690 | |
1691 | |
1692 /* | |
1693 * Scrollbar stuff. | |
1694 */ | |
1695 | |
1696 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1697 gui_mch_set_scrollbar_thumb( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1698 scrollbar_T *sb, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1699 long val, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1700 long size, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1701 long max) |
7 | 1702 { |
1703 if (sb->id != (Widget)0) | |
1704 XtVaSetValues(sb->id, | |
1705 XmNvalue, val, | |
1706 XmNsliderSize, size, | |
1707 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
|
1708 XmNmaximum, max + 1, // Motif has max one past the end |
7 | 1709 NULL); |
1710 } | |
1711 | |
1712 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1713 gui_mch_set_scrollbar_pos( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1714 scrollbar_T *sb, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1715 int x, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1716 int y, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1717 int w, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1718 int h) |
7 | 1719 { |
1720 if (sb->id != (Widget)0) | |
1721 { | |
1722 if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT) | |
1723 { | |
1724 if (y == 0) | |
1725 h -= gui.border_offset; | |
1726 else | |
1727 y -= gui.border_offset; | |
1728 XtVaSetValues(sb->id, | |
1729 XmNtopOffset, y, | |
1730 XmNbottomOffset, -y - h, | |
1731 XmNwidth, w, | |
1732 NULL); | |
1733 } | |
1734 else | |
1735 XtVaSetValues(sb->id, | |
1736 XmNtopOffset, y, | |
1737 XmNleftOffset, x, | |
1738 XmNrightOffset, gui.which_scrollbars[SBAR_RIGHT] | |
1739 ? gui.scrollbar_width : 0, | |
1740 XmNheight, h, | |
1741 NULL); | |
1742 XtManageChild(sb->id); | |
1743 } | |
1744 } | |
1745 | |
1746 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1747 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) |
7 | 1748 { |
1749 Arg args[16]; | |
1750 int n; | |
1751 | |
1752 if (sb->id != (Widget)0) | |
1753 { | |
1754 n = 0; | |
1755 if (flag) | |
1756 { | |
1757 switch (sb->type) | |
1758 { | |
1759 case SBAR_LEFT: | |
1760 XtSetArg(args[n], XmNleftOffset, gui.scrollbar_width); n++; | |
1761 break; | |
1762 | |
1763 case SBAR_RIGHT: | |
1764 XtSetArg(args[n], XmNrightOffset, gui.scrollbar_width); n++; | |
1765 break; | |
1766 | |
1767 case SBAR_BOTTOM: | |
1768 XtSetArg(args[n], XmNbottomOffset, gui.scrollbar_height);n++; | |
1769 break; | |
1770 } | |
1771 XtSetValues(textArea, args, n); | |
1772 XtManageChild(sb->id); | |
1773 } | |
1774 else | |
1775 { | |
1776 if (!gui.which_scrollbars[sb->type]) | |
1777 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1778 // 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
|
1779 // textArea attachment offset. |
7 | 1780 switch (sb->type) |
1781 { | |
1782 case SBAR_LEFT: | |
1783 XtSetArg(args[n], XmNleftOffset, 0); n++; | |
1784 break; | |
1785 | |
1786 case SBAR_RIGHT: | |
1787 XtSetArg(args[n], XmNrightOffset, 0); n++; | |
1788 break; | |
1789 | |
1790 case SBAR_BOTTOM: | |
1791 XtSetArg(args[n], XmNbottomOffset, 0);n++; | |
1792 break; | |
1793 } | |
1794 XtSetValues(textArea, args, n); | |
1795 } | |
1796 XtUnmanageChild(sb->id); | |
1797 } | |
1798 } | |
1799 } | |
1800 | |
1801 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1802 gui_mch_create_scrollbar( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1803 scrollbar_T *sb, |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1804 int orient) // SBAR_VERT or SBAR_HORIZ |
7 | 1805 { |
1806 Arg args[16]; | |
1807 int n; | |
1808 | |
1809 n = 0; | |
1810 XtSetArg(args[n], XmNminimum, 0); n++; | |
1811 XtSetArg(args[n], XmNorientation, | |
1812 (orient == SBAR_VERT) ? XmVERTICAL : XmHORIZONTAL); n++; | |
1813 | |
1814 switch (sb->type) | |
1815 { | |
1816 case SBAR_LEFT: | |
1817 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; | |
1818 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_FORM); n++; | |
1819 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; | |
1820 break; | |
1821 | |
1822 case SBAR_RIGHT: | |
1823 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; | |
1824 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_FORM); n++; | |
1825 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; | |
1826 break; | |
1827 | |
1828 case SBAR_BOTTOM: | |
1829 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; | |
1830 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; | |
1831 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; | |
1832 break; | |
1833 } | |
1834 | |
1835 sb->id = XtCreateWidget("scrollBar", | |
1836 xmScrollBarWidgetClass, textAreaForm, args, n); | |
1837 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1838 // Remember the default colors, needed for ":hi clear". |
7 | 1839 if (gui.scroll_def_bg_pixel == (guicolor_T)0 |
1840 && gui.scroll_def_fg_pixel == (guicolor_T)0) | |
1841 XtVaGetValues(sb->id, | |
1842 XmNbackground, &gui.scroll_def_bg_pixel, | |
1843 XmNforeground, &gui.scroll_def_fg_pixel, | |
1844 NULL); | |
1845 | |
1846 if (sb->id != (Widget)0) | |
1847 { | |
1848 gui_mch_set_scrollbar_colors(sb); | |
1849 XtAddCallback(sb->id, XmNvalueChangedCallback, | |
1850 scroll_cb, (XtPointer)sb->ident); | |
1851 XtAddCallback(sb->id, XmNdragCallback, | |
1852 scroll_cb, (XtPointer)sb->ident); | |
1853 XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb, | |
1854 (XtPointer)0); | |
1855 } | |
1856 } | |
1857 | |
1858 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1859 gui_mch_destroy_scrollbar(scrollbar_T *sb) |
7 | 1860 { |
1861 if (sb->id != (Widget)0) | |
1862 XtDestroyWidget(sb->id); | |
1863 } | |
1864 | |
1865 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1866 gui_mch_set_scrollbar_colors(scrollbar_T *sb) |
7 | 1867 { |
1868 if (sb->id != (Widget)0) | |
1869 { | |
1870 if (gui.scroll_bg_pixel != INVALCOLOR) | |
1871 { | |
1872 #if (XmVersion>=1002) | |
1873 XmChangeColor(sb->id, gui.scroll_bg_pixel); | |
1874 #else | |
1875 XtVaSetValues(sb->id, | |
1876 XmNtroughColor, gui.scroll_bg_pixel, | |
1877 NULL); | |
1878 #endif | |
1879 } | |
1880 | |
1881 if (gui.scroll_fg_pixel != INVALCOLOR) | |
1882 XtVaSetValues(sb->id, | |
1883 XmNforeground, gui.scroll_fg_pixel, | |
1884 #if (XmVersion<1002) | |
1885 XmNbackground, gui.scroll_fg_pixel, | |
1886 #endif | |
1887 NULL); | |
1888 } | |
1889 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1890 // This is needed for the rectangle below the vertical scrollbars. |
7 | 1891 if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0) |
1892 gui_motif_scroll_colors(textAreaForm); | |
1893 } | |
1894 | |
1895 /* | |
1896 * Miscellaneous stuff: | |
1897 */ | |
1898 | |
1899 Window | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
1900 gui_x11_get_wid(void) |
7 | 1901 { |
1902 return(XtWindow(textArea)); | |
1903 } | |
1904 | |
44 | 1905 /* |
1906 * Look for a widget in the widget tree w, with a mnemonic matching keycode. | |
1907 * When one is found, simulate a button press on that widget and give it the | |
1908 * keyboard focus. If the mnemonic is on a label, look in the userData field | |
1909 * of the label to see if it points to another widget, and give that the focus. | |
1910 */ | |
1911 static void | |
1912 do_mnemonic(Widget w, unsigned int keycode) | |
1913 { | |
1914 WidgetList children; | |
1915 int numChildren, i; | |
1916 Boolean isMenu; | |
1917 KeySym mnemonic = '\0'; | |
1918 char mneString[2]; | |
1919 Widget userData; | |
1920 unsigned char rowColType; | |
1921 | |
1922 if (XtIsComposite(w)) | |
1923 { | |
1924 if (XtClass(w) == xmRowColumnWidgetClass) | |
1925 { | |
1604 | 1926 XtVaGetValues(w, XmNrowColumnType, &rowColType, NULL); |
44 | 1927 isMenu = (rowColType != (unsigned char)XmWORK_AREA); |
1928 } | |
1929 else | |
1930 isMenu = False; | |
1931 if (!isMenu) | |
1932 { | |
1933 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren, | |
1604 | 1934 &numChildren, NULL); |
44 | 1935 for (i = 0; i < numChildren; i++) |
1936 do_mnemonic(children[i], keycode); | |
1937 } | |
1938 } | |
1939 else | |
1940 { | |
1604 | 1941 XtVaGetValues(w, XmNmnemonic, &mnemonic, NULL); |
44 | 1942 if (mnemonic != '\0') |
1943 { | |
1944 mneString[0] = mnemonic; | |
1945 mneString[1] = '\0'; | |
1946 if (XKeysymToKeycode(XtDisplay(XtParent(w)), | |
1947 XStringToKeysym(mneString)) == keycode) | |
1948 { | |
1949 if (XtClass(w) == xmLabelWidgetClass | |
1950 || XtClass(w) == xmLabelGadgetClass) | |
1951 { | |
1604 | 1952 XtVaGetValues(w, XmNuserData, &userData, NULL); |
44 | 1953 if (userData != NULL && XtIsWidget(userData)) |
1954 XmProcessTraversal(userData, XmTRAVERSE_CURRENT); | |
1955 } | |
1956 else | |
1957 { | |
1958 XKeyPressedEvent keyEvent; | |
1959 | |
1960 XmProcessTraversal(w, XmTRAVERSE_CURRENT); | |
1961 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1962 CLEAR_FIELD(keyEvent); |
44 | 1963 keyEvent.type = KeyPress; |
1964 keyEvent.serial = 1; | |
1965 keyEvent.send_event = True; | |
1966 keyEvent.display = XtDisplay(w); | |
1967 keyEvent.window = XtWindow(w); | |
1968 XtCallActionProc(w, "Activate", (XEvent *) & keyEvent, | |
1969 NULL, 0); | |
1970 } | |
1971 } | |
1972 } | |
1973 } | |
1974 } | |
1975 | |
1976 /* | |
1977 * Callback routine for dialog mnemonic processing. | |
1978 */ | |
1979 static void | |
1887 | 1980 mnemonic_event(Widget w, XtPointer call_data UNUSED, XKeyEvent *event) |
44 | 1981 { |
1982 do_mnemonic(w, event->keycode); | |
1983 } | |
1984 | |
1985 | |
1986 /* | |
1987 * Search the widget tree under w for widgets with mnemonics. When found, add | |
1988 * a passive grab to the dialog widget for the mnemonic character, thus | |
1989 * directing mnemonic events to the dialog widget. | |
1990 */ | |
1991 static void | |
1992 add_mnemonic_grabs(Widget dialog, Widget w) | |
1993 { | |
1994 char mneString[2]; | |
1995 WidgetList children; | |
1996 int numChildren, i; | |
1997 Boolean isMenu; | |
1998 KeySym mnemonic = '\0'; | |
1999 unsigned char rowColType; | |
2000 | |
2001 if (XtIsComposite(w)) | |
2002 { | |
2003 if (XtClass(w) == xmRowColumnWidgetClass) | |
2004 { | |
1604 | 2005 XtVaGetValues(w, XmNrowColumnType, &rowColType, NULL); |
44 | 2006 isMenu = (rowColType != (unsigned char)XmWORK_AREA); |
2007 } | |
2008 else | |
2009 isMenu = False; | |
2010 if (!isMenu) | |
2011 { | |
2012 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren, | |
1604 | 2013 &numChildren, NULL); |
44 | 2014 for (i = 0; i < numChildren; i++) |
2015 add_mnemonic_grabs(dialog, children[i]); | |
2016 } | |
2017 } | |
2018 else | |
2019 { | |
1604 | 2020 XtVaGetValues(w, XmNmnemonic, &mnemonic, NULL); |
44 | 2021 if (mnemonic != '\0') |
2022 { | |
2023 mneString[0] = mnemonic; | |
2024 mneString[1] = '\0'; | |
2025 XtGrabKey(dialog, XKeysymToKeycode(XtDisplay(dialog), | |
2026 XStringToKeysym(mneString)), | |
2027 Mod1Mask, True, GrabModeAsync, GrabModeAsync); | |
2028 } | |
2029 } | |
2030 } | |
2031 | |
2032 /* | |
2033 * Add a handler for mnemonics in a dialog. Motif itself only handles | |
2034 * mnemonics in menus. Mnemonics added or changed after this call will be | |
2035 * ignored. | |
2036 * | |
2037 * To add a mnemonic to a text field or list, set the XmNmnemonic resource on | |
2038 * the appropriate label and set the XmNuserData resource of the label to the | |
2039 * widget to get the focus when the mnemonic is typed. | |
2040 */ | |
2041 static void | |
2042 activate_dialog_mnemonics(Widget dialog) | |
2043 { | |
2044 if (!dialog) | |
2045 return; | |
2046 | |
2047 XtAddEventHandler(dialog, KeyPressMask, False, | |
2048 (XtEventHandler) mnemonic_event, (XtPointer) NULL); | |
2049 add_mnemonic_grabs(dialog, dialog); | |
2050 } | |
2051 | |
2052 /* | |
2053 * Removes the event handler and key-grabs for dialog mnemonic handling. | |
2054 */ | |
2055 static void | |
2056 suppress_dialog_mnemonics(Widget dialog) | |
2057 { | |
2058 if (!dialog) | |
2059 return; | |
2060 | |
2061 XtUngrabKey(dialog, AnyKey, Mod1Mask); | |
2062 XtRemoveEventHandler(dialog, KeyPressMask, False, | |
2063 (XtEventHandler) mnemonic_event, (XtPointer) NULL); | |
2064 } | |
2065 | |
2066 #if defined(FEAT_BROWSE) || defined(FEAT_GUI_DIALOG) | |
2067 /* | |
2068 * Use the 'guifont' or 'guifontset' as a fontlist for a dialog widget. | |
2069 */ | |
2070 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2071 set_fontlist(Widget id) |
44 | 2072 { |
2073 XmFontList fl; | |
2074 | |
2075 #ifdef FONTSET_ALWAYS | |
48 | 2076 if (gui.fontset != NOFONTSET) |
2077 { | |
44 | 2078 fl = gui_motif_fontset2fontlist((XFontSet *)&gui.fontset); |
2079 if (fl != NULL) | |
2080 { | |
2081 if (XtIsManaged(id)) | |
2082 { | |
2083 XtUnmanageChild(id); | |
2084 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
|
2085 // 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
|
2086 // geometry now. |
44 | 2087 XtManageChild(id); |
2088 } | |
2089 else | |
2090 XtVaSetValues(id, XmNfontList, fl, NULL); | |
2091 XmFontListFree(fl); | |
2092 } | |
2093 } | |
2094 #else | |
48 | 2095 if (gui.norm_font != NOFONT) |
2096 { | |
44 | 2097 fl = gui_motif_create_fontlist((XFontStruct *)gui.norm_font); |
2098 if (fl != NULL) | |
2099 { | |
2100 if (XtIsManaged(id)) | |
2101 { | |
2102 XtUnmanageChild(id); | |
2103 XtVaSetValues(id, XmNfontList, fl, NULL); | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2104 // We should force the widget to recalculate its |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2105 // geometry now. |
44 | 2106 XtManageChild(id); |
2107 } | |
2108 else | |
2109 XtVaSetValues(id, XmNfontList, fl, NULL); | |
2110 XmFontListFree(fl); | |
2111 } | |
2112 } | |
2113 #endif | |
2114 } | |
2115 #endif | |
7 | 2116 |
2117 #if defined(FEAT_BROWSE) || defined(PROTO) | |
2118 | |
2119 /* | |
2120 * file selector related stuff | |
2121 */ | |
2122 | |
2123 #include <Xm/FileSB.h> | |
2124 #include <Xm/XmStrDefs.h> | |
2125 | |
2126 typedef struct dialog_callback_arg | |
2127 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2128 char * args; // not used right now |
7 | 2129 int id; |
2130 } dcbarg_T; | |
2131 | |
2132 static Widget dialog_wgt; | |
2133 static char *browse_fname = NULL; | |
2134 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
|
2135 // used to set up XmStrings |
7 | 2136 |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6819
diff
changeset
|
2137 static void DialogCancelCB(Widget, XtPointer, XtPointer); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6819
diff
changeset
|
2138 static void DialogAcceptCB(Widget, XtPointer, XtPointer); |
7 | 2139 |
2140 /* | |
2141 * This function is used to translate the predefined label text of the | |
2142 * precomposed dialogs. We do this explicitly to allow: | |
2143 * | |
2144 * - usage of gettext for translation, as in all the other places. | |
2145 * | |
2146 * - equalize the messages between different GUI implementations as far as | |
2147 * possible. | |
2148 */ | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2149 static void |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2150 set_predefined_label(Widget parent, String name, char *new_label) |
7 | 2151 { |
44 | 2152 XmString str; |
2153 Widget w; | |
2154 char_u *p, *next; | |
2155 KeySym mnemonic = NUL; | |
7 | 2156 |
2157 w = XtNameToWidget(parent, name); | |
2158 | |
2159 if (!w) | |
2160 return; | |
2161 | |
44 | 2162 p = vim_strsave((char_u *)new_label); |
2163 if (p == NULL) | |
2164 return; | |
2165 for (next = p; *next; ++next) | |
7 | 2166 { |
44 | 2167 if (*next == DLG_HOTKEY_CHAR) |
2168 { | |
2169 int len = STRLEN(next); | |
2170 | |
2171 if (len > 0) | |
2172 { | |
2173 mch_memmove(next, next + 1, len); | |
2174 mnemonic = next[0]; | |
2175 } | |
2176 } | |
2177 } | |
2178 | |
2179 str = XmStringCreate((char *)p, STRING_TAG); | |
2180 vim_free(p); | |
2181 | |
2182 if (str != NULL) | |
2183 { | |
2184 XtVaSetValues(w, | |
2185 XmNlabelString, str, | |
2186 XmNmnemonic, mnemonic, | |
2187 NULL); | |
7 | 2188 XmStringFree(str); |
2189 } | |
44 | 2190 gui_motif_menu_fontlist(w); |
2191 } | |
2192 | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2193 static void |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2194 set_predefined_fontlist(Widget parent, String name) |
44 | 2195 { |
2196 Widget w; | |
2197 w = XtNameToWidget(parent, name); | |
2198 | |
2199 if (!w) | |
2200 return; | |
2201 | |
2202 set_fontlist(w); | |
7 | 2203 } |
2204 | |
2205 /* | |
2206 * Put up a file requester. | |
2207 * Returns the selected name in allocated memory, or NULL for Cancel. | |
2208 */ | |
2209 char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2210 gui_mch_browse( |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2211 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
|
2212 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
|
2213 char_u *dflt, // default name |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2214 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
|
2215 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
|
2216 char_u *filter) // file name filter |
7 | 2217 { |
2218 char_u dirbuf[MAXPATHL]; | |
2219 char_u dfltbuf[MAXPATHL]; | |
2220 char_u *pattern; | |
2221 char_u *tofree = NULL; | |
2222 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2223 // 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
|
2224 // 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
|
2225 // dialog name. |
44 | 2226 |
2227 dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0); | |
7 | 2228 |
2229 if (initdir == NULL || *initdir == NUL) | |
2230 { | |
2231 mch_dirname(dirbuf, MAXPATHL); | |
2232 initdir = dirbuf; | |
2233 } | |
2234 | |
2235 if (dflt == NULL) | |
2236 dflt = (char_u *)""; | |
2237 else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL) | |
2238 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2239 // 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
|
2240 // file name. |
7 | 2241 STRCPY(dfltbuf, initdir); |
2242 add_pathsep(dfltbuf); | |
2243 STRCAT(dfltbuf, dflt); | |
2244 dflt = dfltbuf; | |
2245 } | |
2246 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2247 // 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
|
2248 // the filter. An empty pattern means everything matches. |
7 | 2249 if (filter == NULL) |
2250 pattern = (char_u *)""; | |
2251 else | |
2252 { | |
2253 char_u *s, *p; | |
2254 | |
2255 s = filter; | |
2256 for (p = filter; *p != NUL; ++p) | |
2257 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2258 if (*p == '\t') // end of description, start of pattern |
7 | 2259 s = p + 1; |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2260 if (*p == ';' || *p == '\n') // end of (first) pattern |
7 | 2261 break; |
2262 } | |
2263 pattern = vim_strnsave(s, p - s); | |
2264 tofree = pattern; | |
2265 if (pattern == NULL) | |
2266 pattern = (char_u *)""; | |
2267 } | |
2268 | |
2269 XtVaSetValues(dialog_wgt, | |
2270 XtVaTypedArg, | |
2271 XmNdirectory, XmRString, (char *)initdir, STRLEN(initdir) + 1, | |
2272 XtVaTypedArg, | |
2273 XmNdirSpec, XmRString, (char *)dflt, STRLEN(dflt) + 1, | |
2274 XtVaTypedArg, | |
2275 XmNpattern, XmRString, (char *)pattern, STRLEN(pattern) + 1, | |
2276 XtVaTypedArg, | |
2277 XmNdialogTitle, XmRString, (char *)title, STRLEN(title) + 1, | |
2278 NULL); | |
2279 | |
44 | 2280 set_predefined_label(dialog_wgt, "Apply", _("&Filter")); |
2281 set_predefined_label(dialog_wgt, "Cancel", _("&Cancel")); | |
7 | 2282 set_predefined_label(dialog_wgt, "Dir", _("Directories")); |
2283 set_predefined_label(dialog_wgt, "FilterLabel", _("Filter")); | |
44 | 2284 set_predefined_label(dialog_wgt, "Help", _("&Help")); |
7 | 2285 set_predefined_label(dialog_wgt, "Items", _("Files")); |
44 | 2286 set_predefined_label(dialog_wgt, "OK", _("&OK")); |
7 | 2287 set_predefined_label(dialog_wgt, "Selection", _("Selection")); |
2288 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2289 // 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
|
2290 // fonts for file selection. |
44 | 2291 set_predefined_fontlist(dialog_wgt, "DirListSW.DirList"); |
2292 set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList"); | |
2293 | |
7 | 2294 gui_motif_menu_colors(dialog_wgt); |
2295 if (gui.scroll_bg_pixel != INVALCOLOR) | |
2296 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); | |
2297 | |
2298 XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); | |
2299 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
|
2300 // We have no help in this window, so hide help button |
7 | 2301 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, |
2302 (unsigned char)XmDIALOG_HELP_BUTTON)); | |
2303 | |
2304 manage_centered(dialog_wgt); | |
44 | 2305 activate_dialog_mnemonics(dialog_wgt); |
7 | 2306 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2307 // sit in a loop until the dialog box has gone away |
7 | 2308 do |
2309 { | |
2310 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), | |
2311 (XtInputMask)XtIMAll); | |
2312 } while (XtIsManaged(dialog_wgt)); | |
2313 | |
44 | 2314 suppress_dialog_mnemonics(dialog_wgt); |
7 | 2315 XtDestroyWidget(dialog_wgt); |
2316 vim_free(tofree); | |
2317 | |
2318 if (browse_fname == NULL) | |
2319 return NULL; | |
2320 return vim_strsave((char_u *)browse_fname); | |
2321 } | |
2322 | |
2323 /* | |
2324 * The code below was originally taken from | |
2325 * /usr/examples/motif/xmsamplers/xmeditor.c | |
2326 * on Digital Unix 4.0d, but heavily modified. | |
2327 */ | |
2328 | |
2329 /* | |
2330 * Process callback from Dialog cancel actions. | |
2331 */ | |
2332 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2333 DialogCancelCB( |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2334 Widget w UNUSED, // widget id |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2335 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
|
2336 XtPointer call_data UNUSED) // data from widget class |
7 | 2337 { |
2338 if (browse_fname != NULL) | |
2339 { | |
2340 XtFree(browse_fname); | |
2341 browse_fname = NULL; | |
2342 } | |
2343 XtUnmanageChild(dialog_wgt); | |
2344 } | |
2345 | |
2346 /* | |
2347 * Process callback from Dialog actions. | |
2348 */ | |
2349 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2350 DialogAcceptCB( |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2351 Widget w UNUSED, // widget id |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2352 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
|
2353 XtPointer call_data) // data from widget class |
7 | 2354 { |
2355 XmFileSelectionBoxCallbackStruct *fcb; | |
2356 | |
2357 if (browse_fname != NULL) | |
2358 { | |
2359 XtFree(browse_fname); | |
2360 browse_fname = NULL; | |
2361 } | |
2362 fcb = (XmFileSelectionBoxCallbackStruct *)call_data; | |
2363 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2364 // get the filename from the file selection box |
7 | 2365 XmStringGetLtoR(fcb->value, charset, &browse_fname); |
2366 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2367 // popdown the file selection box |
7 | 2368 XtUnmanageChild(dialog_wgt); |
2369 } | |
2370 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2371 #endif // FEAT_BROWSE |
7 | 2372 |
2373 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) | |
2374 | |
2375 static int dialogStatus; | |
2376 | |
2377 /* | |
2378 * Callback function for the textfield. When CR is hit this works like | |
2379 * hitting the "OK" button, ESC like "Cancel". | |
2380 */ | |
2381 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2382 keyhit_callback( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2383 Widget w, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2384 XtPointer client_data UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2385 XEvent *event, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2386 Boolean *cont UNUSED) |
7 | 2387 { |
2388 char buf[2]; | |
2389 KeySym key_sym; | |
2390 | |
2391 if (XLookupString(&(event->xkey), buf, 2, &key_sym, NULL) == 1) | |
2392 { | |
2393 if (*buf == CAR) | |
2394 dialogStatus = 1; | |
2395 else if (*buf == ESC) | |
2396 dialogStatus = 2; | |
2397 } | |
2398 if ((key_sym == XK_Left || key_sym == XK_Right) | |
2399 && !(event->xkey.state & ShiftMask)) | |
2400 XmTextFieldClearSelection(w, XtLastTimestampProcessed(gui.dpy)); | |
2401 } | |
2402 | |
2403 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2404 butproc( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2405 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2406 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2407 XtPointer call_data UNUSED) |
7 | 2408 { |
2409 dialogStatus = (int)(long)client_data + 1; | |
2410 } | |
2411 | |
2412 #ifdef HAVE_XPM | |
2413 | |
2414 static Widget | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2415 create_pixmap_label( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2416 Widget parent, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2417 String name, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2418 char **data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2419 ArgList args, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2420 Cardinal arg) |
7 | 2421 { |
2422 Widget label; | |
2423 Display *dsp; | |
2424 Screen *scr; | |
2425 int depth; | |
2426 Pixmap pixmap = 0; | |
2427 XpmAttributes attr; | |
2428 Boolean rs; | |
2429 XpmColorSymbol color[5] = | |
2430 { | |
2431 {"none", NULL, 0}, | |
2432 {"iconColor1", NULL, 0}, | |
2433 {"bottomShadowColor", NULL, 0}, | |
2434 {"topShadowColor", NULL, 0}, | |
2435 {"selectColor", NULL, 0} | |
2436 }; | |
2437 | |
2438 label = XmCreateLabelGadget(parent, name, args, arg); | |
2439 | |
2440 /* | |
1207 | 2441 * We need to be careful here, since in case of gadgets, there is |
7 | 2442 * no way to get the background color directly from the widget itself. |
2443 * In such cases we get it from The Core part of his parent instead. | |
2444 */ | |
2445 dsp = XtDisplayOfObject(label); | |
2446 scr = XtScreenOfObject(label); | |
2447 XtVaGetValues(XtIsSubclass(label, coreWidgetClass) | |
2448 ? label : XtParent(label), | |
2449 XmNdepth, &depth, | |
2450 XmNbackground, &color[0].pixel, | |
2451 XmNforeground, &color[1].pixel, | |
2452 XmNbottomShadowColor, &color[2].pixel, | |
2453 XmNtopShadowColor, &color[3].pixel, | |
2454 XmNhighlight, &color[4].pixel, | |
2455 NULL); | |
2456 | |
2457 attr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth; | |
2458 attr.colorsymbols = color; | |
2459 attr.numsymbols = 5; | |
2460 attr.closeness = 65535; | |
2461 attr.depth = depth; | |
2462 XpmCreatePixmapFromData(dsp, RootWindowOfScreen(scr), | |
2463 data, &pixmap, NULL, &attr); | |
2464 | |
2465 XtVaGetValues(label, XmNrecomputeSize, &rs, NULL); | |
2466 XtVaSetValues(label, XmNrecomputeSize, True, NULL); | |
2467 XtVaSetValues(label, | |
2468 XmNlabelType, XmPIXMAP, | |
2469 XmNlabelPixmap, pixmap, | |
2470 NULL); | |
2471 XtVaSetValues(label, XmNrecomputeSize, rs, NULL); | |
2472 | |
2473 return label; | |
2474 } | |
2475 #endif | |
2476 | |
2477 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2478 gui_mch_dialog( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2479 int type UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2480 char_u *title, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2481 char_u *message, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2482 char_u *button_names, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2483 int dfltbutton, |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2484 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
|
2485 int ex_cmd UNUSED) |
7 | 2486 { |
2487 char_u *buts; | |
2488 char_u *p, *next; | |
2489 XtAppContext app; | |
2490 XmString label; | |
2491 int butcount; | |
44 | 2492 Widget w; |
7 | 2493 Widget dialogform = NULL; |
2494 Widget form = NULL; | |
2495 Widget dialogtextfield = NULL; | |
2496 Widget *buttons; | |
2497 Widget sep_form = NULL; | |
2498 Boolean vertical; | |
2499 Widget separator = NULL; | |
2500 int n; | |
2501 Arg args[6]; | |
2502 #ifdef HAVE_XPM | |
2503 char **icon_data = NULL; | |
2504 Widget dialogpixmap = NULL; | |
2505 #endif | |
2506 | |
2507 if (title == NULL) | |
2508 title = (char_u *)_("Vim dialog"); | |
2509 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2510 // if our pointer is currently hidden, then we should show it. |
7 | 2511 gui_mch_mousehide(FALSE); |
2512 | |
2513 dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0); | |
2514 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2515 // Check 'v' flag in 'guioptions': vertical button placement. |
7 | 2516 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); |
2517 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2518 // Set the title of the Dialog window |
7 | 2519 label = XmStringCreateSimple((char *)title); |
2520 if (label == NULL) | |
2521 return -1; | |
2522 XtVaSetValues(dialogform, | |
2523 XmNdialogTitle, label, | |
2524 XmNhorizontalSpacing, 4, | |
2525 XmNverticalSpacing, vertical ? 0 : 4, | |
2526 NULL); | |
2527 XmStringFree(label); | |
2528 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2529 // make a copy, so that we can insert NULs |
7 | 2530 buts = vim_strsave(button_names); |
2531 if (buts == NULL) | |
2532 return -1; | |
2533 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2534 // Count the number of buttons and allocate buttons[]. |
7 | 2535 butcount = 1; |
2536 for (p = buts; *p; ++p) | |
2537 if (*p == DLG_BUTTON_SEP) | |
2538 ++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
|
2539 buttons = ALLOC_MULT(Widget, butcount); |
7 | 2540 if (buttons == NULL) |
2541 { | |
2542 vim_free(buts); | |
2543 return -1; | |
2544 } | |
2545 | |
2546 /* | |
2547 * Create the buttons. | |
2548 */ | |
2549 sep_form = (Widget) 0; | |
2550 p = buts; | |
2551 for (butcount = 0; *p; ++butcount) | |
2552 { | |
44 | 2553 KeySym mnemonic = NUL; |
2554 | |
7 | 2555 for (next = p; *next; ++next) |
2556 { | |
2557 if (*next == DLG_HOTKEY_CHAR) | |
44 | 2558 { |
2559 int len = STRLEN(next); | |
2560 | |
2561 if (len > 0) | |
2562 { | |
2563 mch_memmove(next, next + 1, len); | |
2564 mnemonic = next[0]; | |
2565 } | |
2566 } | |
7 | 2567 if (*next == DLG_BUTTON_SEP) |
2568 { | |
2569 *next++ = NUL; | |
2570 break; | |
2571 } | |
2572 } | |
2573 label = XmStringCreate(_((char *)p), STRING_TAG); | |
2574 if (label == NULL) | |
2575 break; | |
2576 | |
2577 buttons[butcount] = XtVaCreateManagedWidget("button", | |
2578 xmPushButtonWidgetClass, dialogform, | |
2579 XmNlabelString, label, | |
44 | 2580 XmNmnemonic, mnemonic, |
7 | 2581 XmNbottomAttachment, XmATTACH_FORM, |
2582 XmNbottomOffset, 4, | |
2583 XmNshowAsDefault, butcount == dfltbutton - 1, | |
2584 XmNdefaultButtonShadowThickness, 1, | |
2585 NULL); | |
2586 XmStringFree(label); | |
44 | 2587 gui_motif_menu_fontlist(buttons[butcount]); |
7 | 2588 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2589 // Layout properly. |
7 | 2590 |
2591 if (butcount > 0) | |
2592 { | |
2593 if (vertical) | |
2594 XtVaSetValues(buttons[butcount], | |
2595 XmNtopWidget, buttons[butcount - 1], | |
2596 NULL); | |
2597 else | |
2598 { | |
2599 if (*next == NUL) | |
2600 { | |
2601 XtVaSetValues(buttons[butcount], | |
2602 XmNrightAttachment, XmATTACH_FORM, | |
2603 XmNrightOffset, 4, | |
2604 NULL); | |
2605 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2606 // fill in a form as invisible separator |
7 | 2607 sep_form = XtVaCreateWidget("separatorForm", |
2608 xmFormWidgetClass, dialogform, | |
2609 XmNleftAttachment, XmATTACH_WIDGET, | |
2610 XmNleftWidget, buttons[butcount - 1], | |
2611 XmNrightAttachment, XmATTACH_WIDGET, | |
2612 XmNrightWidget, buttons[butcount], | |
2613 XmNbottomAttachment, XmATTACH_FORM, | |
2614 XmNbottomOffset, 4, | |
2615 NULL); | |
2616 XtManageChild(sep_form); | |
2617 } | |
2618 else | |
2619 { | |
2620 XtVaSetValues(buttons[butcount], | |
2621 XmNleftAttachment, XmATTACH_WIDGET, | |
2622 XmNleftWidget, buttons[butcount - 1], | |
2623 NULL); | |
2624 } | |
2625 } | |
2626 } | |
2627 else if (!vertical) | |
2628 { | |
2629 if (*next == NUL) | |
2630 { | |
2631 XtVaSetValues(buttons[0], | |
2632 XmNrightAttachment, XmATTACH_FORM, | |
2633 XmNrightOffset, 4, | |
2634 NULL); | |
2635 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2636 // fill in a form as invisible separator |
7 | 2637 sep_form = XtVaCreateWidget("separatorForm", |
2638 xmFormWidgetClass, dialogform, | |
2639 XmNleftAttachment, XmATTACH_FORM, | |
2640 XmNleftOffset, 4, | |
2641 XmNrightAttachment, XmATTACH_WIDGET, | |
2642 XmNrightWidget, buttons[0], | |
2643 XmNbottomAttachment, XmATTACH_FORM, | |
2644 XmNbottomOffset, 4, | |
2645 NULL); | |
2646 XtManageChild(sep_form); | |
2647 } | |
2648 else | |
2649 XtVaSetValues(buttons[0], | |
2650 XmNleftAttachment, XmATTACH_FORM, | |
2651 XmNleftOffset, 4, | |
2652 NULL); | |
2653 } | |
2654 | |
2655 XtAddCallback(buttons[butcount], XmNactivateCallback, | |
2656 (XtCallbackProc)butproc, (XtPointer)(long)butcount); | |
2657 p = next; | |
2658 } | |
2659 vim_free(buts); | |
2660 | |
2661 separator = (Widget) 0; | |
2662 if (butcount > 0) | |
2663 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2664 // Create the separator for beauty. |
7 | 2665 n = 0; |
2666 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++; | |
2667 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; | |
2668 XtSetArg(args[n], XmNbottomWidget, buttons[0]); n++; | |
2669 XtSetArg(args[n], XmNbottomOffset, 4); n++; | |
2670 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; | |
2671 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; | |
2672 separator = XmCreateSeparatorGadget(dialogform, "separator", args, n); | |
2673 XtManageChild(separator); | |
2674 } | |
2675 | |
2676 if (textfield != NULL) | |
2677 { | |
2678 dialogtextfield = XtVaCreateWidget("textField", | |
2679 xmTextFieldWidgetClass, dialogform, | |
2680 XmNleftAttachment, XmATTACH_FORM, | |
2681 XmNrightAttachment, XmATTACH_FORM, | |
2682 NULL); | |
2683 if (butcount > 0) | |
2684 XtVaSetValues(dialogtextfield, | |
2685 XmNbottomAttachment, XmATTACH_WIDGET, | |
2686 XmNbottomWidget, separator, | |
2687 NULL); | |
2688 else | |
2689 XtVaSetValues(dialogtextfield, | |
2690 XmNbottomAttachment, XmATTACH_FORM, | |
2691 NULL); | |
2692 | |
44 | 2693 set_fontlist(dialogtextfield); |
7 | 2694 XmTextFieldSetString(dialogtextfield, (char *)textfield); |
2695 XtManageChild(dialogtextfield); | |
2696 XtAddEventHandler(dialogtextfield, KeyPressMask, False, | |
2697 (XtEventHandler)keyhit_callback, (XtPointer)NULL); | |
2698 } | |
2699 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2700 // Form holding both message and pixmap labels |
7 | 2701 form = XtVaCreateWidget("separatorForm", |
2702 xmFormWidgetClass, dialogform, | |
2703 XmNleftAttachment, XmATTACH_FORM, | |
2704 XmNrightAttachment, XmATTACH_FORM, | |
2705 XmNtopAttachment, XmATTACH_FORM, | |
2706 NULL); | |
2707 XtManageChild(form); | |
2708 | |
2709 #ifdef HAVE_XPM | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2710 // Add a pixmap, left of the message. |
7 | 2711 switch (type) |
2712 { | |
2713 case VIM_GENERIC: | |
2714 icon_data = generic_xpm; | |
2715 break; | |
2716 case VIM_ERROR: | |
2717 icon_data = error_xpm; | |
2718 break; | |
2719 case VIM_WARNING: | |
2720 icon_data = alert_xpm; | |
2721 break; | |
2722 case VIM_INFO: | |
2723 icon_data = info_xpm; | |
2724 break; | |
2725 case VIM_QUESTION: | |
2726 icon_data = quest_xpm; | |
2727 break; | |
2728 default: | |
2729 icon_data = generic_xpm; | |
2730 } | |
2731 | |
2732 n = 0; | |
2733 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; | |
2734 XtSetArg(args[n], XmNtopOffset, 8); n++; | |
2735 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; | |
2736 XtSetArg(args[n], XmNbottomOffset, 8); n++; | |
2737 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; | |
2738 XtSetArg(args[n], XmNleftOffset, 8); n++; | |
2739 | |
2740 dialogpixmap = create_pixmap_label(form, "dialogPixmap", | |
2741 icon_data, args, n); | |
2742 XtManageChild(dialogpixmap); | |
2743 #endif | |
2744 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2745 // Create the dialog message. |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2746 // 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
|
2747 // 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
|
2748 // 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
|
2749 // Motif. |
44 | 2750 label = XmStringCreateLtoR((char *)message, STRING_TAG); |
7 | 2751 if (label == NULL) |
2752 return -1; | |
44 | 2753 w = XtVaCreateManagedWidget("dialogMessage", |
7 | 2754 xmLabelGadgetClass, form, |
2755 XmNlabelString, label, | |
44 | 2756 XmNalignment, XmALIGNMENT_BEGINNING, |
7 | 2757 XmNtopAttachment, XmATTACH_FORM, |
2758 XmNtopOffset, 8, | |
2759 #ifdef HAVE_XPM | |
2760 XmNleftAttachment, XmATTACH_WIDGET, | |
2761 XmNleftWidget, dialogpixmap, | |
2762 #else | |
2763 XmNleftAttachment, XmATTACH_FORM, | |
2764 #endif | |
2765 XmNleftOffset, 8, | |
2766 XmNrightAttachment, XmATTACH_FORM, | |
2767 XmNrightOffset, 8, | |
2768 XmNbottomAttachment, XmATTACH_FORM, | |
2769 XmNbottomOffset, 8, | |
2770 NULL); | |
2771 XmStringFree(label); | |
44 | 2772 set_fontlist(w); |
7 | 2773 |
2774 if (textfield != NULL) | |
2775 { | |
2776 XtVaSetValues(form, | |
2777 XmNbottomAttachment, XmATTACH_WIDGET, | |
2778 XmNbottomWidget, dialogtextfield, | |
2779 NULL); | |
2780 } | |
2781 else | |
2782 { | |
2783 if (butcount > 0) | |
2784 XtVaSetValues(form, | |
2785 XmNbottomAttachment, XmATTACH_WIDGET, | |
2786 XmNbottomWidget, separator, | |
2787 NULL); | |
2788 else | |
2789 XtVaSetValues(form, | |
2790 XmNbottomAttachment, XmATTACH_FORM, | |
2791 NULL); | |
2792 } | |
2793 | |
2794 if (dfltbutton < 1) | |
2795 dfltbutton = 1; | |
2796 if (dfltbutton > butcount) | |
2797 dfltbutton = butcount; | |
2798 XtVaSetValues(dialogform, | |
2799 XmNdefaultButton, buttons[dfltbutton - 1], NULL); | |
2800 if (textfield != NULL) | |
2801 XtVaSetValues(dialogform, XmNinitialFocus, dialogtextfield, NULL); | |
2802 else | |
2803 XtVaSetValues(dialogform, XmNinitialFocus, buttons[dfltbutton - 1], | |
2804 NULL); | |
2805 | |
2806 manage_centered(dialogform); | |
44 | 2807 activate_dialog_mnemonics(dialogform); |
7 | 2808 |
2809 if (textfield != NULL && *textfield != NUL) | |
2810 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2811 // This only works after the textfield has been realised. |
7 | 2812 XmTextFieldSetSelection(dialogtextfield, |
2813 (XmTextPosition)0, (XmTextPosition)STRLEN(textfield), | |
2814 XtLastTimestampProcessed(gui.dpy)); | |
2815 XmTextFieldSetCursorPosition(dialogtextfield, | |
2816 (XmTextPosition)STRLEN(textfield)); | |
2817 } | |
2818 | |
2819 app = XtWidgetToApplicationContext(dialogform); | |
2820 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2821 // Loop until a button is pressed or the dialog is killed somehow. |
7 | 2822 dialogStatus = -1; |
2823 for (;;) | |
2824 { | |
2825 XtAppProcessEvent(app, (XtInputMask)XtIMAll); | |
2826 if (dialogStatus >= 0 || !XtIsManaged(dialogform)) | |
2827 break; | |
2828 } | |
2829 | |
2830 vim_free(buttons); | |
2831 | |
2832 if (textfield != NULL) | |
2833 { | |
2834 p = (char_u *)XmTextGetString(dialogtextfield); | |
2835 if (p == NULL || dialogStatus < 0) | |
2836 *textfield = NUL; | |
2837 else | |
418 | 2838 vim_strncpy(textfield, p, IOSIZE - 1); |
2137
dabcabce3f9d
updated for version 7.2.419
Bram Moolenaar <bram@zimbu.org>
parents:
1887
diff
changeset
|
2839 XtFree((char *)p); |
7 | 2840 } |
2841 | |
44 | 2842 suppress_dialog_mnemonics(dialogform); |
7 | 2843 XtDestroyWidget(dialogform); |
2844 | |
2845 return dialogStatus; | |
2846 } | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2847 #endif // FEAT_GUI_DIALOG |
7 | 2848 |
2849 #if defined(FEAT_FOOTER) || defined(PROTO) | |
2850 | |
2851 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2852 gui_mch_compute_footer_height(void) |
7 | 2853 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2854 Dimension height; // total Toolbar height |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2855 Dimension top; // XmNmarginTop |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2856 Dimension bottom; // XmNmarginBottom |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2857 Dimension shadow; // XmNshadowThickness |
7 | 2858 |
2859 XtVaGetValues(footer, | |
2860 XmNheight, &height, | |
2861 XmNmarginTop, &top, | |
2862 XmNmarginBottom, &bottom, | |
2863 XmNshadowThickness, &shadow, | |
2864 NULL); | |
2865 | |
2866 return (int) height + top + bottom + (shadow << 1); | |
2867 } | |
2868 | |
2869 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2870 gui_mch_enable_footer(int showit) |
7 | 2871 { |
2872 if (showit) | |
2873 { | |
2874 gui.footer_height = gui_mch_compute_footer_height(); | |
2875 XtManageChild(footer); | |
2876 } | |
2877 else | |
2878 { | |
2879 gui.footer_height = 0; | |
2880 XtUnmanageChild(footer); | |
2881 } | |
2882 XtVaSetValues(textAreaForm, XmNbottomOffset, gui.footer_height, NULL); | |
2883 } | |
2884 | |
2885 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
2886 gui_mch_set_footer(char_u *s) |
7 | 2887 { |
2888 XmString xms; | |
2889 | |
2890 xms = XmStringCreate((char *)s, STRING_TAG); | |
44 | 2891 if (xms != NULL) |
2892 { | |
2893 XtVaSetValues(footer, XmNlabelString, xms, NULL); | |
2894 XmStringFree(xms); | |
2895 } | |
7 | 2896 } |
2897 | |
2898 #endif | |
2899 | |
2900 | |
2901 #if defined(FEAT_TOOLBAR) || defined(PROTO) | |
2902 void | |
2903 gui_mch_show_toolbar(int showit) | |
2904 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2905 Cardinal numChildren; // how many children toolBar has |
7 | 2906 |
2907 if (toolBar == (Widget)0) | |
2908 return; | |
2909 XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL); | |
2910 if (showit && numChildren > 0) | |
2911 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2912 // 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
|
2913 // valid option settings, therefore p_toolbar must not be NULL. |
7 | 2914 WidgetList children; |
2915 | |
2916 XtVaGetValues(toolBar, XmNchildren, &children, NULL); | |
2917 { | |
2918 void (*action)(BalloonEval *); | |
2919 int text = 0; | |
2920 | |
2921 if (strstr((const char *)p_toolbar, "tooltips")) | |
2922 action = &gui_mch_enable_beval_area; | |
2923 else | |
2924 action = &gui_mch_disable_beval_area; | |
2925 if (strstr((const char *)p_toolbar, "text")) | |
2926 text = 1; | |
2927 else if (strstr((const char *)p_toolbar, "icons")) | |
2928 text = -1; | |
2929 if (text != 0) | |
2930 { | |
2931 vimmenu_T *toolbar; | |
2932 vimmenu_T *cur; | |
2933 | |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
18788
diff
changeset
|
2934 FOR_ALL_MENUS(toolbar) |
7 | 2935 if (menu_is_toolbar(toolbar->dname)) |
2936 break; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2937 // 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
|
2938 // 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
|
2939 // |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2940 // 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
|
2941 // of items beginning with toolbar->children. |
7 | 2942 if (toolbar) |
2943 { | |
2944 for (cur = toolbar->children; cur; cur = cur->next) | |
2945 { | |
2946 Arg args[1]; | |
2947 int n = 0; | |
2948 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2949 // 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
|
2950 // currently enabled). |
7 | 2951 if (cur->tip != NULL) |
2952 (*action)(cur->tip); | |
2953 if (!menu_is_separator(cur->name)) | |
2954 { | |
48 | 2955 if (text == 1 || cur->xpm == NULL) |
2956 { | |
7 | 2957 XtSetArg(args[n], XmNlabelType, XmSTRING); |
48 | 2958 ++n; |
2959 } | |
7 | 2960 if (cur->id != NULL) |
2961 { | |
2962 XtUnmanageChild(cur->id); | |
2963 XtSetValues(cur->id, args, n); | |
2964 XtManageChild(cur->id); | |
2965 } | |
2966 } | |
2967 } | |
2968 } | |
2969 } | |
2970 } | |
2971 gui.toolbar_height = gui_mch_compute_toolbar_height(); | |
2972 XtManageChild(XtParent(toolBar)); | |
819 | 2973 #ifdef FEAT_GUI_TABLINE |
2974 if (showing_tabline) | |
2975 { | |
2976 XtVaSetValues(tabLine, | |
2977 XmNtopAttachment, XmATTACH_WIDGET, | |
2978 XmNtopWidget, XtParent(toolBar), | |
2979 NULL); | |
2980 XtVaSetValues(textAreaForm, | |
2981 XmNtopAttachment, XmATTACH_WIDGET, | |
2982 XmNtopWidget, tabLine, | |
2983 NULL); | |
2984 } | |
2985 else | |
2986 #endif | |
2987 XtVaSetValues(textAreaForm, | |
2988 XmNtopAttachment, XmATTACH_WIDGET, | |
2989 XmNtopWidget, XtParent(toolBar), | |
2990 NULL); | |
7 | 2991 if (XtIsManaged(menuBar)) |
2992 XtVaSetValues(XtParent(toolBar), | |
2993 XmNtopAttachment, XmATTACH_WIDGET, | |
2994 XmNtopWidget, menuBar, | |
2995 NULL); | |
2996 else | |
2997 XtVaSetValues(XtParent(toolBar), | |
2998 XmNtopAttachment, XmATTACH_FORM, | |
2999 NULL); | |
3000 } | |
3001 else | |
3002 { | |
3003 gui.toolbar_height = 0; | |
3004 if (XtIsManaged(menuBar)) | |
819 | 3005 { |
3006 #ifdef FEAT_GUI_TABLINE | |
3007 if (showing_tabline) | |
3008 { | |
3009 XtVaSetValues(tabLine, | |
3010 XmNtopAttachment, XmATTACH_WIDGET, | |
3011 XmNtopWidget, menuBar, | |
3012 NULL); | |
3013 XtVaSetValues(textAreaForm, | |
3014 XmNtopAttachment, XmATTACH_WIDGET, | |
3015 XmNtopWidget, tabLine, | |
3016 NULL); | |
3017 } | |
3018 else | |
3019 #endif | |
3020 XtVaSetValues(textAreaForm, | |
3021 XmNtopAttachment, XmATTACH_WIDGET, | |
3022 XmNtopWidget, menuBar, | |
3023 NULL); | |
3024 } | |
7 | 3025 else |
819 | 3026 { |
3027 #ifdef FEAT_GUI_TABLINE | |
3028 if (showing_tabline) | |
3029 { | |
3030 XtVaSetValues(tabLine, | |
3031 XmNtopAttachment, XmATTACH_FORM, | |
3032 NULL); | |
3033 XtVaSetValues(textAreaForm, | |
3034 XmNtopAttachment, XmATTACH_WIDGET, | |
3035 XmNtopWidget, tabLine, | |
3036 NULL); | |
3037 } | |
3038 else | |
3039 #endif | |
3040 XtVaSetValues(textAreaForm, | |
3041 XmNtopAttachment, XmATTACH_FORM, | |
3042 NULL); | |
3043 } | |
7 | 3044 |
3045 XtUnmanageChild(XtParent(toolBar)); | |
3046 } | |
811 | 3047 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3048 } |
3049 | |
3050 /* | |
3051 * A toolbar button has been pushed; now reset the input focus | |
3052 * such that the user can type page up/down etc. and have the | |
3053 * input go to the editor window, not the button | |
3054 */ | |
3055 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3056 reset_focus(void) |
7 | 3057 { |
3058 if (textArea != NULL) | |
3059 XmProcessTraversal(textArea, XmTRAVERSE_CURRENT); | |
3060 } | |
3061 | |
3062 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3063 gui_mch_compute_toolbar_height(void) |
7 | 3064 { |
48 | 3065 Dimension borders; |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3066 Dimension height; // total Toolbar height |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3067 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
|
3068 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
|
3069 Cardinal numChildren; // how many children toolBar has |
7 | 3070 int i; |
3071 | |
48 | 3072 borders = 0; |
7 | 3073 height = 0; |
3074 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
|
3075 { // get height of XmFrame parent |
48 | 3076 Dimension fst; |
3077 Dimension fmh; | |
3078 Dimension tst; | |
3079 Dimension tmh; | |
3080 | |
7 | 3081 XtVaGetValues(toolBarFrame, |
48 | 3082 XmNshadowThickness, &fst, |
3083 XmNmarginHeight, &fmh, | |
7 | 3084 NULL); |
48 | 3085 borders += fst + fmh; |
7 | 3086 XtVaGetValues(toolBar, |
48 | 3087 XmNshadowThickness, &tst, |
3088 XmNmarginHeight, &tmh, | |
7 | 3089 XmNchildren, &children, |
3090 XmNnumChildren, &numChildren, NULL); | |
48 | 3091 borders += tst + tmh; |
1887 | 3092 for (i = 0; i < (int)numChildren; i++) |
7 | 3093 { |
3094 whgt = 0; | |
3095 XtVaGetValues(children[i], XmNheight, &whgt, NULL); | |
3096 if (height < whgt) | |
3097 height = whgt; | |
3098 } | |
3099 } | |
48 | 3100 #ifdef LESSTIF_VERSION |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3101 // Hack: When starting up we get wrong dimensions. |
48 | 3102 if (height < 10) |
3103 height = 24; | |
3104 #endif | |
3105 | |
3106 return (int)(height + (borders << 1)); | |
7 | 3107 } |
3108 | |
161 | 3109 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3110 motif_get_toolbar_colors( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3111 Pixel *bgp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3112 Pixel *fgp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3113 Pixel *bsp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3114 Pixel *tsp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3115 Pixel *hsp) |
161 | 3116 { |
3117 XtVaGetValues(toolBar, | |
856 | 3118 XmNbackground, bgp, |
3119 XmNforeground, fgp, | |
3120 XmNbottomShadowColor, bsp, | |
3121 XmNtopShadowColor, tsp, | |
3122 XmNhighlightColor, hsp, | |
3123 NULL); | |
161 | 3124 } |
3125 | |
7 | 3126 # ifdef FEAT_FOOTER |
3127 /* | |
3128 * The next toolbar enter/leave callbacks should really do balloon help. But | |
4352 | 3129 * I have to use footer help for backwards compatibility. Hopefully both will |
7 | 3130 * get implemented and the user will have a choice. |
3131 */ | |
3132 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3133 toolbarbutton_enter_cb( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3134 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3135 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3136 XEvent *event UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3137 Boolean *cont UNUSED) |
7 | 3138 { |
3139 vimmenu_T *menu = (vimmenu_T *) client_data; | |
3140 | |
3141 if (menu->strings[MENU_INDEX_TIP] != NULL) | |
3142 { | |
3143 if (vim_strchr(p_go, GO_FOOTER) != NULL) | |
3144 gui_mch_set_footer(menu->strings[MENU_INDEX_TIP]); | |
3145 } | |
3146 } | |
3147 | |
3148 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3149 toolbarbutton_leave_cb( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3150 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3151 XtPointer client_data UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3152 XEvent *event UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3153 Boolean *cont UNUSED) |
7 | 3154 { |
3155 gui_mch_set_footer((char_u *) ""); | |
3156 } | |
3157 # endif | |
3158 #endif | |
3159 | |
819 | 3160 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
3161 /* | |
3162 * Show or hide the tabline. | |
3163 */ | |
3164 void | |
3165 gui_mch_show_tabline(int showit) | |
3166 { | |
3167 if (tabLine == (Widget)0) | |
3168 return; | |
3169 | |
3170 if (!showit != !showing_tabline) | |
3171 { | |
3172 if (showit) | |
3173 { | |
3174 XtManageChild(tabLine); | |
3175 XtUnmanageChild(XtNameToWidget(tabLine, "PageScroller")); | |
824 | 3176 XtUnmanageChild(XtNameToWidget(tabLine, "MinorTabScrollerNext")); |
3177 XtUnmanageChild(XtNameToWidget(tabLine, | |
3178 "MinorTabScrollerPrevious")); | |
819 | 3179 #ifdef FEAT_MENU |
3180 # ifdef FEAT_TOOLBAR | |
3181 if (XtIsManaged(XtParent(toolBar))) | |
3182 XtVaSetValues(tabLine, | |
3183 XmNtopAttachment, XmATTACH_WIDGET, | |
3184 XmNtopWidget, XtParent(toolBar), NULL); | |
3185 else | |
3186 # endif | |
3187 if (XtIsManaged(menuBar)) | |
3188 XtVaSetValues(tabLine, | |
3189 XmNtopAttachment, XmATTACH_WIDGET, | |
3190 XmNtopWidget, menuBar, NULL); | |
3191 else | |
3192 #endif | |
3193 XtVaSetValues(tabLine, | |
3194 XmNtopAttachment, XmATTACH_FORM, NULL); | |
3195 XtVaSetValues(textAreaForm, | |
3196 XmNtopAttachment, XmATTACH_WIDGET, | |
3197 XmNtopWidget, tabLine, | |
3198 NULL); | |
3199 } | |
3200 else | |
3201 { | |
3202 XtUnmanageChild(tabLine); | |
3203 #ifdef FEAT_MENU | |
3204 # ifdef FEAT_TOOLBAR | |
3205 if (XtIsManaged(XtParent(toolBar))) | |
3206 XtVaSetValues(textAreaForm, | |
3207 XmNtopAttachment, XmATTACH_WIDGET, | |
3208 XmNtopWidget, XtParent(toolBar), NULL); | |
3209 else | |
3210 # endif | |
3211 if (XtIsManaged(menuBar)) | |
3212 XtVaSetValues(textAreaForm, | |
3213 XmNtopAttachment, XmATTACH_WIDGET, | |
3214 XmNtopWidget, menuBar, NULL); | |
3215 else | |
3216 #endif | |
3217 XtVaSetValues(textAreaForm, | |
3218 XmNtopAttachment, XmATTACH_FORM, NULL); | |
3219 } | |
3220 showing_tabline = showit; | |
3221 } | |
3222 } | |
3223 | |
3224 /* | |
3225 * Return TRUE when tabline is displayed. | |
3226 */ | |
3227 int | |
3228 gui_mch_showing_tabline(void) | |
3229 { | |
3230 return tabLine != (Widget)0 && showing_tabline; | |
3231 } | |
3232 | |
3233 /* | |
3234 * Update the labels of the tabline. | |
3235 */ | |
3236 void | |
3237 gui_mch_update_tabline(void) | |
3238 { | |
3239 tabpage_T *tp; | |
3240 int nr = 1, n; | |
3241 Arg args[10]; | |
3242 int curtabidx = 0, currentpage; | |
3243 Widget tab; | |
3244 XmNotebookPageInfo page_info; | |
3245 XmNotebookPageStatus page_status; | |
3246 int last_page, tab_count; | |
824 | 3247 XmString label_str; |
3248 char *label_cstr; | |
844 | 3249 BalloonEval *beval; |
819 | 3250 |
3251 if (tabLine == (Widget)0) | |
3252 return; | |
3253 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3254 // Add a label for each tab page. They all contain the same text area. |
819 | 3255 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) |
3256 { | |
3257 if (tp == curtab) | |
3258 curtabidx = nr; | |
3259 | |
3260 page_status = XmNotebookGetPageInfo(tabLine, nr, &page_info); | |
3261 if (page_status == XmPAGE_INVALID | |
844 | 3262 || page_info.major_tab_widget == (Widget)0) |
819 | 3263 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3264 // Add the tab |
819 | 3265 n = 0; |
3266 XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++; | |
3267 XtSetArg(args[n], XmNtraversalOn, False); n++; | |
3268 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; | |
3269 XtSetArg(args[n], XmNhighlightThickness, 1); n++; | |
3270 XtSetArg(args[n], XmNshadowThickness , 1); n++; | |
3271 tab = XmCreatePushButton(tabLine, "-Empty-", args, n); | |
3272 XtManageChild(tab); | |
844 | 3273 beval = gui_mch_create_beval_area(tab, NULL, tabline_balloon_cb, |
3274 NULL); | |
3275 XtVaSetValues(tab, XmNuserData, beval, NULL); | |
819 | 3276 } |
3277 else | |
3278 tab = page_info.major_tab_widget; | |
3279 | |
3280 XtVaSetValues(tab, XmNpageNumber, nr, NULL); | |
824 | 3281 |
3282 /* | |
3283 * Change the label text only if it is different | |
3284 */ | |
3285 XtVaGetValues(tab, XmNlabelString, &label_str, NULL); | |
3286 if (XmStringGetLtoR(label_str, XmSTRING_DEFAULT_CHARSET, &label_cstr)) | |
3287 { | |
839 | 3288 get_tabline_label(tp, FALSE); |
3289 if (STRCMP(label_cstr, NameBuff) != 0) | |
3290 { | |
824 | 3291 XtVaSetValues(tab, XtVaTypedArg, XmNlabelString, XmRString, |
3292 NameBuff, STRLEN(NameBuff) + 1, NULL); | |
3293 /* | |
3294 * Force a resize of the tab label button | |
3295 */ | |
3296 XtUnmanageChild(tab); | |
3297 XtManageChild(tab); | |
3298 } | |
3299 XtFree(label_cstr); | |
3300 } | |
819 | 3301 } |
3302 | |
3303 tab_count = nr - 1; | |
3304 | |
3305 XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL); | |
3306 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3307 // Remove any old labels. |
819 | 3308 while (nr <= last_page) |
3309 { | |
3310 if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID | |
3311 && page_info.page_number == nr | |
3312 && page_info.major_tab_widget != (Widget)0) | |
3313 { | |
844 | 3314 XtVaGetValues(page_info.major_tab_widget, XmNuserData, &beval, NULL); |
3315 if (beval != NULL) | |
3316 gui_mch_destroy_beval_area(beval); | |
819 | 3317 XtUnmanageChild(page_info.major_tab_widget); |
3318 XtDestroyWidget(page_info.major_tab_widget); | |
3319 } | |
3320 nr++; | |
3321 } | |
3322 | |
3323 XtVaSetValues(tabLine, XmNlastPageNumber, tab_count, NULL); | |
3324 | |
3325 XtVaGetValues(tabLine, XmNcurrentPageNumber, ¤tpage, NULL); | |
3326 if (currentpage != curtabidx) | |
3327 XtVaSetValues(tabLine, XmNcurrentPageNumber, curtabidx, NULL); | |
3328 } | |
3329 | |
3330 /* | |
3331 * Set the current tab to "nr". First tab is 1. | |
3332 */ | |
3333 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3334 gui_mch_set_curtab(int nr) |
819 | 3335 { |
3336 int currentpage; | |
3337 | |
3338 if (tabLine == (Widget)0) | |
3339 return; | |
3340 | |
3341 XtVaGetValues(tabLine, XmNcurrentPageNumber, ¤tpage, NULL); | |
3342 if (currentpage != nr) | |
3343 XtVaSetValues(tabLine, XmNcurrentPageNumber, nr, NULL); | |
3344 } | |
3345 #endif | |
3346 | |
7 | 3347 /* |
3348 * Set the colors of Widget "id" to the menu colors. | |
3349 */ | |
3350 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3351 gui_motif_menu_colors(Widget id) |
7 | 3352 { |
3353 if (gui.menu_bg_pixel != INVALCOLOR) | |
3354 #if (XmVersion >= 1002) | |
3355 XmChangeColor(id, gui.menu_bg_pixel); | |
3356 #else | |
3357 XtVaSetValues(id, XmNbackground, gui.menu_bg_pixel, NULL); | |
3358 #endif | |
3359 if (gui.menu_fg_pixel != INVALCOLOR) | |
3360 XtVaSetValues(id, XmNforeground, gui.menu_fg_pixel, NULL); | |
3361 } | |
3362 | |
3363 /* | |
3364 * Set the colors of Widget "id" to the scrollbar colors. | |
3365 */ | |
3366 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3367 gui_motif_scroll_colors(Widget id) |
7 | 3368 { |
3369 if (gui.scroll_bg_pixel != INVALCOLOR) | |
3370 #if (XmVersion >= 1002) | |
3371 XmChangeColor(id, gui.scroll_bg_pixel); | |
3372 #else | |
3373 XtVaSetValues(id, XmNbackground, gui.scroll_bg_pixel, NULL); | |
3374 #endif | |
3375 if (gui.scroll_fg_pixel != INVALCOLOR) | |
3376 XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL); | |
3377 } | |
3378 | |
3379 /* | |
3380 * Set the fontlist for Widget "id" to use gui.menu_fontset or gui.menu_font. | |
3381 */ | |
44 | 3382 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3383 gui_motif_menu_fontlist(Widget id UNUSED) |
7 | 3384 { |
44 | 3385 #ifdef FEAT_MENU |
7 | 3386 #ifdef FONTSET_ALWAYS |
3387 if (gui.menu_fontset != NOFONTSET) | |
3388 { | |
3389 XmFontList fl; | |
3390 | |
3391 fl = gui_motif_fontset2fontlist((XFontSet *)&gui.menu_fontset); | |
3392 if (fl != NULL) | |
3393 { | |
3394 if (XtIsManaged(id)) | |
3395 { | |
3396 XtUnmanageChild(id); | |
3397 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
|
3398 // 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
|
3399 // geometry now. |
7 | 3400 XtManageChild(id); |
3401 } | |
3402 else | |
3403 XtVaSetValues(id, XmNfontList, fl, NULL); | |
3404 XmFontListFree(fl); | |
3405 } | |
3406 } | |
3407 #else | |
3408 if (gui.menu_font != NOFONT) | |
3409 { | |
3410 XmFontList fl; | |
3411 | |
3412 fl = gui_motif_create_fontlist((XFontStruct *)gui.menu_font); | |
3413 if (fl != NULL) | |
3414 { | |
3415 if (XtIsManaged(id)) | |
3416 { | |
3417 XtUnmanageChild(id); | |
3418 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
|
3419 // 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
|
3420 // geometry now. |
7 | 3421 XtManageChild(id); |
3422 } | |
3423 else | |
3424 XtVaSetValues(id, XmNfontList, fl, NULL); | |
3425 XmFontListFree(fl); | |
3426 } | |
3427 } | |
3428 #endif | |
44 | 3429 #endif |
7 | 3430 } |
3431 | |
3432 | |
3433 /* | |
3434 * We don't create it twice for the sake of speed. | |
3435 */ | |
3436 | |
3437 typedef struct _SharedFindReplace | |
3438 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3439 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
|
3440 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
|
3441 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
|
3442 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
|
3443 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
|
3444 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
|
3445 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
|
3446 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
|
3447 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
|
3448 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
|
3449 Widget undo; // 'Undo' action button |
7 | 3450 |
3451 Widget cancel; | |
3452 } SharedFindReplace; | |
3453 | |
1887 | 3454 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
3455 static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | |
7 | 3456 |
3457 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3458 find_replace_destroy_callback( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3459 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3460 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3461 XtPointer call_data UNUSED) |
7 | 3462 { |
3463 SharedFindReplace *cd = (SharedFindReplace *)client_data; | |
3464 | |
48 | 3465 if (cd != NULL) |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3466 // suppress_dialog_mnemonics(cd->dialog); |
7 | 3467 cd->dialog = (Widget)0; |
3468 } | |
3469 | |
3470 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3471 find_replace_dismiss_callback( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3472 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3473 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3474 XtPointer call_data UNUSED) |
7 | 3475 { |
3476 SharedFindReplace *cd = (SharedFindReplace *)client_data; | |
3477 | |
3478 if (cd != NULL) | |
3479 XtUnmanageChild(cd->dialog); | |
3480 } | |
3481 | |
3482 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3483 entry_activate_callback( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3484 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3485 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3486 XtPointer call_data UNUSED) |
7 | 3487 { |
3488 XmProcessTraversal((Widget)client_data, XmTRAVERSE_CURRENT); | |
3489 } | |
3490 | |
3491 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3492 find_replace_callback( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3493 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3494 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3495 XtPointer call_data UNUSED) |
7 | 3496 { |
3497 long_u flags = (long_u)client_data; | |
3498 char *find_text, *repl_text; | |
3499 Boolean direction_down = TRUE; | |
3500 Boolean wword; | |
3501 Boolean mcase; | |
3502 SharedFindReplace *sfr; | |
3503 | |
3504 if (flags == FRD_UNDO) | |
3505 { | |
3506 char_u *save_cpo = p_cpo; | |
3507 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3508 // No need to be Vi compatible here. |
7 | 3509 p_cpo = (char_u *)""; |
3510 u_undo(1); | |
3511 p_cpo = save_cpo; | |
3512 gui_update_screen(); | |
3513 return; | |
3514 } | |
3515 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3516 // Get the search/replace strings from the dialog |
7 | 3517 if (flags == FRD_FINDNEXT) |
3518 { | |
3519 repl_text = NULL; | |
3520 sfr = &find_widgets; | |
3521 } | |
3522 else | |
3523 { | |
3524 repl_text = XmTextFieldGetString(repl_widgets.with); | |
3525 sfr = &repl_widgets; | |
3526 } | |
3527 find_text = XmTextFieldGetString(sfr->what); | |
3528 XtVaGetValues(sfr->down, XmNset, &direction_down, NULL); | |
3529 XtVaGetValues(sfr->wword, XmNset, &wword, NULL); | |
3530 XtVaGetValues(sfr->mcase, XmNset, &mcase, NULL); | |
3531 if (wword) | |
3532 flags |= FRD_WHOLE_WORD; | |
3533 if (mcase) | |
3534 flags |= FRD_MATCH_CASE; | |
3535 | |
3536 (void)gui_do_findrepl((int)flags, (char_u *)find_text, (char_u *)repl_text, | |
3537 direction_down); | |
3538 | |
3539 if (find_text != NULL) | |
3540 XtFree(find_text); | |
3541 if (repl_text != NULL) | |
3542 XtFree(repl_text); | |
3543 } | |
3544 | |
3545 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3546 find_replace_keypress( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3547 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3548 SharedFindReplace *frdp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3549 XKeyEvent *event) |
7 | 3550 { |
3551 KeySym keysym; | |
3552 | |
3553 if (frdp == NULL) | |
3554 return; | |
3555 | |
3556 keysym = XLookupKeysym(event, 0); | |
3557 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3558 // the scape key pops the whole dialog down |
7 | 3559 if (keysym == XK_Escape) |
3560 XtUnmanageChild(frdp->dialog); | |
3561 } | |
3562 | |
3563 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3564 set_label(Widget w, char *label) |
44 | 3565 { |
3566 XmString str; | |
3567 char_u *p, *next; | |
3568 KeySym mnemonic = NUL; | |
3569 | |
3570 if (!w) | |
3571 return; | |
3572 | |
4960
27b008d5b7ac
updated for version 7.3.1225
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3573 p = vim_strsave((char_u *)label); |
44 | 3574 if (p == NULL) |
3575 return; | |
3576 for (next = p; *next; ++next) | |
3577 { | |
3578 if (*next == DLG_HOTKEY_CHAR) | |
3579 { | |
3580 int len = STRLEN(next); | |
3581 | |
3582 if (len > 0) | |
3583 { | |
3584 mch_memmove(next, next + 1, len); | |
3585 mnemonic = next[0]; | |
3586 } | |
3587 } | |
3588 } | |
3589 | |
3590 str = XmStringCreateSimple((char *)p); | |
3591 vim_free(p); | |
3592 if (str) | |
3593 { | |
3594 XtVaSetValues(w, | |
3595 XmNlabelString, str, | |
3596 XmNmnemonic, mnemonic, | |
3597 NULL); | |
3598 XmStringFree(str); | |
3599 } | |
3600 gui_motif_menu_fontlist(w); | |
3601 } | |
3602 | |
3603 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3604 find_replace_dialog_create(char_u *arg, int do_replace) |
7 | 3605 { |
3606 SharedFindReplace *frdp; | |
3607 Widget separator; | |
3608 Widget input_form; | |
3609 Widget button_form; | |
3610 Widget toggle_form; | |
3611 Widget frame; | |
3612 XmString str; | |
3613 int n; | |
3614 Arg args[6]; | |
3615 int wword = FALSE; | |
3616 int mcase = !p_ic; | |
3617 Dimension width; | |
3618 Dimension widest; | |
3619 char_u *entry_text; | |
3620 | |
3621 frdp = do_replace ? &repl_widgets : &find_widgets; | |
3622 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3623 // Get the search string to use. |
7 | 3624 entry_text = get_find_dialog_text(arg, &wword, &mcase); |
3625 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3626 // If the dialog already exists, just raise it. |
7 | 3627 if (frdp->dialog) |
3628 { | |
44 | 3629 gui_motif_synch_fonts(); |
3630 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3631 // If the window is already up, just pop it to the top |
7 | 3632 if (XtIsManaged(frdp->dialog)) |
3633 XMapRaised(XtDisplay(frdp->dialog), | |
3634 XtWindow(XtParent(frdp->dialog))); | |
3635 else | |
3636 XtManageChild(frdp->dialog); | |
3637 XtPopup(XtParent(frdp->dialog), XtGrabNone); | |
3638 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT); | |
3639 | |
3640 if (entry_text != NULL) | |
3641 XmTextFieldSetString(frdp->what, (char *)entry_text); | |
3642 vim_free(entry_text); | |
3643 | |
3644 XtVaSetValues(frdp->wword, XmNset, wword, NULL); | |
3645 return; | |
3646 } | |
3647 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3648 // Create a fresh new dialog window |
7 | 3649 if (do_replace) |
3650 str = XmStringCreateSimple(_("VIM - Search and Replace...")); | |
3651 else | |
3652 str = XmStringCreateSimple(_("VIM - Search...")); | |
3653 | |
3654 n = 0; | |
3655 XtSetArg(args[n], XmNautoUnmanage, False); n++; | |
3656 XtSetArg(args[n], XmNnoResize, True); n++; | |
3657 XtSetArg(args[n], XmNdialogTitle, str); n++; | |
3658 | |
3659 frdp->dialog = XmCreateFormDialog(vimShell, "findReplaceDialog", args, n); | |
3660 XmStringFree(str); | |
3661 XtAddCallback(frdp->dialog, XmNdestroyCallback, | |
3662 find_replace_destroy_callback, frdp); | |
3663 | |
3664 button_form = XtVaCreateWidget("buttonForm", | |
3665 xmFormWidgetClass, frdp->dialog, | |
3666 XmNrightAttachment, XmATTACH_FORM, | |
3667 XmNrightOffset, 4, | |
3668 XmNtopAttachment, XmATTACH_FORM, | |
3669 XmNtopOffset, 4, | |
3670 XmNbottomAttachment, XmATTACH_FORM, | |
3671 XmNbottomOffset, 4, | |
3672 NULL); | |
3673 | |
3674 frdp->find = XtVaCreateManagedWidget("findButton", | |
3675 xmPushButtonWidgetClass, button_form, | |
3676 XmNsensitive, True, | |
3677 XmNtopAttachment, XmATTACH_FORM, | |
3678 XmNleftAttachment, XmATTACH_FORM, | |
3679 XmNrightAttachment, XmATTACH_FORM, | |
3680 NULL); | |
44 | 3681 set_label(frdp->find, _("Find &Next")); |
7 | 3682 |
3683 XtAddCallback(frdp->find, XmNactivateCallback, | |
3684 find_replace_callback, | |
1522 | 3685 (do_replace ? (XtPointer)FRD_R_FINDNEXT : (XtPointer)FRD_FINDNEXT)); |
7 | 3686 |
3687 if (do_replace) | |
3688 { | |
3689 frdp->replace = XtVaCreateManagedWidget("replaceButton", | |
3690 xmPushButtonWidgetClass, button_form, | |
3691 XmNtopAttachment, XmATTACH_WIDGET, | |
3692 XmNtopWidget, frdp->find, | |
3693 XmNleftAttachment, XmATTACH_FORM, | |
3694 XmNrightAttachment, XmATTACH_FORM, | |
3695 NULL); | |
44 | 3696 set_label(frdp->replace, _("&Replace")); |
7 | 3697 XtAddCallback(frdp->replace, XmNactivateCallback, |
3698 find_replace_callback, (XtPointer)FRD_REPLACE); | |
3699 | |
3700 frdp->all = XtVaCreateManagedWidget("replaceAllButton", | |
3701 xmPushButtonWidgetClass, button_form, | |
3702 XmNtopAttachment, XmATTACH_WIDGET, | |
3703 XmNtopWidget, frdp->replace, | |
3704 XmNleftAttachment, XmATTACH_FORM, | |
3705 XmNrightAttachment, XmATTACH_FORM, | |
3706 NULL); | |
44 | 3707 set_label(frdp->all, _("Replace &All")); |
7 | 3708 XtAddCallback(frdp->all, XmNactivateCallback, |
3709 find_replace_callback, (XtPointer)FRD_REPLACEALL); | |
3710 | |
3711 frdp->undo = XtVaCreateManagedWidget("undoButton", | |
3712 xmPushButtonWidgetClass, button_form, | |
3713 XmNtopAttachment, XmATTACH_WIDGET, | |
3714 XmNtopWidget, frdp->all, | |
3715 XmNleftAttachment, XmATTACH_FORM, | |
3716 XmNrightAttachment, XmATTACH_FORM, | |
3717 NULL); | |
44 | 3718 set_label(frdp->undo, _("&Undo")); |
7 | 3719 XtAddCallback(frdp->undo, XmNactivateCallback, |
3720 find_replace_callback, (XtPointer)FRD_UNDO); | |
3721 } | |
3722 | |
3723 frdp->cancel = XtVaCreateManagedWidget("closeButton", | |
3724 xmPushButtonWidgetClass, button_form, | |
3725 XmNleftAttachment, XmATTACH_FORM, | |
3726 XmNrightAttachment, XmATTACH_FORM, | |
3727 XmNbottomAttachment, XmATTACH_FORM, | |
3728 NULL); | |
44 | 3729 set_label(frdp->cancel, _("&Cancel")); |
7 | 3730 XtAddCallback(frdp->cancel, XmNactivateCallback, |
3731 find_replace_dismiss_callback, frdp); | |
44 | 3732 gui_motif_menu_fontlist(frdp->cancel); |
7 | 3733 |
3734 XtManageChild(button_form); | |
3735 | |
3736 n = 0; | |
3737 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; | |
3738 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; | |
3739 XtSetArg(args[n], XmNrightWidget, button_form); n++; | |
3740 XtSetArg(args[n], XmNrightOffset, 4); n++; | |
3741 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; | |
3742 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; | |
3743 separator = XmCreateSeparatorGadget(frdp->dialog, "separator", args, n); | |
3744 XtManageChild(separator); | |
3745 | |
3746 input_form = XtVaCreateWidget("inputForm", | |
3747 xmFormWidgetClass, frdp->dialog, | |
3748 XmNleftAttachment, XmATTACH_FORM, | |
3749 XmNleftOffset, 4, | |
3750 XmNrightAttachment, XmATTACH_WIDGET, | |
3751 XmNrightWidget, separator, | |
3752 XmNrightOffset, 4, | |
3753 XmNtopAttachment, XmATTACH_FORM, | |
3754 XmNtopOffset, 4, | |
3755 NULL); | |
3756 | |
3757 { | |
3758 Widget label_what; | |
3759 Widget label_with = (Widget)0; | |
3760 | |
3761 str = XmStringCreateSimple(_("Find what:")); | |
3762 label_what = XtVaCreateManagedWidget("whatLabel", | |
3763 xmLabelGadgetClass, input_form, | |
3764 XmNlabelString, str, | |
3765 XmNleftAttachment, XmATTACH_FORM, | |
3766 XmNtopAttachment, XmATTACH_FORM, | |
3767 XmNtopOffset, 4, | |
3768 NULL); | |
3769 XmStringFree(str); | |
44 | 3770 gui_motif_menu_fontlist(label_what); |
7 | 3771 |
3772 frdp->what = XtVaCreateManagedWidget("whatText", | |
3773 xmTextFieldWidgetClass, input_form, | |
3774 XmNtopAttachment, XmATTACH_FORM, | |
3775 XmNrightAttachment, XmATTACH_FORM, | |
3776 XmNleftAttachment, XmATTACH_FORM, | |
3777 NULL); | |
3778 | |
3779 if (do_replace) | |
3780 { | |
3781 frdp->with = XtVaCreateManagedWidget("withText", | |
3782 xmTextFieldWidgetClass, input_form, | |
3783 XmNtopAttachment, XmATTACH_WIDGET, | |
3784 XmNtopWidget, frdp->what, | |
3785 XmNtopOffset, 4, | |
3786 XmNleftAttachment, XmATTACH_FORM, | |
3787 XmNrightAttachment, XmATTACH_FORM, | |
3788 XmNbottomAttachment, XmATTACH_FORM, | |
3789 NULL); | |
3790 | |
3791 XtAddCallback(frdp->with, XmNactivateCallback, | |
3792 find_replace_callback, (XtPointer) FRD_R_FINDNEXT); | |
3793 | |
3794 str = XmStringCreateSimple(_("Replace with:")); | |
3795 label_with = XtVaCreateManagedWidget("withLabel", | |
3796 xmLabelGadgetClass, input_form, | |
3797 XmNlabelString, str, | |
3798 XmNleftAttachment, XmATTACH_FORM, | |
3799 XmNtopAttachment, XmATTACH_WIDGET, | |
3800 XmNtopWidget, frdp->what, | |
3801 XmNtopOffset, 4, | |
3802 XmNbottomAttachment, XmATTACH_FORM, | |
3803 NULL); | |
3804 XmStringFree(str); | |
44 | 3805 gui_motif_menu_fontlist(label_with); |
7 | 3806 |
3807 /* | |
3808 * Make the entry activation only change the input focus onto the | |
3809 * with item. | |
3810 */ | |
3811 XtAddCallback(frdp->what, XmNactivateCallback, | |
3812 entry_activate_callback, frdp->with); | |
3813 XtAddEventHandler(frdp->with, KeyPressMask, False, | |
3814 (XtEventHandler)find_replace_keypress, | |
3815 (XtPointer) frdp); | |
3816 | |
3817 } | |
3818 else | |
3819 { | |
3820 /* | |
3821 * Make the entry activation do the search. | |
3822 */ | |
3823 XtAddCallback(frdp->what, XmNactivateCallback, | |
3824 find_replace_callback, (XtPointer)FRD_FINDNEXT); | |
3825 } | |
3826 XtAddEventHandler(frdp->what, KeyPressMask, False, | |
3827 (XtEventHandler)find_replace_keypress, | |
3828 (XtPointer)frdp); | |
3829 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3830 // Get the maximum width between the label widgets and line them up. |
7 | 3831 n = 0; |
3832 XtSetArg(args[n], XmNwidth, &width); n++; | |
3833 XtGetValues(label_what, args, n); | |
3834 widest = width; | |
3835 if (do_replace) | |
3836 { | |
3837 XtGetValues(label_with, args, n); | |
3838 if (width > widest) | |
3839 widest = width; | |
3840 } | |
3841 | |
3842 XtVaSetValues(frdp->what, XmNleftOffset, widest, NULL); | |
3843 if (do_replace) | |
3844 XtVaSetValues(frdp->with, XmNleftOffset, widest, NULL); | |
3845 | |
3846 } | |
3847 | |
3848 XtManageChild(input_form); | |
3849 | |
3850 { | |
3851 Widget radio_box; | |
44 | 3852 Widget w; |
7 | 3853 |
3854 frame = XtVaCreateWidget("directionFrame", | |
3855 xmFrameWidgetClass, frdp->dialog, | |
3856 XmNtopAttachment, XmATTACH_WIDGET, | |
3857 XmNtopWidget, input_form, | |
3858 XmNtopOffset, 4, | |
3859 XmNbottomAttachment, XmATTACH_FORM, | |
3860 XmNbottomOffset, 4, | |
3861 XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET, | |
3862 XmNrightWidget, input_form, | |
3863 NULL); | |
3864 | |
3865 str = XmStringCreateSimple(_("Direction")); | |
44 | 3866 w = XtVaCreateManagedWidget("directionFrameLabel", |
7 | 3867 xmLabelGadgetClass, frame, |
3868 XmNlabelString, str, | |
3869 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING, | |
3870 XmNchildType, XmFRAME_TITLE_CHILD, | |
3871 NULL); | |
3872 XmStringFree(str); | |
44 | 3873 gui_motif_menu_fontlist(w); |
7 | 3874 |
3875 radio_box = XmCreateRadioBox(frame, "radioBox", | |
3876 (ArgList)NULL, 0); | |
3877 | |
3878 str = XmStringCreateSimple( _("Up")); | |
3879 frdp->up = XtVaCreateManagedWidget("upRadioButton", | |
3880 xmToggleButtonGadgetClass, radio_box, | |
3881 XmNlabelString, str, | |
3882 XmNset, False, | |
3883 NULL); | |
3884 XmStringFree(str); | |
44 | 3885 gui_motif_menu_fontlist(frdp->up); |
7 | 3886 |
3887 str = XmStringCreateSimple(_("Down")); | |
3888 frdp->down = XtVaCreateManagedWidget("downRadioButton", | |
3889 xmToggleButtonGadgetClass, radio_box, | |
3890 XmNlabelString, str, | |
3891 XmNset, True, | |
3892 NULL); | |
3893 XmStringFree(str); | |
44 | 3894 gui_motif_menu_fontlist(frdp->down); |
7 | 3895 |
3896 XtManageChild(radio_box); | |
3897 XtManageChild(frame); | |
3898 } | |
3899 | |
3900 toggle_form = XtVaCreateWidget("toggleForm", | |
3901 xmFormWidgetClass, frdp->dialog, | |
3902 XmNleftAttachment, XmATTACH_FORM, | |
3903 XmNleftOffset, 4, | |
3904 XmNrightAttachment, XmATTACH_WIDGET, | |
3905 XmNrightWidget, frame, | |
3906 XmNrightOffset, 4, | |
3907 XmNtopAttachment, XmATTACH_WIDGET, | |
3908 XmNtopWidget, input_form, | |
3909 XmNtopOffset, 4, | |
3910 XmNbottomAttachment, XmATTACH_FORM, | |
3911 XmNbottomOffset, 4, | |
3912 NULL); | |
3913 | |
3914 str = XmStringCreateSimple(_("Match whole word only")); | |
3915 frdp->wword = XtVaCreateManagedWidget("wordToggle", | |
3916 xmToggleButtonGadgetClass, toggle_form, | |
3917 XmNlabelString, str, | |
3918 XmNtopAttachment, XmATTACH_FORM, | |
3919 XmNtopOffset, 4, | |
3920 XmNleftAttachment, XmATTACH_FORM, | |
3921 XmNleftOffset, 4, | |
3922 XmNset, wword, | |
3923 NULL); | |
3924 XmStringFree(str); | |
3925 | |
3926 str = XmStringCreateSimple(_("Match case")); | |
3927 frdp->mcase = XtVaCreateManagedWidget("caseToggle", | |
3928 xmToggleButtonGadgetClass, toggle_form, | |
3929 XmNlabelString, str, | |
3930 XmNleftAttachment, XmATTACH_FORM, | |
3931 XmNleftOffset, 4, | |
3932 XmNtopAttachment, XmATTACH_WIDGET, | |
3933 XmNtopWidget, frdp->wword, | |
3934 XmNtopOffset, 4, | |
3935 XmNset, mcase, | |
3936 NULL); | |
3937 XmStringFree(str); | |
44 | 3938 gui_motif_menu_fontlist(frdp->wword); |
3939 gui_motif_menu_fontlist(frdp->mcase); | |
7 | 3940 |
3941 XtManageChild(toggle_form); | |
3942 | |
3943 if (entry_text != NULL) | |
3944 XmTextFieldSetString(frdp->what, (char *)entry_text); | |
3945 vim_free(entry_text); | |
3946 | |
44 | 3947 gui_motif_synch_fonts(); |
3948 | |
3949 manage_centered(frdp->dialog); | |
3950 activate_dialog_mnemonics(frdp->dialog); | |
7 | 3951 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT); |
3952 } | |
3953 | |
3954 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3955 gui_mch_find_dialog(exarg_T *eap) |
7 | 3956 { |
3957 if (!gui.in_use) | |
3958 return; | |
3959 | |
3960 find_replace_dialog_create(eap->arg, FALSE); | |
3961 } | |
3962 | |
3963 | |
3964 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7815
diff
changeset
|
3965 gui_mch_replace_dialog(exarg_T *eap) |
7 | 3966 { |
3967 if (!gui.in_use) | |
3968 return; | |
3969 | |
3970 find_replace_dialog_create(eap->arg, TRUE); | |
3971 } | |
44 | 3972 |
3973 /* | |
3974 * Synchronize all gui elements, which are dependant upon the | |
3975 * main text font used. Those are in esp. the find/replace dialogs. | |
3976 * 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
|
3977 * search for "pi\xea\xb6\xe6" in iso8859-2. |
44 | 3978 */ |
3979 void | |
3980 gui_motif_synch_fonts(void) | |
3981 { | |
3982 SharedFindReplace *frdp; | |
3983 int do_replace; | |
3984 XFontStruct *font; | |
3985 XmFontList font_list; | |
3986 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3987 // 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
|
3988 // we just give up here on font synchronization. |
44 | 3989 font = (XFontStruct *)gui.norm_font; |
3990 if (font == NULL) | |
3991 return; | |
3992 | |
3993 font_list = gui_motif_create_fontlist(font); | |
3994 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3995 // OK this loop is a bit tricky... |
44 | 3996 for (do_replace = 0; do_replace <= 1; ++do_replace) |
3997 { | |
3998 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | |
3999 if (frdp->dialog) | |
4000 { | |
4001 XtVaSetValues(frdp->what, XmNfontList, font_list, NULL); | |
4002 if (do_replace) | |
4003 XtVaSetValues(frdp->with, XmNfontList, font_list, NULL); | |
4004 } | |
4005 } | |
4006 | |
4007 XmFontListFree(font_list); | |
4008 } |