ReactOS 0.4.15-dev-7788-g1ad9096
display.c File Reference
#include "precomp.h"
#include <stdio.h>
#include <malloc.h>
Include dependency graph for display.c:

Go to the source code of this file.

Classes

struct  DISPLAYDATA
 

Macros

#define SPACING1   8
 
#define SPACING2   5
 

Functions

LRESULT CALLBACK DisplayProc (HWND, UINT, WPARAM, LPARAM)
 
BOOL Display_InitClass (HINSTANCE hInstance)
 
static int Display_DrawText (HDC hDC, DISPLAYDATA *pData, int nYPos)
 
static int CALLBACK EnumFontFamProcW (const LOGFONTW *lpelfe, const TEXTMETRICW *lptm, DWORD FontType, LPARAM lParam)
 
static LRESULT Display_SetTypeFace (HWND hwnd, PLOGFONTW pLogFont)
 
static LRESULT Display_SetString (HWND hwnd, LPCWSTR pszString)
 
static LRESULT Display_OnCreate (HWND hwnd)
 
static LRESULT Display_OnPaint (HWND hwnd)
 
static LRESULT Display_OnSize (HWND hwnd)
 
static LRESULT Display_OnVScroll (HWND hwnd, WPARAM wParam)
 
static LRESULT Display_OnDestroy (HWND hwnd)
 
LRESULT Display_OnPrint (HWND hwnd)
 
LRESULT Display_GetFullName (HWND hwnd, INT length, PWSTR ptr)
 

Variables

INT g_NumFonts
 
WCHAR g_FontTitle []
 
const WCHAR g_szFontDisplayClassName [] = L"FontDisplayClass"
 

Macro Definition Documentation

◆ SPACING1

#define SPACING1   8

Definition at line 13 of file display.c.

◆ SPACING2

#define SPACING2   5

Definition at line 14 of file display.c.

Function Documentation

◆ Display_DrawText()

static int Display_DrawText ( HDC  hDC,
DISPLAYDATA pData,
int  nYPos 
)
static

Definition at line 67 of file display.c.

