annotate lwlib/xlwmenu.c @ 872:79c6ff3eef26

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