For a radio button even if the initial style includes WS_TABSTOP the
[wine/wine64.git] / programs / wineconsole / dialog.c
blob4861254c78296639b5b14c17c5a8579d94a64ee3
1 /* dialog management for wineconsole
2 * USER32 backend
3 * (c) 2001 Eric Pouech
4 */
6 #include <stdio.h>
7 #include "commctrl.h"
8 #include "prsht.h"
9 #include "winecon_user.h"
11 /* FIXME: so far, part of the code is made in ASCII because the Uncode property sheet functions
12 * are not implemented yet
15 enum WCUSER_ApplyTo {
16 /* Prop sheet CFG */
17 WCUSER_ApplyToCursorSize,
18 WCUSER_ApplyToHistorySize, WCUSER_ApplyToHistoryMode, WCUSER_ApplyToMenuMask,
19 /* Prop sheet FNT */
20 WCUSER_ApplyToFont, WCUSER_ApplyToAttribute,
21 /* Prop sheep CNF */
22 WCUSER_ApplyToBufferSize, WCUSER_ApplyToWindow
25 struct dialog_info
27 struct config_data* config; /* pointer to configuration used for dialog box */
28 struct inner_data* data; /* pointer to current winecon info */
29 HWND hDlg; /* handle to active propsheet */
30 int nFont; /* number of font size in size LB */
31 struct font_info
33 TEXTMETRIC tm;
34 LOGFONT lf;
35 } *font; /* array of nFont. index sync'ed with SIZE LB */
36 void (*apply)(struct dialog_info*, HWND, enum WCUSER_ApplyTo, DWORD);
39 /******************************************************************
40 * WCUSER_ApplyDefault
44 static void WCUSER_ApplyDefault(struct dialog_info* di, HWND hDlg, enum WCUSER_ApplyTo apply, DWORD val)
46 switch (apply)
48 case WCUSER_ApplyToCursorSize:
49 case WCUSER_ApplyToHistorySize:
50 case WCUSER_ApplyToHistoryMode:
51 case WCUSER_ApplyToBufferSize:
52 case WCUSER_ApplyToWindow:
53 /* not saving those for now... */
54 break;
55 case WCUSER_ApplyToMenuMask:
56 di->config->menu_mask = val;
57 break;
58 case WCUSER_ApplyToFont:
59 WCUSER_CopyFont(di->config, &di->font[val].lf);
60 break;
61 case WCUSER_ApplyToAttribute:
62 di->config->def_attr = val;
63 break;
65 WINECON_RegSave(di->config);
68 /******************************************************************
69 * WCUSER_ApplyCurrent
73 static void WCUSER_ApplyCurrent(struct dialog_info* di, HWND hDlg, enum WCUSER_ApplyTo apply, DWORD val)
75 switch (apply)
77 case WCUSER_ApplyToCursorSize:
79 CONSOLE_CURSOR_INFO cinfo;
80 cinfo.dwSize = val;
81 cinfo.bVisible = di->config->cursor_visible;
82 /* this shall update (through notif) curcfg */
83 SetConsoleCursorInfo(di->data->hConOut, &cinfo);
85 break;
86 case WCUSER_ApplyToHistorySize:
87 di->config->history_size = val;
88 WINECON_SetHistorySize(di->data->hConIn, val);
89 break;
90 case WCUSER_ApplyToHistoryMode:
91 WINECON_SetHistoryMode(di->data->hConIn, val);
92 break;
93 case WCUSER_ApplyToMenuMask:
94 di->config->menu_mask = val;
95 break;
96 case WCUSER_ApplyToFont:
97 WCUSER_SetFont(di->data, &di->font[val].lf);
98 break;
99 case WCUSER_ApplyToAttribute:
100 di->config->def_attr = val;
101 SetConsoleTextAttribute(di->data->hConOut, val);
102 break;
103 case WCUSER_ApplyToBufferSize:
104 /* this shall update (through notif) curcfg */
105 SetConsoleScreenBufferSize(di->data->hConOut, *(COORD*)val);
106 break;
107 case WCUSER_ApplyToWindow:
108 /* this shall update (through notif) curcfg */
109 SetConsoleWindowInfo(di->data->hConOut, FALSE, (SMALL_RECT*)val);
110 break;
114 /******************************************************************
115 * WCUSER_OptionDlgProc
117 * Dialog prop for the option property sheet
119 static BOOL WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
121 struct dialog_info* di;
122 unsigned idc;
124 switch (msg)
126 case WM_INITDIALOG:
127 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
128 di->hDlg = hDlg;
129 SetWindowLongA(hDlg, DWL_USER, (DWORD)di);
130 if (di->config->cursor_size <= 25) idc = IDC_OPT_CURSOR_SMALL;
131 else if (di->config->cursor_size <= 50) idc = IDC_OPT_CURSOR_MEDIUM;
132 else idc = IDC_OPT_CURSOR_LARGE;
133 SendDlgItemMessage(hDlg, idc, BM_SETCHECK, BST_CHECKED, 0L);
134 SetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, WINECON_GetHistorySize(di->data->hConIn), FALSE);
135 if (WINECON_GetHistoryMode(di->data->hConIn))
136 SendDlgItemMessage(hDlg, IDC_OPT_HIST_DOUBLE, BM_SETCHECK, BST_CHECKED, 0L);
137 SendDlgItemMessage(hDlg, IDC_OPT_CONF_CTRL, BM_SETCHECK,
138 (di->config->menu_mask & MK_CONTROL) ? BST_CHECKED : BST_UNCHECKED, 0L);
139 SendDlgItemMessage(hDlg, IDC_OPT_CONF_SHIFT, BM_SETCHECK,
140 (di->config->menu_mask & MK_SHIFT) ? BST_CHECKED : BST_UNCHECKED, 0L);
141 return FALSE; /* because we set the focus */
142 case WM_COMMAND:
143 break;
144 case WM_NOTIFY:
146 NMHDR* nmhdr = (NMHDR*)lParam;
147 DWORD val;
148 BOOL done;
150 di = (struct dialog_info*)GetWindowLongA(hDlg, DWL_USER);
151 switch (nmhdr->code)
153 case PSN_SETACTIVE:
154 /* needed in propsheet to keep properly the selected radio button
155 * otherwise, the focus would be set to the first tab stop in the
156 * propsheet, which would always activate the first radio button
158 if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED)
159 idc = IDC_OPT_CURSOR_SMALL;
160 else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED)
161 idc = IDC_OPT_CURSOR_MEDIUM;
162 else
163 idc = IDC_OPT_CURSOR_LARGE;
164 PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, idc), TRUE);
165 di->hDlg = hDlg;
166 break;
167 case PSN_APPLY:
168 if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) val = 25;
169 else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) val = 50;
170 else val = 99;
171 (di->apply)(di, hDlg, WCUSER_ApplyToCursorSize, val);
173 val = GetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, &done, FALSE);
174 if (done) (di->apply)(di, hDlg, WCUSER_ApplyToHistorySize, val);
176 (di->apply)(di, hDlg, WCUSER_ApplyToHistoryMode,
177 IsDlgButtonChecked(hDlg, IDC_OPT_HIST_DOUBLE) & BST_CHECKED);
179 val = 0;
180 if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_CTRL) & BST_CHECKED) val |= MK_CONTROL;
181 if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_SHIFT) & BST_CHECKED) val |= MK_SHIFT;
182 (di->apply)(di, hDlg, WCUSER_ApplyToMenuMask, val);
183 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
184 return TRUE;
185 default:
186 return FALSE;
188 break;
190 default:
191 return FALSE;
193 return TRUE;
196 /******************************************************************
197 * WCUSER_FontPreviewProc
199 * Window proc for font previewer in font property sheet
201 static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
203 switch (msg)
205 case WM_PAINT:
207 PAINTSTRUCT ps;
208 int font_idx;
209 int size_idx;
210 struct dialog_info* di;
212 di = (struct dialog_info*)GetWindowLong(GetParent(hWnd), DWL_USER);
213 BeginPaint(hWnd, &ps);
215 font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
216 size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
218 if (font_idx >= 0 && size_idx >= 0 && size_idx < di->nFont)
220 HFONT hFont, hOldFont;
221 WCHAR buf1[256];
222 WCHAR buf2[256];
223 int len1, len2;
225 hFont = CreateFontIndirect(&di->font[size_idx].lf);
226 len1 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_1,
227 buf1, sizeof(buf1) / sizeof(WCHAR));
228 len2 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_2,
229 buf2, sizeof(buf2) / sizeof(WCHAR));
230 buf1[len1] = buf2[len2] = 0;
231 if (hFont && len1)
233 hOldFont = SelectObject(ps.hdc, hFont);
234 SetBkColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_BK), 0)]);
235 SetTextColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_FG), 0)]);
236 TextOut(ps.hdc, 0, 0, buf1, len1);
237 if (len2)
238 TextOut(ps.hdc, 0, di->font[size_idx].tm.tmHeight, buf2, len2);
239 SelectObject(ps.hdc, hOldFont);
240 DeleteObject(hFont);
243 EndPaint(hWnd, &ps);
245 break;
246 default:
247 return DefWindowProc(hWnd, msg, wParam, lParam);
249 return 0L;
252 /******************************************************************
253 * WCUSER_ColorPreviewProc
255 * Window proc for color previewer in font property sheet
257 static LRESULT WINAPI WCUSER_ColorPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
259 switch (msg)
261 case WM_PAINT:
263 PAINTSTRUCT ps;
264 int i, step;
265 RECT client, r;
266 HBRUSH hbr;
268 BeginPaint(hWnd, &ps);
269 GetClientRect(hWnd, &client);
270 step = client.right / 8;
272 for (i = 0; i < 16; i++)
274 r.top = (i / 8) * (client.bottom / 2);
275 r.bottom = r.top + client.bottom / 2;
276 r.left = (i & 7) * step;
277 r.right = r.left + step;
278 hbr = CreateSolidBrush(WCUSER_ColorMap[i]);
279 FillRect(ps.hdc, &r, hbr);
280 DeleteObject(hbr);
281 if (GetWindowLong(hWnd, 0) == i)
283 HPEN hOldPen;
284 int i = 2;
286 hOldPen = SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
287 r.right--; r.bottom--;
288 for (;;)
290 MoveToEx(ps.hdc, r.left, r.bottom, NULL);
291 LineTo(ps.hdc, r.left, r.top);
292 LineTo(ps.hdc, r.right, r.top);
293 SelectObject(ps.hdc, GetStockObject(BLACK_PEN));
294 LineTo(ps.hdc, r.right, r.bottom);
295 LineTo(ps.hdc, r.left, r.bottom);
297 if (--i == 0) break;
298 r.left++; r.top++; r.right--; r.bottom--;
299 SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
301 SelectObject(ps.hdc, hOldPen);
304 EndPaint(hWnd, &ps);
305 break;
307 case WM_LBUTTONDOWN:
309 int i, step;
310 RECT client;
312 GetClientRect(hWnd, &client);
313 step = client.right / 8;
314 i = (HIWORD(lParam) >= client.bottom / 2) ? 8 : 0;
315 i += LOWORD(lParam) / step;
316 SetWindowLong(hWnd, 0, i);
317 InvalidateRect(GetDlgItem(GetParent(hWnd), IDC_FNT_PREVIEW), NULL, FALSE);
318 InvalidateRect(hWnd, NULL, FALSE);
320 break;
321 default:
322 return DefWindowProc(hWnd, msg, wParam, lParam);
324 return 0L;
327 /******************************************************************
328 * font_enum
330 * enumerates all the font names with at least one valid font
332 static int CALLBACK font_enum_size2(const LOGFONT* lf, const TEXTMETRIC* tm,
333 DWORD FontType, LPARAM lParam)
335 struct dialog_info* di = (struct dialog_info*)lParam;
337 if (WCUSER_ValidateFontMetric(di->data, tm))
339 di->nFont++;
341 return 1;
344 static int CALLBACK font_enum(const LOGFONT* lf, const TEXTMETRIC* tm,
345 DWORD FontType, LPARAM lParam)
347 struct dialog_info* di = (struct dialog_info*)lParam;
348 HDC hdc;
350 if (WCUSER_ValidateFont(di->data, lf) && (hdc = GetDC(di->hDlg)))
352 di->nFont = 0;
353 EnumFontFamilies(hdc, lf->lfFaceName, font_enum_size2, (LPARAM)di);
354 if (di->nFont)
356 int idx;
357 idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING,
358 0, (LPARAM)lf->lfFaceName);
360 ReleaseDC(di->hDlg, hdc);
362 return 1;
365 /******************************************************************
366 * font_enum_size
370 static int CALLBACK font_enum_size(const LOGFONT* lf, const TEXTMETRIC* tm,
371 DWORD FontType, LPARAM lParam)
373 struct dialog_info* di = (struct dialog_info*)lParam;
375 if (WCUSER_ValidateFontMetric(di->data, tm))
377 WCHAR buf[32];
378 static const WCHAR fmt[] = {'%','l','d',0};
379 int idx;
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].tm.tmHeight; idx++);
385 if (idx < di->nFont &&
386 tm->tmHeight == di->font[idx].tm.tmHeight &&
387 tm->tmMaxCharWidth == di->font[idx].tm.tmMaxCharWidth)
389 /* we already have an entry with the same width & height...
390 * try to see which TEXTMETRIC (old or new) we should keep...
392 if (di->font[idx].tm.tmWeight != tm->tmWeight)
394 /* get the weight closer to 400, the default value */
395 if (abs(tm->tmWeight - 400) < abs(di->font[idx].tm.tmWeight - 400))
397 di->font[idx].tm = *tm;
400 /* else FIXME: skip the new tm for now */
402 else
404 /* here we need to add the new entry */
405 wsprintfW(buf, fmt, tm->tmHeight);
406 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, idx, (LPARAM)buf);
408 /* now grow our arrays and insert to values at the same index than in the list box */
409 di->font = HeapReAlloc(GetProcessHeap(), 0, di->font, sizeof(*di->font) * (di->nFont + 1));
410 if (idx != di->nFont)
411 memmove(&di->font[idx + 1], &di->font[idx], (di->nFont - idx) * sizeof(*di->font));
412 di->font[idx].tm = *tm;
413 di->font[idx].lf = *lf;
414 di->nFont++;
417 return 1;
420 /******************************************************************
421 * select_font
425 static BOOL select_font(struct dialog_info* di)
427 int idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
428 WCHAR buf[256];
429 WCHAR fmt[128];
431 if (idx < 0 || idx >= di->nFont)
432 return FALSE;
434 LoadString(GetModuleHandle(NULL), IDS_FNT_DISPLAY, fmt, sizeof(fmt) / sizeof(WCHAR));
435 wsprintfW(buf, fmt, di->font[idx].tm.tmMaxCharWidth, di->font[idx].tm.tmHeight);
437 SendDlgItemMessage(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf);
438 InvalidateRect(GetDlgItem(di->hDlg, IDC_FNT_PREVIEW), NULL, TRUE);
439 UpdateWindow(GetDlgItem(di->hDlg, IDC_FNT_PREVIEW));
440 return TRUE;
443 /******************************************************************
444 * fill_list_size
446 * fills the size list box according to selected family in font LB
448 static BOOL fill_list_size(struct dialog_info* di, BOOL doInit)
450 HDC hdc;
451 int idx;
452 WCHAR lfFaceName[LF_FACESIZE];
454 idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
455 if (idx < 0) return FALSE;
457 hdc = GetDC(di->hDlg);
458 if (!hdc) return FALSE;
460 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName);
461 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L);
462 if (di->font) HeapFree(GetProcessHeap(), 0, di->font);
463 di->nFont = 0;
464 di->font = NULL;
466 EnumFontFamilies(hdc, lfFaceName, font_enum_size, (LPARAM)di);
467 ReleaseDC(di->hDlg, hdc);
469 if (doInit)
471 for (idx = 0; idx < di->nFont; idx++)
473 if (WCUSER_AreFontsEqual(di->config, &di->font[idx].lf))
474 break;
476 if (idx == di->nFont) idx = 0;
478 else
479 idx = 0;
480 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_SETCURSEL, idx, 0L);
481 select_font(di);
482 return TRUE;
485 /******************************************************************
486 * fill_list_font
488 * Fills the font LB
490 static BOOL fill_list_font(struct dialog_info* di)
492 HDC hdc;
494 hdc = GetDC(di->hDlg);
495 if (!hdc) return FALSE;
497 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L);
498 EnumFontFamilies(hdc, NULL, font_enum, (LPARAM)di);
499 ReleaseDC(di->hDlg, hdc);
500 if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING,
501 (WPARAM)-1, (LPARAM)di->config->face_name) == LB_ERR)
502 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L);
503 fill_list_size(di, TRUE);
504 return TRUE;
507 /******************************************************************
508 * WCUSER_FontDlgProc
510 * Dialog proc for the Font property sheet
512 static BOOL WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
514 struct dialog_info* di;
516 switch (msg)
518 case WM_INITDIALOG:
519 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
520 di->hDlg = hDlg;
521 SetWindowLong(hDlg, DWL_USER, (DWORD)di);
522 fill_list_font(di);
523 SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0, di->config->def_attr & 0x0F);
524 SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0, (di->config->def_attr >> 4) & 0x0F);
525 break;
526 case WM_COMMAND:
527 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
528 switch (LOWORD(wParam))
530 case IDC_FNT_LIST_FONT:
531 if (HIWORD(wParam) == LBN_SELCHANGE)
533 fill_list_size(di, FALSE);
535 break;
536 case IDC_FNT_LIST_SIZE:
537 if (HIWORD(wParam) == LBN_SELCHANGE)
539 select_font(di);
541 break;
543 break;
544 case WM_NOTIFY:
546 NMHDR* nmhdr = (NMHDR*)lParam;
547 DWORD val;
549 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
550 switch (nmhdr->code)
552 case PSN_SETACTIVE:
553 di->hDlg = hDlg;
554 break;
555 case PSN_APPLY:
556 val = SendDlgItemMessage(hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
558 if (val < di->nFont) (di->apply)(di, hDlg, WCUSER_ApplyToFont, val);
560 (di->apply)(di, hDlg, WCUSER_ApplyToAttribute,
561 GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0) |
562 (GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0) << 4));
564 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
565 return TRUE;
566 default:
567 return FALSE;
569 break;
571 default:
572 return FALSE;
574 return TRUE;
577 /******************************************************************
578 * WCUSER_ConfigDlgProc
580 * Dialog proc for the config property sheet
582 static BOOL WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
584 struct dialog_info* di;
586 switch (msg)
588 case WM_INITDIALOG:
589 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
590 di->hDlg = hDlg;
591 SetWindowLong(hDlg, DWL_USER, (DWORD)di);
592 SetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, di->config->sb_width, FALSE);
593 SetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, di->config->sb_height, FALSE);
594 SetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, di->config->win_width, FALSE);
595 SetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, di->config->win_height, FALSE);
596 break;
597 case WM_COMMAND:
598 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
599 switch (LOWORD(wParam))
602 break;
603 case WM_NOTIFY:
605 NMHDR* nmhdr = (NMHDR*)lParam;
606 COORD sb;
607 SMALL_RECT pos;
608 BOOL st_w, st_h;
610 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
611 switch (nmhdr->code)
613 case PSN_SETACTIVE:
614 di->hDlg = hDlg;
615 break;
616 case PSN_APPLY:
617 sb.X = GetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, &st_w, FALSE);
618 sb.Y = GetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, &st_h, FALSE);
619 if (st_w && st_h && (sb.X != di->config->sb_width || sb.Y != di->config->sb_height))
621 (di->apply)(di, hDlg, WCUSER_ApplyToBufferSize, (DWORD)&sb);
624 pos.Right = GetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, &st_w, FALSE);
625 pos.Bottom = GetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, &st_h, FALSE);
626 if (st_w && st_h &&
627 (pos.Right != di->config->win_width || pos.Bottom != di->config->win_height))
629 pos.Left = pos.Top = 0;
630 pos.Right--; pos.Bottom--;
631 (di->apply)(di, hDlg, WCUSER_ApplyToWindow, (DWORD)&pos);
633 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
634 return TRUE;
635 default:
636 return FALSE;
638 break;
640 default:
641 return FALSE;
643 return TRUE;
646 /******************************************************************
647 * WCUSER_GetProperties
649 * Runs the dialog box to set up the winconsole options
651 BOOL WCUSER_GetProperties(struct inner_data* data, BOOL current)
653 HPROPSHEETPAGE psPage[3];
654 PROPSHEETPAGEA psp;
655 PROPSHEETHEADERA psHead;
656 WNDCLASS wndclass;
657 static const WCHAR szFntPreview[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
658 static const WCHAR szColorPreview[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
659 struct dialog_info di;
660 CHAR buff[256];
662 InitCommonControls();
664 di.data = data;
665 if (current)
667 di.config = &data->curcfg;
668 di.apply = WCUSER_ApplyCurrent;
670 else
672 di.config = &data->defcfg;
673 di.apply = WCUSER_ApplyDefault;
675 di.nFont = 0;
676 di.font = NULL;
678 wndclass.style = 0;
679 wndclass.lpfnWndProc = WCUSER_FontPreviewProc;
680 wndclass.cbClsExtra = 0;
681 wndclass.cbWndExtra = 0;
682 wndclass.hInstance = GetModuleHandle(NULL);
683 wndclass.hIcon = 0;
684 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
685 wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
686 wndclass.lpszMenuName = NULL;
687 wndclass.lpszClassName = szFntPreview;
688 RegisterClass(&wndclass);
690 wndclass.style = 0;
691 wndclass.lpfnWndProc = WCUSER_ColorPreviewProc;
692 wndclass.cbClsExtra = 0;
693 wndclass.cbWndExtra = sizeof(DWORD);
694 wndclass.hInstance = GetModuleHandle(NULL);
695 wndclass.hIcon = 0;
696 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
697 wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
698 wndclass.lpszMenuName = NULL;
699 wndclass.lpszClassName = szColorPreview;
700 RegisterClass(&wndclass);
702 memset(&psp, 0, sizeof(psp));
703 psp.dwSize = sizeof(psp);
704 psp.dwFlags = 0;
705 psp.hInstance = wndclass.hInstance;
706 psp.lParam = (LPARAM)&di;
708 psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_OPTION);
709 psp.pfnDlgProc = WCUSER_OptionDlgProc;
710 psPage[0] = CreatePropertySheetPageA(&psp);
712 psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_FONT);
713 psp.pfnDlgProc = WCUSER_FontDlgProc;
714 psPage[1] = CreatePropertySheetPageA(&psp);
716 psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_CONFIG);
717 psp.pfnDlgProc = WCUSER_ConfigDlgProc;
718 psPage[2] = CreatePropertySheetPageA(&psp);
720 memset(&psHead, 0, sizeof(psHead));
721 psHead.dwSize = sizeof(psHead);
723 if (!LoadStringA(GetModuleHandle(NULL),
724 (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT,
725 buff, sizeof(buff)))
726 strcpy(buff, "Setup");
727 psHead.pszCaption = buff;
728 psHead.nPages = 3;
729 psHead.hwndParent = PRIVATE(data)->hWnd;
730 psHead.u3.phpage = psPage;
732 PropertySheetA(&psHead);
734 return TRUE;