comparison src/gui_motif.c @ 18788:e1f4e9d78a6a v8.1.2383

patch 8.1.2383: using old C style comments Commit: https://github.com/vim/vim/commit/734a867ffe198886da7365b618be67ab8ed9d9f6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 2 22:49:38 2019 +0100 patch 8.1.2383: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Dec 2019 23:00:04 +0100
parents ce04ebdf26b8
children 3ff714d765ba
comparison
equal deleted inserted replaced
18787:06ed2fe62dce 18788:e1f4e9d78a6a
47 #endif 47 #endif
48 #ifdef HAVE_XM_NOTEBOOK_H 48 #ifdef HAVE_XM_NOTEBOOK_H
49 # include <Xm/Notebook.h> 49 # include <Xm/Notebook.h>
50 #endif 50 #endif
51 51
52 #include "gui_xmebw.h" /* for our Enhanced Button Widget */ 52 #include "gui_xmebw.h" // for our Enhanced Button Widget
53 53
54 #if defined(FEAT_GUI_DIALOG) && defined(HAVE_XPM) 54 #if defined(FEAT_GUI_DIALOG) && defined(HAVE_XPM)
55 # include "../pixmaps/alert.xpm" 55 # include "../pixmaps/alert.xpm"
56 # include "../pixmaps/error.xpm" 56 # include "../pixmaps/error.xpm"
57 # include "../pixmaps/generic.xpm" 57 # include "../pixmaps/generic.xpm"
78 #ifdef FEAT_FOOTER 78 #ifdef FEAT_FOOTER
79 static Widget footer; 79 static Widget footer;
80 #endif 80 #endif
81 #ifdef FEAT_MENU 81 #ifdef FEAT_MENU
82 # if (XmVersion >= 1002) 82 # if (XmVersion >= 1002)
83 /* remember the last set value for the tearoff item */ 83 // remember the last set value for the tearoff item
84 static int tearoff_val = (int)XmTEAR_OFF_ENABLED; 84 static int tearoff_val = (int)XmTEAR_OFF_ENABLED;
85 # endif 85 # endif
86 static Widget menuBar; 86 static Widget menuBar;
87 #endif 87 #endif
88 88
176 tab_scroll_w = XtNameToWidget(tabLine, scroller_name); 176 tab_scroll_w = XtNameToWidget(tabLine, scroller_name);
177 if (tab_scroll_w != (Widget)0) { 177 if (tab_scroll_w != (Widget)0) {
178 XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth, 178 XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth,
179 &width, XmNheight, &height, NULL); 179 &width, XmNheight, &height, NULL);
180 if (pos_x >= 0) { 180 if (pos_x >= 0) {
181 /* Tab scroller (next) is visible */ 181 // Tab scroller (next) is visible
182 if ((event->x >= pos_x) && (event->x <= pos_x + width) && 182 if ((event->x >= pos_x) && (event->x <= pos_x + width) &&
183 (event->y >= pos_y) && (event->y <= pos_y + height)) { 183 (event->y >= pos_y) && (event->y <= pos_y + height)) {
184 /* Clicked on the scroller */ 184 // Clicked on the scroller
185 return TRUE; 185 return TRUE;
186 } 186 }
187 } 187 }
188 } 188 }
189 return FALSE; 189 return FALSE;
236 } 236 }
237 237
238 if (event->button != Button3) 238 if (event->button != Button3)
239 return; 239 return;
240 240
241 /* When ignoring events don't show the menu. */ 241 // When ignoring events don't show the menu.
242 if (hold_gui_events 242 if (hold_gui_events
243 # ifdef FEAT_CMDWIN 243 # ifdef FEAT_CMDWIN
244 || cmdwin_type != 0 244 || cmdwin_type != 0
245 # endif 245 # endif
246 ) 246 )
247 return; 247 return;
248 248
249 if (event->subwindow != None) 249 if (event->subwindow != None)
250 { 250 {
251 tab_w = XtWindowToWidget(XtDisplay(w), event->subwindow); 251 tab_w = XtWindowToWidget(XtDisplay(w), event->subwindow);
252 /* LINTED: avoid warning: dubious operation on enum */ 252 // LINTED: avoid warning: dubious operation on enum
253 if (tab_w != (Widget)0 && XmIsPushButton(tab_w)) 253 if (tab_w != (Widget)0 && XmIsPushButton(tab_w))
254 XtVaGetValues(tab_w, XmNpageNumber, &tab_idx, NULL); 254 XtVaGetValues(tab_w, XmNpageNumber, &tab_idx, NULL);
255 } 255 }
256 256
257 XtVaSetValues(tabLine_menu, XmNuserData, tab_idx, NULL); 257 XtVaSetValues(tabLine_menu, XmNuserData, tab_idx, NULL);
314 XtGCMask dynamic; 314 XtGCMask dynamic;
315 XFontStruct *fs; 315 XFontStruct *fs;
316 316
317 _XmFontListGetDefaultFont(lw->label.font, &fs); 317 _XmFontListGetDefaultFont(lw->label.font, &fs);
318 318
319 /* FIXME: we should be doing the whole drawing ourself here. */ 319 // FIXME: we should be doing the whole drawing ourself here.
320 insensitiveGC = lw->label.insensitive_GC; 320 insensitiveGC = lw->label.insensitive_GC;
321 321
322 mask = GCForeground | GCBackground | GCGraphicsExposures; 322 mask = GCForeground | GCBackground | GCGraphicsExposures;
323 dynamic = GCClipMask | GCClipXOrigin | GCClipYOrigin; 323 dynamic = GCClipMask | GCClipXOrigin | GCClipYOrigin;
324 values.graphics_exposures = False; 324 values.graphics_exposures = False;
405 */ 405 */
406 #if (XmVersion >= 1002) 406 #if (XmVersion >= 1002)
407 XmRepTypeInstallTearOffModelConverter(); 407 XmRepTypeInstallTearOffModelConverter();
408 #endif 408 #endif
409 409
410 /* Make sure the "Quit" menu entry of the window manager is ignored */ 410 // Make sure the "Quit" menu entry of the window manager is ignored
411 XtVaSetValues(vimShell, XmNdeleteResponse, XmDO_NOTHING, NULL); 411 XtVaSetValues(vimShell, XmNdeleteResponse, XmDO_NOTHING, NULL);
412 412
413 vimForm = XtVaCreateManagedWidget("vimForm", 413 vimForm = XtVaCreateManagedWidget("vimForm",
414 xmFormWidgetClass, vimShell, 414 xmFormWidgetClass, vimShell,
415 XmNborderWidth, 0, 415 XmNborderWidth, 0,
421 NULL); 421 NULL);
422 gui_motif_menu_colors(vimForm); 422 gui_motif_menu_colors(vimForm);
423 423
424 #ifdef FEAT_MENU 424 #ifdef FEAT_MENU
425 { 425 {
426 Arg al[7]; /* Make sure there is enough room for arguments! */ 426 Arg al[7]; // Make sure there is enough room for arguments!
427 int ac = 0; 427 int ac = 0;
428 428
429 # if (XmVersion >= 1002) 429 # if (XmVersion >= 1002)
430 XtSetArg(al[ac], XmNtearOffModel, tearoff_val); ac++; 430 XtSetArg(al[ac], XmNtearOffModel, tearoff_val); ac++;
431 # endif 431 # endif
432 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; 432 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
433 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; 433 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
434 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; 434 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
435 # ifndef FEAT_TOOLBAR 435 # ifndef FEAT_TOOLBAR
436 /* Always stick to right hand side. */ 436 // Always stick to right hand side.
437 XtSetArg(al[ac], XmNrightOffset, 0); ac++; 437 XtSetArg(al[ac], XmNrightOffset, 0); ac++;
438 # endif 438 # endif
439 XtSetArg(al[ac], XmNmarginHeight, 0); ac++; 439 XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
440 menuBar = XmCreateMenuBar(vimForm, "menuBar", al, ac); 440 menuBar = XmCreateMenuBar(vimForm, "menuBar", al, ac);
441 XtManageChild(menuBar); 441 XtManageChild(menuBar);
442 442
443 /* Remember the default colors, needed for ":hi clear". */ 443 // Remember the default colors, needed for ":hi clear".
444 XtVaGetValues(menuBar, 444 XtVaGetValues(menuBar,
445 XmNbackground, &gui.menu_def_bg_pixel, 445 XmNbackground, &gui.menu_def_bg_pixel,
446 XmNforeground, &gui.menu_def_fg_pixel, 446 XmNforeground, &gui.menu_def_fg_pixel,
447 NULL); 447 NULL);
448 gui_motif_menu_colors(menuBar); 448 gui_motif_menu_colors(menuBar);
481 gui_motif_menu_colors(toolBar); 481 gui_motif_menu_colors(toolBar);
482 482
483 #endif 483 #endif
484 484
485 #ifdef FEAT_GUI_TABLINE 485 #ifdef FEAT_GUI_TABLINE
486 /* Create the Vim GUI tabline */ 486 // Create the Vim GUI tabline
487 n = 0; 487 n = 0;
488 XtSetArg(args[n], XmNbindingType, XmNONE); n++; 488 XtSetArg(args[n], XmNbindingType, XmNONE); n++;
489 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; 489 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
490 XtSetArg(args[n], XmNbackPageSize, XmNONE); n++; 490 XtSetArg(args[n], XmNbackPageSize, XmNONE); n++;
491 XtSetArg(args[n], XmNbackPageNumber, 0); n++; 491 XtSetArg(args[n], XmNbackPageNumber, 0); n++;
601 /* 601 /*
602 * Install the callbacks. 602 * Install the callbacks.
603 */ 603 */
604 gui_x11_callbacks(textArea, vimForm); 604 gui_x11_callbacks(textArea, vimForm);
605 605
606 /* Pretend we don't have input focus, we will get an event if we do. */ 606 // Pretend we don't have input focus, we will get an event if we do.
607 gui.in_focus = FALSE; 607 gui.in_focus = FALSE;
608 } 608 }
609 609
610 /* 610 /*
611 * Called when the GUI is not going to start after all. 611 * Called when the GUI is not going to start after all.
625 int y UNUSED, 625 int y UNUSED,
626 int w UNUSED, 626 int w UNUSED,
627 int h UNUSED) 627 int h UNUSED)
628 { 628 {
629 #ifdef FEAT_TOOLBAR 629 #ifdef FEAT_TOOLBAR
630 /* Give keyboard focus to the textArea instead of the toolbar. */ 630 // Give keyboard focus to the textArea instead of the toolbar.
631 reset_focus(); 631 reset_focus();
632 #endif 632 #endif
633 } 633 }
634 634
635 void 635 void
657 unsigned int mask; 657 unsigned int mask;
658 unsigned int width, height, border_width, depth; 658 unsigned int width, height, border_width, depth;
659 int x, y, win_x, win_y, maxX, maxY; 659 int x, y, win_x, win_y, maxX, maxY;
660 Boolean mappedWhenManaged; 660 Boolean mappedWhenManaged;
661 661
662 /* Temporarily set value of XmNmappedWhenManaged 662 // Temporarily set value of XmNmappedWhenManaged
663 to stop the dialog from popping up right away */ 663 // to stop the dialog from popping up right away
664 XtVaGetValues(shell, XmNmappedWhenManaged, &mappedWhenManaged, NULL); 664 XtVaGetValues(shell, XmNmappedWhenManaged, &mappedWhenManaged, NULL);
665 XtVaSetValues(shell, XmNmappedWhenManaged, False, NULL); 665 XtVaSetValues(shell, XmNmappedWhenManaged, False, NULL);
666 666
667 XtManageChild(dialog_child); 667 XtManageChild(dialog_child);
668 668
669 /* Get the pointer position (x, y) */ 669 // Get the pointer position (x, y)
670 XQueryPointer(XtDisplay(shell), XtWindow(shell), &root, &child, 670 XQueryPointer(XtDisplay(shell), XtWindow(shell), &root, &child,
671 &x, &y, &win_x, &win_y, &mask); 671 &x, &y, &win_x, &win_y, &mask);
672 672
673 /* Translate the pointer position (x, y) into a position for the new 673 // Translate the pointer position (x, y) into a position for the new
674 window that will place the pointer at its center */ 674 // window that will place the pointer at its center
675 XGetGeometry(XtDisplay(shell), XtWindow(shell), &root, &win_x, &win_y, 675 XGetGeometry(XtDisplay(shell), XtWindow(shell), &root, &win_x, &win_y,
676 &width, &height, &border_width, &depth); 676 &width, &height, &border_width, &depth);
677 width += 2 * border_width; 677 width += 2 * border_width;
678 height += 2 * border_width; 678 height += 2 * border_width;
679 x -= width / 2; 679 x -= width / 2;
680 y -= height / 2; 680 y -= height / 2;
681 681
682 /* Ensure that the dialog remains on screen */ 682 // Ensure that the dialog remains on screen
683 maxX = XtScreen(shell)->width - width; 683 maxX = XtScreen(shell)->width - width;
684 maxY = XtScreen(shell)->height - height; 684 maxY = XtScreen(shell)->height - height;
685 if (x < 0) 685 if (x < 0)
686 x = 0; 686 x = 0;
687 if (x > maxX) 687 if (x > maxX)
689 if (y < 0) 689 if (y < 0)
690 y = 0; 690 y = 0;
691 if (y > maxY) 691 if (y > maxY)
692 y = maxY; 692 y = maxY;
693 693
694 /* Set desired window position in the DialogShell */ 694 // Set desired window position in the DialogShell
695 XtVaSetValues(shell, XmNx, x, XmNy, y, NULL); 695 XtVaSetValues(shell, XmNx, x, XmNy, y, NULL);
696 696
697 /* Map the widget */ 697 // Map the widget
698 XtMapWidget(shell); 698 XtMapWidget(shell);
699 699
700 /* Restore the value of XmNmappedWhenManaged */ 700 // Restore the value of XmNmappedWhenManaged
701 XtVaSetValues(shell, XmNmappedWhenManaged, mappedWhenManaged, NULL); 701 XtVaSetValues(shell, XmNmappedWhenManaged, mappedWhenManaged, NULL);
702 } 702 }
703 703
704 #if defined(FEAT_MENU) || defined(FEAT_GUI_DIALOG) || defined(PROTO) 704 #if defined(FEAT_MENU) || defined(FEAT_GUI_DIALOG) || defined(PROTO)
705 705
710 gui_motif_create_fontlist(XFontStruct *font) 710 gui_motif_create_fontlist(XFontStruct *font)
711 { 711 {
712 XmFontList font_list; 712 XmFontList font_list;
713 713
714 # if (XmVersion <= 1001) 714 # if (XmVersion <= 1001)
715 /* Motif 1.1 method */ 715 // Motif 1.1 method
716 font_list = XmFontListCreate(font, STRING_TAG); 716 font_list = XmFontListCreate(font, STRING_TAG);
717 # else 717 # else
718 /* Motif 1.2 method */ 718 // Motif 1.2 method
719 XmFontListEntry font_list_entry; 719 XmFontListEntry font_list_entry;
720 720
721 font_list_entry = XmFontListEntryCreate(STRING_TAG, XmFONT_IS_FONT, 721 font_list_entry = XmFontListEntryCreate(STRING_TAG, XmFONT_IS_FONT,
722 (XtPointer)font); 722 (XtPointer)font);
723 font_list = XmFontListAppendEntry(NULL, font_list_entry); 723 font_list = XmFontListAppendEntry(NULL, font_list_entry);
730 XmFontList 730 XmFontList
731 gui_motif_fontset2fontlist(XFontSet *fontset) 731 gui_motif_fontset2fontlist(XFontSet *fontset)
732 { 732 {
733 XmFontList font_list; 733 XmFontList font_list;
734 734
735 /* Motif 1.2 method */ 735 // Motif 1.2 method
736 XmFontListEntry font_list_entry; 736 XmFontListEntry font_list_entry;
737 737
738 font_list_entry = XmFontListEntryCreate(STRING_TAG, 738 font_list_entry = XmFontListEntryCreate(STRING_TAG,
739 XmFONT_IS_FONTSET, 739 XmFONT_IS_FONTSET,
740 (XtPointer)*fontset); 740 (XtPointer)*fontset);
768 { 768 {
769 XtManageChild(menuBar); 769 XtManageChild(menuBar);
770 #ifdef FEAT_TOOLBAR 770 #ifdef FEAT_TOOLBAR
771 if (XtIsManaged(XtParent(toolBar))) 771 if (XtIsManaged(XtParent(toolBar)))
772 { 772 {
773 /* toolBar is attached to top form */ 773 // toolBar is attached to top form
774 XtVaSetValues(XtParent(toolBar), 774 XtVaSetValues(XtParent(toolBar),
775 XmNtopAttachment, XmATTACH_WIDGET, 775 XmNtopAttachment, XmATTACH_WIDGET,
776 XmNtopWidget, menuBar, 776 XmNtopWidget, menuBar,
777 NULL); 777 NULL);
778 #ifdef FEAT_GUI_TABLINE 778 #ifdef FEAT_GUI_TABLINE
907 if (menu_is_popup(menu->name)) 907 if (menu_is_popup(menu->name))
908 { 908 {
909 Arg arg[2]; 909 Arg arg[2];
910 int n = 0; 910 int n = 0;
911 911
912 /* Only create the popup menu when it's actually used, otherwise there 912 // Only create the popup menu when it's actually used, otherwise there
913 * is a delay when using the right mouse button. */ 913 // is a delay when using the right mouse button.
914 # if (XmVersion <= 1002) 914 # if (XmVersion <= 1002)
915 if (mouse_model_popup()) 915 if (mouse_model_popup())
916 # endif 916 # endif
917 { 917 {
918 if (gui.menu_bg_pixel != INVALCOLOR) 918 if (gui.menu_bg_pixel != INVALCOLOR)
938 xmCascadeButtonWidgetClass, 938 xmCascadeButtonWidgetClass,
939 (parent == NULL) ? menuBar : parent->submenu_id, 939 (parent == NULL) ? menuBar : parent->submenu_id,
940 XmNlabelString, label, 940 XmNlabelString, label,
941 XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic, 941 XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic,
942 #if (XmVersion >= 1002) 942 #if (XmVersion >= 1002)
943 /* submenu: count the tearoff item (needed for LessTif) */ 943 // submenu: count the tearoff item (needed for LessTif)
944 XmNpositionIndex, idx + (parent != NULL 944 XmNpositionIndex, idx + (parent != NULL
945 && tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), 945 && tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0),
946 #endif 946 #endif
947 NULL); 947 NULL);
948 gui_motif_menu_colors(menu->id); 948 gui_motif_menu_colors(menu->id);
949 gui_motif_menu_fontlist(menu->id); 949 gui_motif_menu_fontlist(menu->id);
950 XmStringFree(label); 950 XmStringFree(label);
951 951
952 if (menu->id == (Widget)0) /* failed */ 952 if (menu->id == (Widget)0) // failed
953 return; 953 return;
954 954
955 /* add accelerator text */ 955 // add accelerator text
956 gui_motif_add_actext(menu); 956 gui_motif_add_actext(menu);
957 957
958 shell = XtVaCreateWidget("subMenuShell", 958 shell = XtVaCreateWidget("subMenuShell",
959 xmMenuShellWidgetClass, menu->id, 959 xmMenuShellWidgetClass, menu->id,
960 XmNwidth, 1, 960 XmNwidth, 1,
965 xmRowColumnWidgetClass, shell, 965 xmRowColumnWidgetClass, shell,
966 XmNrowColumnType, XmMENU_PULLDOWN, 966 XmNrowColumnType, XmMENU_PULLDOWN,
967 NULL); 967 NULL);
968 gui_motif_menu_colors(menu->submenu_id); 968 gui_motif_menu_colors(menu->submenu_id);
969 969
970 if (menu->submenu_id == (Widget)0) /* failed */ 970 if (menu->submenu_id == (Widget)0) // failed
971 return; 971 return;
972 972
973 #if (XmVersion >= 1002) 973 #if (XmVersion >= 1002)
974 /* Set the colors for the tear off widget */ 974 // Set the colors for the tear off widget
975 toggle_tearoff(menu->submenu_id); 975 toggle_tearoff(menu->submenu_id);
976 #endif 976 #endif
977 977
978 XtVaSetValues(menu->id, 978 XtVaSetValues(menu->id,
979 XmNsubMenuId, menu->submenu_id, 979 XmNsubMenuId, menu->submenu_id,
1003 static void 1003 static void
1004 gui_motif_add_actext(vimmenu_T *menu) 1004 gui_motif_add_actext(vimmenu_T *menu)
1005 { 1005 {
1006 XmString label; 1006 XmString label;
1007 1007
1008 /* Add accelerator text, if there is one */ 1008 // Add accelerator text, if there is one
1009 if (menu->actext != NULL && menu->id != (Widget)0) 1009 if (menu->actext != NULL && menu->id != (Widget)0)
1010 { 1010 {
1011 label = XmStringCreate((char *)menu->actext, STRING_TAG); 1011 label = XmStringCreate((char *)menu->actext, STRING_TAG);
1012 if (label == NULL) 1012 if (label == NULL)
1013 return; 1013 return;
1075 * We need to check all the items for their position and height, for the case 1075 * We need to check all the items for their position and height, for the case
1076 * there are several rows, and/or some characters extend higher or lower. 1076 * there are several rows, and/or some characters extend higher or lower.
1077 */ 1077 */
1078 void 1078 void
1079 gui_mch_compute_menu_height( 1079 gui_mch_compute_menu_height(
1080 Widget id) /* can be NULL when deleting menu */ 1080 Widget id) // can be NULL when deleting menu
1081 { 1081 {
1082 Dimension y, maxy; 1082 Dimension y, maxy;
1083 Dimension margin, shadow; 1083 Dimension margin, shadow;
1084 vimmenu_T *mp; 1084 vimmenu_T *mp;
1085 static Dimension height = 21; /* normal height of a menu item */ 1085 static Dimension height = 21; // normal height of a menu item
1086 1086
1087 /* 1087 /*
1088 * Get the height of the new item, before managing it, because it will 1088 * Get the height of the new item, before managing it, because it will
1089 * still reflect the font size. After managing it depends on the menu 1089 * still reflect the font size. After managing it depends on the menu
1090 * height, which is what we just wanted to get!. 1090 * height, which is what we just wanted to get!.
1091 */ 1091 */
1092 if (id != (Widget)0) 1092 if (id != (Widget)0)
1093 XtVaGetValues(id, XmNheight, &height, NULL); 1093 XtVaGetValues(id, XmNheight, &height, NULL);
1094 1094
1095 /* Find any menu Widget, to be able to call XtManageChild() */ 1095 // Find any menu Widget, to be able to call XtManageChild()
1096 else 1096 else
1097 for (mp = root_menu; mp != NULL; mp = mp->next) 1097 for (mp = root_menu; mp != NULL; mp = mp->next)
1098 if (mp->id != (Widget)0 && menu_is_menubar(mp->name)) 1098 if (mp->id != (Widget)0 && menu_is_menubar(mp->name))
1099 { 1099 {
1100 id = mp->id; 1100 id = mp->id;
1137 * margin = margin around the menu buttons; Must be added. 1137 * margin = margin around the menu buttons; Must be added.
1138 * Add 4 for the underlining of shortcut keys. 1138 * Add 4 for the underlining of shortcut keys.
1139 */ 1139 */
1140 gui.menu_height = maxy + height - 2 * shadow + 2 * margin + 4; 1140 gui.menu_height = maxy + height - 2 * shadow + 2 * margin + 4;
1141 1141
1142 /* Somehow the menu bar doesn't resize automatically. Set it here, 1142 // Somehow the menu bar doesn't resize automatically. Set it here,
1143 * even though this is a catch 22. Don't do this when starting up, 1143 // even though this is a catch 22. Don't do this when starting up,
1144 * somehow the menu gets very high then. */ 1144 // somehow the menu gets very high then.
1145 if (gui.shell_created) 1145 if (gui.shell_created)
1146 XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL); 1146 XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL);
1147 } 1147 }
1148 1148
1149 #ifdef FEAT_TOOLBAR 1149 #ifdef FEAT_TOOLBAR
1166 Pixmap mask; 1166 Pixmap mask;
1167 Pixmap map; 1167 Pixmap map;
1168 1168
1169 attrs.valuemask = 0; 1169 attrs.valuemask = 0;
1170 1170
1171 /* Create the "sensitive" pixmap */ 1171 // Create the "sensitive" pixmap
1172 status = XpmReadFileToPixmap(gui.dpy, 1172 status = XpmReadFileToPixmap(gui.dpy,
1173 RootWindow(gui.dpy, DefaultScreen(gui.dpy)), 1173 RootWindow(gui.dpy, DefaultScreen(gui.dpy)),
1174 (char *)path, &map, &mask, &attrs); 1174 (char *)path, &map, &mask, &attrs);
1175 XpmFreeAttributes(&attrs); 1175 XpmFreeAttributes(&attrs);
1176 1176
1187 * Return a blank pixmap if it fails. 1187 * Return a blank pixmap if it fails.
1188 */ 1188 */
1189 static char ** 1189 static char **
1190 get_toolbar_pixmap(vimmenu_T *menu, char **fname) 1190 get_toolbar_pixmap(vimmenu_T *menu, char **fname)
1191 { 1191 {
1192 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ 1192 char_u buf[MAXPATHL]; // buffer storing expanded pathname
1193 char **xpm = NULL; /* xpm array */ 1193 char **xpm = NULL; // xpm array
1194 int res; 1194 int res;
1195 1195
1196 *fname = NULL; 1196 *fname = NULL;
1197 buf[0] = NUL; /* start with NULL path */ 1197 buf[0] = NUL; // start with NULL path
1198 1198
1199 if (menu->iconfile != NULL) 1199 if (menu->iconfile != NULL)
1200 { 1200 {
1201 /* Use the "icon=" argument. */ 1201 // Use the "icon=" argument.
1202 gui_find_iconfile(menu->iconfile, buf, "xpm"); 1202 gui_find_iconfile(menu->iconfile, buf, "xpm");
1203 res = check_xpm(buf); 1203 res = check_xpm(buf);
1204 1204
1205 /* If it failed, try using the menu name. */ 1205 // If it failed, try using the menu name.
1206 if (res == FAIL && gui_find_bitmap(menu->name, buf, "xpm") == OK) 1206 if (res == FAIL && gui_find_bitmap(menu->name, buf, "xpm") == OK)
1207 res = check_xpm(buf); 1207 res = check_xpm(buf);
1208 if (res == OK) 1208 if (res == OK)
1209 { 1209 {
1210 *fname = (char *)vim_strsave(buf); 1210 *fname = (char *)vim_strsave(buf);
1243 XtSetArg(args[n], XmNpixmapData, menu->xpm); n++; 1243 XtSetArg(args[n], XmNpixmapData, menu->xpm); n++;
1244 XtSetArg(args[n], XmNlabelLocation, XmBOTTOM); n++; 1244 XtSetArg(args[n], XmNlabelLocation, XmBOTTOM); n++;
1245 } 1245 }
1246 return n; 1246 return n;
1247 } 1247 }
1248 #endif /* FEAT_TOOLBAR */ 1248 #endif // FEAT_TOOLBAR
1249 1249
1250 void 1250 void
1251 gui_mch_add_menu_item(vimmenu_T *menu, int idx) 1251 gui_mch_add_menu_item(vimmenu_T *menu, int idx)
1252 { 1252 {
1253 XmString label; 1253 XmString label;
1256 # ifdef EBCDIC 1256 # ifdef EBCDIC
1257 menu->mnemonic = 0; 1257 menu->mnemonic = 0;
1258 # endif 1258 # endif
1259 1259
1260 # if (XmVersion <= 1002) 1260 # if (XmVersion <= 1002)
1261 /* Don't add Popup menu items when the popup menu isn't used. */ 1261 // Don't add Popup menu items when the popup menu isn't used.
1262 if (menu_is_child_of_popup(menu) && !mouse_model_popup()) 1262 if (menu_is_child_of_popup(menu) && !mouse_model_popup())
1263 return; 1263 return;
1264 # endif 1264 # endif
1265 1265
1266 # ifdef FEAT_TOOLBAR 1266 # ifdef FEAT_TOOLBAR
1267 if (menu_is_toolbar(parent->name)) 1267 if (menu_is_toolbar(parent->name))
1268 { 1268 {
1269 WidgetClass type; 1269 WidgetClass type;
1270 XmString xms = NULL; /* fallback label if pixmap not found */ 1270 XmString xms = NULL; // fallback label if pixmap not found
1271 int n; 1271 int n;
1272 Arg args[18]; 1272 Arg args[18];
1273 1273
1274 n = 0; 1274 n = 0;
1275 if (menu_is_separator(menu->name)) 1275 if (menu_is_separator(menu->name))
1293 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; 1293 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
1294 XtSetArg(args[n], XmNseparatorType, XmSHADOW_ETCHED_IN); n++; 1294 XtSetArg(args[n], XmNseparatorType, XmSHADOW_ETCHED_IN); n++;
1295 } 1295 }
1296 else 1296 else
1297 { 1297 {
1298 /* Without shadows one can't sense whatever the button has been 1298 // Without shadows one can't sense whatever the button has been
1299 * pressed or not! However we want to save a bit of space... 1299 // pressed or not! However we want to save a bit of space...
1300 * Need the highlightThickness to see the focus. 1300 // Need the highlightThickness to see the focus.
1301 */
1302 XtSetArg(args[n], XmNhighlightThickness, 1); n++; 1301 XtSetArg(args[n], XmNhighlightThickness, 1); n++;
1303 XtSetArg(args[n], XmNhighlightOnEnter, True); n++; 1302 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
1304 XtSetArg(args[n], XmNmarginWidth, 0); n++; 1303 XtSetArg(args[n], XmNmarginWidth, 0); n++;
1305 XtSetArg(args[n], XmNmarginHeight, 0); n++; 1304 XtSetArg(args[n], XmNmarginHeight, 0); n++;
1306 XtSetArg(args[n], XmNtraversalOn, False); n++; 1305 XtSetArg(args[n], XmNtraversalOn, False); n++;
1307 /* Set the label here, so that we can switch between icons/text 1306 // Set the label here, so that we can switch between icons/text
1308 * by changing the XmNlabelType resource. */ 1307 // by changing the XmNlabelType resource.
1309 xms = XmStringCreate((char *)menu->dname, STRING_TAG); 1308 xms = XmStringCreate((char *)menu->dname, STRING_TAG);
1310 XtSetArg(args[n], XmNlabelString, xms); n++; 1309 XtSetArg(args[n], XmNlabelString, xms); n++;
1311 1310
1312 n = add_pixmap_args(menu, args, n); 1311 n = add_pixmap_args(menu, args, n);
1313 1312
1340 gui_mch_menu_set_tip(menu); 1339 gui_mch_menu_set_tip(menu);
1341 # endif 1340 # endif
1342 1341
1343 menu->parent = parent; 1342 menu->parent = parent;
1344 menu->submenu_id = NULL; 1343 menu->submenu_id = NULL;
1345 /* When adding first item to toolbar it might have to be enabled .*/ 1344 // When adding first item to toolbar it might have to be enabled .
1346 if (!XtIsManaged(XtParent(toolBar)) 1345 if (!XtIsManaged(XtParent(toolBar))
1347 && vim_strchr(p_go, GO_TOOLBAR) != NULL) 1346 && vim_strchr(p_go, GO_TOOLBAR) != NULL)
1348 gui_mch_show_toolbar(TRUE); 1347 gui_mch_show_toolbar(TRUE);
1349 gui.toolbar_height = gui_mch_compute_toolbar_height(); 1348 gui.toolbar_height = gui_mch_compute_toolbar_height();
1350 return; 1349 return;
1351 } /* toolbar menu item */ 1350 } // toolbar menu item
1352 # endif 1351 # endif
1353 1352
1354 /* No parent, must be a non-menubar menu */ 1353 // No parent, must be a non-menubar menu
1355 if (parent->submenu_id == (Widget)0) 1354 if (parent->submenu_id == (Widget)0)
1356 return; 1355 return;
1357 1356
1358 menu->submenu_id = (Widget)0; 1357 menu->submenu_id = (Widget)0;
1359 1358
1360 /* Add menu separator */ 1359 // Add menu separator
1361 if (menu_is_separator(menu->name)) 1360 if (menu_is_separator(menu->name))
1362 { 1361 {
1363 menu->id = XtVaCreateWidget("subMenu", 1362 menu->id = XtVaCreateWidget("subMenu",
1364 xmSeparatorGadgetClass, parent->submenu_id, 1363 xmSeparatorGadgetClass, parent->submenu_id,
1365 #if (XmVersion >= 1002) 1364 #if (XmVersion >= 1002)
1366 /* count the tearoff item (needed for LessTif) */ 1365 // count the tearoff item (needed for LessTif)
1367 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED 1366 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
1368 ? 1 : 0), 1367 ? 1 : 0),
1369 #endif 1368 #endif
1370 NULL); 1369 NULL);
1371 gui_motif_menu_colors(menu->id); 1370 gui_motif_menu_colors(menu->id);
1378 menu->id = XtVaCreateWidget("subMenu", 1377 menu->id = XtVaCreateWidget("subMenu",
1379 xmPushButtonWidgetClass, parent->submenu_id, 1378 xmPushButtonWidgetClass, parent->submenu_id,
1380 XmNlabelString, label, 1379 XmNlabelString, label,
1381 XmNmnemonic, menu->mnemonic, 1380 XmNmnemonic, menu->mnemonic,
1382 #if (XmVersion >= 1002) 1381 #if (XmVersion >= 1002)
1383 /* count the tearoff item (needed for LessTif) */ 1382 // count the tearoff item (needed for LessTif)
1384 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED 1383 XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
1385 ? 1 : 0), 1384 ? 1 : 0),
1386 #endif 1385 #endif
1387 NULL); 1386 NULL);
1388 gui_motif_menu_colors(menu->id); 1387 gui_motif_menu_colors(menu->id);
1391 1390
1392 if (menu->id != (Widget)0) 1391 if (menu->id != (Widget)0)
1393 { 1392 {
1394 XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb, 1393 XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb,
1395 (XtPointer)menu); 1394 (XtPointer)menu);
1396 /* add accelerator text */ 1395 // add accelerator text
1397 gui_motif_add_actext(menu); 1396 gui_motif_add_actext(menu);
1398 } 1397 }
1399 } 1398 }
1400 1399
1401 #if (XmVersion <= 1002) || defined(PROTO) 1400 #if (XmVersion <= 1002) || defined(PROTO)
1408 void 1407 void
1409 gui_motif_update_mousemodel(vimmenu_T *menu) 1408 gui_motif_update_mousemodel(vimmenu_T *menu)
1410 { 1409 {
1411 int idx = 0; 1410 int idx = 0;
1412 1411
1413 /* When GUI hasn't started the menus have not been created. */ 1412 // When GUI hasn't started the menus have not been created.
1414 if (!gui.in_use) 1413 if (!gui.in_use)
1415 return; 1414 return;
1416 1415
1417 while (menu) 1416 while (menu)
1418 { 1417 {
1420 { 1419 {
1421 if (menu_is_popup(menu->name)) 1420 if (menu_is_popup(menu->name))
1422 { 1421 {
1423 if (mouse_model_popup()) 1422 if (mouse_model_popup())
1424 { 1423 {
1425 /* Popup menu will be used. Create the popup menus. */ 1424 // Popup menu will be used. Create the popup menus.
1426 gui_mch_add_menu(menu, idx); 1425 gui_mch_add_menu(menu, idx);
1427 gui_motif_update_mousemodel(menu->children); 1426 gui_motif_update_mousemodel(menu->children);
1428 } 1427 }
1429 else 1428 else
1430 { 1429 {
1431 /* Popup menu will not be used. Destroy the popup menus. */ 1430 // Popup menu will not be used. Destroy the popup menus.
1432 gui_motif_update_mousemodel(menu->children); 1431 gui_motif_update_mousemodel(menu->children);
1433 gui_mch_destroy_menu(menu); 1432 gui_mch_destroy_menu(menu);
1434 } 1433 }
1435 } 1434 }
1436 } 1435 }
1518 #endif 1517 #endif
1519 1518
1520 static void 1519 static void
1521 submenu_change( 1520 submenu_change(
1522 vimmenu_T *menu, 1521 vimmenu_T *menu,
1523 int colors) /* TRUE for colors, FALSE for font */ 1522 int colors) // TRUE for colors, FALSE for font
1524 { 1523 {
1525 vimmenu_T *mp; 1524 vimmenu_T *mp;
1526 1525
1527 for (mp = menu; mp != NULL; mp = mp->next) 1526 for (mp = menu; mp != NULL; mp = mp->next)
1528 { 1527 {
1530 { 1529 {
1531 if (colors) 1530 if (colors)
1532 { 1531 {
1533 gui_motif_menu_colors(mp->id); 1532 gui_motif_menu_colors(mp->id);
1534 #ifdef FEAT_TOOLBAR 1533 #ifdef FEAT_TOOLBAR
1535 /* For a toolbar item: Free the pixmap and allocate a new one, 1534 // For a toolbar item: Free the pixmap and allocate a new one,
1536 * so that the background color is right. */ 1535 // so that the background color is right.
1537 if (mp->xpm != NULL) 1536 if (mp->xpm != NULL)
1538 { 1537 {
1539 int n = 0; 1538 int n = 0;
1540 Arg args[18]; 1539 Arg args[18];
1541 1540
1542 n = add_pixmap_args(mp, args, n); 1541 n = add_pixmap_args(mp, args, n);
1543 XtSetValues(mp->id, args, n); 1542 XtSetValues(mp->id, args, n);
1544 } 1543 }
1545 # ifdef FEAT_BEVAL_GUI 1544 # ifdef FEAT_BEVAL_GUI
1546 /* If we have a tooltip, then we need to change its font */ 1545 // If we have a tooltip, then we need to change its font
1547 if (mp->tip != NULL) 1546 if (mp->tip != NULL)
1548 { 1547 {
1549 Arg args[2]; 1548 Arg args[2];
1550 1549
1551 args[0].name = XmNbackground; 1550 args[0].name = XmNbackground;
1559 } 1558 }
1560 else 1559 else
1561 { 1560 {
1562 gui_motif_menu_fontlist(mp->id); 1561 gui_motif_menu_fontlist(mp->id);
1563 #ifdef FEAT_BEVAL_GUI 1562 #ifdef FEAT_BEVAL_GUI
1564 /* If we have a tooltip, then we need to change its font */ 1563 // If we have a tooltip, then we need to change its font
1565 if (mp->tip != NULL) 1564 if (mp->tip != NULL)
1566 { 1565 {
1567 Arg args[1]; 1566 Arg args[1];
1568 1567
1569 args[0].name = XmNfontList; 1568 args[0].name = XmNfontList;
1576 } 1575 }
1577 1576
1578 if (mp->children != NULL) 1577 if (mp->children != NULL)
1579 { 1578 {
1580 #if (XmVersion >= 1002) 1579 #if (XmVersion >= 1002)
1581 /* Set the colors/font for the tear off widget */ 1580 // Set the colors/font for the tear off widget
1582 if (mp->submenu_id != (Widget)0) 1581 if (mp->submenu_id != (Widget)0)
1583 { 1582 {
1584 if (colors) 1583 if (colors)
1585 gui_motif_menu_colors(mp->submenu_id); 1584 gui_motif_menu_colors(mp->submenu_id);
1586 else 1585 else
1587 gui_motif_menu_fontlist(mp->submenu_id); 1586 gui_motif_menu_fontlist(mp->submenu_id);
1588 toggle_tearoff(mp->submenu_id); 1587 toggle_tearoff(mp->submenu_id);
1589 } 1588 }
1590 #endif 1589 #endif
1591 /* Set the colors for the children */ 1590 // Set the colors for the children
1592 submenu_change(mp->children, colors); 1591 submenu_change(mp->children, colors);
1593 } 1592 }
1594 } 1593 }
1595 } 1594 }
1596 1595
1598 * Destroy the machine specific menu widget. 1597 * Destroy the machine specific menu widget.
1599 */ 1598 */
1600 void 1599 void
1601 gui_mch_destroy_menu(vimmenu_T *menu) 1600 gui_mch_destroy_menu(vimmenu_T *menu)
1602 { 1601 {
1603 /* Please be sure to destroy the parent widget first (i.e. menu->id). 1602 // Please be sure to destroy the parent widget first (i.e. menu->id).
1604 * On the other hand, problems have been reported that the submenu must be 1603 // On the other hand, problems have been reported that the submenu must be
1605 * deleted first... 1604 // deleted first...
1606 * 1605 //
1607 * This code should be basically identical to that in the file gui_athena.c 1606 // This code should be basically identical to that in the file gui_athena.c
1608 * because they are both Xt based. 1607 // because they are both Xt based.
1609 */
1610 if (menu->submenu_id != (Widget)0) 1608 if (menu->submenu_id != (Widget)0)
1611 { 1609 {
1612 XtDestroyWidget(menu->submenu_id); 1610 XtDestroyWidget(menu->submenu_id);
1613 menu->submenu_id = (Widget)0; 1611 menu->submenu_id = (Widget)0;
1614 } 1612 }
1619 1617
1620 parent = XtParent(menu->id); 1618 parent = XtParent(menu->id);
1621 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) 1619 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
1622 if (parent == toolBar && menu->tip != NULL) 1620 if (parent == toolBar && menu->tip != NULL)
1623 { 1621 {
1624 /* We try to destroy this before the actual menu, because there are 1622 // We try to destroy this before the actual menu, because there are
1625 * callbacks, etc. that will be unregistered during the tooltip 1623 // callbacks, etc. that will be unregistered during the tooltip
1626 * destruction. 1624 // destruction.
1627 * 1625 //
1628 * If you call "gui_mch_destroy_beval_area()" after destroying 1626 // If you call "gui_mch_destroy_beval_area()" after destroying
1629 * menu->id, then the tooltip's window will have already been 1627 // menu->id, then the tooltip's window will have already been
1630 * deallocated by Xt, and unknown behaviour will ensue (probably 1628 // deallocated by Xt, and unknown behaviour will ensue (probably
1631 * a core dump). 1629 // a core dump).
1632 */
1633 gui_mch_destroy_beval_area(menu->tip); 1630 gui_mch_destroy_beval_area(menu->tip);
1634 menu->tip = NULL; 1631 menu->tip = NULL;
1635 } 1632 }
1636 #endif 1633 #endif
1637 XtDestroyWidget(menu->id); 1634 XtDestroyWidget(menu->id);
1641 #ifdef FEAT_TOOLBAR 1638 #ifdef FEAT_TOOLBAR
1642 else if (parent == toolBar) 1639 else if (parent == toolBar)
1643 { 1640 {
1644 Cardinal num_children; 1641 Cardinal num_children;
1645 1642
1646 /* When removing last toolbar item, don't display the toolbar. */ 1643 // When removing last toolbar item, don't display the toolbar.
1647 XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL); 1644 XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL);
1648 if (num_children == 0) 1645 if (num_children == 0)
1649 gui_mch_show_toolbar(FALSE); 1646 gui_mch_show_toolbar(FALSE);
1650 else 1647 else
1651 gui.toolbar_height = gui_mch_compute_toolbar_height(); 1648 gui.toolbar_height = gui_mch_compute_toolbar_height();
1661 XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event()); 1658 XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event());
1662 XtManageChild(menu->submenu_id); 1659 XtManageChild(menu->submenu_id);
1663 #endif 1660 #endif
1664 } 1661 }
1665 1662
1666 #endif /* FEAT_MENU */ 1663 #endif // FEAT_MENU
1667 1664
1668 /* 1665 /*
1669 * Set the menu and scrollbar colors to their default values. 1666 * Set the menu and scrollbar colors to their default values.
1670 */ 1667 */
1671 void 1668 void
1672 gui_mch_def_colors(void) 1669 gui_mch_def_colors(void)
1673 { 1670 {
1674 if (gui.in_use) 1671 if (gui.in_use)
1675 { 1672 {
1676 /* Use the values saved when starting up. These should come from the 1673 // Use the values saved when starting up. These should come from the
1677 * window manager or a resources file. */ 1674 // window manager or a resources file.
1678 gui.menu_fg_pixel = gui.menu_def_fg_pixel; 1675 gui.menu_fg_pixel = gui.menu_def_fg_pixel;
1679 gui.menu_bg_pixel = gui.menu_def_bg_pixel; 1676 gui.menu_bg_pixel = gui.menu_def_bg_pixel;
1680 gui.scroll_fg_pixel = gui.scroll_def_fg_pixel; 1677 gui.scroll_fg_pixel = gui.scroll_def_fg_pixel;
1681 gui.scroll_bg_pixel = gui.scroll_def_bg_pixel; 1678 gui.scroll_bg_pixel = gui.scroll_def_bg_pixel;
1682 #ifdef FEAT_BEVAL_GUI 1679 #ifdef FEAT_BEVAL_GUI
1703 if (sb->id != (Widget)0) 1700 if (sb->id != (Widget)0)
1704 XtVaSetValues(sb->id, 1701 XtVaSetValues(sb->id,
1705 XmNvalue, val, 1702 XmNvalue, val,
1706 XmNsliderSize, size, 1703 XmNsliderSize, size,
1707 XmNpageIncrement, (size > 2 ? size - 2 : 1), 1704 XmNpageIncrement, (size > 2 ? size - 2 : 1),
1708 XmNmaximum, max + 1, /* Motif has max one past the end */ 1705 XmNmaximum, max + 1, // Motif has max one past the end
1709 NULL); 1706 NULL);
1710 } 1707 }
1711 1708
1712 void 1709 void
1713 gui_mch_set_scrollbar_pos( 1710 gui_mch_set_scrollbar_pos(
1773 } 1770 }
1774 else 1771 else
1775 { 1772 {
1776 if (!gui.which_scrollbars[sb->type]) 1773 if (!gui.which_scrollbars[sb->type])
1777 { 1774 {
1778 /* The scrollbars of this type are all disabled, adjust the 1775 // The scrollbars of this type are all disabled, adjust the
1779 * textArea attachment offset. */ 1776 // textArea attachment offset.
1780 switch (sb->type) 1777 switch (sb->type)
1781 { 1778 {
1782 case SBAR_LEFT: 1779 case SBAR_LEFT:
1783 XtSetArg(args[n], XmNleftOffset, 0); n++; 1780 XtSetArg(args[n], XmNleftOffset, 0); n++;
1784 break; 1781 break;
1799 } 1796 }
1800 1797
1801 void 1798 void
1802 gui_mch_create_scrollbar( 1799 gui_mch_create_scrollbar(
1803 scrollbar_T *sb, 1800 scrollbar_T *sb,
1804 int orient) /* SBAR_VERT or SBAR_HORIZ */ 1801 int orient) // SBAR_VERT or SBAR_HORIZ
1805 { 1802 {
1806 Arg args[16]; 1803 Arg args[16];
1807 int n; 1804 int n;
1808 1805
1809 n = 0; 1806 n = 0;
1833 } 1830 }
1834 1831
1835 sb->id = XtCreateWidget("scrollBar", 1832 sb->id = XtCreateWidget("scrollBar",
1836 xmScrollBarWidgetClass, textAreaForm, args, n); 1833 xmScrollBarWidgetClass, textAreaForm, args, n);
1837 1834
1838 /* Remember the default colors, needed for ":hi clear". */ 1835 // Remember the default colors, needed for ":hi clear".
1839 if (gui.scroll_def_bg_pixel == (guicolor_T)0 1836 if (gui.scroll_def_bg_pixel == (guicolor_T)0
1840 && gui.scroll_def_fg_pixel == (guicolor_T)0) 1837 && gui.scroll_def_fg_pixel == (guicolor_T)0)
1841 XtVaGetValues(sb->id, 1838 XtVaGetValues(sb->id,
1842 XmNbackground, &gui.scroll_def_bg_pixel, 1839 XmNbackground, &gui.scroll_def_bg_pixel,
1843 XmNforeground, &gui.scroll_def_fg_pixel, 1840 XmNforeground, &gui.scroll_def_fg_pixel,
1885 XmNbackground, gui.scroll_fg_pixel, 1882 XmNbackground, gui.scroll_fg_pixel,
1886 #endif 1883 #endif
1887 NULL); 1884 NULL);
1888 } 1885 }
1889 1886
1890 /* This is needed for the rectangle below the vertical scrollbars. */ 1887 // This is needed for the rectangle below the vertical scrollbars.
1891 if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0) 1888 if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0)
1892 gui_motif_scroll_colors(textAreaForm); 1889 gui_motif_scroll_colors(textAreaForm);
1893 } 1890 }
1894 1891
1895 /* 1892 /*
2080 { 2077 {
2081 if (XtIsManaged(id)) 2078 if (XtIsManaged(id))
2082 { 2079 {
2083 XtUnmanageChild(id); 2080 XtUnmanageChild(id);
2084 XtVaSetValues(id, XmNfontList, fl, NULL); 2081 XtVaSetValues(id, XmNfontList, fl, NULL);
2085 /* We should force the widget to recalculate its 2082 // We should force the widget to recalculate its
2086 * geometry now. */ 2083 // geometry now.
2087 XtManageChild(id); 2084 XtManageChild(id);
2088 } 2085 }
2089 else 2086 else
2090 XtVaSetValues(id, XmNfontList, fl, NULL); 2087 XtVaSetValues(id, XmNfontList, fl, NULL);
2091 XmFontListFree(fl); 2088 XmFontListFree(fl);
2099 { 2096 {
2100 if (XtIsManaged(id)) 2097 if (XtIsManaged(id))
2101 { 2098 {
2102 XtUnmanageChild(id); 2099 XtUnmanageChild(id);
2103 XtVaSetValues(id, XmNfontList, fl, NULL); 2100 XtVaSetValues(id, XmNfontList, fl, NULL);
2104 /* We should force the widget to recalculate its 2101 // We should force the widget to recalculate its
2105 * geometry now. */ 2102 // geometry now.
2106 XtManageChild(id); 2103 XtManageChild(id);
2107 } 2104 }
2108 else 2105 else
2109 XtVaSetValues(id, XmNfontList, fl, NULL); 2106 XtVaSetValues(id, XmNfontList, fl, NULL);
2110 XmFontListFree(fl); 2107 XmFontListFree(fl);
2123 #include <Xm/FileSB.h> 2120 #include <Xm/FileSB.h>
2124 #include <Xm/XmStrDefs.h> 2121 #include <Xm/XmStrDefs.h>
2125 2122
2126 typedef struct dialog_callback_arg 2123 typedef struct dialog_callback_arg
2127 { 2124 {
2128 char * args; /* not used right now */ 2125 char * args; // not used right now
2129 int id; 2126 int id;
2130 } dcbarg_T; 2127 } dcbarg_T;
2131 2128
2132 static Widget dialog_wgt; 2129 static Widget dialog_wgt;
2133 static char *browse_fname = NULL; 2130 static char *browse_fname = NULL;
2134 static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET; 2131 static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
2135 /* used to set up XmStrings */ 2132 // used to set up XmStrings
2136 2133
2137 static void DialogCancelCB(Widget, XtPointer, XtPointer); 2134 static void DialogCancelCB(Widget, XtPointer, XtPointer);
2138 static void DialogAcceptCB(Widget, XtPointer, XtPointer); 2135 static void DialogAcceptCB(Widget, XtPointer, XtPointer);
2139 2136
2140 /* 2137 /*
2206 * Put up a file requester. 2203 * Put up a file requester.
2207 * Returns the selected name in allocated memory, or NULL for Cancel. 2204 * Returns the selected name in allocated memory, or NULL for Cancel.
2208 */ 2205 */
2209 char_u * 2206 char_u *
2210 gui_mch_browse( 2207 gui_mch_browse(
2211 int saving UNUSED, /* select file to write */ 2208 int saving UNUSED, // select file to write
2212 char_u *title, /* title for the window */ 2209 char_u *title, // title for the window
2213 char_u *dflt, /* default name */ 2210 char_u *dflt, // default name
2214 char_u *ext UNUSED, /* not used (extension added) */ 2211 char_u *ext UNUSED, // not used (extension added)
2215 char_u *initdir, /* initial directory, NULL for current dir */ 2212 char_u *initdir, // initial directory, NULL for current dir
2216 char_u *filter) /* file name filter */ 2213 char_u *filter) // file name filter
2217 { 2214 {
2218 char_u dirbuf[MAXPATHL]; 2215 char_u dirbuf[MAXPATHL];
2219 char_u dfltbuf[MAXPATHL]; 2216 char_u dfltbuf[MAXPATHL];
2220 char_u *pattern; 2217 char_u *pattern;
2221 char_u *tofree = NULL; 2218 char_u *tofree = NULL;
2222 2219
2223 /* There a difference between the resource name and value, Therefore, we 2220 // There a difference between the resource name and value, Therefore, we
2224 * avoid to (ab-)use the (maybe internationalized!) dialog title as a 2221 // avoid to (ab-)use the (maybe internationalized!) dialog title as a
2225 * dialog name. 2222 // dialog name.
2226 */
2227 2223
2228 dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0); 2224 dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0);
2229 2225
2230 if (initdir == NULL || *initdir == NUL) 2226 if (initdir == NULL || *initdir == NUL)
2231 { 2227 {
2235 2231
2236 if (dflt == NULL) 2232 if (dflt == NULL)
2237 dflt = (char_u *)""; 2233 dflt = (char_u *)"";
2238 else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL) 2234 else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL)
2239 { 2235 {
2240 /* The default selection should be the full path, "dflt" is only the 2236 // The default selection should be the full path, "dflt" is only the
2241 * file name. */ 2237 // file name.
2242 STRCPY(dfltbuf, initdir); 2238 STRCPY(dfltbuf, initdir);
2243 add_pathsep(dfltbuf); 2239 add_pathsep(dfltbuf);
2244 STRCAT(dfltbuf, dflt); 2240 STRCAT(dfltbuf, dflt);
2245 dflt = dfltbuf; 2241 dflt = dfltbuf;
2246 } 2242 }
2247 2243
2248 /* Can only use one pattern for a file name. Get the first pattern out of 2244 // Can only use one pattern for a file name. Get the first pattern out of
2249 * the filter. An empty pattern means everything matches. */ 2245 // the filter. An empty pattern means everything matches.
2250 if (filter == NULL) 2246 if (filter == NULL)
2251 pattern = (char_u *)""; 2247 pattern = (char_u *)"";
2252 else 2248 else
2253 { 2249 {
2254 char_u *s, *p; 2250 char_u *s, *p;
2255 2251
2256 s = filter; 2252 s = filter;
2257 for (p = filter; *p != NUL; ++p) 2253 for (p = filter; *p != NUL; ++p)
2258 { 2254 {
2259 if (*p == '\t') /* end of description, start of pattern */ 2255 if (*p == '\t') // end of description, start of pattern
2260 s = p + 1; 2256 s = p + 1;
2261 if (*p == ';' || *p == '\n') /* end of (first) pattern */ 2257 if (*p == ';' || *p == '\n') // end of (first) pattern
2262 break; 2258 break;
2263 } 2259 }
2264 pattern = vim_strnsave(s, p - s); 2260 pattern = vim_strnsave(s, p - s);
2265 tofree = pattern; 2261 tofree = pattern;
2266 if (pattern == NULL) 2262 if (pattern == NULL)
2285 set_predefined_label(dialog_wgt, "Help", _("&Help")); 2281 set_predefined_label(dialog_wgt, "Help", _("&Help"));
2286 set_predefined_label(dialog_wgt, "Items", _("Files")); 2282 set_predefined_label(dialog_wgt, "Items", _("Files"));
2287 set_predefined_label(dialog_wgt, "OK", _("&OK")); 2283 set_predefined_label(dialog_wgt, "OK", _("&OK"));
2288 set_predefined_label(dialog_wgt, "Selection", _("Selection")); 2284 set_predefined_label(dialog_wgt, "Selection", _("Selection"));
2289 2285
2290 /* This is to save us from silly external settings using not fixed with 2286 // This is to save us from silly external settings using not fixed with
2291 * fonts for file selection. 2287 // fonts for file selection.
2292 */
2293 set_predefined_fontlist(dialog_wgt, "DirListSW.DirList"); 2288 set_predefined_fontlist(dialog_wgt, "DirListSW.DirList");
2294 set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList"); 2289 set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList");
2295 2290
2296 gui_motif_menu_colors(dialog_wgt); 2291 gui_motif_menu_colors(dialog_wgt);
2297 if (gui.scroll_bg_pixel != INVALCOLOR) 2292 if (gui.scroll_bg_pixel != INVALCOLOR)
2298 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); 2293 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL);
2299 2294
2300 XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); 2295 XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0);
2301 XtAddCallback(dialog_wgt, XmNcancelCallback, DialogCancelCB, (XtPointer)0); 2296 XtAddCallback(dialog_wgt, XmNcancelCallback, DialogCancelCB, (XtPointer)0);
2302 /* We have no help in this window, so hide help button */ 2297 // We have no help in this window, so hide help button
2303 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, 2298 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt,
2304 (unsigned char)XmDIALOG_HELP_BUTTON)); 2299 (unsigned char)XmDIALOG_HELP_BUTTON));
2305 2300
2306 manage_centered(dialog_wgt); 2301 manage_centered(dialog_wgt);
2307 activate_dialog_mnemonics(dialog_wgt); 2302 activate_dialog_mnemonics(dialog_wgt);
2308 2303
2309 /* sit in a loop until the dialog box has gone away */ 2304 // sit in a loop until the dialog box has gone away
2310 do 2305 do
2311 { 2306 {
2312 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), 2307 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt),
2313 (XtInputMask)XtIMAll); 2308 (XtInputMask)XtIMAll);
2314 } while (XtIsManaged(dialog_wgt)); 2309 } while (XtIsManaged(dialog_wgt));
2331 /* 2326 /*
2332 * Process callback from Dialog cancel actions. 2327 * Process callback from Dialog cancel actions.
2333 */ 2328 */
2334 static void 2329 static void
2335 DialogCancelCB( 2330 DialogCancelCB(
2336 Widget w UNUSED, /* widget id */ 2331 Widget w UNUSED, // widget id
2337 XtPointer client_data UNUSED, /* data from application */ 2332 XtPointer client_data UNUSED, // data from application
2338 XtPointer call_data UNUSED) /* data from widget class */ 2333 XtPointer call_data UNUSED) // data from widget class
2339 { 2334 {
2340 if (browse_fname != NULL) 2335 if (browse_fname != NULL)
2341 { 2336 {
2342 XtFree(browse_fname); 2337 XtFree(browse_fname);
2343 browse_fname = NULL; 2338 browse_fname = NULL;
2348 /* 2343 /*
2349 * Process callback from Dialog actions. 2344 * Process callback from Dialog actions.
2350 */ 2345 */
2351 static void 2346 static void
2352 DialogAcceptCB( 2347 DialogAcceptCB(
2353 Widget w UNUSED, /* widget id */ 2348 Widget w UNUSED, // widget id
2354 XtPointer client_data UNUSED, /* data from application */ 2349 XtPointer client_data UNUSED, // data from application
2355 XtPointer call_data) /* data from widget class */ 2350 XtPointer call_data) // data from widget class
2356 { 2351 {
2357 XmFileSelectionBoxCallbackStruct *fcb; 2352 XmFileSelectionBoxCallbackStruct *fcb;
2358 2353
2359 if (browse_fname != NULL) 2354 if (browse_fname != NULL)
2360 { 2355 {
2361 XtFree(browse_fname); 2356 XtFree(browse_fname);
2362 browse_fname = NULL; 2357 browse_fname = NULL;
2363 } 2358 }
2364 fcb = (XmFileSelectionBoxCallbackStruct *)call_data; 2359 fcb = (XmFileSelectionBoxCallbackStruct *)call_data;
2365 2360
2366 /* get the filename from the file selection box */ 2361 // get the filename from the file selection box
2367 XmStringGetLtoR(fcb->value, charset, &browse_fname); 2362 XmStringGetLtoR(fcb->value, charset, &browse_fname);
2368 2363
2369 /* popdown the file selection box */ 2364 // popdown the file selection box
2370 XtUnmanageChild(dialog_wgt); 2365 XtUnmanageChild(dialog_wgt);
2371 } 2366 }
2372 2367
2373 #endif /* FEAT_BROWSE */ 2368 #endif // FEAT_BROWSE
2374 2369
2375 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) 2370 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
2376 2371
2377 static int dialogStatus; 2372 static int dialogStatus;
2378 2373
2481 int type UNUSED, 2476 int type UNUSED,
2482 char_u *title, 2477 char_u *title,
2483 char_u *message, 2478 char_u *message,
2484 char_u *button_names, 2479 char_u *button_names,
2485 int dfltbutton, 2480 int dfltbutton,
2486 char_u *textfield, /* buffer of size IOSIZE */ 2481 char_u *textfield, // buffer of size IOSIZE
2487 int ex_cmd UNUSED) 2482 int ex_cmd UNUSED)
2488 { 2483 {
2489 char_u *buts; 2484 char_u *buts;
2490 char_u *p, *next; 2485 char_u *p, *next;
2491 XtAppContext app; 2486 XtAppContext app;
2507 #endif 2502 #endif
2508 2503
2509 if (title == NULL) 2504 if (title == NULL)
2510 title = (char_u *)_("Vim dialog"); 2505 title = (char_u *)_("Vim dialog");
2511 2506
2512 /* if our pointer is currently hidden, then we should show it. */ 2507 // if our pointer is currently hidden, then we should show it.
2513 gui_mch_mousehide(FALSE); 2508 gui_mch_mousehide(FALSE);
2514 2509
2515 dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0); 2510 dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0);
2516 2511
2517 /* Check 'v' flag in 'guioptions': vertical button placement. */ 2512 // Check 'v' flag in 'guioptions': vertical button placement.
2518 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); 2513 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
2519 2514
2520 /* Set the title of the Dialog window */ 2515 // Set the title of the Dialog window
2521 label = XmStringCreateSimple((char *)title); 2516 label = XmStringCreateSimple((char *)title);
2522 if (label == NULL) 2517 if (label == NULL)
2523 return -1; 2518 return -1;
2524 XtVaSetValues(dialogform, 2519 XtVaSetValues(dialogform,
2525 XmNdialogTitle, label, 2520 XmNdialogTitle, label,
2526 XmNhorizontalSpacing, 4, 2521 XmNhorizontalSpacing, 4,
2527 XmNverticalSpacing, vertical ? 0 : 4, 2522 XmNverticalSpacing, vertical ? 0 : 4,
2528 NULL); 2523 NULL);
2529 XmStringFree(label); 2524 XmStringFree(label);
2530 2525
2531 /* make a copy, so that we can insert NULs */ 2526 // make a copy, so that we can insert NULs
2532 buts = vim_strsave(button_names); 2527 buts = vim_strsave(button_names);
2533 if (buts == NULL) 2528 if (buts == NULL)
2534 return -1; 2529 return -1;
2535 2530
2536 /* Count the number of buttons and allocate buttons[]. */ 2531 // Count the number of buttons and allocate buttons[].
2537 butcount = 1; 2532 butcount = 1;
2538 for (p = buts; *p; ++p) 2533 for (p = buts; *p; ++p)
2539 if (*p == DLG_BUTTON_SEP) 2534 if (*p == DLG_BUTTON_SEP)
2540 ++butcount; 2535 ++butcount;
2541 buttons = ALLOC_MULT(Widget, butcount); 2536 buttons = ALLOC_MULT(Widget, butcount);
2586 XmNdefaultButtonShadowThickness, 1, 2581 XmNdefaultButtonShadowThickness, 1,
2587 NULL); 2582 NULL);
2588 XmStringFree(label); 2583 XmStringFree(label);
2589 gui_motif_menu_fontlist(buttons[butcount]); 2584 gui_motif_menu_fontlist(buttons[butcount]);
2590 2585
2591 /* Layout properly. */ 2586 // Layout properly.
2592 2587
2593 if (butcount > 0) 2588 if (butcount > 0)
2594 { 2589 {
2595 if (vertical) 2590 if (vertical)
2596 XtVaSetValues(buttons[butcount], 2591 XtVaSetValues(buttons[butcount],
2603 XtVaSetValues(buttons[butcount], 2598 XtVaSetValues(buttons[butcount],
2604 XmNrightAttachment, XmATTACH_FORM, 2599 XmNrightAttachment, XmATTACH_FORM,
2605 XmNrightOffset, 4, 2600 XmNrightOffset, 4,
2606 NULL); 2601 NULL);
2607 2602
2608 /* fill in a form as invisible separator */ 2603 // fill in a form as invisible separator
2609 sep_form = XtVaCreateWidget("separatorForm", 2604 sep_form = XtVaCreateWidget("separatorForm",
2610 xmFormWidgetClass, dialogform, 2605 xmFormWidgetClass, dialogform,
2611 XmNleftAttachment, XmATTACH_WIDGET, 2606 XmNleftAttachment, XmATTACH_WIDGET,
2612 XmNleftWidget, buttons[butcount - 1], 2607 XmNleftWidget, buttons[butcount - 1],
2613 XmNrightAttachment, XmATTACH_WIDGET, 2608 XmNrightAttachment, XmATTACH_WIDGET,
2633 XtVaSetValues(buttons[0], 2628 XtVaSetValues(buttons[0],
2634 XmNrightAttachment, XmATTACH_FORM, 2629 XmNrightAttachment, XmATTACH_FORM,
2635 XmNrightOffset, 4, 2630 XmNrightOffset, 4,
2636 NULL); 2631 NULL);
2637 2632
2638 /* fill in a form as invisible separator */ 2633 // fill in a form as invisible separator
2639 sep_form = XtVaCreateWidget("separatorForm", 2634 sep_form = XtVaCreateWidget("separatorForm",
2640 xmFormWidgetClass, dialogform, 2635 xmFormWidgetClass, dialogform,
2641 XmNleftAttachment, XmATTACH_FORM, 2636 XmNleftAttachment, XmATTACH_FORM,
2642 XmNleftOffset, 4, 2637 XmNleftOffset, 4,
2643 XmNrightAttachment, XmATTACH_WIDGET, 2638 XmNrightAttachment, XmATTACH_WIDGET,
2661 vim_free(buts); 2656 vim_free(buts);
2662 2657
2663 separator = (Widget) 0; 2658 separator = (Widget) 0;
2664 if (butcount > 0) 2659 if (butcount > 0)
2665 { 2660 {
2666 /* Create the separator for beauty. */ 2661 // Create the separator for beauty.
2667 n = 0; 2662 n = 0;
2668 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++; 2663 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
2669 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 2664 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
2670 XtSetArg(args[n], XmNbottomWidget, buttons[0]); n++; 2665 XtSetArg(args[n], XmNbottomWidget, buttons[0]); n++;
2671 XtSetArg(args[n], XmNbottomOffset, 4); n++; 2666 XtSetArg(args[n], XmNbottomOffset, 4); n++;
2697 XtManageChild(dialogtextfield); 2692 XtManageChild(dialogtextfield);
2698 XtAddEventHandler(dialogtextfield, KeyPressMask, False, 2693 XtAddEventHandler(dialogtextfield, KeyPressMask, False,
2699 (XtEventHandler)keyhit_callback, (XtPointer)NULL); 2694 (XtEventHandler)keyhit_callback, (XtPointer)NULL);
2700 } 2695 }
2701 2696
2702 /* Form holding both message and pixmap labels */ 2697 // Form holding both message and pixmap labels
2703 form = XtVaCreateWidget("separatorForm", 2698 form = XtVaCreateWidget("separatorForm",
2704 xmFormWidgetClass, dialogform, 2699 xmFormWidgetClass, dialogform,
2705 XmNleftAttachment, XmATTACH_FORM, 2700 XmNleftAttachment, XmATTACH_FORM,
2706 XmNrightAttachment, XmATTACH_FORM, 2701 XmNrightAttachment, XmATTACH_FORM,
2707 XmNtopAttachment, XmATTACH_FORM, 2702 XmNtopAttachment, XmATTACH_FORM,
2708 NULL); 2703 NULL);
2709 XtManageChild(form); 2704 XtManageChild(form);
2710 2705
2711 #ifdef HAVE_XPM 2706 #ifdef HAVE_XPM
2712 /* Add a pixmap, left of the message. */ 2707 // Add a pixmap, left of the message.
2713 switch (type) 2708 switch (type)
2714 { 2709 {
2715 case VIM_GENERIC: 2710 case VIM_GENERIC:
2716 icon_data = generic_xpm; 2711 icon_data = generic_xpm;
2717 break; 2712 break;
2742 dialogpixmap = create_pixmap_label(form, "dialogPixmap", 2737 dialogpixmap = create_pixmap_label(form, "dialogPixmap",
2743 icon_data, args, n); 2738 icon_data, args, n);
2744 XtManageChild(dialogpixmap); 2739 XtManageChild(dialogpixmap);
2745 #endif 2740 #endif
2746 2741
2747 /* Create the dialog message. 2742 // Create the dialog message.
2748 * Since LessTif is apparently having problems with the creation of 2743 // Since LessTif is apparently having problems with the creation of
2749 * properly localized string, we use LtoR here. The symptom is that the 2744 // properly localized string, we use LtoR here. The symptom is that the
2750 * string sill not show properly in multiple lines as it does in native 2745 // string sill not show properly in multiple lines as it does in native
2751 * Motif. 2746 // Motif.
2752 */
2753 label = XmStringCreateLtoR((char *)message, STRING_TAG); 2747 label = XmStringCreateLtoR((char *)message, STRING_TAG);
2754 if (label == NULL) 2748 if (label == NULL)
2755 return -1; 2749 return -1;
2756 w = XtVaCreateManagedWidget("dialogMessage", 2750 w = XtVaCreateManagedWidget("dialogMessage",
2757 xmLabelGadgetClass, form, 2751 xmLabelGadgetClass, form,
2809 manage_centered(dialogform); 2803 manage_centered(dialogform);
2810 activate_dialog_mnemonics(dialogform); 2804 activate_dialog_mnemonics(dialogform);
2811 2805
2812 if (textfield != NULL && *textfield != NUL) 2806 if (textfield != NULL && *textfield != NUL)
2813 { 2807 {
2814 /* This only works after the textfield has been realised. */ 2808 // This only works after the textfield has been realised.
2815 XmTextFieldSetSelection(dialogtextfield, 2809 XmTextFieldSetSelection(dialogtextfield,
2816 (XmTextPosition)0, (XmTextPosition)STRLEN(textfield), 2810 (XmTextPosition)0, (XmTextPosition)STRLEN(textfield),
2817 XtLastTimestampProcessed(gui.dpy)); 2811 XtLastTimestampProcessed(gui.dpy));
2818 XmTextFieldSetCursorPosition(dialogtextfield, 2812 XmTextFieldSetCursorPosition(dialogtextfield,
2819 (XmTextPosition)STRLEN(textfield)); 2813 (XmTextPosition)STRLEN(textfield));
2820 } 2814 }
2821 2815
2822 app = XtWidgetToApplicationContext(dialogform); 2816 app = XtWidgetToApplicationContext(dialogform);
2823 2817
2824 /* Loop until a button is pressed or the dialog is killed somehow. */ 2818 // Loop until a button is pressed or the dialog is killed somehow.
2825 dialogStatus = -1; 2819 dialogStatus = -1;
2826 for (;;) 2820 for (;;)
2827 { 2821 {
2828 XtAppProcessEvent(app, (XtInputMask)XtIMAll); 2822 XtAppProcessEvent(app, (XtInputMask)XtIMAll);
2829 if (dialogStatus >= 0 || !XtIsManaged(dialogform)) 2823 if (dialogStatus >= 0 || !XtIsManaged(dialogform))
2845 suppress_dialog_mnemonics(dialogform); 2839 suppress_dialog_mnemonics(dialogform);
2846 XtDestroyWidget(dialogform); 2840 XtDestroyWidget(dialogform);
2847 2841
2848 return dialogStatus; 2842 return dialogStatus;
2849 } 2843 }
2850 #endif /* FEAT_GUI_DIALOG */ 2844 #endif // FEAT_GUI_DIALOG
2851 2845
2852 #if defined(FEAT_FOOTER) || defined(PROTO) 2846 #if defined(FEAT_FOOTER) || defined(PROTO)
2853 2847
2854 static int 2848 static int
2855 gui_mch_compute_footer_height(void) 2849 gui_mch_compute_footer_height(void)
2856 { 2850 {
2857 Dimension height; /* total Toolbar height */ 2851 Dimension height; // total Toolbar height
2858 Dimension top; /* XmNmarginTop */ 2852 Dimension top; // XmNmarginTop
2859 Dimension bottom; /* XmNmarginBottom */ 2853 Dimension bottom; // XmNmarginBottom
2860 Dimension shadow; /* XmNshadowThickness */ 2854 Dimension shadow; // XmNshadowThickness
2861 2855
2862 XtVaGetValues(footer, 2856 XtVaGetValues(footer,
2863 XmNheight, &height, 2857 XmNheight, &height,
2864 XmNmarginTop, &top, 2858 XmNmarginTop, &top,
2865 XmNmarginBottom, &bottom, 2859 XmNmarginBottom, &bottom,
2903 2897
2904 #if defined(FEAT_TOOLBAR) || defined(PROTO) 2898 #if defined(FEAT_TOOLBAR) || defined(PROTO)
2905 void 2899 void
2906 gui_mch_show_toolbar(int showit) 2900 gui_mch_show_toolbar(int showit)
2907 { 2901 {
2908 Cardinal numChildren; /* how many children toolBar has */ 2902 Cardinal numChildren; // how many children toolBar has
2909 2903
2910 if (toolBar == (Widget)0) 2904 if (toolBar == (Widget)0)
2911 return; 2905 return;
2912 XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL); 2906 XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL);
2913 if (showit && numChildren > 0) 2907 if (showit && numChildren > 0)
2914 { 2908 {
2915 /* Assume that we want to show the toolbar if p_toolbar contains 2909 // Assume that we want to show the toolbar if p_toolbar contains
2916 * valid option settings, therefore p_toolbar must not be NULL. 2910 // valid option settings, therefore p_toolbar must not be NULL.
2917 */
2918 WidgetList children; 2911 WidgetList children;
2919 2912
2920 XtVaGetValues(toolBar, XmNchildren, &children, NULL); 2913 XtVaGetValues(toolBar, XmNchildren, &children, NULL);
2921 { 2914 {
2922 void (*action)(BalloonEval *); 2915 void (*action)(BalloonEval *);
2936 vimmenu_T *cur; 2929 vimmenu_T *cur;
2937 2930
2938 for (toolbar = root_menu; toolbar; toolbar = toolbar->next) 2931 for (toolbar = root_menu; toolbar; toolbar = toolbar->next)
2939 if (menu_is_toolbar(toolbar->dname)) 2932 if (menu_is_toolbar(toolbar->dname))
2940 break; 2933 break;
2941 /* Assumption: toolbar is NULL if there is no toolbar, 2934 // Assumption: toolbar is NULL if there is no toolbar,
2942 * otherwise it contains the toolbar menu structure. 2935 // otherwise it contains the toolbar menu structure.
2943 * 2936 //
2944 * Assumption: "numChildren" == the number of items in the list 2937 // Assumption: "numChildren" == the number of items in the list
2945 * of items beginning with toolbar->children. 2938 // of items beginning with toolbar->children.
2946 */
2947 if (toolbar) 2939 if (toolbar)
2948 { 2940 {
2949 for (cur = toolbar->children; cur; cur = cur->next) 2941 for (cur = toolbar->children; cur; cur = cur->next)
2950 { 2942 {
2951 Arg args[1]; 2943 Arg args[1];
2952 int n = 0; 2944 int n = 0;
2953 2945
2954 /* Enable/Disable tooltip (OK to enable while 2946 // Enable/Disable tooltip (OK to enable while
2955 * currently enabled). */ 2947 // currently enabled).
2956 if (cur->tip != NULL) 2948 if (cur->tip != NULL)
2957 (*action)(cur->tip); 2949 (*action)(cur->tip);
2958 if (!menu_is_separator(cur->name)) 2950 if (!menu_is_separator(cur->name))
2959 { 2951 {
2960 if (text == 1 || cur->xpm == NULL) 2952 if (text == 1 || cur->xpm == NULL)
3066 3058
3067 int 3059 int
3068 gui_mch_compute_toolbar_height(void) 3060 gui_mch_compute_toolbar_height(void)
3069 { 3061 {
3070 Dimension borders; 3062 Dimension borders;
3071 Dimension height; /* total Toolbar height */ 3063 Dimension height; // total Toolbar height
3072 Dimension whgt; /* height of each widget */ 3064 Dimension whgt; // height of each widget
3073 WidgetList children; /* list of toolBar's children */ 3065 WidgetList children; // list of toolBar's children
3074 Cardinal numChildren; /* how many children toolBar has */ 3066 Cardinal numChildren; // how many children toolBar has
3075 int i; 3067 int i;
3076 3068
3077 borders = 0; 3069 borders = 0;
3078 height = 0; 3070 height = 0;
3079 if (toolBar != (Widget)0 && toolBarFrame != (Widget)0) 3071 if (toolBar != (Widget)0 && toolBarFrame != (Widget)0)
3080 { /* get height of XmFrame parent */ 3072 { // get height of XmFrame parent
3081 Dimension fst; 3073 Dimension fst;
3082 Dimension fmh; 3074 Dimension fmh;
3083 Dimension tst; 3075 Dimension tst;
3084 Dimension tmh; 3076 Dimension tmh;
3085 3077
3101 if (height < whgt) 3093 if (height < whgt)
3102 height = whgt; 3094 height = whgt;
3103 } 3095 }
3104 } 3096 }
3105 #ifdef LESSTIF_VERSION 3097 #ifdef LESSTIF_VERSION
3106 /* Hack: When starting up we get wrong dimensions. */ 3098 // Hack: When starting up we get wrong dimensions.
3107 if (height < 10) 3099 if (height < 10)
3108 height = 24; 3100 height = 24;
3109 #endif 3101 #endif
3110 3102
3111 return (int)(height + (borders << 1)); 3103 return (int)(height + (borders << 1));
3254 BalloonEval *beval; 3246 BalloonEval *beval;
3255 3247
3256 if (tabLine == (Widget)0) 3248 if (tabLine == (Widget)0)
3257 return; 3249 return;
3258 3250
3259 /* Add a label for each tab page. They all contain the same text area. */ 3251 // Add a label for each tab page. They all contain the same text area.
3260 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) 3252 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
3261 { 3253 {
3262 if (tp == curtab) 3254 if (tp == curtab)
3263 curtabidx = nr; 3255 curtabidx = nr;
3264 3256
3265 page_status = XmNotebookGetPageInfo(tabLine, nr, &page_info); 3257 page_status = XmNotebookGetPageInfo(tabLine, nr, &page_info);
3266 if (page_status == XmPAGE_INVALID 3258 if (page_status == XmPAGE_INVALID
3267 || page_info.major_tab_widget == (Widget)0) 3259 || page_info.major_tab_widget == (Widget)0)
3268 { 3260 {
3269 /* Add the tab */ 3261 // Add the tab
3270 n = 0; 3262 n = 0;
3271 XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++; 3263 XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++;
3272 XtSetArg(args[n], XmNtraversalOn, False); n++; 3264 XtSetArg(args[n], XmNtraversalOn, False); n++;
3273 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; 3265 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
3274 XtSetArg(args[n], XmNhighlightThickness, 1); n++; 3266 XtSetArg(args[n], XmNhighlightThickness, 1); n++;
3307 3299
3308 tab_count = nr - 1; 3300 tab_count = nr - 1;
3309 3301
3310 XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL); 3302 XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL);
3311 3303
3312 /* Remove any old labels. */ 3304 // Remove any old labels.
3313 while (nr <= last_page) 3305 while (nr <= last_page)
3314 { 3306 {
3315 if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID 3307 if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID
3316 && page_info.page_number == nr 3308 && page_info.page_number == nr
3317 && page_info.major_tab_widget != (Widget)0) 3309 && page_info.major_tab_widget != (Widget)0)
3398 { 3390 {
3399 if (XtIsManaged(id)) 3391 if (XtIsManaged(id))
3400 { 3392 {
3401 XtUnmanageChild(id); 3393 XtUnmanageChild(id);
3402 XtVaSetValues(id, XmNfontList, fl, NULL); 3394 XtVaSetValues(id, XmNfontList, fl, NULL);
3403 /* We should force the widget to recalculate its 3395 // We should force the widget to recalculate its
3404 * geometry now. */ 3396 // geometry now.
3405 XtManageChild(id); 3397 XtManageChild(id);
3406 } 3398 }
3407 else 3399 else
3408 XtVaSetValues(id, XmNfontList, fl, NULL); 3400 XtVaSetValues(id, XmNfontList, fl, NULL);
3409 XmFontListFree(fl); 3401 XmFontListFree(fl);
3419 { 3411 {
3420 if (XtIsManaged(id)) 3412 if (XtIsManaged(id))
3421 { 3413 {
3422 XtUnmanageChild(id); 3414 XtUnmanageChild(id);
3423 XtVaSetValues(id, XmNfontList, fl, NULL); 3415 XtVaSetValues(id, XmNfontList, fl, NULL);
3424 /* We should force the widget to recalculate its 3416 // We should force the widget to recalculate its
3425 * geometry now. */ 3417 // geometry now.
3426 XtManageChild(id); 3418 XtManageChild(id);
3427 } 3419 }
3428 else 3420 else
3429 XtVaSetValues(id, XmNfontList, fl, NULL); 3421 XtVaSetValues(id, XmNfontList, fl, NULL);
3430 XmFontListFree(fl); 3422 XmFontListFree(fl);
3439 * We don't create it twice for the sake of speed. 3431 * We don't create it twice for the sake of speed.
3440 */ 3432 */
3441 3433
3442 typedef struct _SharedFindReplace 3434 typedef struct _SharedFindReplace
3443 { 3435 {
3444 Widget dialog; /* the main dialog widget */ 3436 Widget dialog; // the main dialog widget
3445 Widget wword; /* 'Exact match' check button */ 3437 Widget wword; // 'Exact match' check button
3446 Widget mcase; /* 'match case' check button */ 3438 Widget mcase; // 'match case' check button
3447 Widget up; /* search direction 'Up' radio button */ 3439 Widget up; // search direction 'Up' radio button
3448 Widget down; /* search direction 'Down' radio button */ 3440 Widget down; // search direction 'Down' radio button
3449 Widget what; /* 'Find what' entry text widget */ 3441 Widget what; // 'Find what' entry text widget
3450 Widget with; /* 'Replace with' entry text widget */ 3442 Widget with; // 'Replace with' entry text widget
3451 Widget find; /* 'Find Next' action button */ 3443 Widget find; // 'Find Next' action button
3452 Widget replace; /* 'Replace With' action button */ 3444 Widget replace; // 'Replace With' action button
3453 Widget all; /* 'Replace All' action button */ 3445 Widget all; // 'Replace All' action button
3454 Widget undo; /* 'Undo' action button */ 3446 Widget undo; // 'Undo' action button
3455 3447
3456 Widget cancel; 3448 Widget cancel;
3457 } SharedFindReplace; 3449 } SharedFindReplace;
3458 3450
3459 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; 3451 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
3466 XtPointer call_data UNUSED) 3458 XtPointer call_data UNUSED)
3467 { 3459 {
3468 SharedFindReplace *cd = (SharedFindReplace *)client_data; 3460 SharedFindReplace *cd = (SharedFindReplace *)client_data;
3469 3461
3470 if (cd != NULL) 3462 if (cd != NULL)
3471 /* suppress_dialog_mnemonics(cd->dialog); */ 3463 // suppress_dialog_mnemonics(cd->dialog);
3472 cd->dialog = (Widget)0; 3464 cd->dialog = (Widget)0;
3473 } 3465 }
3474 3466
3475 static void 3467 static void
3476 find_replace_dismiss_callback( 3468 find_replace_dismiss_callback(
3508 3500
3509 if (flags == FRD_UNDO) 3501 if (flags == FRD_UNDO)
3510 { 3502 {
3511 char_u *save_cpo = p_cpo; 3503 char_u *save_cpo = p_cpo;
3512 3504
3513 /* No need to be Vi compatible here. */ 3505 // No need to be Vi compatible here.
3514 p_cpo = (char_u *)""; 3506 p_cpo = (char_u *)"";
3515 u_undo(1); 3507 u_undo(1);
3516 p_cpo = save_cpo; 3508 p_cpo = save_cpo;
3517 gui_update_screen(); 3509 gui_update_screen();
3518 return; 3510 return;
3519 } 3511 }
3520 3512
3521 /* Get the search/replace strings from the dialog */ 3513 // Get the search/replace strings from the dialog
3522 if (flags == FRD_FINDNEXT) 3514 if (flags == FRD_FINDNEXT)
3523 { 3515 {
3524 repl_text = NULL; 3516 repl_text = NULL;
3525 sfr = &find_widgets; 3517 sfr = &find_widgets;
3526 } 3518 }
3558 if (frdp == NULL) 3550 if (frdp == NULL)
3559 return; 3551 return;
3560 3552
3561 keysym = XLookupKeysym(event, 0); 3553 keysym = XLookupKeysym(event, 0);
3562 3554
3563 /* the scape key pops the whole dialog down */ 3555 // the scape key pops the whole dialog down
3564 if (keysym == XK_Escape) 3556 if (keysym == XK_Escape)
3565 XtUnmanageChild(frdp->dialog); 3557 XtUnmanageChild(frdp->dialog);
3566 } 3558 }
3567 3559
3568 static void 3560 static void
3623 Dimension widest; 3615 Dimension widest;
3624 char_u *entry_text; 3616 char_u *entry_text;
3625 3617
3626 frdp = do_replace ? &repl_widgets : &find_widgets; 3618 frdp = do_replace ? &repl_widgets : &find_widgets;
3627 3619
3628 /* Get the search string to use. */ 3620 // Get the search string to use.
3629 entry_text = get_find_dialog_text(arg, &wword, &mcase); 3621 entry_text = get_find_dialog_text(arg, &wword, &mcase);
3630 3622
3631 /* If the dialog already exists, just raise it. */ 3623 // If the dialog already exists, just raise it.
3632 if (frdp->dialog) 3624 if (frdp->dialog)
3633 { 3625 {
3634 gui_motif_synch_fonts(); 3626 gui_motif_synch_fonts();
3635 3627
3636 /* If the window is already up, just pop it to the top */ 3628 // If the window is already up, just pop it to the top
3637 if (XtIsManaged(frdp->dialog)) 3629 if (XtIsManaged(frdp->dialog))
3638 XMapRaised(XtDisplay(frdp->dialog), 3630 XMapRaised(XtDisplay(frdp->dialog),
3639 XtWindow(XtParent(frdp->dialog))); 3631 XtWindow(XtParent(frdp->dialog)));
3640 else 3632 else
3641 XtManageChild(frdp->dialog); 3633 XtManageChild(frdp->dialog);
3648 3640
3649 XtVaSetValues(frdp->wword, XmNset, wword, NULL); 3641 XtVaSetValues(frdp->wword, XmNset, wword, NULL);
3650 return; 3642 return;
3651 } 3643 }
3652 3644
3653 /* Create a fresh new dialog window */ 3645 // Create a fresh new dialog window
3654 if (do_replace) 3646 if (do_replace)
3655 str = XmStringCreateSimple(_("VIM - Search and Replace...")); 3647 str = XmStringCreateSimple(_("VIM - Search and Replace..."));
3656 else 3648 else
3657 str = XmStringCreateSimple(_("VIM - Search...")); 3649 str = XmStringCreateSimple(_("VIM - Search..."));
3658 3650
3830 } 3822 }
3831 XtAddEventHandler(frdp->what, KeyPressMask, False, 3823 XtAddEventHandler(frdp->what, KeyPressMask, False,
3832 (XtEventHandler)find_replace_keypress, 3824 (XtEventHandler)find_replace_keypress,
3833 (XtPointer)frdp); 3825 (XtPointer)frdp);
3834 3826
3835 /* Get the maximum width between the label widgets and line them up. 3827 // Get the maximum width between the label widgets and line them up.
3836 */
3837 n = 0; 3828 n = 0;
3838 XtSetArg(args[n], XmNwidth, &width); n++; 3829 XtSetArg(args[n], XmNwidth, &width); n++;
3839 XtGetValues(label_what, args, n); 3830 XtGetValues(label_what, args, n);
3840 widest = width; 3831 widest = width;
3841 if (do_replace) 3832 if (do_replace)
3988 SharedFindReplace *frdp; 3979 SharedFindReplace *frdp;
3989 int do_replace; 3980 int do_replace;
3990 XFontStruct *font; 3981 XFontStruct *font;
3991 XmFontList font_list; 3982 XmFontList font_list;
3992 3983
3993 /* FIXME: Unless we find out how to create a XmFontList from a XFontSet, 3984 // FIXME: Unless we find out how to create a XmFontList from a XFontSet,
3994 * we just give up here on font synchronization. */ 3985 // we just give up here on font synchronization.
3995 font = (XFontStruct *)gui.norm_font; 3986 font = (XFontStruct *)gui.norm_font;
3996 if (font == NULL) 3987 if (font == NULL)
3997 return; 3988 return;
3998 3989
3999 font_list = gui_motif_create_fontlist(font); 3990 font_list = gui_motif_create_fontlist(font);
4000 3991
4001 /* OK this loop is a bit tricky... */ 3992 // OK this loop is a bit tricky...
4002 for (do_replace = 0; do_replace <= 1; ++do_replace) 3993 for (do_replace = 0; do_replace <= 1; ++do_replace)
4003 { 3994 {
4004 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); 3995 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets);
4005 if (frdp->dialog) 3996 if (frdp->dialog)
4006 { 3997 {