68{
69 HFONT hOldFont;
71 int i, y;
72 WCHAR szSize[5];
73 WCHAR szCaption[LF_FULLFACESIZE + 20];
74
75 /* This is the location on the DC where we draw */
76 y = -nYPos;
77
78 hOldFont = SelectObject(hDC, pData->hCaptionFont);
80
81 swprintf(szCaption, L"%s%s", pData->szTypeFaceName, pData->szFormat);
82 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
83 y += tm.tmHeight + SPACING1;
84
85 /* Draw a separation Line */
87 MoveToEx(hDC, 0, y, NULL);
88 LineTo(hDC, 10000, y);
89 y += SPACING2;
90
91 /* TODO: Output font info */
92
93 /* Output Character set */
94 SelectObject(hDC, pData->hCharSetFont);
96 swprintf(szCaption, L"abcdefghijklmnopqrstuvwxyz");
97 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
98 y += tm.tmHeight + 1;
99
100 swprintf(szCaption, L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
101 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
102 y += tm.tmHeight + 1;
103
104 swprintf(szCaption, L"0123456789.:,;(\"~!@#$%%^&*')");
105 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
106 y += tm.tmHeight + 1;
107
108 /* Draw a separation Line */
110 MoveToEx(hDC, 0, y, NULL);
111 LineTo(hDC, 10000, y);
112 y += SPACING2;
113
114 /* Output the strings for different sizes */
115 for (i = 0; i < MAX_SIZES; i++)
116 {
117 SelectObject(hDC, pData->hFonts[i]);
118 TextOutW(hDC, 20, y, pData->szString, (INT)wcslen(pData->szString));
120 y += tm.tmHeight + 1;
121 SelectObject(hDC, pData->hSizeFont);
122 swprintf(szSize, L"%d", pData->nSizes[i]);
123 TextOutW(hDC, 0, y - 13 - tm.tmDescent, szSize, (INT)wcslen(szSize));
124 }
125 SelectObject(hDC, hOldFont);
126
127 return y;
128}
static HDC hDC
Definition: 3dtext.c:33
#define SPACING1
Definition: display.c:13
#define SPACING2
Definition: display.c:14
#define MAX_SIZES
Definition: display.h:11
#define NULL
Definition: types.h:112
#define swprintf
Definition: precomp.h:40
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define L(x)
Definition: ntvdm.h:50
Definition: time.h:68
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
int32_t INT
Definition: typedefs.h:58
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define BLACK_PEN
Definition: wingdi.h:903
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
#define GetTextMetrics
Definition: wingdi.h:4474
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define LF_FULLFACESIZE
Definition: wingdi.h:41
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Display_OnPaint(), Display_OnPrint(), and Display_SetTypeFace().

◆ Display_GetFullName()

LRESULT Display_GetFullName ( HWND  hwnd,
INT  length,
PWSTR  ptr 
)

Definition at line 510 of file display.c.

511{
513 INT len;
514
516
517 len = wcslen(pData->szTypeFaceName) + wcslen(pData->szFormat) + 2;
518
519 if (ptr != NULL && length >= len)
520 {
521 swprintf(ptr, L"%s%s", pData->szTypeFaceName, pData->szFormat);
522 }
523
524 return (LRESULT)len;
525}
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLsizei len
Definition: glext.h:6722
static PVOID ptr
Definition: dispmode.c:27
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_USERDATA
Definition: treelist.c:63
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by DisplayProc().

◆ Display_InitClass()

BOOL Display_InitClass ( HINSTANCE  hInstance)

Definition at line 40 of file display.c.

41{
42 WNDCLASSEXW wincl;
43
44 /* Set the fontdisplay window class structure */
45 wincl.cbSize = sizeof(WNDCLASSEX);
46 wincl.style = CS_DBLCLKS;
48 wincl.cbClsExtra = 0;
49 wincl.cbWndExtra = 0;
50 wincl.hInstance = hInstance;
51 wincl.hIcon = NULL;
54 wincl.lpszMenuName = NULL;
56 wincl.hIconSm = NULL;
57
58 /* Register the window class, and if it fails return FALSE */
59 if (!RegisterClassExW (&wincl))
60 {
61 return FALSE;
62 }
63 return TRUE;
64}
const WCHAR g_szFontDisplayClassName[]
Definition: display.c:19
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM)
Definition: display.c:528
HINSTANCE hInstance
Definition: charmap.c:19
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LPCWSTR lpszClassName
Definition: winuser.h:3226
LPCWSTR lpszMenuName
Definition: winuser.h:3225
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
int cbWndExtra
Definition: winuser.h:3220
HCURSOR hCursor
Definition: winuser.h:3223
HICON hIconSm
Definition: winuser.h:3227
HINSTANCE hInstance
Definition: winuser.h:3221
UINT style
Definition: winuser.h:3217
int cbClsExtra
Definition: winuser.h:3219
HICON hIcon
Definition: winuser.h:3222
#define WHITE_BRUSH
Definition: wingdi.h:902
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LoadCursor
Definition: winuser.h:5812
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5719

Referenced by wWinMain().

◆ Display_OnCreate()

static LRESULT Display_OnCreate ( HWND  hwnd)
static

Definition at line 254 of file display.c.

255{
257 const int nSizes[MAX_SIZES] = {8, 12, 18, 24, 36, 48, 60, 72};
258 int i;
259 LOGFONTW LogFont = {50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
262 DEFAULT_PITCH , L"MS Shell Dlg"};
263
264 /* Create data structure */
265 pData = malloc(sizeof(DISPLAYDATA));
266 ZeroMemory(pData, sizeof(DISPLAYDATA));
267
268 /* Set the window's GWLP_USERDATA to our data structure */
270
271 for (i = 0; i < MAX_SIZES; i++)
272 {
273 pData->nSizes[i] = nSizes[i];
274 }
275
276 pData->hCaptionFont = CreateFontIndirectW(&LogFont);
277 LogFont.lfHeight = 12;
278 pData->hSizeFont = CreateFontIndirectW(&LogFont);
279
281 L"Jackdaws love my big sphinx of quartz. 1234567890");
282
283 Display_SetTypeFace(hwnd, &LogFont);
284
285 return 0;
286}
static LRESULT Display_SetString(HWND hwnd, LPCWSTR pszString)
Definition: display.c:241
static LRESULT Display_SetTypeFace(HWND hwnd, PLOGFONTW pLogFont)
Definition: display.c:153
#define malloc
Definition: debug_ros.c:4
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
LONG lfHeight
Definition: dimm.idl:59
#define SetWindowLongPtr
Definition: treelist.c:70
#define ZeroMemory
Definition: winbase.h:1712
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define ANSI_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:438
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)

