annotate src/dialog-msw.c @ 826:6728e641994e

[xemacs-hg @ 2002-05-05 11:30:15 by ben] syntax cache, 8-bit-format, lots of code cleanup README.packages: Update info about --package-path. i.c: Create an inheritable event and pass it on to XEmacs, so that ^C can be handled properly. Intercept ^C and signal the event. "Stop Build" in VC++ now works. bytecomp-runtime.el: Doc string changes. compat.el: Some attempts to redo this to make it truly useful and fix the "multiple versions interacting with each other" problem. Not yet done. Currently doesn't work. files.el: Use with-obsolete-variable to avoid warnings in new revert-buffer code. xemacs.mak: Split up CFLAGS into a version without flags specifying the C library. The problem seems to be that minitar depends on zlib, which depends specifically on libc.lib, not on any of the other C libraries. Unless you compile with libc.lib, you get errors -- specifically, no _errno in the other libraries, which must make it something other than an int. (#### But this doesn't seem to obtain in XEmacs, which also uses zlib, and can be linked with any of the C libraries. Maybe zlib is used differently and doesn't need errno, or maybe XEmacs provides an int errno; ... I don't understand. Makefile.in.in: Fix so that packages are around when testing. abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.h, console-stream.c, console-x.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dialog-msw.c, dialog-x.c, dired-msw.c, dired.c, doc.c, doprnt.c, dumper.c, editfns.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, events.h, extents.c, extents.h, faces.c, file-coding.c, file-coding.h, fileio.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, frame.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-msw.h, glyphs-x.c, glyphs.c, glyphs.h, gui-msw.c, gui-x.c, gui.h, gutter.h, hash.h, indent.c, insdel.c, intl-win32.c, intl.c, keymap.c, 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-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, nas.c, objects-msw.c, objects-x.c, opaque.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, process.h, profile.c, rangetab.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, regex.h, scrollbar-msw.c, search.c, select-x.c, specifier.c, specifier.h, symbols.c, symsinit.h, syntax.c, syntax.h, syswindows.h, tests.c, text.c, text.h, tooltalk.c, ui-byhand.c, ui-gtk.c, unicode.c, win32.c, window.c: Another big Ben patch. -- FUNCTIONALITY CHANGES: add partial support for 8-bit-fixed, 16-bit-fixed, and 32-bit-fixed formats. not quite done yet. (in particular, needs functions to actually convert the buffer.) NOTE: lots of changes to regex.c here. also, many new *_fmt() inline funs that take an Internal_Format argument. redo syntax cache code. make the cache per-buffer; keep the cache valid across calls to functions that use it. also keep it valid across insertions/deletions and extent changes, as much as is possible. eliminate the junky regex-reentrancy code by passing in the relevant lisp info to the regex routines as local vars. add general mechanism in extents code for signalling extent changes. fix numerous problems with the case-table implementation; yoshiki never properly transferred many algorithms from old-style to new-style case tables. redo char tables to support a default argument, so that mapping only occurs over changed args. change many chartab functions to accept Lisp_Object instead of Lisp_Char_Table *. comment out the code in font-lock.c by default, because font-lock.el no longer uses it. we should consider eliminating it entirely. Don't output bell as ^G in console-stream when not a TTY. add -mswindows-termination-handle to interface with i.c, so we can properly kill a build. add more error-checking to buffer/string macros. add some additional buffer_or_string_() funs. -- INTERFACE CHANGES AFFECTING MORE CODE: switch the arguments of write_c_string and friends to be consistent with write_fmt_string, which must have printcharfun first. change BI_* macros to BYTE_* for increased clarity; similarly for bi_* local vars. change VOID_TO_LISP to be a one-argument function. eliminate no-longer-needed CVOID_TO_LISP. -- char/string macro changes: rename MAKE_CHAR() to make_emchar() for slightly less confusion with make_char(). (The former generates an Emchar, the latter a Lisp object. Conceivably we should rename make_char() -> wrap_char() and similarly for make_int(), make_float().) Similar changes for other *CHAR* macros -- we now consistently use names with `emchar' whenever we are working with Emchars. Any remaining name with just `char' always refers to a Lisp object. rename macros with XSTRING_* to string_* except for those that reference actual fields in the Lisp_String object, following conventions used elsewhere. rename set_string_{data,length} macros (the only ones to work with a Lisp_String_* instead of a Lisp_Object) to set_lispstringp_* to make the difference clear. try to be consistent about caps vs. lowercase in macro/inline-fun names for chars and such, which wasn't the case before. we now reserve caps either for XFOO_ macros that reference object fields (e.g. XSTRING_DATA) or for things that have non-function semantics, e.g. directly modifying an arg (BREAKUP_EMCHAR) or evaluating an arg (any arg) more than once. otherwise, use lowercase. here is a summary of most of the macros/inline funs changed by all of the above changes: BYTE_*_P -> byte_*_p XSTRING_BYTE -> string_byte set_string_data/length -> set_lispstringp_data/length XSTRING_CHAR_LENGTH -> string_char_length XSTRING_CHAR -> string_emchar INTBYTE_FIRST_BYTE_P -> intbyte_first_byte_p INTBYTE_LEADING_BYTE_P -> intbyte_leading_byte_p charptr_copy_char -> charptr_copy_emchar LEADING_BYTE_* -> leading_byte_* CHAR_* -> EMCHAR_* *_CHAR_* -> *_EMCHAR_* *_CHAR -> *_EMCHAR CHARSET_BY_ -> charset_by_* BYTE_SHIFT_JIS* -> byte_shift_jis* BYTE_BIG5* -> byte_big5* REP_BYTES_BY_FIRST_BYTE -> rep_bytes_by_first_byte char_to_unicode -> emchar_to_unicode valid_char_p -> valid_emchar_p Change intbyte_strcmp -> qxestrcmp_c (duplicated functionality). -- INTERFACE CHANGES AFFECTING LESS CODE: use DECLARE_INLINE_HEADER in various places. remove '#ifdef emacs' from XEmacs-only files. eliminate CHAR_TABLE_VALUE(), which duplicated the functionality of get_char_table(). add BUFFER_TEXT_LOOP to simplify iterations over buffer text. define typedefs for signed and unsigned types of fixed sizes (INT_32_BIT, UINT_32_BIT, etc.). create ALIGN_FOR_TYPE as a higher-level interface onto ALIGN_SIZE; fix code to use it. add charptr_emchar_len to return the text length of the character pointed to by a ptr; use it in place of charcount_to_bytecount(..., 1). add emchar_len to return the text length of a given character. add types Bytexpos and Charxpos to generalize Bytebpos/Bytecount and Charbpos/Charcount, in code (particularly, the extents code and redisplay code) that works with either kind of index. rename redisplay struct params with names such as `charbpos' to e.g. `charpos' when they are e.g. a Charxpos, not a Charbpos. eliminate xxDEFUN in place of DEFUN; no longer necessary with changes awhile back to doc.c. split up big ugly combined list of EXFUNs in lisp.h on a file-by-file basis, since other prototypes are similarly split. rewrite some "*_UNSAFE" macros as inline funs and eliminate the _UNSAFE suffix. move most string code from lisp.h to text.h; the string code and text.h code is now intertwined in such a fashion that they need to be in the same place and partially interleaved. (you can't create forward references for inline funs) automated/lisp-tests.el, automated/symbol-tests.el, automated/test-harness.el: Fix test harness to output FAIL messages to stderr when in batch mode. Fix up some problems in lisp-tests/symbol-tests that were causing spurious failures.
author ben
date Sun, 05 May 2002 11:33:57 +0000
parents 6504113e7c2d
children 2b6fa2618f76
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>
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
3 Copyright (C) 2000, 2001, 2002 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
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
24 /* This file essentially Mule-ized (except perhaps some Unicode splitting).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
25 5-2000. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
26
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* Author:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 Initially written by kkm, May 1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 */
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 <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "opaque.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
40 #include "sysfile.h"
442
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 Lisp_Object Qdialog_box_error;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
43
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
44 static Lisp_Object Q_initial_directory;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 static Lisp_Object Q_initial_filename;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 static Lisp_Object Q_filter_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 static Lisp_Object Q_allow_multi_select;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 static Lisp_Object Q_create_prompt_on_nonexistent;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 static Lisp_Object Q_overwrite_prompt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 static Lisp_Object Q_file_must_exist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 static Lisp_Object Q_no_network_button;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
52 static Lisp_Object Q_no_read_only_return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
53
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 /* List containing all dialog data structures of currently popped up
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 dialogs. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 static Lisp_Object Vdialog_data_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
58 /* List of popup frames wanting keyboard traversal handled */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
59 static Lisp_Object Vpopup_frame_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
60
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
61 Lisp_Object Vdefault_file_dialog_filter_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
62
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 /* DLUs per character metrics */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #define X_DLU_PER_CHAR 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #define Y_DLU_PER_CHAR 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
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 Button metrics
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 --------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 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
71 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
72 8 DLU per button plus 4 DLU per character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 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
74 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
75 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
76 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
77 buttons is 7 DLU.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #define X_MIN_BUTTON 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define X_BUTTON_MARGIN 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define Y_BUTTON 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define X_BUTTON_SPACING 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define X_BUTTON_FROM_EDGE 6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define Y_BUTTON_FROM_EDGE 7
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Text field metrics
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 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
91 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
92 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
93 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
94 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
95 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
96 next line. Each character in the text is considered 4 DLU wide.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #define X_MIN_TEXT 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #define X_AVE_TEXT 200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #define X_MAX_TEXT 300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #define X_TEXT_FROM_EDGE X_BUTTON_FROM_EDGE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #define Y_TEXT_FROM_EDGE 11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 #define Y_TEXT_MARGIN 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #define Y_TEXT_FROM_BUTTON 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #define X_MIN_TEXT_CHAR (X_MIN_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #define X_AVE_TEXT_CHAR (X_AVE_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #define X_MAX_TEXT_CHAR (X_MAX_TEXT / X_DLU_PER_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
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 Layout algorithm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 ----------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 First we calculate the minimum width of the button row, excluding "from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 edge" distances. Note that the static control text can be narrower than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 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
117 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
118 done). Let WBR denote the width of the button row.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 Next, the width of the static field is determined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 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
122 control is the same as the width of the longest line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 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
124 the control is set to X_MIN_TEXT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 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
126 happen.
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 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
129 latter is centered across the dialog, by giving it extra edge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 margins. Otherwise, minimal margins are given to the button row.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 #define ID_ITEM_BIAS 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 mswindows_register_popup_frame (Lisp_Object frame)
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 Vpopup_frame_list = Fcons (frame, Vpopup_frame_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 mswindows_unregister_popup_frame (Lisp_Object frame)
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 Vpopup_frame_list = delq_no_quit (frame, Vpopup_frame_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 /* Dispatch message to any dialog boxes. Return non-zero if dispatched. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 mswindows_is_dialog_msg (MSG *msg)
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 LIST_LOOP_2 (data, Vdialog_data_list)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
153 if (qxeIsDialogMessage (XMSWINDOWS_DIALOG_ID (data)->hwnd, msg))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 return 1;
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
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 LIST_LOOP_2 (popup, Vpopup_frame_list)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 HWND hwnd = FRAME_MSWINDOWS_HANDLE (XFRAME (popup));
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
161 /* This is a windows feature that allows dialog type
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
162 processing to be applied to standard windows containing
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
163 controls. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
164 if (qxeIsDialogMessage (hwnd, msg))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 }
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 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 mark_mswindows_dialog_id (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 struct mswindows_dialog_id *data = XMSWINDOWS_DIALOG_ID (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176 return data->callbacks;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
179 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
180 mark_mswindows_dialog_id,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 593
diff changeset
181 internal_object_printer, 0, 0, 0, 0,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182 struct mswindows_dialog_id);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 /* Dialog procedure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 static BOOL CALLBACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 dialog_proc (HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param)
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 switch (msg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 case WM_INITDIALOG:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
191 qxeSetWindowLong (hwnd, DWL_USER, l_param);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 break;
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 case WM_DESTROY:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 Lisp_Object data;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
197 data = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, DWL_USER));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 Vdialog_data_list = delq_no_quit (data, Vdialog_data_list);
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 break;
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 case WM_COMMAND:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 Lisp_Object fn, arg, data;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 struct mswindows_dialog_id *did;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
207 data = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, DWL_USER));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 did = XMSWINDOWS_DIALOG_ID (data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
209 if (w_param != IDCANCEL) /* user pressed escape */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
210 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
211 assert (w_param >= ID_ITEM_BIAS
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
212 && (EMACS_INT) w_param
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
213 < XVECTOR_LENGTH (did->callbacks) + ID_ITEM_BIAS);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
214
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
215 get_gui_callback (XVECTOR_DATA (did->callbacks)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216 [w_param - ID_ITEM_BIAS],
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217 &fn, &arg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 mswindows_enqueue_misc_user_event (did->frame, fn, arg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221 mswindows_enqueue_misc_user_event (did->frame, Qrun_hooks,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222 Qmenu_no_selection_hook);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223 /* #### need to error-protect! will do so when i merge in
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
224 my stderr-proc ws */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 va_run_hook_with_args (Qdelete_dialog_box_hook, 1, data);
428
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 DestroyWindow (hwnd);
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 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 return FALSE;
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 return TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 /* Helper function which converts the supplied string STRING into Unicode and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 pushes it at the end of DYNARR */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
240 push_lisp_string_as_unicode (unsigned_char_dynarr *dynarr, Lisp_Object string)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
242 int length;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
243 Extbyte *uni_string;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
245 TO_EXTERNAL_FORMAT (LISP_STRING, string,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
246 ALLOCA, (uni_string, length),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
247 Qmswindows_unicode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
248 Dynarr_add_many (dynarr, uni_string, length);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
249 Dynarr_add (dynarr, '\0');
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
250 Dynarr_add (dynarr, '\0');
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
251 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 /* Given button TEXT, return button width in DLU */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
254 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 button_width (Lisp_Object text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
257 /* !!#### do Japanese chars count as two? */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
258 int width =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
259 X_DLU_PER_CHAR *
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
260 intbyte_string_displayed_columns (XSTRING_DATA (text),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
261 XSTRING_LENGTH (text));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return max (X_MIN_BUTTON, width);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* Unwind protection routine frees a dynarr opaqued into arg */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 free_dynarr_opaque_ptr (Lisp_Object arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 Dynarr_free (get_opaque_ptr (arg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 return arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
273 /* Unwind protection decrements dialog count */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
274 static Lisp_Object
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
275 dialog_popped_down (Lisp_Object arg)
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
276 {
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
277 popup_up_p--;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
278 return Qnil;
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
279 }
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
280
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
282 #define ALIGN_TEMPLATE \
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
283 { \
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
284 int slippage = Dynarr_length (template_) & 3; \
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
285 if (slippage) \
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
286 Dynarr_add_many (template_, &zeroes, slippage); \
428
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
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
289 static struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
290 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
291 DWORD errmess;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
292 Char_ASCII *errname;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 } common_dialog_errors[] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
295 { CDERR_DIALOGFAILURE, "CDERR_DIALOGFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 { CDERR_FINDRESFAILURE, "CDERR_FINDRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
297 { CDERR_INITIALIZATION, "CDERR_INITIALIZATION" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
298 { CDERR_LOADRESFAILURE, "CDERR_LOADRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
299 { CDERR_LOADSTRFAILURE, "CDERR_LOADSTRFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
300 { CDERR_LOCKRESFAILURE, "CDERR_LOCKRESFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 { CDERR_MEMALLOCFAILURE, "CDERR_MEMALLOCFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
302 { CDERR_MEMLOCKFAILURE, "CDERR_MEMLOCKFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 { CDERR_NOHINSTANCE, "CDERR_NOHINSTANCE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304 { CDERR_NOHOOK, "CDERR_NOHOOK" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 { CDERR_NOTEMPLATE, "CDERR_NOTEMPLATE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 { CDERR_REGISTERMSGFAIL, "CDERR_REGISTERMSGFAIL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 { CDERR_STRUCTSIZE, "CDERR_STRUCTSIZE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 { PDERR_CREATEICFAILURE, "PDERR_CREATEICFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
309 { PDERR_DEFAULTDIFFERENT, "PDERR_DEFAULTDIFFERENT" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
310 { PDERR_DNDMMISMATCH, "PDERR_DNDMMISMATCH" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311 { PDERR_GETDEVMODEFAIL, "PDERR_GETDEVMODEFAIL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 { PDERR_INITFAILURE, "PDERR_INITFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 { PDERR_LOADDRVFAILURE, "PDERR_LOADDRVFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 { PDERR_NODEFAULTPRN, "PDERR_NODEFAULTPRN" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 { PDERR_NODEVICES, "PDERR_NODEVICES" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 { PDERR_PARSEFAILURE, "PDERR_PARSEFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 { PDERR_PRINTERNOTFOUND, "PDERR_PRINTERNOTFOUND" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 { PDERR_RETDEFFAILURE, "PDERR_RETDEFFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319 { PDERR_SETUPFAILURE, "PDERR_SETUPFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 { CFERR_MAXLESSTHANMIN, "CFERR_MAXLESSTHANMIN" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 { CFERR_NOFONTS, "CFERR_NOFONTS" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 { FNERR_BUFFERTOOSMALL, "FNERR_BUFFERTOOSMALL" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 { FNERR_INVALIDFILENAME, "FNERR_INVALIDFILENAME" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 { FNERR_SUBCLASSFAILURE, "FNERR_SUBCLASSFAILURE" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
325 { FRERR_BUFFERLENGTHZERO, "FRERR_BUFFERLENGTHZERO" },
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
326 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
328 struct param_data
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
329 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
330 Extbyte *fname;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
331 Extbyte *unknown_fname;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
332 int validate;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
333 };
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
334
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
335 static int
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
336 CALLBACK handle_directory_proc (HWND hwnd, UINT msg,
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
337 LPARAM lParam, LPARAM lpData)
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
338 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
339 Extbyte szDir[MAX_PATH * MAX_XETCHAR_SIZE];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
340 struct param_data *pd = (struct param_data *) lpData;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
341
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
342 switch (msg)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
343 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
344 case BFFM_INITIALIZED:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
345 /* WParam is TRUE since you are passing a path.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
346 It would be FALSE if you were passing a pidl. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
347 qxeSendMessage (hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) pd->fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
348 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
349
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
350 case BFFM_SELCHANGED:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
351 /* Set the status window to the currently selected path. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
352 if (qxeSHGetPathFromIDList ((LPITEMIDLIST) lParam, szDir))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
353 qxeSendMessage (hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) szDir);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
354 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
355
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
356 case BFFM_VALIDATEFAILED:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
357 if (pd->validate)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
358 return TRUE;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
359 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
360 pd->unknown_fname = xetcsdup ((Extbyte *) lParam);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
361 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
362
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
363 default:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
364 break;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
365 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
366 return 0;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
367 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
368
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
369 static Lisp_Object
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
370 handle_directory_dialog_box (struct frame *f, Lisp_Object keys)
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
371 {
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
372 Lisp_Object ret = Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
373 BROWSEINFOW bi;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
374 LPITEMIDLIST pidl;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
375 LPMALLOC pMalloc;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
376 struct param_data pd;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
377
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
378 xzero (pd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
379 xzero (bi);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
380
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
381 bi.lParam = (LPARAM) &pd;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
382 bi.hwndOwner = FRAME_MSWINDOWS_HANDLE (f);
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
383 bi.pszDisplayName = 0;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
384 bi.pidlRoot = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
385 bi.ulFlags =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
386 BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
387 bi.lpfn = handle_directory_proc;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
388
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
389 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_string (""), Qnil),
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
390 pd.fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
391
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
392 {
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
393 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
394 {
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
395 if (EQ (key, Q_title))
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
396 {
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
397 CHECK_STRING (value);
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
398 LISP_STRING_TO_EXTERNAL (value, bi.lpszTitle, Qmswindows_tstr);
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
399 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
400 else if (EQ (key, Q_initial_directory))
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
401 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil),
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
402 pd.fname);
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
403 else if (EQ (key, Q_initial_filename))
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
404 ; /* do nothing */
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
405 else if (EQ (key, Q_file_must_exist))
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
406 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
407 if (!NILP (value))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
408 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
409 pd.validate = TRUE;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
410 bi.ulFlags |= BIF_VALIDATE;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
411 }
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
412 else
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
413 bi.ulFlags &= ~BIF_VALIDATE;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
414 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
415 else
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
416 invalid_constant ("Unrecognized directory-dialog keyword", key);
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
417 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
418 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
419
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
420 if (SHGetMalloc (&pMalloc) == NOERROR)
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
421 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
422 pidl = qxeSHBrowseForFolder (&bi);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
423 if (pidl)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
424 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
425 Extbyte *szDir = alloca_extbytes (MAX_PATH * MAX_XETCHAR_SIZE);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
426
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
427 if (qxeSHGetPathFromIDList (pidl, szDir))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
428 ret = tstr_to_local_file_format (szDir);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
429
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
430 XECOMCALL1 (pMalloc, Free, pidl);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
431 XECOMCALL0 (pMalloc, Release);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
432 return ret;
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
433 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
434 else if (pd.unknown_fname != 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
435 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
436 ret = tstr_to_local_file_format (pd.unknown_fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
437 xfree (pd.unknown_fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
438 }
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
439 else while (1)
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
440 signal_quit ();
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
441 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
442 else
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
443 signal_error (Qdialog_box_error,
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
444 "Unable to create folder browser",
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
445 make_int (0));
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
446 return ret;
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
447 }
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
448
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 handle_file_dialog_box (struct frame *f, Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
452 OPENFILENAMEW ofn;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
453 Extbyte fnbuf[8000];
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
454
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 xzero (ofn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 ofn.lStructSize = sizeof (ofn);
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
457 ofn.Flags = OFN_EXPLORER;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 ofn.hwndOwner = FRAME_MSWINDOWS_HANDLE (f);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
459 ofn.lpstrFile = (XELPTSTR) fnbuf;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 ofn.nMaxFile = sizeof (fnbuf) / XETCHAR_SIZE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461 xetcscpy (fnbuf, XETEXT (""));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
462
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_string (""), Qnil),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 ofn.lpstrInitialDir);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
465
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 if (EQ (key, Q_initial_filename))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 Extbyte *fnout;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
472
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 LOCAL_FILE_FORMAT_TO_TSTR (value, fnout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 xetcscpy (fnbuf, fnout);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 else if (EQ (key, Q_title))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 CHECK_STRING (value);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
480 LISP_STRING_TO_TSTR (value, ofn.lpstrTitle);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 else if (EQ (key, Q_initial_directory))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 ofn.lpstrInitialDir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 else if (EQ (key, Q_file_must_exist))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487 if (!NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488 ofn.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
489 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490 ofn.Flags &= ~(OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
492 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
493 invalid_constant ("Unrecognized file-dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
494 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
495 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
496
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
497 if (!qxeGetOpenFileName (&ofn))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
498 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
499 DWORD err = CommDlgExtendedError ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
500 if (!err)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
501 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
502 while (1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
503 signal_quit ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
505 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 int i;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
508
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509 for (i = 0; i < countof (common_dialog_errors); i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 if (common_dialog_errors[i].errmess == err)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
512 signal_error (Qdialog_box_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
513 "Creating file-dialog-box",
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
514 build_msg_string
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
515 (common_dialog_errors[i].errname));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
517
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
518 signal_error (Qdialog_box_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
519 "Unknown common dialog box error???",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
520 make_int (err));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
523
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
524 return tstr_to_local_file_format ((Extbyte *) ofn.lpstrFile);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
526
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 handle_question_dialog_box (struct frame *f, Lisp_Object keys)
428
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 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
531 unsigned_char_dynarr *template_ = Dynarr_new (unsigned_char);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
532 int button_row_width = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
533 int text_width, text_height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 Lisp_Object question = Qnil, title = Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
535
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 int unbind_count = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 record_unwind_protect (free_dynarr_opaque_ptr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 make_opaque_ptr (dialog_items));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 record_unwind_protect (free_dynarr_opaque_ptr,
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
540 make_opaque_ptr (template_));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
541
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 /* 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
543 pointers into KEYS list, which is GC-protected by the caller */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
544
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548 if (EQ (key, Q_question))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 question = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 else if (EQ (key, Q_title))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
555 CHECK_STRING (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556 title = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
558 else if (EQ (key, Q_buttons))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 Lisp_Object item_cons;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
561
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 /* Parse each item in the dialog into gui_item structs,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 and stuff a dynarr of these. Calculate button row width
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 in this loop too */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565 EXTERNAL_LIST_LOOP (item_cons, value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 if (!NILP (XCAR (item_cons)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 Lisp_Object gitem =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 gui_parse_item_keywords (XCAR (item_cons));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 Dynarr_add (dialog_items, gitem);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 button_row_width += button_width (XGUI_ITEM (gitem)->name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 + X_BUTTON_MARGIN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
576
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 button_row_width -= X_BUTTON_MARGIN;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
580 invalid_constant ("Unrecognized question-dialog keyword", key);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
583
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 if (Dynarr_length (dialog_items) == 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
585 sferror ("Dialog descriptor provides no buttons", keys);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
586
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
587 if (NILP (question))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
588 sferror ("Dialog descriptor provides no question", keys);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
589
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 /* Determine the final width layout */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
592 Intbyte *p = XSTRING_DATA (question);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Charcount string_max = 0, this_length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 while (1)
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 Emchar ch = charptr_emchar (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 INC_CHARPTR (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 if (ch == (Emchar)'\n' || ch == (Emchar)'\0')
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 string_max = max (this_length, string_max);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 this_length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 ++this_length;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
606
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 if (ch == (Emchar)'\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
610
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 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
612 text_width = X_AVE_TEXT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 else if (string_max * X_DLU_PER_CHAR < X_MIN_TEXT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 text_width = X_MIN_TEXT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 text_width = string_max * X_DLU_PER_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 text_width = max (text_width, button_row_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 /* Now calculate the height for the text control */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
622 Intbyte *p = XSTRING_DATA (question);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 Charcount break_at = text_width / X_DLU_PER_CHAR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 Charcount char_pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 int num_lines = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 Emchar ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 while ((ch = charptr_emchar (p)) != (Emchar) '\0')
428
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 INC_CHARPTR (p);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 char_pos += ch != (Emchar) '\n';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 if (ch == (Emchar) '\n' || char_pos == break_at)
428
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 ++num_lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 char_pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 }
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 text_height = Y_TEXT_MARGIN + Y_DLU_PER_CHAR * num_lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
640
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 /* 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
642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 DLGTEMPLATE dlg_tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 DLGITEMTEMPLATE item_tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 const unsigned int zeroes = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 const unsigned int ones = 0xFFFFFFFF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 const WORD static_class_id = 0x0082;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 const WORD button_class_id = 0x0080;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
650
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 /* Create and stuff in DLGTEMPLATE header */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
652 dlg_tem.style = (DS_CENTER | DS_MODALFRAME
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 | WS_CAPTION | WS_POPUP | WS_VISIBLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 dlg_tem.dwExtendedStyle = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 dlg_tem.cdit = Dynarr_length (dialog_items) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 dlg_tem.x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 dlg_tem.y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 dlg_tem.cx = text_width + 2 * X_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 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
660 + Y_BUTTON + Y_BUTTON_FROM_EDGE);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
661 Dynarr_add_many (template_, &dlg_tem, sizeof (dlg_tem));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
662
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 /* We want no menu and standard class */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
664 Dynarr_add_many (template_, &zeroes, 4);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
665
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666 /* 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
667 Note that the string must be in Unicode. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 if (NILP (title))
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
669 Dynarr_add_many (template_, L"XEmacs", 14);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 else
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
671 push_lisp_string_as_unicode (template_, title);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
672
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 /* Next add text control. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 item_tem.style = WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 item_tem.dwExtendedStyle = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 item_tem.x = X_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 item_tem.y = Y_TEXT_FROM_EDGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 item_tem.cx = text_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 item_tem.cy = text_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 item_tem.id = 0xFFFF;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
681
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 ALIGN_TEMPLATE;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
683 Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
684
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 /* Right after class id follows */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
686 Dynarr_add_many (template_, &ones, 2);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
687 Dynarr_add_many (template_, &static_class_id, sizeof (static_class_id));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
688
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 /* 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
690 push_lisp_string_as_unicode (template_, question);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
691
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 /* Specify 0 length creation data */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
693 Dynarr_add_many (template_, &zeroes, 2);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
694
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 /* Now it's the button time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 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
697 item_tem.x = X_BUTTON_FROM_EDGE + (button_row_width < text_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 ? (text_width - button_row_width) / 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 : 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 item_tem.cy = Y_BUTTON;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 item_tem.dwExtendedStyle = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
702
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 for (i = 0; i < Dynarr_length (dialog_items); ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
705 Lisp_Object *gui_item = Dynarr_atp (dialog_items, i);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
706 Lisp_Gui_Item *pgui_item = XGUI_ITEM (*gui_item);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
707
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 | (gui_item_active_p (*gui_item) ? 0 : WS_DISABLED));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 item_tem.cx = button_width (pgui_item->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 /* Item ids are indices into dialog_items plus offset, to avoid having
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 items by reserved ids (IDOK, IDCANCEL) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 item_tem.id = i + ID_ITEM_BIAS;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
714
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 ALIGN_TEMPLATE;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
716 Dynarr_add_many (template_, &item_tem, sizeof (item_tem));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
717
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 /* 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
719 Dynarr_add_many (template_, &ones, 2);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
720 Dynarr_add_many (template_, &button_class_id,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
721 sizeof (button_class_id));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
722
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 /* Next thing to add is control text, as Unicode string */
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 Emchar accel_unused;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
726
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
727 push_lisp_string_as_unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
728 (template_,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
729 mswindows_translate_menu_or_dialog_item
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
730 (pgui_item->name, &accel_unused));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
732
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 /* Specify 0 length creation data. */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 563
diff changeset
734 Dynarr_add_many (template_, &zeroes, 2);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
735
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 item_tem.x += item_tem.cx + X_BUTTON_SPACING;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
739
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 /* Now the Windows dialog structure is ready. We need to prepare a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 data structure for the new dialog, which will contain callbacks
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
742 and the frame for these callbacks. This structure has to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743 GC-protected and thus it is put into a statically protected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 list. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
746 Lisp_Object dialog_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 int i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
748 struct mswindows_dialog_id *did =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
749 alloc_lcrecord_type (struct mswindows_dialog_id,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750 &lrecord_mswindows_dialog_id);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
751
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
752 dialog_data = wrap_mswindows_dialog_id (did);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
753
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 did->frame = wrap_frame (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
755 did->callbacks = make_vector (Dynarr_length (dialog_items), Qunbound);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
756 for (i = 0; i < Dynarr_length (dialog_items); i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
757 XVECTOR_DATA (did->callbacks) [i] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758 XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 /* Woof! Everything is ready. Pop pop pop in now! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
761 did->hwnd =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
762 qxeCreateDialogIndirectParam (NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
763 (LPDLGTEMPLATE) Dynarr_atp (template_, 0),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
764 FRAME_MSWINDOWS_HANDLE (f), dialog_proc,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
765 (LPARAM) LISP_TO_VOID (dialog_data));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
766 if (!did->hwnd)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 /* Something went wrong creating the dialog */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
768 signal_error (Qdialog_box_error, "Creating dialog", keys);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
769
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 Vdialog_data_list = Fcons (dialog_data, Vdialog_data_list);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
771
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772 /* Cease protection and free dynarrays */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
773 unbind_to (unbind_count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
774 return dialog_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
776 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
778 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
779 mswindows_make_dialog_box_internal (struct frame* f, Lisp_Object type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
780 Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
781 {
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
782 int unbind_count = specpdl_depth ();
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
783 record_unwind_protect (dialog_popped_down, Qnil);
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
784 popup_up_p++;
819
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 793
diff changeset
785
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
786 if (EQ (type, Qfile))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
787 return unbind_to_1 (unbind_count, handle_file_dialog_box (f, keys));
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
788 else if (EQ (type, Qdirectory))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
789 return unbind_to_1 (unbind_count, handle_directory_dialog_box (f, keys));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 else if (EQ (type, Qquestion))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
791 return unbind_to_1 (unbind_count, handle_question_dialog_box (f, keys));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
792 else if (EQ (type, Qprint))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
793 return unbind_to_1 (unbind_count,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
794 mswindows_handle_print_dialog_box (f, keys));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795 else if (EQ (type, Qpage_setup))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
796 return unbind_to_1 (unbind_count,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
797 mswindows_handle_page_setup_dialog_box (f, keys));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
798 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
799 signal_error (Qunimplemented, "Dialog box type", type);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
800 return Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 console_type_create_dialog_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
806 CONSOLE_HAS_METHOD (mswindows, make_dialog_box_internal);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
807 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
808
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
809 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
810 syms_of_dialog_mswindows (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
811 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
812 INIT_LRECORD_IMPLEMENTATION (mswindows_dialog_id);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
813
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814 DEFKEYWORD (Q_initial_directory);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
815 DEFKEYWORD (Q_initial_filename);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816 DEFKEYWORD (Q_filter_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 DEFKEYWORD (Q_title);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
818 DEFKEYWORD (Q_allow_multi_select);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819 DEFKEYWORD (Q_create_prompt_on_nonexistent);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 DEFKEYWORD (Q_overwrite_prompt);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
821 DEFKEYWORD (Q_file_must_exist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
822 DEFKEYWORD (Q_no_network_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
823 DEFKEYWORD (Q_no_read_only_return);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
824
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825 /* Errors */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 510
diff changeset
826 DEFERROR_STANDARD (Qdialog_box_error, Qgui_error);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 vars_of_dialog_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
832 Vpopup_frame_list = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
833 staticpro (&Vpopup_frame_list);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
834
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 Vdialog_data_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 staticpro (&Vdialog_data_list);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
837
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
838 DEFVAR_LISP ("default-file-dialog-filter-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
839 &Vdefault_file_dialog_filter_alist /*
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
840 */ );
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
841 Vdefault_file_dialog_filter_alist =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
842 list5 (Fcons (build_msg_string ("Text Files"), build_string ("*.txt")),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
843 Fcons (build_msg_string ("C Files"), build_string ("*.c;*.h")),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
844 Fcons (build_msg_string ("Elisp Files"), build_string ("*.el")),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
845 Fcons (build_msg_string ("HTML Files"), build_string ("*.html;*.html")),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 707
diff changeset
846 Fcons (build_msg_string ("All Files"), build_string ("*.*")));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 }