annotate lwlib/xlwmenu.c @ 394:7d59cb494b73 r21-2-12

Import from CVS: tag r21-2-12
author cvs
date Mon, 13 Aug 2007 11:11:37 +0200
parents 8626e4521993
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1 /* Implements a lightweight menubar widget.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of the Lucid Widget Library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
7 The Lucid Widget Library is free software; you can redistribute it and/or
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 modify it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be useful,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
20 Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Created by devin@lucid.com */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 136
diff changeset
24 #include <config.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <string.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <stdio.h>
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 136
diff changeset
29 #include <sys/types.h>
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
30 #include <limits.h>
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 136
diff changeset
31 #ifdef HAVE_UNISTD_H
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 136
diff changeset
32 #include <unistd.h>
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 136
diff changeset
33 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include <X11/IntrinsicP.h>
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
36 #include <X11/ShellP.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include <X11/cursorfont.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include <X11/bitmaps/gray>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include <Xm/Xm.h>
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
43 #if XmVersion < 1002 /* 1.1 or ancient */
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
44 #undef XmFONTLIST_DEFAULT_TAG
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
45 #define XmFONTLIST_DEFAULT_TAG XmSTRING_DEFAULT_CHARSET
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
46 #endif /* XmVersion < 1.2 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include "xlwmenuP.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
50 #ifdef USE_DEBUG_MALLOC
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
51 #include <dmalloc.h>
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
52 #endif
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
53
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
54 /* simple, naieve integer maximum */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
55 #ifndef max
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
56 #define max(a,b) ((a)>(b)?(a):(b))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
57 #endif
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
58
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
59 static char
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
60 xlwMenuTranslations [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "<BtnDown>: start()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 <BtnMotion>: drag()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 <BtnUp>: select()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
66 extern Widget lw_menubar_widget;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
67
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #define offset(field) XtOffset(XlwMenuWidget, field)
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
69 static XtResource
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 xlwMenuResources[] =
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
71 {
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 /* There are three font list resources, so that we can accept either of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 the resources *fontList: or *font:, and so that we can tell the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 difference between them being specified, and being defaulted to a
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
76 font from the XtRString specified here. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 offset(menu.font_list), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 {XtNfont, XtCFont, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 offset(menu.font_list_2),XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 offset(menu.fallback_font_list),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 /* We must use an iso8859-1 font here, or people without $LANG set lose.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 It's fair to assume that those who do have $LANG set also have the
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
85 *fontList resource set, or at least know how to deal with this. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
86 XtRString, (XtPointer) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
89 offset(menu.font), XtRString, (XtPointer) "XtDefaultFont"},
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
90 # ifdef USE_XFONTSET
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
91 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
92 offset(menu.font_set), XtRString, (XtPointer) "XtDefaultFontSet"},
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
93 # endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
96 offset(menu.foreground), XtRString, (XtPointer) "XtDefaultForeground"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
98 offset(menu.button_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
99 {XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
100 offset(menu.highlight_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
101 {XtNtitleForeground, XtCTitleForeground, XtRPixel, sizeof(Pixel),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
102 offset(menu.title_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 offset(menu.margin), XtRImmediate, (XtPointer)2},
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
105 {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2},
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
107 {XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension, sizeof(Dimension),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1},
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
109 {XmNspacing, XmCSpacing, XmRHorizontalDimension, sizeof(Dimension),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 offset(menu.column_spacing), XtRImmediate, (XtPointer)4},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 offset(menu.indicator_size), XtRImmediate, (XtPointer)0},
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
113 #if 0
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
114 {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 sizeof (Dimension), offset (menu.shadow_thickness),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 XtRImmediate, (XtPointer) 2},
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
117 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
118 {XmNshadowThickness, XmCShadowThickness, XtRDimension,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
119 sizeof (Dimension), offset (menu.shadow_thickness),
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
120 XtRImmediate, (XtPointer) 2},
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
121 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 offset (menu.select_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 {XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 offset (menu.bottom_shadow_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 {XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap, sizeof (Pixmap),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 offset (menu.top_shadow_pixmap), XtRImmediate, (XtPointer)None},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 {XmNbottomShadowPixmap, XmCBottomShadowPixmap, XtRPixmap, sizeof (Pixmap),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
133 {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 offset(menu.open), XtRCallback, (XtPointer)NULL},
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
135 {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 offset(menu.select), XtRCallback, (XtPointer)NULL},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 offset(menu.contents), XtRImmediate, (XtPointer)NULL},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
140 offset(menu.cursor_shape), XtRString, (XtPointer) "right_ptr"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 offset(menu.horizontal), XtRImmediate, (XtPointer)True},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 offset (menu.use_backing_store), XtRImmediate, (XtPointer)False},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 {XtNbounceDown, XtCBounceDown, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 offset (menu.bounce_down), XtRImmediate, (XtPointer)True},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 {XtNresourceLabels, XtCResourceLabels, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 offset (menu.lookup_labels), XtRImmediate, (XtPointer)False},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 #undef offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 static Boolean XlwMenuSetValues (Widget current, Widget request, Widget new,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ArgList args, Cardinal *num_args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 static void XlwMenuRealize (Widget w, Mask *valueMask,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 XSetWindowAttributes *attributes);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 static void XlwMenuRedisplay (Widget w, XEvent *ev, Region region);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 static void XlwMenuResize (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 static void XlwMenuInitialize (Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 Cardinal *num_args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 static void XlwMenuDestroy (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 static void XlwMenuClassInitialize (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params);
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
163 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params);
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
164 static void Select(Widget w, XEvent *ev, String *params, Cardinal *num_params);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 static XFontStruct *default_font_of_font_list (XmFontList);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
170 static XtActionsRec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 xlwMenuActionsList [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
173 {"start", Start},
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
174 {"drag", Drag},
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
175 {"select", Select},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 #define SuperClass ((CoreWidgetClass)&coreClassRec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 XlwMenuClassRec xlwMenuClassRec =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 { /* CoreClass fields initialization */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
183 (WidgetClass) SuperClass, /* superclass */
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
184 "XlwMenu", /* class_name */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 sizeof(XlwMenuRec), /* size */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 XlwMenuClassInitialize, /* class_initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 NULL, /* class_part_initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 FALSE, /* class_inited */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 XlwMenuInitialize, /* initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 NULL, /* initialize_hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 XlwMenuRealize, /* realize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 xlwMenuActionsList, /* actions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 XtNumber(xlwMenuActionsList), /* num_actions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 xlwMenuResources, /* resources */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 XtNumber(xlwMenuResources), /* resource_count */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 NULLQUARK, /* xrm_class */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 TRUE, /* compress_motion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 TRUE, /* compress_exposure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 TRUE, /* compress_enterleave */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 FALSE, /* visible_interest */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 XlwMenuDestroy, /* destroy */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 XlwMenuResize, /* resize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 XlwMenuRedisplay, /* expose */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 XlwMenuSetValues, /* set_values */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 NULL, /* set_values_hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 XtInheritSetValuesAlmost, /* set_values_almost */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 NULL, /* get_values_hook */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
208 NULL, /* #### - should this be set for grabs? accept_focus */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 XtVersion, /* version */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 NULL, /* callback_private */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 xlwMenuTranslations, /* tm_table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 XtInheritQueryGeometry, /* query_geometry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 XtInheritDisplayAccelerator, /* display_accelerator */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 NULL /* extension */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 }, /* XlwMenuClass fields initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 0 /* dummy */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 WidgetClass xlwMenuWidgetClass = (WidgetClass) &xlwMenuClassRec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
223 extern int lw_menu_accelerate;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
224
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 /* Utilities */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 #if 0 /* Apparently not used anywhere */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 safe_strdup (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 if (! s) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 result = (char *) malloc (strlen (s) + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 if (! result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 strcpy (result, s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 /* Replacement for XAllocColor() that tries to return the nearest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 available color if the colormap is full. From FSF Emacs. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 allocate_nearest_color (Display *display, Colormap screen_colormap,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 XColor *color_def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
249 int status = XAllocColor (display, screen_colormap, color_def);
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
250 if (status)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
251 return status;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 /* If we got to this point, the colormap is full, so we're
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
255 going to try to get the next closest color.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 The algorithm used is a least-squares matching, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 what X uses for closest color matching with StaticColor visuals. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
259 int nearest, x;
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
260 unsigned long nearest_delta = ULONG_MAX;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
262 int no_cells = XDisplayCells (display, XDefaultScreen (display));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 /* Don't use alloca here because lwlib doesn't have the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 necessary configuration information that src does. */
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
265 XColor *cells = (XColor *) malloc (sizeof (XColor) * no_cells);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 for (x = 0; x < no_cells; x++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 cells[x].pixel = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 XQueryColors (display, screen_colormap, cells, no_cells);
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
271
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
272 for (nearest = 0, x = 0; x < no_cells; x++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
274 long dred = (color_def->red >> 8) - (cells[x].red >> 8);
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
275 long dgreen = (color_def->green >> 8) - (cells[x].green >> 8);
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
276 long dblue = (color_def->blue >> 8) - (cells[x].blue >> 8);
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
277 unsigned long delta = dred * dred + dgreen * dgreen + dblue * dblue;
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
278
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
279 if (delta < nearest_delta)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 nearest = x;
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
282 nearest_delta = delta;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 }
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
285 color_def->red = cells[nearest].red;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 color_def->green = cells[nearest].green;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
287 color_def->blue = cells[nearest].blue;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 free (cells);
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
289 return XAllocColor (display, screen_colormap, color_def);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 push_new_stack (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 if (!mw->menu.new_stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 mw->menu.new_stack_length = 10;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 mw->menu.new_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (widget_value**)XtCalloc (mw->menu.new_stack_length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 else if (mw->menu.new_depth == mw->menu.new_stack_length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 mw->menu.new_stack_length *= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 mw->menu.new_stack =
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
307 (widget_value**)XtRealloc ((char *)mw->menu.new_stack,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 mw->menu.new_stack_length *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 mw->menu.new_stack [mw->menu.new_depth++] = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 pop_new_stack_if_no_contents (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
317 if (mw->menu.new_depth &&
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
318 !mw->menu.new_stack [mw->menu.new_depth - 1]->contents)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
319 mw->menu.new_depth -= 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 make_old_stack_space (XlwMenuWidget mw, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 if (!mw->menu.old_stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 {
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
327 mw->menu.old_stack_length = max (10, n);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 mw->menu.old_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (widget_value**)XtCalloc (mw->menu.old_stack_length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 else if (mw->menu.old_stack_length < n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 {
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
334 while (mw->menu.old_stack_length < n)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 mw->menu.old_stack_length *= 2;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
336
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 mw->menu.old_stack =
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
338 (widget_value**)XtRealloc ((char *)mw->menu.old_stack,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 mw->menu.old_stack_length *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 static Boolean
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
345 close_to_reference_time (Widget w, Time reference_time, XEvent *ev)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
347 return
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
348 reference_time &&
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
349 (ev->xbutton.time - reference_time < XtGetMultiClickTime (XtDisplay (w)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 /* Size code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 string_width (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 XmString s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 char *s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 Dimension width, height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 XmStringExtent (mw->menu.font_list, s, &width, &height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 return width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 #else
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
367 # ifdef USE_XFONTSET
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
368 XRectangle ri, rl;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
369 XmbTextExtents (mw->menu.font_set, s, strlen (s), &ri, &rl);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
370 return rl.width;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
371 # else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 XCharStruct xcs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 int drop;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 return xcs.width;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
376 # endif /* USE_XFONTSET */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
380 static char massaged_resource_char[256];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
381
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
382 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
383 initialize_massaged_resource_char (void)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
384 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
385 int j;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
386 for (j = 0; j < (int) sizeof (massaged_resource_char); j++)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
387 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
388 if ((j >= 'a' && j <= 'z') ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
389 (j >= 'A' && j <= 'Z') ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
390 (j >= '0' && j <= '9') ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
391 (j == '_') ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
392 (j >= 0xa0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
393 massaged_resource_char[j] = (char) j;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
394 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
395 massaged_resource_char ['_'] = '_';
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
396 massaged_resource_char ['+'] = 'P'; /* Convert C++ to cPP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
397 massaged_resource_char ['.'] = '_'; /* Convert Buffers... to buffers___ */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
398 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
399
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
400 static int
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
401 string_width_u (XlwMenuWidget mw,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
402 #ifdef NEED_MOTIF
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
403 XmString string
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
404 #else
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
405 char *string
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
406 #endif
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
407 )
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
408 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
409 #ifdef NEED_MOTIF
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
410 Dimension width, height;
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
411 XmString newstring;
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
412 #else
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 177
diff changeset
413 # ifdef USE_XFONTSET
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 177
diff changeset
414 XRectangle ri, rl;
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 177
diff changeset
415 # else /* ! USE_XFONTSET */
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
416 XCharStruct xcs;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
417 int drop;
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
418 # endif
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
419 #endif
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
420 char* newchars;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
421 int charslength;
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
422 char *chars;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
423 int i, j;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
424
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
425 #ifdef NEED_MOTIF
197
acd284d43ca1 Import from CVS: tag r20-3b25
cvs
parents: 195
diff changeset
426 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
427 {
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
428 chars = "";
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
429 }
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
430 #else
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
431 chars = string;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
432 #endif
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
433 charslength = strlen (chars);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
434 newchars = (char *) alloca (charslength + 1);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
435
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 272
diff changeset
436 for (i = j = 0; chars[i] && (j < charslength); i++)
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
437 if (chars[i]=='%'&&chars[i+1]=='_')
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
438 i++;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
439 else
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
440 newchars[j++] = chars[i];
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
441 newchars[j] = '\0';
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
442
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
443 #ifdef NEED_MOTIF
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
444 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
445 XmStringExtent (mw->menu.font_list, newstring, &width, &height);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
446 XmStringFree (newstring);
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
447 XtFree (chars);
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
448 return width;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
449 #else
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
450 # ifdef USE_XFONTSET
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
451 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
452 return rl.width;
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
453 # else /* ! USE_XFONTSET */
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
454 XTextExtents (mw->menu.font, newchars, j, &drop, &drop, &drop, &xcs);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
455 return xcs.width;
181
bfd6434d15b3 Import from CVS: tag r20-3b17
cvs
parents: 177
diff changeset
456 # endif /* USE_XFONTSET */
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
457 #endif
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
458 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
459
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 massage_resource_name (CONST char *in, char *out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 /* Turn a random string into something suitable for using as a resource.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Kill Buffer" -> "killBuffer"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
467 "Find File..." -> "findFile___"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
468 "Search and Replace..." -> "searchAndReplace___"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
469 "C++ Mode Commands" -> "cppModeCommands"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
470
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
471 Valid characters in a resource NAME component are: a-zA-Z0-9_
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
474 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
475 /* Compile with -DPRINT_XLWMENU_RESOURCE_CONVERSIONS to generate a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
476 translation file for menu localizations. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
477 char *save_in = in, *save_out = out;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
478 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
479
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
480 Boolean firstp = True;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 while (*in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 {
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
483 char ch = massaged_resource_char[(unsigned char) *in++];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
484 if (ch)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
394
7d59cb494b73 Import from CVS: tag r21-2-12
cvs
parents: 380
diff changeset
486 int int_ch = (int) (unsigned char) ch;
7d59cb494b73 Import from CVS: tag r21-2-12
cvs
parents: 380
diff changeset
487 *out++ = firstp ? tolower (int_ch) : toupper (int_ch);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
488 firstp = False;
84
ac0620f6398e Import from CVS: tag r20-0b92
cvs
parents: 80
diff changeset
489 while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0')
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
490 *out++ = ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
491 if (!*(in-1)) /* Overshot the NULL byte? */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
492 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
495 *out = 0;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
496
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
497 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
498 printf ("! Emacs*XlwMenu.%s.labelString:\t%s\n", save_out, save_in);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
499 printf ( "Emacs*XlwMenu.%s.labelString:\n", save_out);
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
500 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 static XtResource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 nameResource[] =
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
505 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
506 { "labelString", "LabelString", XtRString, sizeof(String),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 0, XtRImmediate, 0 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 * This function looks through string searching for parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 * inserts of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 * %[padding]1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 * padding is space (' ') or dash ('-') characters meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 * padding to the left or right of the inserted parameter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 * In essence all %1 strings are replaced by value in the return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 * value (which the caller is expected to free).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 * %% means insert one % (like printf).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 * %1 means insert value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 * %-1 means insert value followed by one space. The latter is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 * not inserted if value is a zero length string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 static char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 parameterize_string (CONST char *string, CONST char *value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 char *percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 char *result;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
528 unsigned int done = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
529 unsigned int ntimes;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 if (!string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 result = XtMalloc(1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 result[0] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 return (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 if (!value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 value = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%'));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ntimes++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 result = &percent[1];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
544
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
545 result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 result[0] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 while ((percent = strchr(string, '%')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
550 unsigned int left_pad;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
551 unsigned int right_pad;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 char *p;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
553
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 if (percent[1] == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 { /* it's a real % */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
556 strncat (result, string, 1 + percent - string); /* incl % */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 string = &percent[2]; /* after the second '%' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 continue; /* with the while() loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
560
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 left_pad = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 right_pad = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 for (p = &percent[1]; /* test *p inside the loop */ ; p++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 if (*p == ' ')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 { /* left pad */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 left_pad++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 else if (*p == '-')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 { /* right pad */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 right_pad++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 else if (*p == '1')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 { /* param and terminator */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
576 strncat (result, string, percent - string);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 if (value[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
579 unsigned int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 for (i = 0; i < left_pad; i++)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
581 strcat (result, " ");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
582 strcat (result, value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 for (i = 0; i < right_pad; i++)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
584 strcat (result, " ");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 string = &p[1]; /* after the '1' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 done++; /* no need to do old way */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 break; /* out of for() loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 { /* bogus, copy the format as is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 /* out of for() loop */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
593 strncat (result, string, 1 + p - string);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
594 string = (*p ? &p[1] : p);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
595 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
600 /* Copy the tail of the string */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
601 strcat (result, string);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
602
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
603 /* If we have not processed a % string, and we have a value, tail it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 if (!done && value[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
606 strcat (result, " ");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
607 strcat (result, value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 static XmString
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 resource_widget_value (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 if (!val->toolkit_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 char *resourced_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 char *converted_name, *str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 XmString complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 char massaged_name [1024];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 if (mw->menu.lookup_labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 /* Convert value style name into resource style name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 eg: "Free Willy" becomes "freeWilly" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 massage_resource_name (val->name, massaged_name);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
630
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 /* If we have a value (parameter) see if we can find a "Named"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 resource. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 char named_name[1024];
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
636 sprintf (named_name, "%sNamed", massaged_name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 named_name, named_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 /* If nothing yet, try to load from the massaged name. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 massaged_name, massaged_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 } /* if (mw->menu.lookup_labels) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 /* Still nothing yet, use the name as the value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 resourced_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 /* Parameterize the string. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
658 converted_name = parameterize_string (resourced_name, val->value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 /* nuke newline characters to prevent menubar screwups */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 for ( str = converted_name ; *str ; str++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 if (str[0] == '\n') str[0] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 /* Improve OSF's bottom line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 complete_name = XmStringCreateLocalized (converted_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 complete_name = XmStringCreateLtoR (converted_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 XtFree (converted_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 val->toolkit_data = complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 val->free_toolkit_data = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 }
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
678 return (XmString) val->toolkit_data;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 /* Unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 #if 0
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
683 /* These two routines should be a seperate file..djw */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 xlw_create_localized_string (Widget w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 char *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 char **args,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
688 unsigned int nargs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 char *string = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 char *arg = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 if (nargs > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 arg = args[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 XtGetSubresources (w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (XtPointer)&string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 nameResource, 1,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
701 NULL, 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 if (!string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 string = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 return parameterize_string (string, arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 static XmString
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 xlw_create_localized_xmstring (Widget w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 char *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 char **args,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
713 unsigned int nargs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 char * string = xlw_create_localized_string (w, name, args, nargs);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 XmString xm_string = XmStringCreateLtoR (string, XmSTRING_DEFAULT_CHARSET);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
717 XtFree (string);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 return xm_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 #else /* !Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 static char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 resource_widget_value (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 if (!val->toolkit_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 char *resourced_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 char *complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 char massaged_name [1024];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 if (mw->menu.lookup_labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 massage_resource_name (val->name, massaged_name);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
736
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 massaged_name, massaged_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 resourced_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
745 complete_name = parameterize_string (resourced_name, val->value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 val->toolkit_data = complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 /* nuke newline characters to prevent menubar screwups */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 for ( ; *complete_name ; complete_name++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 if (complete_name[0] == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 complete_name[0] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 val->free_toolkit_data = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 }
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
756 return (char *) val->toolkit_data;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 #endif /* !Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
761 /* Code for drawing strings. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
763 string_draw (XlwMenuWidget mw,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
764 Window window,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
765 int x, int y,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
766 GC gc,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 #ifdef NEED_MOTIF
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
768 XmString string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 #else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
770 char *string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 #endif
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
772 )
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
773 {
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 XmStringDraw (XtDisplay (mw), window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 mw->menu.font_list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 string, gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 1000, /* ???? width */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 XmALIGNMENT_BEGINNING,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 0, /* ???? layout_direction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 #else
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
784 # ifdef USE_XFONTSET
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
785 XmbDrawString (XtDisplay (mw), window, mw->menu.font_set, gc,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
786 x, y + mw->menu.font_ascent, string, strlen (string));
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
787 # else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 XDrawString (XtDisplay (mw), window, gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 x, y + mw->menu.font_ascent, string, strlen (string));
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
790 # endif /* USE_XFONTSET */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
795 static int
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
796 string_draw_range (
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
797 XlwMenuWidget mw,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
798 Window window,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
799 int x, int y,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
800 GC gc,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
801 char *string,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
802 int start,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
803 int end
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
804 )
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
805 {
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
806 #ifdef NEED_MOTIF
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
807 Dimension width, height;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
808 XmString newstring;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
809 int c;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
810
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
811 if (end <= start)
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
812 return 0;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
813 c = string[end];
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
814 string[end] = '\0';
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
815 newstring = XmStringLtoRCreate (&string[start], XmFONTLIST_DEFAULT_TAG);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
816 XmStringDraw (
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
817 XtDisplay (mw), window,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
818 mw->menu.font_list,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
819 newstring, gc,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
820 x, y,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
821 1000, /* ???? width */
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
822 XmALIGNMENT_BEGINNING,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
823 0, /* ???? layout_direction */
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
824 0
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
825 );
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
826 XmStringExtent (mw->menu.font_list, newstring, &width, &height);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
827 XmStringFree (newstring);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
828 string[end] = c;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
829 return width;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
830 #else
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
831 # ifdef USE_XFONTSET
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
832 XRectangle ri, rl;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
833
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
834 if (end <= start)
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
835 return 0;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
836 XmbDrawString (
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
837 XtDisplay (mw), window, mw->menu.font_set, gc,
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
838 x, y + mw->menu.font_ascent, &string[start], end - start);
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
839 XmbTextExtents (
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
840 mw->menu.font_set, &string[start], end - start, &ri, &rl);
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
841 return rl.width;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
842 # else
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
843 XCharStruct xcs;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
844 int drop;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
845
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
846 if (end <= start)
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
847 return 0;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
848 XDrawString (
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
849 XtDisplay (mw), window, gc,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
850 x, y + mw->menu.font_ascent, &string[start], end - start);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
851 XTextExtents (
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
852 mw->menu.font, &string[start], end - start,
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
853 &drop, &drop, &drop, &xcs);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
854 return xcs.width;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
855 # endif
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
856 #endif
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
857 }
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
858
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
859 static void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
860 string_draw_u (XlwMenuWidget mw,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
861 Window window,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
862 int x, int y,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
863 GC gc,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
864 #ifdef NEED_MOTIF
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
865 XmString string
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
866 #else
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
867 char *string
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
868 #endif
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
869 )
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
870 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
871 int i, s = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
872 char *chars;
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
873
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
874 #ifdef NEED_MOTIF
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
875 XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars);
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
876 #else
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
877 chars = string;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
878 #endif
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
879 for (i=0; chars[i]; ++i) {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
880 if (chars[i] == '%' && chars[i+1] == '_') {
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
881 int w;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
882
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
883 x += string_draw_range (mw, window, x, y, gc, chars, s, i);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
884 w = string_draw_range (mw, window, x, y, gc, chars, i+2, i+3);
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
885
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
886 /* underline next character */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
887 XDrawLine (XtDisplay (mw), window, gc, x - 1,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
888 y + mw->menu.font_ascent + 1,
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
889 x + w - 1, y + mw->menu.font_ascent + 1 );
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
890 x += w;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
891 s = i + 3;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
892 i += 2;
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
893 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
894 }
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 185
diff changeset
895 x += string_draw_range (mw, window, x, y, gc, chars, s, i);
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
896 #ifdef NEED_MOTIF
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
897 XtFree (chars);
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
898 #endif
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
899 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
900
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
901 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 binding_draw (XlwMenuWidget mw, Window w, int x, int y, GC gc, char *value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 XmString xm_value = XmStringCreateLtoR(value, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 string_draw (mw, w, x, y, gc, xm_value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 XmStringFree (xm_value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 string_draw (mw, w, x, y, gc, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
913 /* Low level code for drawing 3-D edges. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
915 shadow_rectangle_draw (Display *dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 GC top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 GC bottom_gc,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
919 int x, int y,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
920 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
921 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
922 unsigned int thickness)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 if (!thickness)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 points [1].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 points [1].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 points [2].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 points [3].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 points [0].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 points [1].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 points [1].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 points [2].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 points [0].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 points [1].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 points [1].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 points [3].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 points [3].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 points [0].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 points [1].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 points [1].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 points [2].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 points [3].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 typedef enum e_shadow_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 /* these are Motif compliant */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 SHADOW_BACKGROUND,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 SHADOW_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 SHADOW_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 SHADOW_ETCHED_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 SHADOW_ETCHED_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 SHADOW_ETCHED_OUT_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 SHADOW_ETCHED_IN_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 SHADOW_SINGLE_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 SHADOW_DOUBLE_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 SHADOW_SINGLE_DASHED_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 SHADOW_DOUBLE_DASHED_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 SHADOW_NO_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 /* these are all non-Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 SHADOW_DOUBLE_ETCHED_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 SHADOW_DOUBLE_ETCHED_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 SHADOW_DOUBLE_ETCHED_OUT_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 SHADOW_DOUBLE_ETCHED_IN_DASH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 } shadow_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 shadow_draw (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 Window window,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
992 int x, int y,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
993 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
994 unsigned int height,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
995 shadow_type type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 Boolean etched = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 switch (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 case SHADOW_BACKGROUND:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 top_gc = bottom_gc = mw->menu.background_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 etched = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 etched = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 case SHADOW_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 case SHADOW_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 if (etched)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1034 unsigned int half = thickness/2;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1035 shadow_rectangle_draw (dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 width - half, height - half,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1041 thickness - half);
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1042 shadow_rectangle_draw (dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 x + half, y + half,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 width - half , height - half,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1048 half);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1052 shadow_rectangle_draw (dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 width, height,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1058 thickness);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1062 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1063 arrow_decoration_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1066 unsigned int width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1067 Boolean raised)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 GC select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 int half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 int length = (int)((double)width * 0.87);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 int thick_med = (int)((double)thickness * 1.73);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 if (width & 0x1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 half_width = width/2 + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 half_width = width/2;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1083
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 select_gc = mw->menu.background_gc;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1085
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 if (raised)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1088 top_gc = mw->menu.shadow_bottom_gc;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1093 top_gc = mw->menu.shadow_top_gc;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1097 /* Fill internal area. We do this first so that the borders have a
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1098 nice sharp edge. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 points [0].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 points [0].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 points [1].x = x + length - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 points [2].x = x + length - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 points [2].y = y + half_width + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 points [3].y = y + width - thickness;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1107
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1108 XFillPolygon (dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 points,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1112 4,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 Convex,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1114 CoordModeOrigin);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 /* left border */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 points [1].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 points [1].y = y + thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 points [2].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 points [2].y = y + width - thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 points [3].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 points [3].y = y + width;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1125
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 /* top border */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 points [0].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 points [1].x = x + length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 points [2].x = x + length - (thickness + thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 points [3].y = y + width - thick_med;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1137
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 /* bottom shadow */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 points [1].x = x + length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 points [2].x = x + length - (thickness + thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 points [3].y = y + thick_med;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1149
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1154 toggle_decoration_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1157 unsigned int width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1158 Boolean set)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 GC select_gc = mw->menu.select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 if (set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 type = SHADOW_IN;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1170 /* Fill internal area. */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1171 if (set)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1172 XFillRectangle (dpy,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 x + thickness,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 y + thickness,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 width - (2*thickness),
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1178 width - (2*thickness));
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1179
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1180 shadow_draw (mw, window, x, y, width, width, type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1184 radio_decoration_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1187 unsigned int width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1188 Boolean enabled)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 GC select_gc = mw->menu.select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 XPoint points[6];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 int half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 int npoints;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 if (width & 0x1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 width++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 half_width = width/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 if (enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1208 top_gc = mw->menu.shadow_bottom_gc;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1213 top_gc = mw->menu.shadow_top_gc;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 #if 1
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1218 /* Draw the bottom first, just in case the regions overlap.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1219 The top should cast the longer shadow. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 points [0].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 points [1].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 points [1].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 points [2].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 points [2].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 points [3].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 points [3].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 points [0].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 points [0].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 points [1].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 points [2].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 points [3].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 points [3].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 points [0].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 points [1].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 points [1].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 points [2].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 points [2].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 points [3].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 points [3].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 points [0].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 points [1].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 points [2].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 points [3].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 #else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1264 /* Draw the bottom first, just in case the regions overlap.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1265 The top should cast the longer shadow. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 npoints = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 points [npoints].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 points [npoints].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 points [npoints++].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 points [npoints].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 points [npoints].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 points [npoints].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 points [npoints++].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 points [npoints].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1280 XFillPolygon (dpy, window, bottom_gc,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 points, npoints, Nonconvex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 npoints = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 points [npoints].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 points [npoints].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 points [npoints++].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 points [npoints].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 points [npoints].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 points [npoints].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 points [npoints++].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 points [npoints].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 XFillPolygon (dpy, window, top_gc, points, npoints, Nonconvex,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1303 /* Fill internal area. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 if (enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 points [0].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 points [1].x = x + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 points [1].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 points [3].x = x + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 points [3].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 XFillPolygon (dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 points,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1318 4,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 Convex,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1320 CoordModeOrigin);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1325 separator_decoration_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1328 unsigned int width,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 Boolean vertical,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1330 shadow_type type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 GC bottom_gc;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1335 unsigned int offset = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1336 unsigned int num_separators = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1337 unsigned int top_line_thickness = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1338 unsigned int bottom_line_thickness = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 Boolean dashed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 switch (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 case SHADOW_NO_LINE: /* nothing to do */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1344 return;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 case SHADOW_DOUBLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 case SHADOW_SINGLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 top_gc = bottom_gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 top_line_thickness = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 case SHADOW_DOUBLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 case SHADOW_SINGLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 top_gc = bottom_gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 top_line_thickness = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 case SHADOW_DOUBLE_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 case SHADOW_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 case SHADOW_DOUBLE_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 case SHADOW_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 case SHADOW_DOUBLE_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 case SHADOW_DOUBLE_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1394
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 if (dashed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 XGCValues values;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 values.line_style = LineOnOffDash;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 if (top_line_thickness > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 XChangeGC (dpy, top_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 if (bottom_line_thickness > 0 && bottom_gc != top_gc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 XChangeGC (dpy, bottom_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1404
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 while (num_separators--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1407 unsigned int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 for (i = 0; i < top_line_thickness; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1410
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 for (i = 0; i < bottom_line_thickness; i++)
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1412 XDrawLine (dpy, window, bottom_gc,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 x, y + top_line_thickness + offset + i,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1414 x + width, y + top_line_thickness + offset + i);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 y += (top_line_thickness + offset + bottom_line_thickness + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 if (dashed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 XGCValues values;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 values.line_style = LineSolid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 if (top_line_thickness > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 XChangeGC (dpy, top_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 if (bottom_line_thickness > 0 && bottom_gc != top_gc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 XChangeGC (dpy, bottom_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 #define SLOPPY_TYPES 0 /* 0=off, 1=error check, 2=easy to please */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 #if SLOPPY_TYPES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 #if SLOPPY_TYPES < 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 static char *wv_types[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 "UNSPECIFIED",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 "BUTTON",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 "TOGGLE",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 "RADIO",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 "TEXT",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 "SEPARATOR",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 "CASCADE",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 "PUSHRIGHT",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 "INCREMENTAL"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 print_widget_value (widget_value *wv, int just_one, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 char d [200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 int i;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1451 for (i = 0; i < depth; i++)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1452 d[i] = ' ';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 d[depth]=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 if (!wv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 printf ("%s(null widget value pointer)\n", d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 printf ("%stype: %s\n", d, wv_types [wv->type]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 printf ("%sname: %s\n", d, (wv->name ? wv->name : "(null)"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 if (wv->name) printf ("%sname: %s\n", d, wv->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 if (wv->value) printf ("%svalue: %s\n", d, wv->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 if (wv->key) printf ("%skey: %s\n", d, wv->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 printf ("%senabled: %d\n", d, wv->enabled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 if (wv->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 printf ("\n%scontents: \n", d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 print_widget_value (wv->contents, 0, depth + 5);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 if (!just_one && wv->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 print_widget_value (wv->next, 0, depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 }
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1479 #endif /* SLOPPY_TYPES < 2 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 all_dashes_p (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 char *p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 if (!s || s[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 for (p = s; *p == '-'; p++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 if (*p == '!' || *p == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 }
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1493 #endif /* SLOPPY_TYPES */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 static widget_value_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 menu_item_type (widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 if (val->type != UNSPECIFIED_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 return val->type;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1500 #if SLOPPY_TYPES
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1501 else if (all_dashes_p (val->name))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1502 return SEPARATOR_TYPE;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1503 else if (val->name && val->name[0] == '\0') /* push right */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1504 return PUSHRIGHT_TYPE;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1505 else if (val->contents) /* cascade */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1506 return CASCADE_TYPE;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1507 else if (val->call_data) /* push button */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1508 return BUTTON_TYPE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 else
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1510 return TEXT_TYPE;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1511 #else
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1512 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 abort();
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
1514 return UNSPECIFIED_TYPE; /* Not reached */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1515 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1519 label_button_size (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1522 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1523 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1524 unsigned int *bindings_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1525 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 *height = (mw->menu.font_ascent + mw->menu.font_descent +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 2 * mw->menu.vertical_margin +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 2 * mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 /* no left column decoration */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 *toggle_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness;;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1532
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
1533 *label_width = string_width_u (mw, resource_widget_value (mw, val));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 *bindings_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1538 label_button_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1544 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1545 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1546 unsigned int label_offset,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1547 unsigned int binding_tab)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1550 GC gc;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1551
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1555 if (highlighted && (in_menubar || val->contents))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1556 gc = mw->menu.highlight_gc;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1557 else if (in_menubar || val->contents)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1558 gc = mw->menu.foreground_gc;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1559 else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1560 gc = mw->menu.title_gc;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1561
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1562 /* Draw the label string. */
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
1563 string_draw_u (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 window,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1565 x + label_offset, y + y_offset,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1566 gc,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1567 resource_widget_value (mw, val));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1571 push_button_size (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1574 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1575 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1576 unsigned int *bindings_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1577 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 /* inherit */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1580 label_button_size (mw, val, in_menubar,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 toggle_width, label_width, bindings_width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1582 height);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1583
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 /* key bindings to display? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 if (!in_menubar && val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 int w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1590 w = string_width (mw, key);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 XmStringFree (key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 char *key = val->key;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 w = string_width (mw, key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 *bindings_width += w + mw->menu.column_spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1601 push_button_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 Boolean highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1605 Window window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1606 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1607 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1608 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1609 unsigned int label_offset,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1610 unsigned int binding_offset)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 GC gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1616
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1617 /* Draw the label string. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1620
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1621 if (highlighted)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1622 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1623 if (val->enabled)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1624 gc = mw->menu.highlight_gc;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1625 else
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 219
diff changeset
1626 gc = mw->menu.inactive_gc;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1627 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1628 else if (menu_pb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 if (val->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 gc = mw->menu.button_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 gc = mw->menu.inactive_button_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 if (val->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 gc = mw->menu.inactive_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
1643 string_draw_u (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 window,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1645 x + label_offset, y + y_offset,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 gc,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1647 resource_widget_value (mw, val));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1648
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1649 /* Draw the keybindings */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 if (val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 if (!binding_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1654 unsigned int s_width =
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1655 string_width (mw, resource_widget_value (mw, val));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 binding_draw (mw, window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 x + binding_offset + mw->menu.column_spacing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 y + y_offset, gc, val->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1662
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1663 /* Draw the shadow */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 if (menu_pb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 type = SHADOW_OUT;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1668 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 type = (val->selected ? SHADOW_ETCHED_OUT : SHADOW_ETCHED_IN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 type = SHADOW_OUT;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1675 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 type = SHADOW_BACKGROUND;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 shadow_draw (mw, window, x, y, width, height, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 static unsigned int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 arrow_decoration_height (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1685 int result = (mw->menu.font_ascent + mw->menu.font_descent) / 2;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1686
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 result += 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 if (result > (mw->menu.font_ascent + mw->menu.font_descent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 result = mw->menu.font_ascent + mw->menu.font_descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1696 cascade_button_size (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1699 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1700 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1701 unsigned int *arrow_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1702 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 /* inherit */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1705 label_button_size (mw, val, in_menubar,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 toggle_width, label_width, arrow_width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1707 height);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 /* we have a pull aside arrow */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 if (!in_menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1711 *arrow_width += arrow_decoration_height (mw) + mw->menu.column_spacing;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 static void
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1716 cascade_button_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 Boolean highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1720 Window window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1721 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1722 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1723 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1724 unsigned int label_offset,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1725 unsigned int binding_offset)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1729 /* Draw the label string. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 label_button_draw (mw, val, in_menubar, highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 window, x, y, width, height, label_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 binding_offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1734 /* Draw the pull aside arrow */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 if (!in_menubar && val->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 int y_offset;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1738 unsigned int arrow_height = arrow_decoration_height (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1739
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (mw->menu.font_ascent+mw->menu.font_descent - arrow_height)/2;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1742
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 if (!binding_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1745 unsigned int s_width =
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1746 string_width (mw, resource_widget_value (mw, val));
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1747
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 label_offset = mw->menu.shadow_thickness +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 mw->menu.horizontal_margin;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1751
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1754
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1755 arrow_decoration_draw (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 x + binding_offset + mw->menu.column_spacing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 arrow_height,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1760 highlighted);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1762
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1763 /* Draw the shadow */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 type = SHADOW_BACKGROUND;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1768
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1769 shadow_draw (mw, window, x, y, width, height, type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1772 static unsigned int
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1773 toggle_decoration_height (XlwMenuWidget mw)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1775 int rv;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 if (mw->menu.indicator_size > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 rv = mw->menu.indicator_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 rv = mw->menu.font_ascent;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1780
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1781 if (rv > (mw->menu.font_ascent + mw->menu.font_descent))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1782 rv = mw->menu.font_ascent + mw->menu.font_descent;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1783
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1784 /* radio button can't be smaller than its border or a filling
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1785 error will occur. */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1786 if (rv < 2 * mw->menu.shadow_thickness)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1787 rv = 2 * mw->menu.shadow_thickness;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1788
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 return rv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1793 toggle_button_size (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1796 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1797 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1798 unsigned int *bindings_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1799 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 /* inherit */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1802 push_button_size (mw, val, in_menubar,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 toggle_width, label_width, bindings_width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1804 height);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 /* we have a toggle */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1806 *toggle_width += toggle_decoration_height (mw) + mw->menu.column_spacing;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1810 toggle_button_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 Boolean highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1814 Window window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1815 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1816 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1817 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1818 unsigned int label_tab,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1819 unsigned int binding_tab)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 int x_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 int y_offset;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1823 unsigned int t_height = toggle_decoration_height (mw);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1824
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1825 /* Draw a toggle. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - t_height)/2;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1829
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 toggle_decoration_draw (mw, window, x + x_offset, y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 t_height, val->selected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1833 /* Draw the pushbutton parts. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 height, label_tab, binding_tab);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1838 static unsigned int
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1839 radio_decoration_height (XlwMenuWidget mw)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1841 return toggle_decoration_height (mw);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 static void
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1845 radio_button_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 Boolean highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1849 Window window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1850 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1851 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1852 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1853 unsigned int label_tab,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1854 unsigned int binding_tab)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 int x_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 int y_offset;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1858 unsigned int r_height = radio_decoration_height (mw);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1859
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1860 /* Draw a toggle. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - r_height)/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 radio_decoration_draw (mw, window, x + x_offset, y + y_offset, r_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 val->selected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1868 /* Draw the pushbutton parts. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 height, label_tab, binding_tab);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 static struct _shadow_names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 CONST char * name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 } shadow_names[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 /* Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 { "singleLine", SHADOW_SINGLE_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 { "doubleLine", SHADOW_DOUBLE_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 { "singleDashedLine", SHADOW_SINGLE_DASHED_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 { "doubleDashedLine", SHADOW_DOUBLE_DASHED_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 { "noLine", SHADOW_NO_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 { "shadowEtchedIn", SHADOW_ETCHED_IN },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 { "shadowEtchedOut", SHADOW_ETCHED_OUT },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 { "shadowEtchedInDash", SHADOW_ETCHED_IN_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 { "shadowEtchedOutDash", SHADOW_ETCHED_OUT_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 /* non-Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 { "shadowDoubleEtchedIn", SHADOW_DOUBLE_ETCHED_IN },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 { "shadowDoubleEtchedOut", SHADOW_DOUBLE_ETCHED_OUT },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 { "shadowDoubleEtchedInDash", SHADOW_DOUBLE_ETCHED_IN_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 { "shadowDoubleEtchedOutDash", SHADOW_DOUBLE_ETCHED_OUT_DASH }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 static shadow_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 separator_type (char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 if (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1901 int i;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1902 for (i = 0; i < (int) (XtNumber (shadow_names)); i++ )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 if (strcmp (name, shadow_names[i].name) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 return shadow_names[i].type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 return SHADOW_BACKGROUND;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1911 static unsigned int
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 separator_decoration_height (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1915 switch (separator_type (val->value))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 case SHADOW_NO_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 case SHADOW_SINGLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 case SHADOW_SINGLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 case SHADOW_DOUBLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 case SHADOW_DOUBLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 return 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 case SHADOW_DOUBLE_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 case SHADOW_DOUBLE_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 case SHADOW_DOUBLE_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 case SHADOW_DOUBLE_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 return (1 + 2 * mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 return mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 separator_size (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1940 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1941 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1942 unsigned int *rest_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1943 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 *height = separator_decoration_height (mw, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 *label_width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 *toggle_width = *rest_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 static void
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1951 separator_draw (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 Boolean highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1955 Window window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
1956 int x, int y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1957 unsigned int width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1958 unsigned int height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1959 unsigned int label_tab,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1960 unsigned int binding_tab)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1962 unsigned int sep_width;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 if (in_menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 sep_width = height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 sep_width = width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 separator_decoration_draw (mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 x,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 sep_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 in_menubar,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1975 separator_type(val->value));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 pushright_size (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 Boolean in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1982 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1983 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1984 unsigned int *rest_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1985 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 *height = *label_width = *toggle_width = *rest_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 size_menu_item (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 int horizontal,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1994 unsigned int *toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1995 unsigned int *label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1996 unsigned int *rest_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
1997 unsigned int *height)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1999 void (*function_ptr) (XlwMenuWidget _mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 widget_value *_val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 Boolean _in_menubar,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2002 unsigned int *_toggle_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2003 unsigned int *_label_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2004 unsigned int *_rest_width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2005 unsigned int *_height);
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2006
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 switch (menu_item_type (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 case TOGGLE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 case RADIO_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 function_ptr = toggle_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 function_ptr = separator_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 case INCREMENTAL_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 function_ptr = cascade_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 case BUTTON_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 function_ptr = push_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 case PUSHRIGHT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 function_ptr = pushright_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 case TEXT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 function_ptr = label_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2032 (*function_ptr) (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 rest_width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2038 height);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 static void
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2042 display_menu_item (XlwMenuWidget mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 window_state *ws,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 XPoint *where,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 Boolean horizontal,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2048 Boolean just_compute)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2050
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 int x = where->x /* + mw->menu.shadow_thickness */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 int y = where->y /* + mw->menu.shadow_thickness */ ;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2053 unsigned int toggle_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2054 unsigned int label_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2055 unsigned int binding_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2056 unsigned int width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2057 unsigned int height;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2058 unsigned int label_tab;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2059 unsigned int binding_tab;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2060 void (*function_ptr) (XlwMenuWidget _mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 widget_value *_val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 Boolean _in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 Boolean _highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2064 Window _window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2065 int _x, int _y,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2066 unsigned int _width,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2067 unsigned int _height,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2068 unsigned int _label_tab,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2069 unsigned int _binding_tab);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2071 size_menu_item (mw, val, horizontal,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2072 &toggle_width, &label_width, &binding_width, &height);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 if (horizontal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 width = toggle_width + label_width + binding_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 height = ws->height - 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 width = ws->width - 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 toggle_width = ws->toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 label_width = ws->label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2085
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 where->x += width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 where->y += height;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2088
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 if (just_compute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 return;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2091
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 label_tab = toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 binding_tab = toggle_width + label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 switch (menu_item_type (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 case TOGGLE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 function_ptr = toggle_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 case RADIO_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 function_ptr = radio_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 function_ptr = separator_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 case INCREMENTAL_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 function_ptr = cascade_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 case BUTTON_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 function_ptr = push_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 case TEXT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 function_ptr = label_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 default: /* do no drawing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2120 (*function_ptr) (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 highlighted,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2124 ws->window,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2125 x, y,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 width, height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 label_tab,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2128 binding_tab);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 size_menu (XlwMenuWidget mw, int level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2134 unsigned int toggle_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2135 unsigned int label_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2136 unsigned int rest_width;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2137 unsigned int height;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2138 unsigned int max_toggle_width = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2139 unsigned int max_label_width = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2140 unsigned int max_rest_width = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2141 unsigned int max_height = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 int horizontal_p = mw->menu.horizontal && (level == 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 widget_value* val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 window_state* ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 if (level >= mw->menu.old_depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2149 ws = &mw->menu.windows [level];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2153 size_menu_item (mw,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 horizontal_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 &toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 &label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 &rest_width,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2159 &height);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 max_label_width += toggle_width + label_width + rest_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 if (height > max_height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 max_height = height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2168 if (max_toggle_width < toggle_width)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2169 max_toggle_width = toggle_width;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2170 if (max_label_width < label_width)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2171 max_label_width = label_width;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2172 if (max_rest_width < rest_width)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2173 max_rest_width = rest_width;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 max_height += height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2177
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 ws->height = max_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ws->width = max_label_width + max_rest_width + max_toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ws->toggle_width = max_toggle_width;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2181 ws->label_width = max_label_width;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2183 ws->width += 2 * mw->menu.shadow_thickness;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 ws->height += 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 display_menu (XlwMenuWidget mw, int level, Boolean just_compute_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 XPoint *highlighted_pos, XPoint *hit, widget_value **hit_return,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 widget_value *this, widget_value *that)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 widget_value *val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 widget_value *following_item;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 window_state *ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 XPoint where;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 int horizontal_p = mw->menu.horizontal && (level == 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 int highlighted_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 int just_compute_this_one_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 if (level >= mw->menu.old_depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 if (level < mw->menu.old_depth - 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 following_item = mw->menu.old_stack [level + 1];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2205 else
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2206 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2207 if (lw_menu_accelerate
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2208 && level == mw->menu.old_depth - 1
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2209 && mw->menu.old_stack [level]->type == CASCADE_TYPE)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2210 just_compute_p = True;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2211 following_item = NULL;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2212 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 #if SLOPPY_TYPES == 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 puts("===================================================================");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 print_widget_value (following_item, 1, 0);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2217 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 if (hit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 *hit_return = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 where.x = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 where.y = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 ws = &mw->menu.windows [level];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 XPoint start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 highlighted_p = (val == following_item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 /* If this is the partition (the dummy item which says that menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 after this should be flushright) then figure out how big the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 following items are. This means we walk down the tail of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 list twice, but that's no big deal - it's short.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 if (horizontal_p && (menu_item_type (val) == PUSHRIGHT_TYPE))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 widget_value *rest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 XPoint flushright_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 int new_x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 flushright_size.x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 flushright_size.y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 for (rest = val; rest; rest = rest->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 display_menu_item (mw, rest, ws, &flushright_size,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 highlighted_p, horizontal_p, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 new_x = ws->width - (flushright_size.x + mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 if (new_x > where.x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 where.x = new_x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 /* We know what we need; don't draw this item. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 if (highlighted_p && highlighted_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 highlighted_pos->x = where.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 highlighted_pos->y = where.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2260
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 just_compute_this_one_p =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 just_compute_p || ((this || that) && val != this && val != that);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 start.x = where.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 start.y = where.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 display_menu_item (mw, val, ws, &where, highlighted_p, horizontal_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 just_compute_this_one_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 if (highlighted_p && highlighted_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 highlighted_pos->y = ws->height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 highlighted_pos->x = ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
2277 if (hit && !*hit_return)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 {
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
2279 if (horizontal_p && hit->x > start.x && hit->x <= where.x)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 *hit_return = val;
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 197
diff changeset
2281 else if (!horizontal_p && hit->y > start.y && hit->y <= where.y)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 *hit_return = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 where.y = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 where.x = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 /* Draw slab edges around menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 if (!just_compute_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 shadow_draw(mw, ws->window, 0, 0, ws->width, ws->height, SHADOW_OUT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 /* Motion code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 set_new_state (XlwMenuWidget mw, widget_value *val, int level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 int i;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2301
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 mw->menu.new_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 for (i = 0; i < level; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 push_new_stack (mw, mw->menu.old_stack [i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 if (val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 push_new_stack (mw, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 make_windows_if_needed (XlwMenuWidget mw, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 int start_at;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 XSetWindowAttributes xswa;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2315 Widget p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 int mask;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2317 int depth;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2318 Visual *visual;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 window_state *windows;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2320 Window root;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2321
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 if (mw->menu.windows_length >= n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2325 root = RootWindowOfScreen (XtScreen(mw));
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2326 /* grab the visual and depth from the nearest shell ancestor */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2327 visual = CopyFromParent;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2328 depth = CopyFromParent;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2329 p = XtParent(mw);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2330 while (visual == CopyFromParent && p)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2331 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2332 if (XtIsShell(p))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2333 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2334 visual = ((ShellWidget)p)->shell.visual;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2335 depth = p->core.depth;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2336 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2337 p = XtParent(p);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2338 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2339
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 xswa.save_under = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 xswa.override_redirect = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 xswa.background_pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 xswa.border_pixel = mw->core.border_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 xswa.event_mask = (ExposureMask | ButtonMotionMask
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 | ButtonReleaseMask | ButtonPressMask);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 xswa.cursor = mw->menu.cursor_shape;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2347 xswa.colormap = mw->core.colormap;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 mask = CWSaveUnder | CWOverrideRedirect | CWBackPixel | CWBorderPixel
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2349 | CWEventMask | CWCursor | CWColormap;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 if (mw->menu.use_backing_store)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 xswa.backing_store = Always;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 mask |= CWBackingStore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2356
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 if (!mw->menu.windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 mw->menu.windows =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (window_state *) XtMalloc (n * sizeof (window_state));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 start_at = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 mw->menu.windows =
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2366 (window_state *) XtRealloc ((char *) mw->menu.windows,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 n * sizeof (window_state));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 start_at = mw->menu.windows_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 mw->menu.windows_length = n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 windows = mw->menu.windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 for (i = start_at; i < n; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 windows [i].x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 windows [i].y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 windows [i].width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 windows [i].height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 windows [i].window =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 XCreateWindow (XtDisplay (mw),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 root,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 0, 0, 1, 1,
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2384 0, depth, CopyFromParent, visual, mask, &xswa);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 /* Make the window fit in the screen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 fit_to_screen (XlwMenuWidget mw, window_state *ws, window_state *previous_ws,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 Boolean horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 int screen_width = WidthOfScreen (XtScreen (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 int screen_height = HeightOfScreen (XtScreen (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 if (ws->x < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ws->x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 else if ((int) (ws->x + ws->width) > screen_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 if (!horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ws->x = previous_ws->x - ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 ws->x = screen_width - ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 /* This check is to make sure we cut off the right side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 instead of the left side if the menu is wider than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 screen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 if (ws->x < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ws->x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 if (ws->y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ws->y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 else if ((int) (ws->y + ws->height) > screen_height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 /* A pulldown must either be entirely above or below the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 If we're here, the pulldown doesn't fit below the menubar, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 let's determine if it will fit above the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 Only put it above if there is more room above than below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 Note shadow_thickness offset to allow for slab surround.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 if (ws->y > (screen_height / 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 ws->y = previous_ws->y - ws->height + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 ws->y = screen_height - ws->height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 /* if it's taller than the screen, display the topmost part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 that will fit, beginning at the top of the screen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 if (ws->y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 ws->y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 /* Updates old_stack from new_stack and redisplays. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 remap_menubar (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 int last_same;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 XPoint selection_position;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 int old_depth = mw->menu.old_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 int new_depth = mw->menu.new_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 widget_value **old_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 widget_value **new_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 window_state *windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 widget_value *old_selection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 widget_value *new_selection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 /* Check that enough windows and old_stack are ready. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 make_windows_if_needed (mw, new_depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 make_old_stack_space (mw, new_depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 windows = mw->menu.windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 old_stack = mw->menu.old_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 new_stack = mw->menu.new_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 /* compute the last identical different entry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 for (i = 1; i < old_depth && i < new_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 if (old_stack [i] != new_stack [i])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 last_same = i - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2467 if (lw_menu_accelerate
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2468 && last_same
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2469 && last_same == old_depth - 1
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2470 && old_stack [last_same]->contents)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2471 last_same--;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2472
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 /* Memorize the previously selected item to be able to refresh it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 old_selection = last_same + 1 < old_depth ? old_stack [last_same + 1] : NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 new_selection = last_same + 1 < new_depth ? new_stack [last_same + 1] : NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 /* updates old_state from new_state. It has to be done now because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 display_menu (called below) uses the old_stack to know what to display. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 for (i = last_same + 1; i < new_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 old_stack [i] = new_stack [i];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2481
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 mw->menu.old_depth = new_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 /* refresh the last seletion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 selection_position.x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 selection_position.y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 display_menu (mw, last_same, new_selection == old_selection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 &selection_position, NULL, NULL, old_selection, new_selection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 /* Now popup the new menus */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 for (i = last_same + 1; i < new_depth && new_stack [i]->contents; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 window_state *previous_ws = &windows [i - 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 window_state *ws = &windows [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2496 if (lw_menu_accelerate && i == new_depth - 1)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2497 break;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2498
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ws->x = previous_ws->x + selection_position.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ws->y = previous_ws->y + selection_position.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 /* take into account the slab around the new menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 ws->y -= mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2505 {
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2506 widget_value *val = mw->menu.old_stack [i];
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2507 if (val->contents->type == INCREMENTAL_TYPE)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2508 {
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2509 /* okay, we're now doing a lisp callback to incrementally generate
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2510 more of the menu. */
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2511 XtCallCallbackList ((Widget)mw,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2512 mw->menu.open,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2513 (XtPointer)val->contents);
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2514 }
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2515 }
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 207
diff changeset
2516
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 size_menu (mw, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 XClearWindow (XtDisplay (mw), ws->window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 XMoveResizeWindow (XtDisplay (mw), ws->window, ws->x, ws->y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ws->width, ws->height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 XMapRaised (XtDisplay (mw), ws->window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 display_menu (mw, i, False, &selection_position, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 /* unmap the menus that popped down */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2529
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2530 last_same = new_depth;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2531 if (lw_menu_accelerate
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2532 && last_same > 1
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2533 && new_stack [last_same - 1]->contents)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2534 last_same--;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2535
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2536 for (i = last_same - 1; i < old_depth; i++)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
2537 if (i >= last_same || !new_stack [i]->contents)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 XUnmapWindow (XtDisplay (mw), windows [i].window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 motion_event_is_in_menu (XlwMenuWidget mw, XMotionEvent *ev, int level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 XPoint *relative_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 window_state *ws = &mw->menu.windows [level];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 int x = level == 0 ? ws->x : ws->x + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 int y = level == 0 ? ws->y : ws->y + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 relative_pos->x = ev->x_root - x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 relative_pos->y = ev->y_root - y;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2550 return (x < ev->x_root && ev->x_root < (int) (x + ws->width) &&
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2551 y < ev->y_root && ev->y_root < (int) (y + ws->height));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 map_event_to_widget_value (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 widget_value **val_ptr, int *level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 Boolean *inside_menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 XPoint relative_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 window_state* ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 *val_ptr = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 *inside_menu = False;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2565
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 /* Find the window */
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 84
diff changeset
2567 #if 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 for (i = mw->menu.old_depth - 1; i >= 0; i--)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 84
diff changeset
2569 #else
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 84
diff changeset
2570 for (i = 0; i <= mw->menu.old_depth - 1; i++)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 84
diff changeset
2571 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 ws = &mw->menu.windows [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 if (ws && motion_event_is_in_menu (mw, ev, i, &relative_pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 *inside_menu = True; /* special logic for menubar below... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 if ((ev->type == ButtonPress) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (ev->state != 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 display_menu (mw, i, True, NULL, &relative_pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 val_ptr, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 if (*val_ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 *level = i + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 *inside_menu = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 else if (mw->menu.horizontal || i == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 /* if we're clicking on empty part of the menubar, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 unpost the stay-up menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 *inside_menu = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 /* Procedures */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 make_drawing_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 XGCValues xgcv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 unsigned long flags = (GCFont | GCForeground | GCBackground);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 xgcv.font = default_font_of_font_list (mw->menu.font_list)->fid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 xgcv.font = mw->menu.font->fid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 xgcv.foreground = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 xgcv.background = mw->menu.foreground;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2615 mw->menu.background_gc = XtGetGC ((Widget) mw, flags, &xgcv);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 xgcv.background = mw->core.background_pixel;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2619 mw->menu.foreground_gc = XtGetGC ((Widget) mw, flags, &xgcv);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 if (mw->menu.select_color != (Pixel)-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 xgcv.foreground = mw->menu.select_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 Display *dpy = XtDisplay(mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 if (CellsOfScreen(DefaultScreenOfDisplay(dpy)) <= 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 { /* mono */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 { /* color */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 XColor xcolor;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2635 Colormap cmap = mw->core.colormap;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 xcolor.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 XQueryColor (dpy, cmap, &xcolor);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2638 xcolor.red = (xcolor.red * 17) / 20;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2639 xcolor.green = (xcolor.green * 17) / 20;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2640 xcolor.blue = (xcolor.blue * 17) / 20;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 if (allocate_nearest_color (dpy, cmap, &xcolor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 xgcv.foreground = xcolor.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 mw->menu.select_gc = XtGetGC ((Widget)mw, flags, &xgcv);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2647
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 xgcv.fill_style = FillStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 xgcv.stipple = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 mw->menu.inactive_gc = XtGetGC ((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 (flags | GCFillStyle | GCStipple),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2656 xgcv.foreground = mw->menu.highlight_foreground;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2657 xgcv.background = mw->core.background_pixel;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2658 mw->menu.highlight_gc = XtGetGC ((Widget)mw, flags, &xgcv);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2659
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2660 xgcv.foreground = mw->menu.title_foreground;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2661 xgcv.background = mw->core.background_pixel;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2662 mw->menu.title_gc = XtGetGC ((Widget)mw, flags, &xgcv);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2663
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 xgcv.foreground = mw->menu.button_foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2667
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 xgcv.fill_style = FillStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 xgcv.stipple = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 mw->menu.inactive_button_gc = XtGetGC ((Widget)mw,
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2671 (flags | GCFillStyle | GCStipple),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 release_drawing_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 XtReleaseGC ((Widget) mw, mw->menu.foreground_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 XtReleaseGC ((Widget) mw, mw->menu.button_gc);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2680 XtReleaseGC ((Widget) mw, mw->menu.highlight_gc);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2681 XtReleaseGC ((Widget) mw, mw->menu.title_gc);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 XtReleaseGC ((Widget) mw, mw->menu.background_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 XtReleaseGC ((Widget) mw, mw->menu.select_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 /* let's get some segvs if we try to use these... */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2687 mw->menu.foreground_gc = (GC) -1;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2688 mw->menu.button_gc = (GC) -1;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2689 mw->menu.highlight_gc = (GC) -1;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
2690 mw->menu.title_gc = (GC) -1;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2691 mw->menu.inactive_gc = (GC) -1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 mw->menu.inactive_button_gc = (GC) -1;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2693 mw->menu.background_gc = (GC) -1;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2694 mw->menu.select_gc = (GC) -1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 ? ((unsigned long) (x)) : ((unsigned long) (y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 make_shadow_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 XGCValues xgcv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 unsigned long pm = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 Display *dpy = XtDisplay ((Widget) mw);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
2706 Colormap cmap = mw->core.colormap;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 XColor topc, botc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 int top_frobbed = 0, bottom_frobbed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2710 if (mw->menu.top_shadow_color == (Pixel) (-1))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2711 mw->menu.top_shadow_color = mw->core.background_pixel;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2712 if (mw->menu.bottom_shadow_color == (Pixel) (-1))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
2713 mw->menu.bottom_shadow_color = mw->menu.foreground;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 if (mw->menu.top_shadow_color == mw->core.background_pixel ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 mw->menu.top_shadow_color == mw->menu.foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 topc.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 XQueryColor (dpy, cmap, &topc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 /* don't overflow/wrap! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 topc.red = MINL (65535, topc.red * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 topc.green = MINL (65535, topc.green * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 topc.blue = MINL (65535, topc.blue * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 if (allocate_nearest_color (dpy, cmap, &topc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 if (topc.pixel == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 XFreeColors( dpy, cmap, &topc.pixel, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 topc.red = MINL (65535, topc.red + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 topc.green = MINL (65535, topc.green + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 topc.blue = MINL (65535, topc.blue + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 if (allocate_nearest_color (dpy, cmap, &topc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 mw->menu.top_shadow_color = topc.pixel;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2735 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 mw->menu.top_shadow_color = topc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 top_frobbed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 if (mw->menu.bottom_shadow_color == mw->menu.foreground ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 mw->menu.bottom_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 botc.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 XQueryColor (dpy, cmap, &botc);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2750 botc.red = (botc.red * 3) / 5;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2751 botc.green = (botc.green * 3) / 5;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
2752 botc.blue = (botc.blue * 3) / 5;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 if (allocate_nearest_color (dpy, cmap, &botc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 if (botc.pixel == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 XFreeColors (dpy, cmap, &botc.pixel, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 botc.red = MINL (65535, botc.red + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 botc.green = MINL (65535, botc.green + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 botc.blue = MINL (65535, botc.blue + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 if (allocate_nearest_color (dpy, cmap, &botc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 mw->menu.bottom_shadow_color = botc.pixel;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2764 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 mw->menu.bottom_shadow_color = botc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 bottom_frobbed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 if (top_frobbed && bottom_frobbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 if (bot_avg > top_avg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 Pixel tmp = mw->menu.top_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 mw->menu.top_shadow_color = mw->menu.bottom_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 mw->menu.bottom_shadow_color = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 else if (topc.pixel == botc.pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 if (botc.pixel == mw->menu.foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 mw->menu.top_shadow_color = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 mw->menu.bottom_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 if (!mw->menu.top_shadow_pixmap &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 mw->menu.top_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 mw->menu.top_shadow_pixmap = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 mw->menu.top_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 if (!mw->menu.bottom_shadow_pixmap &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 mw->menu.bottom_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 mw->menu.bottom_shadow_pixmap = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 mw->menu.bottom_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 xgcv.fill_style = FillOpaqueStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 xgcv.foreground = mw->menu.top_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 xgcv.background = mw->core.background_pixel;
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2810 /* xgcv.stipple = mw->menu.top_shadow_pixmap; gtb */
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2811 #ifdef NEED_MOTIF
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2812 if (mw->menu.top_shadow_pixmap &&
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2813 mw->menu.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2814 xgcv.stipple = mw->menu.top_shadow_pixmap;
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2815 else
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2816 xgcv.stipple = 0;
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2817 #else
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
2818 xgcv.stipple = mw->menu.top_shadow_pixmap;
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2819 #endif /* NEED_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 mw->menu.shadow_top_gc =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 xgcv.foreground = mw->menu.bottom_shadow_color;
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2825 /* xgcv.stipple = mw->menu.bottom_shadow_pixmap; gtb */
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2826 #ifdef NEED_MOTIF
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2827 if (mw->menu.top_shadow_pixmap &&
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2828 mw->menu.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2829 xgcv.stipple = mw->menu.bottom_shadow_pixmap;
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2830 else
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2831 xgcv.stipple = 0;
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2832 #else
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
2833 xgcv.stipple = mw->menu.bottom_shadow_pixmap;
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
2834 #endif /* NEED_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 mw->menu.shadow_bottom_gc =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 release_shadow_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 extract_font_extents (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 /* Find the maximal ascent/descent of the fonts in the font list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 so that all menu items can be the same height... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 mw->menu.font_ascent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 mw->menu.font_descent = 0;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2857
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 XmFontContext context;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 XmFontListEntry fontentry;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2862 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 XmStringCharSet charset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 XFontStruct *font;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 if (! XmFontListInitFontContext (&context, mw->menu.font_list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 /* There is a BUG in the 1.2 version of XmFontListGetNextFont() (or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 specifically, in _XmGetFirstFont()) that can cause a null pointer to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 passed to XFontsOfFontSet. Use XmFontListNextEntry(), which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 newer equivalent, instead. Also, it supports font sets, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 older function doesn't. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 while ((fontentry = XmFontListNextEntry (context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2877 XmFontType rettype;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2878
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
2879 XtPointer one_of_them = XmFontListEntryGetFont (fontentry, &rettype);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 if (rettype == XmFONT_IS_FONTSET)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 XFontSet fontset = (XFontSet) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 XFontStruct **fontstruct_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 char **fontname_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 int fontcount = XFontsOfFontSet (fontset, &fontstruct_list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 &fontname_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 while (--fontcount >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 font = fontstruct_list[fontcount];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 else /* XmFONT_IS_FONT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 font = (XFontStruct *) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 #else /* motif 1.1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 while (XmFontListGetNextFont (context, &charset, &font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 XtFree (charset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 #endif /* Motif version */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 XmFontListFreeFontContext (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 #else /* Not Motif */
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2918 # ifdef USE_XFONTSET
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2919 XFontStruct **fontstruct_list;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2920 char **fontname_list;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2921 XFontStruct *font;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2922 int fontcount = XFontsOfFontSet(mw->menu.font_set, &fontstruct_list,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2923 &fontname_list);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2924 mw->menu.font_ascent = 0;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2925 mw->menu.font_descent = 0;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2926 # if 0 /* nasty, personal debug, Kazz */
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2927 fprintf(stderr, "fontSet count is %d\n", fontcount);
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2928 # endif
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2929 while (--fontcount >= 0) {
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2930 font = fontstruct_list[fontcount];
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2931 if (font->ascent > (int) mw->menu.font_ascent)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2932 mw->menu.font_ascent = font->ascent;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2933 if (font->descent > (int) mw->menu.font_descent)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2934 mw->menu.font_descent = font->descent;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2935 }
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2936 # else /* ! USE_XFONTSET */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 mw->menu.font_ascent = mw->menu.font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 mw->menu.font_descent = mw->menu.font->descent;
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 114
diff changeset
2939 # endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 #endif /* NEED_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 static XFontStruct *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 default_font_of_font_list (XmFontList font_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 XFontStruct *font = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 # if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 /* Xm/Label.c does this: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 _XmFontListGetDefaultFont (font_list, &font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 # else /* !0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 XmFontContext context;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 XmFontListEntry fontentry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 XmFontType rettype;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
2957 XtPointer one_of_them;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2958 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 XmStringCharSet charset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 #endif
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2961
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 if (! XmFontListInitFontContext (&context, font_list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 /* There is a BUG in the 1.2 version of XmFontListGetNextFont() (or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 specifically, in _XmGetFirstFont()) that can cause a null pointer to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 passed to XFontsOfFontSet. Use XmFontListNextEntry(), which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 newer equivalent, instead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 fontentry = XmFontListNextEntry (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 one_of_them = XmFontListEntryGetFont (fontentry, &rettype);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 if (rettype == XmFONT_IS_FONTSET)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 XFontSet fontset = (XFontSet) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 XFontStruct **fontstruct_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 char **fontname_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 (void) XFontsOfFontSet (fontset, &fontstruct_list, &fontname_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 font = fontstruct_list[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 else /* XmFONT_IS_FONT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 font = (XFontStruct *) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2983 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 if (! XmFontListGetNextFont (context, &charset, &font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 XtFree (charset);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
2987 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 XmFontListFreeFontContext (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 # endif /* !0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 if (! font) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 return font;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 #endif /* NEED_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 XlwMenuInitialize (Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 Cardinal *num_args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 /* Get the GCs and the widget size */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 XlwMenuWidget mw = (XlwMenuWidget)new;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3003
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 int mask;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3006
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 Display *display = XtDisplay (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3009
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 mw->menu.cursor = mw->menu.cursor_shape;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3012
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3013 mw->menu.gray_pixmap =
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3014 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3015 gray_width, gray_height, 1, 0, 1);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3016
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 /* The menu.font_list slot came from the *fontList resource (Motif standard.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 The menu.font_list_2 slot came from the *font resource, for backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 compatibility with older versions of this code, and consistency with the
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 365
diff changeset
3021 rest of emacs. If both font and fontList are specified, we use font.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 If only one is specified, we use that. If neither are specified, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 use the "fallback" value. What a kludge!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 Note that this has the bug that a more general wildcard like "*fontList:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 will override a more specific resource like "Emacs*menubar.font:". But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 I can't think of a way around that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 if (mw->menu.font_list) /* if *fontList is specified, use that */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 else if (mw->menu.font_list_2) /* else if *font is specified, use that */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 mw->menu.font_list = mw->menu.font_list_2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 else /* otherwise use default */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 mw->menu.font_list = mw->menu.fallback_font_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 make_drawing_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 make_shadow_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 extract_font_extents (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 xswa.background_pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 xswa.border_pixel = mw->core.border_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 mask = CWBackPixel | CWBorderPixel;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3044
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 mw->menu.popped_up = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 mw->menu.next_release_must_exit = False;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3048
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 mw->menu.old_depth = 1;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3050 mw->menu.old_stack = XtNew (widget_value*);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 mw->menu.old_stack_length = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 mw->menu.old_stack [0] = mw->menu.contents;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3053
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 mw->menu.new_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 mw->menu.new_stack = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 mw->menu.new_stack_length = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 push_new_stack (mw, mw->menu.contents);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3058
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3059 mw->menu.windows = XtNew (window_state);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 mw->menu.windows_length = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 mw->menu.windows [0].x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 mw->menu.windows [0].y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 mw->menu.windows [0].width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 mw->menu.windows [0].height = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 size_menu (mw, 0);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3066
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 mw->core.width = mw->menu.windows [0].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 mw->core.height = mw->menu.windows [0].height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 XlwMenuClassInitialize (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
3074 initialize_massaged_resource_char();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 int mask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (*xlwMenuWidgetClass->core_class.superclass->core_class.realize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (w, valueMask, attributes);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 xswa.save_under = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 xswa.cursor = mw->menu.cursor_shape;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 mask = CWSaveUnder | CWCursor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 if (mw->menu.use_backing_store)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 xswa.backing_store = Always;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 mask |= CWBackingStore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 XChangeWindowAttributes (XtDisplay (w), XtWindow (w), mask, &xswa);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 mw->menu.windows [0].window = XtWindow (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 mw->menu.windows [0].x = w->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 mw->menu.windows [0].y = w->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 mw->menu.windows [0].width = w->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 mw->menu.windows [0].height = w->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 /* Only the toplevel menubar/popup is a widget so it's the only one that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 receives expose events through Xt. So we repaint all the other panes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 when receiving an Expose event. */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3107 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 XlwMenuRedisplay (Widget w, XEvent *ev, Region region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 if (mw->core.being_destroyed) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 for (i = 0; i < mw->menu.old_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 display_menu (mw, i, False, NULL, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 set_new_state (mw, NULL, mw->menu.old_depth); /* #### - ??? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 remap_menubar (mw); /* #### - do these two lines do anything? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3121 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 XlwMenuDestroy (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 XlwMenuWidget mw = (XlwMenuWidget) w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 if (mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 XtUngrabPointer (w, CurrentTime);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3132
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 release_drawing_gcs (mw);
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3134 release_shadow_gcs (mw);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 /* this doesn't come from the resource db but is created explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 so we must free it ourselves. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 mw->menu.gray_pixmap = (Pixmap) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 /* Don't free mw->menu.contents because that comes from our creator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 The `*_stack' elements are just pointers into `contents' so leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 that alone too. But free the stacks themselves. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 /* Remember, you can't free anything that came from the resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 database. This includes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 mw->menu.cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 mw->menu.top_shadow_pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 mw->menu.bottom_shadow_pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 mw->menu.font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 mw->menu.font_set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 Also the color cells of top_shadow_color, bottom_shadow_color,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 foreground, and button_foreground will never be freed until this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 client exits. Nice, eh?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 /* start from 1 because the one in slot 0 is w->core.window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 for (i = 1; i < mw->menu.windows_length; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 XDestroyWindow (XtDisplay (mw), mw->menu.windows [i].window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 if (mw->menu.windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 XtFree ((char *) mw->menu.windows);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3166 static Boolean
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 XlwMenuSetValues (Widget current, Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 Cardinal *num_args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 XlwMenuWidget oldmw = (XlwMenuWidget)current;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 XlwMenuWidget newmw = (XlwMenuWidget)new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 Boolean redisplay = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 if (newmw->menu.contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 && newmw->menu.contents->contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 && newmw->menu.contents->contents->change >= VISIBLE_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 redisplay = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 if (newmw->core.background_pixel != oldmw->core.background_pixel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 || newmw->menu.foreground != oldmw->menu.foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 /* For the XEditResource protocol, which may want to change the font. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 #ifdef NEED_MOTIF
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3184 || newmw->menu.font_list != oldmw->menu.font_list
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3185 || newmw->menu.font_list_2 != oldmw->menu.font_list_2
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 || newmw->menu.font != oldmw->menu.font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 release_drawing_gcs (newmw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 make_drawing_gcs (newmw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 redisplay = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3195
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 for (i = 0; i < oldmw->menu.windows_length; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 XSetWindowBackground (XtDisplay (oldmw),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 oldmw->menu.windows [i].window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 newmw->core.background_pixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 /* clear windows and generate expose events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 XClearArea (XtDisplay (oldmw), oldmw->menu.windows[i].window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 0, 0, 0, 0, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 return redisplay;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3210 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 XlwMenuResize (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3215 mw->menu.windows [0].width = mw->core.width;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 mw->menu.windows [0].height = mw->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 /* Action procedures */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 handle_single_motion_event (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 Boolean select_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 widget_value *val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 Boolean stay_up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 int level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 if (!map_event_to_widget_value (mw, ev, &val, &level, &stay_up))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 /* we wind up here when: (a) the event is in the menubar, (b) the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 event isn't in the menubar or any of the panes, (c) the event is on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 a disabled menu item */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 pop_new_stack_if_no_contents (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 if (select_p && !stay_up) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 /* pop down all menus and exit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 mw->menu.next_release_must_exit = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3237 set_new_state(mw, (val = NULL), 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 /* we wind up here when: (a) the event pops up a pull_right menu,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (b) a menu item that is not disabled is highlighted */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 if (select_p && mw->menu.bounce_down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 && close_to_reference_time((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 mw->menu.menu_bounce_time,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (XEvent *)ev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 /* motion can cause more than one event. Don't bounce right back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 up if we've just bounced down. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 else if (select_p && mw->menu.bounce_down &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 mw->menu.last_selected_val &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (mw->menu.last_selected_val == val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 val = NULL; /* assigned to mw->last_selected_val below */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 mw->menu.menu_bounce_time = ev->time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 /* popdown last menu if we're selecting the same menu item as we did
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 last time and the XlwMenu.bounceDown resource is set, if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 item is on the menubar itself, then exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 if (level == (mw->menu.popped_up ? 0 : 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 mw->menu.next_release_must_exit = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3264 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 set_new_state (mw, val, level);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 mw->menu.last_selected_val = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 remap_menubar (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3271
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 /* Sync with the display. Makes it feel better on X terms. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 XFlush (XtDisplay (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 handle_motion_event (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 Boolean select_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 int x = ev->x_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 int y = ev->y_root;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
3282 unsigned int state = ev->state;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 XMotionEvent *event= ev, dummy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 /* allow motion events to be generated again */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 dummy.window = ev->window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 if (ev->is_hint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 && XQueryPointer (XtDisplay (mw), dummy.window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 &dummy.root, &dummy.subwindow,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 &dummy.x_root, &dummy.y_root,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 &dummy.x, &dummy.y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 &dummy.state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 && dummy.state == state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 && (dummy.x_root != x || dummy.y_root != y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 /* don't handle the event twice or that breaks bounce_down. --Stig */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 dummy.type = ev->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 event = &dummy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3301 lw_menu_accelerate = False;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 handle_single_motion_event (mw, event, select_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3305 Time x_focus_timestamp_really_sucks_fix_me_better;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3306
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3307 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 Start (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3312 lw_menubar_widget = w;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3313
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3314 lw_menu_active = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3315
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 if (!mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 mw->menu.menu_post_time = ev->xbutton.time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 mw->menu.last_selected_val = NULL;
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3322 x_focus_timestamp_really_sucks_fix_me_better =
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3323 ((XButtonPressedEvent*)ev)->time;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3325
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 /* notes the absolute position of the menubar window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3329
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 XtGrabPointer ((Widget)mw, False,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 (ButtonMotionMask | ButtonReleaseMask | ButtonPressMask),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 GrabModeAsync, GrabModeAsync,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 None, mw->menu.cursor_shape,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 ((XButtonPressedEvent*)ev)->time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 mw->menu.pointer_grabbed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 /* handles the down like a move, slots are mostly compatible */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 handle_motion_event (mw, &ev->xmotion, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3342 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 handle_motion_event (mw, &ev->xmotion, False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3349 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 Select (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 widget_value *selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3354
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3355 lw_menu_accelerate = False;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3356
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 /* If user releases the button quickly, without selecting anything,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 after the initial down-click that brought the menu up,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 if ((selected_item == 0 || selected_item->call_data == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 && (!mw->menu.next_release_must_exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 || close_to_reference_time(w, mw->menu.menu_post_time, ev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 mw->menu.next_release_must_exit = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 /* pop down everything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 mw->menu.new_depth = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 remap_menubar (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3371
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 /* Destroy() only gets called for popup menus. Menubar widgets aren't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 destroyed when their menu panes get nuked. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 if (mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 XtUngrabPointer ((Widget)w, ev->xmotion.time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3379
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 if (mw->menu.popped_up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 mw->menu.popped_up = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 XtPopdown (XtParent (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3385
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3386 lw_menu_active = False;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3387
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3388 x_focus_timestamp_really_sucks_fix_me_better =
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3389 ((XButtonPressedEvent*)ev)->time;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3390
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 /* callback */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3392 XtCallCallbackList ((Widget) mw, mw->menu.select, (XtPointer) selected_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3395 /* Action procedures for keyboard accelerators */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3396
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3397 /* set the menu */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3398 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3399 xlw_set_menu (Widget w, widget_value *val)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3400 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3401 lw_menubar_widget = w;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3402 set_new_state ((XlwMenuWidget)w, val, 1);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3403 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3404
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3405 /* prepare the menu structure via the call-backs */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3406 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3407 xlw_map_menu (Time t)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3408 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3409 XlwMenuWidget mw = (XlwMenuWidget)lw_menubar_widget;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3410
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3411 lw_menu_accelerate = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3412
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3413 if (!mw->menu.pointer_grabbed)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3414 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3415 XWindowAttributes ret;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3416 Window parent,root;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3417 Window *waste;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3418 unsigned int num_waste;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3419
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3420 lw_menu_active = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3421
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3422 mw->menu.menu_post_time = t;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3423 mw->menu.menu_bounce_time = 0;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3424
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3425 mw->menu.next_release_must_exit = True;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3426 mw->menu.last_selected_val = NULL;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3427
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3428 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3429
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3430 /* do this for keyboards too! */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3431 /* notes the absolute position of the menubar window */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3432 /*
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3433 mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3434 mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3435 */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3436
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3437 /* get the geometry of the menubar */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3438
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3439 /* there has to be a better way than this. */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3440
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3441 mw->menu.windows [0].x = 0;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3442 mw->menu.windows [0].y = 0;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3443
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3444 parent = XtWindow (lw_menubar_widget);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3445 do
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3446 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3447 XGetWindowAttributes (XtDisplay (lw_menubar_widget), parent, &ret);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3448 mw->menu.windows [0].x += ret.x;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3449 mw->menu.windows [0].y += ret.y;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3450
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3451 if (parent)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3452 XQueryTree (XtDisplay (lw_menubar_widget), parent, &root, &parent, &waste,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3453 &num_waste);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3454 if (waste)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3455 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3456 XFree (waste);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3457 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3458 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3459 while (parent != root);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3460
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3461 XtGrabPointer ((Widget)mw, False,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3462 (ButtonMotionMask | ButtonReleaseMask | ButtonPressMask),
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3463 GrabModeAsync, GrabModeAsync,
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3464 None, mw->menu.cursor_shape, t);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3465 mw->menu.pointer_grabbed = True;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3466 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3467 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3468
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3469 /* display the stupid menu already */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3470 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3471 xlw_display_menu (Time t)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3472 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3473 XlwMenuWidget mw = (XlwMenuWidget)lw_menubar_widget;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3474
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3475 lw_menu_accelerate = True;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3476
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3477 remap_menubar (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3478
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3479 /* Sync with the display. Makes it feel better on X terms. */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3480 XFlush (XtDisplay (mw));
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3481 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3482
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3483 /* push a sub menu */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3484 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3485 xlw_push_menu (widget_value *val)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3486 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3487 push_new_stack ((XlwMenuWidget)lw_menubar_widget, val);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3488 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3489
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3490 /* pop a sub menu */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3491 int
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3492 xlw_pop_menu (void)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3493 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3494 if (((XlwMenuWidget)lw_menubar_widget)->menu.new_depth > 0)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3495 ((XlwMenuWidget)lw_menubar_widget)->menu.new_depth --;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3496 else
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3497 return 0;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3498 return 1;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3499 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3500
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3501 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3502 xlw_kill_menus (widget_value *val)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3503 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3504 XlwMenuWidget mw = (XlwMenuWidget)lw_menubar_widget;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3505
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3506 lw_menu_accelerate = False;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3507
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3508 mw->menu.new_depth = 1;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3509 remap_menubar (mw);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3510
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3511 if (mw->menu.pointer_grabbed)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3512 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3513 XtUngrabPointer (lw_menubar_widget, CurrentTime);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3514 mw->menu.pointer_grabbed = False;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3515 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3516
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3517 lw_menu_active = False;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3518 XtCallCallbackList (lw_menubar_widget, mw->menu.select, (XtPointer)val);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3519 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3520
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3521 /* set the menu item */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3522 void
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3523 xlw_set_item (widget_value *val)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3524 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3525 if (((XlwMenuWidget)lw_menubar_widget)->menu.new_depth > 0)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3526 ((XlwMenuWidget) lw_menubar_widget)->menu.new_depth --;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3527 push_new_stack ((XlwMenuWidget) lw_menubar_widget, val);
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3528 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3529
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3530 /* get either the current entry or a list of all entries in the current submenu */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3531 widget_value *
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3532 xlw_get_entries (int allp)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3533 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3534 XlwMenuWidget mw = (XlwMenuWidget)lw_menubar_widget;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3535 if (allp)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3536 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3537 if (mw->menu.new_depth >= 2)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3538 return mw->menu.new_stack [mw->menu.new_depth - 2]->contents;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3539 else
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3540 return mw->menu.new_stack[0];
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3541 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3542 else
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3543 if (mw->menu.new_depth >= 1)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3544 return mw->menu.new_stack [mw->menu.new_depth - 1];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3545
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3546 return NULL;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3547 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3548
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3549 int
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3550 xlw_menu_level (void)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3551 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3552 return ((XlwMenuWidget)lw_menubar_widget)->menu.new_depth;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3553 }
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 163
diff changeset
3554
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 /* Special code to pop-up a menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 xlw_pop_up_menu (XlwMenuWidget mw, XButtonPressedEvent *event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 int x = event->x_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 int y = event->y_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 int w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 int h;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 int borderwidth = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 Screen* screen = XtScreen (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 mw->menu.menu_post_time = event->time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 mw->menu.last_selected_val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3572 XtCallCallbackList ((Widget) mw, mw->menu.open, NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 size_menu (mw, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 w = mw->menu.windows [0].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 h = mw->menu.windows [0].height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 x -= borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 y -= borderwidth;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3581
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 if (x < borderwidth)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3583 x = borderwidth;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3584
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3585 if (x > WidthOfScreen (screen) - w - 2 * borderwidth)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3586 x = WidthOfScreen (screen) - w - 2 * borderwidth;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3587
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 if (y < borderwidth)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3589 y = borderwidth;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 181
diff changeset
3590
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3591 if (y > HeightOfScreen (screen) - h - 2 * borderwidth)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3592 y = HeightOfScreen (screen) - h - 2 * borderwidth;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 mw->menu.popped_up = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 XtConfigureWidget (XtParent (mw), x, y, w, h,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 XtParent (mw)->core.border_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 XtPopup (XtParent (mw), XtGrabExclusive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 if (!mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 XtGrabPointer ((Widget)mw, False,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 (ButtonMotionMask | ButtonReleaseMask | ButtonPressMask),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 GrabModeAsync, GrabModeAsync,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 None, mw->menu.cursor_shape, event->time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 mw->menu.pointer_grabbed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 mw->menu.windows [0].x = x + borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 mw->menu.windows [0].y = y + borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 handle_motion_event (mw, (XMotionEvent *) event, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 /* #### unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 * This is a horrible function which should not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 * use it to put the resize method back the way the XlwMenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 * class initializer put it. Motif screws with this when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 * the XlwMenu class gets instantiated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 xlw_unmunge_class_resize (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 if (w->core.widget_class->core_class.resize != XlwMenuResize)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
3626 w->core.widget_class->core_class.resize = XlwMenuResize;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629