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