1 /* dialog management for wineconsole
3 * Copyright (c) 2001, 2002 Eric Pouech
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
33 #include "winecon_user.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole
);
41 struct config_data config
; /* configuration used for dialog box */
42 struct inner_data
* data
; /* pointer to current winecon info */
43 HWND hDlg
; /* handle to active propsheet */
44 int nFont
; /* number of font size in size LB */
49 WCHAR faceName
[LF_FACESIZE
];
50 } *font
; /* array of nFont. index sync'ed with SIZE LB */
53 /******************************************************************
54 * WCUSER_OptionDlgProc
56 * Dialog prop for the option property sheet
58 static INT_PTR WINAPI
WCUSER_OptionDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
60 struct dialog_info
* di
;
66 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
68 SetWindowLongPtrW(hDlg
, DWLP_USER
, (LONG_PTR
)di
);
70 SendMessageW(GetDlgItem(hDlg
,IDC_OPT_HIST_SIZE_UD
), UDM_SETRANGE
, 0, MAKELPARAM(500, 0));
72 if (di
->config
.cursor_size
<= 25) idc
= IDC_OPT_CURSOR_SMALL
;
73 else if (di
->config
.cursor_size
<= 50) idc
= IDC_OPT_CURSOR_MEDIUM
;
74 else idc
= IDC_OPT_CURSOR_LARGE
;
75 SendDlgItemMessageW(hDlg
, idc
, BM_SETCHECK
, BST_CHECKED
, 0);
76 SetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, di
->config
.history_size
, FALSE
);
77 SendDlgItemMessageW(hDlg
, IDC_OPT_HIST_NODOUBLE
, BM_SETCHECK
,
78 (di
->config
.history_nodup
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
79 SendDlgItemMessageW(hDlg
, IDC_OPT_INSERT_MODE
, BM_SETCHECK
,
80 (di
->config
.insert_mode
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
81 SendDlgItemMessageW(hDlg
, IDC_OPT_CONF_CTRL
, BM_SETCHECK
,
82 (di
->config
.menu_mask
& MK_CONTROL
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
83 SendDlgItemMessageW(hDlg
, IDC_OPT_CONF_SHIFT
, BM_SETCHECK
,
84 (di
->config
.menu_mask
& MK_SHIFT
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
85 SendDlgItemMessageW(hDlg
, IDC_OPT_QUICK_EDIT
, BM_SETCHECK
,
86 (di
->config
.quick_edit
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
87 return FALSE
; /* because we set the focus */
92 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
96 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
101 /* needed in propsheet to keep properly the selected radio button
102 * otherwise, the focus would be set to the first tab stop in the
103 * propsheet, which would always activate the first radio button
105 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
)
106 idc
= IDC_OPT_CURSOR_SMALL
;
107 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
)
108 idc
= IDC_OPT_CURSOR_MEDIUM
;
110 idc
= IDC_OPT_CURSOR_LARGE
;
111 PostMessageW(hDlg
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem(hDlg
, idc
), TRUE
);
115 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
) val
= 25;
116 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
) val
= 50;
118 di
->config
.cursor_size
= val
;
120 val
= GetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, &done
, FALSE
);
121 if (done
) di
->config
.history_size
= val
;
123 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_HIST_NODOUBLE
) & BST_CHECKED
) != 0;
124 di
->config
.history_nodup
= val
;
126 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_INSERT_MODE
) & BST_CHECKED
) != 0;
127 di
->config
.insert_mode
= val
;
130 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_CTRL
) & BST_CHECKED
) val
|= MK_CONTROL
;
131 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_SHIFT
) & BST_CHECKED
) val
|= MK_SHIFT
;
132 di
->config
.menu_mask
= val
;
134 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_QUICK_EDIT
) & BST_CHECKED
) != 0;
135 di
->config
.quick_edit
= val
;
137 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
150 /******************************************************************
151 * WCUSER_FontPreviewProc
153 * Window proc for font previewer in font property sheet
155 static LRESULT WINAPI
WCUSER_FontPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
160 SetWindowLongPtrW(hWnd
, 0, 0);
163 return GetWindowLongPtrW(hWnd
, 0);
165 SetWindowLongPtrW(hWnd
, 0, wParam
);
168 InvalidateRect(hWnd
, NULL
, TRUE
);
174 HFONT hFont
= (HFONT
)GetWindowLongPtrW(hWnd
, 0);
175 if (hFont
) DeleteObject(hFont
);
182 struct dialog_info
* di
;
183 HFONT hFont
, hOldFont
;
185 di
= (struct dialog_info
*)GetWindowLongPtrW(GetParent(hWnd
), DWLP_USER
);
186 BeginPaint(hWnd
, &ps
);
188 size_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
190 hFont
= (HFONT
)GetWindowLongPtrW(hWnd
, 0);
194 WCHAR ascii
[] = {'A','S','C','I','I',':',' ','a','b','c','X','Y','Z','\0'};
198 hOldFont
= SelectObject(ps
.hdc
, hFont
);
199 bkcolor
= WCUSER_ColorMap
[GetWindowLongW(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_BK
), 0)];
200 FillRect(ps
.hdc
, &ps
.rcPaint
, CreateSolidBrush(bkcolor
));
201 SetBkColor(ps
.hdc
, bkcolor
);
202 SetTextColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLongW(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_FG
), 0)]);
203 len
= LoadStringW(GetModuleHandleW(NULL
), IDS_FNT_PREVIEW
,
204 buf
, sizeof(buf
) / sizeof(buf
[0]));
206 TextOutW(ps
.hdc
, 0, 0, buf
, len
);
207 TextOutW(ps
.hdc
, 0, di
->font
[size_idx
].height
, ascii
,
208 sizeof(ascii
)/sizeof(ascii
[0]) - 1);
209 SelectObject(ps
.hdc
, hOldFont
);
215 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
220 /******************************************************************
221 * WCUSER_ColorPreviewProc
223 * Window proc for color previewer in font property sheet
225 static LRESULT WINAPI
WCUSER_ColorPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
236 BeginPaint(hWnd
, &ps
);
237 GetClientRect(hWnd
, &client
);
238 step
= client
.right
/ 8;
240 for (i
= 0; i
< 16; i
++)
242 r
.top
= (i
/ 8) * (client
.bottom
/ 2);
243 r
.bottom
= r
.top
+ client
.bottom
/ 2;
244 r
.left
= (i
& 7) * step
;
245 r
.right
= r
.left
+ step
;
246 hbr
= CreateSolidBrush(WCUSER_ColorMap
[i
]);
247 FillRect(ps
.hdc
, &r
, hbr
);
249 if (GetWindowLongW(hWnd
, 0) == i
)
254 hOldPen
= SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
255 r
.right
--; r
.bottom
--;
258 MoveToEx(ps
.hdc
, r
.left
, r
.bottom
, NULL
);
259 LineTo(ps
.hdc
, r
.left
, r
.top
);
260 LineTo(ps
.hdc
, r
.right
, r
.top
);
261 SelectObject(ps
.hdc
, GetStockObject(BLACK_PEN
));
262 LineTo(ps
.hdc
, r
.right
, r
.bottom
);
263 LineTo(ps
.hdc
, r
.left
, r
.bottom
);
266 r
.left
++; r
.top
++; r
.right
--; r
.bottom
--;
267 SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
269 SelectObject(ps
.hdc
, hOldPen
);
280 GetClientRect(hWnd
, &client
);
281 step
= client
.right
/ 8;
282 i
= (HIWORD(lParam
) >= client
.bottom
/ 2) ? 8 : 0;
283 i
+= LOWORD(lParam
) / step
;
284 SetWindowLongW(hWnd
, 0, i
);
285 InvalidateRect(GetDlgItem(GetParent(hWnd
), IDC_FNT_PREVIEW
), NULL
, FALSE
);
286 InvalidateRect(hWnd
, NULL
, FALSE
);
290 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
295 /******************************************************************
298 * enumerates all the font names with at least one valid font
300 static int CALLBACK
font_enum_size2(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
301 DWORD FontType
, LPARAM lParam
)
303 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
305 WCUSER_DumpTextMetric(tm
, FontType
);
306 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
, 0))
314 static int CALLBACK
font_enum(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
315 DWORD FontType
, LPARAM lParam
)
317 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
319 WCUSER_DumpLogFont("DlgFamily: ", lf
, FontType
);
320 if (WCUSER_ValidateFont(di
->data
, lf
, 0))
322 if (FontType
& RASTER_FONTTYPE
)
325 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, lf
->lfFaceName
, font_enum_size2
, (LPARAM
)di
);
332 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_ADDSTRING
,
333 0, (LPARAM
)lf
->lfFaceName
);
340 /******************************************************************
345 static int CALLBACK
font_enum_size(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
346 DWORD FontType
, LPARAM lParam
)
348 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
350 static const WCHAR fmt
[] = {'%','l','d',0};
352 WCUSER_DumpTextMetric(tm
, FontType
);
353 if (di
->nFont
== 0 && !(FontType
& RASTER_FONTTYPE
))
355 static const int sizes
[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
358 di
->nFont
= sizeof(sizes
) / sizeof(sizes
[0]);
359 di
->font
= HeapAlloc(GetProcessHeap(), 0, di
->nFont
* sizeof(di
->font
[0]));
360 for (i
= 0; i
< di
->nFont
; i
++)
362 /* drop sizes where window size wouldn't fit on screen */
363 if (sizes
[i
] * di
->data
->curcfg
.win_height
> GetSystemMetrics(SM_CYSCREEN
))
368 di
->font
[i
].height
= sizes
[i
];
369 di
->font
[i
].weight
= 400;
370 lstrcpyW(di
->font
[i
].faceName
, lf
->lfFaceName
);
371 wsprintfW(buf
, fmt
, sizes
[i
]);
372 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, i
, (LPARAM
)buf
);
374 /* don't need to enumerate other */
378 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
, 0))
382 /* we want the string to be sorted with a numeric order, not a lexicographic...
383 * do the job by hand... get where to insert the new string
385 while (idx
< di
->nFont
&& tm
->tmHeight
> di
->font
[idx
].height
)
387 while (idx
< di
->nFont
&&
388 tm
->tmHeight
== di
->font
[idx
].height
&&
389 tm
->tmWeight
> di
->font
[idx
].weight
)
391 if (idx
== di
->nFont
||
392 tm
->tmHeight
!= di
->font
[idx
].height
||
393 tm
->tmWeight
< di
->font
[idx
].weight
)
395 /* here we need to add the new entry */
396 wsprintfW(buf
, fmt
, tm
->tmHeight
);
397 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, idx
, (LPARAM
)buf
);
399 /* now grow our arrays and insert the values at the same index than in the list box */
402 di
->font
= HeapReAlloc(GetProcessHeap(), 0, di
->font
, sizeof(*di
->font
) * (di
->nFont
+ 1));
403 if (idx
!= di
->nFont
)
404 memmove(&di
->font
[idx
+ 1], &di
->font
[idx
], (di
->nFont
- idx
) * sizeof(*di
->font
));
407 di
->font
= HeapAlloc(GetProcessHeap(), 0, sizeof(*di
->font
));
408 di
->font
[idx
].height
= tm
->tmHeight
;
409 di
->font
[idx
].weight
= tm
->tmWeight
;
410 lstrcpyW(di
->font
[idx
].faceName
, lf
->lfFaceName
);
417 /******************************************************************
422 static BOOL
select_font(struct dialog_info
* di
)
424 int font_idx
, size_idx
;
429 HFONT hFont
, hOldFont
;
430 struct config_data config
;
432 font_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0, 0);
433 size_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
435 if (font_idx
< 0 || size_idx
< 0 || size_idx
>= di
->nFont
)
438 WCUSER_FillLogFont(&lf
, di
->font
[size_idx
].faceName
,
439 di
->font
[size_idx
].height
, di
->font
[size_idx
].weight
);
440 hFont
= WCUSER_CopyFont(&config
, di
->data
->hWnd
, &lf
, NULL
);
441 if (!hFont
) return FALSE
;
443 if (config
.cell_height
!= di
->font
[size_idx
].height
)
444 WINE_TRACE("mismatched heights (%u<>%u)\n",
445 config
.cell_height
, di
->font
[size_idx
].height
);
446 hOldFont
= (HFONT
)SendDlgItemMessageW(di
->hDlg
, IDC_FNT_PREVIEW
, WM_GETFONT
, 0, 0);
448 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
449 if (hOldFont
) DeleteObject(hOldFont
);
451 LoadStringW(GetModuleHandleW(NULL
), IDS_FNT_DISPLAY
, fmt
, sizeof(fmt
) / sizeof(fmt
[0]));
452 args
[0] = config
.cell_width
;
453 args
[1] = config
.cell_height
;
454 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
455 fmt
, 0, 0, buf
, sizeof(buf
)/sizeof(*buf
), (__ms_va_list
*)args
);
457 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_FONT_INFO
, WM_SETTEXT
, 0, (LPARAM
)buf
);
462 /******************************************************************
465 * fills the size list box according to selected family in font LB
467 static BOOL
fill_list_size(struct dialog_info
* di
, BOOL doInit
)
470 WCHAR lfFaceName
[LF_FACESIZE
];
472 idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0, 0);
473 if (idx
< 0) return FALSE
;
475 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETTEXT
, idx
, (LPARAM
)lfFaceName
);
476 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_RESETCONTENT
, 0, 0);
477 HeapFree(GetProcessHeap(), 0, di
->font
);
481 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, lfFaceName
, font_enum_size
, (LPARAM
)di
);
487 for (idx
= 0; idx
< di
->nFont
; idx
++)
489 if (!lstrcmpW(di
->font
[idx
].faceName
, di
->config
.face_name
) &&
490 di
->font
[idx
].height
== di
->config
.cell_height
&&
491 di
->font
[idx
].weight
== di
->config
.font_weight
)
493 if (ref
== -1) ref
= idx
;
494 else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref
, idx
);
497 idx
= (ref
== -1) ? 0 : ref
;
501 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_SETCURSEL
, idx
, 0);
506 /******************************************************************
511 static BOOL
fill_list_font(struct dialog_info
* di
)
513 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_RESETCONTENT
, 0, 0);
514 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, NULL
, font_enum
, (LPARAM
)di
);
515 if (SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SELECTSTRING
,
516 -1, (LPARAM
)di
->config
.face_name
) == LB_ERR
)
517 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SETCURSEL
, 0, 0);
518 fill_list_size(di
, TRUE
);
522 /******************************************************************
525 * Dialog proc for the Font property sheet
527 static INT_PTR WINAPI
WCUSER_FontDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
529 struct dialog_info
* di
;
534 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
536 SetWindowLongPtrW(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
537 /* remove dialog from this control, font will be reset when listboxes are filled */
538 SendDlgItemMessageW(hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, 0, 0);
540 SetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0, (di
->config
.def_attr
>> 4) & 0x0F);
541 SetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0, di
->config
.def_attr
& 0x0F);
544 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
545 switch (LOWORD(wParam
))
547 case IDC_FNT_LIST_FONT
:
548 if (HIWORD(wParam
) == LBN_SELCHANGE
)
550 fill_list_size(di
, FALSE
);
553 case IDC_FNT_LIST_SIZE
:
554 if (HIWORD(wParam
) == LBN_SELCHANGE
)
563 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
566 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
573 val
= SendDlgItemMessageW(hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
579 WCUSER_FillLogFont(&lf
, di
->font
[val
].faceName
,
580 di
->font
[val
].height
, di
->font
[val
].weight
);
581 DeleteObject(WCUSER_CopyFont(&di
->config
,
582 di
->data
->hWnd
, &lf
, NULL
));
585 val
= (GetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0) << 4) |
586 GetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0);
587 di
->config
.def_attr
= val
;
589 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
602 /******************************************************************
603 * WCUSER_ConfigDlgProc
605 * Dialog proc for the config property sheet
607 static INT_PTR WINAPI
WCUSER_ConfigDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
609 struct dialog_info
* di
;
615 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
618 SetWindowLongPtrW(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
619 SetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, di
->config
.sb_width
, FALSE
);
620 SetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, di
->config
.sb_height
, FALSE
);
621 SetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, di
->config
.win_width
, FALSE
);
622 SetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, di
->config
.win_height
, FALSE
);
624 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_WIN_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
625 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_WIN_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
626 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_SB_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
627 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_SB_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
629 SendDlgItemMessageW(hDlg
, IDC_CNF_CLOSE_EXIT
, BM_SETCHECK
,
630 (di
->config
.exit_on_die
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
632 static const WCHAR s1
[] = {'W','i','n','3','2',0};
633 static const WCHAR s2
[] = {'E','m','a','c','s',0};
635 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
, 0, (LPARAM
)s1
);
636 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
, 0, (LPARAM
)s2
);
637 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_SETCURSEL
, di
->config
.edition_mode
, 0);
642 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
643 switch (LOWORD(wParam
))
649 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
650 int win_w
, win_h
, sb_w
, sb_h
;
653 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
660 sb_w
= GetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, &st1
, FALSE
);
661 sb_h
= GetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, &st2
, FALSE
);
664 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
667 win_w
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, &st1
, FALSE
);
668 win_h
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, &st2
, FALSE
);
671 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
674 if (win_w
> sb_w
|| win_h
> sb_h
)
679 LoadStringW(GetModuleHandleW(NULL
), IDS_DLG_TIT_ERROR
,
680 cap
, sizeof(cap
) / sizeof(cap
[0]));
681 LoadStringW(GetModuleHandleW(NULL
), IDS_DLG_ERR_SBWINSIZE
,
682 txt
, sizeof(txt
) / sizeof(cap
[0]));
684 MessageBoxW(hDlg
, txt
, cap
, MB_OK
);
685 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
688 di
->config
.win_width
= win_w
;
689 di
->config
.win_height
= win_h
;
690 di
->config
.sb_width
= sb_w
;
691 di
->config
.sb_height
= sb_h
;
693 di
->config
.exit_on_die
= IsDlgButtonChecked(hDlg
, IDC_CNF_CLOSE_EXIT
) ? 1 : 0;
694 di
->config
.edition_mode
= SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
,
696 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
709 /******************************************************************
712 * Dialog Procedure for choosing how to handle modification to the
715 static INT_PTR WINAPI
WCUSER_SaveDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
720 SendDlgItemMessageW(hDlg
, IDC_SAV_SESSION
, BM_SETCHECK
, BST_CHECKED
, 0);
723 switch (LOWORD(wParam
))
727 (IsDlgButtonChecked(hDlg
, IDC_SAV_SAVE
) == BST_CHECKED
) ?
728 IDC_SAV_SAVE
: IDC_SAV_SESSION
);
731 EndDialog(hDlg
, IDCANCEL
); break;
740 /******************************************************************
741 * WCUSER_GetProperties
743 * Runs the dialog box to set up the wineconsole options
745 BOOL
WCUSER_GetProperties(struct inner_data
* data
, BOOL current
)
747 HPROPSHEETPAGE psPage
[3];
749 PROPSHEETHEADERW psHead
;
752 static const WCHAR szFntPreview
[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
753 static const WCHAR szColorPreview
[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
754 struct dialog_info di
;
755 struct config_data defcfg
;
756 struct config_data
* refcfg
;
757 BOOL save
, modify_session
;
759 InitCommonControls();
764 refcfg
= &data
->curcfg
;
769 WINECON_RegLoad(NULL
, refcfg
= &defcfg
);
776 modify_session
= FALSE
;
779 wndclass
.lpfnWndProc
= WCUSER_FontPreviewProc
;
780 wndclass
.cbClsExtra
= 0;
781 wndclass
.cbWndExtra
= sizeof (DWORD_PTR
); /* for hFont */
782 wndclass
.hInstance
= GetModuleHandleW(NULL
);
784 wndclass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
785 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
786 wndclass
.lpszMenuName
= NULL
;
787 wndclass
.lpszClassName
= szFntPreview
;
788 RegisterClassW(&wndclass
);
791 wndclass
.lpfnWndProc
= WCUSER_ColorPreviewProc
;
792 wndclass
.cbClsExtra
= 0;
793 wndclass
.cbWndExtra
= sizeof(DWORD
);
794 wndclass
.hInstance
= GetModuleHandleW(NULL
);
796 wndclass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
797 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
798 wndclass
.lpszMenuName
= NULL
;
799 wndclass
.lpszClassName
= szColorPreview
;
800 RegisterClassW(&wndclass
);
802 memset(&psp
, 0, sizeof(psp
));
803 psp
.dwSize
= sizeof(psp
);
805 psp
.hInstance
= wndclass
.hInstance
;
806 psp
.lParam
= (LPARAM
)&di
;
808 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_OPTION
);
809 psp
.pfnDlgProc
= WCUSER_OptionDlgProc
;
810 psPage
[0] = CreatePropertySheetPageW(&psp
);
812 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_FONT
);
813 psp
.pfnDlgProc
= WCUSER_FontDlgProc
;
814 psPage
[1] = CreatePropertySheetPageW(&psp
);
816 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_CONFIG
);
817 psp
.pfnDlgProc
= WCUSER_ConfigDlgProc
;
818 psPage
[2] = CreatePropertySheetPageW(&psp
);
820 memset(&psHead
, 0, sizeof(psHead
));
821 psHead
.dwSize
= sizeof(psHead
);
823 if (!LoadStringW(GetModuleHandleW(NULL
),
824 (current
) ? IDS_DLG_TIT_CURRENT
: IDS_DLG_TIT_DEFAULT
,
825 buff
, sizeof(buff
) / sizeof(buff
[0])))
835 psHead
.pszCaption
= buff
;
837 psHead
.hwndParent
= data
->hWnd
;
838 psHead
.u3
.phpage
= psPage
;
839 psHead
.dwFlags
= PSH_NOAPPLYNOW
;
841 WINECON_DumpConfig("init", refcfg
);
843 PropertySheetW(&psHead
);
845 if (memcmp(refcfg
, &di
.config
, sizeof(*refcfg
)) == 0)
848 WINECON_DumpConfig("ref", refcfg
);
849 WINECON_DumpConfig("cur", &di
.config
);
850 if (refcfg
== &data
->curcfg
)
852 switch (DialogBoxW(GetModuleHandleW(NULL
), MAKEINTRESOURCEW(IDD_SAVE_SETTINGS
),
853 data
->hWnd
, WCUSER_SaveDlgProc
))
855 case IDC_SAV_SAVE
: save
= TRUE
; modify_session
= TRUE
; break;
856 case IDC_SAV_SESSION
: modify_session
= TRUE
; break;
857 case IDCANCEL
: break;
858 default: WINE_ERR("ooch\n");
862 if (modify_session
) WINECON_SetConfig(data
, &di
.config
);
863 if (save
) WINECON_RegSave(&di
.config
);