Referenced by DisplayProc().

◆ Display_OnDestroy()

static LRESULT Display_OnDestroy ( HWND  hwnd)
static

Definition at line 398 of file display.c.

399{
401 int i;
402
404
405 /* Delete the fonts */
406 DeleteObject(pData->hCaptionFont);
407 DeleteObject(pData->hCharSetFont);
408 DeleteObject(pData->hSizeFont);
409
410 for (i = 0; i < MAX_SIZES; i++)
411 {
412 DeleteObject(pData->hFonts[i]);
413 }
414
415 /* Free the data structure */
416 free(pData);
417
418 return 0;
419}
#define free
Definition: debug_ros.c:5
pKey DeleteObject()

Referenced by DisplayProc().

◆ Display_OnPaint()

static LRESULT Display_OnPaint ( HWND  hwnd)
static

Definition at line 289 of file display.c.

290{
292 PAINTSTRUCT ps;
293 SCROLLINFO si;
294
296
297 /* Get the Scroll position */
298 si.cbSize = sizeof(si);
299 si.fMask = SIF_POS;
301
302 BeginPaint(hwnd, &ps);
303
304 /* Erase background */
306
307 /* Draw the text */
309
310 EndPaint(hwnd, &ps);
311
312 return 0;
313}
static int Display_DrawText(HDC hDC, DISPLAYDATA *pData, int nYPos)
Definition: display.c:67
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define SB_VERT
Definition: winuser.h:553
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define SIF_POS
Definition: winuser.h:1234
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)

Referenced by DisplayProc().

◆ Display_OnPrint()

LRESULT Display_OnPrint ( HWND  hwnd)

Definition at line 422 of file display.c.

