comparison src/dialog-msw.c @ 418:e804706bfb8c r21-2-17

Import from CVS: tag r21-2-17
author cvs
date Mon, 13 Aug 2007 11:23:13 +0200
parents 697ef44129c6
children
comparison
equal deleted inserted replaced
417:43a18b32d56e 418:e804706bfb8c
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)
198 } 192 }
199 193
200 static void 194 static void
201 mswindows_popup_dialog_box (struct frame* f, Lisp_Object desc) 195 mswindows_popup_dialog_box (struct frame* f, Lisp_Object desc)
202 { 196 {
203 struct_gui_item_dynarr *dialog_items = Dynarr_new (struct_gui_item); 197 Lisp_Object_dynarr *dialog_items = Dynarr_new (Lisp_Object);
204 unsigned_char_dynarr *template = Dynarr_new (unsigned_char); 198 unsigned_char_dynarr *template = Dynarr_new (unsigned_char);
205 unsigned int button_row_width = 0; 199 unsigned int button_row_width = 0;
206 unsigned int text_width, text_height; 200 unsigned int text_width, text_height;
207 201
208 int unbind_count = specpdl_depth (); 202 int unbind_count = specpdl_depth ();
221 215
222 EXTERNAL_LIST_LOOP (item_cons, XCDR (desc)) 216 EXTERNAL_LIST_LOOP (item_cons, XCDR (desc))
223 { 217 {
224 if (!NILP (XCAR (item_cons))) 218 if (!NILP (XCAR (item_cons)))
225 { 219 {
226 struct gui_item gitem; 220 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); 221 Dynarr_add (dialog_items, gitem);
230 button_row_width += button_width (gitem.name) + X_BUTTON_MARGIN; 222 button_row_width += button_width (XGUI_ITEM (gitem)->name)
223 + X_BUTTON_MARGIN;
231 } 224 }
232 } 225 }
233 if (Dynarr_length (dialog_items) == 0) 226 if (Dynarr_length (dialog_items) == 0)
234 signal_simple_error ("Dialog descriptor provides no active items", desc); 227 signal_simple_error ("Dialog descriptor provides no active items", desc);
235 button_row_width -= X_BUTTON_MARGIN; 228 button_row_width -= X_BUTTON_MARGIN;
348 item_tem.cy = Y_BUTTON; 341 item_tem.cy = Y_BUTTON;
349 item_tem.dwExtendedStyle = 0; 342 item_tem.dwExtendedStyle = 0;
350 343
351 for (i = 0; i < Dynarr_length (dialog_items); ++i) 344 for (i = 0; i < Dynarr_length (dialog_items); ++i)
352 { 345 {
353 struct gui_item *pgui_item = Dynarr_atp (dialog_items, i); 346 Lisp_Object* gui_item = Dynarr_atp (dialog_items, i);
347 struct Lisp_Gui_Item *pgui_item = XGUI_ITEM (*gui_item);
354 348
355 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON 349 item_tem.style = (WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON
356 | (gui_item_active_p (pgui_item) ? 0 : WS_DISABLED)); 350 | (gui_item_active_p (*gui_item) ? 0 : WS_DISABLED));
357 item_tem.cx = button_width (pgui_item->name); 351 item_tem.cx = button_width (pgui_item->name);
358 /* Item ids are indices into dialog_items plus offset, to avoid having 352 /* Item ids are indices into dialog_items plus offset, to avoid having
359 items by reserved ids (IDOK, IDCANCEL) */ 353 items by reserved ids (IDOK, IDCANCEL) */
360 item_tem.id = i + ID_ITEM_BIAS; 354 item_tem.id = i + ID_ITEM_BIAS;
361 355
388 382
389 XSETFRAME (frame, f); 383 XSETFRAME (frame, f);
390 vector = make_vector (Dynarr_length (dialog_items), Qunbound); 384 vector = make_vector (Dynarr_length (dialog_items), Qunbound);
391 dialog_data = Fcons (frame, vector); 385 dialog_data = Fcons (frame, vector);
392 for (i = 0; i < Dynarr_length (dialog_items); i++) 386 for (i = 0; i < Dynarr_length (dialog_items); i++)
393 XVECTOR_DATA (vector) [i] = Dynarr_atp (dialog_items, i)->callback; 387 XVECTOR_DATA (vector) [i] = XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback;
394 388
395 /* Woof! Everything is ready. Pop pop pop in now! */ 389 /* Woof! Everything is ready. Pop pop pop in now! */
396 if (!CreateDialogIndirectParam (NULL, 390 if (!CreateDialogIndirectParam (NULL,
397 (LPDLGTEMPLATE) Dynarr_atp (template, 0), 391 (LPDLGTEMPLATE) Dynarr_atp (template, 0),
398 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, 392 FRAME_MSWINDOWS_HANDLE (f), dialog_proc,