Mercurial > hg > xemacs-beta
comparison src/dialog-msw.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
108 margins. Otherwise, minimal margins are given to the button row. | 108 margins. Otherwise, minimal margins are given to the button row. |
109 */ | 109 */ |
110 | 110 |
111 #define ID_ITEM_BIAS 32 | 111 #define ID_ITEM_BIAS 32 |
112 | 112 |
113 typedef struct gui_item struct_gui_item; | |
114 typedef struct | |
115 { | |
116 Dynarr_declare (struct gui_item); | |
117 } struct_gui_item_dynarr; | |
118 | |
119 /* Dialog procedure */ | 113 /* Dialog procedure */ |
120 static BOOL CALLBACK | 114 static BOOL CALLBACK |
121 dialog_proc (HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) | 115 dialog_proc (HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) |
122 { | 116 { |
123 switch (msg) | 117 switch (msg) |
163 { | 157 { |
164 Extbyte *mbcs_string; | 158 Extbyte *mbcs_string; |
165 Charcount length = XSTRING_CHAR_LENGTH (string); | 159 Charcount length = XSTRING_CHAR_LENGTH (string); |
166 LPWSTR uni_string; | 160 LPWSTR uni_string; |
167 | 161 |
168 GET_C_CHARPTR_EXT_DATA_ALLOCA (XSTRING_DATA (string), | 162 TO_EXTERNAL_FORMAT (LISP_STRING, string, |
169 FORMAT_OS, mbcs_string); | 163 C_STRING_ALLOCA, mbcs_string, |
164 Qnative); | |
170 uni_string = alloca_array (WCHAR, length + 1); | 165 uni_string = alloca_array (WCHAR, length + 1); |
171 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1, | 166 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1, |
172 uni_string, sizeof(WCHAR) * (length + 1)); | 167 uni_string, sizeof(WCHAR) * (length + 1)); |
173 Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length); | 168 Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length); |
174 } | 169 } |
198 } | 193 } |
199 | 194 |
200 static void | 195 static void |
201 mswindows_popup_dialog_box (struct frame* f, Lisp_Object desc) | 196 mswindows_popup_dialog_box (struct frame* f, Lisp_Object desc) |
202 { | 197 { |
203 struct_gui_item_dynarr *dialog_items = Dynarr_new (struct_gui_item); | 198 Lisp_Object_dynarr *dialog_items = Dynarr_new (Lisp_Object); |
204 unsigned_char_dynarr *template = Dynarr_new (unsigned_char); | 199 unsigned_char_dynarr *template = Dynarr_new (unsigned_char); |
205 unsigned int button_row_width = 0; | 200 unsigned int button_row_width = 0; |
206 unsigned int text_width, text_height; | 201 unsigned int text_width, text_height; |
207 | 202 |
208 int unbind_count = specpdl_depth (); | 203 int unbind_count = specpdl_depth (); |
221 | 216 |
222 EXTERNAL_LIST_LOOP (item_cons, XCDR (desc)) | 217 EXTERNAL_LIST_LOOP (item_cons, XCDR (desc)) |
223 { | 218 { |
224 if (!NILP (XCAR (item_cons))) | 219 if (!NILP (XCAR (item_cons))) |
225 { | 220 { |
226 struct gui_item gitem; | 221 Lisp_Object gitem = gui_parse_item_keywords (XCAR (item_cons)); |
227 gui_item_init (&gitem); | |
228 gui_parse_item_keywords (XCAR (item_cons), &gitem); | |
229 Dynarr_add (dialog_items, gitem); | 222 Dynarr_add (dialog_items, gitem); |
230 button_row_width += button_width (gitem.name) + X_BUTTON_MARGIN; | 223 button_row_width += button_width (XGUI_ITEM (gitem)->name) |
224 + X_BUTTON_MARGIN; | |
231 } | 225 } |
232 } | 226 } |
233 if (Dynarr_length (dialog_items) == 0) | 227 if (Dynarr_length (dialog_items) == 0) |
234 signal_simple_error ("Dialog descriptor provides no active items", desc); | 228 signal_simple_error ("Dialog descriptor provides no active items", desc); |
235 button_row_width -= X_BUTTON_MARGIN; | 229 button_row_width -= X_BUTTON_MARGIN; |
348 item_tem.cy = Y_BUTTON; | 342 item_tem.cy = Y_BUTTON; |
349 item_tem.dwExtendedStyle = 0; | 343 item_tem.dwExtendedStyle = 0; |
350 | 344 |
351 for (i = 0; i < Dynarr_length (dialog_items); ++i) | 345 for (i = 0; i < Dynarr_length (dialog_items); ++i) |
352 { | 346 { |
353 struct gui_item *pgui_item = Dynarr_atp (dialog_items, i); | 347 Lisp_Object* gui_item = Dynarr_atp (dialog_items, i); |
348 Lisp_Gui_Item *pgui_item = XGUI_ITEM (*gui_item); | |
354 | 349 |
355 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | 350 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON |
356 | (gui_item_active_p (pgui_item) ? 0 : WS_DISABLED)); | 351 | (gui_item_active_p (*gui_item) ? 0 : WS_DISABLED)); |
357 item_tem.cx = button_width (pgui_item->name); | 352 item_tem.cx = button_width (pgui_item->name); |
358 /* Item ids are indices into dialog_items plus offset, to avoid having | 353 /* Item ids are indices into dialog_items plus offset, to avoid having |
359 items by reserved ids (IDOK, IDCANCEL) */ | 354 items by reserved ids (IDOK, IDCANCEL) */ |
360 item_tem.id = i + ID_ITEM_BIAS; | 355 item_tem.id = i + ID_ITEM_BIAS; |
361 | 356 |
388 | 383 |
389 XSETFRAME (frame, f); | 384 XSETFRAME (frame, f); |
390 vector = make_vector (Dynarr_length (dialog_items), Qunbound); | 385 vector = make_vector (Dynarr_length (dialog_items), Qunbound); |
391 dialog_data = Fcons (frame, vector); | 386 dialog_data = Fcons (frame, vector); |
392 for (i = 0; i < Dynarr_length (dialog_items); i++) | 387 for (i = 0; i < Dynarr_length (dialog_items); i++) |
393 XVECTOR_DATA (vector) [i] = Dynarr_atp (dialog_items, i)->callback; | 388 XVECTOR_DATA (vector) [i] = XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback; |
394 | 389 |
395 /* Woof! Everything is ready. Pop pop pop in now! */ | 390 /* Woof! Everything is ready. Pop pop pop in now! */ |
396 if (!CreateDialogIndirectParam (NULL, | 391 if (!CreateDialogIndirectParam (NULL, |
397 (LPDLGTEMPLATE) Dynarr_atp (template, 0), | 392 (LPDLGTEMPLATE) Dynarr_atp (template, 0), |
398 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, | 393 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, |