423{
424 PRINTDLG pfont;
426 int copies, yPos;
427
428 /* Clears the memory before using it */
429 ZeroMemory(&pfont, sizeof(pfont));
430
431 pfont.lStructSize = sizeof(pfont);
432 pfont.hwndOwner = hwnd;
433 pfont.hDevMode = NULL;
434 pfont.hDevNames = NULL;
436 pfont.nCopies = 1;
437 pfont.nFromPage = 0xFFFF;
438 pfont.nToPage = 0xFFFF;
439 pfont.nMinPage = 1;
440 pfont.nMaxPage = 0xFFFF;
441
442 /* Opens up the print dialog box */
443 if (PrintDlg(&pfont))
444 {
445 DOCINFO docinfo;
446#if 0
448
449 pData = malloc(sizeof(DISPLAYDATA));
450 ZeroMemory(pData, sizeof(DISPLAYDATA));
451
452 /* Sets up the font layout */
454#endif
455 docinfo.cbSize = sizeof(DOCINFO);
456 docinfo.lpszDocName = L"Printing Font";
457 docinfo.lpszOutput = NULL;
458 docinfo.lpszDatatype = NULL;
459 docinfo.fwType = 0;
460
461 /* We start printing */
462 StartDoc(pfont.hDC, &docinfo);
463
464 /* Grabs the text metrics for the printer */
465 GetTextMetrics(pfont.hDC, &tm);
466
467 /* Start out with 0 for the y position for the page */
468 yPos = 0;
469
470 /* Starts out with the current page */
471 StartPage(pfont.hDC);
472
473 /* Used when printing for more than one copy */
474 for (copies = 0; copies < pfont.nCopies; copies++)
475 {
476 /* Test output */
477 TextOutW(pfont.hDC, 10, yPos, L"Testing...1...2...3", 19);
478
479 /* TODO: Determine if using Display_DrawText() will work for both rendering out to the
480 window and to the printer output */
481#if 0
482 Display_DrawText(pfont.hDC, pData, yPos);
483#endif
484
485 /* Ends the current page */
486 EndPage(pfont.hDC);
487
488 /* If we are making more than one copy, start a new page */
489 if (copies != pfont.nCopies)
490 {
491 yPos = 0;
492 StartPage(pfont.hDC);
493 }
494 }
495
496 /* The printing is now over */
497 EndDoc(pfont.hDC);
498
499 DeleteDC(pfont.hDC);
500#if 0
501 /* Frees the memory since we no longer need it for now */
502 free(pData);
503#endif
504 }
505
506 return 0;
507}
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define PrintDlg
Definition: commdlg.h:668
#define PD_RETURNDC
Definition: commdlg.h:155
int cbSize
Definition: wingdi.h:1676
LPCSTR lpszOutput
Definition: wingdi.h:1678
LPCSTR lpszDatatype
Definition: wingdi.h:1679
LPCSTR lpszDocName
Definition: wingdi.h:1677
DWORD fwType
Definition: wingdi.h:1680
WORD nMaxPage
Definition: commdlg.h:474
HDC hDC
Definition: commdlg.h:469
DWORD Flags
Definition: commdlg.h:470
WORD nCopies
Definition: commdlg.h:475
WORD nFromPage
Definition: commdlg.h:471
HGLOBAL hDevMode
Definition: commdlg.h:467
WORD nToPage
Definition: commdlg.h:472
WORD nMinPage
Definition: commdlg.h:473
HGLOBAL hDevNames
Definition: commdlg.h:468
HWND hwndOwner
Definition: commdlg.h:466
DWORD lStructSize
Definition: commdlg.h:465
int WINAPI EndPage(_In_ HDC)
int WINAPI EndDoc(_In_ HDC)
int WINAPI StartPage(_In_ HDC)
DOCINFOA DOCINFO
Definition: wingdi.h:4414
BOOL WINAPI DeleteDC(_In_ HDC)
#define StartDoc
Definition: wingdi.h:4482

Referenced by MainWndProc().

◆ Display_OnSize()

static LRESULT Display_OnSize ( HWND  hwnd)
static

Definition at line 316 of file display.c.

317{
318 RECT rect;
319 SCROLLINFO si;
320 int nOldPos;
321
323
324 /* Get the old scroll pos */
325 si.cbSize = sizeof(si);
326 si.fMask = SIF_POS;
328 nOldPos = si.nPos;
329
330 /* Set the new page size */
331 si.fMask = SIF_PAGE;
332 si.nPage = rect.bottom;
334
335 /* Get the new scroll pos */
336 si.fMask = SIF_POS;
338
339 /* If they don't match ... */
340 if (nOldPos != si.nPos)
341 {
342 /* ... scroll the window */
343 ScrollWindowEx(hwnd, 0, nOldPos - si.nPos, NULL, NULL, NULL, NULL, SW_INVALIDATE);
345 }
346
347 return 0;
348}
& rect
Definition: startmenu.cpp:1413
#define SW_INVALIDATE
Definition: winuser.h:2579
#define SIF_PAGE
Definition: winuser.h:1233
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI UpdateWindow(_In_ HWND)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)

Referenced by DisplayProc().

◆ Display_OnVScroll()

static LRESULT Display_OnVScroll ( HWND  hwnd,
WPARAM  wParam 
)
static

Definition at line 351 of file display.c.

