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