annotate lwlib/xlwmenu.c @ 5104:868a5349acee

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