352{
353 SCROLLINFO si;
354 int nPos;
355
356 si.cbSize = sizeof(si);
359
360 switch(LOWORD(wParam))
361 {
362 case SB_PAGEUP:
363 nPos = si.nPos - 50;
364 break;
365 case SB_PAGEDOWN:
366 nPos = si.nPos + 50;
367 break;
368 case SB_LINEUP:
369 nPos = si.nPos - 10;
370 break;
371 case SB_LINEDOWN:
372 nPos = si.nPos + 10;
373 break;
374 case SB_THUMBTRACK:
375 case SB_THUMBPOSITION:
376 nPos = si.nTrackPos;
377 break;
378 default:
379 nPos = si.nPos;
380 }
381
382 nPos = max(nPos, si.nMin);
383 nPos = min(nPos, si.nMax);
384 if (nPos != si.nPos)
385 {
387 si.cbSize = sizeof(si);
388 si.nPos = nPos;
389 si.fMask = SIF_POS;
392 }
393
394 return 0;
395}
WPARAM wParam
Definition: combotst.c:138
#define min(a, b)
Definition: monoChain.cc:55
#define LOWORD(l)
Definition: pedump.c:82
#define max(a, b)
Definition: svc.c:63
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_LINEUP
Definition: winuser.h:564
#define SIF_RANGE
Definition: winuser.h:1235
#define SIF_TRACKPOS
Definition: winuser.h:1237
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_PAGEUP
Definition: winuser.h:568
#define SB_THUMBPOSITION
Definition: winuser.h:572

Referenced by DisplayProc().

◆ Display_SetString()

static LRESULT Display_SetString ( HWND  hwnd,
LPCWSTR  pszString 
)
static

Definition at line 241 of file display.c.

242{
244
246 lstrcpynW(pData->szString, pszString, ARRAYSIZE(pData->szString));
247
249
250 return 0;
251}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define lstrcpynW
Definition: compat.h:738
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by Display_OnCreate(), and DisplayProc().

◆ Display_SetTypeFace()

static LRESULT Display_SetTypeFace ( HWND  hwnd,
PLOGFONTW  pLogFont 
)
static

Definition at line 153 of file display.c.

154{
157 HDC hDC;
158 RECT rect;
159 SCROLLINFO si;
160 int i;
161 LOGFONTW logfont;
162 BOOL fOpenType;
163 BYTE Buffer[512];
165 LPWSTR pch;
166
167 /* Set the new type face name */
169 lstrcpynW(pData->szTypeFaceName, pLogFont->lfFaceName,
170 ARRAYSIZE(pData->szTypeFaceName));
171
172 /* Create the new fonts */
173 hDC = GetDC(hwnd);
174 DeleteObject(pData->hCharSetFont);
175
176 logfont = *pLogFont;
177 logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
178 pData->hCharSetFont = CreateFontIndirectW(&logfont);
179
180 /* Get font format */
181 SelectObject(hDC, pData->hCharSetFont);
183 if (tm.tmPitchAndFamily & TMPF_TRUETYPE)
184 {
185 if (GetOutlineTextMetricsW(hDC, sizeof(Buffer), pOTM))
186 {
187 LPBYTE pb = Buffer;
188 pb += (WORD)(DWORD_PTR)pOTM->otmpStyleName;
189 pch = (LPWSTR)pb;
190 if (*pch)
191 {
192 lstrcatW(pData->szTypeFaceName, L" ");
193 lstrcatW(pData->szTypeFaceName, pch);
194 }
195 }
196
197 fOpenType = FALSE;
198 EnumFontFamiliesExW(hDC, &logfont,
199 EnumFontFamProcW, (LPARAM)&fOpenType, 0);
200
201 if (fOpenType)
202 swprintf(pData->szFormat, L" (OpenType)");
203 else
204 swprintf(pData->szFormat, L" (TrueType)");
205 }
206 else if (tm.tmPitchAndFamily & TMPF_VECTOR)
207 {
208 swprintf(pData->szFormat, L" (Vector)");
209 }
210 else
211 {
212 swprintf(pData->szFormat, L" (Raster)");
213 }
214
215 for (i = 0; i < MAX_SIZES; i++)
216 {
217 DeleteObject(pData->hFonts[i]);
218 logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);
219 pData->hFonts[i] = CreateFontIndirectW(&logfont);
220 }
221
222 /* Calculate new page dimensions */
223 pData->nPageHeight = Display_DrawText(hDC, pData, 0);
225
226 /* Set the vertical scrolling range and page size */
228 si.cbSize = sizeof(si);
230 si.nMin = 0;
231 si.nMax = pData->nPageHeight;
232 si.nPage = rect.bottom;
233 si.nPos = 0;
234 si.nTrackPos = 0;
236
237 return 0;
238}
static int CALLBACK EnumFontFamProcW(const LOGFONTW *lpelfe, const TEXTMETRICW *lptm, DWORD FontType, LPARAM lParam)
Definition: display.c:132
Definition: bufpool.h:45
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define pch(ap)
Definition: match.c:418
static HDC
Definition: imagelist.c:92
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1910
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG_PTR LPARAM
Definition: windef.h:208
struct _OUTLINETEXTMETRICW * LPOUTLINETEXTMETRICW
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
#define LOGPIXELSY
Definition: wingdi.h:719
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
#define TMPF_VECTOR
Definition: wingdi.h:1312
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193

