comparison src/dialog-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children de805c49cfc1
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
158 Extbyte *mbcs_string; 158 Extbyte *mbcs_string;
159 Charcount length = XSTRING_CHAR_LENGTH (string); 159 Charcount length = XSTRING_CHAR_LENGTH (string);
160 LPWSTR uni_string; 160 LPWSTR uni_string;
161 161
162 TO_EXTERNAL_FORMAT (LISP_STRING, string, 162 TO_EXTERNAL_FORMAT (LISP_STRING, string,
163 C_STRING_ALLOCA, mbcs_string,
164 Qnative);
165 uni_string = alloca_array (WCHAR, length + 1);
166 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
167 uni_string, sizeof(WCHAR) * (length + 1));
168 Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length);
169 }
170
171 /* Helper function which converts the supplied string STRING into Unicode and
172 pushes it at the end of DYNARR */
173 static void
174 push_bufbyte_string_as_unicode (unsigned_char_dynarr* dynarr, Bufbyte *string,
175 Bytecount len)
176 {
177 Extbyte *mbcs_string;
178 Charcount length = bytecount_to_charcount (string, len);
179 LPWSTR uni_string;
180
181 TO_EXTERNAL_FORMAT (C_STRING, string,
163 C_STRING_ALLOCA, mbcs_string, 182 C_STRING_ALLOCA, mbcs_string,
164 Qnative); 183 Qnative);
165 uni_string = alloca_array (WCHAR, length + 1); 184 uni_string = alloca_array (WCHAR, length + 1);
166 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1, 185 length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
167 uni_string, sizeof(WCHAR) * (length + 1)); 186 uni_string, sizeof(WCHAR) * (length + 1));
360 /* Right after 0xFFFF and class id atom follows */ 379 /* Right after 0xFFFF and class id atom follows */
361 Dynarr_add_many (template, &ones, 2); 380 Dynarr_add_many (template, &ones, 2);
362 Dynarr_add_many (template, &button_class_id, sizeof (button_class_id)); 381 Dynarr_add_many (template, &button_class_id, sizeof (button_class_id));
363 382
364 /* Next thing to add is control text, as Unicode string */ 383 /* Next thing to add is control text, as Unicode string */
365 push_lisp_string_as_unicode (template, pgui_item->name); 384 {
385 Lisp_Object ctext = pgui_item->name;
386 Emchar accel_unused;
387 Bufbyte *trans = (Bufbyte *) alloca (2 * XSTRING_LENGTH (ctext) + 3);
388 Bytecount translen;
389
390 memcpy (trans, XSTRING_DATA (ctext), XSTRING_LENGTH (ctext) + 1);
391 translen =
392 msw_translate_menu_or_dialog_item (trans,
393 XSTRING_LENGTH (ctext),
394 2 * XSTRING_LENGTH (ctext) + 3,
395 &accel_unused,
396 ctext);
397 push_bufbyte_string_as_unicode (template, trans, translen);
398 }
366 399
367 /* Specify 0 length creation data. */ 400 /* Specify 0 length creation data. */
368 Dynarr_add_many (template, &zeroes, 2); 401 Dynarr_add_many (template, &zeroes, 2);
369 402
370 item_tem.x += item_tem.cx + X_BUTTON_SPACING; 403 item_tem.x += item_tem.cx + X_BUTTON_SPACING;
383 416
384 XSETFRAME (frame, f); 417 XSETFRAME (frame, f);
385 vector = make_vector (Dynarr_length (dialog_items), Qunbound); 418 vector = make_vector (Dynarr_length (dialog_items), Qunbound);
386 dialog_data = Fcons (frame, vector); 419 dialog_data = Fcons (frame, vector);
387 for (i = 0; i < Dynarr_length (dialog_items); i++) 420 for (i = 0; i < Dynarr_length (dialog_items); i++)
388 XVECTOR_DATA (vector) [i] = XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback; 421 XVECTOR_DATA (vector) [i] =
422 XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback;
389 423
390 /* Woof! Everything is ready. Pop pop pop in now! */ 424 /* Woof! Everything is ready. Pop pop pop in now! */
391 if (!CreateDialogIndirectParam (NULL, 425 if (!CreateDialogIndirectParam (NULL,
392 (LPDLGTEMPLATE) Dynarr_atp (template, 0), 426 (LPDLGTEMPLATE) Dynarr_atp (template, 0),
393 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, 427 FRAME_MSWINDOWS_HANDLE (f), dialog_proc,