Mercurial > emacs
comparison lwlib/xlwmenu.c @ 109351:c8a969d13eda
merge trunk
author | Kenichi Handa <handa@etlken> |
---|---|
date | Fri, 09 Jul 2010 15:55:27 +0900 |
parents | 33021b778d4d |
children | 8adb5d28e463 |
comparison
equal
deleted
inserted
replaced
109350:c11d07f3d731 | 109351:c8a969d13eda |
---|---|
185 }; | 185 }; |
186 #undef offset | 186 #undef offset |
187 | 187 |
188 static Boolean XlwMenuSetValues(Widget current, Widget request, Widget new, | 188 static Boolean XlwMenuSetValues(Widget current, Widget request, Widget new, |
189 ArgList args, Cardinal *num_args); | 189 ArgList args, Cardinal *num_args); |
190 static void XlwMenuRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes); | 190 static void XlwMenuRealize(Widget, Mask *, XSetWindowAttributes *); |
191 static void XlwMenuResize(Widget w); | 191 static void XlwMenuResize(Widget w); |
192 static void XlwMenuInitialize(Widget request, Widget mw, ArgList args, Cardinal *num_args); | 192 static void XlwMenuInitialize(Widget, Widget, ArgList, Cardinal *); |
193 static void XlwMenuRedisplay(Widget w, XEvent *ev, Region region); | 193 static void XlwMenuRedisplay(Widget w, XEvent *ev, Region region); |
194 static void XlwMenuDestroy(Widget w); | 194 static void XlwMenuDestroy(Widget w); |
195 static void XlwMenuClassInitialize(void); | 195 static void XlwMenuClassInitialize(void); |
196 static void Start(Widget w, XEvent *ev, String *params, Cardinal *num_params); | 196 static void Start(Widget w, XEvent *ev, String *params, Cardinal *num_params); |
197 static void Drag(Widget w, XEvent *ev, String *params, Cardinal *num_params); | 197 static void Drag(Widget w, XEvent *ev, String *params, Cardinal *num_params); |
471 return (char*)val->toolkit_data; | 471 return (char*)val->toolkit_data; |
472 } | 472 } |
473 | 473 |
474 /* Returns the sizes of an item */ | 474 /* Returns the sizes of an item */ |
475 static void | 475 static void |
476 size_menu_item (mw, val, horizontal_p, label_width, rest_width, button_width, | 476 size_menu_item (XlwMenuWidget mw, |
477 height) | 477 widget_value* val, |
478 XlwMenuWidget mw; | 478 int horizontal_p, |
479 widget_value* val; | 479 int* label_width, |
480 int horizontal_p; | 480 int* rest_width, |
481 int* label_width; | 481 int* button_width, |
482 int* rest_width; | 482 int* height) |
483 int* button_width; | |
484 int* height; | |
485 { | 483 { |
486 enum menu_separator separator; | 484 enum menu_separator separator; |
487 | 485 |
488 if (lw_separator_p (val->name, &separator, 0)) | 486 if (lw_separator_p (val->name, &separator, 0)) |
489 { | 487 { |
523 } | 521 } |
524 | 522 |
525 static void | 523 static void |
526 size_menu (XlwMenuWidget mw, int level) | 524 size_menu (XlwMenuWidget mw, int level) |
527 { | 525 { |
528 unsigned int label_width = 0; | 526 int label_width = 0; |
529 int rest_width = 0; | 527 int rest_width = 0; |
530 int button_width = 0; | 528 int button_width = 0; |
531 int max_rest_width = 0; | 529 int max_rest_width = 0; |
532 int max_button_width = 0; | 530 int max_button_width = 0; |
533 unsigned int height = 0; | 531 int height = 0; |
534 int horizontal_p = mw->menu.horizontal && (level == 0); | 532 int horizontal_p = mw->menu.horizontal && (level == 0); |
535 widget_value* val; | 533 widget_value* val; |
536 window_state* ws; | 534 window_state* ws; |
537 | 535 |
538 if (level >= mw->menu.old_depth) | 536 if (level >= mw->menu.old_depth) |
587 | 585 |
588 | 586 |
589 /* Display code */ | 587 /* Display code */ |
590 | 588 |
591 static void | 589 static void |
592 draw_arrow (XlwMenuWidget mw, Window window, GC gc, int x, int y, int width, int down_p) | 590 draw_arrow (XlwMenuWidget mw, |
591 Window window, | |
592 GC gc, | |
593 int x, | |
594 int y, | |
595 int width, | |
596 int down_p) | |
593 { | 597 { |
594 Display *dpy = XtDisplay (mw); | 598 Display *dpy = XtDisplay (mw); |
595 GC top_gc = mw->menu.shadow_top_gc; | 599 GC top_gc = mw->menu.shadow_top_gc; |
596 GC bottom_gc = mw->menu.shadow_bottom_gc; | 600 GC bottom_gc = mw->menu.shadow_bottom_gc; |
597 int thickness = mw->menu.shadow_thickness; | 601 int thickness = mw->menu.shadow_thickness; |
644 } | 648 } |
645 | 649 |
646 | 650 |
647 | 651 |
648 static void | 652 static void |
649 draw_shadow_rectangle (XlwMenuWidget mw, Window window, int x, int y, int width, int height, int erase_p, int down_p) | 653 draw_shadow_rectangle (XlwMenuWidget mw, |
654 Window window, | |
655 int x, | |
656 int y, | |
657 int width, | |
658 int height, | |
659 int erase_p, | |
660 int down_p) | |
650 { | 661 { |
651 Display *dpy = XtDisplay (mw); | 662 Display *dpy = XtDisplay (mw); |
652 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; | 663 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; |
653 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; | 664 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; |
654 int thickness = mw->menu.shadow_thickness; | 665 int thickness = mw->menu.shadow_thickness; |
700 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); | 711 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); |
701 } | 712 } |
702 | 713 |
703 | 714 |
704 static void | 715 static void |
705 draw_shadow_rhombus (XlwMenuWidget mw, Window window, int x, int y, int width, int height, int erase_p, int down_p) | 716 draw_shadow_rhombus (XlwMenuWidget mw, |
717 Window window, | |
718 int x, | |
719 int y, | |
720 int width, | |
721 int height, | |
722 int erase_p, | |
723 int down_p) | |
706 { | 724 { |
707 Display *dpy = XtDisplay (mw); | 725 Display *dpy = XtDisplay (mw); |
708 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; | 726 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; |
709 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; | 727 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; |
710 int thickness = mw->menu.shadow_thickness; | 728 int thickness = mw->menu.shadow_thickness; |
794 /* Draw a menu separator on widget MW, X window WINDOW. X/Y is the | 812 /* Draw a menu separator on widget MW, X window WINDOW. X/Y is the |
795 top-left corner of the menu item. WIDTH is the width of the | 813 top-left corner of the menu item. WIDTH is the width of the |
796 separator to draw. TYPE is the separator type. */ | 814 separator to draw. TYPE is the separator type. */ |
797 | 815 |
798 static void | 816 static void |
799 draw_separator (XlwMenuWidget mw, Window window, int x, int y, int width, enum menu_separator type) | 817 draw_separator (XlwMenuWidget mw, |
818 Window window, | |
819 int x, | |
820 int y, | |
821 int width, | |
822 enum menu_separator type) | |
800 { | 823 { |
801 Display *dpy = XtDisplay (mw); | 824 Display *dpy = XtDisplay (mw); |
802 XGCValues xgcv; | 825 XGCValues xgcv; |
803 | 826 |
804 switch (type) | 827 switch (type) |
944 | 967 |
945 /* Display the menu item and increment where.x and where.y to show how large | 968 /* Display the menu item and increment where.x and where.y to show how large |
946 the menu item was. */ | 969 the menu item was. */ |
947 | 970 |
948 static void | 971 static void |
949 display_menu_item (mw, val, ws, where, highlighted_p, horizontal_p, | 972 display_menu_item (XlwMenuWidget mw, |
950 just_compute_p) | 973 widget_value* val, |
951 XlwMenuWidget mw; | 974 window_state* ws, |
952 widget_value* val; | 975 XPoint* where, |
953 window_state* ws; | 976 Boolean highlighted_p, |
954 XPoint* where; | 977 Boolean horizontal_p, |
955 Boolean highlighted_p; | 978 Boolean just_compute_p) |
956 Boolean horizontal_p; | |
957 Boolean just_compute_p; | |
958 { | 979 { |
959 GC deco_gc; | 980 GC deco_gc; |
960 GC text_gc; | 981 GC text_gc; |
961 int font_height = MENU_FONT_HEIGHT (mw); | 982 int font_height = MENU_FONT_HEIGHT (mw); |
962 int font_ascent = MENU_FONT_ASCENT (mw); | 983 int font_ascent = MENU_FONT_ASCENT (mw); |
1135 where->x += width; | 1156 where->x += width; |
1136 where->y += height; | 1157 where->y += height; |
1137 } | 1158 } |
1138 | 1159 |
1139 static void | 1160 static void |
1140 display_menu (XlwMenuWidget mw, int level, Boolean just_compute_p, XPoint *highlighted_pos, XPoint *hit, widget_value **hit_return) | 1161 display_menu (XlwMenuWidget mw, |
1162 int level, | |
1163 Boolean just_compute_p, | |
1164 XPoint *highlighted_pos, | |
1165 XPoint *hit, | |
1166 widget_value **hit_return) | |
1141 { | 1167 { |
1142 widget_value* val; | 1168 widget_value* val; |
1143 widget_value* following_item; | 1169 widget_value* following_item; |
1144 window_state* ws; | 1170 window_state* ws; |
1145 XPoint where; | 1171 XPoint where; |
1343 return i < mw->menu.windows_length; | 1369 return i < mw->menu.windows_length; |
1344 } | 1370 } |
1345 | 1371 |
1346 /* Make the window fit in the screen */ | 1372 /* Make the window fit in the screen */ |
1347 static void | 1373 static void |
1348 fit_to_screen (XlwMenuWidget mw, window_state *ws, window_state *previous_ws, Boolean horizontal_p) | 1374 fit_to_screen (XlwMenuWidget mw, |
1375 window_state *ws, | |
1376 window_state *previous_ws, | |
1377 Boolean horizontal_p) | |
1349 { | 1378 { |
1350 unsigned int screen_width = WidthOfScreen (XtScreen (mw)); | 1379 unsigned int screen_width = WidthOfScreen (XtScreen (mw)); |
1351 unsigned int screen_height = HeightOfScreen (XtScreen (mw)); | 1380 unsigned int screen_height = HeightOfScreen (XtScreen (mw)); |
1352 /* 1 if we are unable to avoid an overlap between | 1381 /* 1 if we are unable to avoid an overlap between |
1353 this menu and the parent menu in the X dimension. */ | 1382 this menu and the parent menu in the X dimension. */ |
1517 if (i >= new_depth || (i > 0 && !new_stack[i]->contents)) | 1546 if (i >= new_depth || (i > 0 && !new_stack[i]->contents)) |
1518 XtPopdown (windows[i].w); | 1547 XtPopdown (windows[i].w); |
1519 } | 1548 } |
1520 | 1549 |
1521 static Boolean | 1550 static Boolean |
1522 motion_event_is_in_menu (XlwMenuWidget mw, XMotionEvent *ev, int level, XPoint *relative_pos) | 1551 motion_event_is_in_menu (XlwMenuWidget mw, |
1552 XMotionEvent *ev, | |
1553 int level, | |
1554 XPoint *relative_pos) | |
1523 { | 1555 { |
1524 window_state* ws = &mw->menu.windows [level]; | 1556 window_state* ws = &mw->menu.windows [level]; |
1525 int shadow = level == 0 ? 0 : mw->menu.shadow_thickness; | 1557 int shadow = level == 0 ? 0 : mw->menu.shadow_thickness; |
1526 int x = ws->x + shadow; | 1558 int x = ws->x + shadow; |
1527 int y = ws->y + shadow; | 1559 int y = ws->y + shadow; |
1530 return (x - shadow < ev->x_root && ev->x_root < x + ws->width | 1562 return (x - shadow < ev->x_root && ev->x_root < x + ws->width |
1531 && y - shadow < ev->y_root && ev->y_root < y + ws->height); | 1563 && y - shadow < ev->y_root && ev->y_root < y + ws->height); |
1532 } | 1564 } |
1533 | 1565 |
1534 static Boolean | 1566 static Boolean |
1535 map_event_to_widget_value (XlwMenuWidget mw, XMotionEvent *ev, widget_value **val, int *level) | 1567 map_event_to_widget_value (XlwMenuWidget mw, |
1568 XMotionEvent *ev, | |
1569 widget_value **val, | |
1570 int *level) | |
1536 { | 1571 { |
1537 int i; | 1572 int i; |
1538 XPoint relative_pos; | 1573 XPoint relative_pos; |
1539 window_state* ws; | 1574 window_state* ws; |
1540 int inside = 0; | 1575 int inside = 0; |