Mercurial > vim
comparison src/gui_athena.c @ 7821:81794242a275 v7.4.1207
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 16:39:25 2016 +0100
patch 7.4.1207
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 16:45:04 +0100 |
parents | a1e71a01dbd6 |
children | 7898da204b98 |
comparison
equal
deleted
inserted
replaced
7820:38d22ab3d9a0 | 7821:81794242a275 |
---|---|
85 /* | 85 /* |
86 * Scrollbar callback (XtNjumpProc) for when the scrollbar is dragged with the | 86 * Scrollbar callback (XtNjumpProc) for when the scrollbar is dragged with the |
87 * left or middle mouse button. | 87 * left or middle mouse button. |
88 */ | 88 */ |
89 static void | 89 static void |
90 gui_athena_scroll_cb_jump(w, client_data, call_data) | 90 gui_athena_scroll_cb_jump( |
91 Widget w UNUSED; | 91 Widget w UNUSED, |
92 XtPointer client_data, call_data; | 92 XtPointer client_data, call_data) |
93 { | 93 { |
94 scrollbar_T *sb, *sb_info; | 94 scrollbar_T *sb, *sb_info; |
95 long value; | 95 long value; |
96 | 96 |
97 sb = gui_find_scrollbar((long)client_data); | 97 sb = gui_find_scrollbar((long)client_data); |
120 /* | 120 /* |
121 * Scrollbar callback (XtNscrollProc) for paging up or down with the left or | 121 * Scrollbar callback (XtNscrollProc) for paging up or down with the left or |
122 * right mouse buttons. | 122 * right mouse buttons. |
123 */ | 123 */ |
124 static void | 124 static void |
125 gui_athena_scroll_cb_scroll(w, client_data, call_data) | 125 gui_athena_scroll_cb_scroll( |
126 Widget w UNUSED; | 126 Widget w UNUSED, |
127 XtPointer client_data, call_data; | 127 XtPointer client_data, call_data) |
128 { | 128 { |
129 scrollbar_T *sb, *sb_info; | 129 scrollbar_T *sb, *sb_info; |
130 long value; | 130 long value; |
131 int data = (int)(long)call_data; | 131 int data = (int)(long)call_data; |
132 int page; | 132 int page; |
226 | 226 |
227 /* | 227 /* |
228 * Create all the Athena widgets necessary. | 228 * Create all the Athena widgets necessary. |
229 */ | 229 */ |
230 void | 230 void |
231 gui_x11_create_widgets() | 231 gui_x11_create_widgets(void) |
232 { | 232 { |
233 /* | 233 /* |
234 * We don't have any borders handled internally by the textArea to worry | 234 * We don't have any borders handled internally by the textArea to worry |
235 * about so only skip over the configured border width. | 235 * about so only skip over the configured border width. |
236 */ | 236 */ |
323 #ifdef FEAT_MENU | 323 #ifdef FEAT_MENU |
324 /* | 324 /* |
325 * Calculates the Pixmap based on the size of the current menu font. | 325 * Calculates the Pixmap based on the size of the current menu font. |
326 */ | 326 */ |
327 static Pixmap | 327 static Pixmap |
328 gui_athena_create_pullright_pixmap(w) | 328 gui_athena_create_pullright_pixmap(Widget w) |
329 Widget w; | |
330 { | 329 { |
331 Pixmap retval; | 330 Pixmap retval; |
332 #ifdef FONTSET_ALWAYS | 331 #ifdef FONTSET_ALWAYS |
333 XFontSet font = None; | 332 XFontSet font = None; |
334 #else | 333 #else |
423 | 422 |
424 /* | 423 /* |
425 * Called when the GUI is not going to start after all. | 424 * Called when the GUI is not going to start after all. |
426 */ | 425 */ |
427 void | 426 void |
428 gui_x11_destroy_widgets() | 427 gui_x11_destroy_widgets(void) |
429 { | 428 { |
430 textArea = NULL; | 429 textArea = NULL; |
431 #ifdef FEAT_MENU | 430 #ifdef FEAT_MENU |
432 menuBar = NULL; | 431 menuBar = NULL; |
433 #endif | 432 #endif |
448 /* | 447 /* |
449 * Allocated a pixmap for toolbar menu "menu". | 448 * Allocated a pixmap for toolbar menu "menu". |
450 * Return in "sen". | 449 * Return in "sen". |
451 */ | 450 */ |
452 static void | 451 static void |
453 get_toolbar_pixmap(menu, sen) | 452 get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen) |
454 vimmenu_T *menu; | |
455 Pixmap *sen; | |
456 { | 453 { |
457 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ | 454 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ |
458 char **xpm = NULL; /* xpm array */ | 455 char **xpm = NULL; /* xpm array */ |
459 | 456 |
460 buf[0] = NUL; /* start with NULL path */ | 457 buf[0] = NUL; /* start with NULL path */ |
490 * background colors. If there is an error reading a color xpm file, | 487 * background colors. If there is an error reading a color xpm file, |
491 * drop back and read the monochrome file. If successful, create the | 488 * drop back and read the monochrome file. If successful, create the |
492 * insensitive Pixmap too. | 489 * insensitive Pixmap too. |
493 */ | 490 */ |
494 static void | 491 static void |
495 createXpmImages(path, xpm, sen) | 492 createXpmImages(char_u *path, char **xpm, Pixmap *sen) |
496 char_u *path; | |
497 char **xpm; | |
498 Pixmap *sen; | |
499 { | 493 { |
500 Window rootWindow; | 494 Window rootWindow; |
501 XpmAttributes attrs; | 495 XpmAttributes attrs; |
502 XpmColorSymbol color[5] = | 496 XpmColorSymbol color[5] = |
503 { | 497 { |
564 | 558 |
565 XpmFreeAttributes(&attrs); | 559 XpmFreeAttributes(&attrs); |
566 } | 560 } |
567 | 561 |
568 void | 562 void |
569 gui_mch_set_toolbar_pos(x, y, w, h) | 563 gui_mch_set_toolbar_pos( |
570 int x; | 564 int x, |
571 int y; | 565 int y, |
572 int w; | 566 int w, |
573 int h; | 567 int h) |
574 { | 568 { |
575 Dimension border; | 569 Dimension border; |
576 int height; | 570 int height; |
577 | 571 |
578 if (!XtIsManaged(toolBar)) /* nothing to do */ | 572 if (!XtIsManaged(toolBar)) /* nothing to do */ |
593 XtManageChild(toolBar); | 587 XtManageChild(toolBar); |
594 } | 588 } |
595 #endif | 589 #endif |
596 | 590 |
597 void | 591 void |
598 gui_mch_set_text_area_pos(x, y, w, h) | 592 gui_mch_set_text_area_pos( |
599 int x; | 593 int x, |
600 int y; | 594 int y, |
601 int w; | 595 int w, |
602 int h; | 596 int h) |
603 { | 597 { |
604 XtUnmanageChild(textArea); | 598 XtUnmanageChild(textArea); |
605 XtVaSetValues(textArea, | 599 XtVaSetValues(textArea, |
606 XtNhorizDistance, x, | 600 XtNhorizDistance, x, |
607 XtNvertDistance, y, | 601 XtNvertDistance, y, |
620 * A toolbar button has been pushed; now reset the input focus | 614 * A toolbar button has been pushed; now reset the input focus |
621 * such that the user can type page up/down etc. and have the | 615 * such that the user can type page up/down etc. and have the |
622 * input go to the editor window, not the button | 616 * input go to the editor window, not the button |
623 */ | 617 */ |
624 static void | 618 static void |
625 gui_mch_reset_focus() | 619 gui_mch_reset_focus(void) |
626 { | 620 { |
627 XtSetKeyboardFocus(vimForm, textArea); | 621 XtSetKeyboardFocus(vimForm, textArea); |
628 } | 622 } |
629 #endif | 623 #endif |
630 | 624 |
631 | 625 |
632 void | 626 void |
633 gui_x11_set_back_color() | 627 gui_x11_set_back_color(void) |
634 { | 628 { |
635 if (textArea != NULL) | 629 if (textArea != NULL) |
636 XtVaSetValues(textArea, | 630 XtVaSetValues(textArea, |
637 XtNbackground, gui.back_pixel, | 631 XtNbackground, gui.back_pixel, |
638 NULL); | 632 NULL); |
650 static void gui_mch_submenu_change(vimmenu_T *mp, int colors); | 644 static void gui_mch_submenu_change(vimmenu_T *mp, int colors); |
651 static void gui_athena_menu_font(Widget id); | 645 static void gui_athena_menu_font(Widget id); |
652 static Boolean gui_athena_menu_has_submenus(Widget, Widget); | 646 static Boolean gui_athena_menu_has_submenus(Widget, Widget); |
653 | 647 |
654 void | 648 void |
655 gui_mch_enable_menu(flag) | 649 gui_mch_enable_menu(int flag) |
656 int flag; | |
657 { | 650 { |
658 if (flag) | 651 if (flag) |
659 { | 652 { |
660 XtManageChild(menuBar); | 653 XtManageChild(menuBar); |
661 # ifdef FEAT_TOOLBAR | 654 # ifdef FEAT_TOOLBAR |
683 # endif | 676 # endif |
684 } | 677 } |
685 } | 678 } |
686 | 679 |
687 void | 680 void |
688 gui_mch_set_menu_pos(x, y, w, h) | 681 gui_mch_set_menu_pos( |
689 int x; | 682 int x, |
690 int y; | 683 int y, |
691 int w; | 684 int w, |
692 int h; | 685 int h) |
693 { | 686 { |
694 Dimension border; | 687 Dimension border; |
695 int height; | 688 int height; |
696 | 689 |
697 XtUnmanageChild(menuBar); | 690 XtUnmanageChild(menuBar); |
715 * | 708 * |
716 * Valid range of return values is: 0 (beginning of children) to | 709 * Valid range of return values is: 0 (beginning of children) to |
717 * numChildren (end of children). | 710 * numChildren (end of children). |
718 */ | 711 */ |
719 static Cardinal | 712 static Cardinal |
720 athena_calculate_ins_pos(widget) | 713 athena_calculate_ins_pos(Widget widget) |
721 Widget widget; | |
722 { | 714 { |
723 /* Assume that if the parent of the vimmenu_T is NULL, then we can get | 715 /* Assume that if the parent of the vimmenu_T is NULL, then we can get |
724 * to this menu by traversing "next", starting at "root_menu". | 716 * to this menu by traversing "next", starting at "root_menu". |
725 * | 717 * |
726 * This holds true for popup menus, toolbar, and toplevel menu items. | 718 * This holds true for popup menus, toolbar, and toplevel menu items. |
762 } | 754 } |
763 return retval; | 755 return retval; |
764 } | 756 } |
765 | 757 |
766 void | 758 void |
767 gui_mch_add_menu(menu, idx) | 759 gui_mch_add_menu(vimmenu_T *menu, int idx UNUSED) |
768 vimmenu_T *menu; | |
769 int idx UNUSED; | |
770 { | 760 { |
771 char_u *pullright_name; | 761 char_u *pullright_name; |
772 Dimension height, space, border; | 762 Dimension height, space, border; |
773 vimmenu_T *parent = menu->parent; | 763 vimmenu_T *parent = menu->parent; |
774 | 764 |
882 * | 872 * |
883 * "id" is the parent of the menu items. | 873 * "id" is the parent of the menu items. |
884 * Ignore widget "ignore" in the pane. | 874 * Ignore widget "ignore" in the pane. |
885 */ | 875 */ |
886 static Boolean | 876 static Boolean |
887 gui_athena_menu_has_submenus(id, ignore) | 877 gui_athena_menu_has_submenus(Widget id, Widget ignore) |
888 Widget id; | |
889 Widget ignore; | |
890 { | 878 { |
891 WidgetList children; | 879 WidgetList children; |
892 Cardinal num_children; | 880 Cardinal num_children; |
893 int i; | 881 int i; |
894 | 882 |
904 } | 892 } |
905 return False; | 893 return False; |
906 } | 894 } |
907 | 895 |
908 static void | 896 static void |
909 gui_athena_menu_font(id) | 897 gui_athena_menu_font(Widget id) |
910 Widget id; | |
911 { | 898 { |
912 #ifdef FONTSET_ALWAYS | 899 #ifdef FONTSET_ALWAYS |
913 if (gui.menu_fontset != NOFONTSET) | 900 if (gui.menu_fontset != NOFONTSET) |
914 { | 901 { |
915 if (XtIsManaged(id)) | 902 if (XtIsManaged(id)) |
952 #endif | 939 #endif |
953 } | 940 } |
954 | 941 |
955 | 942 |
956 void | 943 void |
957 gui_mch_new_menu_font() | 944 gui_mch_new_menu_font(void) |
958 { | 945 { |
959 Pixmap oldpuller = None; | 946 Pixmap oldpuller = None; |
960 | 947 |
961 if (menuBar == (Widget)0) | 948 if (menuBar == (Widget)0) |
962 return; | 949 return; |
1029 XFreePixmap(gui.dpy, oldpuller); | 1016 XFreePixmap(gui.dpy, oldpuller); |
1030 } | 1017 } |
1031 | 1018 |
1032 #if defined(FEAT_BEVAL) || defined(PROTO) | 1019 #if defined(FEAT_BEVAL) || defined(PROTO) |
1033 void | 1020 void |
1034 gui_mch_new_tooltip_font() | 1021 gui_mch_new_tooltip_font(void) |
1035 { | 1022 { |
1036 # ifdef FEAT_TOOLBAR | 1023 # ifdef FEAT_TOOLBAR |
1037 vimmenu_T *menu; | 1024 vimmenu_T *menu; |
1038 | 1025 |
1039 if (toolBar == (Widget)0) | 1026 if (toolBar == (Widget)0) |
1044 gui_mch_submenu_change(menu, FALSE); | 1031 gui_mch_submenu_change(menu, FALSE); |
1045 # endif | 1032 # endif |
1046 } | 1033 } |
1047 | 1034 |
1048 void | 1035 void |
1049 gui_mch_new_tooltip_colors() | 1036 gui_mch_new_tooltip_colors(void) |
1050 { | 1037 { |
1051 # ifdef FEAT_TOOLBAR | 1038 # ifdef FEAT_TOOLBAR |
1052 vimmenu_T *menu; | 1039 vimmenu_T *menu; |
1053 | 1040 |
1054 if (toolBar == (Widget)0) | 1041 if (toolBar == (Widget)0) |
1060 # endif | 1047 # endif |
1061 } | 1048 } |
1062 #endif | 1049 #endif |
1063 | 1050 |
1064 static void | 1051 static void |
1065 gui_mch_submenu_change(menu, colors) | 1052 gui_mch_submenu_change( |
1066 vimmenu_T *menu; | 1053 vimmenu_T *menu, |
1067 int colors; /* TRUE for colors, FALSE for font */ | 1054 int colors) /* TRUE for colors, FALSE for font */ |
1068 { | 1055 { |
1069 vimmenu_T *mp; | 1056 vimmenu_T *mp; |
1070 | 1057 |
1071 for (mp = menu; mp != NULL; mp = mp->next) | 1058 for (mp = menu; mp != NULL; mp = mp->next) |
1072 { | 1059 { |
1139 /* | 1126 /* |
1140 * Make a submenu name into a pullright name. | 1127 * Make a submenu name into a pullright name. |
1141 * Replace '.' by '_', can't include '.' in the submenu name. | 1128 * Replace '.' by '_', can't include '.' in the submenu name. |
1142 */ | 1129 */ |
1143 static char_u * | 1130 static char_u * |
1144 make_pull_name(name) | 1131 make_pull_name(char_u * name) |
1145 char_u * name; | |
1146 { | 1132 { |
1147 char_u *pname; | 1133 char_u *pname; |
1148 char_u *p; | 1134 char_u *p; |
1149 | 1135 |
1150 pname = vim_strnsave(name, STRLEN(name) + strlen("-pullright")); | 1136 pname = vim_strnsave(name, STRLEN(name) + strlen("-pullright")); |
1156 } | 1142 } |
1157 return pname; | 1143 return pname; |
1158 } | 1144 } |
1159 | 1145 |
1160 void | 1146 void |
1161 gui_mch_add_menu_item(menu, idx) | 1147 gui_mch_add_menu_item(vimmenu_T *menu, int idx UNUSED) |
1162 vimmenu_T *menu; | |
1163 int idx UNUSED; | |
1164 { | 1148 { |
1165 vimmenu_T *parent = menu->parent; | 1149 vimmenu_T *parent = menu->parent; |
1166 | 1150 |
1167 a_cur_menu = menu; | 1151 a_cur_menu = menu; |
1168 # ifdef FEAT_TOOLBAR | 1152 # ifdef FEAT_TOOLBAR |
1402 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); | 1386 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
1403 } | 1387 } |
1404 | 1388 |
1405 | 1389 |
1406 int | 1390 int |
1407 gui_mch_compute_toolbar_height() | 1391 gui_mch_compute_toolbar_height(void) |
1408 { | 1392 { |
1409 Dimension height; /* total Toolbar height */ | 1393 Dimension height; /* total Toolbar height */ |
1410 Dimension whgt; /* height of each widget */ | 1394 Dimension whgt; /* height of each widget */ |
1411 Dimension marginHeight; /* XmNmarginHeight of toolBar */ | 1395 Dimension marginHeight; /* XmNmarginHeight of toolBar */ |
1412 Dimension shadowThickness; /* thickness of Xtparent(toolBar) */ | 1396 Dimension shadowThickness; /* thickness of Xtparent(toolBar) */ |
1437 | 1421 |
1438 return (int)(height + (marginHeight << 1) + (shadowThickness << 1)); | 1422 return (int)(height + (marginHeight << 1) + (shadowThickness << 1)); |
1439 } | 1423 } |
1440 | 1424 |
1441 void | 1425 void |
1442 gui_mch_get_toolbar_colors(bgp, fgp, bsp, tsp, hsp) | 1426 gui_mch_get_toolbar_colors( |
1443 Pixel *bgp; | 1427 Pixel *bgp, |
1444 Pixel *fgp; | 1428 Pixel *fgp, |
1445 Pixel *bsp; | 1429 Pixel *bsp, |
1446 Pixel *tsp; | 1430 Pixel *tsp, |
1447 Pixel *hsp; | 1431 Pixel *hsp) |
1448 { | 1432 { |
1449 XtVaGetValues(toolBar, XtNbackground, bgp, XtNborderColor, fgp, NULL); | 1433 XtVaGetValues(toolBar, XtNbackground, bgp, XtNborderColor, fgp, NULL); |
1450 *bsp = *bgp; | 1434 *bsp = *bgp; |
1451 *tsp = *fgp; | 1435 *tsp = *fgp; |
1452 *hsp = *tsp; | 1436 *hsp = *tsp; |
1453 } | 1437 } |
1454 #endif | 1438 #endif |
1455 | 1439 |
1456 | 1440 |
1457 void | 1441 void |
1458 gui_mch_toggle_tearoffs(enable) | 1442 gui_mch_toggle_tearoffs(int enable UNUSED) |
1459 int enable UNUSED; | |
1460 { | 1443 { |
1461 /* no tearoff menus */ | 1444 /* no tearoff menus */ |
1462 } | 1445 } |
1463 | 1446 |
1464 void | 1447 void |
1465 gui_mch_new_menu_colors() | 1448 gui_mch_new_menu_colors(void) |
1466 { | 1449 { |
1467 if (menuBar == (Widget)0) | 1450 if (menuBar == (Widget)0) |
1468 return; | 1451 return; |
1469 if (gui.menu_fg_pixel != INVALCOLOR) | 1452 if (gui.menu_fg_pixel != INVALCOLOR) |
1470 XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); | 1453 XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); |
1478 | 1461 |
1479 /* | 1462 /* |
1480 * Destroy the machine specific menu widget. | 1463 * Destroy the machine specific menu widget. |
1481 */ | 1464 */ |
1482 void | 1465 void |
1483 gui_mch_destroy_menu(menu) | 1466 gui_mch_destroy_menu(vimmenu_T *menu) |
1484 vimmenu_T *menu; | |
1485 { | 1467 { |
1486 Widget parent; | 1468 Widget parent; |
1487 | 1469 |
1488 /* There is no item for the toolbar. */ | 1470 /* There is no item for the toolbar. */ |
1489 if (menu->id == (Widget)0) | 1471 if (menu->id == (Widget)0) |
1624 menu->submenu_id = (Widget)0; | 1606 menu->submenu_id = (Widget)0; |
1625 } | 1607 } |
1626 } | 1608 } |
1627 | 1609 |
1628 static void | 1610 static void |
1629 gui_athena_menu_timeout(client_data, id) | 1611 gui_athena_menu_timeout( |
1630 XtPointer client_data; | 1612 XtPointer client_data, |
1631 XtIntervalId *id UNUSED; | 1613 XtIntervalId *id UNUSED) |
1632 { | 1614 { |
1633 Widget w = (Widget)client_data; | 1615 Widget w = (Widget)client_data; |
1634 Widget popup; | 1616 Widget popup; |
1635 | 1617 |
1636 timer = 0; | 1618 timer = 0; |
1656 * rightmost end of the menu entry that caused the popup. | 1638 * rightmost end of the menu entry that caused the popup. |
1657 * | 1639 * |
1658 * This is called when XtPopup() is called. | 1640 * This is called when XtPopup() is called. |
1659 */ | 1641 */ |
1660 static void | 1642 static void |
1661 gui_athena_popup_callback(w, client_data, call_data) | 1643 gui_athena_popup_callback( |
1662 Widget w; | 1644 Widget w, |
1663 XtPointer client_data; | 1645 XtPointer client_data, |
1664 XtPointer call_data UNUSED; | 1646 XtPointer call_data UNUSED) |
1665 { | 1647 { |
1666 /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */ | 1648 /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */ |
1667 vimmenu_T *menu = (vimmenu_T *)client_data; | 1649 vimmenu_T *menu = (vimmenu_T *)client_data; |
1668 Dimension width; | 1650 Dimension width; |
1669 Position root_x, root_y; | 1651 Position root_x, root_y; |
1688 XtNy, root_y, | 1670 XtNy, root_y, |
1689 NULL); | 1671 NULL); |
1690 } | 1672 } |
1691 | 1673 |
1692 static void | 1674 static void |
1693 gui_athena_popdown_submenus_action(w, event, args, nargs) | 1675 gui_athena_popdown_submenus_action( |
1694 Widget w; | 1676 Widget w, |
1695 XEvent *event; | 1677 XEvent *event, |
1696 String *args; | 1678 String *args, |
1697 Cardinal *nargs; | 1679 Cardinal *nargs) |
1698 { | 1680 { |
1699 WidgetList children; | 1681 WidgetList children; |
1700 Cardinal num_children; | 1682 Cardinal num_children; |
1701 | 1683 |
1702 XtVaGetValues(w, XtNchildren, &children, | 1684 XtVaGetValues(w, XtNchildren, &children, |
1717 } | 1699 } |
1718 } | 1700 } |
1719 | 1701 |
1720 /* Used to determine if the given widget has a submenu that can be popped up. */ | 1702 /* Used to determine if the given widget has a submenu that can be popped up. */ |
1721 static Boolean | 1703 static Boolean |
1722 has_submenu(widget) | 1704 has_submenu(Widget widget) |
1723 Widget widget; | |
1724 { | 1705 { |
1725 if ((widget != NULL) && XtIsSubclass(widget,smeBSBObjectClass)) | 1706 if ((widget != NULL) && XtIsSubclass(widget,smeBSBObjectClass)) |
1726 { | 1707 { |
1727 Pixmap p; | 1708 Pixmap p; |
1728 | 1709 |
1732 } | 1713 } |
1733 return False; | 1714 return False; |
1734 } | 1715 } |
1735 | 1716 |
1736 static void | 1717 static void |
1737 gui_athena_delayed_arm_action(w, event, args, nargs) | 1718 gui_athena_delayed_arm_action( |
1738 Widget w; | 1719 Widget w, |
1739 XEvent *event; | 1720 XEvent *event, |
1740 String *args; | 1721 String *args, |
1741 Cardinal *nargs; | 1722 Cardinal *nargs) |
1742 { | 1723 { |
1743 Dimension width, height; | 1724 Dimension width, height; |
1744 | 1725 |
1745 if (event->type != MotionNotify) | 1726 if (event->type != MotionNotify) |
1746 return; | 1727 return; |
1776 } | 1757 } |
1777 } | 1758 } |
1778 } | 1759 } |
1779 | 1760 |
1780 static Widget | 1761 static Widget |
1781 get_popup_entry(w) | 1762 get_popup_entry(Widget w) |
1782 Widget w; | |
1783 { | 1763 { |
1784 Widget menuw; | 1764 Widget menuw; |
1785 | 1765 |
1786 /* Get the active entry for the current menu */ | 1766 /* Get the active entry for the current menu */ |
1787 if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0) | 1767 if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0) |
1792 | 1772 |
1793 /* Given the widget that has been determined to have a submenu, return the submenu widget | 1773 /* Given the widget that has been determined to have a submenu, return the submenu widget |
1794 * that is to be popped up. | 1774 * that is to be popped up. |
1795 */ | 1775 */ |
1796 static Widget | 1776 static Widget |
1797 submenu_widget(widget) | 1777 submenu_widget(Widget widget) |
1798 Widget widget; | |
1799 { | 1778 { |
1800 /* Precondition: has_submenu(widget) == True | 1779 /* Precondition: has_submenu(widget) == True |
1801 * XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True | 1780 * XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True |
1802 */ | 1781 */ |
1803 | 1782 |
1812 /* Postcondition: (popup != NULL) implies | 1791 /* Postcondition: (popup != NULL) implies |
1813 * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */ | 1792 * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */ |
1814 } | 1793 } |
1815 | 1794 |
1816 void | 1795 void |
1817 gui_mch_show_popupmenu(menu) | 1796 gui_mch_show_popupmenu(vimmenu_T *menu) |
1818 vimmenu_T *menu; | |
1819 { | 1797 { |
1820 int rootx, rooty, winx, winy; | 1798 int rootx, rooty, winx, winy; |
1821 Window root, child; | 1799 Window root, child; |
1822 unsigned int mask; | 1800 unsigned int mask; |
1823 | 1801 |
1848 | 1826 |
1849 /* | 1827 /* |
1850 * Set the menu and scrollbar colors to their default values. | 1828 * Set the menu and scrollbar colors to their default values. |
1851 */ | 1829 */ |
1852 void | 1830 void |
1853 gui_mch_def_colors() | 1831 gui_mch_def_colors(void) |
1854 { | 1832 { |
1855 /* | 1833 /* |
1856 * Get the colors ourselves. Using the automatic conversion doesn't | 1834 * Get the colors ourselves. Using the automatic conversion doesn't |
1857 * handle looking for approximate colors. | 1835 * handle looking for approximate colors. |
1858 */ | 1836 */ |
1873 /* | 1851 /* |
1874 * Scrollbar stuff. | 1852 * Scrollbar stuff. |
1875 */ | 1853 */ |
1876 | 1854 |
1877 void | 1855 void |
1878 gui_mch_set_scrollbar_thumb(sb, val, size, max) | 1856 gui_mch_set_scrollbar_thumb( |
1879 scrollbar_T *sb; | 1857 scrollbar_T *sb, |
1880 long val; | 1858 long val, |
1881 long size; | 1859 long size, |
1882 long max; | 1860 long max) |
1883 { | 1861 { |
1884 double v, s; | 1862 double v, s; |
1885 | 1863 |
1886 if (sb->id == (Widget)0) | 1864 if (sb->id == (Widget)0) |
1887 return; | 1865 return; |
1909 #endif | 1887 #endif |
1910 } | 1888 } |
1911 } | 1889 } |
1912 | 1890 |
1913 void | 1891 void |
1914 gui_mch_set_scrollbar_pos(sb, x, y, w, h) | 1892 gui_mch_set_scrollbar_pos( |
1915 scrollbar_T *sb; | 1893 scrollbar_T *sb, |
1916 int x; | 1894 int x, |
1917 int y; | 1895 int y, |
1918 int w; | 1896 int w, |
1919 int h; | 1897 int h) |
1920 { | 1898 { |
1921 if (sb->id == (Widget)0) | 1899 if (sb->id == (Widget)0) |
1922 return; | 1900 return; |
1923 | 1901 |
1924 XtUnmanageChild(sb->id); | 1902 XtUnmanageChild(sb->id); |
1930 NULL); | 1908 NULL); |
1931 XtManageChild(sb->id); | 1909 XtManageChild(sb->id); |
1932 } | 1910 } |
1933 | 1911 |
1934 void | 1912 void |
1935 gui_mch_enable_scrollbar(sb, flag) | 1913 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) |
1936 scrollbar_T *sb; | |
1937 int flag; | |
1938 { | 1914 { |
1939 if (sb->id != (Widget)0) | 1915 if (sb->id != (Widget)0) |
1940 { | 1916 { |
1941 if (flag) | 1917 if (flag) |
1942 XtManageChild(sb->id); | 1918 XtManageChild(sb->id); |
1944 XtUnmanageChild(sb->id); | 1920 XtUnmanageChild(sb->id); |
1945 } | 1921 } |
1946 } | 1922 } |
1947 | 1923 |
1948 void | 1924 void |
1949 gui_mch_create_scrollbar(sb, orient) | 1925 gui_mch_create_scrollbar( |
1950 scrollbar_T *sb; | 1926 scrollbar_T *sb, |
1951 int orient; /* SBAR_VERT or SBAR_HORIZ */ | 1927 int orient) /* SBAR_VERT or SBAR_HORIZ */ |
1952 { | 1928 { |
1953 sb->id = XtVaCreateWidget("scrollBar", | 1929 sb->id = XtVaCreateWidget("scrollBar", |
1954 #ifdef FEAT_GUI_NEXTAW | 1930 #ifdef FEAT_GUI_NEXTAW |
1955 scrollbarWidgetClass, vimForm, | 1931 scrollbarWidgetClass, vimForm, |
1956 #else | 1932 #else |
1982 #endif | 1958 #endif |
1983 } | 1959 } |
1984 | 1960 |
1985 #if defined(FEAT_WINDOWS) || defined(PROTO) | 1961 #if defined(FEAT_WINDOWS) || defined(PROTO) |
1986 void | 1962 void |
1987 gui_mch_destroy_scrollbar(sb) | 1963 gui_mch_destroy_scrollbar(scrollbar_T *sb) |
1988 scrollbar_T *sb; | |
1989 { | 1964 { |
1990 if (sb->id != (Widget)0) | 1965 if (sb->id != (Widget)0) |
1991 XtDestroyWidget(sb->id); | 1966 XtDestroyWidget(sb->id); |
1992 } | 1967 } |
1993 #endif | 1968 #endif |
1994 | 1969 |
1995 void | 1970 void |
1996 gui_mch_set_scrollbar_colors(sb) | 1971 gui_mch_set_scrollbar_colors(scrollbar_T *sb) |
1997 scrollbar_T *sb; | |
1998 { | 1972 { |
1999 if (sb->id != (Widget)0) | 1973 if (sb->id != (Widget)0) |
2000 XtVaSetValues(sb->id, | 1974 XtVaSetValues(sb->id, |
2001 XtNforeground, gui.scroll_fg_pixel, | 1975 XtNforeground, gui.scroll_fg_pixel, |
2002 XtNbackground, gui.scroll_bg_pixel, | 1976 XtNbackground, gui.scroll_bg_pixel, |
2009 | 1983 |
2010 /* | 1984 /* |
2011 * Miscellaneous stuff: | 1985 * Miscellaneous stuff: |
2012 */ | 1986 */ |
2013 Window | 1987 Window |
2014 gui_x11_get_wid() | 1988 gui_x11_get_wid(void) |
2015 { | 1989 { |
2016 return XtWindow(textArea); | 1990 return XtWindow(textArea); |
2017 } | 1991 } |
2018 | 1992 |
2019 #if defined(FEAT_BROWSE) || defined(PROTO) | 1993 #if defined(FEAT_BROWSE) || defined(PROTO) |
2020 /* | 1994 /* |
2021 * Put up a file requester. | 1995 * Put up a file requester. |
2022 * Returns the selected name in allocated memory, or NULL for Cancel. | 1996 * Returns the selected name in allocated memory, or NULL for Cancel. |
2023 */ | 1997 */ |
2024 char_u * | 1998 char_u * |
2025 gui_mch_browse(saving, title, dflt, ext, initdir, filter) | 1999 gui_mch_browse( |
2026 int saving UNUSED; /* select file to write */ | 2000 int saving UNUSED, /* select file to write */ |
2027 char_u *title; /* title for the window */ | 2001 char_u *title, /* title for the window */ |
2028 char_u *dflt; /* default name */ | 2002 char_u *dflt, /* default name */ |
2029 char_u *ext UNUSED; /* extension added */ | 2003 char_u *ext UNUSED, /* extension added */ |
2030 char_u *initdir; /* initial directory, NULL for current dir */ | 2004 char_u *initdir, /* initial directory, NULL for current dir */ |
2031 char_u *filter UNUSED; /* file name filter */ | 2005 char_u *filter UNUSED) /* file name filter */ |
2032 { | 2006 { |
2033 Position x, y; | 2007 Position x, y; |
2034 char_u dirbuf[MAXPATHL]; | 2008 char_u dirbuf[MAXPATHL]; |
2035 | 2009 |
2036 /* Concatenate "initdir" and "dflt". */ | 2010 /* Concatenate "initdir" and "dflt". */ |
2073 /* | 2047 /* |
2074 * Callback function for the textfield. When CR is hit this works like | 2048 * Callback function for the textfield. When CR is hit this works like |
2075 * hitting the "OK" button, ESC like "Cancel". | 2049 * hitting the "OK" button, ESC like "Cancel". |
2076 */ | 2050 */ |
2077 static void | 2051 static void |
2078 keyhit_callback(w, client_data, event, cont) | 2052 keyhit_callback( |
2079 Widget w UNUSED; | 2053 Widget w UNUSED, |
2080 XtPointer client_data UNUSED; | 2054 XtPointer client_data UNUSED, |
2081 XEvent *event; | 2055 XEvent *event, |
2082 Boolean *cont UNUSED; | 2056 Boolean *cont UNUSED) |
2083 { | 2057 { |
2084 char buf[2]; | 2058 char buf[2]; |
2085 | 2059 |
2086 if (XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1) | 2060 if (XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1) |
2087 { | 2061 { |
2091 dialogStatus = 0; | 2065 dialogStatus = 0; |
2092 } | 2066 } |
2093 } | 2067 } |
2094 | 2068 |
2095 static void | 2069 static void |
2096 butproc(w, client_data, call_data) | 2070 butproc( |
2097 Widget w UNUSED; | 2071 Widget w UNUSED, |
2098 XtPointer client_data; | 2072 XtPointer client_data, |
2099 XtPointer call_data UNUSED; | 2073 XtPointer call_data UNUSED) |
2100 { | 2074 { |
2101 dialogStatus = (int)(long)client_data + 1; | 2075 dialogStatus = (int)(long)client_data + 1; |
2102 } | 2076 } |
2103 | 2077 |
2104 /* | 2078 /* |
2105 * Function called when dialog window closed. | 2079 * Function called when dialog window closed. |
2106 */ | 2080 */ |
2107 static void | 2081 static void |
2108 dialog_wm_handler(w, client_data, event, dum) | 2082 dialog_wm_handler( |
2109 Widget w UNUSED; | 2083 Widget w UNUSED, |
2110 XtPointer client_data UNUSED; | 2084 XtPointer client_data UNUSED, |
2111 XEvent *event; | 2085 XEvent *event, |
2112 Boolean *dum UNUSED; | 2086 Boolean *dum UNUSED) |
2113 { | 2087 { |
2114 if (event->type == ClientMessage | 2088 if (event->type == ClientMessage |
2115 && (Atom)((XClientMessageEvent *)event)->data.l[0] == dialogatom) | 2089 && (Atom)((XClientMessageEvent *)event)->data.l[0] == dialogatom) |
2116 dialogStatus = 0; | 2090 dialogStatus = 0; |
2117 } | 2091 } |
2118 | 2092 |
2119 int | 2093 int |
2120 gui_mch_dialog(type, title, message, buttons, dfltbutton, textfield, ex_cmd) | 2094 gui_mch_dialog( |
2121 int type UNUSED; | 2095 int type UNUSED, |
2122 char_u *title; | 2096 char_u *title, |
2123 char_u *message; | 2097 char_u *message, |
2124 char_u *buttons; | 2098 char_u *buttons, |
2125 int dfltbutton UNUSED; | 2099 int dfltbutton UNUSED, |
2126 char_u *textfield; | 2100 char_u *textfield, |
2127 int ex_cmd UNUSED; | 2101 int ex_cmd UNUSED) |
2128 { | 2102 { |
2129 char_u *buts; | 2103 char_u *buts; |
2130 char_u *p, *next; | 2104 char_u *p, *next; |
2131 XtAppContext app; | 2105 XtAppContext app; |
2132 XEvent event; | 2106 XEvent event; |
2303 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_MENU) | 2277 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_MENU) |
2304 /* | 2278 /* |
2305 * Set the colors of Widget "id" to the menu colors. | 2279 * Set the colors of Widget "id" to the menu colors. |
2306 */ | 2280 */ |
2307 static void | 2281 static void |
2308 gui_athena_menu_colors(id) | 2282 gui_athena_menu_colors(Widget id) |
2309 Widget id; | |
2310 { | 2283 { |
2311 if (gui.menu_bg_pixel != INVALCOLOR) | 2284 if (gui.menu_bg_pixel != INVALCOLOR) |
2312 XtVaSetValues(id, XtNbackground, gui.menu_bg_pixel, NULL); | 2285 XtVaSetValues(id, XtNbackground, gui.menu_bg_pixel, NULL); |
2313 if (gui.menu_fg_pixel != INVALCOLOR) | 2286 if (gui.menu_fg_pixel != INVALCOLOR) |
2314 XtVaSetValues(id, XtNforeground, gui.menu_fg_pixel, NULL); | 2287 XtVaSetValues(id, XtNforeground, gui.menu_fg_pixel, NULL); |
2317 | 2290 |
2318 /* | 2291 /* |
2319 * Set the colors of Widget "id" to the scroll colors. | 2292 * Set the colors of Widget "id" to the scroll colors. |
2320 */ | 2293 */ |
2321 static void | 2294 static void |
2322 gui_athena_scroll_colors(id) | 2295 gui_athena_scroll_colors(Widget id) |
2323 Widget id; | |
2324 { | 2296 { |
2325 if (gui.scroll_bg_pixel != INVALCOLOR) | 2297 if (gui.scroll_bg_pixel != INVALCOLOR) |
2326 XtVaSetValues(id, XtNbackground, gui.scroll_bg_pixel, NULL); | 2298 XtVaSetValues(id, XtNbackground, gui.scroll_bg_pixel, NULL); |
2327 if (gui.scroll_fg_pixel != INVALCOLOR) | 2299 if (gui.scroll_fg_pixel != INVALCOLOR) |
2328 XtVaSetValues(id, XtNforeground, gui.scroll_fg_pixel, NULL); | 2300 XtVaSetValues(id, XtNforeground, gui.scroll_fg_pixel, NULL); |