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