ReactOS 0.4.15-dev-5875-g7c755d9
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 28 of file display.c.

◆ SPACING2

#define SPACING2   5

Definition at line 29 of file display.c.

Function Documentation

◆ Display_DrawText()

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

Definition at line 82 of file display.c.

83{
84 HFONT hOldFont;
86 int i, y;
87 WCHAR szSize[5];
88 WCHAR szCaption[LF_FULLFACESIZE + 20];
89
90 /* This is the location on the DC where we draw */
91 y = -nYPos;
92
93 hOldFont = SelectObject(hDC, pData->hCaptionFont);
95
96 swprintf(szCaption, L"%s%s", pData->szTypeFaceName, pData->szFormat);
97 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
98 y += tm.tmHeight + SPACING1;
99
100 /* Draw a separation Line */
102 MoveToEx(hDC, 0, y, NULL);
103 LineTo(hDC, 10000, y);
104 y += SPACING2;
105
106 /* TODO: Output font info */
107
108 /* Output Character set */
109 SelectObject(hDC, pData->hCharSetFont);
111 swprintf(szCaption, L"abcdefghijklmnopqrstuvwxyz");
112 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
113 y += tm.tmHeight + 1;
114
115 swprintf(szCaption, L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
116 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
117 y += tm.tmHeight + 1;
118
119 swprintf(szCaption, L"0123456789.:,;(\"~!@#$%%^&*')");
120 TextOutW(hDC, 0, y, szCaption, (INT)wcslen(szCaption));
121 y += tm.tmHeight + 1;
122
123 /* Draw a separation Line */
125 MoveToEx(hDC, 0, y, NULL);
126 LineTo(hDC, 10000, y);
127 y += SPACING2;
128
129 /* Output the strings for different sizes */
130 for (i = 0; i < MAX_SIZES; i++)
131 {
132 SelectObject(hDC, pData->hFonts[i]);
133 TextOutW(hDC, 20, y, pData->szString, (INT)wcslen(pData->szString));
135 y += tm.tmHeight + 1;
136 SelectObject(hDC, pData->hSizeFont);
137 swprintf(szSize, L"%d", pData->nSizes[i]);
138 TextOutW(hDC, 0, y - 13 - tm.tmDescent, szSize, (INT)wcslen(szSize));
139 }
140 SelectObject(hDC, hOldFont);
141
142 return y;
143}
static HDC hDC
Definition: 3dtext.c:33
#define SPACING1
Definition: display.c:28
#define SPACING2
Definition: display.c:29
#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 525 of file display.c.

526{
528 INT len;
529
531
532 len = wcslen(pData->szTypeFaceName) + wcslen(pData->szFormat) + 2;
533
534 if (ptr != NULL && length >= len)
535 {
536 swprintf(ptr, L"%s%s", pData->szTypeFaceName, pData->szFormat);
537 }
538
539 return (LRESULT)len;
540}
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 55 of file display.c.

56{
57 WNDCLASSEXW wincl;
58
59 /* Set the fontdisplay window class structure */
60 wincl.cbSize = sizeof(WNDCLASSEX);
61 wincl.style = CS_DBLCLKS;
63 wincl.cbClsExtra = 0;
64 wincl.cbWndExtra = 0;
65 wincl.hInstance = hInstance;
66 wincl.hIcon = NULL;
69 wincl.lpszMenuName = NULL;
71 wincl.hIconSm = NULL;
72
73 /* Register the window class, and if it fails return FALSE */
74 if (!RegisterClassExW (&wincl))
75 {
76 return FALSE;
77 }
78 return TRUE;
79}
const WCHAR g_szFontDisplayClassName[]
Definition: display.c:34
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM)
Definition: display.c:543
HINSTANCE hInstance
Definition: charmap.c:19
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LPCWSTR lpszClassName
Definition: winuser.h:3216
LPCWSTR lpszMenuName
Definition: winuser.h:3215
HBRUSH hbrBackground
Definition: winuser.h:3214
WNDPROC lpfnWndProc
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3206
int cbWndExtra
Definition: winuser.h:3210
HCURSOR hCursor
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3217
HINSTANCE hInstance
Definition: winuser.h:3211
UINT style
Definition: winuser.h:3207
int cbClsExtra
Definition: winuser.h:3209
HICON hIcon
Definition: winuser.h:3212
#define WHITE_BRUSH
Definition: wingdi.h:902
#define IDC_ARROW
Definition: winuser.h:682
#define CS_DBLCLKS
Definition: winuser.h:646
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LoadCursor
Definition: winuser.h:5802
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5709

