Mercurial > hg > xemacs-beta
annotate src/gui-msw.c @ 5554:a42e686a01bf
Automated merge with file:///Sources/xemacs-21.5-checked-out
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Wed, 24 Aug 2011 11:07:26 +0100 |
| parents | 308d34e9f07d |
| children | 56144c8593a8 |
| rev | line source |
|---|---|
| 428 | 1 /* mswindows GUI code. (menubars, scrollbars, toolbars, dialogs) |
| 2 Copyright (C) 1998 Andy Piper. | |
| 1204 | 3 Copyright (C) 2002 Ben Wing. |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 8 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
10 option) any later version. |
| 428 | 11 |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2367
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 19 |
| 20 /* Synched up with: Not in FSF. */ | |
| 21 | |
| 771 | 22 /* This file essentially Mule-ized (except perhaps some Unicode splitting). |
| 23 5-2000. */ | |
| 24 | |
| 428 | 25 #include <config.h> |
| 26 #include "lisp.h" | |
| 872 | 27 #include "console-msw-impl.h" |
| 442 | 28 #include "redisplay.h" |
| 428 | 29 #include "gui.h" |
| 442 | 30 #include "glyphs.h" |
| 872 | 31 #include "frame-impl.h" |
| 428 | 32 #include "elhash.h" |
| 442 | 33 #include "events.h" |
| 440 | 34 #include "buffer.h" |
| 428 | 35 |
| 36 /* | |
| 37 * Return value is Qt if we have dispatched the command, | |
| 38 * or Qnil if id has not been mapped to a callback. | |
| 39 * Window procedure may try other targets to route the | |
| 40 * command if we return nil | |
| 41 */ | |
| 42 Lisp_Object | |
| 2286 | 43 mswindows_handle_gui_wm_command (struct frame *f, HWND UNUSED (ctrl), |
| 44 LPARAM id) | |
| 428 | 45 { |
| 46 /* Try to map the command id through the proper hash table */ | |
| 442 | 47 Lisp_Object callback, callback_ex, image_instance, frame, event; |
| 48 | |
| 793 | 49 frame = wrap_frame (f); |
| 428 | 50 |
| 826 | 51 image_instance = Fgethash (make_int_verify (id), |
| 442 | 52 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f), Qnil); |
| 53 /* It is possible for a widget action to cause it to get out of sync | |
| 54 with its instantiator. Thus it is necessary to signal this | |
| 55 possibility. */ | |
| 56 if (IMAGE_INSTANCEP (image_instance)) | |
| 57 XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (image_instance) = 1; | |
| 58 callback = Fgethash (make_int (id), | |
| 59 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), Qnil); | |
| 60 callback_ex = Fgethash (make_int (id), | |
| 61 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f), Qnil); | |
| 428 | 62 |
| 442 | 63 if (!NILP (callback_ex) && !UNBOUNDP (callback_ex)) |
| 64 { | |
| 65 event = Fmake_event (Qnil, Qnil); | |
| 440 | 66 |
| 964 | 67 XSET_EVENT_TYPE (event, misc_user_event); |
| 68 XSET_EVENT_CHANNEL (event, frame); | |
| 69 XSET_EVENT_TIMESTAMP (event, GetTickCount()); | |
| 1204 | 70 XSET_EVENT_MISC_USER_FUNCTION (event, Qeval); |
| 71 XSET_EVENT_MISC_USER_OBJECT (event, | |
| 964 | 72 list4 (Qfuncall, callback_ex, image_instance, event)); |
| 442 | 73 } |
| 74 else if (NILP (callback) || UNBOUNDP (callback)) | |
| 75 return Qnil; | |
| 76 else | |
| 77 { | |
| 78 Lisp_Object fn, arg; | |
| 440 | 79 |
| 442 | 80 event = Fmake_event (Qnil, Qnil); |
| 440 | 81 |
| 442 | 82 get_gui_callback (callback, &fn, &arg); |
| 964 | 83 XSET_EVENT_TYPE (event, misc_user_event); |
| 84 XSET_EVENT_CHANNEL (event, frame); | |
| 85 XSET_EVENT_TIMESTAMP (event, GetTickCount()); | |
| 1204 | 86 XSET_EVENT_MISC_USER_FUNCTION (event, fn); |
| 87 XSET_EVENT_MISC_USER_OBJECT (event, arg); | |
| 442 | 88 } |
| 89 | |
| 90 mswindows_enqueue_dispatch_event (event); | |
| 91 /* The result of this evaluation could cause other instances to change so | |
| 92 enqueue an update callback to check this. */ | |
| 93 enqueue_magic_eval_event (update_widget_instances, frame); | |
| 94 return Qt; | |
| 440 | 95 } |
| 96 | |
| 1204 | 97 /* |
| 98 * Translate X accelerator syntax to win32 accelerator syntax. | |
| 99 * accel = (Ichar*) to receive the accelerator character | |
| 100 * or NULL to suppress accelerators in the menu or dialog item. | |
| 101 * | |
| 102 * %% is replaced with % | |
| 103 * if accel is NULL: | |
| 104 * %_ is removed. | |
| 105 * if accel is non-NULL: | |
| 106 * %_ is replaced with &. | |
| 107 * The accelerator character is passed back in *accel. | |
| 108 * (If there is no accelerator, it will be added on the first character.) | |
| 109 * | |
| 110 */ | |
| 111 | |
| 112 Lisp_Object | |
| 113 mswindows_translate_menu_or_dialog_item (Lisp_Object item, Ichar *accel) | |
| 114 { | |
| 115 Bytecount len = XSTRING_LENGTH (item); | |
| 2367 | 116 Ibyte *it = alloca_ibytes (2 * len + 42), *ptr = it; |
| 1204 | 117 |
| 118 memcpy (ptr, XSTRING_DATA (item), len + 1); | |
| 119 if (accel) | |
| 120 *accel = '\0'; | |
| 121 | |
| 122 /* Escape '&' as '&&' */ | |
| 123 | |
| 124 while ((ptr = (Ibyte *) memchr (ptr, '&', len - (ptr - it))) != NULL) | |
| 125 { | |
| 126 memmove (ptr + 1, ptr, (len - (ptr - it)) + 1); | |
| 127 len++; | |
| 128 ptr += 2; | |
| 129 } | |
| 130 | |
| 131 /* Replace XEmacs accelerator '%_' with Windows accelerator '&' | |
| 132 and `%%' with `%'. */ | |
| 133 ptr = it; | |
| 134 while ((ptr = (Ibyte *) memchr (ptr, '%', len - (ptr - it))) != NULL) | |
| 135 { | |
| 136 if (*(ptr + 1) == '_') | |
| 137 { | |
| 138 if (accel) | |
| 139 { | |
| 140 *ptr = '&'; | |
| 141 if (!*accel) | |
| 142 *accel = DOWNCASE (0, itext_ichar (ptr + 2)); | |
| 143 memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1); | |
| 144 len--; | |
| 145 } | |
| 146 else /* Skip accelerator */ | |
| 147 { | |
| 148 memmove (ptr, ptr + 2, len - (ptr - it + 2) + 1); | |
| 149 len -= 2; | |
| 150 } | |
| 151 } | |
| 152 else if (*(ptr + 1) == '%') | |
| 153 { | |
| 154 memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1); | |
| 155 len--; | |
| 156 ptr++; | |
| 157 } | |
| 158 else /* % on its own - shouldn't happen */ | |
| 159 ptr++; | |
| 160 } | |
| 161 | |
| 162 if (accel && !*accel) | |
| 163 { | |
| 164 /* Force a default accelerator */ | |
| 165 ptr = it; | |
| 166 memmove (ptr + 1, ptr, len + 1); | |
| 167 *accel = DOWNCASE (0, itext_ichar (ptr + 1)); | |
| 168 *ptr = '&'; | |
| 169 | |
| 170 len++; | |
| 171 } | |
| 172 | |
| 173 return make_string (it, len); | |
| 174 } | |
| 175 | |
| 440 | 176 void |
| 177 syms_of_gui_mswindows (void) | |
| 178 { | |
| 179 } |
