annotate src/toolbar-msw.c @ 793:e38acbeb1cae

[xemacs-hg @ 2002-03-29 04:46:17 by ben] lots o' fixes etc/ChangeLog: New file. Separated out all entries for etc/ into their own ChangeLog. Includes entries for the following files: etc/BABYL, etc/BETA, etc/CHARSETS, etc/DISTRIB, etc/Emacs.ad, etc/FTP, etc/GNUS-NEWS, etc/GOATS, etc/HELLO, etc/INSTALL, etc/MACHINES, etc/MAILINGLISTS, etc/MSDOS, etc/MYTHOLOGY, etc/NEWS, etc/OXYMORONS, etc/PACKAGES, etc/README, etc/TUTORIAL, etc/TUTORIAL.de, etc/TUTORIAL.ja, etc/TUTORIAL.ko, etc/TUTORIAL.se, etc/aliases.ksh, etc/altrasoft-logo.xpm, etc/check_cygwin_setup.sh, etc/custom/example-themes/europe-theme.el, etc/custom/example-themes/ex-custom-file, etc/custom/example-themes/example-theme.el, etc/e/eterm.ti, etc/edt-user.doc, etc/enriched.doc, etc/etags.1, etc/gnuserv.1, etc/gnuserv.README, etc/package-index.LATEST.gpg, etc/package-index.LATEST.pgp, etc/photos/jan.png, etc/recycle.xpm, etc/refcard.tex, etc/sample.Xdefaults, etc/sample.emacs, etc/sgml/CATALOG, etc/sgml/HTML32.dtd, etc/skk/SKK.tut.E, etc/smilies/Face_ase.xbm, etc/smilies/Face_ase2.xbm, etc/smilies/Face_ase3.xbm, etc/smilies/Face_smile.xbm, etc/smilies/Face_weep.xbm, etc/sounds, etc/toolbar, etc/toolbar/workshop-cap-up.xpm, etc/xemacs-ja.1, etc/xemacs.1, etc/yow.lines, etc\BETA, etc\NEWS, etc\README, etc\TUTORIAL, etc\TUTORIAL.de, etc\check_cygwin_setup.sh, etc\sample.init.el, etc\unicode\README, etc\unicode\mule-ucs\*, etc\unicode\other\* unicode/unicode-consortium/8859-16.TXT: New file. mule/english.el: Define this charset now, since a bug was fixed that formerly prevented it. mule/ethio-util.el: Fix compile errors involving Unicode `characters', which should be integers. Makefile.in.in: Always include gui.c, to fix compile error when TTY-only. EmacsFrame.c, abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, bytecode.h, callint.c, callproc.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.c, console-msw.h, console-tty.c, console-x.c, console-x.h, console.c, console.h, data.c, database.c, device-gtk.c, device-msw.c, device-x.c, device.c, device.h, dialog-msw.c, doc.c, doprnt.c, dumper.c, dynarr.c, editfns.c, eldap.c, eldap.h, elhash.c, elhash.h, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, events.h, extents.c, extents.h, faces.c, faces.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, free-hook.c, general-slots.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gtk-xemacs.c, gui-msw.c, gui-x.c, gui-x.h, gui.c, gui.h, gutter.c, gutter.h, indent.c, input-method-xlib.c, insdel.c, keymap.c, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-canna.c, mule-ccl.c, mule-charset.c, mule-wnnfns.c, native-gtk-toolbar.c, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, opaque.c, opaque.h, postgresql.c, postgresql.h, print.c, process-unix.c, process.c, process.h, rangetab.c, rangetab.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, search.c, select-gtk.c, select-x.c, sound.c, specifier.c, specifier.h, strftime.c, symbols.c, symeval.h, syntax.h, text.c, text.h, toolbar-common.c, toolbar-msw.c, toolbar.c, toolbar.h, tooltalk.c, tooltalk.h, ui-gtk.c, ui-gtk.h, undo.c, vm-limit.c, window.c, window.h: Eliminate XSETFOO. Replace all usages with wrap_foo(). Make symbol->name a Lisp_Object, not Lisp_String *. Eliminate nearly all uses of Lisp_String * in favor of Lisp_Object, and correct macros so most of them favor Lisp_Object. Create new error-behavior ERROR_ME_DEBUG_WARN -- output warnings, but at level `debug' (usually ignored). Use it when instantiating specifiers, so problems can be debugged. Move log-warning-minimum-level into C so that we can optimize ERROR_ME_DEBUG_WARN. Fix warning levels consistent with new definitions. Add default_ and parent fields to char table; not yet implemented. New fun Dynarr_verify(); use for further error checking on Dynarrs. Rearrange code at top of lisp.h in conjunction with dynarr changes. Fix eifree(). Use Eistrings in various places (format_event_object(), where_is_to_char(), and callers thereof) to avoid fixed-size strings buffers. New fun write_eistring(). Reindent and fix GPM code to follow standards. Set default MS Windows font to Lucida Console (same size as Courier New but less interline spacing, so more lines fit). Increase default frame size on Windows to 50 lines. (If that's too big for the workspace, the frame will be shrunk as necessary.) Fix problem with text files with no newlines (). (Change `convert-eol' coding system to use `nil' for autodetect, consistent with make-coding-system.) Correct compile warnings in vm-limit.c. Fix handling of reverse-direction charsets to avoid errors when opening (e.g.) mule-ucs/lisp/reldata/uiso8859-6.el. Recode some object printing methods to use write_fmt_string() instead of a fixed buffer and sprintf. Turn on display of png comments as warnings (level `info'), now that they're unobtrusive. Revamped the sound documentation. Fixed bug in redisplay w.r.t. hscroll/truncation/continuation glyphs causing jumping up and down of the lines, since they're bigger than the line size. (It was seen most obviously when there's a horizontal scroll bar, e.g. do C-h a glyph or something like that.) The problem was that the glyph-contrib-p setting on glyphs was ignored even if it was set properly, which it wasn't until now.
author ben
date Fri, 29 Mar 2002 04:49:13 +0000
parents 943eaba38521
children a5954632b187
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 /* toolbar implementation -- mswindows interface.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
4 Copyright (C) 1995, 1996, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1996 Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 Copyright (C) 1998 Andy Piper.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* This implementation by Andy Piper <andyp@parallax.co.uk>, with bits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 borrowed from toolbar-x.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
30 /* This file essentially Mule-ized (except perhaps some Unicode splitting).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
31 5-2000. (??? Needs a once-over.) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
32
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
33 #define NEED_MSWINDOWS_COMMCTRL
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
34
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "toolbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #include "glyphs-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #include "objects-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #define TOOLBAR_ITEM_ID_MIN 0x4000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #define TOOLBAR_ITEM_ID_MAX 0x7FFF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #define TOOLBAR_ID_BIAS 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 #define TOOLBAR_HANDLE(f,p) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
54
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #define MSWINDOWS_BUTTON_SHADOW_THICKNESS 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #define MSWINDOWS_BLANK_SIZE 5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #define MSWINDOWS_MINIMUM_TOOLBAR_SIZE 8
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 switch (pos) \
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 case TOP_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (frame)->top_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 case BOTTOM_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (frame)->bottom_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 case LEFT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (frame)->left_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 case RIGHT_TOOLBAR: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (frame)->right_toolbar_was_visible = flag; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 break; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 default: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 abort (); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
84 allocate_toolbar_item_id (struct frame *f, struct toolbar_button *button,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 /* hmm what do we generate an id based on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 int id = TOOLBAR_ITEM_ID_BITS (internal_hash (button->callback, 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 while (!NILP (Fgethash (make_int (id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 id = TOOLBAR_ITEM_ID_BITS (id + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 return id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 mswindows_clear_toolbar (struct frame *f, enum toolbar_pos pos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 int thickness_change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 HIMAGELIST ilist=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 HWND toolbarwnd = TOOLBAR_HANDLE(f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 if (toolbarwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 TBBUTTON info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
108 /* Delete the buttons and remove the command from the hash table */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
109 i = qxeSendMessage (toolbarwnd, TB_BUTTONCOUNT, 0, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 for (i--; i >= 0; i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
112 qxeSendMessage (toolbarwnd, TB_GETBUTTON, (WPARAM)i,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (LPARAM)&info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 Fremhash(make_int(info.idCommand),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
116 qxeSendMessage (toolbarwnd, TB_DELETEBUTTON, (WPARAM)i, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 /* finally get rid of the image list assuming it clears up its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 bitmaps */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
121 qxeSendMessage (toolbarwnd, TB_GETIMAGELIST, 0, (LONG) &ilist);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 if (ilist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 ImageList_Destroy(ilist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
126 qxeSendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 ShowWindow(toolbarwnd, SW_HIDE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
131 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos) = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 int x, y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 int width=-1, height=-1, bmwidth=0, bmheight=0, maxbmwidth, maxbmheight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 int style_3d=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 int border_width = FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 Lisp_Object button, glyph, instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 Lisp_Object window = FRAME_LAST_NONMINIBUF_WINDOW (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 int nbuttons=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 int shadow_thickness = 2; /* get this from somewhere else? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 int window_frame_width = 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 int padding = (border_width + shadow_thickness) * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 unsigned int checksum=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 struct window *w = XWINDOW (window);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
151 TBBUTTON *button_tbl, *tbbutton;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 HIMAGELIST ilist=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 HWND toolbarwnd=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 /* ediff bogusly sets the height to 2 for some obscure X-specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 reason. This ensures that we only try and output a toolbar for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 sensible sizes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 if (bar_width < MSWINDOWS_MINIMUM_TOOLBAR_SIZE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 bar_height < MSWINDOWS_MINIMUM_TOOLBAR_SIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 if (x==1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 x=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 toolbarwnd = TOOLBAR_HANDLE (f,pos);
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 /* set button sizes based on bar size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 if (vert)
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 if (style_3d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 width = height = bar_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 - (window_frame_width + shadow_thickness) * 2;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 width = height = bar_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 maxbmwidth = maxbmheight = width - padding;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 if (style_3d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 height = width = bar_height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 - (window_frame_width + shadow_thickness) * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 width = height = bar_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 maxbmwidth = maxbmheight = width - padding;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 /* First loop over all of the buttons to determine how many there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 are. This loop will also make sure that all instances are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 instantiated so when we actually output them they will come up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 checksum = HASH5 (checksum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 internal_hash (get_toolbar_button_glyph(w, tb), 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 internal_hash (tb->callback, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 LISP_HASH (w->toolbar_buttons_captioned_p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 nbuttons++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* only rebuild if something has changed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* remove the old one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 mswindows_clear_toolbar (f, pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos)=checksum;
428
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 /* build up the data required by win32 fns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 tbbutton = button_tbl;
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 while (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 HBITMAP bitmap=NULL, mask=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 bitmap=mask=NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 if (tb->blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 tbbutton->fsStyle = TBSTYLE_SEP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 tbbutton->idCommand = allocate_toolbar_item_id (f, tb, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 /* currently we output the toolbar again with disabled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 buttons it might be good to use the ms disabled code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 instead but that means another image list, so we'll stick
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 with the emacs model. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 tbbutton->fsState = tb->enabled ? TBSTATE_ENABLED :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 TBSTATE_INDETERMINATE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 tbbutton->fsStyle = TBSTYLE_BUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 tbbutton->dwData=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 tbbutton->iString=0;
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 /* mess with the button image */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 glyph = get_toolbar_button_glyph (w, tb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 if (GLYPHP (glyph))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 instance = glyph_image_instance (glyph, window,
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
256 ERROR_ME_DEBUG_WARN, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 instance = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 if (IMAGE_INSTANCEP (instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
262 Lisp_Image_Instance *p = XIMAGE_INSTANCE (instance);
428
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 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 /* we are going to honor the toolbar settings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 and resize the bitmaps accordingly if they are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 too big. If they are too small we leave them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 and pad the difference - unless a different size
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 crops up in the middle, at which point we *have*
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
271 to resize since the ImageList won't cope. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 if ((bmwidth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 IMAGE_INSTANCE_PIXMAP_WIDTH (p) != bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (bmheight
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) != bmheight)
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 IMAGE_INSTANCE_PIXMAP_WIDTH (p) > maxbmwidth
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 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > maxbmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if (!bmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 bmheight = min (maxbmheight,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 if (!bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 bmwidth = min (maxbmwidth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 IMAGE_INSTANCE_PIXMAP_WIDTH (p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 if (! (bitmap = mswindows_create_resized_bitmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (p, f, bmwidth, bmheight)))
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 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 if (ilist) ImageList_Destroy (ilist);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
297 gui_error ("Couldn't resize pixmap", instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 /* we don't care if the mask fails */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 mask = mswindows_create_resized_mask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (p, f, bmwidth, bmheight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 else
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 if (!bmwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 bmwidth = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 if (!bmheight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 bmheight = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 /* need to build an image list for the bitmaps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 if (!ilist && !(ilist = ImageList_Create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 ( bmwidth, bmheight,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (IMAGE_INSTANCE_MSWINDOWS_MASK (p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 ? ILC_MASK : 0) | ILC_COLOR24,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 nbuttons, nbuttons * 2 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 xfree (button_tbl);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
319 gui_error ("Couldn't create image list", instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 /* make the mask actually do something */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 ImageList_SetBkColor (ilist, CLR_NONE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 /* add a bitmap to the list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 if ((tbbutton->iBitmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 ImageList_Add
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (ilist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 bitmap ? bitmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 : IMAGE_INSTANCE_MSWINDOWS_BITMAP (p),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 mask ? mask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 : IMAGE_INSTANCE_MSWINDOWS_MASK (p))) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 xfree (button_tbl);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
334 if (ilist)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
335 ImageList_Destroy (ilist);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
336 gui_error
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 ("couldn't add image to image list", instance);
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 /* we're done with these now */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 DeleteObject (bitmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 DeleteObject (mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 }
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 Fputhash (make_int (tbbutton->idCommand),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 button, FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 }
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 /* now fix up the button size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 tb->x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 tb->y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 tb->vertical = vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 tb->border_width = border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 tb->width = width + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 tb->height = height + MSWINDOWS_BUTTON_SHADOW_THICKNESS * 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 if (tb->blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 tb->height = MSWINDOWS_BLANK_SIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 tb->width = MSWINDOWS_BLANK_SIZE;
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 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 y += tb->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 x += tb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /* move on to the next button */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 tbbutton++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 button = tb->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 button = FRAME_TOOLBAR_BUTTONS (f, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 /* create the toolbar window? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 if (!toolbarwnd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (toolbarwnd =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
380 qxeCreateWindowEx (WS_EX_WINDOWEDGE,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
381 XETEXT (TOOLBARCLASSNAME),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
382 NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
383 WS_CHILD
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
384 | (style_3d ? WS_DLGFRAME : 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
385 | TBSTYLE_TOOLTIPS
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
386 | CCS_NORESIZE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
387 | CCS_NOPARENTALIGN | CCS_NODIVIDER
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
388 | CCS_ADJUSTABLE,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
389 x, y, bar_width, bar_height,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
390 FRAME_MSWINDOWS_HANDLE (f),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
391 (HMENU)(TOOLBAR_ID_BIAS + pos),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
392 NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
393 NULL))==NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 ImageList_Destroy (ilist);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
397 gui_error ("couldn't create toolbar", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 /* finally populate with images */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
401 if (qxeSendMessage (toolbarwnd, TB_BUTTONSTRUCTSIZE,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
402 (WPARAM)sizeof(TBBUTTON), (LPARAM)0) == -1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 mswindows_clear_toolbar (f, pos, 0);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
405 gui_error ("couldn't set button structure size", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 height = min (bmheight + padding, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 width = min (bmwidth + padding, width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 /* pad the buttons */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
414 qxeSendMessage (toolbarwnd, TB_SETPADDING,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
415 0, MAKELPARAM (width - bmwidth, height - bmheight));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 /* set the size of buttons */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
418 qxeSendMessage (toolbarwnd, TB_SETBUTTONSIZE, 0,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
419 (LPARAM) MAKELONG (width, height));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 /* set the size of bitmaps */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
422 qxeSendMessage (toolbarwnd, TB_SETBITMAPSIZE, 0,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
423 (LPARAM) MAKELONG (bmwidth, bmheight));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 /* tell it we've done it */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
426 qxeSendMessage (toolbarwnd, TB_AUTOSIZE, 0, 0);
428
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 /* finally populate with images */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
429 if (!qxeSendMessage (toolbarwnd, TB_ADDBUTTONS,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
430 (WPARAM) nbuttons, (LPARAM) button_tbl))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 mswindows_clear_toolbar (f, pos, 0);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
433 gui_error ("couldn't add button list to toolbar", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 /* vertical toolbars need more rows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 if (vert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 RECT tmp;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
440 qxeSendMessage (toolbarwnd, TB_SETROWS,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
441 MAKEWPARAM (nbuttons, FALSE), (LPARAM) &tmp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 RECT tmp;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
447 qxeSendMessage (toolbarwnd, TB_SETROWS, MAKEWPARAM(1, FALSE),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
448 (LPARAM)&tmp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 /* finally populate with images */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
452 if (qxeSendMessage (toolbarwnd, TB_SETIMAGELIST, 0,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
453 (LPARAM)ilist) < 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 ||
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
455 qxeSendMessage (toolbarwnd, TB_SETDISABLEDIMAGELIST, 0,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
456 (LPARAM)ilist) < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 mswindows_clear_toolbar (f, pos, 0);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 442
diff changeset
459 gui_error ("couldn't add image list to toolbar", Qunbound);
428
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 /* now display the window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 ShowWindow (toolbarwnd, SW_SHOW);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 /* no idea why this is necessary but initial display will not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 happen otherwise. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 mswindows_move_toolbar (f, pos);
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 if (button_tbl) xfree (button_tbl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 int bar_x, bar_y, bar_width, bar_height, vert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 HWND toolbarwnd = TOOLBAR_HANDLE(f,pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 if (toolbarwnd)
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 get_toolbar_coords (f, pos, &bar_x, &bar_y, &bar_width, &bar_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 &vert, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 /* #### This terrible mangling with coordinates perhaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 arises from different treatment of toolbar positions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 by Windows and by XEmacs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 switch (pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 case TOP_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 bar_x--; bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 bar_width+=3; bar_height+=3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 case LEFT_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 bar_x--; bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 bar_height++; bar_width++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 case BOTTOM_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 bar_y-=2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 bar_width+=4; bar_height+=4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 case RIGHT_TOOLBAR:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 bar_y-=2; bar_x++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 bar_width++; bar_height++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 break;
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 SetWindowPos (toolbarwnd, NULL, bar_x, bar_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 bar_width, bar_height, SWP_NOZORDER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 mswindows_redraw_exposed_toolbars (struct frame *f, int x, int y, int width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 assert (FRAME_MSWINDOWS_P (f));
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 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 mswindows_move_toolbar (f, TOP_TOOLBAR);
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 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 mswindows_move_toolbar (f, BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 mswindows_move_toolbar (f, LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 mswindows_move_toolbar (f, RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 mswindows_redraw_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 FRAME_PIXHEIGHT (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 mswindows_initialize_frame_toolbars (struct frame *f)
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
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 mswindows_output_frame_toolbars (struct frame *f)
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 assert (FRAME_MSWINDOWS_P (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 mswindows_output_toolbar (f, TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 else if (f->top_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 mswindows_clear_toolbar (f, TOP_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 mswindows_output_toolbar (f, BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 else if (f->bottom_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 mswindows_clear_toolbar (f, BOTTOM_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 mswindows_output_toolbar (f, LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 else if (f->left_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 mswindows_clear_toolbar (f, LEFT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 mswindows_output_toolbar (f, RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 else if (f->right_toolbar_was_visible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 mswindows_clear_toolbar (f, RIGHT_TOOLBAR, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 mswindows_free_frame_toolbars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 HWND twnd=NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 #define DELETE_TOOLBAR(pos) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575 mswindows_clear_toolbar(f, pos, 0); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
576 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 TOOLBAR_ID_BIAS + pos))) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 DestroyWindow(twnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 DELETE_TOOLBAR(TOP_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 DELETE_TOOLBAR(BOTTOM_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 DELETE_TOOLBAR(LEFT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 DELETE_TOOLBAR(RIGHT_TOOLBAR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 #undef DELETE_TOOLBAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
587 /* map toolbar hwnd to pos */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
588 static int
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
589 mswindows_find_toolbar_pos (struct frame *f, HWND ctrl)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
591 int id = GetDlgCtrlID (ctrl);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 return id ? id - TOOLBAR_ID_BIAS : -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 Lisp_Object
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
596 mswindows_get_toolbar_button_text (struct frame *f, int command_id)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 Lisp_Object button = Fgethash (make_int (command_id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
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 if (!NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 return tb->help_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 return Qnil;
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 * Return value is Qt if we have dispatched the command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 * or Qnil if id has not been mapped to a callback.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 * Window procedure may try other targets to route the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 * command if we return nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 Lisp_Object
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
616 mswindows_handle_toolbar_wm_command (struct frame *f, HWND ctrl, WORD id)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 /* Try to map the command id through the proper hash table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 Lisp_Object button, data, fn, arg, frame;
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 button = Fgethash (make_int (id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f), Qnil);
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 if (NILP (button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 data = XTOOLBAR_BUTTON (button)->callback;
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 /* #### ? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 if (UNBOUNDP (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 /* Ok, this is our one. Enqueue it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 get_gui_callback (data, &fn, &arg);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
635 frame = wrap_frame (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 mswindows_enqueue_misc_user_event (frame, fn, arg);
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 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
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 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 console_type_create_toolbar_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars);
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