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 SetWindowLongPtr(hDlg
, DWLP_USER
, (LONG_PTR
)di
);
70 SendMessage(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 SendDlgItemMessage(hDlg
, idc
, BM_SETCHECK
, BST_CHECKED
, 0L);
76 SetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, WINECON_GetHistorySize(di
->data
->hConIn
), FALSE
);
77 SendDlgItemMessage(hDlg
, IDC_OPT_HIST_NODOUBLE
, BM_SETCHECK
,
78 (di
->config
.history_nodup
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
79 SendDlgItemMessage(hDlg
, IDC_OPT_CONF_CTRL
, BM_SETCHECK
,
80 (di
->config
.menu_mask
& MK_CONTROL
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
81 SendDlgItemMessage(hDlg
, IDC_OPT_CONF_SHIFT
, BM_SETCHECK
,
82 (di
->config
.menu_mask
& MK_SHIFT
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
83 SendDlgItemMessage(hDlg
, IDC_OPT_QUICK_EDIT
, BM_SETCHECK
,
84 (di
->config
.quick_edit
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
85 return FALSE
; /* because we set the focus */
90 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
94 di
= (struct dialog_info
*)GetWindowLongPtr(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 PostMessage(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
) ? TRUE
: FALSE
;
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
) ? TRUE
: FALSE
;
130 di
->config
.quick_edit
= val
;
132 SetWindowLongPtr(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 SetWindowLongPtr(hWnd
, 0, 0);
158 return GetWindowLongPtr(hWnd
, 0);
160 SetWindowLongPtr(hWnd
, 0, wParam
);
163 InvalidateRect(hWnd
, NULL
, TRUE
);
169 HFONT hFont
= (HFONT
)GetWindowLongPtr(hWnd
, 0L);
170 if (hFont
) DeleteObject(hFont
);
178 struct dialog_info
* di
;
179 HFONT hFont
, hOldFont
;
181 di
= (struct dialog_info
*)GetWindowLongPtr(GetParent(hWnd
), DWLP_USER
);
182 BeginPaint(hWnd
, &ps
);
184 font_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
185 size_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
187 hFont
= (HFONT
)GetWindowLongPtr(hWnd
, 0L);
194 len1
= LoadString(GetModuleHandle(NULL
), IDS_FNT_PREVIEW_1
,
195 buf1
, sizeof(buf1
) / sizeof(WCHAR
));
196 len2
= LoadString(GetModuleHandle(NULL
), IDS_FNT_PREVIEW_2
,
197 buf2
, sizeof(buf2
) / sizeof(WCHAR
));
198 buf1
[len1
] = buf2
[len2
] = 0;
201 hOldFont
= SelectObject(ps
.hdc
, hFont
);
202 SetBkColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLong(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_BK
), 0)]);
203 SetTextColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLong(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_FG
), 0)]);
204 TextOut(ps
.hdc
, 0, 0, buf1
, len1
);
206 TextOut(ps
.hdc
, 0, di
->font
[size_idx
].height
, buf2
, len2
);
207 SelectObject(ps
.hdc
, hOldFont
);
214 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
219 /******************************************************************
220 * WCUSER_ColorPreviewProc
222 * Window proc for color previewer in font property sheet
224 static LRESULT WINAPI
WCUSER_ColorPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
235 BeginPaint(hWnd
, &ps
);
236 GetClientRect(hWnd
, &client
);
237 step
= client
.right
/ 8;
239 for (i
= 0; i
< 16; i
++)
241 r
.top
= (i
/ 8) * (client
.bottom
/ 2);
242 r
.bottom
= r
.top
+ client
.bottom
/ 2;
243 r
.left
= (i
& 7) * step
;
244 r
.right
= r
.left
+ step
;
245 hbr
= CreateSolidBrush(WCUSER_ColorMap
[i
]);
246 FillRect(ps
.hdc
, &r
, hbr
);
248 if (GetWindowLong(hWnd
, 0) == i
)
253 hOldPen
= SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
254 r
.right
--; r
.bottom
--;
257 MoveToEx(ps
.hdc
, r
.left
, r
.bottom
, NULL
);
258 LineTo(ps
.hdc
, r
.left
, r
.top
);
259 LineTo(ps
.hdc
, r
.right
, r
.top
);
260 SelectObject(ps
.hdc
, GetStockObject(BLACK_PEN
));
261 LineTo(ps
.hdc
, r
.right
, r
.bottom
);
262 LineTo(ps
.hdc
, r
.left
, r
.bottom
);
265 r
.left
++; r
.top
++; r
.right
--; r
.bottom
--;
266 SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
268 SelectObject(ps
.hdc
, hOldPen
);
279 GetClientRect(hWnd
, &client
);
280 step
= client
.right
/ 8;
281 i
= (HIWORD(lParam
) >= client
.bottom
/ 2) ? 8 : 0;
282 i
+= LOWORD(lParam
) / step
;
283 SetWindowLong(hWnd
, 0, i
);
284 InvalidateRect(GetDlgItem(GetParent(hWnd
), IDC_FNT_PREVIEW
), NULL
, FALSE
);
285 InvalidateRect(hWnd
, NULL
, FALSE
);
289 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
294 /******************************************************************
297 * enumerates all the font names with at least one valid font
299 static int CALLBACK
font_enum_size2(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
300 DWORD FontType
, LPARAM lParam
)
302 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
304 WCUSER_DumpTextMetric(tm
, FontType
);
305 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
313 static int CALLBACK
font_enum(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
314 DWORD FontType
, LPARAM lParam
)
316 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
318 WCUSER_DumpLogFont("DlgFamily: ", lf
, FontType
);
319 if (WCUSER_ValidateFont(di
->data
, lf
))
321 if (FontType
& RASTER_FONTTYPE
)
324 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, lf
->lfFaceName
, font_enum_size2
, (LPARAM
)di
);
331 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_ADDSTRING
,
332 0, (LPARAM
)lf
->lfFaceName
);
339 /******************************************************************
344 static int CALLBACK
font_enum_size(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
345 DWORD FontType
, LPARAM lParam
)
347 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
349 static const WCHAR fmt
[] = {'%','l','d',0};
351 WCUSER_DumpTextMetric(tm
, FontType
);
352 if (di
->nFont
== 0 && !(FontType
& RASTER_FONTTYPE
))
354 static const int sizes
[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
357 di
->nFont
= sizeof(sizes
) / sizeof(sizes
[0]);
358 di
->font
= HeapAlloc(GetProcessHeap(), 0, di
->nFont
* sizeof(di
->font
[0]));
359 for (i
= 0; i
< di
->nFont
; i
++)
361 /* drop sizes where window size wouldn't fit on screen */
362 if (sizes
[i
] * di
->data
->curcfg
.win_height
> GetSystemMetrics(SM_CYSCREEN
))
367 di
->font
[i
].height
= sizes
[i
];
368 di
->font
[i
].weight
= 400;
369 lstrcpy(di
->font
[i
].faceName
, lf
->lfFaceName
);
370 wsprintf(buf
, fmt
, sizes
[i
]);
371 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, i
, (LPARAM
)buf
);
373 /* don't need to enumerate other */
377 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
381 /* we want the string to be sorted with a numeric order, not a lexicographic...
382 * do the job by hand... get where to insert the new string
384 for (idx
= 0; idx
< di
->nFont
&& tm
->tmHeight
> di
->font
[idx
].height
; idx
++);
385 while (idx
< di
->nFont
&&
386 tm
->tmHeight
== di
->font
[idx
].height
&&
387 tm
->tmWeight
> di
->font
[idx
].weight
)
389 if (idx
== di
->nFont
||
390 tm
->tmHeight
!= di
->font
[idx
].height
||
391 tm
->tmWeight
< di
->font
[idx
].weight
)
393 /* here we need to add the new entry */
394 wsprintf(buf
, fmt
, tm
->tmHeight
);
395 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, idx
, (LPARAM
)buf
);
397 /* now grow our arrays and insert the values at the same index than in the list box */
400 di
->font
= HeapReAlloc(GetProcessHeap(), 0, di
->font
, sizeof(*di
->font
) * (di
->nFont
+ 1));
401 if (idx
!= di
->nFont
)
402 memmove(&di
->font
[idx
+ 1], &di
->font
[idx
], (di
->nFont
- idx
) * sizeof(*di
->font
));
405 di
->font
= HeapAlloc(GetProcessHeap(), 0, sizeof(*di
->font
));
406 di
->font
[idx
].height
= tm
->tmHeight
;
407 di
->font
[idx
].weight
= tm
->tmWeight
;
408 lstrcpy(di
->font
[idx
].faceName
, lf
->lfFaceName
);
415 /******************************************************************
420 static BOOL
select_font(struct dialog_info
* di
)
422 int font_idx
, size_idx
;
426 HFONT hFont
, hOldFont
;
427 struct config_data config
;
429 font_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
430 size_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
432 if (font_idx
< 0 || size_idx
< 0 || size_idx
>= di
->nFont
)
435 WCUSER_FillLogFont(&lf
, di
->font
[size_idx
].faceName
,
436 di
->font
[size_idx
].height
, di
->font
[size_idx
].weight
);
437 hFont
= WCUSER_CopyFont(&config
, di
->data
->hWnd
, &lf
, NULL
);
438 if (!hFont
) return FALSE
;
440 if (config
.cell_height
!= di
->font
[size_idx
].height
)
441 WINE_TRACE("mismatched heights (%u<>%u)\n",
442 config
.cell_height
, di
->font
[size_idx
].height
);
443 hOldFont
= (HFONT
)SendDlgItemMessage(di
->hDlg
, IDC_FNT_PREVIEW
, WM_GETFONT
, 0L, 0L);
445 SendDlgItemMessage(di
->hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
446 if (hOldFont
) DeleteObject(hOldFont
);
448 LoadString(GetModuleHandle(NULL
), IDS_FNT_DISPLAY
, fmt
, sizeof(fmt
) / sizeof(WCHAR
));
449 wsprintf(buf
, fmt
, config
.cell_width
, config
.cell_height
);
451 SendDlgItemMessage(di
->hDlg
, IDC_FNT_FONT_INFO
, WM_SETTEXT
, 0, (LPARAM
)buf
);
456 /******************************************************************
459 * fills the size list box according to selected family in font LB
461 static BOOL
fill_list_size(struct dialog_info
* di
, BOOL doInit
)
464 WCHAR lfFaceName
[LF_FACESIZE
];
466 idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
467 if (idx
< 0) return FALSE
;
469 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETTEXT
, idx
, (LPARAM
)lfFaceName
);
470 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_RESETCONTENT
, 0L, 0L);
471 HeapFree(GetProcessHeap(), 0, di
->font
);
475 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, lfFaceName
, font_enum_size
, (LPARAM
)di
);
481 for (idx
= 0; idx
< di
->nFont
; idx
++)
483 if (!lstrcmp(di
->font
[idx
].faceName
, di
->config
.face_name
) &&
484 di
->font
[idx
].height
== di
->config
.cell_height
&&
485 di
->font
[idx
].weight
== di
->config
.font_weight
)
487 if (ref
== -1) ref
= idx
;
488 else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref
, idx
);
491 idx
= (ref
== -1) ? 0 : ref
;
495 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_SETCURSEL
, idx
, 0L);
500 /******************************************************************
505 static BOOL
fill_list_font(struct dialog_info
* di
)
507 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_RESETCONTENT
, 0L, 0L);
508 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, NULL
, font_enum
, (LPARAM
)di
);
509 if (SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SELECTSTRING
,
510 (WPARAM
)-1, (LPARAM
)di
->config
.face_name
) == LB_ERR
)
511 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SETCURSEL
, 0L, 0L);
512 fill_list_size(di
, TRUE
);
516 /******************************************************************
519 * Dialog proc for the Font property sheet
521 static INT_PTR WINAPI
WCUSER_FontDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
523 struct dialog_info
* di
;
528 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
530 SetWindowLongPtr(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
531 /* remove dialog from this control, font will be reset when listboxes are filled */
532 SendDlgItemMessage(hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, 0L, 0L);
534 SetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0, (di
->config
.def_attr
>> 4) & 0x0F);
535 SetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0, di
->config
.def_attr
& 0x0F);
538 di
= (struct dialog_info
*)GetWindowLongPtr(hDlg
, DWLP_USER
);
539 switch (LOWORD(wParam
))
541 case IDC_FNT_LIST_FONT
:
542 if (HIWORD(wParam
) == LBN_SELCHANGE
)
544 fill_list_size(di
, FALSE
);
547 case IDC_FNT_LIST_SIZE
:
548 if (HIWORD(wParam
) == LBN_SELCHANGE
)
557 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
560 di
= (struct dialog_info
*)GetWindowLongPtr(hDlg
, DWLP_USER
);
567 val
= SendDlgItemMessage(hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
573 WCUSER_FillLogFont(&lf
, di
->font
[val
].faceName
,
574 di
->font
[val
].height
, di
->font
[val
].weight
);
575 DeleteObject(WCUSER_CopyFont(&di
->config
,
576 di
->data
->hWnd
, &lf
, NULL
));
579 val
= (GetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0) << 4) |
580 GetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0);
581 di
->config
.def_attr
= val
;
583 SetWindowLongPtr(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
596 /******************************************************************
597 * WCUSER_ConfigDlgProc
599 * Dialog proc for the config property sheet
601 static INT_PTR WINAPI
WCUSER_ConfigDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
603 struct dialog_info
* di
;
609 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
612 SetWindowLongPtr(hDlg
, DWLP_USER
, (DWORD_PTR
)di
);
613 SetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, di
->config
.sb_width
, FALSE
);
614 SetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, di
->config
.sb_height
, FALSE
);
615 SetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, di
->config
.win_width
, FALSE
);
616 SetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, di
->config
.win_height
, FALSE
);
618 SendMessage(GetDlgItem(hDlg
,IDC_CNF_WIN_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM (nMaxUD
, 0));
619 SendMessage(GetDlgItem(hDlg
,IDC_CNF_WIN_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM (nMaxUD
, 0));
620 SendMessage(GetDlgItem(hDlg
,IDC_CNF_SB_HEIGHT_UD
), UDM_SETRANGE
, 0, MAKELPARAM (nMaxUD
, 0));
621 SendMessage(GetDlgItem(hDlg
,IDC_CNF_SB_WIDTH_UD
), UDM_SETRANGE
, 0, MAKELPARAM (nMaxUD
, 0));
623 SendDlgItemMessage(hDlg
, IDC_CNF_CLOSE_EXIT
, BM_SETCHECK
,
624 (di
->config
.exit_on_die
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
626 static const WCHAR s1
[] = {'W','i','n','3','2',0};
627 static const WCHAR s2
[] = {'E','m','a','c','s',0};
629 SendDlgItemMessage(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
,
631 SendDlgItemMessage(hDlg
, IDC_CNF_EDITION_MODE
, CB_ADDSTRING
,
633 SendDlgItemMessage(hDlg
, IDC_CNF_EDITION_MODE
, CB_SETCURSEL
,
634 di
->config
.edition_mode
, 0);
639 di
= (struct dialog_info
*)GetWindowLongPtr(hDlg
, DWLP_USER
);
640 switch (LOWORD(wParam
))
646 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
647 int win_w
, win_h
, sb_w
, sb_h
;
650 di
= (struct dialog_info
*)GetWindowLongPtr(hDlg
, DWLP_USER
);
657 sb_w
= GetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, &st1
, FALSE
);
658 sb_h
= GetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, &st2
, FALSE
);
661 SetWindowLongPtr(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
664 win_w
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, &st1
, FALSE
);
665 win_h
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, &st2
, FALSE
);
668 SetWindowLongPtr(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
671 if (win_w
> sb_w
|| win_h
> sb_h
)
676 LoadString(GetModuleHandle(NULL
), IDS_DLG_TIT_ERROR
,
677 cap
, sizeof(cap
) / sizeof(WCHAR
));
678 LoadString(GetModuleHandle(NULL
), IDS_DLG_ERR_SBWINSIZE
,
679 txt
, sizeof(txt
) / sizeof(WCHAR
));
681 MessageBox(hDlg
, txt
, cap
, MB_OK
);
682 SetWindowLongPtr(hDlg
, DWLP_MSGRESULT
, PSNRET_INVALID
);
685 di
->config
.win_width
= win_w
;
686 di
->config
.win_height
= win_h
;
687 di
->config
.sb_width
= sb_w
;
688 di
->config
.sb_height
= sb_h
;
690 di
->config
.exit_on_die
= IsDlgButtonChecked(hDlg
, IDC_CNF_CLOSE_EXIT
) ? 1 : 0;
691 di
->config
.edition_mode
= SendDlgItemMessage(hDlg
, IDC_CNF_EDITION_MODE
, CB_GETCURSEL
,
693 SetWindowLongPtr(hDlg
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
706 /******************************************************************
709 * Dialog Procedure for choosing how to handle modification to the
712 static INT_PTR WINAPI
WCUSER_SaveDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
717 SendDlgItemMessage(hDlg
, IDC_SAV_SESSION
, BM_SETCHECK
, BST_CHECKED
, 0);
720 switch (LOWORD(wParam
))
724 (IsDlgButtonChecked(hDlg
, IDC_SAV_SAVE
) == BST_CHECKED
) ?
725 IDC_SAV_SAVE
: IDC_SAV_SESSION
);
728 EndDialog(hDlg
, IDCANCEL
); break;
737 /******************************************************************
738 * WCUSER_GetProperties
740 * Runs the dialog box to set up the wineconsole options
742 BOOL
WCUSER_GetProperties(struct inner_data
* data
, BOOL current
)
744 HPROPSHEETPAGE psPage
[3];
746 PROPSHEETHEADER psHead
;
749 static const WCHAR szFntPreview
[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
750 static const WCHAR szColorPreview
[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
751 struct dialog_info di
;
752 struct config_data defcfg
;
753 struct config_data
* refcfg
;
754 BOOL save
, modify_session
;
756 InitCommonControls();
761 refcfg
= &data
->curcfg
;
766 WINECON_RegLoad(NULL
, refcfg
= &defcfg
);
773 modify_session
= FALSE
;
776 wndclass
.lpfnWndProc
= WCUSER_FontPreviewProc
;
777 wndclass
.cbClsExtra
= 0;
778 wndclass
.cbWndExtra
= sizeof (DWORD_PTR
); /* for hFont */
779 wndclass
.hInstance
= GetModuleHandle(NULL
);
781 wndclass
.hCursor
= LoadCursor(0, IDC_ARROW
);
782 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
783 wndclass
.lpszMenuName
= NULL
;
784 wndclass
.lpszClassName
= szFntPreview
;
785 RegisterClass(&wndclass
);
788 wndclass
.lpfnWndProc
= WCUSER_ColorPreviewProc
;
789 wndclass
.cbClsExtra
= 0;
790 wndclass
.cbWndExtra
= sizeof(DWORD
);
791 wndclass
.hInstance
= GetModuleHandle(NULL
);
793 wndclass
.hCursor
= LoadCursor(0, IDC_ARROW
);
794 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
795 wndclass
.lpszMenuName
= NULL
;
796 wndclass
.lpszClassName
= szColorPreview
;
797 RegisterClass(&wndclass
);
799 memset(&psp
, 0, sizeof(psp
));
800 psp
.dwSize
= sizeof(psp
);
802 psp
.hInstance
= wndclass
.hInstance
;
803 psp
.lParam
= (LPARAM
)&di
;
805 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_OPTION
);
806 psp
.pfnDlgProc
= WCUSER_OptionDlgProc
;
807 psPage
[0] = CreatePropertySheetPage(&psp
);
809 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_FONT
);
810 psp
.pfnDlgProc
= WCUSER_FontDlgProc
;
811 psPage
[1] = CreatePropertySheetPage(&psp
);
813 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
814 psp
.pfnDlgProc
= WCUSER_ConfigDlgProc
;
815 psPage
[2] = CreatePropertySheetPage(&psp
);
817 memset(&psHead
, 0, sizeof(psHead
));
818 psHead
.dwSize
= sizeof(psHead
);
820 if (!LoadString(GetModuleHandle(NULL
),
821 (current
) ? IDS_DLG_TIT_CURRENT
: IDS_DLG_TIT_DEFAULT
,
822 buff
, sizeof(buff
) / sizeof(buff
[0])))
832 psHead
.pszCaption
= buff
;
834 psHead
.hwndParent
= data
->hWnd
;
835 psHead
.u3
.phpage
= psPage
;
837 WINECON_DumpConfig("init", refcfg
);
839 PropertySheet(&psHead
);
841 if (memcmp(refcfg
, &di
.config
, sizeof(*refcfg
)) == 0)
844 WINECON_DumpConfig("ref", refcfg
);
845 WINECON_DumpConfig("cur", &di
.config
);
846 if (refcfg
== &data
->curcfg
)
848 switch (DialogBox(GetModuleHandle(NULL
), MAKEINTRESOURCE(IDD_SAVE_SETTINGS
),
849 data
->hWnd
, WCUSER_SaveDlgProc
))
851 case IDC_SAV_SAVE
: save
= TRUE
; modify_session
= TRUE
; break;
852 case IDC_SAV_SESSION
: modify_session
= TRUE
; break;
853 case IDCANCEL
: break;
854 default: WINE_ERR("ooch\n");
858 if (modify_session
) WINECON_SetConfig(data
, &di
.config
);
859 if (save
) WINECON_RegSave(&di
.config
);