annotate lwlib/xlwmenu.c @ 48:56c54cf7c5b6 r19-16b90

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