Referenced by wWinMain().

◆ Display_OnCreate()

static LRESULT Display_OnCreate ( HWND  hwnd)
static

Definition at line 269 of file display.c.

270{
272 const int nSizes[MAX_SIZES] = {8, 12, 18, 24, 36, 48, 60, 72};
273 int i;
274 LOGFONTW LogFont = {50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
277 DEFAULT_PITCH , L"MS Shell Dlg"};
278
279 /* Create data structure */
280 pData = malloc(sizeof(DISPLAYDATA));
281 ZeroMemory(pData, sizeof(DISPLAYDATA));
282
283 /* Set the window's GWLP_USERDATA to our data structure */
285
286 for (i = 0; i < MAX_SIZES; i++)
287 {
288 pData->nSizes[i] = nSizes[i];
289 }
290
291 pData->hCaptionFont = CreateFontIndirectW(&LogFont);
292 LogFont.lfHeight = 12;
293 pData->hSizeFont = CreateFontIndirectW(&LogFont);
294
296 L"Jackdaws love my big sphinx of quartz. 1234567890");
297
298 Display_SetTypeFace(hwnd, &LogFont);
299
300 return 0;
301}
static LRESULT Display_SetString(HWND hwnd, LPCWSTR pszString)
Definition: display.c:256
static LRESULT Display_SetTypeFace(HWND hwnd, PLOGFONTW pLogFont)
Definition: display.c:168
#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:1670
#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 413 of file display.c.

414{
416 int i;
417
419
420 /* Delete the fonts */
421 DeleteObject(pData->hCaptionFont);
422 DeleteObject(pData->hCharSetFont);
423 DeleteObject(pData->hSizeFont);
424
425 for (i = 0; i < MAX_SIZES; i++)
426 {
427 DeleteObject(pData->hFonts[i]);
428 }
429
430 /* Free the data structure */
431 free(pData);
432
433 return 0;
434}
#define free
Definition: debug_ros.c:5
pKey DeleteObject()

Referenced by DisplayProc().

◆ Display_OnPaint()

static LRESULT Display_OnPaint ( HWND  hwnd)
static

Definition at line 304 of file display.c.

305{
307 PAINTSTRUCT ps;
308 SCROLLINFO si;
309
311
312 /* Get the Scroll position */
313 si.cbSize = sizeof(si);
314 si.fMask = SIF_POS;
316
317 BeginPaint(hwnd, &ps);
318
319 /* Erase background */
321
322 /* Draw the text */
324
325 EndPaint(hwnd, &ps);
326
327 return 0;
328}
static int Display_DrawText(HDC hDC, DISPLAYDATA *pData, int nYPos)
Definition: display.c:82
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:1224
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 437 of file display.c.

