1 | /*
|
---|
2 | * COMMDLG - Font Dialog
|
---|
3 | *
|
---|
4 | * Copyright 1994 Martin Ayotte
|
---|
5 | * Copyright 1996 Albrecht Kleine
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifdef __WIN32OS2__
|
---|
9 | #include <windef.h>
|
---|
10 | #include <winbase.h>
|
---|
11 | #include <wingdi.h>
|
---|
12 | #include <winuser.h>
|
---|
13 | #include <heapstring.h>
|
---|
14 | #include <misc.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include <ctype.h>
|
---|
18 | #include <stdlib.h>
|
---|
19 | #include <stdio.h>
|
---|
20 | #include <string.h>
|
---|
21 | #include "windef.h"
|
---|
22 | #include "winbase.h"
|
---|
23 | #include "wingdi.h"
|
---|
24 | #ifndef __WIN32OS2__
|
---|
25 | #include "wine/winbase16.h"
|
---|
26 | #include "wine/winuser16.h"
|
---|
27 | #endif
|
---|
28 | #include "wine/winestring.h"
|
---|
29 | #include "ldt.h"
|
---|
30 | #include "heap.h"
|
---|
31 | #include "commdlg.h"
|
---|
32 | #include "dialog.h"
|
---|
33 | #include "dlgs.h"
|
---|
34 | #include "module.h"
|
---|
35 | #include "debugtools.h"
|
---|
36 | #ifndef __WIN32OS2__
|
---|
37 | #include "font.h"
|
---|
38 | #endif
|
---|
39 | #include "winproc.h"
|
---|
40 | #include "cderr.h"
|
---|
41 |
|
---|
42 | DEFAULT_DEBUG_CHANNEL(commdlg);
|
---|
43 |
|
---|
44 | #include "cdlg.h"
|
---|
45 |
|
---|
46 | #ifdef __WIN32OS2__
|
---|
47 | static HBITMAP hBitmapTT = 0;
|
---|
48 | #else
|
---|
49 | static HBITMAP16 hBitmapTT = 0;
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
|
---|
53 | LPARAM lParam);
|
---|
54 | LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
|
---|
55 | LPARAM lParam);
|
---|
56 |
|
---|
57 | #ifndef __WIN32OS2__
|
---|
58 | LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
|
---|
59 | LPARAM lParam);
|
---|
60 |
|
---|
61 | static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
|
---|
62 | {
|
---|
63 | chf32a->lStructSize=sizeof(CHOOSEFONTA);
|
---|
64 | chf32a->hwndOwner=chf16->hwndOwner;
|
---|
65 | chf32a->hDC=chf16->hDC;
|
---|
66 | chf32a->iPointSize=chf16->iPointSize;
|
---|
67 | chf32a->Flags=chf16->Flags;
|
---|
68 | chf32a->rgbColors=chf16->rgbColors;
|
---|
69 | chf32a->lCustData=chf16->lCustData;
|
---|
70 | chf32a->lpfnHook=NULL;
|
---|
71 | chf32a->lpTemplateName=PTR_SEG_TO_LIN(chf16->lpTemplateName);
|
---|
72 | chf32a->hInstance=chf16->hInstance;
|
---|
73 | chf32a->lpszStyle=PTR_SEG_TO_LIN(chf16->lpszStyle);
|
---|
74 | chf32a->nFontType=chf16->nFontType;
|
---|
75 | chf32a->nSizeMax=chf16->nSizeMax;
|
---|
76 | chf32a->nSizeMin=chf16->nSizeMin;
|
---|
77 | FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16->lpLogFont), chf32a->lpLogFont);
|
---|
78 | }
|
---|
79 |
|
---|
80 | /***********************************************************************
|
---|
81 | * ChooseFont16 (COMMDLG.15)
|
---|
82 | */
|
---|
83 | BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
|
---|
84 | {
|
---|
85 | HINSTANCE16 hInst;
|
---|
86 | HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
|
---|
87 | HGLOBAL16 hGlobal16 = 0;
|
---|
88 | BOOL16 bRet = FALSE;
|
---|
89 | LPCVOID template;
|
---|
90 | FARPROC16 ptr;
|
---|
91 | CHOOSEFONTA cf32a;
|
---|
92 | LOGFONTA lf32a;
|
---|
93 | SEGPTR lpTemplateName;
|
---|
94 |
|
---|
95 | cf32a.lpLogFont=&lf32a;
|
---|
96 | CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
|
---|
97 |
|
---|
98 | TRACE("ChooseFont\n");
|
---|
99 | if (!lpChFont) return FALSE;
|
---|
100 |
|
---|
101 | if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
|
---|
102 | {
|
---|
103 | if (!(template = LockResource16( lpChFont->hInstance )))
|
---|
104 | {
|
---|
105 | COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
---|
106 | return FALSE;
|
---|
107 | }
|
---|
108 | }
|
---|
109 | else if (lpChFont->Flags & CF_ENABLETEMPLATE)
|
---|
110 | {
|
---|
111 | HANDLE16 hResInfo;
|
---|
112 | if (!(hResInfo = FindResource16( lpChFont->hInstance,
|
---|
113 | lpChFont->lpTemplateName,
|
---|
114 | RT_DIALOG16)))
|
---|
115 | {
|
---|
116 | COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
---|
117 | return FALSE;
|
---|
118 | }
|
---|
119 | if (!(hDlgTmpl16 = LoadResource16( lpChFont->hInstance, hResInfo )) ||
|
---|
120 | !(template = LockResource16( hDlgTmpl16 )))
|
---|
121 | {
|
---|
122 | COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
---|
123 | return FALSE;
|
---|
124 | }
|
---|
125 | }
|
---|
126 | else
|
---|
127 | {
|
---|
128 | HANDLE hResInfo, hDlgTmpl32;
|
---|
129 | LPCVOID template32;
|
---|
130 | DWORD size;
|
---|
131 | if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
|
---|
132 | {
|
---|
133 | COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
---|
134 | return FALSE;
|
---|
135 | }
|
---|
136 | if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
|
---|
137 | !(template32 = LockResource(hDlgTmpl32)))
|
---|
138 | {
|
---|
139 | COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
---|
140 | return FALSE;
|
---|
141 | }
|
---|
142 | size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
|
---|
143 | hGlobal16 = GlobalAlloc16(0, size);
|
---|
144 | if (!hGlobal16)
|
---|
145 | {
|
---|
146 | COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
---|
147 | ERR("alloc failure for %ld bytes\n", size);
|
---|
148 | return FALSE;
|
---|
149 | }
|
---|
150 | template = GlobalLock16(hGlobal16);
|
---|
151 | if (!template)
|
---|
152 | {
|
---|
153 | COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
---|
154 | ERR("global lock failure for %x handle\n", hGlobal16);
|
---|
155 | GlobalFree16(hGlobal16);
|
---|
156 | return FALSE;
|
---|
157 | }
|
---|
158 | ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
|
---|
159 | hDlgTmpl16 = hGlobal16;
|
---|
160 |
|
---|
161 | }
|
---|
162 |
|
---|
163 | /* lpTemplateName is not used in the dialog */
|
---|
164 | lpTemplateName=lpChFont->lpTemplateName;
|
---|
165 | lpChFont->lpTemplateName=(SEGPTR)&cf32a;
|
---|
166 |
|
---|
167 | ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (SEGPTR) 16);
|
---|
168 | hInst = GetWindowLongA(lpChFont->hwndOwner, GWL_HINSTANCE);
|
---|
169 | bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChFont->hwndOwner,
|
---|
170 | (DLGPROC16) ptr, (DWORD)lpChFont);
|
---|
171 | if (hResource16) FreeResource16(hDlgTmpl16);
|
---|
172 | if (hGlobal16)
|
---|
173 | {
|
---|
174 | GlobalUnlock16(hGlobal16);
|
---|
175 | GlobalFree16(hGlobal16);
|
---|
176 | }
|
---|
177 | lpChFont->lpTemplateName=lpTemplateName;
|
---|
178 | FONT_LogFont32ATo16(cf32a.lpLogFont,
|
---|
179 | (LPLOGFONT16)(PTR_SEG_TO_LIN(lpChFont->lpLogFont)));
|
---|
180 | return bRet;
|
---|
181 | }
|
---|
182 | #endif //!__WIN32OS2__
|
---|
183 |
|
---|
184 | /***********************************************************************
|
---|
185 | * ChooseFontA (COMDLG32.3)
|
---|
186 | */
|
---|
187 | BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
|
---|
188 | {
|
---|
189 | LPCVOID template;
|
---|
190 | HANDLE hResInfo, hDlgTmpl;
|
---|
191 |
|
---|
192 | if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
|
---|
193 | {
|
---|
194 | COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
---|
195 | return FALSE;
|
---|
196 | }
|
---|
197 | if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
---|
198 | !(template = LockResource( hDlgTmpl )))
|
---|
199 | {
|
---|
200 | COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
---|
201 | return FALSE;
|
---|
202 | }
|
---|
203 |
|
---|
204 | if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
|
---|
205 | CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
|
---|
206 | return DialogBoxIndirectParamA(COMMDLG_hInstance32, template,
|
---|
207 | lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcA, (LPARAM)lpChFont );
|
---|
208 | }
|
---|
209 |
|
---|
210 | /***********************************************************************
|
---|
211 | * ChooseFontW (COMDLG32.4)
|
---|
212 | */
|
---|
213 | BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
|
---|
214 | {
|
---|
215 | BOOL bRet=FALSE;
|
---|
216 | CHOOSEFONTA cf32a;
|
---|
217 | LOGFONTA lf32a;
|
---|
218 | LPCVOID template;
|
---|
219 | HANDLE hResInfo, hDlgTmpl;
|
---|
220 |
|
---|
221 | if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
|
---|
222 | {
|
---|
223 | COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
---|
224 | return FALSE;
|
---|
225 | }
|
---|
226 | if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
---|
227 | !(template = LockResource( hDlgTmpl )))
|
---|
228 | {
|
---|
229 | COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
---|
230 | return FALSE;
|
---|
231 | }
|
---|
232 |
|
---|
233 | if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
|
---|
234 | CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
|
---|
235 | memcpy(&cf32a, lpChFont, sizeof(cf32a));
|
---|
236 | memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA));
|
---|
237 | lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE);
|
---|
238 | cf32a.lpLogFont=&lf32a;
|
---|
239 | cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
|
---|
240 | lpChFont->lpTemplateName=(LPWSTR)&cf32a;
|
---|
241 | bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template,
|
---|
242 | lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcW, (LPARAM)lpChFont );
|
---|
243 | HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
|
---|
244 | lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
|
---|
245 | memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
|
---|
246 | lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE);
|
---|
247 | return bRet;
|
---|
248 | }
|
---|
249 |
|
---|
250 |
|
---|
251 | #define TEXT_EXTRAS 4
|
---|
252 | #define TEXT_COLORS 16
|
---|
253 |
|
---|
254 | static const COLORREF textcolors[TEXT_COLORS]=
|
---|
255 | {
|
---|
256 | 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
|
---|
257 | 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
|
---|
258 | 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
|
---|
259 | 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
|
---|
260 | };
|
---|
261 |
|
---|
262 | /***********************************************************************
|
---|
263 | * CFn_HookCallChk [internal]
|
---|
264 | */
|
---|
265 | static BOOL CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
|
---|
266 | {
|
---|
267 | if (lpcf)
|
---|
268 | if(lpcf->Flags & CF_ENABLEHOOK)
|
---|
269 | if (lpcf->lpfnHook)
|
---|
270 | return TRUE;
|
---|
271 | return FALSE;
|
---|
272 | }
|
---|
273 |
|
---|
274 | /***********************************************************************
|
---|
275 | * CFn_HookCallChk32 [internal]
|
---|
276 | */
|
---|
277 | static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
|
---|
278 | {
|
---|
279 | if (lpcf)
|
---|
280 | if(lpcf->Flags & CF_ENABLEHOOK)
|
---|
281 | if (lpcf->lpfnHook)
|
---|
282 | return TRUE;
|
---|
283 | return FALSE;
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | /*************************************************************************
|
---|
288 | * AddFontFamily [internal]
|
---|
289 | */
|
---|
290 | static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType,
|
---|
291 | LPCHOOSEFONTA lpcf, HWND hwnd)
|
---|
292 | {
|
---|
293 | int i;
|
---|
294 | WORD w;
|
---|
295 |
|
---|
296 | TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
|
---|
297 |
|
---|
298 | if (lpcf->Flags & CF_FIXEDPITCHONLY)
|
---|
299 | if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
|
---|
300 | return 1;
|
---|
301 | if (lpcf->Flags & CF_ANSIONLY)
|
---|
302 | if (lplf->lfCharSet != ANSI_CHARSET)
|
---|
303 | return 1;
|
---|
304 | if (lpcf->Flags & CF_TTONLY)
|
---|
305 | if (!(nFontType & TRUETYPE_FONTTYPE))
|
---|
306 | return 1;
|
---|
307 |
|
---|
308 | i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
|
---|
309 | if (i!=CB_ERR)
|
---|
310 | {
|
---|
311 | w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
|
---|
312 | SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
|
---|
313 | return 1 ; /* store some important font information */
|
---|
314 | }
|
---|
315 | else
|
---|
316 | return 0;
|
---|
317 | }
|
---|
318 |
|
---|
319 | typedef struct
|
---|
320 | {
|
---|
321 | HWND hWnd1;
|
---|
322 | HWND hWnd2;
|
---|
323 | LPCHOOSEFONTA lpcf32a;
|
---|
324 | } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
|
---|
325 |
|
---|
326 | /*************************************************************************
|
---|
327 | * FontFamilyEnumProc32 [internal]
|
---|
328 | */
|
---|
329 | static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont,
|
---|
330 | LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
|
---|
331 | {
|
---|
332 | LPCFn_ENUMSTRUCT e;
|
---|
333 | e=(LPCFn_ENUMSTRUCT)lParam;
|
---|
334 | return AddFontFamily(&lpEnumLogFont->elfLogFont, nFontType, e->lpcf32a, e->hWnd1);
|
---|
335 | }
|
---|
336 |
|
---|
337 | #ifndef __WIN32OS2__
|
---|
338 | /***********************************************************************
|
---|
339 | * FontFamilyEnumProc16 (COMMDLG.19)
|
---|
340 | */
|
---|
341 | INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
|
---|
342 | UINT16 nFontType, LPARAM lParam )
|
---|
343 | {
|
---|
344 | HWND16 hwnd=LOWORD(lParam);
|
---|
345 | HWND hDlg=GetParent(hwnd);
|
---|
346 | LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
---|
347 | LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
|
---|
348 | LOGFONTA lf32a;
|
---|
349 | FONT_LogFont16To32A(lplf, &lf32a);
|
---|
350 | return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
|
---|
351 | hwnd);
|
---|
352 | }
|
---|
353 | #endif //!__WIN32OS2__
|
---|
354 |
|
---|
355 | /*************************************************************************
|
---|
356 | * SetFontStylesToCombo2 [internal]
|
---|
357 | *
|
---|
358 | * Fill font style information into combobox (without using font.c directly)
|
---|
359 | */
|
---|
360 | static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, LPLOGFONTA lplf)
|
---|
361 | {
|
---|
362 | #define FSTYLES 4
|
---|
363 | struct FONTSTYLE
|
---|
364 | { int italic;
|
---|
365 | int weight;
|
---|
366 | char stname[20]; };
|
---|
367 | static struct FONTSTYLE fontstyles[FSTYLES]={
|
---|
368 | { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
|
---|
369 | { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
|
---|
370 | HFONT hf;
|
---|
371 | TEXTMETRICA tm;
|
---|
372 | int i,j;
|
---|
373 |
|
---|
374 | for (i=0;i<FSTYLES;i++)
|
---|
375 | {
|
---|
376 | lplf->lfItalic=fontstyles[i].italic;
|
---|
377 | lplf->lfWeight=fontstyles[i].weight;
|
---|
378 | hf=CreateFontIndirectA(lplf);
|
---|
379 | hf=SelectObject(hdc,hf);
|
---|
380 | GetTextMetricsA(hdc,&tm);
|
---|
381 | hf=SelectObject(hdc,hf);
|
---|
382 | DeleteObject(hf);
|
---|
383 |
|
---|
384 | if (tm.tmWeight==fontstyles[i].weight &&
|
---|
385 | tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
|
---|
386 | {
|
---|
387 | #ifdef __WIN32OS2__
|
---|
388 | char *str = fontstyles[i].stname;
|
---|
389 | j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str );
|
---|
390 | if (j==CB_ERR) return 1;
|
---|
391 | j=SendMessageA(hwnd, CB_SETITEMDATA, j,
|
---|
392 | MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
|
---|
393 | #else
|
---|
394 | char *str = SEGPTR_STRDUP(fontstyles[i].stname);
|
---|
395 | j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
|
---|
396 | SEGPTR_FREE(str);
|
---|
397 | if (j==CB_ERR) return 1;
|
---|
398 | j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
|
---|
399 | MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
|
---|
400 | #endif
|
---|
401 | if (j==CB_ERR) return 1;
|
---|
402 | }
|
---|
403 | }
|
---|
404 | return 0;
|
---|
405 | }
|
---|
406 |
|
---|
407 | /*************************************************************************
|
---|
408 | * AddFontSizeToCombo3 [internal]
|
---|
409 | */
|
---|
410 | static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
|
---|
411 | {
|
---|
412 | int j;
|
---|
413 | char buffer[20];
|
---|
414 |
|
---|
415 | if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
|
---|
416 | ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
|
---|
417 | {
|
---|
418 | sprintf(buffer, "%2d", h);
|
---|
419 | j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
|
---|
420 | if (j==CB_ERR)
|
---|
421 | {
|
---|
422 | j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
|
---|
423 | if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
|
---|
424 | if (j==CB_ERR) return 1;
|
---|
425 | }
|
---|
426 | }
|
---|
427 | return 0;
|
---|
428 | }
|
---|
429 |
|
---|
430 | /*************************************************************************
|
---|
431 | * SetFontSizesToCombo3 [internal]
|
---|
432 | */
|
---|
433 | static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
|
---|
434 | {
|
---|
435 | static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
|
---|
436 | int i;
|
---|
437 |
|
---|
438 | for (i=0; sizes[i]; i++)
|
---|
439 | if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
|
---|
440 | return 0;
|
---|
441 | }
|
---|
442 |
|
---|
443 | /***********************************************************************
|
---|
444 | * AddFontStyle [internal]
|
---|
445 | */
|
---|
446 | static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType,
|
---|
447 | LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
|
---|
448 | {
|
---|
449 | int i;
|
---|
450 |
|
---|
451 | TRACE("(nFontType=%d)\n",nFontType);
|
---|
452 | TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
|
---|
453 | " ch=%d op=%d cp=%d q=%d pf=%xh\n",
|
---|
454 | lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
|
---|
455 | lplf->lfEscapement,lplf->lfOrientation,
|
---|
456 | lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
|
---|
457 | lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
|
---|
458 | lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
|
---|
459 | if (nFontType & RASTER_FONTTYPE)
|
---|
460 | {
|
---|
461 | if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
|
---|
462 | } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
|
---|
463 |
|
---|
464 | if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
|
---|
465 | {
|
---|
466 | HDC hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
---|
467 | i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
|
---|
468 | if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
|
---|
469 | ReleaseDC(hDlg,hdc);
|
---|
470 | if (i)
|
---|
471 | return 0;
|
---|
472 | }
|
---|
473 | return 1 ;
|
---|
474 |
|
---|
475 | }
|
---|
476 |
|
---|
477 | #ifndef __WIN32OS2__
|
---|
478 | /***********************************************************************
|
---|
479 | * FontStyleEnumProc16 (COMMDLG.18)
|
---|
480 | */
|
---|
481 | INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
|
---|
482 | UINT16 nFontType, LPARAM lParam )
|
---|
483 | {
|
---|
484 | HWND16 hcmb2=LOWORD(lParam);
|
---|
485 | HWND16 hcmb3=HIWORD(lParam);
|
---|
486 | HWND hDlg=GetParent(hcmb3);
|
---|
487 | LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
---|
488 | LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
|
---|
489 | LOGFONTA lf32a;
|
---|
490 | FONT_LogFont16To32A(lplf, &lf32a);
|
---|
491 | return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
|
---|
492 | hcmb2, hcmb3, hDlg);
|
---|
493 | }
|
---|
494 | #endif //!__WIN32OS2__
|
---|
495 |
|
---|
496 | /***********************************************************************
|
---|
497 | * FontStyleEnumProc32 [internal]
|
---|
498 | */
|
---|
499 | static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont,
|
---|
500 | LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam )
|
---|
501 | {
|
---|
502 | LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
|
---|
503 | HWND hcmb2=s->hWnd1;
|
---|
504 | HWND hcmb3=s->hWnd2;
|
---|
505 | HWND hDlg=GetParent(hcmb3);
|
---|
506 | return AddFontStyle(&lpFont->elfLogFont, nFontType, s->lpcf32a, hcmb2,
|
---|
507 | hcmb3, hDlg);
|
---|
508 | }
|
---|
509 |
|
---|
510 | /***********************************************************************
|
---|
511 | * CFn_WMInitDialog [internal]
|
---|
512 | */
|
---|
513 | static LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
---|
514 | LPCHOOSEFONTA lpcf)
|
---|
515 | {
|
---|
516 | HDC hdc;
|
---|
517 | int i,j,res,init=0;
|
---|
518 | long l;
|
---|
519 | LPLOGFONTA lpxx;
|
---|
520 | HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
|
---|
521 |
|
---|
522 | SetWindowLongA(hDlg, DWL_USER, lParam);
|
---|
523 | lpxx=lpcf->lpLogFont;
|
---|
524 | TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
|
---|
525 |
|
---|
526 | if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
|
---|
527 | {
|
---|
528 | ERR("structure size failure !!!\n");
|
---|
529 | EndDialog (hDlg, 0);
|
---|
530 | return FALSE;
|
---|
531 | }
|
---|
532 | if (!hBitmapTT)
|
---|
533 | hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
|
---|
534 |
|
---|
535 | /* This font will be deleted by WM_COMMAND */
|
---|
536 | SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,
|
---|
537 | CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
|
---|
538 |
|
---|
539 | if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
|
---|
540 | ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
|
---|
541 | if (!(lpcf->Flags & CF_APPLY))
|
---|
542 | ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
|
---|
543 | if (lpcf->Flags & CF_EFFECTS)
|
---|
544 | {
|
---|
545 | for (res=1,i=0;res && i<TEXT_COLORS;i++)
|
---|
546 | {
|
---|
547 | /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
|
---|
548 | char name[20];
|
---|
549 | strcpy( name, "[color name]" );
|
---|
550 | j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
|
---|
551 | #ifdef __WIN32OS2__
|
---|
552 | SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA, j, textcolors[j]);
|
---|
553 | #else
|
---|
554 | SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
|
---|
555 | #endif
|
---|
556 | /* look for a fitting value in color combobox */
|
---|
557 | if (textcolors[j]==lpcf->rgbColors)
|
---|
558 | SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
|
---|
559 | }
|
---|
560 | }
|
---|
561 | else
|
---|
562 | {
|
---|
563 | ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
|
---|
564 | ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
|
---|
565 | ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
|
---|
566 | ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
|
---|
567 | ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
|
---|
568 | }
|
---|
569 | hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
---|
570 | if (hdc)
|
---|
571 | {
|
---|
572 | CFn_ENUMSTRUCT s;
|
---|
573 | s.hWnd1=GetDlgItem(hDlg,cmb1);
|
---|
574 | s.lpcf32a=lpcf;
|
---|
575 | if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s))
|
---|
576 | TRACE("EnumFontFamilies returns 0\n");
|
---|
577 | if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
|
---|
578 | {
|
---|
579 | /* look for fitting font name in combobox1 */
|
---|
580 | j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
|
---|
581 | if (j!=CB_ERR)
|
---|
582 | {
|
---|
583 | SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
|
---|
584 | SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
|
---|
585 | GetDlgItem(hDlg,cmb1));
|
---|
586 | init=1;
|
---|
587 | /* look for fitting font style in combobox2 */
|
---|
588 | l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
|
---|
589 | for (i=0;i<TEXT_EXTRAS;i++)
|
---|
590 | {
|
---|
591 | if (l==SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0))
|
---|
592 | SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
|
---|
593 | }
|
---|
594 |
|
---|
595 | /* look for fitting font size in combobox3 */
|
---|
596 | j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
|
---|
597 | for (i=0;i<j;i++)
|
---|
598 | {
|
---|
599 | if (lpxx->lfHeight==(int)SendDlgItemMessageA(hDlg,cmb3, CB_GETITEMDATA,i,0))
|
---|
600 | SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
|
---|
601 | }
|
---|
602 | }
|
---|
603 | }
|
---|
604 | if (!init)
|
---|
605 | {
|
---|
606 | SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
|
---|
607 | SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
|
---|
608 | GetDlgItem(hDlg,cmb1));
|
---|
609 | }
|
---|
610 | if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
|
---|
611 | {
|
---|
612 | j=SendDlgItemMessageA(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
|
---|
613 | if (j!=CB_ERR)
|
---|
614 | {
|
---|
615 | j=SendDlgItemMessageA(hDlg,cmb2,CB_SETCURSEL,j,0);
|
---|
616 | SendMessageA(hDlg,WM_COMMAND,cmb2,
|
---|
617 | MAKELONG(GetDlgItem(hDlg,cmb2),CBN_SELCHANGE));
|
---|
618 | }
|
---|
619 | }
|
---|
620 | }
|
---|
621 | else
|
---|
622 | {
|
---|
623 | WARN("HDC failure !!!\n");
|
---|
624 | EndDialog (hDlg, 0);
|
---|
625 | return FALSE;
|
---|
626 | }
|
---|
627 |
|
---|
628 | if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
|
---|
629 | ReleaseDC(hDlg,hdc);
|
---|
630 | SetCursor(hcursor);
|
---|
631 | return TRUE;
|
---|
632 | }
|
---|
633 |
|
---|
634 |
|
---|
635 | /***********************************************************************
|
---|
636 | * CFn_WMMeasureItem [internal]
|
---|
637 | */
|
---|
638 | static LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
---|
639 | {
|
---|
640 | BITMAP bm;
|
---|
641 | LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
|
---|
642 | if (!hBitmapTT)
|
---|
643 | hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
|
---|
644 | GetObjectA( hBitmapTT, sizeof(bm), &bm );
|
---|
645 | lpmi->itemHeight=bm.bmHeight;
|
---|
646 | /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
|
---|
647 | return 0;
|
---|
648 | }
|
---|
649 |
|
---|
650 |
|
---|
651 | /***********************************************************************
|
---|
652 | * CFn_WMDrawItem [internal]
|
---|
653 | */
|
---|
654 | static LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
---|
655 | {
|
---|
656 | HBRUSH hBrush;
|
---|
657 | char buffer[40];
|
---|
658 | BITMAP bm;
|
---|
659 | COLORREF cr, oldText=0, oldBk=0;
|
---|
660 | RECT rect;
|
---|
661 | #if 0
|
---|
662 | HDC hMemDC;
|
---|
663 | int nFontType;
|
---|
664 | HBITMAP hBitmap; /* for later TT usage */
|
---|
665 | #endif
|
---|
666 | LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
|
---|
667 |
|
---|
668 | if (lpdi->itemID == 0xFFFF) /* got no items */
|
---|
669 | DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
|
---|
670 | else
|
---|
671 | {
|
---|
672 | if (lpdi->CtlType == ODT_COMBOBOX)
|
---|
673 | {
|
---|
674 | if (lpdi->itemState ==ODS_SELECTED)
|
---|
675 | {
|
---|
676 | hBrush=GetSysColorBrush(COLOR_HIGHLIGHT);
|
---|
677 | oldText=SetTextColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
---|
678 | oldBk=SetBkColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
---|
679 | } else
|
---|
680 | {
|
---|
681 | hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
|
---|
682 | SelectObject(lpdi->hDC, hBrush);
|
---|
683 | }
|
---|
684 | FillRect(lpdi->hDC, &lpdi->rcItem, hBrush);
|
---|
685 | }
|
---|
686 | else
|
---|
687 | return TRUE; /* this should never happen */
|
---|
688 |
|
---|
689 | rect=lpdi->rcItem;
|
---|
690 | switch (lpdi->CtlID)
|
---|
691 | {
|
---|
692 | case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
|
---|
693 | SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
---|
694 | (LPARAM)buffer);
|
---|
695 | GetObjectA( hBitmapTT, sizeof(bm), &bm );
|
---|
696 | TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
|
---|
697 | lpdi->rcItem.top, buffer, strlen(buffer));
|
---|
698 | #if 0
|
---|
699 | nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
|
---|
700 | /* FIXME: draw bitmap if truetype usage */
|
---|
701 | if (nFontType&TRUETYPE_FONTTYPE)
|
---|
702 | {
|
---|
703 | hMemDC = CreateCompatibleDC(lpdi->hDC);
|
---|
704 | hBitmap = SelectObject(hMemDC, hBitmapTT);
|
---|
705 | BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
|
---|
706 | bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
|
---|
707 | SelectObject(hMemDC, hBitmap);
|
---|
708 | DeleteDC(hMemDC);
|
---|
709 | }
|
---|
710 | #endif
|
---|
711 | break;
|
---|
712 | case cmb2:
|
---|
713 | case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
|
---|
714 | SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
---|
715 | (LPARAM)buffer);
|
---|
716 | TextOutA(lpdi->hDC, lpdi->rcItem.left,
|
---|
717 | lpdi->rcItem.top, buffer, strlen(buffer));
|
---|
718 | break;
|
---|
719 |
|
---|
720 | case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
|
---|
721 | SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
---|
722 | (LPARAM)buffer);
|
---|
723 | TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
|
---|
724 | lpdi->rcItem.top, buffer, strlen(buffer));
|
---|
725 | cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
|
---|
726 | hBrush = CreateSolidBrush(cr);
|
---|
727 | if (hBrush)
|
---|
728 | {
|
---|
729 | hBrush = SelectObject (lpdi->hDC, hBrush) ;
|
---|
730 | rect.right=rect.left+25;
|
---|
731 | rect.top++;
|
---|
732 | rect.left+=5;
|
---|
733 | rect.bottom--;
|
---|
734 | Rectangle( lpdi->hDC, rect.left, rect.top,
|
---|
735 | rect.right, rect.bottom );
|
---|
736 | DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
|
---|
737 | }
|
---|
738 | rect=lpdi->rcItem;
|
---|
739 | rect.left+=25+5;
|
---|
740 | break;
|
---|
741 |
|
---|
742 | default: return TRUE; /* this should never happen */
|
---|
743 | }
|
---|
744 | if (lpdi->itemState == ODS_SELECTED)
|
---|
745 | {
|
---|
746 | SetTextColor(lpdi->hDC, oldText);
|
---|
747 | SetBkColor(lpdi->hDC, oldBk);
|
---|
748 | }
|
---|
749 | }
|
---|
750 | return TRUE;
|
---|
751 | }
|
---|
752 |
|
---|
753 | /***********************************************************************
|
---|
754 | * CFn_WMCtlColor [internal]
|
---|
755 | */
|
---|
756 | static LRESULT CFn_WMCtlColorStatic(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
---|
757 | LPCHOOSEFONTA lpcf)
|
---|
758 | {
|
---|
759 | if (lpcf->Flags & CF_EFFECTS)
|
---|
760 | if (GetDlgCtrlID(lParam)==stc6)
|
---|
761 | {
|
---|
762 | SetTextColor((HDC)wParam, lpcf->rgbColors);
|
---|
763 | return GetStockObject(WHITE_BRUSH);
|
---|
764 | }
|
---|
765 | return 0;
|
---|
766 | }
|
---|
767 |
|
---|
768 | /***********************************************************************
|
---|
769 | * CFn_WMCommand [internal]
|
---|
770 | */
|
---|
771 | static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
---|
772 | LPCHOOSEFONTA lpcf)
|
---|
773 | {
|
---|
774 | HFONT hFont;
|
---|
775 | int i,j;
|
---|
776 | long l;
|
---|
777 | HDC hdc;
|
---|
778 | LPLOGFONTA lpxx=lpcf->lpLogFont;
|
---|
779 |
|
---|
780 | TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
|
---|
781 | switch (LOWORD(wParam))
|
---|
782 | {
|
---|
783 | case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
|
---|
784 | {
|
---|
785 | hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
---|
786 | if (hdc)
|
---|
787 | {
|
---|
788 | #ifdef __WIN32OS2__
|
---|
789 | SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
|
---|
790 | SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
|
---|
791 | i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
|
---|
792 | #else
|
---|
793 | SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
|
---|
794 | SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
|
---|
795 | i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
|
---|
796 | #endif
|
---|
797 | if (i!=CB_ERR)
|
---|
798 | {
|
---|
799 | HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
|
---|
800 | CFn_ENUMSTRUCT s;
|
---|
801 | char str[256];
|
---|
802 | SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
|
---|
803 | (LPARAM)str);
|
---|
804 | TRACE("WM_COMMAND/cmb1 =>%s\n",str);
|
---|
805 | s.hWnd1=GetDlgItem(hDlg, cmb2);
|
---|
806 | s.hWnd2=GetDlgItem(hDlg, cmb3);
|
---|
807 | s.lpcf32a=lpcf;
|
---|
808 | EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
|
---|
809 | SetCursor(hcursor);
|
---|
810 | }
|
---|
811 | if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
|
---|
812 | ReleaseDC(hDlg,hdc);
|
---|
813 | }
|
---|
814 | else
|
---|
815 | {
|
---|
816 | WARN("HDC failure !!!\n");
|
---|
817 | EndDialog (hDlg, 0);
|
---|
818 | return TRUE;
|
---|
819 | }
|
---|
820 | }
|
---|
821 | case chx1:
|
---|
822 | case chx2:
|
---|
823 | case cmb2:
|
---|
824 | case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
|
---|
825 | {
|
---|
826 | char str[256];
|
---|
827 | TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
|
---|
828 | i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
|
---|
829 | if (i==CB_ERR)
|
---|
830 | i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
|
---|
831 | else
|
---|
832 | {
|
---|
833 | SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
|
---|
834 | (LPARAM)str);
|
---|
835 | l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
|
---|
836 | j=HIWORD(l);
|
---|
837 | lpcf->nFontType = LOWORD(l);
|
---|
838 | /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
|
---|
839 | /* same value reported to the EnumFonts
|
---|
840 | call back with the extra FONTTYPE_... bits added */
|
---|
841 | lpxx->lfPitchAndFamily=j&0xff;
|
---|
842 | lpxx->lfCharSet=j>>8;
|
---|
843 | }
|
---|
844 | strcpy(lpxx->lfFaceName,str);
|
---|
845 | i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
|
---|
846 | if (i!=CB_ERR)
|
---|
847 | {
|
---|
848 | l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
|
---|
849 | if (0!=(lpxx->lfItalic=HIWORD(l)))
|
---|
850 | lpcf->nFontType |= ITALIC_FONTTYPE;
|
---|
851 | if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
|
---|
852 | lpcf->nFontType |= BOLD_FONTTYPE;
|
---|
853 | }
|
---|
854 | i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
|
---|
855 | if (i!=CB_ERR)
|
---|
856 | lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
|
---|
857 | else
|
---|
858 | lpxx->lfHeight=0;
|
---|
859 | lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
|
---|
860 | lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
|
---|
861 | lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
|
---|
862 | lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
|
---|
863 | lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
|
---|
864 | lpxx->lfQuality=DEFAULT_QUALITY;
|
---|
865 | lpcf->iPointSize= -10*lpxx->lfHeight;
|
---|
866 |
|
---|
867 | hFont=CreateFontIndirectA(lpxx);
|
---|
868 | if (hFont)
|
---|
869 | {
|
---|
870 | HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
|
---|
871 | WM_GETFONT, 0, 0);
|
---|
872 | SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
|
---|
873 | DeleteObject(oldFont);
|
---|
874 | }
|
---|
875 | }
|
---|
876 | break;
|
---|
877 |
|
---|
878 | case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
|
---|
879 | if (i!=CB_ERR)
|
---|
880 | {
|
---|
881 | lpcf->rgbColors=textcolors[i];
|
---|
882 | InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
|
---|
883 | }
|
---|
884 | break;
|
---|
885 |
|
---|
886 | case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
|
---|
887 | if (lpcf->hwndOwner)
|
---|
888 | SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
|
---|
889 | /* if (CFn_HookCallChk(lpcf))
|
---|
890 | CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
|
---|
891 | break;
|
---|
892 |
|
---|
893 | case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
|
---|
894 | ( (lpcf->Flags & CF_LIMITSIZE) &&
|
---|
895 | (-lpxx->lfHeight >= lpcf->nSizeMin) &&
|
---|
896 | (-lpxx->lfHeight <= lpcf->nSizeMax)))
|
---|
897 | EndDialog(hDlg, TRUE);
|
---|
898 | else
|
---|
899 | {
|
---|
900 | char buffer[80];
|
---|
901 | sprintf(buffer,"Select a font size between %d and %d points.",
|
---|
902 | lpcf->nSizeMin,lpcf->nSizeMax);
|
---|
903 | MessageBoxA(hDlg, buffer, NULL, MB_OK);
|
---|
904 | }
|
---|
905 | return(TRUE);
|
---|
906 | case IDCANCEL:EndDialog(hDlg, FALSE);
|
---|
907 | return(TRUE);
|
---|
908 | }
|
---|
909 | return(FALSE);
|
---|
910 | }
|
---|
911 |
|
---|
912 | static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
913 | {
|
---|
914 | DeleteObject(SendDlgItemMessageA(hwnd, stc6, WM_GETFONT, 0, 0));
|
---|
915 | return TRUE;
|
---|
916 | }
|
---|
917 |
|
---|
918 | #ifndef __WIN32OS2__
|
---|
919 | /***********************************************************************
|
---|
920 | * FormatCharDlgProc16 (COMMDLG.16)
|
---|
921 | FIXME: 1. some strings are "hardcoded", but it's better load from sysres
|
---|
922 | 2. some CF_.. flags are not supported
|
---|
923 | 3. some TType extensions
|
---|
924 | */
|
---|
925 | LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
|
---|
926 | LPARAM lParam)
|
---|
927 | {
|
---|
928 | LPCHOOSEFONT16 lpcf;
|
---|
929 | LPCHOOSEFONTA lpcf32a;
|
---|
930 | UINT uMsg32;
|
---|
931 | WPARAM wParam32;
|
---|
932 | LRESULT res=0;
|
---|
933 | if (message!=WM_INITDIALOG)
|
---|
934 | {
|
---|
935 | lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
---|
936 | if (!lpcf)
|
---|
937 | return FALSE;
|
---|
938 | if (CFn_HookCallChk(lpcf))
|
---|
939 | res=CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,message,wParam,lParam);
|
---|
940 | if (res)
|
---|
941 | return res;
|
---|
942 | }
|
---|
943 | else
|
---|
944 | {
|
---|
945 | lpcf=(LPCHOOSEFONT16)lParam;
|
---|
946 | lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
|
---|
947 | if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
|
---|
948 | {
|
---|
949 | TRACE("CFn_WMInitDialog returned FALSE\n");
|
---|
950 | return FALSE;
|
---|
951 | }
|
---|
952 | if (CFn_HookCallChk(lpcf))
|
---|
953 | return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
|
---|
954 | }
|
---|
955 | WINPROC_MapMsg16To32A(message, wParam, &uMsg32, &wParam32, &lParam);
|
---|
956 | lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
|
---|
957 | switch (uMsg32)
|
---|
958 | {
|
---|
959 | case WM_MEASUREITEM:
|
---|
960 | res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
|
---|
961 | break;
|
---|
962 | case WM_DRAWITEM:
|
---|
963 | res=CFn_WMDrawItem(hDlg, wParam32, lParam);
|
---|
964 | break;
|
---|
965 | case WM_CTLCOLORSTATIC:
|
---|
966 | res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
|
---|
967 | break;
|
---|
968 | case WM_COMMAND:
|
---|
969 | res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
|
---|
970 | break;
|
---|
971 | case WM_DESTROY:
|
---|
972 | res=CFn_WMDestroy(hDlg, wParam32, lParam);
|
---|
973 | break;
|
---|
974 | case WM_CHOOSEFONT_GETLOGFONT:
|
---|
975 | TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
|
---|
976 | lParam);
|
---|
977 | FIXME("current logfont back to caller\n");
|
---|
978 | break;
|
---|
979 | }
|
---|
980 | WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
|
---|
981 | return res;
|
---|
982 | }
|
---|
983 | #endif //!__WIN32OS2__
|
---|
984 |
|
---|
985 | /***********************************************************************
|
---|
986 | * FormatCharDlgProcA [internal]
|
---|
987 | */
|
---|
988 | LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
|
---|
989 | LPARAM lParam)
|
---|
990 | {
|
---|
991 | LPCHOOSEFONTA lpcf;
|
---|
992 | LRESULT res=FALSE;
|
---|
993 | if (uMsg!=WM_INITDIALOG)
|
---|
994 | {
|
---|
995 | lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
|
---|
996 | if (!lpcf)
|
---|
997 | return FALSE;
|
---|
998 | if (CFn_HookCallChk32(lpcf))
|
---|
999 | res=CallWindowProcA((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
|
---|
1000 | if (res)
|
---|
1001 | return res;
|
---|
1002 | }
|
---|
1003 | else
|
---|
1004 | {
|
---|
1005 | lpcf=(LPCHOOSEFONTA)lParam;
|
---|
1006 | if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
|
---|
1007 | {
|
---|
1008 | TRACE("CFn_WMInitDialog returned FALSE\n");
|
---|
1009 | return FALSE;
|
---|
1010 | }
|
---|
1011 | if (CFn_HookCallChk32(lpcf))
|
---|
1012 | return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
|
---|
1013 | }
|
---|
1014 | switch (uMsg)
|
---|
1015 | {
|
---|
1016 | case WM_MEASUREITEM:
|
---|
1017 | return CFn_WMMeasureItem(hDlg, wParam, lParam);
|
---|
1018 | case WM_DRAWITEM:
|
---|
1019 | return CFn_WMDrawItem(hDlg, wParam, lParam);
|
---|
1020 | case WM_CTLCOLORSTATIC:
|
---|
1021 | return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
|
---|
1022 | case WM_COMMAND:
|
---|
1023 | return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
|
---|
1024 | case WM_DESTROY:
|
---|
1025 | return CFn_WMDestroy(hDlg, wParam, lParam);
|
---|
1026 | case WM_CHOOSEFONT_GETLOGFONT:
|
---|
1027 | TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
|
---|
1028 | lParam);
|
---|
1029 | FIXME("current logfont back to caller\n");
|
---|
1030 | break;
|
---|
1031 | }
|
---|
1032 | return res;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | /***********************************************************************
|
---|
1036 | * FormatCharDlgProcW [internal]
|
---|
1037 | */
|
---|
1038 | LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
|
---|
1039 | LPARAM lParam)
|
---|
1040 | {
|
---|
1041 | LPCHOOSEFONTW lpcf32w;
|
---|
1042 | LPCHOOSEFONTA lpcf32a;
|
---|
1043 | LRESULT res=FALSE;
|
---|
1044 | if (uMsg!=WM_INITDIALOG)
|
---|
1045 | {
|
---|
1046 | lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
|
---|
1047 | if (!lpcf32w)
|
---|
1048 | return FALSE;
|
---|
1049 | if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
|
---|
1050 | res=CallWindowProcW((WNDPROC)lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
|
---|
1051 | if (res)
|
---|
1052 | return res;
|
---|
1053 | }
|
---|
1054 | else
|
---|
1055 | {
|
---|
1056 | lpcf32w=(LPCHOOSEFONTW)lParam;
|
---|
1057 | lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
|
---|
1058 | if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
|
---|
1059 | {
|
---|
1060 | TRACE("CFn_WMInitDialog returned FALSE\n");
|
---|
1061 | return FALSE;
|
---|
1062 | }
|
---|
1063 | if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
|
---|
1064 | return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
|
---|
1065 | }
|
---|
1066 | lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
|
---|
1067 | switch (uMsg)
|
---|
1068 | {
|
---|
1069 | case WM_MEASUREITEM:
|
---|
1070 | return CFn_WMMeasureItem(hDlg, wParam, lParam);
|
---|
1071 | case WM_DRAWITEM:
|
---|
1072 | return CFn_WMDrawItem(hDlg, wParam, lParam);
|
---|
1073 | case WM_CTLCOLORSTATIC:
|
---|
1074 | return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
|
---|
1075 | case WM_COMMAND:
|
---|
1076 | return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
|
---|
1077 | case WM_DESTROY:
|
---|
1078 | return CFn_WMDestroy(hDlg, wParam, lParam);
|
---|
1079 | case WM_CHOOSEFONT_GETLOGFONT:
|
---|
1080 | TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
|
---|
1081 | lParam);
|
---|
1082 | FIXME("current logfont back to caller\n");
|
---|
1083 | break;
|
---|
1084 | }
|
---|
1085 | return res;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 |
|
---|