Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 1 | /* dialog management for wineconsole |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 2 | * USER32 backend |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 3 | * Copyright (c) 2001, 2002 Eric Pouech |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 4 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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 |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <stdio.h> |
James Juran | 424a080 | 2002-01-01 00:14:02 +0000 | [diff] [blame] | 21 | #include <stdlib.h> |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 22 | #include <stdarg.h> |
Alexandre Julliard | ae4311c | 2003-01-07 23:11:12 +0000 | [diff] [blame] | 23 | |
| 24 | #define NONAMELESSUNION |
| 25 | #define NONAMELESSSTRUCT |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 26 | #include "windef.h" |
| 27 | #include "winbase.h" |
| 28 | #include "wingdi.h" |
| 29 | #include "winuser.h" |
| 30 | #include "winnls.h" |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 31 | #include "commctrl.h" |
| 32 | #include "prsht.h" |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 33 | #include "winecon_user.h" |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 34 | |
Eric Pouech | e53cd36 | 2002-05-14 21:45:13 +0000 | [diff] [blame] | 35 | #include "wine/debug.h" |
| 36 | |
| 37 | WINE_DEFAULT_DEBUG_CHANNEL(wineconsole); |
| 38 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 39 | struct dialog_info |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 40 | { |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 41 | struct config_data config; /* configuration used for dialog box */ |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 42 | struct inner_data* data; /* pointer to current winecon info */ |
| 43 | HWND hDlg; /* handle to active propsheet */ |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 44 | int nFont; /* number of font size in size LB */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 45 | struct font_info |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 46 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 47 | UINT height; |
| 48 | UINT weight; |
| 49 | WCHAR faceName[LF_FACESIZE]; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 50 | } *font; /* array of nFont. index sync'ed with SIZE LB */ |
| 51 | }; |
| 52 | |
| 53 | /****************************************************************** |
| 54 | * WCUSER_OptionDlgProc |
| 55 | * |
| 56 | * Dialog prop for the option property sheet |
| 57 | */ |
| 58 | static BOOL WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) |
| 59 | { |
| 60 | struct dialog_info* di; |
| 61 | unsigned idc; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 62 | |
| 63 | switch (msg) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 64 | { |
| 65 | case WM_INITDIALOG: |
| 66 | di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; |
| 67 | di->hDlg = hDlg; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 68 | SetWindowLong(hDlg, DWL_USER, (DWORD)di); |
| 69 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 70 | if (di->config.cursor_size <= 25) idc = IDC_OPT_CURSOR_SMALL; |
| 71 | else if (di->config.cursor_size <= 50) idc = IDC_OPT_CURSOR_MEDIUM; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 72 | else idc = IDC_OPT_CURSOR_LARGE; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 73 | SendDlgItemMessage(hDlg, idc, BM_SETCHECK, BST_CHECKED, 0L); |
| 74 | SetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, WINECON_GetHistorySize(di->data->hConIn), FALSE); |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 75 | SendDlgItemMessage(hDlg, IDC_OPT_HIST_NODOUBLE, BM_SETCHECK, |
| 76 | (di->config.history_nodup) ? BST_CHECKED : BST_UNCHECKED, 0L); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 77 | SendDlgItemMessage(hDlg, IDC_OPT_CONF_CTRL, BM_SETCHECK, |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 78 | (di->config.menu_mask & MK_CONTROL) ? BST_CHECKED : BST_UNCHECKED, 0L); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 79 | SendDlgItemMessage(hDlg, IDC_OPT_CONF_SHIFT, BM_SETCHECK, |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 80 | (di->config.menu_mask & MK_SHIFT) ? BST_CHECKED : BST_UNCHECKED, 0L); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 81 | SendDlgItemMessage(hDlg, IDC_OPT_QUICK_EDIT, BM_SETCHECK, |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 82 | (di->config.quick_edit) ? BST_CHECKED : BST_UNCHECKED, 0L); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 83 | return FALSE; /* because we set the focus */ |
| 84 | case WM_COMMAND: |
| 85 | break; |
| 86 | case WM_NOTIFY: |
| 87 | { |
| 88 | NMHDR* nmhdr = (NMHDR*)lParam; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 89 | DWORD val; |
| 90 | BOOL done; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 91 | |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 92 | di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); |
| 93 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 94 | switch (nmhdr->code) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 95 | { |
| 96 | case PSN_SETACTIVE: |
| 97 | /* needed in propsheet to keep properly the selected radio button |
| 98 | * otherwise, the focus would be set to the first tab stop in the |
| 99 | * propsheet, which would always activate the first radio button |
| 100 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 101 | if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 102 | idc = IDC_OPT_CURSOR_SMALL; |
| 103 | else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) |
| 104 | idc = IDC_OPT_CURSOR_MEDIUM; |
| 105 | else |
| 106 | idc = IDC_OPT_CURSOR_LARGE; |
| 107 | PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, idc), TRUE); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 108 | di->hDlg = hDlg; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 109 | break; |
| 110 | case PSN_APPLY: |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 111 | if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) val = 25; |
| 112 | else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) val = 50; |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 113 | else val = 100; |
| 114 | di->config.cursor_size = val; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 115 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 116 | val = GetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, &done, FALSE); |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 117 | if (done) di->config.history_size = val; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 118 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 119 | val = (IsDlgButtonChecked(hDlg, IDC_OPT_HIST_NODOUBLE) & BST_CHECKED) ? TRUE : FALSE; |
| 120 | di->config.history_nodup = val; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 121 | |
| 122 | val = 0; |
| 123 | if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_CTRL) & BST_CHECKED) val |= MK_CONTROL; |
| 124 | if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_SHIFT) & BST_CHECKED) val |= MK_SHIFT; |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 125 | di->config.menu_mask = val; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 126 | |
| 127 | val = (IsDlgButtonChecked(hDlg, IDC_OPT_QUICK_EDIT) & BST_CHECKED) ? TRUE : FALSE; |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 128 | di->config.quick_edit = val; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 129 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 130 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 131 | return TRUE; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 132 | default: |
| 133 | return FALSE; |
| 134 | } |
| 135 | break; |
| 136 | } |
| 137 | default: |
| 138 | return FALSE; |
| 139 | } |
| 140 | return TRUE; |
| 141 | } |
| 142 | |
| 143 | /****************************************************************** |
| 144 | * WCUSER_FontPreviewProc |
| 145 | * |
| 146 | * Window proc for font previewer in font property sheet |
| 147 | */ |
| 148 | static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
| 149 | { |
| 150 | switch (msg) |
| 151 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 152 | case WM_CREATE: |
| 153 | SetWindowLong(hWnd, 0, 0); |
| 154 | break; |
| 155 | case WM_GETFONT: |
| 156 | return GetWindowLong(hWnd, 0); |
| 157 | case WM_SETFONT: |
| 158 | SetWindowLong(hWnd, 0, wParam); |
| 159 | if (LOWORD(lParam)) |
| 160 | { |
| 161 | InvalidateRect(hWnd, NULL, TRUE); |
| 162 | UpdateWindow(hWnd); |
| 163 | } |
| 164 | break; |
| 165 | case WM_DESTROY: |
| 166 | { |
| 167 | HFONT hFont = (HFONT)GetWindowLong(hWnd, 0L); |
| 168 | if (hFont) DeleteObject(hFont); |
| 169 | } |
| 170 | break; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 171 | case WM_PAINT: |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 172 | { |
| 173 | PAINTSTRUCT ps; |
| 174 | int font_idx; |
| 175 | int size_idx; |
| 176 | struct dialog_info* di; |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 177 | HFONT hFont, hOldFont; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 178 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 179 | di = (struct dialog_info*)GetWindowLong(GetParent(hWnd), DWL_USER); |
| 180 | BeginPaint(hWnd, &ps); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 181 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 182 | font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L); |
| 183 | size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 184 | |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 185 | hFont = (HFONT)GetWindowLong(hWnd, 0L); |
| 186 | if (hFont) |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 187 | { |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 188 | WCHAR buf1[256]; |
| 189 | WCHAR buf2[256]; |
| 190 | int len1, len2; |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 191 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 192 | len1 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_1, |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 193 | buf1, sizeof(buf1) / sizeof(WCHAR)); |
| 194 | len2 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_2, |
| 195 | buf2, sizeof(buf2) / sizeof(WCHAR)); |
| 196 | buf1[len1] = buf2[len2] = 0; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 197 | if (len1) |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 198 | { |
| 199 | hOldFont = SelectObject(ps.hdc, hFont); |
| 200 | SetBkColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_BK), 0)]); |
| 201 | SetTextColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_FG), 0)]); |
| 202 | TextOut(ps.hdc, 0, 0, buf1, len1); |
| 203 | if (len2) |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 204 | TextOut(ps.hdc, 0, di->font[size_idx].height, buf2, len2); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 205 | SelectObject(ps.hdc, hOldFont); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | EndPaint(hWnd, &ps); |
| 209 | } |
| 210 | break; |
| 211 | default: |
| 212 | return DefWindowProc(hWnd, msg, wParam, lParam); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 213 | } |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 214 | return 0L; |
| 215 | } |
| 216 | |
| 217 | /****************************************************************** |
| 218 | * WCUSER_ColorPreviewProc |
| 219 | * |
| 220 | * Window proc for color previewer in font property sheet |
| 221 | */ |
| 222 | static LRESULT WINAPI WCUSER_ColorPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
| 223 | { |
| 224 | switch (msg) |
| 225 | { |
| 226 | case WM_PAINT: |
| 227 | { |
| 228 | PAINTSTRUCT ps; |
| 229 | int i, step; |
| 230 | RECT client, r; |
| 231 | HBRUSH hbr; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 232 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 233 | BeginPaint(hWnd, &ps); |
| 234 | GetClientRect(hWnd, &client); |
| 235 | step = client.right / 8; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 236 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 237 | for (i = 0; i < 16; i++) |
| 238 | { |
| 239 | r.top = (i / 8) * (client.bottom / 2); |
| 240 | r.bottom = r.top + client.bottom / 2; |
| 241 | r.left = (i & 7) * step; |
| 242 | r.right = r.left + step; |
| 243 | hbr = CreateSolidBrush(WCUSER_ColorMap[i]); |
| 244 | FillRect(ps.hdc, &r, hbr); |
| 245 | DeleteObject(hbr); |
| 246 | if (GetWindowLong(hWnd, 0) == i) |
| 247 | { |
| 248 | HPEN hOldPen; |
| 249 | int i = 2; |
| 250 | |
| 251 | hOldPen = SelectObject(ps.hdc, GetStockObject(WHITE_PEN)); |
| 252 | r.right--; r.bottom--; |
| 253 | for (;;) |
| 254 | { |
| 255 | MoveToEx(ps.hdc, r.left, r.bottom, NULL); |
| 256 | LineTo(ps.hdc, r.left, r.top); |
| 257 | LineTo(ps.hdc, r.right, r.top); |
| 258 | SelectObject(ps.hdc, GetStockObject(BLACK_PEN)); |
| 259 | LineTo(ps.hdc, r.right, r.bottom); |
| 260 | LineTo(ps.hdc, r.left, r.bottom); |
| 261 | |
| 262 | if (--i == 0) break; |
| 263 | r.left++; r.top++; r.right--; r.bottom--; |
| 264 | SelectObject(ps.hdc, GetStockObject(WHITE_PEN)); |
| 265 | } |
| 266 | SelectObject(ps.hdc, hOldPen); |
| 267 | } |
| 268 | } |
| 269 | EndPaint(hWnd, &ps); |
| 270 | break; |
| 271 | } |
| 272 | case WM_LBUTTONDOWN: |
| 273 | { |
| 274 | int i, step; |
| 275 | RECT client; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 276 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 277 | GetClientRect(hWnd, &client); |
| 278 | step = client.right / 8; |
| 279 | i = (HIWORD(lParam) >= client.bottom / 2) ? 8 : 0; |
| 280 | i += LOWORD(lParam) / step; |
| 281 | SetWindowLong(hWnd, 0, i); |
| 282 | InvalidateRect(GetDlgItem(GetParent(hWnd), IDC_FNT_PREVIEW), NULL, FALSE); |
| 283 | InvalidateRect(hWnd, NULL, FALSE); |
| 284 | } |
| 285 | break; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 286 | default: |
| 287 | return DefWindowProc(hWnd, msg, wParam, lParam); |
| 288 | } |
| 289 | return 0L; |
| 290 | } |
| 291 | |
| 292 | /****************************************************************** |
| 293 | * font_enum |
| 294 | * |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 295 | * enumerates all the font names with at least one valid font |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 296 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 297 | static int CALLBACK font_enum_size2(const LOGFONT* lf, const TEXTMETRIC* tm, |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 298 | DWORD FontType, LPARAM lParam) |
| 299 | { |
| 300 | struct dialog_info* di = (struct dialog_info*)lParam; |
| 301 | |
Eric Pouech | e53cd36 | 2002-05-14 21:45:13 +0000 | [diff] [blame] | 302 | WCUSER_DumpTextMetric(tm, FontType); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 303 | if (WCUSER_ValidateFontMetric(di->data, tm, FontType)) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 304 | { |
| 305 | di->nFont++; |
| 306 | } |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 307 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 308 | return 1; |
| 309 | } |
| 310 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 311 | static int CALLBACK font_enum(const LOGFONT* lf, const TEXTMETRIC* tm, |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 312 | DWORD FontType, LPARAM lParam) |
| 313 | { |
| 314 | struct dialog_info* di = (struct dialog_info*)lParam; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 315 | |
Eric Pouech | 0587a47 | 2002-05-21 18:05:16 +0000 | [diff] [blame] | 316 | WCUSER_DumpLogFont("DlgFamily: ", lf, FontType); |
| 317 | if (WCUSER_ValidateFont(di->data, lf)) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 318 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 319 | if (FontType & RASTER_FONTTYPE) |
| 320 | { |
| 321 | di->nFont = 0; |
Eric Pouech | 0587a47 | 2002-05-21 18:05:16 +0000 | [diff] [blame] | 322 | EnumFontFamilies(PRIVATE(di->data)->hMemDC, lf->lfFaceName, font_enum_size2, (LPARAM)di); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 323 | } |
| 324 | else |
| 325 | di->nFont = 1; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 326 | |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 327 | if (di->nFont) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 328 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 329 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING, |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 330 | 0, (LPARAM)lf->lfFaceName); |
| 331 | } |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 332 | } |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 333 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 334 | return 1; |
| 335 | } |
| 336 | |
| 337 | /****************************************************************** |
| 338 | * font_enum_size |
| 339 | * |
| 340 | * |
| 341 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 342 | static int CALLBACK font_enum_size(const LOGFONT* lf, const TEXTMETRIC* tm, |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 343 | DWORD FontType, LPARAM lParam) |
| 344 | { |
| 345 | struct dialog_info* di = (struct dialog_info*)lParam; |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 346 | WCHAR buf[32]; |
| 347 | static const WCHAR fmt[] = {'%','l','d',0}; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 348 | |
Eric Pouech | e53cd36 | 2002-05-14 21:45:13 +0000 | [diff] [blame] | 349 | WCUSER_DumpTextMetric(tm, FontType); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 350 | if (di->nFont == 0 && !(FontType & RASTER_FONTTYPE)) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 351 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 352 | static const int sizes[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72}; |
| 353 | int i; |
| 354 | |
| 355 | di->nFont = sizeof(sizes) / sizeof(sizes[0]); |
| 356 | di->font = HeapAlloc(GetProcessHeap(), 0, di->nFont * sizeof(di->font[0])); |
| 357 | for (i = 0; i < di->nFont; i++) |
| 358 | { |
| 359 | /* drop sizes where window size wouldn't fit on screen */ |
| 360 | if (sizes[i] * di->data->curcfg.win_height > GetSystemMetrics(SM_CYSCREEN)) |
| 361 | { |
| 362 | di->nFont = i; |
| 363 | break; |
| 364 | } |
| 365 | di->font[i].height = sizes[i]; |
| 366 | di->font[i].weight = 400; |
| 367 | lstrcpy(di->font[i].faceName, lf->lfFaceName); |
| 368 | wsprintf(buf, fmt, sizes[i]); |
| 369 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, i, (LPARAM)buf); |
| 370 | } |
| 371 | /* don't need to enumerate other */ |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | if (WCUSER_ValidateFontMetric(di->data, tm, FontType)) |
| 376 | { |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 377 | int idx; |
| 378 | |
| 379 | /* we want the string to be sorted with a numeric order, not a lexicographic... |
| 380 | * do the job by hand... get where to insert the new string |
| 381 | */ |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 382 | for (idx = 0; idx < di->nFont && tm->tmHeight > di->font[idx].height; idx++); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 383 | while (idx < di->nFont && |
| 384 | tm->tmHeight == di->font[idx].height && |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 385 | tm->tmWeight > di->font[idx].weight) |
| 386 | idx++; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 387 | if (idx == di->nFont || |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 388 | tm->tmHeight != di->font[idx].height || |
| 389 | tm->tmWeight < di->font[idx].weight) |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 390 | { |
| 391 | /* here we need to add the new entry */ |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 392 | wsprintf(buf, fmt, tm->tmHeight); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 393 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, idx, (LPARAM)buf); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 394 | |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 395 | /* now grow our arrays and insert the values at the same index than in the list box */ |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 396 | di->font = HeapReAlloc(GetProcessHeap(), 0, di->font, sizeof(*di->font) * (di->nFont + 1)); |
| 397 | if (idx != di->nFont) |
| 398 | memmove(&di->font[idx + 1], &di->font[idx], (di->nFont - idx) * sizeof(*di->font)); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 399 | di->font[idx].height = tm->tmHeight; |
| 400 | di->font[idx].weight = tm->tmWeight; |
| 401 | lstrcpy(di->font[idx].faceName, lf->lfFaceName); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 402 | di->nFont++; |
| 403 | } |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 404 | } |
| 405 | return 1; |
| 406 | } |
| 407 | |
| 408 | /****************************************************************** |
| 409 | * select_font |
| 410 | * |
| 411 | * |
| 412 | */ |
| 413 | static BOOL select_font(struct dialog_info* di) |
| 414 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 415 | int font_idx, size_idx; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 416 | WCHAR buf[256]; |
| 417 | WCHAR fmt[128]; |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 418 | LOGFONT lf; |
| 419 | HFONT hFont, hOldFont; |
| 420 | struct config_data config; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 421 | |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 422 | font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L); |
| 423 | size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L); |
| 424 | |
| 425 | if (font_idx < 0 || size_idx < 0 || size_idx >= di->nFont) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 426 | return FALSE; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 427 | |
| 428 | WCUSER_FillLogFont(&lf, di->font[size_idx].faceName, |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 429 | di->font[size_idx].height, di->font[size_idx].weight); |
| 430 | hFont = WCUSER_CopyFont(&config, PRIVATE(di->data)->hWnd, &lf); |
| 431 | if (!hFont) return FALSE; |
| 432 | |
| 433 | if (config.cell_height != di->font[size_idx].height) |
Andreas Mohr | 029b948 | 2002-07-23 02:02:46 +0000 | [diff] [blame] | 434 | WINE_TRACE("mismatched heights (%u<>%u)\n", |
Eric Pouech | e53cd36 | 2002-05-14 21:45:13 +0000 | [diff] [blame] | 435 | config.cell_height, di->font[size_idx].height); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 436 | hOldFont = (HFONT)SendDlgItemMessage(di->hDlg, IDC_FNT_PREVIEW, WM_GETFONT, 0L, 0L); |
| 437 | |
| 438 | SendDlgItemMessage(di->hDlg, IDC_FNT_PREVIEW, WM_SETFONT, (DWORD)hFont, TRUE); |
| 439 | if (hOldFont) DeleteObject(hOldFont); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 440 | |
| 441 | LoadString(GetModuleHandle(NULL), IDS_FNT_DISPLAY, fmt, sizeof(fmt) / sizeof(WCHAR)); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 442 | wsprintf(buf, fmt, config.cell_width, config.cell_height); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 443 | |
| 444 | SendDlgItemMessage(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 445 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 446 | return TRUE; |
| 447 | } |
| 448 | |
| 449 | /****************************************************************** |
| 450 | * fill_list_size |
| 451 | * |
| 452 | * fills the size list box according to selected family in font LB |
| 453 | */ |
| 454 | static BOOL fill_list_size(struct dialog_info* di, BOOL doInit) |
| 455 | { |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 456 | int idx; |
| 457 | WCHAR lfFaceName[LF_FACESIZE]; |
| 458 | |
| 459 | idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L); |
| 460 | if (idx < 0) return FALSE; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 461 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 462 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName); |
| 463 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L); |
Michael Stefaniuc | 5ad7d85 | 2004-12-23 17:06:43 +0000 | [diff] [blame] | 464 | HeapFree(GetProcessHeap(), 0, di->font); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 465 | di->nFont = 0; |
| 466 | di->font = NULL; |
| 467 | |
Eric Pouech | 0587a47 | 2002-05-21 18:05:16 +0000 | [diff] [blame] | 468 | EnumFontFamilies(PRIVATE(di->data)->hMemDC, lfFaceName, font_enum_size, (LPARAM)di); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 469 | |
| 470 | if (doInit) |
| 471 | { |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 472 | int ref = -1; |
| 473 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 474 | for (idx = 0; idx < di->nFont; idx++) |
| 475 | { |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 476 | if (!lstrcmp(di->font[idx].faceName, di->config.face_name) && |
| 477 | di->font[idx].height == di->config.cell_height && |
| 478 | di->font[idx].weight == di->config.font_weight) |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 479 | { |
| 480 | if (ref == -1) ref = idx; |
Eric Pouech | e53cd36 | 2002-05-14 21:45:13 +0000 | [diff] [blame] | 481 | else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref, idx); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 482 | } |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 483 | } |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 484 | idx = (ref == -1) ? 0 : ref; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 485 | } |
| 486 | else |
| 487 | idx = 0; |
| 488 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_SETCURSEL, idx, 0L); |
| 489 | select_font(di); |
| 490 | return TRUE; |
| 491 | } |
| 492 | |
| 493 | /****************************************************************** |
| 494 | * fill_list_font |
| 495 | * |
| 496 | * Fills the font LB |
| 497 | */ |
| 498 | static BOOL fill_list_font(struct dialog_info* di) |
| 499 | { |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 500 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L); |
Eric Pouech | 0587a47 | 2002-05-21 18:05:16 +0000 | [diff] [blame] | 501 | EnumFontFamilies(PRIVATE(di->data)->hMemDC, NULL, font_enum, (LPARAM)di); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 502 | if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING, |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 503 | (WPARAM)-1, (LPARAM)di->config.face_name) == LB_ERR) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 504 | SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L); |
| 505 | fill_list_size(di, TRUE); |
| 506 | return TRUE; |
| 507 | } |
| 508 | |
| 509 | /****************************************************************** |
| 510 | * WCUSER_FontDlgProc |
| 511 | * |
| 512 | * Dialog proc for the Font property sheet |
| 513 | */ |
| 514 | static BOOL WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) |
| 515 | { |
| 516 | struct dialog_info* di; |
| 517 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 518 | switch (msg) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 519 | { |
| 520 | case WM_INITDIALOG: |
| 521 | di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; |
| 522 | di->hDlg = hDlg; |
| 523 | SetWindowLong(hDlg, DWL_USER, (DWORD)di); |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 524 | /* remove dialog from this control, font will be reset when listboxes are filled */ |
| 525 | SendDlgItemMessage(hDlg, IDC_FNT_PREVIEW, WM_SETFONT, 0L, 0L); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 526 | fill_list_font(di); |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 527 | SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0, (di->config.def_attr >> 4) & 0x0F); |
| 528 | SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0, di->config.def_attr & 0x0F); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 529 | break; |
| 530 | case WM_COMMAND: |
| 531 | di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 532 | switch (LOWORD(wParam)) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 533 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 534 | case IDC_FNT_LIST_FONT: |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 535 | if (HIWORD(wParam) == LBN_SELCHANGE) |
| 536 | { |
| 537 | fill_list_size(di, FALSE); |
| 538 | } |
| 539 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 540 | case IDC_FNT_LIST_SIZE: |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 541 | if (HIWORD(wParam) == LBN_SELCHANGE) |
| 542 | { |
| 543 | select_font(di); |
| 544 | } |
| 545 | break; |
| 546 | } |
| 547 | break; |
| 548 | case WM_NOTIFY: |
| 549 | { |
| 550 | NMHDR* nmhdr = (NMHDR*)lParam; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 551 | DWORD val; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 552 | |
| 553 | di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 554 | switch (nmhdr->code) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 555 | { |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 556 | case PSN_SETACTIVE: |
| 557 | di->hDlg = hDlg; |
| 558 | break; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 559 | case PSN_APPLY: |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 560 | val = SendDlgItemMessage(hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 561 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 562 | if (val < di->nFont) |
| 563 | { |
| 564 | LOGFONT lf; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 565 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 566 | WCUSER_FillLogFont(&lf, di->font[val].faceName, |
| 567 | di->font[val].height, di->font[val].weight); |
| 568 | DeleteObject(WCUSER_CopyFont(&di->config, |
| 569 | PRIVATE(di->data)->hWnd, &lf)); |
| 570 | } |
| 571 | |
| 572 | val = (GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0) << 4) | |
| 573 | GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0); |
| 574 | di->config.def_attr = val; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 575 | |
| 576 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 577 | return TRUE; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 578 | default: |
| 579 | return FALSE; |
| 580 | } |
| 581 | break; |
| 582 | } |
| 583 | default: |
| 584 | return FALSE; |
| 585 | } |
| 586 | return TRUE; |
| 587 | } |
| 588 | |
| 589 | /****************************************************************** |
| 590 | * WCUSER_ConfigDlgProc |
| 591 | * |
| 592 | * Dialog proc for the config property sheet |
| 593 | */ |
| 594 | static BOOL WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) |
| 595 | { |
| 596 | struct dialog_info* di; |
| 597 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 598 | switch (msg) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 599 | { |
| 600 | case WM_INITDIALOG: |
| 601 | di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; |
| 602 | di->hDlg = hDlg; |
| 603 | SetWindowLong(hDlg, DWL_USER, (DWORD)di); |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 604 | SetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, di->config.sb_width, FALSE); |
| 605 | SetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, di->config.sb_height, FALSE); |
| 606 | SetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, di->config.win_width, FALSE); |
| 607 | SetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, di->config.win_height, FALSE); |
| 608 | SendDlgItemMessage(hDlg, IDC_CNF_CLOSE_EXIT, BM_SETCHECK, |
| 609 | (di->config.exit_on_die) ? BST_CHECKED : BST_UNCHECKED, 0L); |
Eric Pouech | 1880800 | 2003-01-11 21:00:20 +0000 | [diff] [blame] | 610 | { |
Francois Gouget | ebf0eb3 | 2004-04-20 00:34:52 +0000 | [diff] [blame] | 611 | static const WCHAR s1[] = {'W','i','n','3','2',0}; |
| 612 | static const WCHAR s2[] = {'E','m','a','c','s',0}; |
Eric Pouech | 1880800 | 2003-01-11 21:00:20 +0000 | [diff] [blame] | 613 | |
| 614 | SendDlgItemMessage(hDlg, IDC_CNF_EDITION_MODE, CB_ADDSTRING, |
| 615 | 0, (LPARAM)s1); |
| 616 | SendDlgItemMessage(hDlg, IDC_CNF_EDITION_MODE, CB_ADDSTRING, |
| 617 | 0, (LPARAM)s2); |
| 618 | SendDlgItemMessage(hDlg, IDC_CNF_EDITION_MODE, CB_SETCURSEL, |
| 619 | di->config.edition_mode, 0); |
Eric Pouech | 1880800 | 2003-01-11 21:00:20 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 622 | break; |
| 623 | case WM_COMMAND: |
| 624 | di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 625 | switch (LOWORD(wParam)) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 626 | { |
| 627 | } |
| 628 | break; |
| 629 | case WM_NOTIFY: |
| 630 | { |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 631 | NMHDR* nmhdr = (NMHDR*)lParam; |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 632 | int win_w, win_h, sb_w, sb_h; |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 633 | BOOL st1, st2; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 634 | |
| 635 | di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 636 | switch (nmhdr->code) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 637 | { |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 638 | case PSN_SETACTIVE: |
| 639 | di->hDlg = hDlg; |
| 640 | break; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 641 | case PSN_APPLY: |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 642 | sb_w = GetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, &st1, FALSE); |
| 643 | sb_h = GetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, &st2, FALSE); |
| 644 | if (!st1 || ! st2) |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 645 | { |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 646 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID); |
| 647 | return TRUE; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 648 | } |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 649 | win_w = GetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, &st1, FALSE); |
| 650 | win_h = GetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, &st2, FALSE); |
| 651 | if (!st1 || !st2) |
| 652 | { |
| 653 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID); |
| 654 | return TRUE; |
| 655 | } |
| 656 | if (win_w > sb_w || win_h > sb_h) |
| 657 | { |
| 658 | WCHAR cap[256]; |
| 659 | WCHAR txt[256]; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 660 | |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 661 | LoadString(GetModuleHandle(NULL), IDS_DLG_TIT_ERROR, |
| 662 | cap, sizeof(cap) / sizeof(WCHAR)); |
| 663 | LoadString(GetModuleHandle(NULL), IDS_DLG_ERR_SBWINSIZE, |
| 664 | txt, sizeof(txt) / sizeof(WCHAR)); |
| 665 | |
| 666 | MessageBox(hDlg, txt, cap, MB_OK); |
| 667 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_INVALID); |
| 668 | return TRUE; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 669 | } |
Eric Pouech | f4d19e6 | 2003-02-24 20:41:08 +0000 | [diff] [blame] | 670 | di->config.win_width = win_w; |
| 671 | di->config.win_height = win_h; |
| 672 | di->config.sb_width = sb_w; |
| 673 | di->config.sb_height = sb_h; |
| 674 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 675 | di->config.exit_on_die = IsDlgButtonChecked(hDlg, IDC_CNF_CLOSE_EXIT) ? 1 : 0; |
Eric Pouech | 1880800 | 2003-01-11 21:00:20 +0000 | [diff] [blame] | 676 | di->config.edition_mode = SendDlgItemMessage(hDlg, IDC_CNF_EDITION_MODE, CB_GETCURSEL, |
| 677 | 0, 0); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 678 | SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 679 | return TRUE; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 680 | default: |
| 681 | return FALSE; |
| 682 | } |
| 683 | break; |
| 684 | } |
| 685 | default: |
| 686 | return FALSE; |
| 687 | } |
| 688 | return TRUE; |
| 689 | } |
| 690 | |
| 691 | /****************************************************************** |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 692 | * WCUSER_SaveDlgProc |
| 693 | * |
| 694 | * Dialog Procedure for choosing how to handle modification to the |
| 695 | * console settings. |
| 696 | */ |
| 697 | static BOOL WINAPI WCUSER_SaveDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) |
| 698 | { |
| 699 | switch (msg) |
| 700 | { |
| 701 | case WM_INITDIALOG: |
| 702 | break; |
| 703 | case WM_COMMAND: |
| 704 | switch (LOWORD(wParam)) |
| 705 | { |
| 706 | case IDOK: |
| 707 | EndDialog(hDlg, |
| 708 | (IsDlgButtonChecked(hDlg, IDC_SAV_SAVE) == BST_CHECKED) ? |
| 709 | IDC_SAV_SAVE : IDC_SAV_SESSION); |
| 710 | break; |
| 711 | case IDCANCEL: |
| 712 | EndDialog(hDlg, IDCANCEL); break; |
| 713 | } |
| 714 | break; |
| 715 | default: |
| 716 | return FALSE; |
| 717 | } |
| 718 | return TRUE; |
| 719 | } |
| 720 | |
| 721 | /****************************************************************** |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 722 | * WCUSER_GetProperties |
| 723 | * |
Andreas Mohr | 029b948 | 2002-07-23 02:02:46 +0000 | [diff] [blame] | 724 | * Runs the dialog box to set up the wineconsole options |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 725 | */ |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 726 | BOOL WCUSER_GetProperties(struct inner_data* data, BOOL current) |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 727 | { |
| 728 | HPROPSHEETPAGE psPage[3]; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 729 | PROPSHEETPAGE psp; |
| 730 | PROPSHEETHEADER psHead; |
| 731 | WCHAR buff[256]; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 732 | WNDCLASS wndclass; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 733 | static const WCHAR szFntPreview[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0}; |
| 734 | static const WCHAR szColorPreview[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0}; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 735 | struct dialog_info di; |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 736 | struct config_data defcfg; |
| 737 | struct config_data* refcfg; |
| 738 | BOOL save, modify_session; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 739 | |
| 740 | InitCommonControls(); |
| 741 | |
| 742 | di.data = data; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 743 | if (current) |
| 744 | { |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 745 | refcfg = &data->curcfg; |
| 746 | save = FALSE; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 747 | } |
| 748 | else |
| 749 | { |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 750 | WINECON_RegLoad(NULL, refcfg = &defcfg); |
| 751 | save = TRUE; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 752 | } |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 753 | di.config = *refcfg; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 754 | di.nFont = 0; |
| 755 | di.font = NULL; |
| 756 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 757 | modify_session = FALSE; |
| 758 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 759 | wndclass.style = 0; |
| 760 | wndclass.lpfnWndProc = WCUSER_FontPreviewProc; |
| 761 | wndclass.cbClsExtra = 0; |
Eric Pouech | be9268a | 2002-03-23 20:14:04 +0000 | [diff] [blame] | 762 | wndclass.cbWndExtra = 4; /* for hFont */ |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 763 | wndclass.hInstance = GetModuleHandle(NULL); |
| 764 | wndclass.hIcon = 0; |
| 765 | wndclass.hCursor = LoadCursor(0, IDC_ARROW); |
| 766 | wndclass.hbrBackground = GetStockObject(BLACK_BRUSH); |
| 767 | wndclass.lpszMenuName = NULL; |
| 768 | wndclass.lpszClassName = szFntPreview; |
| 769 | RegisterClass(&wndclass); |
| 770 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 771 | wndclass.style = 0; |
| 772 | wndclass.lpfnWndProc = WCUSER_ColorPreviewProc; |
| 773 | wndclass.cbClsExtra = 0; |
| 774 | wndclass.cbWndExtra = sizeof(DWORD); |
| 775 | wndclass.hInstance = GetModuleHandle(NULL); |
| 776 | wndclass.hIcon = 0; |
| 777 | wndclass.hCursor = LoadCursor(0, IDC_ARROW); |
| 778 | wndclass.hbrBackground = GetStockObject(BLACK_BRUSH); |
| 779 | wndclass.lpszMenuName = NULL; |
| 780 | wndclass.lpszClassName = szColorPreview; |
| 781 | RegisterClass(&wndclass); |
| 782 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 783 | memset(&psp, 0, sizeof(psp)); |
| 784 | psp.dwSize = sizeof(psp); |
| 785 | psp.dwFlags = 0; |
| 786 | psp.hInstance = wndclass.hInstance; |
| 787 | psp.lParam = (LPARAM)&di; |
| 788 | |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 789 | psp.u.pszTemplate = MAKEINTRESOURCE(IDD_OPTION); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 790 | psp.pfnDlgProc = WCUSER_OptionDlgProc; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 791 | psPage[0] = CreatePropertySheetPage(&psp); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 792 | |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 793 | psp.u.pszTemplate = MAKEINTRESOURCE(IDD_FONT); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 794 | psp.pfnDlgProc = WCUSER_FontDlgProc; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 795 | psPage[1] = CreatePropertySheetPage(&psp); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 796 | |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 797 | psp.u.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 798 | psp.pfnDlgProc = WCUSER_ConfigDlgProc; |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 799 | psPage[2] = CreatePropertySheetPage(&psp); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 800 | |
| 801 | memset(&psHead, 0, sizeof(psHead)); |
| 802 | psHead.dwSize = sizeof(psHead); |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 803 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 804 | if (!LoadString(GetModuleHandle(NULL), |
| 805 | (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT, |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 806 | buff, sizeof(buff) / sizeof(buff[0]))) |
| 807 | { |
| 808 | buff[0] = 'S'; |
| 809 | buff[1] = 'e'; |
| 810 | buff[2] = 't'; |
| 811 | buff[3] = 'u'; |
| 812 | buff[4] = 'p'; |
| 813 | buff[5] = '\0'; |
| 814 | } |
| 815 | |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 816 | psHead.pszCaption = buff; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 817 | psHead.nPages = 3; |
Eric Pouech | 94719d4 | 2001-12-04 20:46:54 +0000 | [diff] [blame] | 818 | psHead.hwndParent = PRIVATE(data)->hWnd; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 819 | psHead.u3.phpage = psPage; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 820 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 821 | WINECON_DumpConfig("init", refcfg); |
| 822 | |
Eric Pouech | 5ef8871 | 2002-02-04 18:41:32 +0000 | [diff] [blame] | 823 | PropertySheet(&psHead); |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 824 | |
Eric Pouech | 0589f72 | 2002-09-04 18:41:52 +0000 | [diff] [blame] | 825 | if (memcmp(refcfg, &di.config, sizeof(*refcfg)) == 0) |
| 826 | return TRUE; |
| 827 | |
| 828 | WINECON_DumpConfig("ref", refcfg); |
| 829 | WINECON_DumpConfig("cur", &di.config); |
| 830 | if (refcfg == &data->curcfg) |
| 831 | { |
| 832 | switch (DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SAVE_SETTINGS), |
| 833 | PRIVATE(data)->hWnd, WCUSER_SaveDlgProc)) |
| 834 | { |
| 835 | case IDC_SAV_SAVE: save = TRUE; modify_session = TRUE; break; |
| 836 | case IDC_SAV_SESSION: modify_session = TRUE; break; |
| 837 | case IDCANCEL: break; |
| 838 | default: WINE_ERR("ooch\n"); |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | if (modify_session) WINECON_SetConfig(data, &di.config, FALSE); |
| 843 | if (save) WINECON_RegSave(&di.config); |
| 844 | |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 845 | return TRUE; |
| 846 | } |