Mercurial > hg > xemacs-beta
comparison src/dialog-msw.c @ 5125:b5df3737028a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 01:58:04 -0600 |
parents | e0db3c197671 ae48681c47fa |
children | a9c41067dd88 |
comparison
equal
deleted
inserted
replaced
5124:623d57b7fbe8 | 5125:b5df3737028a |
---|---|
1 /* Implements elisp-programmable dialog boxes -- MS Windows interface. | 1 /* Implements elisp-programmable dialog boxes -- MS Windows interface. |
2 Copyright (C) 1998 Kirill M. Katsnelson <kkm@kis.ru> | 2 Copyright (C) 1998 Kirill M. Katsnelson <kkm@kis.ru> |
3 Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing. | 3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2010 Ben Wing. |
4 | 4 |
5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
6 | 6 |
7 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
200 break; | 200 break; |
201 | 201 |
202 case WM_DESTROY: | 202 case WM_DESTROY: |
203 { | 203 { |
204 Lisp_Object data; | 204 Lisp_Object data; |
205 data = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, DWL_USER)); | 205 data = GET_LISP_FROM_VOID ((void *) qxeGetWindowLong (hwnd, DWL_USER)); |
206 Vdialog_data_list = delq_no_quit (data, Vdialog_data_list); | 206 Vdialog_data_list = delq_no_quit (data, Vdialog_data_list); |
207 } | 207 } |
208 break; | 208 break; |
209 | 209 |
210 case WM_COMMAND: | 210 case WM_COMMAND: |
211 { | 211 { |
212 Lisp_Object fn, arg, data; | 212 Lisp_Object fn, arg, data; |
213 struct mswindows_dialog_id *did; | 213 struct mswindows_dialog_id *did; |
214 | 214 |
215 data = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, DWL_USER)); | 215 data = GET_LISP_FROM_VOID ((void *) qxeGetWindowLong (hwnd, DWL_USER)); |
216 did = XMSWINDOWS_DIALOG_ID (data); | 216 did = XMSWINDOWS_DIALOG_ID (data); |
217 if (w_param != IDCANCEL) /* user pressed escape */ | 217 if (w_param != IDCANCEL) /* user pressed escape */ |
218 { | 218 { |
219 assert (w_param >= ID_ITEM_BIAS | 219 assert (w_param >= ID_ITEM_BIAS |
220 && (EMACS_INT) w_param | 220 && (EMACS_INT) w_param |
247 push_lisp_string_as_unicode (unsigned_char_dynarr *dynarr, Lisp_Object string) | 247 push_lisp_string_as_unicode (unsigned_char_dynarr *dynarr, Lisp_Object string) |
248 { | 248 { |
249 int length; | 249 int length; |
250 Extbyte *uni_string; | 250 Extbyte *uni_string; |
251 | 251 |
252 TO_EXTERNAL_FORMAT (LISP_STRING, string, | 252 LISP_STRING_TO_SIZED_EXTERNAL (string, uni_string, length, |
253 ALLOCA, (uni_string, length), | 253 Qmswindows_unicode); |
254 Qmswindows_unicode); | |
255 Dynarr_add_many (dynarr, uni_string, length); | 254 Dynarr_add_many (dynarr, uni_string, length); |
256 Dynarr_add (dynarr, '\0'); | 255 Dynarr_add (dynarr, '\0'); |
257 Dynarr_add (dynarr, '\0'); | 256 Dynarr_add (dynarr, '\0'); |
258 } | 257 } |
259 | 258 |
294 } | 293 } |
295 | 294 |
296 static struct | 295 static struct |
297 { | 296 { |
298 DWORD errmess; | 297 DWORD errmess; |
299 Ascbyte *errname; | 298 const Ascbyte *errname; |
300 } common_dialog_errors[] = | 299 } common_dialog_errors[] = |
301 { | 300 { |
302 { CDERR_DIALOGFAILURE, "CDERR_DIALOGFAILURE" }, | 301 { CDERR_DIALOGFAILURE, "CDERR_DIALOGFAILURE" }, |
303 { CDERR_FINDRESFAILURE, "CDERR_FINDRESFAILURE" }, | 302 { CDERR_FINDRESFAILURE, "CDERR_FINDRESFAILURE" }, |
304 { CDERR_INITIALIZATION, "CDERR_INITIALIZATION" }, | 303 { CDERR_INITIALIZATION, "CDERR_INITIALIZATION" }, |
341 | 340 |
342 static int | 341 static int |
343 CALLBACK handle_directory_proc (HWND hwnd, UINT msg, | 342 CALLBACK handle_directory_proc (HWND hwnd, UINT msg, |
344 LPARAM lParam, LPARAM lpData) | 343 LPARAM lParam, LPARAM lpData) |
345 { | 344 { |
346 Extbyte szDir[PATH_MAX_EXTERNAL]; | 345 Extbyte szDir[PATH_MAX_TCHAR]; |
347 struct param_data *pd = (struct param_data *) lpData; | 346 struct param_data *pd = (struct param_data *) lpData; |
348 | 347 |
349 switch (msg) | 348 switch (msg) |
350 { | 349 { |
351 case BFFM_INITIALIZED: | 350 case BFFM_INITIALIZED: |
391 bi.pidlRoot = 0; | 390 bi.pidlRoot = 0; |
392 bi.ulFlags = | 391 bi.ulFlags = |
393 BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX | BIF_NEWDIALOGSTYLE; | 392 BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX | BIF_NEWDIALOGSTYLE; |
394 bi.lpfn = handle_directory_proc; | 393 bi.lpfn = handle_directory_proc; |
395 | 394 |
396 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_string (""), Qnil), | 395 LISP_LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_ascstring (""), Qnil), |
397 pd.fname); | 396 pd.fname); |
398 | 397 |
399 { | 398 { |
400 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys) | 399 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys) |
401 { | 400 { |
402 if (EQ (key, Q_title)) | 401 if (EQ (key, Q_title)) |
403 { | 402 { |
404 CHECK_STRING (value); | 403 CHECK_STRING (value); |
405 LISP_STRING_TO_EXTERNAL (value, bi.lpszTitle, Qmswindows_tstr); | 404 bi.lpszTitle = (XELPTSTR) LISP_STRING_TO_TSTR (value); |
406 } | 405 } |
407 else if (EQ (key, Q_initial_directory)) | 406 else if (EQ (key, Q_initial_directory)) |
408 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil), | 407 LISP_LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil), |
409 pd.fname); | 408 pd.fname); |
410 else if (EQ (key, Q_initial_filename)) | 409 else if (EQ (key, Q_initial_filename)) |
411 ; /* do nothing */ | 410 ; /* do nothing */ |
412 else if (EQ (key, Q_file_must_exist)) | 411 else if (EQ (key, Q_file_must_exist)) |
413 { | 412 { |
427 if (SHGetMalloc (&pMalloc) == NOERROR) | 426 if (SHGetMalloc (&pMalloc) == NOERROR) |
428 { | 427 { |
429 pidl = qxeSHBrowseForFolder (&bi); | 428 pidl = qxeSHBrowseForFolder (&bi); |
430 if (pidl) | 429 if (pidl) |
431 { | 430 { |
432 Extbyte *szDir = alloca_extbytes (PATH_MAX_EXTERNAL); | 431 Extbyte *szDir = alloca_extbytes (PATH_MAX_TCHAR); |
433 | 432 |
434 if (qxeSHGetPathFromIDList (pidl, szDir)) | 433 if (qxeSHGetPathFromIDList (pidl, szDir)) |
435 ret = tstr_to_local_file_format (szDir); | 434 ret = tstr_to_local_file_format (szDir); |
436 | 435 |
437 XECOMCALL1 (pMalloc, Free, pidl); | 436 XECOMCALL1 (pMalloc, Free, pidl); |
439 return ret; | 438 return ret; |
440 } | 439 } |
441 else if (pd.unknown_fname != 0) | 440 else if (pd.unknown_fname != 0) |
442 { | 441 { |
443 ret = tstr_to_local_file_format (pd.unknown_fname); | 442 ret = tstr_to_local_file_format (pd.unknown_fname); |
444 xfree (pd.unknown_fname, Extbyte *); | 443 xfree (pd.unknown_fname); |
445 } | 444 } |
446 else while (1) | 445 else while (1) |
447 signal_quit (); | 446 signal_quit (); |
448 } | 447 } |
449 else | 448 else |
465 ofn.hwndOwner = FRAME_MSWINDOWS_HANDLE (f); | 464 ofn.hwndOwner = FRAME_MSWINDOWS_HANDLE (f); |
466 ofn.lpstrFile = (XELPTSTR) fnbuf; | 465 ofn.lpstrFile = (XELPTSTR) fnbuf; |
467 ofn.nMaxFile = sizeof (fnbuf) / XETCHAR_SIZE; | 466 ofn.nMaxFile = sizeof (fnbuf) / XETCHAR_SIZE; |
468 qxetcscpy (fnbuf, XETEXT ("")); | 467 qxetcscpy (fnbuf, XETEXT ("")); |
469 | 468 |
470 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_string (""), Qnil), | 469 LISP_LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (build_ascstring (""), |
471 ofn.lpstrInitialDir); | 470 Qnil), |
471 ofn.lpstrInitialDir); | |
472 | 472 |
473 { | 473 { |
474 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys) | 474 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys) |
475 { | 475 { |
476 if (EQ (key, Q_initial_filename)) | 476 if (EQ (key, Q_initial_filename)) |
477 { | 477 { |
478 Extbyte *fnout; | 478 Extbyte *fnout; |
479 | 479 |
480 CHECK_STRING (value); | 480 CHECK_STRING (value); |
481 LOCAL_FILE_FORMAT_TO_TSTR (value, fnout); | 481 LISP_LOCAL_FILE_FORMAT_TO_TSTR (value, fnout); |
482 qxetcscpy (fnbuf, fnout); | 482 qxetcscpy (fnbuf, fnout); |
483 } | 483 } |
484 else if (EQ (key, Q_title)) | 484 else if (EQ (key, Q_title)) |
485 { | 485 { |
486 CHECK_STRING (value); | 486 CHECK_STRING (value); |
487 LISP_STRING_TO_TSTR (value, ofn.lpstrTitle); | 487 ofn.lpstrTitle = (XELPTSTR) LISP_STRING_TO_TSTR (value); |
488 } | 488 } |
489 else if (EQ (key, Q_initial_directory)) | 489 else if (EQ (key, Q_initial_directory)) |
490 LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil), | 490 LISP_LOCAL_FILE_FORMAT_TO_TSTR (Fexpand_file_name (value, Qnil), |
491 ofn.lpstrInitialDir); | 491 ofn.lpstrInitialDir); |
492 else if (EQ (key, Q_file_must_exist)) | 492 else if (EQ (key, Q_file_must_exist)) |
493 { | 493 { |
494 if (!NILP (value)) | 494 if (!NILP (value)) |
495 ofn.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; | 495 ofn.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; |
496 else | 496 else |
758 XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback; | 758 XGUI_ITEM (*Dynarr_atp (dialog_items, i))->callback; |
759 | 759 |
760 /* Woof! Everything is ready. Pop pop pop in now! */ | 760 /* Woof! Everything is ready. Pop pop pop in now! */ |
761 did->hwnd = | 761 did->hwnd = |
762 qxeCreateDialogIndirectParam (NULL, | 762 qxeCreateDialogIndirectParam (NULL, |
763 (LPDLGTEMPLATE) Dynarr_atp (template_, 0), | 763 (LPDLGTEMPLATE) Dynarr_begin (template_), |
764 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, | 764 FRAME_MSWINDOWS_HANDLE (f), dialog_proc, |
765 (LPARAM) LISP_TO_VOID (obj)); | 765 (LPARAM) STORE_LISP_IN_VOID (obj)); |
766 if (!did->hwnd) | 766 if (!did->hwnd) |
767 /* Something went wrong creating the dialog */ | 767 /* Something went wrong creating the dialog */ |
768 signal_error (Qdialog_box_error, "Creating dialog", keys); | 768 signal_error (Qdialog_box_error, "Creating dialog", keys); |
769 | 769 |
770 Vdialog_data_list = Fcons (obj, Vdialog_data_list); | 770 Vdialog_data_list = Fcons (obj, Vdialog_data_list); |
837 | 837 |
838 DEFVAR_LISP ("default-file-dialog-filter-alist", | 838 DEFVAR_LISP ("default-file-dialog-filter-alist", |
839 &Vdefault_file_dialog_filter_alist /* | 839 &Vdefault_file_dialog_filter_alist /* |
840 */ ); | 840 */ ); |
841 Vdefault_file_dialog_filter_alist = | 841 Vdefault_file_dialog_filter_alist = |
842 list5 (Fcons (build_msg_string ("Text Files"), build_string ("*.txt")), | 842 list5 (Fcons (build_defer_string ("Text Files"), build_ascstring ("*.txt")), |
843 Fcons (build_msg_string ("C Files"), build_string ("*.c;*.h")), | 843 Fcons (build_defer_string ("C Files"), build_ascstring ("*.c;*.h")), |
844 Fcons (build_msg_string ("Elisp Files"), build_string ("*.el")), | 844 Fcons (build_defer_string ("Elisp Files"), build_ascstring ("*.el")), |
845 Fcons (build_msg_string ("HTML Files"), build_string ("*.html;*.html")), | 845 Fcons (build_defer_string ("HTML Files"), build_ascstring ("*.html;*.html")), |
846 Fcons (build_msg_string ("All Files"), build_string ("*.*"))); | 846 Fcons (build_defer_string ("All Files"), build_ascstring ("*.*"))); |
847 } | 847 } |