Mercurial > emacs
annotate lwlib/xlwmenu.c @ 74182:c82e46a2e888
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 25 Nov 2006 13:29:40 +0000 |
parents | b90abedf3b79 |
children | d263801b3ca8 c44562301a11 a8190f7e546e |
rev | line source |
---|---|
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1 /* Implements a lightweight menubar widget. |
5626 | 2 Copyright (C) 1992 Lucid, Inc. |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65713
diff
changeset
|
3 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
5626 | 4 |
5 This file is part of the Lucid Widget Library. | |
6 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
7 The Lucid Widget Library is free software; you can redistribute it and/or |
5626 | 8 modify it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 2, or (at your option) | |
10 any later version. | |
11 | |
12 The Lucid Widget Library is distributed in the hope that it will be useful, | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5626 | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
15742 | 18 along with GNU Emacs; see the file COPYING. If not, write to the |
64083 | 19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
5626 | 21 |
22 /* Created by devin@lucid.com */ | |
23 | |
26087
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25526
diff
changeset
|
24 #ifdef HAVE_CONFIG_H |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25526
diff
changeset
|
25 #include <config.h> |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25526
diff
changeset
|
26 #endif |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25526
diff
changeset
|
27 |
51143
d4196d00eba5
Include lisp.h, not ../src/lisp.h.
Dave Love <fx@gnu.org>
parents:
49600
diff
changeset
|
28 #include "lisp.h" |
41767 | 29 |
5626 | 30 #include <stdio.h> |
31 | |
32 #include <sys/types.h> | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
33 #if (defined __sun) && !(defined SUNOS41) |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
34 #define SUNOS41 |
5626 | 35 #include <X11/Xos.h> |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
36 #undef SUNOS41 |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
37 #else |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
38 #include <X11/Xos.h> |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
39 #endif |
5626 | 40 #include <X11/IntrinsicP.h> |
9033 | 41 #include <X11/ObjectP.h> |
5626 | 42 #include <X11/StringDefs.h> |
43 #include <X11/cursorfont.h> | |
44 #include "xlwmenuP.h" | |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
45 |
29469
f9b5fe053f7c
(x_alloc_nearest_color_for_widget, x_catch_errors, x_uncatch_errors)
Dave Love <fx@gnu.org>
parents:
27988
diff
changeset
|
46 #ifdef emacs |
30324
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
47 |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
48 /* Defined in xfns.c. When config.h defines `static' as empty, we get |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
49 redefinition errors when gray_bitmap is included more than once, so |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
50 we're referring to the one include in xfns.c here. */ |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
51 |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
52 extern int gray_bitmap_width; |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
53 extern int gray_bitmap_height; |
34557
b9586137049e
(gray_bitmap_bits): Remove `unsigned' from
Dave Love <fx@gnu.org>
parents:
34436
diff
changeset
|
54 extern char *gray_bitmap_bits; |
30324
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
55 |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
56 #include "xterm.h" |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
57 |
30324
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
58 #else /* not emacs */ |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
59 |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
60 #include <X11/bitmaps/gray> |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
61 #define gray_bitmap_width gray_width |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
62 #define gray_bitmap_height gray_height |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
63 #define gray_bitmap_bits gray_bits |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
64 |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
65 #endif /* not emacs */ |
8860 | 66 |
67 static int pointer_grabbed; | |
68 static XEvent menu_post_event; | |
5626 | 69 |
9746
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
70 XFontStruct *xlwmenu_default_font; |
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
71 |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
72 static char |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
73 xlwMenuTranslations [] = |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
74 "<BtnDown>: start()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
75 <Motion>: drag()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
76 <BtnUp>: select()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
77 <Key>Shift_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
78 <Key>Shift_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
79 <Key>Meta_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
80 <Key>Meta_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
81 <Key>Control_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
82 <Key>Control_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
83 <Key>Hyper_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
84 <Key>Hyper_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
85 <Key>Super_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
86 <Key>Super_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
87 <Key>Alt_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
88 <Key>Alt_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
89 <Key>Caps_Lock: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
90 <Key>Shift_Lock: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
91 <KeyUp>Shift_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
92 <KeyUp>Shift_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
93 <KeyUp>Meta_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
94 <KeyUp>Meta_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
95 <KeyUp>Control_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
96 <KeyUp>Control_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
97 <KeyUp>Hyper_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
98 <KeyUp>Hyper_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
99 <KeyUp>Super_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
100 <KeyUp>Super_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
101 <KeyUp>Alt_L: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
102 <KeyUp>Alt_R: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
103 <KeyUp>Caps_Lock: nothing()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
104 <KeyUp>Shift_Lock:nothing()\n\ |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
105 <Key>Return: select()\n\ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
106 <Key>Down: down()\n\ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
107 <Key>Up: up()\n\ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
108 <Key>Left: left()\n\ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
109 <Key>Right: right()\n\ |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
110 <Key>: key()\n\ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
111 <KeyUp>: key()\n\ |
5626 | 112 "; |
113 | |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
114 /* FIXME: Space should toggle toggleable menu item but not remove the menu |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
115 so you can toggle the next one without entering the menu again. */ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
116 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
117 /* FIXME: Should ESC close one level of menu structure or the complete menu? */ |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
118 |
44966 | 119 /* FIXME: F10 should enter the menu, the first one in the menu-bar. */ |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
120 |
5626 | 121 #define offset(field) XtOffset(XlwMenuWidget, field) |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
122 static XtResource |
5626 | 123 xlwMenuResources[] = |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
124 { |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
125 #ifdef HAVE_X_I18N |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
126 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
127 offset(menu.fontSet), XtRFontSet, NULL}, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
128 #endif |
5626 | 129 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
130 offset(menu.font), XtRString, "XtDefaultFont"}, |
5626 | 131 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), |
132 offset(menu.foreground), XtRString, "XtDefaultForeground"}, | |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
133 {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
134 offset(menu.disabled_foreground), XtRString, (XtPointer)NULL}, |
5626 | 135 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), |
136 offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, | |
137 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), | |
44966 | 138 offset(menu.margin), XtRImmediate, (XtPointer)1}, |
5626 | 139 {XtNhorizontalSpacing, XtCMargin, XtRDimension, sizeof(Dimension), |
140 offset(menu.horizontal_spacing), XtRImmediate, (XtPointer)3}, | |
141 {XtNverticalSpacing, XtCMargin, XtRDimension, sizeof(Dimension), | |
44966 | 142 offset(menu.vertical_spacing), XtRImmediate, (XtPointer)2}, |
5626 | 143 {XtNarrowSpacing, XtCMargin, XtRDimension, sizeof(Dimension), |
144 offset(menu.arrow_spacing), XtRImmediate, (XtPointer)10}, | |
145 | |
8860 | 146 {XmNshadowThickness, XmCShadowThickness, XtRDimension, |
5626 | 147 sizeof (Dimension), offset (menu.shadow_thickness), |
44966 | 148 XtRImmediate, (XtPointer)1}, |
5626 | 149 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel), |
150 offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1}, | |
151 {XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel), | |
152 offset (menu.bottom_shadow_color), XtRImmediate, (XtPointer)-1}, | |
153 {XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap, sizeof (Pixmap), | |
154 offset (menu.top_shadow_pixmap), XtRImmediate, (XtPointer)None}, | |
155 {XmNbottomShadowPixmap, XmCBottomShadowPixmap, XtRPixmap, sizeof (Pixmap), | |
156 offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None}, | |
157 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
158 {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer), |
5626 | 159 offset(menu.open), XtRCallback, (XtPointer)NULL}, |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
160 {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer), |
5626 | 161 offset(menu.select), XtRCallback, (XtPointer)NULL}, |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
162 {XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer), |
27338
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
163 offset(menu.highlight), XtRCallback, (XtPointer)NULL}, |
5626 | 164 {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer), |
165 offset(menu.contents), XtRImmediate, (XtPointer)NULL}, | |
166 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), | |
167 offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"}, | |
168 {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int), | |
169 offset(menu.horizontal), XtRImmediate, (XtPointer)True}, | |
170 }; | |
171 #undef offset | |
172 | |
173 static Boolean XlwMenuSetValues(); | |
174 static void XlwMenuRealize(); | |
175 static void XlwMenuRedisplay(); | |
176 static void XlwMenuResize(); | |
177 static void XlwMenuInitialize(); | |
178 static void XlwMenuRedisplay(); | |
179 static void XlwMenuDestroy(); | |
180 static void XlwMenuClassInitialize(); | |
181 static void Start(); | |
182 static void Drag(); | |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
183 static void Down(); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
184 static void Up(); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
185 static void Left(); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
186 static void Right(); |
5626 | 187 static void Select(); |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
188 static void Key(); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
189 static void Nothing(); |
48479 | 190 static int separator_height __P ((enum menu_separator)); |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
191 static void pop_up_menu __P ((XlwMenuWidget, XButtonPressedEvent *)); |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
192 |
5626 | 193 |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
194 static XtActionsRec |
5626 | 195 xlwMenuActionsList [] = |
196 { | |
197 {"start", Start}, | |
198 {"drag", Drag}, | |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
199 {"down", Down}, |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
200 {"up", Up}, |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
201 {"left", Left}, |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
202 {"right", Right}, |
5626 | 203 {"select", Select}, |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
204 {"key", Key}, |
59100
768cf68dcd0a
* xlwmenu.c (xlwMenuActionsList): Install MenuGadgetEscape as an
Jan Djärv <jan.h.d@swipnet.se>
parents:
57842
diff
changeset
|
205 {"MenuGadgetEscape", Key}, /* Compatibility with Lesstif/Motif. */ |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
206 {"nothing", Nothing}, |
5626 | 207 }; |
208 | |
209 #define SuperClass ((CoreWidgetClass)&coreClassRec) | |
210 | |
211 XlwMenuClassRec xlwMenuClassRec = | |
212 { | |
213 { /* CoreClass fields initialization */ | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
214 (WidgetClass) SuperClass, /* superclass */ |
5626 | 215 "XlwMenu", /* class_name */ |
216 sizeof(XlwMenuRec), /* size */ | |
217 XlwMenuClassInitialize, /* class_initialize */ | |
218 NULL, /* class_part_initialize */ | |
219 FALSE, /* class_inited */ | |
220 XlwMenuInitialize, /* initialize */ | |
221 NULL, /* initialize_hook */ | |
222 XlwMenuRealize, /* realize */ | |
223 xlwMenuActionsList, /* actions */ | |
224 XtNumber(xlwMenuActionsList), /* num_actions */ | |
225 xlwMenuResources, /* resources */ | |
226 XtNumber(xlwMenuResources), /* resource_count */ | |
227 NULLQUARK, /* xrm_class */ | |
228 TRUE, /* compress_motion */ | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
229 XtExposeCompressMaximal, /* compress_exposure */ |
5626 | 230 TRUE, /* compress_enterleave */ |
231 FALSE, /* visible_interest */ | |
232 XlwMenuDestroy, /* destroy */ | |
233 XlwMenuResize, /* resize */ | |
234 XlwMenuRedisplay, /* expose */ | |
235 XlwMenuSetValues, /* set_values */ | |
236 NULL, /* set_values_hook */ | |
237 XtInheritSetValuesAlmost, /* set_values_almost */ | |
238 NULL, /* get_values_hook */ | |
239 NULL, /* accept_focus */ | |
240 XtVersion, /* version */ | |
241 NULL, /* callback_private */ | |
242 xlwMenuTranslations, /* tm_table */ | |
243 XtInheritQueryGeometry, /* query_geometry */ | |
244 XtInheritDisplayAccelerator, /* display_accelerator */ | |
245 NULL /* extension */ | |
246 }, /* XlwMenuClass fields initialization */ | |
247 { | |
248 0 /* dummy */ | |
249 }, | |
250 }; | |
251 | |
252 WidgetClass xlwMenuWidgetClass = (WidgetClass) &xlwMenuClassRec; | |
253 | |
8860 | 254 int submenu_destroyed; |
255 | |
44931
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
256 /* For debug, if installation-directory is non-nil this is not an installed |
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
257 Emacs. In that case we do not grab the keyboard to make it easier to |
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
258 debug. */ |
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
259 #define GRAB_KEYBOARD (EQ (Vinstallation_directory, Qnil)) |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
260 |
8860 | 261 static int next_release_must_exit; |
262 | |
5626 | 263 /* Utilities */ |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
264 |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
265 /* Ungrab pointer and keyboard */ |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
266 static void |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
267 ungrab_all (w, ungrabtime) |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
268 Widget w; |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
269 Time ungrabtime; |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
270 { |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
271 XtUngrabPointer (w, ungrabtime); |
44931
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
272 if (GRAB_KEYBOARD) XtUngrabKeyboard (w, ungrabtime); |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
273 } |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
274 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
275 /* Like abort, but remove grabs from widget W before. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
276 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
277 static void |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
278 abort_gracefully (w) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
279 Widget w; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
280 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
281 if (XtIsShell (XtParent (w))) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
282 XtRemoveGrab (w); |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
283 ungrab_all (w, CurrentTime); |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
284 abort (); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
285 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
286 |
5626 | 287 static void |
8860 | 288 push_new_stack (mw, val) |
289 XlwMenuWidget mw; | |
290 widget_value* val; | |
5626 | 291 { |
292 if (!mw->menu.new_stack) | |
293 { | |
294 mw->menu.new_stack_length = 10; | |
295 mw->menu.new_stack = | |
296 (widget_value**)XtCalloc (mw->menu.new_stack_length, | |
297 sizeof (widget_value*)); | |
298 } | |
299 else if (mw->menu.new_depth == mw->menu.new_stack_length) | |
300 { | |
301 mw->menu.new_stack_length *= 2; | |
302 mw->menu.new_stack = | |
303 (widget_value**)XtRealloc ((char*)mw->menu.new_stack, | |
304 mw->menu.new_stack_length * sizeof (widget_value*)); | |
305 } | |
306 mw->menu.new_stack [mw->menu.new_depth++] = val; | |
307 } | |
308 | |
309 static void | |
8860 | 310 pop_new_stack_if_no_contents (mw) |
311 XlwMenuWidget mw; | |
5626 | 312 { |
48929
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
313 if (mw->menu.new_depth > 1) |
5626 | 314 { |
315 if (!mw->menu.new_stack [mw->menu.new_depth - 1]->contents) | |
316 mw->menu.new_depth -= 1; | |
317 } | |
318 } | |
319 | |
320 static void | |
8860 | 321 make_old_stack_space (mw, n) |
322 XlwMenuWidget mw; | |
323 int n; | |
5626 | 324 { |
325 if (!mw->menu.old_stack) | |
326 { | |
327 mw->menu.old_stack_length = 10; | |
328 mw->menu.old_stack = | |
329 (widget_value**)XtCalloc (mw->menu.old_stack_length, | |
330 sizeof (widget_value*)); | |
331 } | |
332 else if (mw->menu.old_stack_length < n) | |
333 { | |
334 mw->menu.old_stack_length *= 2; | |
335 mw->menu.old_stack = | |
336 (widget_value**)XtRealloc ((char*)mw->menu.old_stack, | |
337 mw->menu.old_stack_length * sizeof (widget_value*)); | |
338 } | |
339 } | |
340 | |
341 /* Size code */ | |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
342 static int |
8860 | 343 string_width (mw, s) |
344 XlwMenuWidget mw; | |
345 char *s; | |
5626 | 346 { |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
347 XCharStruct xcs; |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
348 int drop; |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
349 #ifdef HAVE_X_I18N |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
350 XRectangle ink, logical; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
351 if (mw->menu.fontSet) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
352 { |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
353 XmbTextExtents (mw->menu.fontSet, s, strlen (s), &ink, &logical); |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
354 return logical.width; |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
355 } |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
356 #endif |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
357 |
5626 | 358 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs); |
359 return xcs.width; | |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
360 |
5626 | 361 } |
362 | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
363 #ifdef HAVE_X_I18N |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
364 #define MENU_FONT_HEIGHT(mw) \ |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
365 ((mw)->menu.fontSet != NULL \ |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
366 ? (mw)->menu.font_extents->max_logical_extent.height \ |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
367 : (mw)->menu.font->ascent + (mw)->menu.font->descent) |
60700
2610d09357c8
(MENU_FONT_ASCENT) [HAVE_X_I18N]: Try to be more correct.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60698
diff
changeset
|
368 #define MENU_FONT_ASCENT(mw) \ |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
369 ((mw)->menu.fontSet != NULL \ |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
370 ? - (mw)->menu.font_extents->max_logical_extent.y \ |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
371 : (mw)->menu.font->ascent) |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
372 #else |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
373 #define MENU_FONT_HEIGHT(mw) \ |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
374 ((mw)->menu.font->ascent + (mw)->menu.font->descent) |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
375 #define MENU_FONT_ASCENT(mw) ((mw)->menu.font->ascent) |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
376 #endif |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
377 |
5626 | 378 static int |
8860 | 379 arrow_width (mw) |
380 XlwMenuWidget mw; | |
5626 | 381 { |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
382 return (MENU_FONT_ASCENT (mw) * 3/4) | 1; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
383 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
384 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
385 /* Return the width of toggle buttons of widget MW. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
386 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
387 static int |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
388 toggle_button_width (mw) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
389 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
390 { |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
391 return (MENU_FONT_HEIGHT (mw) * 2 / 3) | 1; |
5626 | 392 } |
393 | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
394 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
395 /* Return the width of radio buttons of widget MW. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
396 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
397 static int |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
398 radio_button_width (mw) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
399 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
400 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
401 return toggle_button_width (mw) * 1.41; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
402 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
403 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
404 |
5626 | 405 static XtResource |
406 nameResource[] = | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
407 { |
5626 | 408 {"labelString", "LabelString", XtRString, sizeof(String), |
409 0, XtRImmediate, 0}, | |
410 }; | |
411 | |
412 static char* | |
8860 | 413 resource_widget_value (mw, val) |
414 XlwMenuWidget mw; | |
415 widget_value *val; | |
5626 | 416 { |
417 if (!val->toolkit_data) | |
418 { | |
419 char* resourced_name = NULL; | |
420 char* complete_name; | |
421 XtGetSubresources ((Widget) mw, | |
422 (XtPointer) &resourced_name, | |
423 val->name, val->name, | |
424 nameResource, 1, NULL, 0); | |
425 if (!resourced_name) | |
426 resourced_name = val->name; | |
427 if (!val->value) | |
5654
f84dac6453db
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
428 { |
f84dac6453db
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
429 complete_name = (char *) XtMalloc (strlen (resourced_name) + 1); |
f84dac6453db
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
430 strcpy (complete_name, resourced_name); |
f84dac6453db
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
431 } |
5626 | 432 else |
433 { | |
434 int complete_length = | |
435 strlen (resourced_name) + strlen (val->value) + 2; | |
436 complete_name = XtMalloc (complete_length); | |
437 *complete_name = 0; | |
438 strcat (complete_name, resourced_name); | |
439 strcat (complete_name, " "); | |
440 strcat (complete_name, val->value); | |
441 } | |
442 | |
443 val->toolkit_data = complete_name; | |
444 val->free_toolkit_data = True; | |
445 } | |
446 return (char*)val->toolkit_data; | |
447 } | |
448 | |
449 /* Returns the sizes of an item */ | |
450 static void | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
451 size_menu_item (mw, val, horizontal_p, label_width, rest_width, button_width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
452 height) |
8860 | 453 XlwMenuWidget mw; |
454 widget_value* val; | |
455 int horizontal_p; | |
456 int* label_width; | |
457 int* rest_width; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
458 int* button_width; |
8860 | 459 int* height; |
5626 | 460 { |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
461 enum menu_separator separator; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
462 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
463 if (lw_separator_p (val->name, &separator, 0)) |
5626 | 464 { |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
465 *height = separator_height (separator); |
5626 | 466 *label_width = 1; |
467 *rest_width = 0; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
468 *button_width = 0; |
5626 | 469 } |
470 else | |
471 { | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
472 *height = MENU_FONT_HEIGHT (mw) |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
473 + 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
474 |
5626 | 475 *label_width = |
476 string_width (mw, resource_widget_value (mw, val)) | |
477 + mw->menu.horizontal_spacing + mw->menu.shadow_thickness; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
478 |
5626 | 479 *rest_width = mw->menu.horizontal_spacing + mw->menu.shadow_thickness; |
480 if (!horizontal_p) | |
481 { | |
482 if (val->contents) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
483 /* Add width of the arrow displayed for submenus. */ |
5626 | 484 *rest_width += arrow_width (mw) + mw->menu.arrow_spacing; |
485 else if (val->key) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
486 /* Add width of key equivalent string. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
487 *rest_width += (string_width (mw, val->key) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
488 + mw->menu.arrow_spacing); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
489 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
490 if (val->button_type == BUTTON_TYPE_TOGGLE) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
491 *button_width = (toggle_button_width (mw) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
492 + mw->menu.horizontal_spacing); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
493 else if (val->button_type == BUTTON_TYPE_RADIO) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
494 *button_width = (radio_button_width (mw) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
495 + mw->menu.horizontal_spacing); |
5626 | 496 } |
497 } | |
498 } | |
499 | |
500 static void | |
8860 | 501 size_menu (mw, level) |
502 XlwMenuWidget mw; | |
503 int level; | |
5626 | 504 { |
11461
65c12e57f119
(size_menu): Make height and label_width unsigned.
Richard M. Stallman <rms@gnu.org>
parents:
9746
diff
changeset
|
505 unsigned int label_width = 0; |
5626 | 506 int rest_width = 0; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
507 int button_width = 0; |
5626 | 508 int max_rest_width = 0; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
509 int max_button_width = 0; |
11461
65c12e57f119
(size_menu): Make height and label_width unsigned.
Richard M. Stallman <rms@gnu.org>
parents:
9746
diff
changeset
|
510 unsigned int height = 0; |
5626 | 511 int horizontal_p = mw->menu.horizontal && (level == 0); |
512 widget_value* val; | |
513 window_state* ws; | |
514 | |
515 if (level >= mw->menu.old_depth) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
516 abort_gracefully ((Widget) mw); |
5626 | 517 |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
518 ws = &mw->menu.windows [level]; |
5626 | 519 ws->width = 0; |
520 ws->height = 0; | |
521 ws->label_width = 0; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
522 ws->button_width = 0; |
5626 | 523 |
524 for (val = mw->menu.old_stack [level]->contents; val; val = val->next) | |
525 { | |
526 size_menu_item (mw, val, horizontal_p, &label_width, &rest_width, | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
527 &button_width, &height); |
5626 | 528 if (horizontal_p) |
529 { | |
530 ws->width += label_width + rest_width; | |
531 if (height > ws->height) | |
532 ws->height = height; | |
533 } | |
534 else | |
535 { | |
536 if (label_width > ws->label_width) | |
537 ws->label_width = label_width; | |
538 if (rest_width > max_rest_width) | |
539 max_rest_width = rest_width; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
540 if (button_width > max_button_width) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
541 max_button_width = button_width; |
5626 | 542 ws->height += height; |
543 } | |
544 } | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
545 |
5626 | 546 if (horizontal_p) |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
547 ws->label_width = ws->button_width = 0; |
5626 | 548 else |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
549 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
550 ws->width = ws->label_width + max_rest_width + max_button_width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
551 ws->button_width = max_button_width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
552 } |
5626 | 553 |
554 ws->width += 2 * mw->menu.shadow_thickness; | |
555 ws->height += 2 * mw->menu.shadow_thickness; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
556 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
557 if (horizontal_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
558 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
559 ws->width += 2 * mw->menu.margin; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
560 ws->height += 2 * mw->menu.margin; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
561 } |
5626 | 562 } |
563 | |
564 | |
565 /* Display code */ | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
566 |
5626 | 567 static void |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
568 draw_arrow (mw, window, gc, x, y, width, down_p) |
8860 | 569 XlwMenuWidget mw; |
570 Window window; | |
571 GC gc; | |
572 int x; | |
573 int y; | |
574 int width; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
575 int down_p; |
5626 | 576 { |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
577 Display *dpy = XtDisplay (mw); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
578 GC top_gc = mw->menu.shadow_top_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
579 GC bottom_gc = mw->menu.shadow_bottom_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
580 int thickness = mw->menu.shadow_thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
581 int height = width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
582 XPoint pt[10]; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
583 /* alpha = atan (0.5) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
584 factor = (1 + sin (alpha)) / cos (alpha) */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
585 double factor = 1.62; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
586 int thickness2 = thickness * factor; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
587 |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
588 y += (MENU_FONT_HEIGHT (mw) - height) / 2; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
589 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
590 if (down_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
591 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
592 GC temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
593 temp = top_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
594 top_gc = bottom_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
595 bottom_gc = temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
596 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
597 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
598 pt[0].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
599 pt[0].y = y + height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
600 pt[1].x = x + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
601 pt[1].y = y + height - thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
602 pt[2].x = x + thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
603 pt[2].y = y + thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
604 pt[3].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
605 pt[3].y = y; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
606 XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
607 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
608 pt[0].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
609 pt[0].y = y; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
610 pt[1].x = x + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
611 pt[1].y = y + thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
612 pt[2].x = x + width - thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
613 pt[2].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
614 pt[3].x = x + width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
615 pt[3].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
616 XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
617 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
618 pt[0].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
619 pt[0].y = y + height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
620 pt[1].x = x + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
621 pt[1].y = y + height - thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
622 pt[2].x = x + width - thickness2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
623 pt[2].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
624 pt[3].x = x + width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
625 pt[3].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
626 XFillPolygon (dpy, window, bottom_gc, pt, 4, Convex, CoordModeOrigin); |
5626 | 627 } |
628 | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
629 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
630 |
5626 | 631 static void |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
632 draw_shadow_rectangle (mw, window, x, y, width, height, erase_p, down_p) |
8860 | 633 XlwMenuWidget mw; |
634 Window window; | |
635 int x; | |
636 int y; | |
637 int width; | |
638 int height; | |
639 int erase_p; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
640 int down_p; |
5626 | 641 { |
642 Display *dpy = XtDisplay (mw); | |
643 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; | |
644 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; | |
645 int thickness = mw->menu.shadow_thickness; | |
646 XPoint points [4]; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
647 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
648 if (!erase_p && down_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
649 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
650 GC temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
651 temp = top_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
652 top_gc = bottom_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
653 bottom_gc = temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
654 } |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
655 |
5626 | 656 points [0].x = x; |
657 points [0].y = y; | |
658 points [1].x = x + width; | |
659 points [1].y = y; | |
660 points [2].x = x + width - thickness; | |
661 points [2].y = y + thickness; | |
662 points [3].x = x; | |
663 points [3].y = y + thickness; | |
664 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); | |
665 points [0].x = x; | |
666 points [0].y = y + thickness; | |
667 points [1].x = x; | |
668 points [1].y = y + height; | |
669 points [2].x = x + thickness; | |
670 points [2].y = y + height - thickness; | |
671 points [3].x = x + thickness; | |
672 points [3].y = y + thickness; | |
673 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); | |
674 points [0].x = x + width; | |
675 points [0].y = y; | |
676 points [1].x = x + width - thickness; | |
677 points [1].y = y + thickness; | |
678 points [2].x = x + width - thickness; | |
679 points [2].y = y + height - thickness; | |
680 points [3].x = x + width; | |
681 points [3].y = y + height - thickness; | |
682 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); | |
683 points [0].x = x; | |
684 points [0].y = y + height; | |
685 points [1].x = x + width; | |
686 points [1].y = y + height; | |
687 points [2].x = x + width; | |
688 points [2].y = y + height - thickness; | |
689 points [3].x = x + thickness; | |
690 points [3].y = y + height - thickness; | |
691 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); | |
692 } | |
693 | |
694 | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
695 static void |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
696 draw_shadow_rhombus (mw, window, x, y, width, height, erase_p, down_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
697 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
698 Window window; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
699 int x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
700 int y; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
701 int width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
702 int height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
703 int erase_p; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
704 int down_p; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
705 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
706 Display *dpy = XtDisplay (mw); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
707 GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
708 GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
709 int thickness = mw->menu.shadow_thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
710 XPoint points [4]; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
711 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
712 if (!erase_p && down_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
713 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
714 GC temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
715 temp = top_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
716 top_gc = bottom_gc; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
717 bottom_gc = temp; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
718 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
719 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
720 points [0].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
721 points [0].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
722 points [1].x = x + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
723 points [1].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
724 points [2].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
725 points [2].y = y + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
726 points [3].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
727 points [3].y = y; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
728 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
729 points [0].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
730 points [0].y = y; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
731 points [1].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
732 points [1].y = y + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
733 points [2].x = x + width - thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
734 points [2].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
735 points [3].x = x + width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
736 points [3].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
737 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
738 points [0].x = x; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
739 points [0].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
740 points [1].x = x + thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
741 points [1].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
742 points [2].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
743 points [2].y = y + height - thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
744 points [3].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
745 points [3].y = y + height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
746 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
747 points [0].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
748 points [0].y = y + height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
749 points [1].x = x + width / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
750 points [1].y = y + height - thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
751 points [2].x = x + width - thickness; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
752 points [2].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
753 points [3].x = x + width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
754 points [3].y = y + height / 2; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
755 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
756 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
757 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
758 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
759 /* Draw a toggle button on widget MW, X window WINDOW. X/Y is the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
760 top-left corner of the menu item. SELECTED_P non-zero means the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
761 toggle button is selected. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
762 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
763 static void |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
764 draw_toggle (mw, window, x, y, selected_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
765 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
766 Window window; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
767 int x, y, selected_p; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
768 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
769 int width, height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
770 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
771 width = toggle_button_width (mw); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
772 height = width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
773 x += mw->menu.horizontal_spacing; |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
774 y += (MENU_FONT_ASCENT (mw) - height) / 2; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
775 draw_shadow_rectangle (mw, window, x, y, width, height, False, selected_p); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
776 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
777 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
778 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
779 /* Draw a radio button on widget MW, X window WINDOW. X/Y is the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
780 top-left corner of the menu item. SELECTED_P non-zero means the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
781 toggle button is selected. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
782 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
783 static void |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
784 draw_radio (mw, window, x, y, selected_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
785 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
786 Window window; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
787 int x, y, selected_p; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
788 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
789 int width, height; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
790 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
791 width = radio_button_width (mw); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
792 height = width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
793 x += mw->menu.horizontal_spacing; |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
794 y += (MENU_FONT_ASCENT (mw) - height) / 2; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
795 draw_shadow_rhombus (mw, window, x, y, width, height, False, selected_p); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
796 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
797 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
798 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
799 /* Draw a menu separator on widget MW, X window WINDOW. X/Y is the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
800 top-left corner of the menu item. WIDTH is the width of the |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
801 separator to draw. TYPE is the separator type. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
802 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
803 static void |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
804 draw_separator (mw, window, x, y, width, type) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
805 XlwMenuWidget mw; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
806 Window window; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
807 int x, y, width; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
808 enum menu_separator type; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
809 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
810 Display *dpy = XtDisplay (mw); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
811 XGCValues xgcv; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
812 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
813 switch (type) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
814 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
815 case SEPARATOR_NO_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
816 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
817 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
818 case SEPARATOR_SINGLE_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
819 XDrawLine (dpy, window, mw->menu.foreground_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
820 x, y, x + width, y); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
821 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
822 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
823 case SEPARATOR_DOUBLE_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
824 draw_separator (mw, window, x, y, width, SEPARATOR_SINGLE_LINE); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
825 draw_separator (mw, window, x, y + 2, width, SEPARATOR_SINGLE_LINE); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
826 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
827 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
828 case SEPARATOR_SINGLE_DASHED_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
829 xgcv.line_style = LineOnOffDash; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
830 XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
831 XDrawLine (dpy, window, mw->menu.foreground_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
832 x, y, x + width, y); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
833 xgcv.line_style = LineSolid; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
834 XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
835 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
836 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
837 case SEPARATOR_DOUBLE_DASHED_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
838 draw_separator (mw, window, x, y, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
839 SEPARATOR_SINGLE_DASHED_LINE); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
840 draw_separator (mw, window, x, y + 2, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
841 SEPARATOR_SINGLE_DASHED_LINE); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
842 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
843 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
844 case SEPARATOR_SHADOW_ETCHED_IN: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
845 XDrawLine (dpy, window, mw->menu.shadow_bottom_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
846 x, y, x + width, y); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
847 XDrawLine (dpy, window, mw->menu.shadow_top_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
848 x, y + 1, x + width, y + 1); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
849 break; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
850 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
851 case SEPARATOR_SHADOW_ETCHED_OUT: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
852 XDrawLine (dpy, window, mw->menu.shadow_top_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
853 x, y, x + width, y); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
854 XDrawLine (dpy, window, mw->menu.shadow_bottom_gc, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
855 x, y + 1, x + width, y + 1); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
856 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
857 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
858 case SEPARATOR_SHADOW_ETCHED_IN_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
859 xgcv.line_style = LineOnOffDash; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
860 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
861 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
34436
a27cc46a67b4
(draw_separator) <SEPARATOR_SHADOW_ETCHED_IN_DASH>:
Dave Love <fx@gnu.org>
parents:
33714
diff
changeset
|
862 draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_IN); |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
863 xgcv.line_style = LineSolid; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
864 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
865 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
866 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
867 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
868 case SEPARATOR_SHADOW_ETCHED_OUT_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
869 xgcv.line_style = LineOnOffDash; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
870 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
871 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
34436
a27cc46a67b4
(draw_separator) <SEPARATOR_SHADOW_ETCHED_IN_DASH>:
Dave Love <fx@gnu.org>
parents:
33714
diff
changeset
|
872 draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_OUT); |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
873 xgcv.line_style = LineSolid; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
874 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
875 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
876 break; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
877 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
878 case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
879 draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_IN); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
880 draw_separator (mw, window, x, y + 3, width, SEPARATOR_SHADOW_ETCHED_IN); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
881 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
882 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
883 case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
884 draw_separator (mw, window, x, y, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
885 SEPARATOR_SHADOW_ETCHED_OUT); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
886 draw_separator (mw, window, x, y + 3, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
887 SEPARATOR_SHADOW_ETCHED_OUT); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
888 break; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
889 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
890 case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
891 xgcv.line_style = LineOnOffDash; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
892 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
893 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
894 draw_separator (mw, window, x, y, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
895 SEPARATOR_SHADOW_DOUBLE_ETCHED_IN); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
896 xgcv.line_style = LineSolid; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
897 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
898 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
899 break; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
900 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
901 case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
902 xgcv.line_style = LineOnOffDash; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
903 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
904 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
905 draw_separator (mw, window, x, y, width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
906 SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
907 xgcv.line_style = LineSolid; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
908 XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
909 XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
910 break; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
911 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
912 default: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
913 abort (); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
914 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
915 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
916 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
917 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
918 /* Return the pixel height of menu separator SEPARATOR. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
919 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
920 static int |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
921 separator_height (separator) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
922 enum menu_separator separator; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
923 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
924 switch (separator) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
925 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
926 case SEPARATOR_NO_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
927 return 2; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
928 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
929 case SEPARATOR_SINGLE_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
930 case SEPARATOR_SINGLE_DASHED_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
931 return 1; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
932 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
933 case SEPARATOR_DOUBLE_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
934 case SEPARATOR_DOUBLE_DASHED_LINE: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
935 return 3; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
936 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
937 case SEPARATOR_SHADOW_ETCHED_IN: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
938 case SEPARATOR_SHADOW_ETCHED_OUT: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
939 case SEPARATOR_SHADOW_ETCHED_IN_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
940 case SEPARATOR_SHADOW_ETCHED_OUT_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
941 return 2; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
942 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
943 case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
944 case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
945 case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
946 case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
947 return 5; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
948 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
949 default: |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
950 abort (); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
951 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
952 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
953 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
954 |
5626 | 955 /* Display the menu item and increment where.x and where.y to show how large |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
956 the menu item was. */ |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
957 |
5626 | 958 static void |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
959 display_menu_item (mw, val, ws, where, highlighted_p, horizontal_p, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
960 just_compute_p) |
8860 | 961 XlwMenuWidget mw; |
962 widget_value* val; | |
963 window_state* ws; | |
964 XPoint* where; | |
965 Boolean highlighted_p; | |
966 Boolean horizontal_p; | |
967 Boolean just_compute_p; | |
5626 | 968 { |
969 GC deco_gc; | |
970 GC text_gc; | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
971 int font_height = MENU_FONT_HEIGHT (mw); |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
972 int font_ascent = MENU_FONT_ASCENT (mw); |
5626 | 973 int shadow = mw->menu.shadow_thickness; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
974 int margin = mw->menu.margin; |
5626 | 975 int h_spacing = mw->menu.horizontal_spacing; |
976 int v_spacing = mw->menu.vertical_spacing; | |
977 int label_width; | |
978 int rest_width; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
979 int button_width; |
5626 | 980 int height; |
981 int width; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
982 enum menu_separator separator; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
983 int separator_p = lw_separator_p (val->name, &separator, 0); |
5626 | 984 |
985 /* compute the sizes of the item */ | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
986 size_menu_item (mw, val, horizontal_p, &label_width, &rest_width, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
987 &button_width, &height); |
5626 | 988 |
989 if (horizontal_p) | |
990 width = label_width + rest_width; | |
991 else | |
992 { | |
993 label_width = ws->label_width; | |
994 width = ws->width - 2 * shadow; | |
995 } | |
996 | |
997 /* Only highlight an enabled item that has a callback. */ | |
998 if (highlighted_p) | |
999 if (!val->enabled || !(val->call_data || val->contents)) | |
1000 highlighted_p = 0; | |
1001 | |
1002 /* do the drawing. */ | |
1003 if (!just_compute_p) | |
1004 { | |
1005 /* Add the shadow border of the containing menu */ | |
1006 int x = where->x + shadow; | |
1007 int y = where->y + shadow; | |
1008 | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1009 if (horizontal_p) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1010 { |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1011 x += margin; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1012 y += margin; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1013 } |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1014 |
5626 | 1015 /* pick the foreground and background GC. */ |
1016 if (val->enabled) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1017 text_gc = mw->menu.foreground_gc; |
5626 | 1018 else |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1019 text_gc = mw->menu.disabled_gc; |
5626 | 1020 deco_gc = mw->menu.foreground_gc; |
1021 | |
1022 if (separator_p) | |
1023 { | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1024 draw_separator (mw, ws->window, x, y, width, separator); |
5626 | 1025 } |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1026 else |
5626 | 1027 { |
9227
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1028 int x_offset = x + h_spacing + shadow; |
5626 | 1029 char* display_string = resource_widget_value (mw, val); |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1030 draw_shadow_rectangle (mw, ws->window, x, y, width, height, True, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1031 False); |
9227
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1032 |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1033 /* Deal with centering a menu title. */ |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1034 if (!horizontal_p && !val->contents && !val->call_data) |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1035 { |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1036 int l = string_width (mw, display_string); |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1037 |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1038 if (width > l) |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1039 x_offset = (width - l) >> 1; |
968bb25ec1af
(display_menu_item): Add support for displaying the title in pop up menus.
Paul Reilly <pmr@pajato.com>
parents:
9092
diff
changeset
|
1040 } |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1041 else if (!horizontal_p && ws->button_width) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1042 x_offset += ws->button_width; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1043 |
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1044 |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1045 #ifdef HAVE_X_I18N |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1046 if (mw->menu.fontSet) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1047 XmbDrawString (XtDisplay (mw), ws->window, mw->menu.fontSet, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1048 text_gc, x_offset, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1049 y + v_spacing + shadow + font_ascent, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1050 display_string, strlen (display_string)); |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1051 else |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1052 #endif |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1053 XDrawString (XtDisplay (mw), ws->window, |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1054 text_gc, x_offset, |
5626 | 1055 y + v_spacing + shadow + font_ascent, |
1056 display_string, strlen (display_string)); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1057 |
5626 | 1058 if (!horizontal_p) |
1059 { | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1060 if (val->button_type == BUTTON_TYPE_TOGGLE) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1061 draw_toggle (mw, ws->window, x, y + v_spacing + shadow, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1062 val->selected); |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1063 else if (val->button_type == BUTTON_TYPE_RADIO) |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1064 draw_radio (mw, ws->window, x, y + v_spacing + shadow, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1065 val->selected); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1066 |
5626 | 1067 if (val->contents) |
1068 { | |
1069 int a_w = arrow_width (mw); | |
1070 draw_arrow (mw, ws->window, deco_gc, | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1071 x + width - a_w |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1072 - mw->menu.horizontal_spacing |
8860 | 1073 - mw->menu.shadow_thickness, |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1074 y + v_spacing + shadow, a_w, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1075 highlighted_p); |
5626 | 1076 } |
1077 else if (val->key) | |
1078 { | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1079 #ifdef HAVE_X_I18N |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1080 if (mw->menu.fontSet) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1081 XmbDrawString (XtDisplay (mw), ws->window, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1082 mw->menu.fontSet, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1083 text_gc, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1084 x + label_width + mw->menu.arrow_spacing, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1085 y + v_spacing + shadow + font_ascent, |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1086 val->key, strlen (val->key)); |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1087 else |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1088 #endif |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1089 XDrawString (XtDisplay (mw), ws->window, |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1090 text_gc, |
5626 | 1091 x + label_width + mw->menu.arrow_spacing, |
1092 y + v_spacing + shadow + font_ascent, | |
1093 val->key, strlen (val->key)); | |
1094 } | |
1095 } | |
8860 | 1096 else |
1097 { | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1098 XDrawRectangle (XtDisplay (mw), ws->window, |
8860 | 1099 mw->menu.background_gc, |
1100 x + shadow, y + shadow, | |
1101 label_width + h_spacing - 1, | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1102 font_height + 2 * v_spacing - 1); |
8860 | 1103 draw_shadow_rectangle (mw, ws->window, x, y, width, height, |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1104 True, False); |
8860 | 1105 } |
5626 | 1106 |
1107 if (highlighted_p) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1108 draw_shadow_rectangle (mw, ws->window, x, y, width, height, False, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1109 False); |
5626 | 1110 } |
1111 } | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1112 |
5626 | 1113 where->x += width; |
1114 where->y += height; | |
1115 } | |
1116 | |
1117 static void | |
8860 | 1118 display_menu (mw, level, just_compute_p, highlighted_pos, hit, hit_return, |
1119 this, that) | |
1120 XlwMenuWidget mw; | |
1121 int level; | |
1122 Boolean just_compute_p; | |
1123 XPoint* highlighted_pos; | |
1124 XPoint* hit; | |
1125 widget_value** hit_return; | |
1126 widget_value* this; | |
1127 widget_value* that; | |
5626 | 1128 { |
1129 widget_value* val; | |
1130 widget_value* following_item; | |
1131 window_state* ws; | |
1132 XPoint where; | |
1133 int horizontal_p = mw->menu.horizontal && (level == 0); | |
1134 int highlighted_p; | |
1135 int just_compute_this_one_p; | |
18993
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1136 /* This is set nonzero if the element containing HIGHLIGHTED_POS |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1137 is disabled, so that we do not return any subsequent element either. */ |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1138 int no_return = 0; |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1139 enum menu_separator separator; |
5626 | 1140 |
1141 if (level >= mw->menu.old_depth) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1142 abort_gracefully ((Widget) mw); |
5626 | 1143 |
1144 if (level < mw->menu.old_depth - 1) | |
1145 following_item = mw->menu.old_stack [level + 1]; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1146 else |
5626 | 1147 following_item = NULL; |
1148 | |
1149 if (hit) | |
1150 *hit_return = NULL; | |
1151 | |
1152 where.x = 0; | |
1153 where.y = 0; | |
1154 | |
1155 ws = &mw->menu.windows [level]; | |
1156 for (val = mw->menu.old_stack [level]->contents; val; val = val->next) | |
1157 { | |
1158 highlighted_p = val == following_item; | |
1159 if (highlighted_p && highlighted_pos) | |
1160 { | |
1161 if (horizontal_p) | |
1162 highlighted_pos->x = where.x; | |
1163 else | |
1164 highlighted_pos->y = where.y; | |
1165 } | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1166 |
5626 | 1167 just_compute_this_one_p = |
1168 just_compute_p || ((this || that) && val != this && val != that); | |
1169 | |
1170 display_menu_item (mw, val, ws, &where, highlighted_p, horizontal_p, | |
1171 just_compute_this_one_p); | |
1172 | |
1173 if (highlighted_p && highlighted_pos) | |
1174 { | |
1175 if (horizontal_p) | |
1176 highlighted_pos->y = where.y; | |
1177 else | |
1178 highlighted_pos->x = where.x; | |
1179 } | |
1180 | |
1181 if (hit | |
1182 && !*hit_return | |
1183 && (horizontal_p ? hit->x < where.x : hit->y < where.y) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1184 && !lw_separator_p (val->name, &separator, 0) |
18993
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1185 && !no_return) |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1186 { |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1187 if (val->enabled) |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1188 *hit_return = val; |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1189 else |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1190 no_return = 1; |
c3bfd473a4d3
(display_menu): If an item is disabled,
Richard M. Stallman <rms@gnu.org>
parents:
17622
diff
changeset
|
1191 } |
5626 | 1192 |
1193 if (horizontal_p) | |
1194 where.y = 0; | |
1195 else | |
1196 where.x = 0; | |
1197 } | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1198 |
5626 | 1199 if (!just_compute_p) |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1200 draw_shadow_rectangle (mw, ws->window, 0, 0, ws->width, ws->height, |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1201 False, False); |
5626 | 1202 } |
1203 | |
1204 /* Motion code */ | |
1205 static void | |
8860 | 1206 set_new_state (mw, val, level) |
1207 XlwMenuWidget mw; | |
1208 widget_value* val; | |
1209 int level; | |
5626 | 1210 { |
1211 int i; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1212 |
5626 | 1213 mw->menu.new_depth = 0; |
1214 for (i = 0; i < level; i++) | |
1215 push_new_stack (mw, mw->menu.old_stack [i]); | |
1216 push_new_stack (mw, val); | |
1217 } | |
1218 | |
1219 static void | |
8860 | 1220 make_windows_if_needed (mw, n) |
1221 XlwMenuWidget mw; | |
1222 int n; | |
5626 | 1223 { |
1224 int i; | |
1225 int start_at; | |
1226 XSetWindowAttributes xswa; | |
1227 int mask; | |
1228 Window root = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw))); | |
1229 window_state* windows; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1230 |
5626 | 1231 if (mw->menu.windows_length >= n) |
1232 return; | |
1233 | |
1234 xswa.save_under = True; | |
1235 xswa.override_redirect = True; | |
1236 xswa.background_pixel = mw->core.background_pixel; | |
1237 xswa.border_pixel = mw->core.border_pixel; | |
1238 xswa.event_mask = | |
8860 | 1239 ExposureMask | PointerMotionMask | PointerMotionHintMask |
5626 | 1240 | ButtonReleaseMask | ButtonPressMask; |
1241 xswa.cursor = mw->menu.cursor_shape; | |
1242 mask = CWSaveUnder | CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
1243 | CWEventMask | CWCursor; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1244 |
5626 | 1245 if (!mw->menu.windows) |
1246 { | |
1247 mw->menu.windows = | |
1248 (window_state*)XtMalloc (n * sizeof (window_state)); | |
1249 start_at = 0; | |
1250 } | |
1251 else | |
1252 { | |
1253 mw->menu.windows = | |
1254 (window_state*)XtRealloc ((char*)mw->menu.windows, | |
1255 n * sizeof (window_state)); | |
1256 start_at = mw->menu.windows_length; | |
1257 } | |
1258 mw->menu.windows_length = n; | |
1259 | |
1260 windows = mw->menu.windows; | |
1261 | |
1262 for (i = start_at; i < n; i++) | |
1263 { | |
1264 windows [i].x = 0; | |
1265 windows [i].y = 0; | |
1266 windows [i].width = 1; | |
1267 windows [i].height = 1; | |
1268 windows [i].window = | |
1269 XCreateWindow (XtDisplay (mw), root, 0, 0, 1, 1, | |
1270 0, 0, CopyFromParent, CopyFromParent, mask, &xswa); | |
1271 } | |
1272 } | |
1273 | |
37524
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1274 /* Value is non-zero if WINDOW is part of menu bar widget W. */ |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1275 |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1276 int |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1277 xlwmenu_window_p (w, window) |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1278 Widget w; |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1279 Window window; |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1280 { |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1281 XlwMenuWidget mw = (XlwMenuWidget) w; |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1282 int i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48929
diff
changeset
|
1283 |
37524
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1284 for (i = 0; i < mw->menu.windows_length; ++i) |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1285 if (window == mw->menu.windows[i].window) |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1286 break; |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1287 |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1288 return i < mw->menu.windows_length; |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1289 } |
f0a59a792f7d
(xlwmenu_window_p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
34557
diff
changeset
|
1290 |
5626 | 1291 /* Make the window fit in the screen */ |
1292 static void | |
8860 | 1293 fit_to_screen (mw, ws, previous_ws, horizontal_p) |
1294 XlwMenuWidget mw; | |
1295 window_state* ws; | |
1296 window_state* previous_ws; | |
1297 Boolean horizontal_p; | |
5626 | 1298 { |
11461
65c12e57f119
(size_menu): Make height and label_width unsigned.
Richard M. Stallman <rms@gnu.org>
parents:
9746
diff
changeset
|
1299 unsigned int screen_width = WidthOfScreen (XtScreen (mw)); |
65c12e57f119
(size_menu): Make height and label_width unsigned.
Richard M. Stallman <rms@gnu.org>
parents:
9746
diff
changeset
|
1300 unsigned int screen_height = HeightOfScreen (XtScreen (mw)); |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1301 /* 1 if we are unable to avoid an overlap between |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1302 this menu and the parent menu in the X dimension. */ |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1303 int horizontal_overlap = 0; |
5626 | 1304 |
1305 if (ws->x < 0) | |
1306 ws->x = 0; | |
1307 else if (ws->x + ws->width > screen_width) | |
1308 { | |
1309 if (!horizontal_p) | |
31370 | 1310 /* The addition of shadow-thickness for a sub-menu's position is |
1311 to reflect a similar adjustment when the menu is displayed to | |
1312 the right of the invoking menu-item; it makes the sub-menu | |
1313 look more `attached' to the menu-item. */ | |
1314 ws->x = previous_ws->x - ws->width + mw->menu.shadow_thickness; | |
5626 | 1315 else |
1316 ws->x = screen_width - ws->width; | |
9395
d954daf0a213
(fit_to_screen): Don't put the menu off the left or top.
Richard M. Stallman <rms@gnu.org>
parents:
9227
diff
changeset
|
1317 if (ws->x < 0) |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1318 { |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1319 ws->x = 0; |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1320 horizontal_overlap = 1; |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1321 } |
5626 | 1322 } |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1323 /* If we overlap in X, try to avoid overlap in Y. */ |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1324 if (horizontal_overlap |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1325 && ws->y < previous_ws->y + previous_ws->height |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1326 && previous_ws->y < ws->y + ws->height) |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1327 { |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1328 /* Put this menu right below or right above PREVIOUS_WS |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1329 if there's room. */ |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1330 if (previous_ws->y + previous_ws->height + ws->height < screen_height) |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1331 ws->y = previous_ws->y + previous_ws->height; |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1332 else if (previous_ws->y - ws->height > 0) |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1333 ws->y = previous_ws->y - ws->height; |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1334 } |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1335 |
5626 | 1336 if (ws->y < 0) |
1337 ws->y = 0; | |
1338 else if (ws->y + ws->height > screen_height) | |
1339 { | |
1340 if (horizontal_p) | |
1341 ws->y = previous_ws->y - ws->height; | |
1342 else | |
1343 ws->y = screen_height - ws->height; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1344 if (ws->y < 0) |
9395
d954daf0a213
(fit_to_screen): Don't put the menu off the left or top.
Richard M. Stallman <rms@gnu.org>
parents:
9227
diff
changeset
|
1345 ws->y = 0; |
5626 | 1346 } |
1347 } | |
1348 | |
1349 /* Updates old_stack from new_stack and redisplays. */ | |
1350 static void | |
8860 | 1351 remap_menubar (mw) |
1352 XlwMenuWidget mw; | |
5626 | 1353 { |
1354 int i; | |
1355 int last_same; | |
1356 XPoint selection_position; | |
1357 int old_depth = mw->menu.old_depth; | |
1358 int new_depth = mw->menu.new_depth; | |
1359 widget_value** old_stack; | |
1360 widget_value** new_stack; | |
1361 window_state* windows; | |
1362 widget_value* old_selection; | |
1363 widget_value* new_selection; | |
1364 | |
1365 /* Check that enough windows and old_stack are ready. */ | |
1366 make_windows_if_needed (mw, new_depth); | |
1367 make_old_stack_space (mw, new_depth); | |
1368 windows = mw->menu.windows; | |
1369 old_stack = mw->menu.old_stack; | |
1370 new_stack = mw->menu.new_stack; | |
1371 | |
1372 /* compute the last identical different entry */ | |
1373 for (i = 1; i < old_depth && i < new_depth; i++) | |
1374 if (old_stack [i] != new_stack [i]) | |
1375 break; | |
1376 last_same = i - 1; | |
1377 | |
1378 /* Memorize the previously selected item to be able to refresh it */ | |
1379 old_selection = last_same + 1 < old_depth ? old_stack [last_same + 1] : NULL; | |
1380 if (old_selection && !old_selection->enabled) | |
1381 old_selection = NULL; | |
1382 new_selection = last_same + 1 < new_depth ? new_stack [last_same + 1] : NULL; | |
1383 if (new_selection && !new_selection->enabled) | |
1384 new_selection = NULL; | |
1385 | |
27338
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1386 /* Call callback when the hightlighted item changes. */ |
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1387 if (old_selection || new_selection) |
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1388 XtCallCallbackList ((Widget)mw, mw->menu.highlight, |
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1389 (XtPointer) new_selection); |
58f8eee82765
(xlwMenuResources): All XtNhighlightCallback.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1390 |
5626 | 1391 /* updates old_state from new_state. It has to be done now because |
1392 display_menu (called below) uses the old_stack to know what to display. */ | |
1393 for (i = last_same + 1; i < new_depth; i++) | |
1394 old_stack [i] = new_stack [i]; | |
1395 mw->menu.old_depth = new_depth; | |
1396 | |
14018 | 1397 /* refresh the last selection */ |
5626 | 1398 selection_position.x = 0; |
1399 selection_position.y = 0; | |
1400 display_menu (mw, last_same, new_selection == old_selection, | |
1401 &selection_position, NULL, NULL, old_selection, new_selection); | |
1402 | |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1403 /* Now place the new menus. */ |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1404 for (i = last_same + 1; i < new_depth && new_stack[i]->contents; i++) |
5626 | 1405 { |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1406 window_state *previous_ws = &windows[i - 1]; |
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1407 window_state *ws = &windows[i]; |
5626 | 1408 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1409 ws->x = (previous_ws->x + selection_position.x |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1410 + mw->menu.shadow_thickness); |
31370 | 1411 if (mw->menu.horizontal && i == 1) |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1412 ws->x += mw->menu.margin; |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1413 |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1414 #if 0 |
5626 | 1415 if (!mw->menu.horizontal || i > 1) |
1416 ws->x += mw->menu.shadow_thickness; | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1417 #endif |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1418 |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1419 ws->y = (previous_ws->y + selection_position.y |
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1420 + mw->menu.shadow_thickness); |
31370 | 1421 if (mw->menu.horizontal && i == 1) |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1422 ws->y += mw->menu.margin; |
5626 | 1423 |
1424 size_menu (mw, i); | |
1425 | |
1426 fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1); | |
1427 | |
1428 XClearWindow (XtDisplay (mw), ws->window); | |
1429 XMoveResizeWindow (XtDisplay (mw), ws->window, ws->x, ws->y, | |
1430 ws->width, ws->height); | |
1431 XMapRaised (XtDisplay (mw), ws->window); | |
1432 display_menu (mw, i, False, &selection_position, NULL, NULL, NULL, NULL); | |
1433 } | |
1434 | |
1435 /* unmap the menus that popped down */ | |
1436 for (i = new_depth - 1; i < old_depth; i++) | |
48929
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
1437 if (i >= new_depth || (i > 0 && !new_stack[i]->contents)) |
16917
5aabcff9fdd3
(enriched-translations): Add top' and choice' everywhere so that *
Richard M. Stallman <rms@gnu.org>
parents:
15742
diff
changeset
|
1438 XUnmapWindow (XtDisplay (mw), windows[i].window); |
5626 | 1439 } |
1440 | |
1441 static Boolean | |
8860 | 1442 motion_event_is_in_menu (mw, ev, level, relative_pos) |
1443 XlwMenuWidget mw; | |
1444 XMotionEvent* ev; | |
1445 int level; | |
1446 XPoint* relative_pos; | |
5626 | 1447 { |
1448 window_state* ws = &mw->menu.windows [level]; | |
19960
38172783650b
(motion_event_is_in_menu): Extend the left and
Richard M. Stallman <rms@gnu.org>
parents:
18993
diff
changeset
|
1449 int shadow = level == 0 ? 0 : mw->menu.shadow_thickness; |
38172783650b
(motion_event_is_in_menu): Extend the left and
Richard M. Stallman <rms@gnu.org>
parents:
18993
diff
changeset
|
1450 int x = ws->x + shadow; |
38172783650b
(motion_event_is_in_menu): Extend the left and
Richard M. Stallman <rms@gnu.org>
parents:
18993
diff
changeset
|
1451 int y = ws->y + shadow; |
5626 | 1452 relative_pos->x = ev->x_root - x; |
1453 relative_pos->y = ev->y_root - y; | |
19960
38172783650b
(motion_event_is_in_menu): Extend the left and
Richard M. Stallman <rms@gnu.org>
parents:
18993
diff
changeset
|
1454 return (x - shadow < ev->x_root && ev->x_root < x + ws->width |
38172783650b
(motion_event_is_in_menu): Extend the left and
Richard M. Stallman <rms@gnu.org>
parents:
18993
diff
changeset
|
1455 && y - shadow < ev->y_root && ev->y_root < y + ws->height); |
5626 | 1456 } |
1457 | |
1458 static Boolean | |
8860 | 1459 map_event_to_widget_value (mw, ev, val, level) |
1460 XlwMenuWidget mw; | |
1461 XMotionEvent* ev; | |
1462 widget_value** val; | |
1463 int* level; | |
5626 | 1464 { |
1465 int i; | |
1466 XPoint relative_pos; | |
1467 window_state* ws; | |
1468 | |
1469 *val = NULL; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1470 |
5626 | 1471 /* Find the window */ |
1472 for (i = mw->menu.old_depth - 1; i >= 0; i--) | |
1473 { | |
1474 ws = &mw->menu.windows [i]; | |
1475 if (ws && motion_event_is_in_menu (mw, ev, i, &relative_pos)) | |
1476 { | |
1477 display_menu (mw, i, True, NULL, &relative_pos, val, NULL, NULL); | |
1478 | |
1479 if (*val) | |
1480 { | |
1481 *level = i + 1; | |
1482 return True; | |
1483 } | |
1484 } | |
1485 } | |
1486 return False; | |
1487 } | |
1488 | |
1489 /* Procedures */ | |
1490 static void | |
8860 | 1491 make_drawing_gcs (mw) |
1492 XlwMenuWidget mw; | |
5626 | 1493 { |
1494 XGCValues xgcv; | |
45152
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1495 float scale; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1496 XtGCMask mask = GCForeground | GCBackground; |
5626 | 1497 |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1498 #ifdef HAVE_X_I18N |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1499 if (!mw->menu.fontSet) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1500 { |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1501 xgcv.font = mw->menu.font->fid; |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1502 mask |= GCFont; |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1503 } |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1504 #else |
5626 | 1505 xgcv.font = mw->menu.font->fid; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1506 mask |= GCFont; |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1507 #endif |
5626 | 1508 xgcv.foreground = mw->menu.foreground; |
1509 xgcv.background = mw->core.background_pixel; | |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1510 mw->menu.foreground_gc = XtGetGC ((Widget)mw, mask, &xgcv); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1511 |
5626 | 1512 xgcv.foreground = mw->menu.button_foreground; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1513 mw->menu.button_gc = XtGetGC ((Widget)mw, mask, &xgcv); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1514 |
5626 | 1515 xgcv.background = mw->core.background_pixel; |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1516 |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1517 #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff)) |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1518 |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1519 /* Allocate color for disabled menu-items. */ |
45152
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1520 mw->menu.disabled_foreground = mw->menu.foreground; |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1521 if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel)) |
45152
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1522 scale = 2.3; |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1523 else |
45152
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1524 scale = 0.55; |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1525 |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1526 x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw), |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1527 mw->core.colormap, |
45152
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1528 &mw->menu.disabled_foreground, |
0e9984418269
(make_drawing_gcs): The scaling factor passed to
Pavel Janík <Pavel@Janik.cz>
parents:
45147
diff
changeset
|
1529 scale, |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1530 0x8000); |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1531 |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1532 if (mw->menu.foreground == mw->menu.disabled_foreground |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1533 || mw->core.background_pixel == mw->menu.disabled_foreground) |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1534 { |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1535 /* Too few colors, use stipple. */ |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1536 xgcv.foreground = mw->menu.foreground; |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1537 xgcv.fill_style = FillStippled; |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1538 xgcv.stipple = mw->menu.gray_pixmap; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1539 mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1540 | GCFillStyle | GCStipple, &xgcv); |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1541 } |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1542 else |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1543 { |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1544 /* Many colors available, use disabled pixel. */ |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1545 xgcv.foreground = mw->menu.disabled_foreground; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1546 mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask, &xgcv); |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1547 } |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1548 |
5626 | 1549 xgcv.foreground = mw->menu.button_foreground; |
1550 xgcv.background = mw->core.background_pixel; | |
1551 xgcv.fill_style = FillStippled; | |
1552 xgcv.stipple = mw->menu.gray_pixmap; | |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1553 mw->menu.inactive_button_gc = XtGetGC ((Widget)mw, mask |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1554 | GCFillStyle | GCStipple, &xgcv); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1555 |
5626 | 1556 xgcv.foreground = mw->core.background_pixel; |
1557 xgcv.background = mw->menu.foreground; | |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1558 mw->menu.background_gc = XtGetGC ((Widget)mw, mask, &xgcv); |
5626 | 1559 } |
1560 | |
1561 static void | |
8860 | 1562 release_drawing_gcs (mw) |
1563 XlwMenuWidget mw; | |
5626 | 1564 { |
1565 XtReleaseGC ((Widget) mw, mw->menu.foreground_gc); | |
1566 XtReleaseGC ((Widget) mw, mw->menu.button_gc); | |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1567 XtReleaseGC ((Widget) mw, mw->menu.disabled_gc); |
5626 | 1568 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); |
1569 XtReleaseGC ((Widget) mw, mw->menu.background_gc); | |
1570 /* let's get some segvs if we try to use these... */ | |
1571 mw->menu.foreground_gc = (GC) -1; | |
1572 mw->menu.button_gc = (GC) -1; | |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
1573 mw->menu.disabled_gc = (GC) -1; |
5626 | 1574 mw->menu.inactive_button_gc = (GC) -1; |
1575 mw->menu.background_gc = (GC) -1; | |
1576 } | |
1577 | |
1578 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ | |
1579 ? ((unsigned long) (x)) : ((unsigned long) (y))) | |
1580 | |
1581 static void | |
8860 | 1582 make_shadow_gcs (mw) |
1583 XlwMenuWidget mw; | |
5626 | 1584 { |
1585 XGCValues xgcv; | |
1586 unsigned long pm = 0; | |
1587 Display *dpy = XtDisplay ((Widget) mw); | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1588 Screen *screen = XtScreen ((Widget) mw); |
27988
817a3a4058a0
(make_shadow_gcs): Use the widget's colormap instead
Gerd Moellmann <gerd@gnu.org>
parents:
27338
diff
changeset
|
1589 Colormap cmap = mw->core.colormap; |
5626 | 1590 XColor topc, botc; |
1591 int top_frobbed = 0, bottom_frobbed = 0; | |
1592 | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1593 mw->menu.free_top_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1594 mw->menu.free_bottom_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1595 |
5626 | 1596 if (mw->menu.top_shadow_color == -1) |
1597 mw->menu.top_shadow_color = mw->core.background_pixel; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1598 else |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1599 mw->menu.top_shadow_color = mw->menu.top_shadow_color; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1600 |
5626 | 1601 if (mw->menu.bottom_shadow_color == -1) |
1602 mw->menu.bottom_shadow_color = mw->menu.foreground; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1603 else |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1604 mw->menu.bottom_shadow_color = mw->menu.bottom_shadow_color; |
5626 | 1605 |
1606 if (mw->menu.top_shadow_color == mw->core.background_pixel || | |
1607 mw->menu.top_shadow_color == mw->menu.foreground) | |
1608 { | |
1609 topc.pixel = mw->core.background_pixel; | |
31341
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1610 #ifdef emacs |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1611 if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap, |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1612 &topc.pixel, |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1613 1.2, 0x8000)) |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1614 #else |
5626 | 1615 XQueryColor (dpy, cmap, &topc); |
1616 /* don't overflow/wrap! */ | |
1617 topc.red = MINL (65535, topc.red * 1.2); | |
1618 topc.green = MINL (65535, topc.green * 1.2); | |
1619 topc.blue = MINL (65535, topc.blue * 1.2); | |
1620 if (XAllocColor (dpy, cmap, &topc)) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1621 #endif |
5626 | 1622 { |
1623 mw->menu.top_shadow_color = topc.pixel; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1624 mw->menu.free_top_shadow_color_p = 1; |
5626 | 1625 top_frobbed = 1; |
1626 } | |
1627 } | |
1628 if (mw->menu.bottom_shadow_color == mw->menu.foreground || | |
1629 mw->menu.bottom_shadow_color == mw->core.background_pixel) | |
1630 { | |
1631 botc.pixel = mw->core.background_pixel; | |
31341
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1632 #ifdef emacs |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1633 if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap, |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1634 &botc.pixel, |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1635 0.6, 0x4000)) |
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1636 #else |
5626 | 1637 XQueryColor (dpy, cmap, &botc); |
1638 botc.red *= 0.6; | |
1639 botc.green *= 0.6; | |
1640 botc.blue *= 0.6; | |
1641 if (XAllocColor (dpy, cmap, &botc)) | |
25034
305d2ac394ae
(make_shadow_gcs) ]emacs]: Use x_alloc_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents:
19960
diff
changeset
|
1642 #endif |
5626 | 1643 { |
1644 mw->menu.bottom_shadow_color = botc.pixel; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1645 mw->menu.free_bottom_shadow_color_p = 1; |
5626 | 1646 bottom_frobbed = 1; |
1647 } | |
1648 } | |
1649 | |
1650 if (top_frobbed && bottom_frobbed) | |
1651 { | |
31341
1c5d68acbded
(x_alloc_lighter_color_for_widget):
Miles Bader <miles@gnu.org>
parents:
31287
diff
changeset
|
1652 if (topc.pixel == botc.pixel) |
5626 | 1653 { |
1654 if (botc.pixel == mw->menu.foreground) | |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1655 { |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1656 if (mw->menu.free_top_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1657 { |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1658 x_free_dpy_colors (dpy, screen, cmap, |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1659 &mw->menu.top_shadow_color, 1); |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1660 mw->menu.free_top_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1661 } |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1662 mw->menu.top_shadow_color = mw->core.background_pixel; |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1663 } |
5626 | 1664 else |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1665 { |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1666 if (mw->menu.free_bottom_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1667 { |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1668 x_free_dpy_colors (dpy, screen, cmap, |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1669 &mw->menu.bottom_shadow_color, 1); |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1670 mw->menu.free_bottom_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1671 } |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1672 mw->menu.bottom_shadow_color = mw->menu.foreground; |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1673 } |
5626 | 1674 } |
1675 } | |
1676 | |
1677 if (!mw->menu.top_shadow_pixmap && | |
1678 mw->menu.top_shadow_color == mw->core.background_pixel) | |
1679 { | |
1680 mw->menu.top_shadow_pixmap = mw->menu.gray_pixmap; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1681 if (mw->menu.free_top_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1682 { |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1683 x_free_dpy_colors (dpy, screen, cmap, &mw->menu.top_shadow_color, 1); |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1684 mw->menu.free_top_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1685 } |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1686 mw->menu.top_shadow_color = mw->menu.foreground; |
5626 | 1687 } |
1688 if (!mw->menu.bottom_shadow_pixmap && | |
1689 mw->menu.bottom_shadow_color == mw->core.background_pixel) | |
1690 { | |
1691 mw->menu.bottom_shadow_pixmap = mw->menu.gray_pixmap; | |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1692 if (mw->menu.free_bottom_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1693 { |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1694 x_free_dpy_colors (dpy, screen, cmap, |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1695 &mw->menu.bottom_shadow_color, 1); |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1696 mw->menu.free_bottom_shadow_color_p = 0; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1697 } |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1698 mw->menu.bottom_shadow_color = mw->menu.foreground; |
5626 | 1699 } |
1700 | |
1701 xgcv.fill_style = FillStippled; | |
1702 xgcv.foreground = mw->menu.top_shadow_color; | |
1703 xgcv.stipple = mw->menu.top_shadow_pixmap; | |
1704 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); | |
1705 mw->menu.shadow_top_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv); | |
1706 | |
1707 xgcv.foreground = mw->menu.bottom_shadow_color; | |
1708 xgcv.stipple = mw->menu.bottom_shadow_pixmap; | |
1709 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); | |
1710 mw->menu.shadow_bottom_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv); | |
1711 } | |
1712 | |
1713 | |
1714 static void | |
8860 | 1715 release_shadow_gcs (mw) |
1716 XlwMenuWidget mw; | |
5626 | 1717 { |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1718 Display *dpy = XtDisplay ((Widget) mw); |
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1719 Screen *screen = XtScreen ((Widget) mw); |
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1720 Colormap cmap = mw->core.colormap; |
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1721 Pixel px[2]; |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1722 int i = 0; |
29602
d13e7c93d265
(make_shadow_gcs): Free and copy colors so that
Gerd Moellmann <gerd@gnu.org>
parents:
29469
diff
changeset
|
1723 |
29700
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1724 if (mw->menu.free_top_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1725 px[i++] = mw->menu.top_shadow_color; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1726 if (mw->menu.free_bottom_shadow_color_p) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1727 px[i++] = mw->menu.bottom_shadow_color; |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1728 if (i > 0) |
1e88ad071a1a
(make_shadow_gcs): Set free_top_shadow_color_p
Gerd Moellmann <gerd@gnu.org>
parents:
29602
diff
changeset
|
1729 x_free_dpy_colors (dpy, screen, cmap, px, i); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1730 |
5626 | 1731 XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc); |
1732 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc); | |
1733 } | |
1734 | |
1735 static void | |
9746
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1736 XlwMenuInitialize (request, mw, args, num_args) |
8860 | 1737 Widget request; |
9746
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1738 XlwMenuWidget mw; |
8860 | 1739 ArgList args; |
1740 Cardinal *num_args; | |
5626 | 1741 { |
1742 /* Get the GCs and the widget size */ | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1743 |
5626 | 1744 Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw))); |
1745 Display* display = XtDisplay (mw); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1746 |
8860 | 1747 #if 0 |
1748 widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); | |
1749 | |
1750 /* _XtCreate is freeing the object that was passed to us, | |
1751 so make a copy that we will actually keep. */ | |
1752 lwlib_bcopy (mw->menu.contents, tem, sizeof (widget_value)); | |
1753 mw->menu.contents = tem; | |
1754 #endif | |
1755 | |
5626 | 1756 /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */ |
1757 mw->menu.cursor = mw->menu.cursor_shape; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1758 |
11885
c686f5539749
(XlwMenuInitialize): Cast XCreatePixmapFromBitmapData args.
Karl Heuer <kwzh@gnu.org>
parents:
11461
diff
changeset
|
1759 mw->menu.gray_pixmap |
30324
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
1760 = XCreatePixmapFromBitmapData (display, window, gray_bitmap_bits, |
d4713daa6716
Don't include <X11/bitmaps/gray> because that
Gerd Moellmann <gerd@gnu.org>
parents:
29700
diff
changeset
|
1761 gray_bitmap_width, gray_bitmap_height, |
11885
c686f5539749
(XlwMenuInitialize): Cast XCreatePixmapFromBitmapData args.
Karl Heuer <kwzh@gnu.org>
parents:
11461
diff
changeset
|
1762 (unsigned long)1, (unsigned long)0, 1); |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1763 |
9746
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1764 /* I don't understand why this ends up 0 sometimes, |
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1765 but it does. This kludge works around it. |
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1766 Can anyone find a real fix? -- rms. */ |
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1767 if (mw->menu.font == 0) |
49e984bf6689
(xlwmenu_default_font): New global variable.
Richard M. Stallman <rms@gnu.org>
parents:
9700
diff
changeset
|
1768 mw->menu.font = xlwmenu_default_font; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1769 #ifdef HAVE_X_I18N |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1770 if (mw->menu.fontSet) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1771 mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet); |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1772 #endif |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1773 |
5626 | 1774 make_drawing_gcs (mw); |
1775 make_shadow_gcs (mw); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1776 |
5626 | 1777 mw->menu.popped_up = False; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1778 |
5626 | 1779 mw->menu.old_depth = 1; |
1780 mw->menu.old_stack = (widget_value**)XtMalloc (sizeof (widget_value*)); | |
1781 mw->menu.old_stack_length = 1; | |
1782 mw->menu.old_stack [0] = mw->menu.contents; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1783 |
5626 | 1784 mw->menu.new_depth = 0; |
1785 mw->menu.new_stack = 0; | |
1786 mw->menu.new_stack_length = 0; | |
1787 push_new_stack (mw, mw->menu.contents); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1788 |
5626 | 1789 mw->menu.windows = (window_state*)XtMalloc (sizeof (window_state)); |
1790 mw->menu.windows_length = 1; | |
1791 mw->menu.windows [0].x = 0; | |
1792 mw->menu.windows [0].y = 0; | |
1793 mw->menu.windows [0].width = 0; | |
1794 mw->menu.windows [0].height = 0; | |
1795 size_menu (mw, 0); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1796 |
5626 | 1797 mw->core.width = mw->menu.windows [0].width; |
1798 mw->core.height = mw->menu.windows [0].height; | |
1799 } | |
1800 | |
1801 static void | |
1802 XlwMenuClassInitialize () | |
1803 { | |
1804 } | |
1805 | |
1806 static void | |
8860 | 1807 XlwMenuRealize (w, valueMask, attributes) |
1808 Widget w; | |
1809 Mask *valueMask; | |
1810 XSetWindowAttributes *attributes; | |
5626 | 1811 { |
1812 XlwMenuWidget mw = (XlwMenuWidget)w; | |
1813 XSetWindowAttributes xswa; | |
1814 int mask; | |
1815 | |
1816 (*xlwMenuWidgetClass->core_class.superclass->core_class.realize) | |
1817 (w, valueMask, attributes); | |
1818 | |
1819 xswa.save_under = True; | |
1820 xswa.cursor = mw->menu.cursor_shape; | |
1821 mask = CWSaveUnder | CWCursor; | |
1822 XChangeWindowAttributes (XtDisplay (w), XtWindow (w), mask, &xswa); | |
1823 | |
1824 mw->menu.windows [0].window = XtWindow (w); | |
1825 mw->menu.windows [0].x = w->core.x; | |
1826 mw->menu.windows [0].y = w->core.y; | |
1827 mw->menu.windows [0].width = w->core.width; | |
1828 mw->menu.windows [0].height = w->core.height; | |
1829 } | |
1830 | |
1831 /* Only the toplevel menubar/popup is a widget so it's the only one that | |
1832 receives expose events through Xt. So we repaint all the other panes | |
1833 when receiving an Expose event. */ | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1834 static void |
8860 | 1835 XlwMenuRedisplay (w, ev, region) |
1836 Widget w; | |
1837 XEvent* ev; | |
1838 Region region; | |
5626 | 1839 { |
1840 XlwMenuWidget mw = (XlwMenuWidget)w; | |
1841 int i; | |
1842 | |
8860 | 1843 /* If we have a depth beyond 1, it's because a submenu was displayed. |
1844 If the submenu has been destroyed, set the depth back to 1. */ | |
1845 if (submenu_destroyed) | |
1846 { | |
1847 mw->menu.old_depth = 1; | |
1848 submenu_destroyed = 0; | |
1849 } | |
1850 | |
5626 | 1851 for (i = 0; i < mw->menu.old_depth; i++) |
1852 display_menu (mw, i, False, NULL, NULL, NULL, NULL, NULL); | |
1853 } | |
1854 | |
33714
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1855 |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1856 /* Part of a hack to make the menu redisplay when a tooltip frame |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1857 over a menu item is unmapped. */ |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1858 |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1859 void |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1860 xlwmenu_redisplay (w) |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1861 Widget w; |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1862 { |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1863 XlwMenuRedisplay (w, NULL, None); |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1864 } |
f957a9063fb1
(xlwmenu_redisplay): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31963
diff
changeset
|
1865 |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1866 static void |
8860 | 1867 XlwMenuDestroy (w) |
1868 Widget w; | |
5626 | 1869 { |
1870 int i; | |
1871 XlwMenuWidget mw = (XlwMenuWidget) w; | |
1872 | |
8860 | 1873 if (pointer_grabbed) |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
1874 ungrab_all ((Widget)w, CurrentTime); |
8860 | 1875 pointer_grabbed = 0; |
1876 | |
1877 submenu_destroyed = 1; | |
1878 | |
5626 | 1879 release_drawing_gcs (mw); |
1880 release_shadow_gcs (mw); | |
1881 | |
1882 /* this doesn't come from the resource db but is created explicitly | |
1883 so we must free it ourselves. */ | |
1884 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap); | |
1885 mw->menu.gray_pixmap = (Pixmap) -1; | |
1886 | |
8860 | 1887 #if 0 |
1888 /* Do free mw->menu.contents because nowadays we copy it | |
1889 during initialization. */ | |
1890 XtFree (mw->menu.contents); | |
1891 #endif | |
1892 | |
5626 | 1893 /* Don't free mw->menu.contents because that comes from our creator. |
1894 The `*_stack' elements are just pointers into `contents' so leave | |
1895 that alone too. But free the stacks themselves. */ | |
1896 if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack); | |
1897 if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack); | |
1898 | |
1899 /* Remember, you can't free anything that came from the resource | |
1900 database. This includes: | |
1901 mw->menu.cursor | |
1902 mw->menu.top_shadow_pixmap | |
1903 mw->menu.bottom_shadow_pixmap | |
1904 mw->menu.font | |
1905 Also the color cells of top_shadow_color, bottom_shadow_color, | |
1906 foreground, and button_foreground will never be freed until this | |
1907 client exits. Nice, eh? | |
1908 */ | |
1909 | |
1910 /* start from 1 because the one in slot 0 is w->core.window */ | |
1911 for (i = 1; i < mw->menu.windows_length; i++) | |
1912 XDestroyWindow (XtDisplay (mw), mw->menu.windows [i].window); | |
1913 if (mw->menu.windows) | |
1914 XtFree ((char *) mw->menu.windows); | |
1915 } | |
1916 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1917 static Boolean |
8860 | 1918 XlwMenuSetValues (current, request, new) |
1919 Widget current; | |
1920 Widget request; | |
1921 Widget new; | |
5626 | 1922 { |
1923 XlwMenuWidget oldmw = (XlwMenuWidget)current; | |
1924 XlwMenuWidget newmw = (XlwMenuWidget)new; | |
1925 Boolean redisplay = False; | |
1926 int i; | |
1927 | |
1928 if (newmw->menu.contents | |
1929 && newmw->menu.contents->contents | |
1930 && newmw->menu.contents->contents->change >= VISIBLE_CHANGE) | |
1931 redisplay = True; | |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
1932 /* Do redisplay if the contents are entirely eliminated. */ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
1933 if (newmw->menu.contents |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
1934 && newmw->menu.contents->contents == 0 |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
1935 && newmw->menu.contents->change >= VISIBLE_CHANGE) |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
1936 redisplay = True; |
5626 | 1937 |
1938 if (newmw->core.background_pixel != oldmw->core.background_pixel | |
8860 | 1939 || newmw->menu.foreground != oldmw->menu.foreground |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1940 #ifdef HAVE_X_I18N |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1941 || newmw->menu.fontSet != oldmw->menu.fontSet |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1942 || (newmw->menu.fontSet == NULL && newmw->menu.font != oldmw->menu.font) |
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1943 #else |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1944 || newmw->menu.font != oldmw->menu.font |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1945 #endif |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1946 ) |
5626 | 1947 { |
1948 release_drawing_gcs (newmw); | |
1949 make_drawing_gcs (newmw); | |
31287 | 1950 |
1951 release_shadow_gcs (newmw); | |
1952 /* Cause the shadow colors to be recalculated. */ | |
1953 newmw->menu.top_shadow_color = -1; | |
1954 newmw->menu.bottom_shadow_color = -1; | |
1955 make_shadow_gcs (newmw); | |
1956 | |
5626 | 1957 redisplay = True; |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1958 |
31369
6aa8a6e72c0f
(XlwMenuSetValues): Pass the correct pointer type to XtIsRealized.
Miles Bader <miles@gnu.org>
parents:
31364
diff
changeset
|
1959 if (XtIsRealized (current)) |
31364
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1960 /* If the menu is currently displayed, change the display. */ |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1961 for (i = 0; i < oldmw->menu.windows_length; i++) |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1962 { |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1963 XSetWindowBackground (XtDisplay (oldmw), |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1964 oldmw->menu.windows [i].window, |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1965 newmw->core.background_pixel); |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1966 /* clear windows and generate expose events */ |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1967 XClearArea (XtDisplay (oldmw), oldmw->menu.windows[i].window, |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1968 0, 0, 0, 0, True); |
8bafcf2cfd57
(XlwMenuSetValues): Only frob the display if the menu is actually displayed.
Miles Bader <miles@gnu.org>
parents:
31341
diff
changeset
|
1969 } |
5626 | 1970 } |
1971 | |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1972 #ifdef HAVE_X_I18N |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1973 if (newmw->menu.fontSet != oldmw->menu.fontSet && newmw->menu.fontSet != NULL) |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1974 { |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1975 redisplay = True; |
61209
0769f2fae9d0
* xlwmenu.c (string_width):
Jan Djärv <jan.h.d@swipnet.se>
parents:
60829
diff
changeset
|
1976 newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.fontSet); |
60698
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1977 } |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1978 #endif |
3e557e11645e
Add support for I18N to Lucid menus.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59100
diff
changeset
|
1979 |
5626 | 1980 return redisplay; |
1981 } | |
1982 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
1983 static void |
8860 | 1984 XlwMenuResize (w) |
1985 Widget w; | |
5626 | 1986 { |
1987 XlwMenuWidget mw = (XlwMenuWidget)w; | |
1988 | |
8860 | 1989 if (mw->menu.popped_up) |
1990 { | |
1991 /* Don't allow the popup menu to resize itself. */ | |
1992 mw->core.width = mw->menu.windows [0].width; | |
1993 mw->core.height = mw->menu.windows [0].height; | |
1994 mw->core.parent->core.width = mw->core.width ; | |
1995 mw->core.parent->core.height = mw->core.height ; | |
1996 } | |
1997 else | |
1998 { | |
1999 mw->menu.windows [0].width = mw->core.width; | |
2000 mw->menu.windows [0].height = mw->core.height; | |
2001 } | |
5626 | 2002 } |
2003 | |
2004 /* Action procedures */ | |
2005 static void | |
8860 | 2006 handle_single_motion_event (mw, ev) |
2007 XlwMenuWidget mw; | |
2008 XMotionEvent* ev; | |
5626 | 2009 { |
2010 widget_value* val; | |
2011 int level; | |
2012 | |
2013 if (!map_event_to_widget_value (mw, ev, &val, &level)) | |
2014 pop_new_stack_if_no_contents (mw); | |
2015 else | |
2016 set_new_state (mw, val, level); | |
2017 remap_menubar (mw); | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
2018 |
5626 | 2019 /* Sync with the display. Makes it feel better on X terms. */ |
2020 XSync (XtDisplay (mw), False); | |
2021 } | |
2022 | |
2023 static void | |
8860 | 2024 handle_motion_event (mw, ev) |
2025 XlwMenuWidget mw; | |
2026 XMotionEvent* ev; | |
5626 | 2027 { |
2028 int x = ev->x_root; | |
2029 int y = ev->y_root; | |
2030 int state = ev->state; | |
2031 | |
2032 handle_single_motion_event (mw, ev); | |
2033 | |
2034 /* allow motion events to be generated again */ | |
2035 if (ev->is_hint | |
2036 && XQueryPointer (XtDisplay (mw), ev->window, | |
2037 &ev->root, &ev->subwindow, | |
2038 &ev->x_root, &ev->y_root, | |
2039 &ev->x, &ev->y, | |
2040 &ev->state) | |
2041 && ev->state == state | |
2042 && (ev->x_root != x || ev->y_root != y)) | |
2043 handle_single_motion_event (mw, ev); | |
2044 } | |
2045 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
2046 static void |
8860 | 2047 Start (w, ev, params, num_params) |
2048 Widget w; | |
2049 XEvent *ev; | |
2050 String *params; | |
2051 Cardinal *num_params; | |
5626 | 2052 { |
2053 XlwMenuWidget mw = (XlwMenuWidget)w; | |
2054 | |
8860 | 2055 if (!mw->menu.popped_up) |
2056 { | |
2057 menu_post_event = *ev; | |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2058 /* If event is set to CurrentTime, get the last known time stamp. |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2059 This is for calculating if (popup) menus should stay up after |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2060 a fast click. */ |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2061 if (menu_post_event.xbutton.time == CurrentTime) |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2062 menu_post_event.xbutton.time |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2063 = XtLastTimestampProcessed (XtDisplay (w)); |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2064 |
29469
f9b5fe053f7c
(x_alloc_nearest_color_for_widget, x_catch_errors, x_uncatch_errors)
Dave Love <fx@gnu.org>
parents:
27988
diff
changeset
|
2065 pop_up_menu (mw, (XButtonPressedEvent*) ev); |
8860 | 2066 } |
2067 else | |
9027 | 2068 { |
2069 /* If we push a button while the menu is posted semipermanently, | |
2070 releasing the button should always pop the menu down. */ | |
2071 next_release_must_exit = 1; | |
5626 | 2072 |
9027 | 2073 /* notes the absolute position of the menubar window */ |
2074 mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x; | |
2075 mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y; | |
2076 | |
2077 /* handles the down like a move, slots are compatible */ | |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
2078 ev->xmotion.is_hint = 0; |
9027 | 2079 handle_motion_event (mw, &ev->xmotion); |
2080 } | |
5626 | 2081 } |
2082 | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
2083 static void |
8860 | 2084 Drag (w, ev, params, num_params) |
2085 Widget w; | |
2086 XEvent *ev; | |
2087 String *params; | |
2088 Cardinal *num_params; | |
5626 | 2089 { |
2090 XlwMenuWidget mw = (XlwMenuWidget)w; | |
11987
9619c1121b43
(Drag): Do nothing unless menu.popped_up field is set.
Karl Heuer <kwzh@gnu.org>
parents:
11885
diff
changeset
|
2091 if (mw->menu.popped_up) |
9619c1121b43
(Drag): Do nothing unless menu.popped_up field is set.
Karl Heuer <kwzh@gnu.org>
parents:
11885
diff
changeset
|
2092 handle_motion_event (mw, &ev->xmotion); |
5626 | 2093 } |
2094 | |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2095 /* Do nothing. |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2096 This is how we handle presses and releases of modifier keys. */ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2097 static void |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2098 Nothing (w, ev, params, num_params) |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2099 Widget w; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2100 XEvent *ev; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2101 String *params; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2102 Cardinal *num_params; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2103 { |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2104 } |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2105 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2106 static widget_value * |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2107 find_first_selectable (mw, item, skip_titles) |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2108 XlwMenuWidget mw; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2109 widget_value *item; |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2110 int skip_titles; |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2111 { |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2112 widget_value *current = item; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2113 enum menu_separator separator; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2114 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2115 while (lw_separator_p (current->name, &separator, 0) || !current->enabled |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2116 || (skip_titles && !current->call_data && !current->contents)) |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2117 if (current->next) |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2118 current=current->next; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2119 else |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2120 return NULL; |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2121 |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2122 return current; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2123 } |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2124 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2125 static widget_value * |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2126 find_next_selectable (mw, item, skip_titles) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2127 XlwMenuWidget mw; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2128 widget_value *item; |
65713
ad24f42046b1
* xlwmenu.c (find_next_selectable):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
65684
diff
changeset
|
2129 int skip_titles; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2130 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2131 widget_value *current = item; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2132 enum menu_separator separator; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2133 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2134 while (current->next && (current=current->next) && |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2135 (lw_separator_p (current->name, &separator, 0) || !current->enabled |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2136 || (skip_titles && !current->call_data && !current->contents))) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2137 ; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2138 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2139 if (current == item) |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2140 { |
45147
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
2141 if (mw->menu.old_depth < 2) |
e10cf8f440ae
(xlwMenuResources): New resource.
Pavel Janík <Pavel@Janik.cz>
parents:
44966
diff
changeset
|
2142 return current; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2143 current = mw->menu.old_stack [mw->menu.old_depth - 2]->contents; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2144 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2145 while (lw_separator_p (current->name, &separator, 0) |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2146 || !current->enabled |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2147 || (skip_titles && !current->call_data |
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2148 && !current->contents)) |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2149 { |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2150 if (current->next) |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2151 current=current->next; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2152 |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2153 if (current == item) |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2154 break; |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2155 } |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2156 |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2157 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2158 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2159 return current; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2160 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2161 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2162 static widget_value * |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2163 find_prev_selectable (mw, item, skip_titles) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2164 XlwMenuWidget mw; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2165 widget_value *item; |
65713
ad24f42046b1
* xlwmenu.c (find_next_selectable):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
65684
diff
changeset
|
2166 int skip_titles; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2167 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2168 widget_value *current = item; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2169 widget_value *prev = item; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2170 |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2171 while ((current=find_next_selectable (mw, current, skip_titles)) |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2172 != item) |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2173 { |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2174 if (prev == current) |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2175 break; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2176 prev=current; |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2177 } |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2178 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2179 return prev; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2180 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2181 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2182 static void |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2183 Down (w, ev, params, num_params) |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2184 Widget w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2185 XEvent *ev; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2186 String *params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2187 Cardinal *num_params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2188 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2189 XlwMenuWidget mw = (XlwMenuWidget) w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2190 widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2191 int popup_menu_p = mw->menu.top_depth == 1; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2192 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2193 /* Inside top-level menu-bar? */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2194 if (mw->menu.old_depth == mw->menu.top_depth) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2195 /* When <down> in the menu-bar is pressed, display the corresponding |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2196 sub-menu and select the first selectable menu item there. |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2197 If this is a popup menu, skip title item of the popup. */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2198 set_new_state (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2199 find_first_selectable (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2200 selected_item->contents, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2201 popup_menu_p), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2202 mw->menu.old_depth); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2203 else |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2204 /* Highlight next possible (enabled and not separator) menu item. */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2205 set_new_state (mw, find_next_selectable (mw, selected_item, popup_menu_p), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2206 mw->menu.old_depth - 1); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2207 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2208 remap_menubar (mw); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2209 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2210 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2211 static void |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2212 Up (w, ev, params, num_params) |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2213 Widget w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2214 XEvent *ev; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2215 String *params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2216 Cardinal *num_params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2217 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2218 XlwMenuWidget mw = (XlwMenuWidget) w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2219 widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2220 int popup_menu_p = mw->menu.top_depth == 1; |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2221 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2222 /* Inside top-level menu-bar? */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2223 if (mw->menu.old_depth == mw->menu.top_depth) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2224 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2225 /* FIXME: this is tricky. <up> in the menu-bar should select the |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2226 last selectable item in the list. So we select the first |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2227 selectable one and find the previous selectable item. Is there |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2228 a better way? */ |
57842
2c65a9fc7dec
* xlwmenu.c (find_first_selectable, find_next_selectable)
Jan Djärv <jan.h.d@swipnet.se>
parents:
53564
diff
changeset
|
2229 /* If this is a popup menu, skip title item of the popup. */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2230 set_new_state (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2231 find_first_selectable (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2232 selected_item->contents, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2233 popup_menu_p), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2234 mw->menu.old_depth); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2235 remap_menubar (mw); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2236 selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2237 set_new_state (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2238 find_prev_selectable (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2239 selected_item, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2240 popup_menu_p), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2241 mw->menu.old_depth - 1); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2242 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2243 else |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2244 /* Highlight previous (enabled and not separator) menu item. */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2245 set_new_state (mw, find_prev_selectable (mw, selected_item, popup_menu_p), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2246 mw->menu.old_depth - 1); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2247 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2248 remap_menubar (mw); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2249 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2250 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2251 void |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2252 Left (w, ev, params, num_params) |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2253 Widget w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2254 XEvent *ev; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2255 String *params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2256 Cardinal *num_params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2257 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2258 XlwMenuWidget mw = (XlwMenuWidget) w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2259 widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2260 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2261 /* Inside top-level menu-bar? */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2262 if (mw->menu.old_depth == mw->menu.top_depth) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2263 /* When <left> in the menu-bar is pressed, display the previous item on |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2264 the menu-bar. If the current item is the first one, highlight the |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2265 last item in the menubar (probably Help). */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2266 set_new_state (mw, find_prev_selectable (mw, selected_item, 0), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2267 mw->menu.old_depth - 1); |
48929
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2268 else if (mw->menu.old_depth == 1 |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2269 && selected_item->contents) /* Is this menu item expandable? */ |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2270 { |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2271 set_new_state (mw, selected_item->contents, mw->menu.old_depth); |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2272 remap_menubar (mw); |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2273 selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2274 if (!selected_item->enabled && find_first_selectable (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2275 selected_item, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2276 0)) |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2277 set_new_state (mw, find_first_selectable (mw, selected_item, 0), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2278 mw->menu.old_depth - 1); |
48929
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2279 } |
d81c005163cb
(pop_new_stack_if_no_contents): Do nothing if new_depth is 1.
Richard M. Stallman <rms@gnu.org>
parents:
48479
diff
changeset
|
2280 |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2281 else |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2282 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2283 pop_new_stack_if_no_contents (mw); |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2284 set_new_state (mw, mw->menu.old_stack [mw->menu.old_depth - 2], |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2285 mw->menu.old_depth - 2); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2286 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2287 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2288 remap_menubar (mw); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2289 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2290 |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2291 void |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2292 Right (w, ev, params, num_params) |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2293 Widget w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2294 XEvent *ev; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2295 String *params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2296 Cardinal *num_params; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2297 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2298 XlwMenuWidget mw = (XlwMenuWidget) w; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2299 widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2300 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2301 /* Inside top-level menu-bar? */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2302 if (mw->menu.old_depth == mw->menu.top_depth) |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2303 /* When <right> in the menu-bar is pressed, display the next item on |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2304 the menu-bar. If the current item is the last one, highlight the |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2305 first item (probably File). */ |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2306 set_new_state (mw, find_next_selectable (mw, selected_item, 0), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2307 mw->menu.old_depth - 1); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2308 else if (selected_item->contents) /* Is this menu item expandable? */ |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2309 { |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2310 set_new_state (mw, selected_item->contents, mw->menu.old_depth); |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2311 remap_menubar (mw); |
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2312 selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2313 if (!selected_item->enabled && find_first_selectable (mw, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2314 selected_item, |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2315 0)) |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2316 set_new_state (mw, find_first_selectable (mw, selected_item, 0), |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2317 mw->menu.old_depth - 1); |
44713
a05c8614feee
(find_next_selectable): New function.
Pavel Janík <Pavel@Janik.cz>
parents:
44707
diff
changeset
|
2318 } |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2319 else |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2320 { |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2321 pop_new_stack_if_no_contents (mw); |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2322 set_new_state (mw, mw->menu.old_stack [mw->menu.old_depth - 2], |
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2323 mw->menu.old_depth - 2); |
44707
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2324 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2325 |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2326 remap_menubar (mw); |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2327 } |
3444517c6483
(xlwMenuTranslations, xlwMenuActionsList): Add translations for cursor keys
Pavel Janík <Pavel@Janik.cz>
parents:
41767
diff
changeset
|
2328 |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2329 /* Handle key press and release events while menu is popped up. |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2330 Our action is to get rid of the menu. */ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2331 static void |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2332 Key (w, ev, params, num_params) |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2333 Widget w; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2334 XEvent *ev; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2335 String *params; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2336 Cardinal *num_params; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2337 { |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2338 XlwMenuWidget mw = (XlwMenuWidget)w; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2339 |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2340 /* Pop down everything. */ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2341 mw->menu.new_depth = 1; |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2342 remap_menubar (mw); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2343 |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2344 if (mw->menu.popped_up) |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2345 { |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2346 mw->menu.popped_up = False; |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2347 ungrab_all ((Widget)mw, ev->xmotion.time); |
13899
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2348 if (XtIsShell (XtParent ((Widget) mw))) |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2349 XtPopdown (XtParent ((Widget) mw)); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2350 else |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2351 { |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2352 XtRemoveGrab ((Widget) mw); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2353 display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2354 } |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2355 } |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2356 |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2357 /* callback */ |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2358 XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)0); |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2359 } |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2360 |
3fbe9b840379
(xlwMenuActionsList): Add "key" and "nothing".
Richard M. Stallman <rms@gnu.org>
parents:
13560
diff
changeset
|
2361 static void |
8860 | 2362 Select (w, ev, params, num_params) |
2363 Widget w; | |
2364 XEvent *ev; | |
2365 String *params; | |
2366 Cardinal *num_params; | |
5626 | 2367 { |
2368 XlwMenuWidget mw = (XlwMenuWidget)w; | |
2369 widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; | |
31963
833428005bf6
* xlwmenu.c: Before including <X11/Xos.h> on SUN, define SUNOS41
Sam Steingold <sds@gnu.org>
parents:
31370
diff
changeset
|
2370 |
8860 | 2371 /* If user releases the button quickly, without selecting anything, |
2372 after the initial down-click that brought the menu up, | |
2373 do nothing. */ | |
2374 if ((selected_item == 0 | |
2375 || ((widget_value *) selected_item)->call_data == 0) | |
2376 && !next_release_must_exit | |
2377 && (ev->xbutton.time - menu_post_event.xbutton.time | |
2378 < XtGetMultiClickTime (XtDisplay (w)))) | |
2379 return; | |
2380 | |
2381 /* pop down everything. */ | |
5626 | 2382 mw->menu.new_depth = 1; |
2383 remap_menubar (mw); | |
2384 | |
2385 if (mw->menu.popped_up) | |
2386 { | |
2387 mw->menu.popped_up = False; | |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2388 ungrab_all ((Widget)mw, ev->xmotion.time); |
9033 | 2389 if (XtIsShell (XtParent ((Widget) mw))) |
2390 XtPopdown (XtParent ((Widget) mw)); | |
9027 | 2391 else |
2392 { | |
2393 XtRemoveGrab ((Widget) mw); | |
2394 display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL); | |
2395 } | |
5626 | 2396 } |
2397 | |
2398 /* callback */ | |
2399 XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)selected_item); | |
2400 } | |
2401 | |
2402 | |
2403 /* Special code to pop-up a menu */ | |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2404 static void |
8860 | 2405 pop_up_menu (mw, event) |
2406 XlwMenuWidget mw; | |
2407 XButtonPressedEvent* event; | |
5626 | 2408 { |
2409 int x = event->x_root; | |
2410 int y = event->y_root; | |
2411 int w; | |
2412 int h; | |
2413 int borderwidth = mw->menu.shadow_thickness; | |
2414 Screen* screen = XtScreen (mw); | |
9700
d09dc2f44ecb
(pop_up_menu): Pass a Display * to x_catch_errors, etc.
Richard M. Stallman <rms@gnu.org>
parents:
9395
diff
changeset
|
2415 Display *display = XtDisplay (mw); |
5626 | 2416 |
8860 | 2417 next_release_must_exit = 0; |
2418 | |
5626 | 2419 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL); |
2420 | |
9033 | 2421 if (XtIsShell (XtParent ((Widget)mw))) |
9027 | 2422 size_menu (mw, 0); |
5626 | 2423 |
2424 w = mw->menu.windows [0].width; | |
2425 h = mw->menu.windows [0].height; | |
2426 | |
2427 x -= borderwidth; | |
2428 y -= borderwidth; | |
2429 if (x < borderwidth) | |
2430 x = borderwidth; | |
2431 if (x + w + 2 * borderwidth > WidthOfScreen (screen)) | |
2432 x = WidthOfScreen (screen) - w - 2 * borderwidth; | |
2433 if (y < borderwidth) | |
2434 y = borderwidth; | |
2435 if (y + h + 2 * borderwidth> HeightOfScreen (screen)) | |
2436 y = HeightOfScreen (screen) - h - 2 * borderwidth; | |
2437 | |
2438 mw->menu.popped_up = True; | |
9033 | 2439 if (XtIsShell (XtParent ((Widget)mw))) |
9027 | 2440 { |
9033 | 2441 XtConfigureWidget (XtParent ((Widget)mw), x, y, w, h, |
2442 XtParent ((Widget)mw)->core.border_width); | |
2443 XtPopup (XtParent ((Widget)mw), XtGrabExclusive); | |
9027 | 2444 display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL); |
2445 mw->menu.windows [0].x = x + borderwidth; | |
2446 mw->menu.windows [0].y = y + borderwidth; | |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2447 mw->menu.top_depth = 1; /* Popup menus don't have a bar so top is 1 */ |
9027 | 2448 } |
2449 else | |
2450 { | |
2451 XEvent *ev = (XEvent *) event; | |
2452 | |
9092
0033f98d2ffd
Clean up of temporary changes used to try to find a workaround for the
Paul Reilly <pmr@pajato.com>
parents:
9086
diff
changeset
|
2453 XtAddGrab ((Widget) mw, True, True); |
9027 | 2454 |
2455 /* notes the absolute position of the menubar window */ | |
2456 mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x; | |
2457 mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y; | |
53564
609ef1718642
Changes for lucid popup menus (keyboard traversal enabled) and dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2458 mw->menu.top_depth = 2; |
9027 | 2459 } |
2460 | |
8860 | 2461 #ifdef emacs |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
2462 x_catch_errors (display); |
8860 | 2463 #endif |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2464 if (XtGrabPointer ((Widget)mw, False, |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2465 (PointerMotionMask |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2466 | PointerMotionHintMask |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2467 | ButtonReleaseMask |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2468 | ButtonPressMask), |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2469 GrabModeAsync, GrabModeAsync, None, |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2470 mw->menu.cursor_shape, |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2471 event->time) == Success) |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2472 { |
44931
18616c930588
Do not grab keyboard if installation-directory is
Jan Djärv <jan.h.d@swipnet.se>
parents:
44750
diff
changeset
|
2473 if (! GRAB_KEYBOARD |
44750
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2474 || XtGrabKeyboard ((Widget)mw, False, GrabModeAsync, |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2475 GrabModeAsync, event->time) == Success) |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2476 { |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2477 XtSetKeyboardFocus((Widget)mw, None); |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2478 pointer_grabbed = 1; |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2479 } |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2480 else |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2481 XtUngrabPointer ((Widget)mw, event->time); |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2482 } |
2e7603e0c455
Add calls to Grab/UngrabKeyboard to remove strange interactions with
Jan Djärv <jan.h.d@swipnet.se>
parents:
44713
diff
changeset
|
2483 |
8860 | 2484 #ifdef emacs |
9700
d09dc2f44ecb
(pop_up_menu): Pass a Display * to x_catch_errors, etc.
Richard M. Stallman <rms@gnu.org>
parents:
9395
diff
changeset
|
2485 if (x_had_errors_p (display)) |
8860 | 2486 { |
2487 pointer_grabbed = 0; | |
2488 XtUngrabPointer ((Widget)mw, event->time); | |
2489 } | |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
2490 x_uncatch_errors (); |
8860 | 2491 #endif |
5626 | 2492 |
70850
b90abedf3b79
* xlwmenu.c: Include xterm.h if emacs instead of declaring functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68640
diff
changeset
|
2493 ((XMotionEvent*)event)->is_hint = 0; |
5626 | 2494 handle_motion_event (mw, (XMotionEvent*)event); |
2495 } | |
52401 | 2496 |
2497 /* arch-tag: 657f43dd-dfd0-4cc9-910c-52935f01176e | |
2498 (do not change this comment) */ |