annotate src/gui-msw.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3ecd8885ac67
children abe6d1db359e
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 /* mswindows GUI code. (menubars, scrollbars, toolbars, dialogs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998 Andy Piper.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 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
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 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
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "redisplay.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "console-msw.h"
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
30 #include "buffer.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * Return value is Qt if we have dispatched the command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 * or Qnil if id has not been mapped to a callback.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 * Window procedure may try other targets to route the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 * command if we return nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
39 mswindows_handle_gui_wm_command (struct frame* f, HWND ctrl, DWORD id)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 /* Try to map the command id through the proper hash table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 Lisp_Object data, fn, arg, frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
44 /* #### make_int should assert that --kkm */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
45 assert (XINT (make_int (id)) == id);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
46
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 data = Fgethash (make_int (id),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 if (NILP (data) || UNBOUNDP (data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 MARK_SUBWINDOWS_STATE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 /* Ok, this is our one. Enqueue it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 get_gui_callback (data, &fn, &arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 mswindows_enqueue_misc_user_event (frame, fn, arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
62 DEFUN ("mswindows-shell-execute", Fmswindows_shell_execute, 2, 4, 0, /*
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
63 Get Windows to perform OPERATION on DOCUMENT.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
64 This is a wrapper around the ShellExecute system function, which
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
65 invokes the application registered to handle OPERATION for DOCUMENT.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
66 OPERATION is typically \"open\", \"print\" or \"explore\" (but can be
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
67 nil for the default action), and DOCUMENT is typically the name of a
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
68 document file or URL, but can also be a program executable to run or
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
69 a directory to open in the Windows Explorer.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
70
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
71 If DOCUMENT is a program executable, PARAMETERS can be a string
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
72 containing command line parameters, but otherwise should be nil.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
73
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
74 SHOW-FLAG can be used to control whether the invoked application is hidden
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
75 or minimized. If SHOW-FLAG is nil, the application is displayed normally,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
76 otherwise it is an integer representing a ShowWindow flag:
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
77
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
78 0 - start hidden
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
79 1 - start normally
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
80 3 - start maximized
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
81 6 - start minimized
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
82 */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
83 (operation, document, parameters, show_flag))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
84 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
85 Lisp_Object current_dir;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
86
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
87 CHECK_STRING (document);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
88
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
89 /* Encode filename and current directory. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
90 current_dir = current_buffer->directory;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
91 if ((int) ShellExecute (NULL,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
92 (STRINGP (operation) ?
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
93 XSTRING (operation)->data : NULL),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
94 XSTRING (document)->data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
95 (STRINGP (parameters) ?
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
96 XSTRING (parameters)->data : NULL),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
97 XSTRING (current_dir)->data,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
98 (INTP (show_flag) ?
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
99 XINT (show_flag) : SW_SHOWDEFAULT))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
100 > 32)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
101 return Qt;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
102
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
103 error ("ShellExecute failed");
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
104 return Qnil;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
105 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
106
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
107 void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
108 syms_of_gui_mswindows (void)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
109 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
110 DEFSUBR (Fmswindows_shell_execute);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
111 }