438{
439 PRINTDLG pfont;
441 int copies, yPos;
442
443 /* Clears the memory before using it */
444 ZeroMemory(&pfont, sizeof(pfont));
445
446 pfont.lStructSize = sizeof(pfont);
447 pfont.hwndOwner = hwnd;
448 pfont.hDevMode = NULL;
449 pfont.hDevNames = NULL;
451 pfont.nCopies = 1;
452 pfont.nFromPage = 0xFFFF;
453 pfont.nToPage = 0xFFFF;
454 pfont.nMinPage = 1;
455 pfont.nMaxPage = 0xFFFF;
456
457 /* Opens up the print dialog box */
458 if (PrintDlg(&pfont))
459 {
460 DOCINFO docinfo;
461#if 0
463
464 pData = malloc(sizeof(DISPLAYDATA));
465 ZeroMemory(pData, sizeof(DISPLAYDATA));
466
467 /* Sets up the font layout */
469#endif
470 docinfo.cbSize = sizeof(DOCINFO);
471 docinfo.lpszDocName = L"Printing Font";
472 docinfo.lpszOutput = NULL;
473 docinfo.lpszDatatype = NULL;
474 docinfo.fwType = 0;
475
476 /* We start printing */
477 StartDoc(pfont.hDC, &docinfo);
478
479 /* Grabs the text metrics for the printer */
480 GetTextMetrics(pfont.hDC, &tm);
481
482 /* Start out with 0 for the y position for the page */
483 yPos = 0;
484
485 /* Starts out with the current page */
486 StartPage(pfont.hDC);
487
488 /* Used when printing for more than one copy */
489 for (copies = 0; copies < pfont.nCopies; copies++)
490 {
491 /* Test output */
492 TextOutW(pfont.hDC, 10, yPos, L"Testing...1...2...3", 19);
493
494 /* TODO: Determine if using Display_DrawText() will work for both rendering out to the
495 window and to the printer output */
496#if 0
497 Display_DrawText(pfont.hDC, pData, yPos);
498#endif
499
500 /* Ends the current page */
501 EndPage(pfont.hDC);
502
503 /* If we are making more than one copy, start a new page */
504 if (copies != pfont.nCopies)
505 {
506 yPos = 0;
507 StartPage(pfont.hDC);
508 }
509 }
510
511 /* The printing is now over */
512 EndDoc(pfont.hDC);
513
514 DeleteDC(pfont.hDC);
515#if 0
516 /* Frees the memory since we no longer need it for now */
517 free(pData);
518#endif
519 }
520
521 return 0;
522}
#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 331 of file display.c.

332{
333 RECT rect;
334 SCROLLINFO si;
335 int nOldPos;
336
338
339 /* Get the old scroll pos */
340 si.cbSize = sizeof(si);
341 si.fMask = SIF_POS;
343 nOldPos = si.nPos;
344
345 /* Set the new page size */
346 si.fMask = SIF_PAGE;
347 si.nPage = rect.bottom;
349
350 /* Get the new scroll pos */
351 si.fMask = SIF_POS;
353
354 /* If they don't match ... */
355 if (nOldPos != si.nPos)
356 {
357 /* ... scroll the window */
358 ScrollWindowEx(hwnd, 0, nOldPos - si.nPos, NULL, NULL, NULL, NULL, SW_INVALIDATE);
360 }
361
362 return 0;
363}
& rect
Definition: startmenu.cpp:1413
#define SW_INVALIDATE
Definition: winuser.h:2569
#define SIF_PAGE
Definition: winuser.h:1223
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 366 of file display.c.

367{
368 SCROLLINFO si;
369 int nPos;
370
371 si.cbSize = sizeof(si);
374
375 switch(LOWORD(wParam))
376 {
377 case SB_PAGEUP:
378 nPos = si.nPos - 50;
379 break;
380 case SB_PAGEDOWN:
381 nPos = si.nPos + 50;
382 break;
383 case SB_LINEUP:
384 nPos = si.nPos - 10;
385 break;
386 case SB_LINEDOWN:
387 nPos = si.nPos + 10;
388 break;
389 case SB_THUMBTRACK:
390 case SB_THUMBPOSITION:
391 nPos = si.nTrackPos;
392 break;
393 default:
394 nPos = si.nPos;
395 }
396
397 nPos = max(nPos, si.nMin);
398 nPos = min(nPos, si.nMax);
399 if (nPos != si.nPos)
400 {
402 si.cbSize = sizeof(si);
403 si.nPos = nPos;
404 si.fMask = SIF_POS;
407 }
408
409 return 0;
410}
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:1225
#define SIF_TRACKPOS
Definition: winuser.h:1227
#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 256 of file display.c.

257{
259
261 lstrcpynW(pData->szString, pszString, ARRAYSIZE(pData->szString));
262
264
265 return 0;
266}
#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 168 of file display.c.

