1 /* dialog management for wineconsole
3 * Copyright (c) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "winecon_user.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole
);
32 WCUSER_ApplyToCursorSize
,
33 WCUSER_ApplyToHistorySize
, WCUSER_ApplyToHistoryMode
, WCUSER_ApplyToMenuMask
,
34 WCUSER_ApplyToEditMode
,
36 WCUSER_ApplyToFont
, WCUSER_ApplyToAttribute
,
38 WCUSER_ApplyToBufferSize
, WCUSER_ApplyToWindow
43 struct config_data
* config
; /* pointer to configuration used for dialog box */
44 struct inner_data
* data
; /* pointer to current winecon info */
45 HWND hDlg
; /* handle to active propsheet */
46 int nFont
; /* number of font size in size LB */
51 WCHAR faceName
[LF_FACESIZE
];
52 } *font
; /* array of nFont. index sync'ed with SIZE LB */
53 void (*apply
)(struct dialog_info
*, HWND
, enum WCUSER_ApplyTo
, DWORD
);
56 /******************************************************************
61 static void WCUSER_ApplyDefault(struct dialog_info
* di
, HWND hDlg
, enum WCUSER_ApplyTo apply
, DWORD val
)
65 case WCUSER_ApplyToCursorSize
:
66 case WCUSER_ApplyToHistorySize
:
67 case WCUSER_ApplyToHistoryMode
:
68 case WCUSER_ApplyToBufferSize
:
69 case WCUSER_ApplyToWindow
:
70 /* not saving those for now... */
72 case WCUSER_ApplyToMenuMask
:
73 di
->config
->menu_mask
= val
;
75 case WCUSER_ApplyToEditMode
:
76 di
->config
->quick_edit
= val
;
78 case WCUSER_ApplyToFont
:
83 WCUSER_FillLogFont(&lf
, di
->font
[val
].faceName
,
84 di
->font
[val
].height
, di
->font
[val
].weight
);
85 hFont
= WCUSER_CopyFont(di
->config
, PRIVATE(di
->data
)->hWnd
, &lf
);
89 case WCUSER_ApplyToAttribute
:
90 di
->config
->def_attr
= val
;
93 WINECON_RegSave(di
->config
);
96 /******************************************************************
101 static void WCUSER_ApplyCurrent(struct dialog_info
* di
, HWND hDlg
, enum WCUSER_ApplyTo apply
, DWORD val
)
105 case WCUSER_ApplyToCursorSize
:
107 CONSOLE_CURSOR_INFO cinfo
;
109 cinfo
.bVisible
= di
->config
->cursor_visible
;
110 /* this shall update (through notif) curcfg */
111 SetConsoleCursorInfo(di
->data
->hConOut
, &cinfo
);
114 case WCUSER_ApplyToHistorySize
:
115 di
->config
->history_size
= val
;
116 WINECON_SetHistorySize(di
->data
->hConIn
, val
);
118 case WCUSER_ApplyToHistoryMode
:
119 WINECON_SetHistoryMode(di
->data
->hConIn
, val
);
121 case WCUSER_ApplyToMenuMask
:
122 di
->config
->menu_mask
= val
;
124 case WCUSER_ApplyToEditMode
:
125 di
->config
->quick_edit
= val
;
127 case WCUSER_ApplyToFont
:
130 WCUSER_FillLogFont(&lf
, di
->font
[val
].faceName
,
131 di
->font
[val
].height
, di
->font
[val
].weight
);
132 WCUSER_SetFont(di
->data
, &lf
);
135 case WCUSER_ApplyToAttribute
:
136 di
->config
->def_attr
= val
;
137 SetConsoleTextAttribute(di
->data
->hConOut
, val
);
139 case WCUSER_ApplyToBufferSize
:
140 /* this shall update (through notif) curcfg */
141 SetConsoleScreenBufferSize(di
->data
->hConOut
, *(COORD
*)val
);
143 case WCUSER_ApplyToWindow
:
144 /* this shall update (through notif) curcfg */
145 SetConsoleWindowInfo(di
->data
->hConOut
, FALSE
, (SMALL_RECT
*)val
);
150 /******************************************************************
151 * WCUSER_OptionDlgProc
153 * Dialog prop for the option property sheet
155 static BOOL WINAPI
WCUSER_OptionDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
157 struct dialog_info
* di
;
163 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
165 SetWindowLong(hDlg
, DWL_USER
, (DWORD
)di
);
167 if (di
->config
->cursor_size
<= 25) idc
= IDC_OPT_CURSOR_SMALL
;
168 else if (di
->config
->cursor_size
<= 50) idc
= IDC_OPT_CURSOR_MEDIUM
;
169 else idc
= IDC_OPT_CURSOR_LARGE
;
170 SendDlgItemMessage(hDlg
, idc
, BM_SETCHECK
, BST_CHECKED
, 0L);
171 SetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, WINECON_GetHistorySize(di
->data
->hConIn
), FALSE
);
172 if (WINECON_GetHistoryMode(di
->data
->hConIn
))
173 SendDlgItemMessage(hDlg
, IDC_OPT_HIST_DOUBLE
, BM_SETCHECK
, BST_CHECKED
, 0L);
174 SendDlgItemMessage(hDlg
, IDC_OPT_CONF_CTRL
, BM_SETCHECK
,
175 (di
->config
->menu_mask
& MK_CONTROL
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
176 SendDlgItemMessage(hDlg
, IDC_OPT_CONF_SHIFT
, BM_SETCHECK
,
177 (di
->config
->menu_mask
& MK_SHIFT
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
178 SendDlgItemMessage(hDlg
, IDC_OPT_QUICK_EDIT
, BM_SETCHECK
,
179 (di
->config
->quick_edit
) ? BST_CHECKED
: BST_UNCHECKED
, 0L);
180 return FALSE
; /* because we set the focus */
185 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
189 di
= (struct dialog_info
*)GetWindowLong(hDlg
, DWL_USER
);
194 /* needed in propsheet to keep properly the selected radio button
195 * otherwise, the focus would be set to the first tab stop in the
196 * propsheet, which would always activate the first radio button
198 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
)
199 idc
= IDC_OPT_CURSOR_SMALL
;
200 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
)
201 idc
= IDC_OPT_CURSOR_MEDIUM
;
203 idc
= IDC_OPT_CURSOR_LARGE
;
204 PostMessage(hDlg
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem(hDlg
, idc
), TRUE
);
208 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_SMALL
) == BST_CHECKED
) val
= 25;
209 else if (IsDlgButtonChecked(hDlg
, IDC_OPT_CURSOR_MEDIUM
) == BST_CHECKED
) val
= 50;
211 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToCursorSize
, val
);
213 val
= GetDlgItemInt(hDlg
, IDC_OPT_HIST_SIZE
, &done
, FALSE
);
214 if (done
) (di
->apply
)(di
, hDlg
, WCUSER_ApplyToHistorySize
, val
);
216 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToHistoryMode
,
217 IsDlgButtonChecked(hDlg
, IDC_OPT_HIST_DOUBLE
) & BST_CHECKED
);
220 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_CTRL
) & BST_CHECKED
) val
|= MK_CONTROL
;
221 if (IsDlgButtonChecked(hDlg
, IDC_OPT_CONF_SHIFT
) & BST_CHECKED
) val
|= MK_SHIFT
;
222 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToMenuMask
, val
);
224 val
= (IsDlgButtonChecked(hDlg
, IDC_OPT_QUICK_EDIT
) & BST_CHECKED
) ? TRUE
: FALSE
;
225 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToEditMode
, val
);
227 SetWindowLong(hDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
240 /******************************************************************
241 * WCUSER_FontPreviewProc
243 * Window proc for font previewer in font property sheet
245 static LRESULT WINAPI
WCUSER_FontPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
250 SetWindowLong(hWnd
, 0, 0);
253 return GetWindowLong(hWnd
, 0);
255 SetWindowLong(hWnd
, 0, wParam
);
258 InvalidateRect(hWnd
, NULL
, TRUE
);
264 HFONT hFont
= (HFONT
)GetWindowLong(hWnd
, 0L);
265 if (hFont
) DeleteObject(hFont
);
273 struct dialog_info
* di
;
274 HFONT hFont
, hOldFont
;
276 di
= (struct dialog_info
*)GetWindowLong(GetParent(hWnd
), DWL_USER
);
277 BeginPaint(hWnd
, &ps
);
279 font_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
280 size_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
282 hFont
= (HFONT
)GetWindowLong(hWnd
, 0L);
289 len1
= LoadString(GetModuleHandle(NULL
), IDS_FNT_PREVIEW_1
,
290 buf1
, sizeof(buf1
) / sizeof(WCHAR
));
291 len2
= LoadString(GetModuleHandle(NULL
), IDS_FNT_PREVIEW_2
,
292 buf2
, sizeof(buf2
) / sizeof(WCHAR
));
293 buf1
[len1
] = buf2
[len2
] = 0;
296 hOldFont
= SelectObject(ps
.hdc
, hFont
);
297 SetBkColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLong(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_BK
), 0)]);
298 SetTextColor(ps
.hdc
, WCUSER_ColorMap
[GetWindowLong(GetDlgItem(di
->hDlg
, IDC_FNT_COLOR_FG
), 0)]);
299 TextOut(ps
.hdc
, 0, 0, buf1
, len1
);
301 TextOut(ps
.hdc
, 0, di
->font
[size_idx
].height
, buf2
, len2
);
302 SelectObject(ps
.hdc
, hOldFont
);
309 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
314 /******************************************************************
315 * WCUSER_ColorPreviewProc
317 * Window proc for color previewer in font property sheet
319 static LRESULT WINAPI
WCUSER_ColorPreviewProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
330 BeginPaint(hWnd
, &ps
);
331 GetClientRect(hWnd
, &client
);
332 step
= client
.right
/ 8;
334 for (i
= 0; i
< 16; i
++)
336 r
.top
= (i
/ 8) * (client
.bottom
/ 2);
337 r
.bottom
= r
.top
+ client
.bottom
/ 2;
338 r
.left
= (i
& 7) * step
;
339 r
.right
= r
.left
+ step
;
340 hbr
= CreateSolidBrush(WCUSER_ColorMap
[i
]);
341 FillRect(ps
.hdc
, &r
, hbr
);
343 if (GetWindowLong(hWnd
, 0) == i
)
348 hOldPen
= SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
349 r
.right
--; r
.bottom
--;
352 MoveToEx(ps
.hdc
, r
.left
, r
.bottom
, NULL
);
353 LineTo(ps
.hdc
, r
.left
, r
.top
);
354 LineTo(ps
.hdc
, r
.right
, r
.top
);
355 SelectObject(ps
.hdc
, GetStockObject(BLACK_PEN
));
356 LineTo(ps
.hdc
, r
.right
, r
.bottom
);
357 LineTo(ps
.hdc
, r
.left
, r
.bottom
);
360 r
.left
++; r
.top
++; r
.right
--; r
.bottom
--;
361 SelectObject(ps
.hdc
, GetStockObject(WHITE_PEN
));
363 SelectObject(ps
.hdc
, hOldPen
);
374 GetClientRect(hWnd
, &client
);
375 step
= client
.right
/ 8;
376 i
= (HIWORD(lParam
) >= client
.bottom
/ 2) ? 8 : 0;
377 i
+= LOWORD(lParam
) / step
;
378 SetWindowLong(hWnd
, 0, i
);
379 InvalidateRect(GetDlgItem(GetParent(hWnd
), IDC_FNT_PREVIEW
), NULL
, FALSE
);
380 InvalidateRect(hWnd
, NULL
, FALSE
);
384 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
389 /******************************************************************
392 * enumerates all the font names with at least one valid font
394 static int CALLBACK
font_enum_size2(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
395 DWORD FontType
, LPARAM lParam
)
397 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
399 WCUSER_DumpTextMetric(tm
, FontType
);
400 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
408 static int CALLBACK
font_enum(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
409 DWORD FontType
, LPARAM lParam
)
411 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
413 WCUSER_DumpLogFont("DlgFamily: ", lf
, FontType
);
414 if (WCUSER_ValidateFont(di
->data
, lf
))
416 if (FontType
& RASTER_FONTTYPE
)
419 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, lf
->lfFaceName
, font_enum_size2
, (LPARAM
)di
);
426 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_ADDSTRING
,
427 0, (LPARAM
)lf
->lfFaceName
);
434 /******************************************************************
439 static int CALLBACK
font_enum_size(const LOGFONT
* lf
, const TEXTMETRIC
* tm
,
440 DWORD FontType
, LPARAM lParam
)
442 struct dialog_info
* di
= (struct dialog_info
*)lParam
;
444 static const WCHAR fmt
[] = {'%','l','d',0};
446 WCUSER_DumpTextMetric(tm
, FontType
);
447 if (di
->nFont
== 0 && !(FontType
& RASTER_FONTTYPE
))
449 static const int sizes
[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
452 di
->nFont
= sizeof(sizes
) / sizeof(sizes
[0]);
453 di
->font
= HeapAlloc(GetProcessHeap(), 0, di
->nFont
* sizeof(di
->font
[0]));
454 for (i
= 0; i
< di
->nFont
; i
++)
456 /* drop sizes where window size wouldn't fit on screen */
457 if (sizes
[i
] * di
->data
->curcfg
.win_height
> GetSystemMetrics(SM_CYSCREEN
))
462 di
->font
[i
].height
= sizes
[i
];
463 di
->font
[i
].weight
= 400;
464 lstrcpy(di
->font
[i
].faceName
, lf
->lfFaceName
);
465 wsprintf(buf
, fmt
, sizes
[i
]);
466 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, i
, (LPARAM
)buf
);
468 /* don't need to enumerate other */
472 if (WCUSER_ValidateFontMetric(di
->data
, tm
, FontType
))
476 /* we want the string to be sorted with a numeric order, not a lexicographic...
477 * do the job by hand... get where to insert the new string
479 for (idx
= 0; idx
< di
->nFont
&& tm
->tmHeight
> di
->font
[idx
].height
; idx
++);
480 while (idx
< di
->nFont
&&
481 tm
->tmHeight
== di
->font
[idx
].height
&&
482 tm
->tmWeight
> di
->font
[idx
].weight
)
484 if (idx
== di
->nFont
||
485 tm
->tmHeight
!= di
->font
[idx
].height
||
486 tm
->tmWeight
< di
->font
[idx
].weight
)
488 /* here we need to add the new entry */
489 wsprintf(buf
, fmt
, tm
->tmHeight
);
490 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_INSERTSTRING
, idx
, (LPARAM
)buf
);
492 /* now grow our arrays and insert the values at the same index than in the list box */
493 di
->font
= HeapReAlloc(GetProcessHeap(), 0, di
->font
, sizeof(*di
->font
) * (di
->nFont
+ 1));
494 if (idx
!= di
->nFont
)
495 memmove(&di
->font
[idx
+ 1], &di
->font
[idx
], (di
->nFont
- idx
) * sizeof(*di
->font
));
496 di
->font
[idx
].height
= tm
->tmHeight
;
497 di
->font
[idx
].weight
= tm
->tmWeight
;
498 lstrcpy(di
->font
[idx
].faceName
, lf
->lfFaceName
);
505 /******************************************************************
510 static BOOL
select_font(struct dialog_info
* di
)
512 int font_idx
, size_idx
;
516 HFONT hFont
, hOldFont
;
517 struct config_data config
;
519 font_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
520 size_idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
522 if (font_idx
< 0 || size_idx
< 0 || size_idx
>= di
->nFont
)
525 WCUSER_FillLogFont(&lf
, di
->font
[size_idx
].faceName
,
526 di
->font
[size_idx
].height
, di
->font
[size_idx
].weight
);
527 hFont
= WCUSER_CopyFont(&config
, PRIVATE(di
->data
)->hWnd
, &lf
);
528 if (!hFont
) return FALSE
;
530 if (config
.cell_height
!= di
->font
[size_idx
].height
)
531 WINE_TRACE("select_font: mismatched heights (%u<>%u)\n",
532 config
.cell_height
, di
->font
[size_idx
].height
);
533 hOldFont
= (HFONT
)SendDlgItemMessage(di
->hDlg
, IDC_FNT_PREVIEW
, WM_GETFONT
, 0L, 0L);
535 SendDlgItemMessage(di
->hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, (DWORD
)hFont
, TRUE
);
536 if (hOldFont
) DeleteObject(hOldFont
);
538 LoadString(GetModuleHandle(NULL
), IDS_FNT_DISPLAY
, fmt
, sizeof(fmt
) / sizeof(WCHAR
));
539 wsprintf(buf
, fmt
, config
.cell_width
, config
.cell_height
);
541 SendDlgItemMessage(di
->hDlg
, IDC_FNT_FONT_INFO
, WM_SETTEXT
, 0, (LPARAM
)buf
);
546 /******************************************************************
549 * fills the size list box according to selected family in font LB
551 static BOOL
fill_list_size(struct dialog_info
* di
, BOOL doInit
)
554 WCHAR lfFaceName
[LF_FACESIZE
];
556 idx
= SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETCURSEL
, 0L, 0L);
557 if (idx
< 0) return FALSE
;
559 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_GETTEXT
, idx
, (LPARAM
)lfFaceName
);
560 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_RESETCONTENT
, 0L, 0L);
561 if (di
->font
) HeapFree(GetProcessHeap(), 0, di
->font
);
565 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, lfFaceName
, font_enum_size
, (LPARAM
)di
);
571 for (idx
= 0; idx
< di
->nFont
; idx
++)
573 if (!lstrcmp(di
->font
[idx
].faceName
, di
->config
->face_name
) &&
574 di
->font
[idx
].height
== di
->config
->cell_height
&&
575 di
->font
[idx
].weight
== di
->config
->font_weight
)
577 if (ref
== -1) ref
= idx
;
578 else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref
, idx
);
581 idx
= (ref
== -1) ? 0 : ref
;
585 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_SIZE
, LB_SETCURSEL
, idx
, 0L);
590 /******************************************************************
595 static BOOL
fill_list_font(struct dialog_info
* di
)
597 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_RESETCONTENT
, 0L, 0L);
598 EnumFontFamilies(PRIVATE(di
->data
)->hMemDC
, NULL
, font_enum
, (LPARAM
)di
);
599 if (SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SELECTSTRING
,
600 (WPARAM
)-1, (LPARAM
)di
->config
->face_name
) == LB_ERR
)
601 SendDlgItemMessage(di
->hDlg
, IDC_FNT_LIST_FONT
, LB_SETCURSEL
, 0L, 0L);
602 fill_list_size(di
, TRUE
);
606 /******************************************************************
609 * Dialog proc for the Font property sheet
611 static BOOL WINAPI
WCUSER_FontDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
613 struct dialog_info
* di
;
618 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
620 SetWindowLong(hDlg
, DWL_USER
, (DWORD
)di
);
621 /* remove dialog from this control, font will be reset when listboxes are filled */
622 SendDlgItemMessage(hDlg
, IDC_FNT_PREVIEW
, WM_SETFONT
, 0L, 0L);
624 SetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0, (di
->config
->def_attr
>> 4) & 0x0F);
625 SetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0, di
->config
->def_attr
& 0x0F);
628 di
= (struct dialog_info
*)GetWindowLong(hDlg
, DWL_USER
);
629 switch (LOWORD(wParam
))
631 case IDC_FNT_LIST_FONT
:
632 if (HIWORD(wParam
) == LBN_SELCHANGE
)
634 fill_list_size(di
, FALSE
);
637 case IDC_FNT_LIST_SIZE
:
638 if (HIWORD(wParam
) == LBN_SELCHANGE
)
647 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
650 di
= (struct dialog_info
*)GetWindowLong(hDlg
, DWL_USER
);
657 val
= SendDlgItemMessage(hDlg
, IDC_FNT_LIST_SIZE
, LB_GETCURSEL
, 0L, 0L);
659 if (val
< di
->nFont
) (di
->apply
)(di
, hDlg
, WCUSER_ApplyToFont
, val
);
661 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToAttribute
,
662 (GetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_BK
), 0) << 4) |
663 GetWindowLong(GetDlgItem(hDlg
, IDC_FNT_COLOR_FG
), 0));
665 SetWindowLong(hDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
678 /******************************************************************
679 * WCUSER_ConfigDlgProc
681 * Dialog proc for the config property sheet
683 static BOOL WINAPI
WCUSER_ConfigDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
685 struct dialog_info
* di
;
690 di
= (struct dialog_info
*)((PROPSHEETPAGEA
*)lParam
)->lParam
;
692 SetWindowLong(hDlg
, DWL_USER
, (DWORD
)di
);
693 SetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, di
->config
->sb_width
, FALSE
);
694 SetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, di
->config
->sb_height
, FALSE
);
695 SetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, di
->config
->win_width
, FALSE
);
696 SetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, di
->config
->win_height
, FALSE
);
699 di
= (struct dialog_info
*)GetWindowLong(hDlg
, DWL_USER
);
700 switch (LOWORD(wParam
))
706 NMHDR
* nmhdr
= (NMHDR
*)lParam
;
711 di
= (struct dialog_info
*)GetWindowLong(hDlg
, DWL_USER
);
718 sb
.X
= GetDlgItemInt(hDlg
, IDC_CNF_SB_WIDTH
, &st_w
, FALSE
);
719 sb
.Y
= GetDlgItemInt(hDlg
, IDC_CNF_SB_HEIGHT
, &st_h
, FALSE
);
720 if (st_w
&& st_h
&& (sb
.X
!= di
->config
->sb_width
|| sb
.Y
!= di
->config
->sb_height
))
722 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToBufferSize
, (DWORD
)&sb
);
725 pos
.Right
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_WIDTH
, &st_w
, FALSE
);
726 pos
.Bottom
= GetDlgItemInt(hDlg
, IDC_CNF_WIN_HEIGHT
, &st_h
, FALSE
);
728 (pos
.Right
!= di
->config
->win_width
|| pos
.Bottom
!= di
->config
->win_height
))
730 pos
.Left
= pos
.Top
= 0;
731 pos
.Right
--; pos
.Bottom
--;
732 (di
->apply
)(di
, hDlg
, WCUSER_ApplyToWindow
, (DWORD
)&pos
);
734 SetWindowLong(hDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
747 /******************************************************************
748 * WCUSER_GetProperties
750 * Runs the dialog box to set up the winconsole options
752 BOOL
WCUSER_GetProperties(struct inner_data
* data
, BOOL current
)
754 HPROPSHEETPAGE psPage
[3];
756 PROPSHEETHEADER psHead
;
759 static const WCHAR szFntPreview
[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
760 static const WCHAR szColorPreview
[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
761 struct dialog_info di
;
763 InitCommonControls();
768 di
.config
= &data
->curcfg
;
769 di
.apply
= WCUSER_ApplyCurrent
;
773 di
.config
= &data
->defcfg
;
774 di
.apply
= WCUSER_ApplyDefault
;
780 wndclass
.lpfnWndProc
= WCUSER_FontPreviewProc
;
781 wndclass
.cbClsExtra
= 0;
782 wndclass
.cbWndExtra
= 4; /* for hFont */
783 wndclass
.hInstance
= GetModuleHandle(NULL
);
785 wndclass
.hCursor
= LoadCursor(0, IDC_ARROW
);
786 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
787 wndclass
.lpszMenuName
= NULL
;
788 wndclass
.lpszClassName
= szFntPreview
;
789 RegisterClass(&wndclass
);
792 wndclass
.lpfnWndProc
= WCUSER_ColorPreviewProc
;
793 wndclass
.cbClsExtra
= 0;
794 wndclass
.cbWndExtra
= sizeof(DWORD
);
795 wndclass
.hInstance
= GetModuleHandle(NULL
);
797 wndclass
.hCursor
= LoadCursor(0, IDC_ARROW
);
798 wndclass
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
799 wndclass
.lpszMenuName
= NULL
;
800 wndclass
.lpszClassName
= szColorPreview
;
801 RegisterClass(&wndclass
);
803 memset(&psp
, 0, sizeof(psp
));
804 psp
.dwSize
= sizeof(psp
);
806 psp
.hInstance
= wndclass
.hInstance
;
807 psp
.lParam
= (LPARAM
)&di
;
809 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_OPTION
);
810 psp
.pfnDlgProc
= WCUSER_OptionDlgProc
;
811 psPage
[0] = CreatePropertySheetPage(&psp
);
813 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_FONT
);
814 psp
.pfnDlgProc
= WCUSER_FontDlgProc
;
815 psPage
[1] = CreatePropertySheetPage(&psp
);
817 psp
.u
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
818 psp
.pfnDlgProc
= WCUSER_ConfigDlgProc
;
819 psPage
[2] = CreatePropertySheetPage(&psp
);
821 memset(&psHead
, 0, sizeof(psHead
));
822 psHead
.dwSize
= sizeof(psHead
);
824 if (!LoadString(GetModuleHandle(NULL
),
825 (current
) ? IDS_DLG_TIT_CURRENT
: IDS_DLG_TIT_DEFAULT
,
826 buff
, sizeof(buff
) / sizeof(buff
[0])))
836 psHead
.pszCaption
= buff
;
838 psHead
.hwndParent
= PRIVATE(data
)->hWnd
;
839 psHead
.u3
.phpage
= psPage
;
841 PropertySheet(&psHead
);