annotate src/dialog-msw.c @ 617:af57a77cbc92

[xemacs-hg @ 2001-06-18 07:09:50 by ben] --------------------------------------------------------------- DOCUMENTATION FIXES: --------------------------------------------------------------- eval.c: Correct documentation. elhash.c: Doc correction. --------------------------------------------------------------- LISP OBJECT CLEANUP: --------------------------------------------------------------- bytecode.h, buffer.h, casetab.h, chartab.h, console-msw.h, console.h, database.c, device.h, eldap.h, elhash.h, events.h, extents.h, faces.h, file-coding.h, frame.h, glyphs.h, gui-x.h, gui.h, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lrecord.h, lstream.h, mule-charset.h, objects.h, opaque.h, postgresql.h, process.h, rangetab.h, specifier.h, toolbar.h, tooltalk.h, ui-gtk.h: Add wrap_* to all objects (it was already there for a few of them) -- an expression to encapsulate a pointer into a Lisp object, rather than the inconvenient XSET*. "wrap" was chosen because "make" as in make_int(), make_char() is not appropriate. (It implies allocation. The issue does not exist for ints and chars because they are not allocated.) Full error checking has been added to these expressions. When used without error checking, non-union build, use of these expressions will incur no loss of efficiency. (In fact, XSET* is now defined in terms of wrap_* in a non-union build.) In a union build, you will also get no loss of efficiency provided that you have a decent optimizing compiler, and a compiler that either understands inlines or automatically inlines those particular functions. (And since people don't normally do their production builds on union, it doesn't matter.) Update the sample Lisp object definition in lrecord.h accordingly. dumper.c: Fix places in dumper that referenced wrap_object to reference its new name, wrap_pointer_1. buffer.c, bufslots.h, conslots.h, console.c, console.h, devslots.h, device.c, device.h, frame.c, frame.h, frameslots.h, window.c, window.h, winslots.h: -- Extract out the Lisp objects of `struct device' into devslots.h, just like for the other structures. -- Extract out the remaining (not copied into the window config) Lisp objects in `struct window' into winslots.h; use different macros (WINDOW_SLOT vs. WINDOW_SAVED_SLOT) to differentiate them. -- Eliminate the `dead' flag of `struct frame', since it duplicates information already available in `framemeths', and fix FRAME_LIVE_P accordingly. (Devices and consoles already work this way.) -- In *slots.h, switch to system where MARKED_SLOT is automatically undef'd at the end of the file. (Follows what winslots.h already does.) -- Update the comments at the beginning of *slots.h to be accurate. -- When making any of the above objects dead, zero it out entirely and reset all Lisp object slots to Qnil. (We were already doing this somewhat, but not consistently.) This (1) Eliminates the possibility of extra objects hanging around that ought to be GC'd, (2) Causes an immediate crash if anyone tries to access a structure in one of these objects, (3) Ensures consistent behavior wrt dead objects. dialog-msw.c: Use internal_object_printer, since this object should not escape. --------------------------------------------------------------- FIXING A CRASH THAT I HIT ONCE (AND A RELATED BAD BEHAVIOR): --------------------------------------------------------------- eval.c: Fix up some comments about the FSF implementation. Fix two nasty bugs: (1) condition_case_unwind frees the conses sitting in the catch->tag slot too quickly, resulting in a crash that I hit. (2) catches need to be unwound one at a time when calling unwind-protect code, rather than all at once at the end; otherwise, incorrect behavior can result. (A comment shows exactly how.) backtrace.h: Improve comment about FSF differences in the handler stack. --------------------------------------------------------------- FIXING A CRASH THAT I REPEATEDLY HIT WHEN USING THE MOUSE WHEEL UNDER MSWINDOWS: --------------------------------------------------------------- Basic idea: My crash is due either to a dead, non-marked, GC-collected frame inside of a window mirror, or a prematurely freed window mirror. We need to mark the Lisp objects inside of window mirrors. Tracking the lifespan of window mirrors and scrollbar instances is extremely hard, and there may well be lurking bugs where such objects are freed too soon. The only safe way to fix these problems (and it fixes both problems at once) is to make both of these structures Lisp objects. lrecord.h, emacs.c, inline.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, symsinit.h: Make scrollbar instances actual Lisp objects. Mark the window mirrors in them. inline.c needs to know about scrollbar.h now. Record the new type in lrecord.h. Fix up scrollbar-*.c appropriately. Create a hash table in scrollbar-msw.c so that the scrollbar instances stored in scrollbar HWND's are properly GC-protected. Create complex_vars_of_scrollbar_mswindows() to create the hash table at startup, and call it from emacs.c. Don't store the scrollbar instance as a property of the GTK scrollbar, as it's not used and if we did this, we'd have to separately GC-protect it in a hash table, like in MS Windows. lrecord.h, frame.h, frame.c, frameslots.h, redisplay.c, window.c, window.h: Move mark_window_mirror from redisplay.c to window.c. Make window mirrors actual Lisp objects. Tell lrecord.h about them. Change the window mirror member of struct frame from a pointer to a Lisp object, and add XWINDOW_MIRROR in appropriate places. Mark the scrollbar instances in the window mirror. redisplay.c, redisplay.h, alloc.c: Delete mark_redisplay. Don't call mark_redisplay. We now mark frame-specific structures in mark_frame. NOTE: I also deleted an extremely questionable call to update_frame_window_mirrors(). It was extremely questionable before, and now totally impossible, since it will create Lisp objects during redisplay. frame.c: Mark the scrollbar instances, which are now Lisp objects. Call mark_gutter() here, not in mark_redisplay(). gutter.c: Update comments about correct marking. --------------------------------------------------------------- ISSUES BROUGHT UP BY MARTIN: --------------------------------------------------------------- buffer.h: Put back these macros the way Steve T and I think they ought to be. I already explained in a previous changelog entry why I think these macros should be the way I'd defined them. Once again: We fix these macros so they don't care about the type of their lvalues. The non-C-string equivalents of these already function in the same way, and it's correct because it should be OK to pass in a CBufbyte *, a BufByte *, a Char_Binary *, an UChar_Binary *, etc. The whole reason for these different types is to work around errors caused by signed-vs-unsigned non-matching types. Any possible error that might be caught in a DFC macro would also be caught wherever the argument is used elsewhere. So creating multiple macro versions would add no useful error-checking and just further complicate an already complicated area. As for Martin's "ANSI aliasing" bug, XEmacs is not ANSI-aliasing clean and probably never will be. Unless the board agrees to change XEmacs in this way (and we really don't want to go down that road), this is not a bug. sound.h: Undo Martin's type change. signal.c: Fix problem identified by Martin with Linux and g++ due to non-standard declaration of setitimer(). systime.h: Update the docs for "qxe_" to point out why making the encapsulation explicit is always the right way to go. (setitimer() itself serves as an example.) For 21.4: update-elc-2.el: Correct misplaced parentheses, making lisp/mule not get recompiled.
author ben
date Mon, 18 Jun 2001 07:10:32 +0000
parents 5fd7ba8b56e7
children b39c14581166
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 elisp-programmable dialog boxes -- MS Windows interface.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998 Kirill M. Katsnelson <kkm@kis.ru>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3 Copyright (C) 2000 Ben Wing.
428
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 XEmacs.
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 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 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
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 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 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 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 /* Synched up with: Not in FSF. */
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 /* Author:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 Initially written by kkm, May 1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 */
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 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "opaque.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
37 #include <cderr.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
38 #include <commdlg.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
39
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
40 Lisp_Object Qdialog_box_error;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
41
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
42 static Lisp_Object Q_initial_directory;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
43 static Lisp_Object Q_initial_filename;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
44 static Lisp_Object Q_filter_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 static Lisp_Object Q_allow_multi_select;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 static Lisp_Object Q_create_prompt_on_nonexistent;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 static Lisp_Object Q_overwrite_prompt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 static Lisp_Object Q_file_must_exist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 static Lisp_Object Q_no_network_button;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 static Lisp_Object Q_no_read_only_return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 /* List containing all dialog data structures of currently popped up
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
53 dialogs. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 static Lisp_Object Vdialog_data_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
56 /* List of popup frames wanting keyboard traversal handled */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
57 static Lisp_Object Vpopup_frame_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
58
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
59 Lisp_Object Vdefault_file_dialog_filter_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
60
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* DLUs per character metrics */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #define X_DLU_PER_CHAR 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #define Y_DLU_PER_CHAR 8
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 Button metrics
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 All buttons have height of 15 DLU. The minimum width for a button is 32 DLU,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 but it can be expanded to accommodate its text, so the width is calculated as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 8 DLU per button plus 4 DLU per character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 max (32, 6 * text_length). The factor of six is rather empirical, but it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 works better than 8 which comes from the definition of a DLU. Buttons are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 spaced with 6 DLU gap. Minimum distance from the button to the left or right
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 dialog edges is 6 DLU, and the distance between the dialog bottom edge and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 buttons is 7 DLU.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #define X_MIN_BUTTON 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #define X_BUTTON_MARGIN 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #define Y_BUTTON 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define X_BUTTON_SPACING 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define X_BUTTON_FROM_EDGE 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define Y_BUTTON_FROM_EDGE 7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 Text field metrics
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 ------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Text distance from left and right edges is the same as for buttons, and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 top margin is 11 DLU. The static control has height of 2 DLU per control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 plus 8 DLU per each line of text. Distance between the bottom edge of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 control and the button row is 15 DLU. Minimum width of the static control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 is 100 DLU, thus giving minimum dialog weight of 112 DLU. Maximum width is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 300 DLU, and, if the text is wider than that, the text is wrapped on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 next line. Each character in the text is considered 4 DLU wide.
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 #define X_MIN_TEXT 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #define X_AVE_TEXT 200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #define X_MAX_TEXT 300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #define X_TEXT_FROM_EDGE X_BUTTON_FROM_EDGE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #define Y_TEXT_FROM_EDGE 11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #define Y_TEXT_MARGIN 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #define Y_TEXT_FROM_BUTTON 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #define X_MIN_TEXT_CHAR (X_MIN_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 #define X_AVE_TEXT_CHAR (X_AVE_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #define X_MAX_TEXT_CHAR (X_MAX_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 Layout algorithm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 ----------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 First we calculate the minimum width of the button row, excluding "from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 edge" distances. Note that the static control text can be narrower than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 X_AVE_TEXT only if both text and button row are narrower than that (so,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 even if text *can* be wrapped into 2 rows narrower than ave width, it is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 done). Let WBR denote the width of the button row.
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 Next, the width of the static field is determined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 First, if all lines of text fit into max (WBR, X_MAX_TEXT), the width of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 control is the same as the width of the longest line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 Second, if all lines of text are narrower than X_MIN_TEXT, then width of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 the control is set to X_MIN_TEXT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 Otherwise, width is set to max(WBR, X_AVE_TEXT). In this case, line wrapping will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 happen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 If width of the text control is larger than that of the button row, then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 latter is centered across the dialog, by giving it extra edge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 margins. Otherwise, minimal margins are given to the button row.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 #define ID_ITEM_BIAS 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 mswindows_register_popup_frame (Lisp_Object frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 Vpopup_frame_list = Fcons (frame, Vpopup_frame_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 mswindows_unregister_popup_frame (Lisp_Object frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 Vpopup_frame_list = delq_no_quit (frame, Vpopup_frame_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 /* Dispatch message to any dialog boxes. Return non-zero if dispatched. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 mswindows_is_dialog_msg (MSG *msg)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 LIST_LOOP_2 (data, Vdialog_data_list)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 if (IsDialogMessage (XMSWINDOWS_DIALOG_ID (data)->hwnd, msg))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 LIST_LOOP_2 (popup, Vpopup_frame_list)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 HWND hwnd = FRAME_MSWINDOWS_HANDLE (XFRAME (popup));
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
159 /* This is a windows feature that allows dialog type
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
160 processing to be applied to standard windows containing
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
161 controls. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 if (IsDialogMessage (hwnd, msg))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 mark_mswindows_dialog_id (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 struct mswindows_dialog_id *data = XMSWINDOWS_DIALOG_ID (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 return data->callbacks;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 DEFINE_LRECORD_IMPLEMENTATION ("mswindows-dialog-id", mswindows_dialog_id,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 593
diff changeset
178 mark_mswindows_dialog_id,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 593
diff changeset
179 internal_object_printer, 0, 0, 0, 0,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 struct mswindows_dialog_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 /* Dialog procedure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 static BOOL CALLBACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 dialog_proc (HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 switch (msg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 case WM_INITDIALOG:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 SetWindowLong (hwnd, DWL_USER, l_param);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 break;
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 case WM_DESTROY:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 Lisp_Object data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 VOID_TO_LISP (data, GetWindowLong (hwnd, DWL_USER));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 Vdialog_data_list = delq_no_quit (data, Vdialog_data_list);
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 break;
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 case WM_COMMAND:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 Lisp_Object fn, arg, data;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 struct mswindows_dialog_id *did;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 VOID_TO_LISP (data, GetWindowLong (hwnd, DWL_USER));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 did = XMSWINDOWS_DIALOG_ID (data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
207 if (w_param != IDCANCEL) /* user pressed escape */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
209 assert (w_param >= ID_ITEM_BIAS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
210 && w_param
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
211 < XVECTOR_LENGTH (did->callbacks) + ID_ITEM_BIAS);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
212
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
213 get_gui_callback (XVECTOR_DATA (did->callbacks)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
214 [w_param - ID_ITEM_BIAS],
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
215 &fn, &arg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216 mswindows_enqueue_misc_user_event (did->frame, fn, arg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 mswindows_enqueue_misc_user_event (did->frame, Qrun_hooks,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220 Qmenu_no_selection_hook);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221 /* #### need to error-protect! will do so when i merge in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222 my working ws */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223 va_run_hook_with_args (Qdelete_dialog_box_hook, 1, data);
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 DestroyWindow (hwnd);
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 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 return FALSE;
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 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 /* Helper function which converts the supplied string STRING into Unicode and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 pushes it at the end of DYNARR */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 push_lisp_string_as_unicode (unsigned_char_dynarr* dynarr, Lisp_Object string)
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 Extbyte *mbcs_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 Charcount length = XSTRING_CHAR_LENGTH (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 LPWSTR uni_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
244 TO_EXTERNAL_FORMAT (LISP_STRING, string,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
245 C_STRING_ALLOCA, mbcs_string,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
246 Qnative);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 uni_string = alloca_array (WCHAR, length + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 uni_string, sizeof(WCHAR) * (length + 1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
253 /* Helper function which converts the supplied string STRING into Unicode and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
254 pushes it at the end of DYNARR */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
255 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
256 push_bufbyte_string_as_unicode (unsigned_char_dynarr* dynarr, Bufbyte *string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 Bytecount len)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 Extbyte *mbcs_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
260 Charcount length = bytecount_to_charcount (string, len);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 LPWSTR uni_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
263 TO_EXTERNAL_FORMAT (C_STRING, string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
264 C_STRING_ALLOCA, mbcs_string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
265 Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
266 uni_string = alloca_array (WCHAR, length + 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 uni_string, sizeof(WCHAR) * (length + 1));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 /* Given button TEXT, return button width in DLU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 static unsigned int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 button_width (Lisp_Object text)
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 unsigned int width = X_DLU_PER_CHAR * XSTRING_CHAR_LENGTH (text);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 return max (X_MIN_BUTTON, width);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* Unwind protection routine frees a dynarr opaqued into arg */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 free_dynarr_opaque_ptr (Lisp_Object arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 Dynarr_free (get_opaque_ptr (arg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 return arg;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
289 #define ALIGN_TEMPLATE \
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
290 { \
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
291 unsigned int slippage = Dynarr_length (template_) & 3; \
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
292 if (slippage) \
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
293 Dynarr_add_many (template_, &zeroes, slippage); \
428
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
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 static struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
297 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
298 int errmess;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
299 char *errname;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
300 } common_dialog_errors[] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
302 { CDERR_DIALOGFAILURE, "CDERR_DIALOGFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 { CDERR_FINDRESFAILURE, "CDERR_FINDRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304 { CDERR_INITIALIZATION, "CDERR_INITIALIZATION" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 { CDERR_LOADRESFAILURE, "CDERR_LOADRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 { CDERR_LOADSTRFAILURE, "CDERR_LOADSTRFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 { CDERR_LOCKRESFAILURE, "CDERR_LOCKRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 { CDERR_MEMALLOCFAILURE, "CDERR_MEMALLOCFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
309 { CDERR_MEMLOCKFAILURE, "CDERR_MEMLOCKFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
310 { CDERR_NOHINSTANCE, "CDERR_NOHINSTANCE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311 { CDERR_NOHOOK, "CDERR_NOHOOK" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 { CDERR_NOTEMPLATE, "CDERR_NOTEMPLATE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 { CDERR_REGISTERMSGFAIL, "CDERR_REGISTERMSGFAIL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 { CDERR_STRUCTSIZE, "CDERR_STRUCTSIZE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 { PDERR_CREATEICFAILURE, "PDERR_CREATEICFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 { PDERR_DEFAULTDIFFERENT, "PDERR_DEFAULTDIFFERENT" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 { PDERR_DNDMMISMATCH, "PDERR_DNDMMISMATCH" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 { PDERR_GETDEVMODEFAIL, "PDERR_GETDEVMODEFAIL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319 { PDERR_INITFAILURE, "PDERR_INITFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 { PDERR_LOADDRVFAILURE, "PDERR_LOADDRVFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 { PDERR_NODEFAULTPRN, "PDERR_NODEFAULTPRN" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 { PDERR_NODEVICES, "PDERR_NODEVICES" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 { PDERR_PARSEFAILURE, "PDERR_PARSEFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 { PDERR_PRINTERNOTFOUND, "PDERR_PRINTERNOTFOUND" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
325 { PDERR_RETDEFFAILURE, "PDERR_RETDEFFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
326 { PDERR_SETUPFAILURE, "PDERR_SETUPFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 { CFERR_MAXLESSTHANMIN, "CFERR_MAXLESSTHANMIN" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 { CFERR_NOFONTS, "CFERR_NOFONTS" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
329 { FNERR_BUFFERTOOSMALL, "FNERR_BUFFERTOOSMALL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
330 { FNERR_INVALIDFILENAME, "FNERR_INVALIDFILENAME" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
331 { FNERR_SUBCLASSFAILURE, "FNERR_SUBCLASSFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
332 { FRERR_BUFFERLENGTHZERO, "FRERR_BUFFERLENGTHZERO" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
333 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
334
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
335 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
336 handle_file_dialog_box (struct frame *f, Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
337 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
338 OPENFILENAME ofn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
339 char fnbuf[8000];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
340
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
341 xzero (ofn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
342 ofn.lStructSize = sizeof (ofn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
343 ofn.hwndOwner = FRAME_MSWINDOWS_HANDLE (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
344 ofn.lpstrFile = fnbuf;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
345 ofn.nMaxFile = sizeof (fnbuf) / XETCHAR_SIZE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
346 xetcscpy (fnbuf, XETEXT (""));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
347
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
348 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_string (""), Qnil),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
349 ofn.lpstrInitialDir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
350
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
351 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
353 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
354 if (EQ (key, Q_initial_filename))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 Extbyte *fnout;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359 LOCAL_FILE_FORMAT_TO_TSTR (value, fnout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 xetcscpy (fnbuf, fnout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 else if (EQ (key, Q_title))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 LISP_STRING_TO_EXTERNAL (value, ofn.lpstrTitle, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 else if (EQ (key, Q_initial_directory))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
368 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
369 ofn.lpstrInitialDir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
370 else if (EQ (key, Q_file_must_exist))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372 if (!NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
373 ofn.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
374 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
375 ofn.Flags &= ~(OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
378 invalid_constant ("Unrecognized file-dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382 if (!GetOpenFileName (&ofn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 DWORD err = CommDlgExtendedError ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 if (!err)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
386 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
387 while (1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
388 signal_quit ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
394 for (i = 0; i < countof (common_dialog_errors); i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396 if (common_dialog_errors[i].errmess == err)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
397 signal_error (Qdialog_box_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
398 "Creating file-dialog-box",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
399 build_string
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
400 (common_dialog_errors[i].errname));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
403 signal_error (Qdialog_box_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
404 "Unknown common dialog box error???",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
405 make_int (err));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
406 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
407 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
408
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
409 return tstr_to_local_file_format (ofn.lpstrFile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
410 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
413 handle_question_dialog_box (struct frame *f, Lisp_Object keys)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 Lisp_Object_dynarr *dialog_items = Dynarr_new (Lisp_Object);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
416 unsigned_char_dynarr *template_ = Dynarr_new (unsigned_char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 unsigned int button_row_width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 unsigned int text_width, text_height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
419 Lisp_Object question = Qnil, title = Qnil;
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 int unbind_count = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 record_unwind_protect (free_dynarr_opaque_ptr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 make_opaque_ptr (dialog_items));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 record_unwind_protect (free_dynarr_opaque_ptr,
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
425 make_opaque_ptr (template_));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 /* A big NO NEED to GCPRO gui_items stored in the array: they are just
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
428 pointers into KEYS list, which is GC-protected by the caller */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
433 if (EQ (key, Q_question))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
434 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
435 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 question = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
437 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
438 else if (EQ (key, Q_title))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
440 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
441 title = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 else if (EQ (key, Q_buttons))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 Lisp_Object item_cons;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 /* Parse each item in the dialog into gui_item structs,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 and stuff a dynarr of these. Calculate button row width
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 in this loop too */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 EXTERNAL_LIST_LOOP (item_cons, value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 if (!NILP (XCAR (item_cons)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 Lisp_Object gitem =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 gui_parse_item_keywords (XCAR (item_cons));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 Dynarr_add (dialog_items, gitem);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 button_row_width += button_width (XGUI_ITEM (gitem)->name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 + X_BUTTON_MARGIN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 button_row_width -= X_BUTTON_MARGIN;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
465 invalid_constant ("Unrecognized question-dialog keyword", key);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 if (Dynarr_length (dialog_items) == 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
470 sferror ("Dialog descriptor provides no buttons", keys);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 if (NILP (question))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
473 sferror ("Dialog descriptor provides no question", keys);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 /* Determine the final width layout */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 Bufbyte *p = XSTRING_DATA (question);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 Charcount string_max = 0, this_length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 Emchar ch = charptr_emchar (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 INC_CHARPTR (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 if (ch == (Emchar)'\n' || ch == (Emchar)'\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 string_max = max (this_length, string_max);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 this_length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ++this_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 if (ch == (Emchar)'\0')
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 if (string_max * X_DLU_PER_CHAR > max (X_MAX_TEXT, button_row_width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 text_width = X_AVE_TEXT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 else if (string_max * X_DLU_PER_CHAR < X_MIN_TEXT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 text_width = X_MIN_TEXT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 text_width = string_max * X_DLU_PER_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 text_width = max (text_width, button_row_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 /* Now calculate the height for the text control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 Bufbyte *p = XSTRING_DATA (question);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 Charcount break_at = text_width / X_DLU_PER_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 Charcount char_pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 int num_lines = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 Emchar ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
513 while ((ch = charptr_emchar (p)) != (Emchar) '\0')
428
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 INC_CHARPTR (p);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 char_pos += ch != (Emchar) '\n';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517 if (ch == (Emchar) '\n' || char_pos == break_at)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 ++num_lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 char_pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 text_height = Y_TEXT_MARGIN + Y_DLU_PER_CHAR * num_lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 /* Ok, now we are ready to stuff the dialog template and lay out controls */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 DLGTEMPLATE dlg_tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 DLGITEMTEMPLATE item_tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 const unsigned int zeroes = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 const unsigned int ones = 0xFFFFFFFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 const WORD static_class_id = 0x0082;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 const WORD button_class_id = 0x0080;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 /* Create and stuff in DLGTEMPLATE header */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 dlg_tem.style = (DS_CENTER | DS_MODALFRAME | DS_SETFONT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 | WS_CAPTION | WS_POPUP | WS_VISIBLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 dlg_tem.dwExtendedStyle = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 dlg_tem.cdit = Dynarr_length (dialog_items) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 dlg_tem.x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 dlg_tem.y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 dlg_tem.cx = text_width + 2 * X_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 dlg_tem.cy = (Y_TEXT_FROM_EDGE + text_height + Y_TEXT_FROM_BUTTON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 + Y_BUTTON + Y_BUTTON_FROM_EDGE);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
546 Dynarr_add_many (template_, &dlg_tem, sizeof (dlg_tem));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 /* We want no menu and standard class */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
549 Dynarr_add_many (template_, &zeroes, 4);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 /* And the third is the dialog title. "XEmacs" unless one is supplied.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552 Note that the string must be in Unicode. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 if (NILP (title))
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
554 Dynarr_add_many (template_, L"XEmacs", 14);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
555 else
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
556 push_lisp_string_as_unicode (template_, title);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 /* We want standard dialog font */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
559 Dynarr_add_many (template_, L"\x08MS Shell Dlg", 28);
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 /* Next add text control. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 item_tem.style = WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 item_tem.dwExtendedStyle = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 item_tem.x = X_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 item_tem.y = Y_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 item_tem.cx = text_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 item_tem.cy = text_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 item_tem.id = 0xFFFF;
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 ALIGN_TEMPLATE;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
571 Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
428
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 /* Right after class id follows */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
574 Dynarr_add_many (template_, &ones, 2);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
575 Dynarr_add_many (template_, &static_class_id, sizeof (static_class_id));
428
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 /* Next thing to add is control text, as Unicode string */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
578 push_lisp_string_as_unicode (template_, question);
428
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 /* Specify 0 length creation data */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
581 Dynarr_add_many (template_, &zeroes, 2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 /* Now it's the button time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 item_tem.y = Y_TEXT_FROM_EDGE + text_height + Y_TEXT_FROM_BUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 item_tem.x = X_BUTTON_FROM_EDGE + (button_row_width < text_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 ? (text_width - button_row_width) / 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 : 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 item_tem.cy = Y_BUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 item_tem.dwExtendedStyle = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 for (i = 0; i < Dynarr_length (dialog_items); ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Lisp_Object* gui_item = Dynarr_atp (dialog_items, i);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
594 Lisp_Gui_Item *pgui_item = XGUI_ITEM (*gui_item);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 | (gui_item_active_p (*gui_item) ? 0 : WS_DISABLED));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 item_tem.cx = button_width (pgui_item->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 /* Item ids are indices into dialog_items plus offset, to avoid having
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 items by reserved ids (IDOK, IDCANCEL) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 item_tem.id = i + ID_ITEM_BIAS;
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 ALIGN_TEMPLATE;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
604 Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
428
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 /* Right after 0xFFFF and class id atom follows */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
607 Dynarr_add_many (template_, &ones, 2);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
608 Dynarr_add_many (template_, &button_class_id,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
609 sizeof (button_class_id));
428
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 /* Next thing to add is control text, as Unicode string */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
612 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
613 Lisp_Object ctext = pgui_item->name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
614 Emchar accel_unused;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
615 Bufbyte *trans = (Bufbyte *) alloca (2 * XSTRING_LENGTH (ctext) + 3);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616 Bytecount translen;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618 memcpy (trans, XSTRING_DATA (ctext), XSTRING_LENGTH (ctext) + 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 translen =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620 mswindows_translate_menu_or_dialog_item (trans,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 XSTRING_LENGTH (ctext),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 2 * XSTRING_LENGTH (ctext) + 3,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 &accel_unused,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 ctext);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
625 push_bufbyte_string_as_unicode (template_, trans, translen);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
626 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 /* Specify 0 length creation data. */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
629 Dynarr_add_many (template_, &zeroes, 2);
428
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 item_tem.x += item_tem.cx + X_BUTTON_SPACING;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 /* Now the Windows dialog structure is ready. We need to prepare a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 data structure for the new dialog, which will contain callbacks
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 and the frame for these callbacks. This structure has to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 GC-protected and thus it is put into a statically protected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639 list. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641 Lisp_Object dialog_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 int i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
643 struct mswindows_dialog_id *did =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644 alloc_lcrecord_type (struct mswindows_dialog_id,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645 &lrecord_mswindows_dialog_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
647 XSETMSWINDOWS_DIALOG_ID (dialog_data, did);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
648
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
649 did->frame = wrap_frame (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
650 did->callbacks = make_vector (Dynarr_length (dialog_items), Qunbound);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 for (i = 0; i < Dynarr_length (dialog_items); i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 XVECTOR_DATA (did->callbacks) [i] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
653 XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 /* Woof! Everything is ready. Pop pop pop in now! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656 did->hwnd =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657 CreateDialogIndirectParam (NULL,
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
658 (LPDLGTEMPLATE) Dynarr_atp (template_, 0),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 FRAME_MSWINDOWS_HANDLE (f), dialog_proc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 (LPARAM) LISP_TO_VOID (dialog_data));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 if (!did->hwnd)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 /* Something went wrong creating the dialog */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
663 signal_error (Qdialog_box_error, "Creating dialog", keys);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 Vdialog_data_list = Fcons (dialog_data, Vdialog_data_list);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 /* Cease protection and free dynarrays */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 unbind_to (unbind_count, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 return dialog_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 mswindows_make_dialog_box_internal (struct frame* f, Lisp_Object type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 if (EQ (type, Qfile))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 return handle_file_dialog_box (f, keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 else if (EQ (type, Qquestion))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 return handle_question_dialog_box (f, keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
681 else if (EQ (type, Qprint))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 return mswindows_handle_print_dialog_box (f, keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 else if (EQ (type, Qpage_setup))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 return mswindows_handle_page_setup_dialog_box (f, keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
686 signal_error (Qunimplemented, "Dialog box type", type);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 return Qnil;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 console_type_create_dialog_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 CONSOLE_HAS_METHOD (mswindows, make_dialog_box_internal);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 syms_of_dialog_mswindows (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699 INIT_LRECORD_IMPLEMENTATION (mswindows_dialog_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701 DEFKEYWORD (Q_initial_directory);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 DEFKEYWORD (Q_initial_filename);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 DEFKEYWORD (Q_filter_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704 DEFKEYWORD (Q_title);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 DEFKEYWORD (Q_allow_multi_select);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 DEFKEYWORD (Q_create_prompt_on_nonexistent);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 DEFKEYWORD (Q_overwrite_prompt);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 DEFKEYWORD (Q_file_must_exist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 DEFKEYWORD (Q_no_network_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710 DEFKEYWORD (Q_no_read_only_return);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
711
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
712 /* Errors */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
713 DEFERROR_STANDARD (Qdialog_box_error, Qgui_error);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 vars_of_dialog_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 Vpopup_frame_list = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720 staticpro (&Vpopup_frame_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 Vdialog_data_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 staticpro (&Vdialog_data_list);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725 DEFVAR_LISP ("default-file-dialog-filter-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 &Vdefault_file_dialog_filter_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
727 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 Vdefault_file_dialog_filter_alist =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
729 list5 (Fcons (build_string ("Text Files"), build_string ("*.txt")),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
730 Fcons (build_string ("C Files"), build_string ("*.c;*.h")),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731 Fcons (build_string ("Elisp Files"), build_string ("*.el")),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732 Fcons (build_string ("HTML Files"), build_string ("*.html;*.html")),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 Fcons (build_string ("All Files"), build_string ("*.*")));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 }