Referenced by Display_OnCreate(), and DisplayProc().

◆ DisplayProc()

LRESULT CALLBACK DisplayProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 528 of file display.c.

529{
530 switch (message)
531 {
532 case WM_CREATE:
533 return Display_OnCreate(hwnd);
534
535 case WM_PAINT:
536 return Display_OnPaint(hwnd);
537
538 case WM_SIZE:
539 return Display_OnSize(hwnd);
540
541 case WM_VSCROLL:
543
544 case FVM_SETTYPEFACE:
546
547 case FVM_SETSTRING:
549
550 case FVM_GETFULLNAME:
552
553 case WM_DESTROY:
554 return Display_OnDestroy(hwnd);
555
556 default:
558 }
559
560 return 0;
561}
static LRESULT Display_OnDestroy(HWND hwnd)
Definition: display.c:398
LRESULT Display_GetFullName(HWND hwnd, INT length, PWSTR ptr)
Definition: display.c:510
static LRESULT Display_OnVScroll(HWND hwnd, WPARAM wParam)
Definition: display.c:351
static LRESULT Display_OnPaint(HWND hwnd)
Definition: display.c:289
static LRESULT Display_OnCreate(HWND hwnd)
Definition: display.c:254
static LRESULT Display_OnSize(HWND hwnd)
Definition: display.c:316
#define FVM_SETSTRING
Definition: display.h:5
#define FVM_GETFULLNAME
Definition: display.h:6
#define FVM_SETTYPEFACE
Definition: display.h:4
LPARAM lParam
Definition: combotst.c:139
Definition: tftpd.h:60
uint16_t * PWSTR
Definition: typedefs.h:56
#define WM_PAINT
Definition: winuser.h:1620
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1744
#define WM_CREATE
Definition: winuser.h:1608
#define WM_SIZE
Definition: winuser.h:1611
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by Display_InitClass().

◆ EnumFontFamProcW()

static int CALLBACK EnumFontFamProcW ( const LOGFONTW lpelfe,
const TEXTMETRICW lptm,
DWORD  FontType,
LPARAM  lParam 
)
static

Definition at line 132 of file display.c.

137{
139 PBOOL pfOpenType = (PBOOL)lParam;
140
141 if (FontType & TRUETYPE_FONTTYPE)
142 {
144 {
145 *pfOpenType = TRUE;
146 return FALSE;
147 }
148 }
149 return TRUE;
150}
static LPTEXTMETRICW lptm
Definition: font.c:42
BOOL * PBOOL
Definition: windef.h:161
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109
#define NTM_TT_OPENTYPE
Definition: wingdi.h:27
struct tagNEWTEXTMETRICW * PNEWTEXTMETRICW
#define NTM_PS_OPENTYPE
Definition: wingdi.h:26

Referenced by Display_SetTypeFace().

Variable Documentation

◆ g_FontTitle

WCHAR g_FontTitle[]
extern

Definition at line 24 of file fontview.c.

Referenced by wWinMain().

◆ g_NumFonts

INT g_NumFonts
extern

Definition at line 21 of file fontview.c.

Referenced by MainWnd_OnCreate(), MainWnd_OnNext(), and wWinMain().

◆ g_szFontDisplayClassName

const WCHAR g_szFontDisplayClassName[] = L"FontDisplayClass"

Definition at line 19 of file display.c.

Referenced by Display_InitClass(), and MainWnd_OnCreate().