169{
172 HDC hDC;
173 RECT rect;
174 SCROLLINFO si;
175 int i;
176 LOGFONTW logfont;
177 BOOL fOpenType;
178 BYTE Buffer[512];
180 LPWSTR pch;
181
182 /* Set the new type face name */
184 lstrcpynW(pData->szTypeFaceName, pLogFont->lfFaceName,
185 ARRAYSIZE(pData->szTypeFaceName));
186
187 /* Create the new fonts */
188 hDC = GetDC(hwnd);
189 DeleteObject(pData->hCharSetFont);
190
191 logfont = *pLogFont;
192 logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
193 pData->hCharSetFont = CreateFontIndirectW(&logfont);
194
195 /* Get font format */
196 SelectObject(hDC, pData->hCharSetFont);
198 if (tm.tmPitchAndFamily & TMPF_TRUETYPE)
199 {
200 if (GetOutlineTextMetricsW(hDC, sizeof(Buffer), pOTM))
201 {
202 LPBYTE pb = Buffer;
203 pb += (WORD)(DWORD_PTR)pOTM->otmpStyleName;
204 pch = (LPWSTR)pb;
205 if (*pch)
206 {
207 lstrcatW(pData->szTypeFaceName, L" ");
208 lstrcatW(pData->szTypeFaceName, pch);
209 }
210 }
211
212 fOpenType = FALSE;
213 EnumFontFamiliesExW(hDC, &logfont,
214 EnumFontFamProcW, (LPARAM)&fOpenType, 0);
215
216 if (fOpenType)
217 swprintf(pData->szFormat, L" (OpenType)");
218 else
219 swprintf(pData->szFormat, L" (TrueType)");
220 }
221 else if (tm.tmPitchAndFamily & TMPF_VECTOR)
222 {
223 swprintf(pData->szFormat, L" (Vector)");
224 }
225 else
226 {
227 swprintf(pData->szFormat, L" (Raster)");
228 }
229
230 for (i = 0; i < MAX_SIZES; i++)
231 {
232 DeleteObject(pData->hFonts[i]);
233 logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);
234 pData->hFonts[i] = CreateFontIndirectW(&logfont);
235 }
236
237 /* Calculate new page dimensions */
238 pData->nPageHeight = Display_DrawText(hDC, pData, 0);
240
241 /* Set the vertical scrolling range and page size */
243 si.cbSize = sizeof(si);
245 si.nMin = 0;
246 si.nMax = pData->nPageHeight;
247 si.nPage = rect.bottom;
248 si.nPos = 0;
249 si.nTrackPos = 0;
251
252 return 0;
253}
static int CALLBACK EnumFontFamProcW(const LOGFONTW *lpelfe, const TEXTMETRICW *lptm, DWORD FontType, LPARAM lParam)
Definition: display.c:147
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 543 of file display.c.

544{
545 switch (message)
546 {
547 case WM_CREATE:
548 return Display_OnCreate(hwnd);
549
550 case WM_PAINT:
551 return Display_OnPaint(hwnd);
552
553 case WM_SIZE:
554 return Display_OnSize(hwnd);
555
556 case WM_VSCROLL:
558
559 case FVM_SETTYPEFACE:
561
562 case FVM_SETSTRING:
564
565 case FVM_GETFULLNAME:
567
568 case WM_DESTROY:
569 return Display_OnDestroy(hwnd);
570
571 default:
573 }
574
575 return 0;
576}
static LRESULT Display_OnDestroy(HWND hwnd)
Definition: display.c:413
LRESULT Display_GetFullName(HWND hwnd, INT length, PWSTR ptr)
Definition: display.c:525
static LRESULT Display_OnVScroll(HWND hwnd, WPARAM wParam)
Definition: display.c:366
static LRESULT Display_OnPaint(HWND hwnd)
Definition: display.c:304
static LRESULT Display_OnCreate(HWND hwnd)
Definition: display.c:269
static LRESULT Display_OnSize(HWND hwnd)
Definition: display.c:331
#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:1610
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1734
#define WM_CREATE
Definition: winuser.h:1598
#define WM_SIZE
Definition: winuser.h:1601
#define WM_DESTROY
Definition: winuser.h:1599

Referenced by Display_InitClass().

◆ EnumFontFamProcW()

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

Definition at line 147 of file display.c.

152{
154 PBOOL pfOpenType = (PBOOL)lParam;
155
156 if (FontType & TRUETYPE_FONTTYPE)
157 {
159 {
160 *pfOpenType = TRUE;
161 return FALSE;
162 }
163 }
164 return TRUE;
165}
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 39 of file fontview.c.

Referenced by wWinMain().

◆ g_NumFonts

INT g_NumFonts
extern

Definition at line 36 of file fontview.c.

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

◆ g_szFontDisplayClassName

const WCHAR g_szFontDisplayClassName[] = L"FontDisplayClass"

Definition at line 34 of file display.c.

Referenced by Display_InitClass(), and MainWnd_OnCreate().