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
25 #define NONAMELESSSTRUCT
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_CONF_CTRL
, BM_SETCHECK
,
80 (di
->config
.menu_mask
& MK_CONTROL
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
81 SendDlgItemMessageW(hDlg
, IDC_OPT_CONF_SHIFT
, BM_SETCHECK
,
82 (di
->config
.menu_mask
& MK_SHIFT
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
83 SendDlgItemMessageW(hDlg
, IDC_OPT_QUICK_EDIT
, BM_SETCHECK
,
84 (di
->config
.quick_edit
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
85 return FALSE
; /* because we set the focus */
90 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
94 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
99 /* needed in propsheet to keep properly the selected radio button
100 * otherwise, the focus would be set to the first tab stop in the
101 * propsheet, which would always activate the first radio button
103 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
)
104 idc
= IDC_OPT_CURSOR_SMALL
;
105 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
)
106 idc
= IDC_OPT_CURSOR_MEDIUM
;
108 idc
= IDC_OPT_CURSOR_LARGE
;
109 PostMessageW(hDlg
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem(hDlg
, idc
), TRUE
);
113 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
) val
= 25;
114 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
) val
= 50;
116 di
->config
.cursor_size
= val
;
118 val
= GetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, &done
, FALSE
);
119 if (done
) di
->config
.history_size
= val
;
121 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_HIST_NODOUBLE
) & BST_CHECKED
) != 0;
122 di
->config
.history_nodup
= val
;
125 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_CTRL
) & BST_CHECKED
) val
|= MK_CONTROL
;
126 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_SHIFT
) & BST_CHECKED
) val
|= MK_SHIFT
;
127 di
->config
.menu_mask
= val
;
129 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_QUICK_EDIT
) & BST_CHECKED
) != 0;
130 di
->config
.quick_edit
= val
;
132 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
145 /******************************************************************
146 * WCUSER_FontPreviewProc
148 * Window proc for font previewer in font property sheet
150 static LRESULT WINAPI
WCUSER_FontPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
155 SetWindowLongPtrW(hWnd
, 0, 0);
158 return GetWindowLongPtrW(hWnd
, 0);
160 SetWindowLongPtrW(hWnd
, 0, wParam
);
163 InvalidateRect(hWnd
, NULL
, TRUE
);
169 HFONT hFont
= (HFONT
)GetWindowLongPtrW(hWnd
, 0);
170 if (hFont
) DeleteObject(hFont
);
177 struct dialog_info
* di
;
178 HFONT hFont
, hOldFont
;
180 di
= (struct dialog_info
*)GetWindowLongPtrW(GetParent(hWnd
), DWLP_USER
);
181 BeginPaint(hWnd
, &ps
);
183 size_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
185 hFont
= (HFONT
)GetWindowLongPtrW(hWnd
, 0);
188 WCHAR ascii
[] = {'A','S','C','I','I',':',' ','a','b','c','X','Y','Z','\0'};
192 hOldFont
= SelectObject(ps
.hdc
, hFont
);
193 SetBkColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLongW(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_BK
), 0)]);
194 SetTextColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLongW(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_FG
), 0)]);
195 len
= LoadStringW(GetModuleHandleW(NULL
), IDS_FNT_PREVIEW
,
196 buf
, sizeof(buf
) / sizeof(buf
[0]));
198 TextOutW(ps
.hdc
, 0, 0, buf
, len
);
199 TextOutW(ps
.hdc
, 0, di
->font
[size_idx
].height
, ascii
,
200 sizeof(ascii
)/sizeof(ascii
[0]) - 1);
201 SelectObject(ps
.hdc
, hOldFont
);
207 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
212 /******************************************************************
213 * WCUSER_ColorPreviewProc
215 * Window proc for color previewer in font property sheet
217 static LRESULT WINAPI
WCUSER_ColorPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
228 BeginPaint(hWnd
, &ps
);
229 GetClientRect(hWnd
, &client
);
230 step
= client
.right
/ 8;
232 for (i
= 0; i
< 16; i
++)
234 r
.top
= (i
/ 8) * (client
.bottom
/ 2);
235 r
.bottom
= r
.top
+ client
.bottom
/ 2;
236 r
.left
= (i
& 7) * step
;
237 r
.right
= r
.left
+ step
;
238 hbr
= CreateSolidBrush(WCUSER_ColorMap
[i
]);
239 FillRect(ps
.hdc
, &r
, hbr
);
241 if (GetWindowLongW(hWnd
, 0) == i
)
246 hOldPen
= SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
247 r
.right
--; r
.bottom
--;
250 MoveToEx(ps
.hdc
, r
.left
, r
.bottom
, NULL
);
251 LineTo(ps
.hdc
, r
.left
, r
.top
);
252 LineTo(ps
.hdc
, r
.right
, r
.top
);
253 SelectObject(ps
.hdc
, GetStockObject(BLACK_PEN
));
254 LineTo(ps
.hdc
, r
.right
, r
.bottom
);
255 LineTo(ps
.hdc
, r
.left
, r
.bottom
);
258 r
.left
++; r
.top
++; r
.right
--; r
.bottom
--;
259 SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
261 SelectObject(ps
.hdc
, hOldPen
);
272 GetClientRect(hWnd
, &client
);
273 step
= client
.right
/ 8;
274 i
= (HIWORD(lParam
) >= client
.bottom
/ 2) ? 8 : 0;
275 i
+= LOWORD(lParam
) / step
;
276 SetWindowLongW(hWnd
, 0, i
);
277 InvalidateRect(GetDlgItem(GetParent(hWnd
), IDC_FNT_PREVIEW
), NULL
, FALSE
);
278 InvalidateRect(hWnd
, NULL
, FALSE
);
282 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
287 /******************************************************************
290 * enumerates all the font names with at least one valid font
292 static int CALLBACK
font_enum_size2(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
293 DWORD FontType
, LPARAM lParam
)
295 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
297 WCUSER_DumpTextMetric(tm
, FontType
);
298 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
306 static int CALLBACK
font_enum(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
307 DWORD FontType
, LPARAM lParam
)
309 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
311 WCUSER_DumpLogFont("DlgFamily: ", lf
, FontType
);
312 if (WCUSER_ValidateFont(di
->data
, lf
))
314 if (FontType
& RASTER_FONTTYPE
)
317 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, lf
->lfFaceName
, font_enum_size2
, (LPARAM
)di
);
324 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_ADDSTRING
,
325 0, (LPARAM
)lf
->lfFaceName
);
332 /******************************************************************
337 static int CALLBACK
font_enum_size(const LOGFONTW
* lf
, const TEXTMETRICW
* tm
,
338 DWORD FontType
, LPARAM lParam
)
340 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
342 static const WCHAR fmt
[] = {'%','l','d',0};
344 WCUSER_DumpTextMetric(tm
, FontType
);
345 if (di
->nFont
== 0 && !(FontType
& RASTER_FONTTYPE
))
347 static const int sizes
[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
350 di
->nFont
= sizeof(sizes
) / sizeof(sizes
[0]);
351 di
->font
= HeapAlloc(GetProcessHeap(), 0, di
->nFont
* sizeof(di
->font
[0]));
352 for (i
= 0; i
< di
->nFont
; i
++)
354 /* drop sizes where window size wouldn't fit on screen */
355 if (sizes
[i
] * di
->data
->curcfg
.win_height
> GetSystemMetrics(SM_CYSCREEN
))
360 di
->font
[i
].height
= sizes
[i
];
361 di
->font
[i
].weight
= 400;
362 lstrcpyW(di
->font
[i
].faceName
, lf
->lfFaceName
);
363 wsprintfW(buf
, fmt
, sizes
[i
]);
364 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, i
, (LPARAM
)buf
);
366 /* don't need to enumerate other */
370 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
374 /* we want the string to be sorted with a numeric order, not a lexicographic...
375 * do the job by hand... get where to insert the new string
377 while (idx
< di
->nFont
&& tm
->tmHeight
> di
->font
[idx
].height
)
379 while (idx
< di
->nFont
&&
380 tm
->tmHeight
== di
->font
[idx
].height
&&
381 tm
->tmWeight
> di
->font
[idx
].weight
)
383 if (idx
== di
->nFont
||
384 tm
->tmHeight
!= di
->font
[idx
].height
||
385 tm
->tmWeight
< di
->font
[idx
].weight
)
387 /* here we need to add the new entry */
388 wsprintfW(buf
, fmt
, tm
->tmHeight
);
389 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, idx
, (LPARAM
)buf
);
391 /* now grow our arrays and insert the values at the same index than in the list box */
394 di
->font
= HeapReAlloc(GetProcessHeap(), 0, di
->font
, sizeof(*di
->font
) * (di
->nFont
+ 1));
395 if (idx
!= di
->nFont
)
396 memmove(&di
->font
[idx
+ 1], &di
->font
[idx
], (di
->nFont
- idx
) * sizeof(*di
->font
));
399 di
->font
= HeapAlloc(GetProcessHeap(), 0, sizeof(*di
->font
));
400 di
->font
[idx
].height
= tm
->tmHeight
;
401 di
->font
[idx
].weight
= tm
->tmWeight
;
402 lstrcpyW(di
->font
[idx
].faceName
, lf
->lfFaceName
);
409 /******************************************************************
414 static BOOL
select_font(struct dialog_info
* di
)
416 int font_idx
, size_idx
;
421 HFONT hFont
, hOldFont
;
422 struct config_data config
;
424 font_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0, 0);
425 size_idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
427 if (font_idx
< 0 || size_idx
< 0 || size_idx
>= di
->nFont
)
430 WCUSER_FillLogFont(&lf
, di
->font
[size_idx
].faceName
,
431 di
->font
[size_idx
].height
, di
->font
[size_idx
].weight
);
432 hFont
= WCUSER_CopyFont(&config
, di
->data
->hWnd
, &lf
, NULL
);
433 if (!hFont
) return FALSE
;
435 if (config
.cell_height
!= di
->font
[size_idx
].height
)
436 WINE_TRACE("mismatched heights (%u<>%u)\n",
437 config
.cell_height
, di
->font
[size_idx
].height
);
438 hOldFont
= (HFONT
)SendDlgItemMessageW(di
->hDlg
, IDC_FNT_PREVIEW
, WM_GETFONT
, 0, 0);
440 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
441 if (hOldFont
) DeleteObject(hOldFont
);
443 LoadStringW(GetModuleHandleW(NULL
), IDS_FNT_DISPLAY
, fmt
, sizeof(fmt
) / sizeof(fmt
[0]));
444 args
[0] = config
.cell_width
;
445 args
[1] = config
.cell_height
;
446 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
447 fmt
, 0, 0, buf
, sizeof(buf
)/sizeof(*buf
), (__ms_va_list
*)args
);
449 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_FONT_INFO
, WM_SETTEXT
, 0, (LPARAM
)buf
);
454 /******************************************************************
457 * fills the size list box according to selected family in font LB
459 static BOOL
fill_list_size(struct dialog_info
* di
, BOOL doInit
)
462 WCHAR lfFaceName
[LF_FACESIZE
];
464 idx
= SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0, 0);
465 if (idx
< 0) return FALSE
;
467 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETTEXT
, idx
, (LPARAM
)lfFaceName
);
468 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_RESETCONTENT
, 0, 0);
469 HeapFree(GetProcessHeap(), 0, di
->font
);
473 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, lfFaceName
, font_enum_size
, (LPARAM
)di
);
479 for (idx
= 0; idx
< di
->nFont
; idx
++)
481 if (!lstrcmpW(di
->font
[idx
].faceName
, di
->config
.face_name
) &&
482 di
->font
[idx
].height
== di
->config
.cell_height
&&
483 di
->font
[idx
].weight
== di
->config
.font_weight
)
485 if (ref
== -1) ref
= idx
;
486 else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref
, idx
);
489 idx
= (ref
== -1) ? 0 : ref
;
493 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_SETCURSEL
, idx
, 0);
498 /******************************************************************
503 static BOOL
fill_list_font(struct dialog_info
* di
)
505 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_RESETCONTENT
, 0, 0);
506 EnumFontFamiliesW(PRIVATE(di
->data
)->hMemDC
, NULL
, font_enum
, (LPARAM
)di
);
507 if (SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SELECTSTRING
,
508 -1, (LPARAM
)di
->config
.face_name
) == LB_ERR
)
509 SendDlgItemMessageW(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SETCURSEL
, 0, 0);
510 fill_list_size(di
, TRUE
);
514 /******************************************************************
517 * Dialog proc for the Font property sheet
519 static INT_PTR WINAPI
WCUSER_FontDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
521 struct dialog_info
* di
;
526 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
528 SetWindowLongPtrW(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
529 /* remove dialog from this control, font will be reset when listboxes are filled */
530 SendDlgItemMessageW(hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, 0, 0);
532 SetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0, (di
->config
.def_attr
>> 4) & 0x0F);
533 SetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0, di
->config
.def_attr
& 0x0F);
536 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
537 switch (LOWORD(wParam
))
539 case IDC_FNT_LIST_FONT
:
540 if (HIWORD(wParam
) == LBN_SELCHANGE
)
542 fill_list_size(di
, FALSE
);
545 case IDC_FNT_LIST_SIZE
:
546 if (HIWORD(wParam
) == LBN_SELCHANGE
)
555 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
558 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
565 val
= SendDlgItemMessageW(hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0, 0);
571 WCUSER_FillLogFont(&lf
, di
->font
[val
].faceName
,
572 di
->font
[val
].height
, di
->font
[val
].weight
);
573 DeleteObject(WCUSER_CopyFont(&di
->config
,
574 di
->data
->hWnd
, &lf
, NULL
));
577 val
= (GetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0) << 4) |
578 GetWindowLongW(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0);
579 di
->config
.def_attr
= val
;
581 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
594 /******************************************************************
595 * WCUSER_ConfigDlgProc
597 * Dialog proc for the config property sheet
599 static INT_PTR WINAPI
WCUSER_ConfigDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
601 struct dialog_info
* di
;
607 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
610 SetWindowLongPtrW(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
611 SetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, di
->config
.sb_width
, FALSE
);
612 SetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, di
->config
.sb_height
, FALSE
);
613 SetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, di
->config
.win_width
, FALSE
);
614 SetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, di
->config
.win_height
, FALSE
);
616 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_WIN_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
617 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_WIN_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
618 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_SB_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
619 SendMessageW(GetDlgItem(hDlg
,IDC_CNF_SB_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM(nMaxUD
, 0));
621 SendDlgItemMessageW(hDlg
, IDC_CNF_CLOSE_EXIT
, BM_SETCHECK
,
622 (di
->config
.exit_on_die
) ? BST_CHECKED
: BST_UNCHECKED
, 0);
624 static const WCHAR s1
[] = {'W','i','n','3','2',0};
625 static const WCHAR s2
[] = {'E','m','a','c','s',0};
627 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
, 0, (LPARAM
)s1
);
628 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
, 0, (LPARAM
)s2
);
629 SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
, CB_SETCURSEL
, di
->config
.edition_mode
, 0);
634 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
635 switch (LOWORD(wParam
))
641 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
642 int win_w
, win_h
, sb_w
, sb_h
;
645 di
= (struct dialog_info
*)GetWindowLongPtrW(hDlg
, DWLP_USER
);
652 sb_w
= GetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, &st1
, FALSE
);
653 sb_h
= GetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, &st2
, FALSE
);
656 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
659 win_w
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, &st1
, FALSE
);
660 win_h
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, &st2
, FALSE
);
663 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
666 if (win_w
> sb_w
|| win_h
> sb_h
)
671 LoadStringW(GetModuleHandleW(NULL
), IDS_DLG_TIT_ERROR
,
672 cap
, sizeof(cap
) / sizeof(cap
[0]));
673 LoadStringW(GetModuleHandleW(NULL
), IDS_DLG_ERR_SBWINSIZE
,
674 txt
, sizeof(txt
) / sizeof(cap
[0]));
676 MessageBoxW(hDlg
, txt
, cap
, MB_OK
);
677 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
680 di
->config
.win_width
= win_w
;
681 di
->config
.win_height
= win_h
;
682 di
->config
.sb_width
= sb_w
;
683 di
->config
.sb_height
= sb_h
;
685 di
->config
.exit_on_die
= IsDlgButtonChecked(hDlg
, IDC_CNF_CLOSE_EXIT
) ? 1 : 0;
686 di
->config
.edition_mode
= SendDlgItemMessageW(hDlg
, IDC_CNF_EDITION_MODE
,
688 SetWindowLongPtrW(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
701 /******************************************************************
704 * Dialog Procedure for choosing how to handle modification to the
707 static INT_PTR WINAPI
WCUSER_SaveDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
712 SendDlgItemMessageW(hDlg
, IDC_SAV_SESSION
, BM_SETCHECK
, BST_CHECKED
, 0);
715 switch (LOWORD(wParam
))
719 (IsDlgButtonChecked(hDlg
, IDC_SAV_SAVE
) == BST_CHECKED
) ?
720 IDC_SAV_SAVE
: IDC_SAV_SESSION
);
723 EndDialog(hDlg
, IDCANCEL
); break;
732 /******************************************************************
733 * WCUSER_GetProperties
735 * Runs the dialog box to set up the wineconsole options
737 BOOL
WCUSER_GetProperties(struct inner_data
* data
, BOOL current
)
739 HPROPSHEETPAGE psPage
[3];
741 PROPSHEETHEADERW psHead
;
744 static const WCHAR szFntPreview
[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
745 static const WCHAR szColorPreview
[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
746 struct dialog_info di
;
747 struct config_data defcfg
;
748 struct config_data
* refcfg
;
749 BOOL save
, modify_session
;
751 InitCommonControls();
756 refcfg
= &data
->curcfg
;
761 WINECON_RegLoad(NULL
, refcfg
= &defcfg
);
768 modify_session
= FALSE
;
771 wndclass
.lpfnWndProc
= WCUSER_FontPreviewProc
;
772 wndclass
.cbClsExtra
= 0;
773 wndclass
.cbWndExtra
= sizeof (DWORD_PTR
); /* for hFont */
774 wndclass
.hInstance
= GetModuleHandleW(NULL
);
776 wndclass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
777 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
778 wndclass
.lpszMenuName
= NULL
;
779 wndclass
.lpszClassName
= szFntPreview
;
780 RegisterClassW(&wndclass
);
783 wndclass
.lpfnWndProc
= WCUSER_ColorPreviewProc
;
784 wndclass
.cbClsExtra
= 0;
785 wndclass
.cbWndExtra
= sizeof(DWORD
);
786 wndclass
.hInstance
= GetModuleHandleW(NULL
);
788 wndclass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
789 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
790 wndclass
.lpszMenuName
= NULL
;
791 wndclass
.lpszClassName
= szColorPreview
;
792 RegisterClassW(&wndclass
);
794 memset(&psp
, 0, sizeof(psp
));
795 psp
.dwSize
= sizeof(psp
);
797 psp
.hInstance
= wndclass
.hInstance
;
798 psp
.lParam
= (LPARAM
)&di
;
800 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_OPTION
);
801 psp
.pfnDlgProc
= WCUSER_OptionDlgProc
;
802 psPage
[0] = CreatePropertySheetPageW(&psp
);
804 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_FONT
);
805 psp
.pfnDlgProc
= WCUSER_FontDlgProc
;
806 psPage
[1] = CreatePropertySheetPageW(&psp
);
808 psp
.u
.pszTemplate
= MAKEINTRESOURCEW(IDD_CONFIG
);
809 psp
.pfnDlgProc
= WCUSER_ConfigDlgProc
;
810 psPage
[2] = CreatePropertySheetPageW(&psp
);
812 memset(&psHead
, 0, sizeof(psHead
));
813 psHead
.dwSize
= sizeof(psHead
);
815 if (!LoadStringW(GetModuleHandleW(NULL
),
816 (current
) ? IDS_DLG_TIT_CURRENT
: IDS_DLG_TIT_DEFAULT
,
817 buff
, sizeof(buff
) / sizeof(buff
[0])))
827 psHead
.pszCaption
= buff
;
829 psHead
.hwndParent
= data
->hWnd
;
830 psHead
.u3
.phpage
= psPage
;
831 psHead
.dwFlags
= PSH_NOAPPLYNOW
;
833 WINECON_DumpConfig("init", refcfg
);
835 PropertySheetW(&psHead
);
837 if (memcmp(refcfg
, &di
.config
, sizeof(*refcfg
)) == 0)
840 WINECON_DumpConfig("ref", refcfg
);
841 WINECON_DumpConfig("cur", &di
.config
);
842 if (refcfg
== &data
->curcfg
)
844 switch (DialogBoxW(GetModuleHandleW(NULL
), MAKEINTRESOURCEW(IDD_SAVE_SETTINGS
),
845 data
->hWnd
, WCUSER_SaveDlgProc
))
847 case IDC_SAV_SAVE
: save
= TRUE
; modify_session
= TRUE
; break;
848 case IDC_SAV_SESSION
: modify_session
= TRUE
; break;
849 case IDCANCEL
: break;
850 default: WINE_ERR("ooch\n");
854 if (modify_session
) WINECON_SetConfig(data
, &di
.config
);
855 if (save
) WINECON_RegSave(&di
.config
);