comparison src/gui_athena.c @ 18781:79e10adc821d v8.1.2380

patch 8.1.2380: using old C style comments Commit: https://github.com/vim/vim/commit/306139005c31ea7e6f892dd119beba3c94dcb982 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 1 22:11:18 2019 +0100 patch 8.1.2380: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Sun, 01 Dec 2019 22:15:03 +0100
parents 6e4e0d43b20b
children 3ff714d765ba
comparison
equal deleted inserted replaced
18780:04ce3b8a50ed 18781:79e10adc821d
32 # include <X11/Xaw/SmeLine.h> 32 # include <X11/Xaw/SmeLine.h>
33 # include <X11/Xaw/Box.h> 33 # include <X11/Xaw/Box.h>
34 # include <X11/Xaw/Dialog.h> 34 # include <X11/Xaw/Dialog.h>
35 # include <X11/Xaw/Text.h> 35 # include <X11/Xaw/Text.h>
36 # include <X11/Xaw/AsciiText.h> 36 # include <X11/Xaw/AsciiText.h>
37 #endif /* FEAT_GUI_NEXTAW */ 37 #endif // FEAT_GUI_NEXTAW
38 38
39 #ifndef FEAT_GUI_NEXTAW 39 #ifndef FEAT_GUI_NEXTAW
40 # include "gui_at_sb.h" 40 # include "gui_at_sb.h"
41 #endif 41 #endif
42 42
44 44
45 static Widget vimForm = (Widget)0; 45 static Widget vimForm = (Widget)0;
46 Widget textArea = (Widget)0; 46 Widget textArea = (Widget)0;
47 #ifdef FEAT_MENU 47 #ifdef FEAT_MENU
48 static Widget menuBar = (Widget)0; 48 static Widget menuBar = (Widget)0;
49 static XtIntervalId timer = 0; /* 0 = expired, otherwise active */ 49 static XtIntervalId timer = 0; // 0 = expired, otherwise active
50 50
51 /* Used to figure out menu ordering */ 51 // Used to figure out menu ordering
52 static vimmenu_T *a_cur_menu = NULL; 52 static vimmenu_T *a_cur_menu = NULL;
53 static Cardinal athena_calculate_ins_pos(Widget); 53 static Cardinal athena_calculate_ins_pos(Widget);
54 54
55 static void gui_athena_popup_callback(Widget, XtPointer, XtPointer); 55 static void gui_athena_popup_callback(Widget, XtPointer, XtPointer);
56 static void gui_athena_delayed_arm_action(Widget, XEvent *, String *, 56 static void gui_athena_delayed_arm_action(Widget, XEvent *, String *,
94 94
95 sb = gui_find_scrollbar((long)client_data); 95 sb = gui_find_scrollbar((long)client_data);
96 96
97 if (sb == NULL) 97 if (sb == NULL)
98 return; 98 return;
99 else if (sb->wp != NULL) /* Left or right scrollbar */ 99 else if (sb->wp != NULL) // Left or right scrollbar
100 { 100 {
101 /* 101 /*
102 * Careful: need to get scrollbar info out of first (left) scrollbar 102 * Careful: need to get scrollbar info out of first (left) scrollbar
103 * for window, but keep real scrollbar too because we must pass it to 103 * for window, but keep real scrollbar too because we must pass it to
104 * gui_drag_scrollbar(). 104 * gui_drag_scrollbar().
105 */ 105 */
106 sb_info = &sb->wp->w_scrollbars[0]; 106 sb_info = &sb->wp->w_scrollbars[0];
107 } 107 }
108 else /* Bottom scrollbar */ 108 else // Bottom scrollbar
109 sb_info = sb; 109 sb_info = sb;
110 110
111 value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001); 111 value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001);
112 if (value > sb_info->max) 112 if (value > sb_info->max)
113 value = sb_info->max; 113 value = sb_info->max;
132 132
133 sb = gui_find_scrollbar((long)client_data); 133 sb = gui_find_scrollbar((long)client_data);
134 134
135 if (sb == NULL) 135 if (sb == NULL)
136 return; 136 return;
137 if (sb->wp != NULL) /* Left or right scrollbar */ 137 if (sb->wp != NULL) // Left or right scrollbar
138 { 138 {
139 /* 139 /*
140 * Careful: need to get scrollbar info out of first (left) scrollbar 140 * Careful: need to get scrollbar info out of first (left) scrollbar
141 * for window, but keep real scrollbar too because we must pass it to 141 * for window, but keep real scrollbar too because we must pass it to
142 * gui_drag_scrollbar(). 142 * gui_drag_scrollbar().
143 */ 143 */
144 sb_info = &sb->wp->w_scrollbars[0]; 144 sb_info = &sb->wp->w_scrollbars[0];
145 145
146 if (sb_info->size > 5) 146 if (sb_info->size > 5)
147 page = sb_info->size - 2; /* use two lines of context */ 147 page = sb_info->size - 2; // use two lines of context
148 else 148 else
149 page = sb_info->size; 149 page = sb_info->size;
150 #ifdef FEAT_GUI_NEXTAW 150 #ifdef FEAT_GUI_NEXTAW
151 if (data < 0) 151 if (data < 0)
152 { 152 {
175 case -END_PAGE_DATA: data = -sb_info->max; break; 175 case -END_PAGE_DATA: data = -sb_info->max; break;
176 default: data = 0; break; 176 default: data = 0; break;
177 } 177 }
178 #endif 178 #endif
179 } 179 }
180 else /* Bottom scrollbar */ 180 else // Bottom scrollbar
181 { 181 {
182 sb_info = sb; 182 sb_info = sb;
183 #ifdef FEAT_GUI_NEXTAW 183 #ifdef FEAT_GUI_NEXTAW
184 if (data < 0) 184 if (data < 0)
185 { 185 {
192 data = (data + gui.char_width - 1) / gui.char_width; 192 data = (data + gui.char_width - 1) / gui.char_width;
193 if (data < sb->size) 193 if (data < sb->size)
194 data = 1; 194 data = 1;
195 } 195 }
196 #endif 196 #endif
197 if (data < -1) /* page-width left */ 197 if (data < -1) // page-width left
198 { 198 {
199 if (sb->size > 8) 199 if (sb->size > 8)
200 data = -(sb->size - 5); 200 data = -(sb->size - 5);
201 else 201 else
202 data = -sb->size; 202 data = -sb->size;
203 } 203 }
204 else if (data > 1) /* page-width right */ 204 else if (data > 1) // page-width right
205 { 205 {
206 if (sb->size > 8) 206 if (sb->size > 8)
207 data = (sb->size - 5); 207 data = (sb->size - 5);
208 else 208 else
209 data = sb->size; 209 data = sb->size;
214 if (value > sb_info->max) 214 if (value > sb_info->max)
215 value = sb_info->max; 215 value = sb_info->max;
216 else if (value < 0) 216 else if (value < 0)
217 value = 0; 217 value = 0;
218 218
219 /* Update the bottom scrollbar an extra time (why is this needed?? */ 219 // Update the bottom scrollbar an extra time (why is this needed??
220 if (sb->wp == NULL) /* Bottom scrollbar */ 220 if (sb->wp == NULL) // Bottom scrollbar
221 gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max); 221 gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max);
222 222
223 gui_drag_scrollbar(sb, value, FALSE); 223 gui_drag_scrollbar(sb, value, FALSE);
224 } 224 }
225 225
233 * We don't have any borders handled internally by the textArea to worry 233 * We don't have any borders handled internally by the textArea to worry
234 * about so only skip over the configured border width. 234 * about so only skip over the configured border width.
235 */ 235 */
236 gui.border_offset = gui.border_width; 236 gui.border_offset = gui.border_width;
237 237
238 /* The form containing all the other widgets */ 238 // The form containing all the other widgets
239 vimForm = XtVaCreateManagedWidget("vimForm", 239 vimForm = XtVaCreateManagedWidget("vimForm",
240 formWidgetClass, vimShell, 240 formWidgetClass, vimShell,
241 XtNborderWidth, 0, 241 XtNborderWidth, 0,
242 NULL); 242 NULL);
243 gui_athena_scroll_colors(vimForm); 243 gui_athena_scroll_colors(vimForm);
244 244
245 #ifdef FEAT_MENU 245 #ifdef FEAT_MENU
246 /* The top menu bar */ 246 // The top menu bar
247 menuBar = XtVaCreateManagedWidget("menuBar", 247 menuBar = XtVaCreateManagedWidget("menuBar",
248 boxWidgetClass, vimForm, 248 boxWidgetClass, vimForm,
249 XtNresizable, True, 249 XtNresizable, True,
250 XtNtop, XtChainTop, 250 XtNtop, XtChainTop,
251 XtNbottom, XtChainTop, 251 XtNbottom, XtChainTop,
257 if (gui.menu_fg_pixel != INVALCOLOR) 257 if (gui.menu_fg_pixel != INVALCOLOR)
258 XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); 258 XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL);
259 #endif 259 #endif
260 260
261 #ifdef FEAT_TOOLBAR 261 #ifdef FEAT_TOOLBAR
262 /* Don't create it Managed, it will be managed when creating the first 262 // Don't create it Managed, it will be managed when creating the first
263 * item. Otherwise an empty toolbar shows up. */ 263 // item. Otherwise an empty toolbar shows up.
264 toolBar = XtVaCreateWidget("toolBar", 264 toolBar = XtVaCreateWidget("toolBar",
265 boxWidgetClass, vimForm, 265 boxWidgetClass, vimForm,
266 XtNresizable, True, 266 XtNresizable, True,
267 XtNtop, XtChainTop, 267 XtNtop, XtChainTop,
268 XtNbottom, XtChainTop, 268 XtNbottom, XtChainTop,
274 XtNinsertPosition, athena_calculate_ins_pos, 274 XtNinsertPosition, athena_calculate_ins_pos,
275 NULL); 275 NULL);
276 gui_athena_menu_colors(toolBar); 276 gui_athena_menu_colors(toolBar);
277 #endif 277 #endif
278 278
279 /* The text area. */ 279 // The text area.
280 textArea = XtVaCreateManagedWidget("textArea", 280 textArea = XtVaCreateManagedWidget("textArea",
281 coreWidgetClass, vimForm, 281 coreWidgetClass, vimForm,
282 XtNresizable, True, 282 XtNresizable, True,
283 XtNtop, XtChainTop, 283 XtNtop, XtChainTop,
284 XtNbottom, XtChainTop, 284 XtNbottom, XtChainTop,
313 313
314 XtAppAddActions(XtWidgetToApplicationContext(vimForm), pullAction, 314 XtAppAddActions(XtWidgetToApplicationContext(vimForm), pullAction,
315 XtNumber(pullAction)); 315 XtNumber(pullAction));
316 #endif 316 #endif
317 317
318 /* Pretend we don't have input focus, we will get an event if we do. */ 318 // Pretend we don't have input focus, we will get an event if we do.
319 gui.in_focus = FALSE; 319 gui.in_focus = FALSE;
320 } 320 }
321 321
322 #ifdef FEAT_MENU 322 #ifdef FEAT_MENU
323 /* 323 /*
350 #else 350 #else
351 from.size = strlen(from.addr = XtDefaultFont); 351 from.size = strlen(from.addr = XtDefaultFont);
352 to.addr = (XtPointer)&font; 352 to.addr = (XtPointer)&font;
353 to.size = sizeof(XFontStruct *); 353 to.size = sizeof(XFontStruct *);
354 #endif 354 #endif
355 /* Assumption: The menuBar children will use the same font as the 355 // Assumption: The menuBar children will use the same font as the
356 * pulldown menu items AND they will all be of type 356 // pulldown menu items AND they will all be of type
357 * XtNfont. 357 // XtNfont.
358 */
359 XtVaGetValues(menuBar, XtNchildren, &children, 358 XtVaGetValues(menuBar, XtNchildren, &children,
360 XtNnumChildren, &num_children, 359 XtNnumChildren, &num_children,
361 NULL); 360 NULL);
362 if (XtConvertAndStore(w ? w : 361 if (XtConvertAndStore(w ? w :
363 (num_children > 0) ? children[0] : menuBar, 362 (num_children > 0) ? children[0] : menuBar,
367 #else 366 #else
368 XtRFontStruct, &to 367 XtRFontStruct, &to
369 #endif 368 #endif
370 ) == False) 369 ) == False)
371 return None; 370 return None;
372 /* "font" should now contain data */ 371 // "font" should now contain data
373 } 372 }
374 else 373 else
375 #ifdef FONTSET_ALWAYS 374 #ifdef FONTSET_ALWAYS
376 font = (XFontSet)gui.menu_fontset; 375 font = (XFontSet)gui.menu_fontset;
377 #else 376 #else
447 * Return in "sen". 446 * Return in "sen".
448 */ 447 */
449 static void 448 static void
450 get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen) 449 get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen)
451 { 450 {
452 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ 451 char_u buf[MAXPATHL]; // buffer storing expanded pathname
453 char **xpm = NULL; /* xpm array */ 452 char **xpm = NULL; // xpm array
454 453
455 buf[0] = NUL; /* start with NULL path */ 454 buf[0] = NUL; // start with NULL path
456 455
457 if (menu->iconfile != NULL) 456 if (menu->iconfile != NULL)
458 { 457 {
459 /* Use the "icon=" argument. */ 458 // Use the "icon=" argument.
460 gui_find_iconfile(menu->iconfile, buf, "xpm"); 459 gui_find_iconfile(menu->iconfile, buf, "xpm");
461 createXpmImages(buf, NULL, sen); 460 createXpmImages(buf, NULL, sen);
462 461
463 /* If it failed, try using the menu name. */ 462 // If it failed, try using the menu name.
464 if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK) 463 if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK)
465 createXpmImages(buf, NULL, sen); 464 createXpmImages(buf, NULL, sen);
466 if (*sen != (Pixmap)0) 465 if (*sen != (Pixmap)0)
467 return; 466 return;
468 } 467 }
509 &color[FOREGROUND].pixel, 508 &color[FOREGROUND].pixel,
510 &color[BOTTOM_SHADOW].pixel, 509 &color[BOTTOM_SHADOW].pixel,
511 &color[TOP_SHADOW].pixel, 510 &color[TOP_SHADOW].pixel,
512 &color[HIGHLIGHT].pixel); 511 &color[HIGHLIGHT].pixel);
513 512
514 /* Setup the color substitution table */ 513 // Setup the color substitution table
515 attrs.valuemask = XpmColorSymbols; 514 attrs.valuemask = XpmColorSymbols;
516 attrs.colorsymbols = color; 515 attrs.colorsymbols = color;
517 attrs.numsymbols = 5; 516 attrs.numsymbols = 5;
518 517
519 screenNum = DefaultScreen(gui.dpy); 518 screenNum = DefaultScreen(gui.dpy);
520 rootWindow = RootWindow(gui.dpy, screenNum); 519 rootWindow = RootWindow(gui.dpy, screenNum);
521 520
522 /* Create the "sensitive" pixmap */ 521 // Create the "sensitive" pixmap
523 if (xpm != NULL) 522 if (xpm != NULL)
524 status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm, 523 status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm,
525 &map, &mask, &attrs); 524 &map, &mask, &attrs);
526 else 525 else
527 status = XpmReadFileToPixmap(gui.dpy, rootWindow, (char *)path, 526 status = XpmReadFileToPixmap(gui.dpy, rootWindow, (char *)path,
530 { 529 {
531 XGCValues gcvalues; 530 XGCValues gcvalues;
532 GC back_gc; 531 GC back_gc;
533 GC mask_gc; 532 GC mask_gc;
534 533
535 /* Need to create new Pixmaps with the mask applied. */ 534 // Need to create new Pixmaps with the mask applied.
536 gcvalues.foreground = color[BACKGROUND].pixel; 535 gcvalues.foreground = color[BACKGROUND].pixel;
537 back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); 536 back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
538 mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); 537 mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
539 XSetClipMask(gui.dpy, mask_gc, mask); 538 XSetClipMask(gui.dpy, mask_gc, mask);
540 539
541 /* Create the "sensitive" pixmap. */ 540 // Create the "sensitive" pixmap.
542 *sen = XCreatePixmap(gui.dpy, rootWindow, 541 *sen = XCreatePixmap(gui.dpy, rootWindow,
543 attrs.width, attrs.height, 542 attrs.width, attrs.height,
544 DefaultDepth(gui.dpy, screenNum)); 543 DefaultDepth(gui.dpy, screenNum));
545 XFillRectangle(gui.dpy, *sen, back_gc, 0, 0, 544 XFillRectangle(gui.dpy, *sen, back_gc, 0, 0,
546 attrs.width, attrs.height); 545 attrs.width, attrs.height);
565 int h) 564 int h)
566 { 565 {
567 Dimension border; 566 Dimension border;
568 int height; 567 int height;
569 568
570 if (!XtIsManaged(toolBar)) /* nothing to do */ 569 if (!XtIsManaged(toolBar)) // nothing to do
571 return; 570 return;
572 XtUnmanageChild(toolBar); 571 XtUnmanageChild(toolBar);
573 XtVaGetValues(toolBar, 572 XtVaGetValues(toolBar,
574 XtNborderWidth, &border, 573 XtNborderWidth, &border,
575 NULL); 574 NULL);
600 XtNwidth, w, 599 XtNwidth, w,
601 XtNheight, h, 600 XtNheight, h,
602 NULL); 601 NULL);
603 XtManageChild(textArea); 602 XtManageChild(textArea);
604 #ifdef FEAT_TOOLBAR 603 #ifdef FEAT_TOOLBAR
605 /* Give keyboard focus to the textArea instead of the toolbar. */ 604 // Give keyboard focus to the textArea instead of the toolbar.
606 gui_mch_reset_focus(); 605 gui_mch_reset_focus();
607 #endif 606 #endif
608 } 607 }
609 608
610 #ifdef FEAT_TOOLBAR 609 #ifdef FEAT_TOOLBAR
684 Dimension border; 683 Dimension border;
685 int height; 684 int height;
686 685
687 XtUnmanageChild(menuBar); 686 XtUnmanageChild(menuBar);
688 XtVaGetValues(menuBar, XtNborderWidth, &border, NULL); 687 XtVaGetValues(menuBar, XtNborderWidth, &border, NULL);
689 /* avoid trouble when there are no menu items, and h is 1 */ 688 // avoid trouble when there are no menu items, and h is 1
690 height = h - 2 * border; 689 height = h - 2 * border;
691 if (height < 0) 690 if (height < 0)
692 height = 1; 691 height = 1;
693 XtVaSetValues(menuBar, 692 XtVaSetValues(menuBar,
694 XtNhorizDistance, x, 693 XtNhorizDistance, x,
707 * numChildren (end of children). 706 * numChildren (end of children).
708 */ 707 */
709 static Cardinal 708 static Cardinal
710 athena_calculate_ins_pos(Widget widget) 709 athena_calculate_ins_pos(Widget widget)
711 { 710 {
712 /* Assume that if the parent of the vimmenu_T is NULL, then we can get 711 // Assume that if the parent of the vimmenu_T is NULL, then we can get
713 * to this menu by traversing "next", starting at "root_menu". 712 // to this menu by traversing "next", starting at "root_menu".
714 * 713 //
715 * This holds true for popup menus, toolbar, and toplevel menu items. 714 // This holds true for popup menus, toolbar, and toplevel menu items.
716 */ 715
717 716 // Popup menus: "id" is NULL. Only submenu_id is valid
718 /* Popup menus: "id" is NULL. Only submenu_id is valid */ 717
719 718 // Menus that are not toplevel: "parent" will be non-NULL, "id" &
720 /* Menus that are not toplevel: "parent" will be non-NULL, "id" & 719 // "submenu_id" will be non-NULL.
721 * "submenu_id" will be non-NULL. 720
722 */ 721 // Toplevel menus: "parent" is NULL, id is the widget of the menu item
723
724 /* Toplevel menus: "parent" is NULL, id is the widget of the menu item */
725 722
726 WidgetList children; 723 WidgetList children;
727 Cardinal num_children = 0; 724 Cardinal num_children = 0;
728 int retval; 725 int retval;
729 Arg args[2]; 726 Arg args[2];
791 XtNtranslations, supermenuTrans, 788 XtNtranslations, supermenuTrans,
792 NULL); 789 NULL);
793 gui_athena_menu_colors(menu->submenu_id); 790 gui_athena_menu_colors(menu->submenu_id);
794 gui_athena_menu_font(menu->submenu_id); 791 gui_athena_menu_font(menu->submenu_id);
795 792
796 /* Don't update the menu height when it was set at a fixed value */ 793 // Don't update the menu height when it was set at a fixed value
797 if (!gui.menu_height_fixed) 794 if (!gui.menu_height_fixed)
798 { 795 {
799 /* 796 /*
800 * When we add a top-level item to the menu bar, we can figure 797 * When we add a top-level item to the menu bar, we can figure
801 * out how high the menu bar should be. 798 * out how high the menu bar should be.
825 if (pullerBitmap == None) 822 if (pullerBitmap == None)
826 pullerBitmap = gui_athena_create_pullright_pixmap(menu->id); 823 pullerBitmap = gui_athena_create_pullright_pixmap(menu->id);
827 824
828 XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap, 825 XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap,
829 NULL); 826 NULL);
830 /* If there are other menu items that are not pulldown menus, 827 // If there are other menu items that are not pulldown menus,
831 * we need to adjust the right margins of those, too. 828 // we need to adjust the right margins of those, too.
832 */
833 { 829 {
834 WidgetList children; 830 WidgetList children;
835 Cardinal num_children; 831 Cardinal num_children;
836 int i; 832 int i;
837 833
863 XtOverrideTranslations(parent->submenu_id, parentTrans); 859 XtOverrideTranslations(parent->submenu_id, parentTrans);
864 } 860 }
865 a_cur_menu = NULL; 861 a_cur_menu = NULL;
866 } 862 }
867 863
868 /* Used to determine whether a SimpleMenu has pulldown entries. 864 // Used to determine whether a SimpleMenu has pulldown entries.
869 * 865 //
870 * "id" is the parent of the menu items. 866 // "id" is the parent of the menu items.
871 * Ignore widget "ignore" in the pane. 867 // Ignore widget "ignore" in the pane.
872 */
873 static Boolean 868 static Boolean
874 gui_athena_menu_has_submenus(Widget id, Widget ignore) 869 gui_athena_menu_has_submenus(Widget id, Widget ignore)
875 { 870 {
876 WidgetList children; 871 WidgetList children;
877 Cardinal num_children; 872 Cardinal num_children;
898 { 893 {
899 if (XtIsManaged(id)) 894 if (XtIsManaged(id))
900 { 895 {
901 XtUnmanageChild(id); 896 XtUnmanageChild(id);
902 XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL); 897 XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL);
903 /* We should force the widget to recalculate its 898 // We should force the widget to recalculate its
904 * geometry now. */ 899 // geometry now.
905 XtManageChild(id); 900 XtManageChild(id);
906 } 901 }
907 else 902 else
908 XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL); 903 XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL);
909 if (has_submenu(id)) 904 if (has_submenu(id))
927 # endif 922 # endif
928 XtVaSetValues(id, XtNfont, gui.menu_font, NULL); 923 XtVaSetValues(id, XtNfont, gui.menu_font, NULL);
929 if (has_submenu(id)) 924 if (has_submenu(id))
930 XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL); 925 XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL);
931 926
932 /* Force the widget to recalculate its geometry now. */ 927 // Force the widget to recalculate its geometry now.
933 if (managed) 928 if (managed)
934 XtManageChild(id); 929 XtManageChild(id);
935 } 930 }
936 #endif 931 #endif
937 } 932 }
951 pullerBitmap = gui_athena_create_pullright_pixmap(NULL); 946 pullerBitmap = gui_athena_create_pullright_pixmap(NULL);
952 } 947 }
953 gui_mch_submenu_change(root_menu, FALSE); 948 gui_mch_submenu_change(root_menu, FALSE);
954 949
955 { 950 {
956 /* Iterate through the menubar menu items and get the height of 951 // Iterate through the menubar menu items and get the height of
957 * each one. The menu bar height is set to the maximum of all 952 // each one. The menu bar height is set to the maximum of all
958 * the heights. 953 // the heights.
959 */
960 vimmenu_T *mp; 954 vimmenu_T *mp;
961 int max_height = 9999; 955 int max_height = 9999;
962 956
963 for (mp = root_menu; mp != NULL; mp = mp->next) 957 for (mp = root_menu; mp != NULL; mp = mp->next)
964 { 958 {
973 max_height = height; 967 max_height = height;
974 } 968 }
975 } 969 }
976 if (max_height != 9999) 970 if (max_height != 9999)
977 { 971 {
978 /* Don't update the menu height when it was set at a fixed value */ 972 // Don't update the menu height when it was set at a fixed value
979 if (!gui.menu_height_fixed) 973 if (!gui.menu_height_fixed)
980 { 974 {
981 Dimension space, border; 975 Dimension space, border;
982 976
983 XtVaGetValues(menuBar, 977 XtVaGetValues(menuBar,
986 NULL); 980 NULL);
987 gui.menu_height = max_height + 2 * (space + border); 981 gui.menu_height = max_height + 2 * (space + border);
988 } 982 }
989 } 983 }
990 } 984 }
991 /* Now, to simulate the window being resized. Only, this 985 // Now, to simulate the window being resized. Only, this
992 * will resize the window to its current state. 986 // will resize the window to its current state.
993 * 987 //
994 * There has to be a better way, but I do not see one at this time. 988 // There has to be a better way, but I do not see one at this time.
995 * (David Harrison) 989 // (David Harrison)
996 */
997 { 990 {
998 Position w, h; 991 Position w, h;
999 992
1000 XtVaGetValues(vimShell, 993 XtVaGetValues(vimShell,
1001 XtNwidth, &w, 994 XtNwidth, &w,
1046 #endif 1039 #endif
1047 1040
1048 static void 1041 static void
1049 gui_mch_submenu_change( 1042 gui_mch_submenu_change(
1050 vimmenu_T *menu, 1043 vimmenu_T *menu,
1051 int colors) /* TRUE for colors, FALSE for font */ 1044 int colors) // TRUE for colors, FALSE for font
1052 { 1045 {
1053 vimmenu_T *mp; 1046 vimmenu_T *mp;
1054 1047
1055 for (mp = menu; mp != NULL; mp = mp->next) 1048 for (mp = menu; mp != NULL; mp = mp->next)
1056 { 1049 {
1058 { 1051 {
1059 if (colors) 1052 if (colors)
1060 { 1053 {
1061 gui_athena_menu_colors(mp->id); 1054 gui_athena_menu_colors(mp->id);
1062 #ifdef FEAT_TOOLBAR 1055 #ifdef FEAT_TOOLBAR
1063 /* For a toolbar item: Free the pixmap and allocate a new one, 1056 // For a toolbar item: Free the pixmap and allocate a new one,
1064 * so that the background color is right. */ 1057 // so that the background color is right.
1065 if (mp->image != (Pixmap)0) 1058 if (mp->image != (Pixmap)0)
1066 { 1059 {
1067 XFreePixmap(gui.dpy, mp->image); 1060 XFreePixmap(gui.dpy, mp->image);
1068 get_toolbar_pixmap(mp, &mp->image); 1061 get_toolbar_pixmap(mp, &mp->image);
1069 if (mp->image != (Pixmap)0) 1062 if (mp->image != (Pixmap)0)
1070 XtVaSetValues(mp->id, XtNbitmap, mp->image, NULL); 1063 XtVaSetValues(mp->id, XtNbitmap, mp->image, NULL);
1071 } 1064 }
1072 1065
1073 # ifdef FEAT_BEVAL_GUI 1066 # ifdef FEAT_BEVAL_GUI
1074 /* If we have a tooltip, then we need to change its colors */ 1067 // If we have a tooltip, then we need to change its colors
1075 if (mp->tip != NULL) 1068 if (mp->tip != NULL)
1076 { 1069 {
1077 Arg args[2]; 1070 Arg args[2];
1078 1071
1079 args[0].name = XtNbackground; 1072 args[0].name = XtNbackground;
1087 } 1080 }
1088 else 1081 else
1089 { 1082 {
1090 gui_athena_menu_font(mp->id); 1083 gui_athena_menu_font(mp->id);
1091 #ifdef FEAT_BEVAL_GUI 1084 #ifdef FEAT_BEVAL_GUI
1092 /* If we have a tooltip, then we need to change its font */ 1085 // If we have a tooltip, then we need to change its font
1093 /* Assume XtNinternational == True (in createBalloonEvalWindow) 1086 // Assume XtNinternational == True (in createBalloonEvalWindow)
1094 */
1095 if (mp->tip != NULL) 1087 if (mp->tip != NULL)
1096 { 1088 {
1097 Arg args[1]; 1089 Arg args[1];
1098 1090
1099 args[0].name = XtNfontSet; 1091 args[0].name = XtNfontSet;
1104 } 1096 }
1105 } 1097 }
1106 1098
1107 if (mp->children != NULL) 1099 if (mp->children != NULL)
1108 { 1100 {
1109 /* Set the colors/font for the tear off widget */ 1101 // Set the colors/font for the tear off widget
1110 if (mp->submenu_id != (Widget)0) 1102 if (mp->submenu_id != (Widget)0)
1111 { 1103 {
1112 if (colors) 1104 if (colors)
1113 gui_athena_menu_colors(mp->submenu_id); 1105 gui_athena_menu_colors(mp->submenu_id);
1114 else 1106 else
1115 gui_athena_menu_font(mp->submenu_id); 1107 gui_athena_menu_font(mp->submenu_id);
1116 } 1108 }
1117 /* Set the colors for the children */ 1109 // Set the colors for the children
1118 gui_mch_submenu_change(mp->children, colors); 1110 gui_mch_submenu_change(mp->children, colors);
1119 } 1111 }
1120 } 1112 }
1121 } 1113 }
1122 1114
1169 if (menu->image != 0) 1161 if (menu->image != 0)
1170 XtSetArg(args[n], XtNbitmap, menu->image); n++; 1162 XtSetArg(args[n], XtNbitmap, menu->image); n++;
1171 } 1163 }
1172 XtSetArg(args[n], XtNhighlightThickness, 0); n++; 1164 XtSetArg(args[n], XtNhighlightThickness, 0); n++;
1173 type = commandWidgetClass; 1165 type = commandWidgetClass;
1174 /* TODO: figure out the position in the toolbar? 1166 // TODO: figure out the position in the toolbar?
1175 * This currently works fine for the default toolbar, but 1167 // This currently works fine for the default toolbar, but
1176 * what if we add/remove items during later runtime? 1168 // what if we add/remove items during later runtime?
1177 */ 1169
1178 1170 // NOTE: "idx" isn't used here. The position is calculated by
1179 /* NOTE: "idx" isn't used here. The position is calculated by 1171 // athena_calculate_ins_pos(). The position it calculates
1180 * athena_calculate_ins_pos(). The position it calculates 1172 // should be equal to "idx".
1181 * should be equal to "idx". 1173 // TODO: Could we just store "idx" and use that as the child
1182 */ 1174 // placement?
1183 /* TODO: Could we just store "idx" and use that as the child
1184 * placement?
1185 */
1186 1175
1187 if (menu->id == NULL) 1176 if (menu->id == NULL)
1188 { 1177 {
1189 menu->id = XtCreateManagedWidget((char *)menu->dname, 1178 menu->id = XtCreateManagedWidget((char *)menu->dname,
1190 type, toolBar, args, n); 1179 type, toolBar, args, n);
1204 if (!XtIsManaged(toolBar) 1193 if (!XtIsManaged(toolBar)
1205 && vim_strchr(p_go, GO_TOOLBAR) != NULL) 1194 && vim_strchr(p_go, GO_TOOLBAR) != NULL)
1206 gui_mch_show_toolbar(TRUE); 1195 gui_mch_show_toolbar(TRUE);
1207 gui.toolbar_height = gui_mch_compute_toolbar_height(); 1196 gui.toolbar_height = gui_mch_compute_toolbar_height();
1208 return; 1197 return;
1209 } /* toolbar menu item */ 1198 } // toolbar menu item
1210 # endif 1199 # endif
1211 1200
1212 /* Add menu separator */ 1201 // Add menu separator
1213 if (menu_is_separator(menu->name)) 1202 if (menu_is_separator(menu->name))
1214 { 1203 {
1215 menu->submenu_id = (Widget)0; 1204 menu->submenu_id = (Widget)0;
1216 menu->id = XtVaCreateManagedWidget((char *)menu->dname, 1205 menu->id = XtVaCreateManagedWidget((char *)menu->dname,
1217 smeLineObjectClass, parent->submenu_id, 1206 smeLineObjectClass, parent->submenu_id,
1233 #endif 1222 #endif
1234 NULL); 1223 NULL);
1235 if (menu->id == (Widget)0) 1224 if (menu->id == (Widget)0)
1236 return; 1225 return;
1237 1226
1238 /* If there are other "pulldown" items in this pane, then adjust 1227 // If there are other "pulldown" items in this pane, then adjust
1239 * the right margin to accommodate the arrow pixmap, otherwise 1228 // the right margin to accommodate the arrow pixmap, otherwise
1240 * the right margin will be the same as the left margin. 1229 // the right margin will be the same as the left margin.
1241 */
1242 { 1230 {
1243 Dimension left_margin; 1231 Dimension left_margin;
1244 1232
1245 XtVaGetValues(menu->id, XtNleftMargin, &left_margin, NULL); 1233 XtVaGetValues(menu->id, XtNleftMargin, &left_margin, NULL);
1246 XtVaSetValues(menu->id, XtNrightMargin, 1234 XtVaSetValues(menu->id, XtNrightMargin,
1261 1249
1262 #if defined(FEAT_TOOLBAR) || defined(PROTO) 1250 #if defined(FEAT_TOOLBAR) || defined(PROTO)
1263 void 1251 void
1264 gui_mch_show_toolbar(int showit) 1252 gui_mch_show_toolbar(int showit)
1265 { 1253 {
1266 Cardinal numChildren; /* how many children toolBar has */ 1254 Cardinal numChildren; // how many children toolBar has
1267 1255
1268 if (toolBar == (Widget)0) 1256 if (toolBar == (Widget)0)
1269 return; 1257 return;
1270 XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL); 1258 XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL);
1271 if (showit && numChildren > 0) 1259 if (showit && numChildren > 0)
1272 { 1260 {
1273 /* Assume that we want to show the toolbar if p_toolbar contains valid 1261 // Assume that we want to show the toolbar if p_toolbar contains valid
1274 * option settings, therefore p_toolbar must not be NULL. 1262 // option settings, therefore p_toolbar must not be NULL.
1275 */
1276 WidgetList children; 1263 WidgetList children;
1277 1264
1278 XtVaGetValues(toolBar, XtNchildren, &children, NULL); 1265 XtVaGetValues(toolBar, XtNchildren, &children, NULL);
1279 { 1266 {
1280 void (*action)(BalloonEval *); 1267 void (*action)(BalloonEval *);
1294 vimmenu_T *cur; 1281 vimmenu_T *cur;
1295 1282
1296 for (toolbar = root_menu; toolbar; toolbar = toolbar->next) 1283 for (toolbar = root_menu; toolbar; toolbar = toolbar->next)
1297 if (menu_is_toolbar(toolbar->dname)) 1284 if (menu_is_toolbar(toolbar->dname))
1298 break; 1285 break;
1299 /* Assumption: toolbar is NULL if there is no toolbar, 1286 // Assumption: toolbar is NULL if there is no toolbar,
1300 * otherwise it contains the toolbar menu structure. 1287 // otherwise it contains the toolbar menu structure.
1301 * 1288 //
1302 * Assumption: "numChildren" == the number of items in the list 1289 // Assumption: "numChildren" == the number of items in the list
1303 * of items beginning with toolbar->children. 1290 // of items beginning with toolbar->children.
1304 */
1305 if (toolbar) 1291 if (toolbar)
1306 { 1292 {
1307 for (cur = toolbar->children; cur; cur = cur->next) 1293 for (cur = toolbar->children; cur; cur = cur->next)
1308 { 1294 {
1309 Arg args[2]; 1295 Arg args[2];
1310 int n = 0; 1296 int n = 0;
1311 1297
1312 /* Enable/Disable tooltip (OK to enable while currently 1298 // Enable/Disable tooltip (OK to enable while currently
1313 * enabled) 1299 // enabled)
1314 */
1315 if (cur->tip != NULL) 1300 if (cur->tip != NULL)
1316 (*action)(cur->tip); 1301 (*action)(cur->tip);
1317 if (text == 1) 1302 if (text == 1)
1318 { 1303 {
1319 XtSetArg(args[n], XtNbitmap, None); 1304 XtSetArg(args[n], XtNbitmap, None);
1385 1370
1386 1371
1387 int 1372 int
1388 gui_mch_compute_toolbar_height(void) 1373 gui_mch_compute_toolbar_height(void)
1389 { 1374 {
1390 Dimension height; /* total Toolbar height */ 1375 Dimension height; // total Toolbar height
1391 Dimension whgt; /* height of each widget */ 1376 Dimension whgt; // height of each widget
1392 Dimension marginHeight; /* XmNmarginHeight of toolBar */ 1377 Dimension marginHeight; // XmNmarginHeight of toolBar
1393 Dimension shadowThickness; /* thickness of Xtparent(toolBar) */ 1378 Dimension shadowThickness; // thickness of Xtparent(toolBar)
1394 WidgetList children; /* list of toolBar's children */ 1379 WidgetList children; // list of toolBar's children
1395 Cardinal numChildren; /* how many children toolBar has */ 1380 Cardinal numChildren; // how many children toolBar has
1396 int i; 1381 int i;
1397 1382
1398 height = 0; 1383 height = 0;
1399 shadowThickness = 0; 1384 shadowThickness = 0;
1400 marginHeight = 0; 1385 marginHeight = 0;
1436 1421
1437 1422
1438 void 1423 void
1439 gui_mch_toggle_tearoffs(int enable UNUSED) 1424 gui_mch_toggle_tearoffs(int enable UNUSED)
1440 { 1425 {
1441 /* no tearoff menus */ 1426 // no tearoff menus
1442 } 1427 }
1443 1428
1444 void 1429 void
1445 gui_mch_new_menu_colors(void) 1430 gui_mch_new_menu_colors(void)
1446 { 1431 {
1462 void 1447 void
1463 gui_mch_destroy_menu(vimmenu_T *menu) 1448 gui_mch_destroy_menu(vimmenu_T *menu)
1464 { 1449 {
1465 Widget parent; 1450 Widget parent;
1466 1451
1467 /* There is no item for the toolbar. */ 1452 // There is no item for the toolbar.
1468 if (menu->id == (Widget)0) 1453 if (menu->id == (Widget)0)
1469 return; 1454 return;
1470 1455
1471 parent = XtParent(menu->id); 1456 parent = XtParent(menu->id);
1472 1457
1473 /* When removing the last "pulldown" menu item from a pane, adjust the 1458 // When removing the last "pulldown" menu item from a pane, adjust the
1474 * right margins of the remaining widgets. 1459 // right margins of the remaining widgets.
1475 */
1476 if (menu->submenu_id != (Widget)0) 1460 if (menu->submenu_id != (Widget)0)
1477 { 1461 {
1478 /* Go through the menu items in the parent of this item and 1462 // Go through the menu items in the parent of this item and
1479 * adjust their margins, if necessary. 1463 // adjust their margins, if necessary.
1480 * This takes care of the case when we delete the last menu item in a 1464 // This takes care of the case when we delete the last menu item in a
1481 * pane that has a submenu. In this case, there will be no arrow 1465 // pane that has a submenu. In this case, there will be no arrow
1482 * pixmaps shown anymore. 1466 // pixmaps shown anymore.
1483 */
1484 { 1467 {
1485 WidgetList children; 1468 WidgetList children;
1486 Cardinal num_children; 1469 Cardinal num_children;
1487 int i; 1470 int i;
1488 Dimension right_margin = 0; 1471 Dimension right_margin = 0;
1513 XtVaSetValues(children[i], XtNrightMargin, right_margin, 1496 XtVaSetValues(children[i], XtNrightMargin, right_margin,
1514 NULL); 1497 NULL);
1515 } 1498 }
1516 } 1499 }
1517 } 1500 }
1518 /* Please be sure to destroy the parent widget first (i.e. menu->id). 1501 // Please be sure to destroy the parent widget first (i.e. menu->id).
1519 * 1502 //
1520 * This code should be basically identical to that in the file gui_motif.c 1503 // This code should be basically identical to that in the file gui_motif.c
1521 * because they are both Xt based. 1504 // because they are both Xt based.
1522 */
1523 if (menu->id != (Widget)0) 1505 if (menu->id != (Widget)0)
1524 { 1506 {
1525 Cardinal num_children; 1507 Cardinal num_children;
1526 Dimension height, space, border; 1508 Dimension height, space, border;
1527 1509
1533 XtNheight, &height, 1515 XtNheight, &height,
1534 NULL); 1516 NULL);
1535 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) 1517 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
1536 if (parent == toolBar && menu->tip != NULL) 1518 if (parent == toolBar && menu->tip != NULL)
1537 { 1519 {
1538 /* We try to destroy this before the actual menu, because there are 1520 // We try to destroy this before the actual menu, because there are
1539 * callbacks, etc. that will be unregistered during the tooltip 1521 // callbacks, etc. that will be unregistered during the tooltip
1540 * destruction. 1522 // destruction.
1541 * 1523 //
1542 * If you call "gui_mch_destroy_beval_area()" after destroying 1524 // If you call "gui_mch_destroy_beval_area()" after destroying
1543 * menu->id, then the tooltip's window will have already been 1525 // menu->id, then the tooltip's window will have already been
1544 * deallocated by Xt, and unknown behaviour will ensue (probably 1526 // deallocated by Xt, and unknown behaviour will ensue (probably
1545 * a core dump). 1527 // a core dump).
1546 */
1547 gui_mch_destroy_beval_area(menu->tip); 1528 gui_mch_destroy_beval_area(menu->tip);
1548 menu->tip = NULL; 1529 menu->tip = NULL;
1549 } 1530 }
1550 #endif 1531 #endif
1551 /* 1532 /*
1553 * BadValue error when a menu's last child is destroyed. We check to 1534 * BadValue error when a menu's last child is destroyed. We check to
1554 * see if this is the last child and if so, don't delete it. The parent 1535 * see if this is the last child and if so, don't delete it. The parent
1555 * will be deleted soon anyway, and it will delete its children like 1536 * will be deleted soon anyway, and it will delete its children like
1556 * all good widgets do. 1537 * all good widgets do.
1557 */ 1538 */
1558 /* NOTE: The cause of the BadValue X Protocol Error is because when the 1539 // NOTE: The cause of the BadValue X Protocol Error is because when the
1559 * last child is destroyed, it is first unmanaged, thus causing a 1540 // last child is destroyed, it is first unmanaged, thus causing a
1560 * geometry resize request from the parent Shell widget. 1541 // geometry resize request from the parent Shell widget.
1561 * Since the Shell widget has no more children, it is resized to have 1542 // Since the Shell widget has no more children, it is resized to have
1562 * width/height of 0. XConfigureWindow() is then called with the 1543 // width/height of 0. XConfigureWindow() is then called with the
1563 * width/height of 0, which generates the BadValue. 1544 // width/height of 0, which generates the BadValue.
1564 * 1545 //
1565 * This happens in phase two of the widget destruction process. 1546 // This happens in phase two of the widget destruction process.
1566 */
1567 { 1547 {
1568 if (parent != menuBar 1548 if (parent != menuBar
1569 #ifdef FEAT_TOOLBAR 1549 #ifdef FEAT_TOOLBAR
1570 && parent != toolBar 1550 && parent != toolBar
1571 #endif 1551 #endif
1586 gui.menu_height = height + 2 * (space + border); 1566 gui.menu_height = height + 2 * (space + border);
1587 } 1567 }
1588 #ifdef FEAT_TOOLBAR 1568 #ifdef FEAT_TOOLBAR
1589 else if (parent == toolBar) 1569 else if (parent == toolBar)
1590 { 1570 {
1591 /* When removing last toolbar item, don't display the toolbar. */ 1571 // When removing last toolbar item, don't display the toolbar.
1592 XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL); 1572 XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL);
1593 if (num_children == 0) 1573 if (num_children == 0)
1594 gui_mch_show_toolbar(FALSE); 1574 gui_mch_show_toolbar(FALSE);
1595 else 1575 else
1596 gui.toolbar_height = gui_mch_compute_toolbar_height(); 1576 gui.toolbar_height = gui_mch_compute_toolbar_height();
1618 Pixmap p; 1598 Pixmap p;
1619 1599
1620 XtVaGetValues(w, XtNrightBitmap, &p, NULL); 1600 XtVaGetValues(w, XtNrightBitmap, &p, NULL);
1621 if ((p != None) && (p != XtUnspecifiedPixmap)) 1601 if ((p != None) && (p != XtUnspecifiedPixmap))
1622 { 1602 {
1623 /* We are dealing with an item that has a submenu */ 1603 // We are dealing with an item that has a submenu
1624 popup = get_popup_entry(XtParent(w)); 1604 popup = get_popup_entry(XtParent(w));
1625 if (popup == (Widget)0) 1605 if (popup == (Widget)0)
1626 return; 1606 return;
1627 XtPopup(popup, XtGrabNonexclusive); 1607 XtPopup(popup, XtGrabNonexclusive);
1628 } 1608 }
1629 } 1609 }
1630 } 1610 }
1631 1611
1632 /* This routine is used to calculate the position (in screen coordinates) 1612 /*
1613 * This routine is used to calculate the position (in screen coordinates)
1633 * where a submenu should appear relative to the menu entry that popped it 1614 * where a submenu should appear relative to the menu entry that popped it
1634 * up. It should appear even with and just slightly to the left of the 1615 * up. It should appear even with and just slightly to the left of the
1635 * rightmost end of the menu entry that caused the popup. 1616 * rightmost end of the menu entry that caused the popup.
1636 * 1617 *
1637 * This is called when XtPopup() is called. 1618 * This is called when XtPopup() is called.
1640 gui_athena_popup_callback( 1621 gui_athena_popup_callback(
1641 Widget w, 1622 Widget w,
1642 XtPointer client_data, 1623 XtPointer client_data,
1643 XtPointer call_data UNUSED) 1624 XtPointer call_data UNUSED)
1644 { 1625 {
1645 /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */ 1626 // Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass)
1646 vimmenu_T *menu = (vimmenu_T *)client_data; 1627 vimmenu_T *menu = (vimmenu_T *)client_data;
1647 Dimension width; 1628 Dimension width;
1648 Position root_x, root_y; 1629 Position root_x, root_y;
1649 1630
1650 /* First, popdown any siblings that may have menus popped up */ 1631 // First, popdown any siblings that may have menus popped up
1651 { 1632 {
1652 vimmenu_T *i; 1633 vimmenu_T *i;
1653 1634
1654 for (i = menu->parent->children; i != NULL; i = i->next) 1635 for (i = menu->parent->children; i != NULL; i = i->next)
1655 { 1636 {
1658 } 1639 }
1659 } 1640 }
1660 XtVaGetValues(XtParent(w), 1641 XtVaGetValues(XtParent(w),
1661 XtNwidth, &width, 1642 XtNwidth, &width,
1662 NULL); 1643 NULL);
1663 /* Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id */ 1644 // Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id
1664 /* i.e. This IS the active entry */ 1645 // i.e. This IS the active entry
1665 XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y); 1646 XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y);
1666 XtVaSetValues(w, XtNx, root_x, 1647 XtVaSetValues(w, XtNx, root_x,
1667 XtNy, root_y, 1648 XtNy, root_y,
1668 NULL); 1649 NULL);
1669 } 1650 }
1694 XtPopdown(temp_w); 1675 XtPopdown(temp_w);
1695 } 1676 }
1696 } 1677 }
1697 } 1678 }
1698 1679
1699 /* Used to determine if the given widget has a submenu that can be popped up. */ 1680 /*
1681 * Used to determine if the given widget has a submenu that can be popped up.
1682 */
1700 static Boolean 1683 static Boolean
1701 has_submenu(Widget widget) 1684 has_submenu(Widget widget)
1702 { 1685 {
1703 if ((widget != NULL) && XtIsSubclass(widget,smeBSBObjectClass)) 1686 if ((widget != NULL) && XtIsSubclass(widget,smeBSBObjectClass))
1704 { 1687 {
1738 current = XawSimpleMenuGetActiveEntry(w); 1721 current = XawSimpleMenuGetActiveEntry(w);
1739 if (current != previous_active_widget) 1722 if (current != previous_active_widget)
1740 { 1723 {
1741 if (timer) 1724 if (timer)
1742 { 1725 {
1743 /* If the timeout hasn't been triggered, remove it */ 1726 // If the timeout hasn't been triggered, remove it
1744 XtRemoveTimeOut(timer); 1727 XtRemoveTimeOut(timer);
1745 } 1728 }
1746 gui_athena_popdown_submenus_action(w,event,args,nargs); 1729 gui_athena_popdown_submenus_action(w,event,args,nargs);
1747 if (has_submenu(current)) 1730 if (has_submenu(current))
1748 { 1731 {
1758 static Widget 1741 static Widget
1759 get_popup_entry(Widget w) 1742 get_popup_entry(Widget w)
1760 { 1743 {
1761 Widget menuw; 1744 Widget menuw;
1762 1745
1763 /* Get the active entry for the current menu */ 1746 // Get the active entry for the current menu
1764 if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0) 1747 if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0)
1765 return NULL; 1748 return NULL;
1766 1749
1767 return submenu_widget(menuw); 1750 return submenu_widget(menuw);
1768 } 1751 }
1769 1752
1770 /* Given the widget that has been determined to have a submenu, return the submenu widget 1753 /*
1771 * that is to be popped up. 1754 * Given the widget that has been determined to have a submenu, return the
1755 * submenu widget that is to be popped up.
1772 */ 1756 */
1773 static Widget 1757 static Widget
1774 submenu_widget(Widget widget) 1758 submenu_widget(Widget widget)
1775 { 1759 {
1776 /* Precondition: has_submenu(widget) == True 1760 // Precondition: has_submenu(widget) == True
1777 * XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True 1761 // XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True
1778 */
1779 1762
1780 char_u *pullright_name; 1763 char_u *pullright_name;
1781 Widget popup; 1764 Widget popup;
1782 1765
1783 pullright_name = make_pull_name((char_u *)XtName(widget)); 1766 pullright_name = make_pull_name((char_u *)XtName(widget));
1784 popup = XtNameToWidget(XtParent(widget), (char *)pullright_name); 1767 popup = XtNameToWidget(XtParent(widget), (char *)pullright_name);
1785 vim_free(pullright_name); 1768 vim_free(pullright_name);
1786 1769
1787 return popup; 1770 return popup;
1788 /* Postcondition: (popup != NULL) implies 1771 // Postcondition: (popup != NULL) implies
1789 * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */ 1772 // (XtIsSubclass(popup,simpleMenuWidgetClass) == True)
1790 } 1773 }
1791 1774
1792 void 1775 void
1793 gui_mch_show_popupmenu(vimmenu_T *menu) 1776 gui_mch_show_popupmenu(vimmenu_T *menu)
1794 { 1777 {
1797 unsigned int mask; 1780 unsigned int mask;
1798 1781
1799 if (menu->submenu_id == (Widget)0) 1782 if (menu->submenu_id == (Widget)0)
1800 return; 1783 return;
1801 1784
1802 /* Position the popup menu at the pointer */ 1785 // Position the popup menu at the pointer
1803 if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child, 1786 if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child,
1804 &rootx, &rooty, &winx, &winy, &mask)) 1787 &rootx, &rooty, &winx, &winy, &mask))
1805 { 1788 {
1806 rootx -= 30; 1789 rootx -= 30;
1807 if (rootx < 0) 1790 if (rootx < 0)
1817 1800
1818 XtOverrideTranslations(menu->submenu_id, popupTrans); 1801 XtOverrideTranslations(menu->submenu_id, popupTrans);
1819 XtPopupSpringLoaded(menu->submenu_id); 1802 XtPopupSpringLoaded(menu->submenu_id);
1820 } 1803 }
1821 1804
1822 #endif /* FEAT_MENU */ 1805 #endif // FEAT_MENU
1823 1806
1824 /* 1807 /*
1825 * Set the menu and scrollbar colors to their default values. 1808 * Set the menu and scrollbar colors to their default values.
1826 */ 1809 */
1827 void 1810 void
1864 /* 1847 /*
1865 * Athena scrollbar must go from 0.0 to 1.0. 1848 * Athena scrollbar must go from 0.0 to 1.0.
1866 */ 1849 */
1867 if (max == 0) 1850 if (max == 0)
1868 { 1851 {
1869 /* So you can't scroll it at all (normally it scrolls past end) */ 1852 // So you can't scroll it at all (normally it scrolls past end)
1870 #ifdef FEAT_GUI_NEXTAW 1853 #ifdef FEAT_GUI_NEXTAW
1871 XawScrollbarSetThumb(sb->id, 0.0, 1.0); 1854 XawScrollbarSetThumb(sb->id, 0.0, 1.0);
1872 #else 1855 #else
1873 vim_XawScrollbarSetThumb(sb->id, 0.0, 1.0, 0.0); 1856 vim_XawScrollbarSetThumb(sb->id, 0.0, 1.0, 0.0);
1874 #endif 1857 #endif
1919 } 1902 }
1920 1903
1921 void 1904 void
1922 gui_mch_create_scrollbar( 1905 gui_mch_create_scrollbar(
1923 scrollbar_T *sb, 1906 scrollbar_T *sb,
1924 int orient) /* SBAR_VERT or SBAR_HORIZ */ 1907 int orient) // SBAR_VERT or SBAR_HORIZ
1925 { 1908 {
1926 sb->id = XtVaCreateWidget("scrollBar", 1909 sb->id = XtVaCreateWidget("scrollBar",
1927 #ifdef FEAT_GUI_NEXTAW 1910 #ifdef FEAT_GUI_NEXTAW
1928 scrollbarWidgetClass, vimForm, 1911 scrollbarWidgetClass, vimForm,
1929 #else 1912 #else
1969 XtVaSetValues(sb->id, 1952 XtVaSetValues(sb->id,
1970 XtNforeground, gui.scroll_fg_pixel, 1953 XtNforeground, gui.scroll_fg_pixel,
1971 XtNbackground, gui.scroll_bg_pixel, 1954 XtNbackground, gui.scroll_bg_pixel,
1972 NULL); 1955 NULL);
1973 1956
1974 /* This is needed for the rectangle below the vertical scrollbars. */ 1957 // This is needed for the rectangle below the vertical scrollbars.
1975 if (sb == &gui.bottom_sbar && vimForm != (Widget)0) 1958 if (sb == &gui.bottom_sbar && vimForm != (Widget)0)
1976 gui_athena_scroll_colors(vimForm); 1959 gui_athena_scroll_colors(vimForm);
1977 } 1960 }
1978 1961
1979 /* 1962 /*
1990 * Put up a file requester. 1973 * Put up a file requester.
1991 * Returns the selected name in allocated memory, or NULL for Cancel. 1974 * Returns the selected name in allocated memory, or NULL for Cancel.
1992 */ 1975 */
1993 char_u * 1976 char_u *
1994 gui_mch_browse( 1977 gui_mch_browse(
1995 int saving UNUSED, /* select file to write */ 1978 int saving UNUSED, // select file to write
1996 char_u *title, /* title for the window */ 1979 char_u *title, // title for the window
1997 char_u *dflt, /* default name */ 1980 char_u *dflt, // default name
1998 char_u *ext UNUSED, /* extension added */ 1981 char_u *ext UNUSED, // extension added
1999 char_u *initdir, /* initial directory, NULL for current dir */ 1982 char_u *initdir, // initial directory, NULL for current dir
2000 char_u *filter UNUSED) /* file name filter */ 1983 char_u *filter UNUSED) // file name filter
2001 { 1984 {
2002 Position x, y; 1985 Position x, y;
2003 char_u dirbuf[MAXPATHL]; 1986 char_u dirbuf[MAXPATHL];
2004 1987
2005 /* Concatenate "initdir" and "dflt". */ 1988 // Concatenate "initdir" and "dflt".
2006 if (initdir == NULL || *initdir == NUL) 1989 if (initdir == NULL || *initdir == NUL)
2007 mch_dirname(dirbuf, MAXPATHL); 1990 mch_dirname(dirbuf, MAXPATHL);
2008 else if (STRLEN(initdir) + 2 < MAXPATHL) 1991 else if (STRLEN(initdir) + 2 < MAXPATHL)
2009 STRCPY(dirbuf, initdir); 1992 STRCPY(dirbuf, initdir);
2010 else 1993 else
2014 { 1997 {
2015 add_pathsep(dirbuf); 1998 add_pathsep(dirbuf);
2016 STRCAT(dirbuf, dflt); 1999 STRCAT(dirbuf, dflt);
2017 } 2000 }
2018 2001
2019 /* Position the file selector just below the menubar */ 2002 // Position the file selector just below the menubar
2020 XtTranslateCoords(vimShell, (Position)0, (Position) 2003 XtTranslateCoords(vimShell, (Position)0, (Position)
2021 #ifdef FEAT_MENU 2004 #ifdef FEAT_MENU
2022 gui.menu_height 2005 gui.menu_height
2023 #else 2006 #else
2024 0 2007 0
2109 2092
2110 if (title == NULL) 2093 if (title == NULL)
2111 title = (char_u *)_("Vim dialog"); 2094 title = (char_u *)_("Vim dialog");
2112 dialogStatus = -1; 2095 dialogStatus = -1;
2113 2096
2114 /* if our pointer is currently hidden, then we should show it. */ 2097 // if our pointer is currently hidden, then we should show it.
2115 gui_mch_mousehide(FALSE); 2098 gui_mch_mousehide(FALSE);
2116 2099
2117 /* Check 'v' flag in 'guioptions': vertical button placement. */ 2100 // Check 'v' flag in 'guioptions': vertical button placement.
2118 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); 2101 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
2119 2102
2120 /* The shell is created each time, to make sure it is resized properly */ 2103 // The shell is created each time, to make sure it is resized properly
2121 dialogshell = XtVaCreatePopupShell("dialogShell", 2104 dialogshell = XtVaCreatePopupShell("dialogShell",
2122 transientShellWidgetClass, vimShell, 2105 transientShellWidgetClass, vimShell,
2123 XtNtitle, title, 2106 XtNtitle, title,
2124 NULL); 2107 NULL);
2125 if (dialogshell == (Widget)0) 2108 if (dialogshell == (Widget)0)
2168 XawTextSetInsertionPoint(dialogtextfield, 2151 XawTextSetInsertionPoint(dialogtextfield,
2169 (XawTextPosition)STRLEN(textfield)); 2152 (XawTextPosition)STRLEN(textfield));
2170 XtSetKeyboardFocus(dialog, dialogtextfield); 2153 XtSetKeyboardFocus(dialog, dialogtextfield);
2171 } 2154 }
2172 2155
2173 /* make a copy, so that we can insert NULs */ 2156 // make a copy, so that we can insert NULs
2174 buts = vim_strsave(buttons); 2157 buts = vim_strsave(buttons);
2175 if (buts == NULL) 2158 if (buts == NULL)
2176 return -1; 2159 return -1;
2177 2160
2178 p = buts; 2161 p = buts;
2211 } 2194 }
2212 vim_free(buts); 2195 vim_free(buts);
2213 2196
2214 XtRealizeWidget(dialogshell); 2197 XtRealizeWidget(dialogshell);
2215 2198
2216 /* Setup for catching the close-window event, don't let it close Vim! */ 2199 // Setup for catching the close-window event, don't let it close Vim!
2217 dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False); 2200 dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False);
2218 XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1); 2201 XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1);
2219 XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL); 2202 XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL);
2220 2203
2221 XtVaGetValues(dialogshell, 2204 XtVaGetValues(dialogshell,
2234 x = 0; 2217 x = 0;
2235 if (y < 0) 2218 if (y < 0)
2236 y = 0; 2219 y = 0;
2237 XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL); 2220 XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL);
2238 2221
2239 /* Position the mouse pointer in the dialog, required for when focus 2222 // Position the mouse pointer in the dialog, required for when focus
2240 * follows mouse. */ 2223 // follows mouse.
2241 XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40); 2224 XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40);
2242 2225
2243 2226
2244 app = XtWidgetToApplicationContext(dialogshell); 2227 app = XtWidgetToApplicationContext(dialogshell);
2245 2228