ReactOS  0.4.12-dev-721-g03c3dd5
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;
85  TEXTMETRIC tm;
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);
110  GetTextMetrics(hDC, &tm);
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));
134  GetTextMetrics(hDC, &tm);
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define LF_FULLFACESIZE
Definition: wingdi.h:41
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SPACING2
Definition: display.c:29
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define GetTextMetrics
Definition: wingdi.h:4452
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
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
smooth NULL
Definition: ftsmooth.c:416
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SPACING1
Definition: display.c:28
static const WCHAR L[]
Definition: oid.c:1250
Definition: time.h:76
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
static HDC hDC
Definition: 3dtext.c:33
#define BLACK_PEN
Definition: wingdi.h:902
#define MAX_SIZES
Definition: display.h:11
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int32_t INT
Definition: typedefs.h:56
static PVOID ptr
Definition: dispmode.c:27
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG_PTR LRESULT
Definition: windef.h:209
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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;
62  wincl.lpfnWndProc = DisplayProc;
63  wincl.cbClsExtra = 0;
64  wincl.cbWndExtra = 0;
65  wincl.hInstance = hInstance;
66  wincl.hIcon = NULL;
67  wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRUE
Definition: types.h:120
int cbWndExtra
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3175
#define WHITE_BRUSH
Definition: wingdi.h:901
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
HINSTANCE hInstance
Definition: charmap.c:20
LPCWSTR lpszMenuName
Definition: winuser.h:3178
smooth NULL
Definition: ftsmooth.c:416
int cbClsExtra
Definition: winuser.h:3172
LPCWSTR lpszClassName
Definition: winuser.h:3179
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
HINSTANCE hInstance
Definition: winuser.h:3174
HCURSOR hCursor
Definition: winuser.h:3176
#define CS_DBLCLKS
Definition: winuser.h:646
UINT style
Definition: winuser.h:3170
#define LoadCursor
Definition: winuser.h:5678
WNDPROC lpfnWndProc
Definition: winuser.h:3171
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM)
Definition: display.c:543
HICON hIconSm
Definition: winuser.h:3180
#define IDC_ARROW
Definition: winuser.h:682
const WCHAR g_szFontDisplayClassName[]
Definition: display.c:34
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585

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_SetTypeFace(HWND hwnd, PLOGFONTW pLogFont)
Definition: display.c:168
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG lfHeight
Definition: dimm.idl:59
#define ZeroMemory
Definition: winbase.h:1635
#define PROOF_QUALITY
Definition: wingdi.h:437
#define SetWindowLongPtr
Definition: treelist.c:70
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
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
#define GWLP_USERDATA
Definition: treelist.c:63
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define DEFAULT_PITCH
Definition: wingdi.h:442
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_SIZES
Definition: display.h:11
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define FW_NORMAL
Definition: wingdi.h:372
#define malloc
Definition: debug_ros.c:4
#define ANSI_CHARSET
Definition: wingdi.h:382
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static LRESULT Display_SetString(HWND hwnd, LPCWSTR pszString)
Definition: display.c:256

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define free
Definition: debug_ros.c:5
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
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
#define GWLP_USERDATA
Definition: treelist.c:63
#define MAX_SIZES
Definition: display.h:11
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

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;
315  GetScrollInfo(hwnd, SB_VERT, &si);
316 
317  BeginPaint(hwnd, &ps);
318 
319  /* Erase background */
321 
322  /* Draw the text */
323  Display_DrawText(ps.hdc, pData, si.nPos);
324 
325  EndPaint(hwnd, &ps);
326 
327  return 0;
328 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SB_VERT
Definition: winuser.h:553
#define WHITE_BRUSH
Definition: wingdi.h:901
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWLP_USERDATA
Definition: treelist.c:63
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SIF_POS
Definition: winuser.h:1220
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
static int Display_DrawText(HDC hDC, DISPLAYDATA *pData, int nYPos)
Definition: display.c:82

Referenced by DisplayProc().

◆ Display_OnPrint()

LRESULT Display_OnPrint ( HWND  hwnd)

Definition at line 437 of file display.c.

438 {
439  PRINTDLG pfont;
440  TEXTMETRIC tm;
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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WORD nMaxPage
Definition: commdlg.h:474
#define free
Definition: debug_ros.c:5
#define ZeroMemory
Definition: winbase.h:1635
WORD nCopies
Definition: commdlg.h:475
#define GetTextMetrics
Definition: wingdi.h:4452
int WINAPI EndPage(_In_ HDC)
WORD nMinPage
Definition: commdlg.h:473
int WINAPI StartPage(_In_ HDC)
HANDLE hDevNames
Definition: commdlg.h:468
#define PrintDlg
Definition: commdlg.h:668
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define GWLP_USERDATA
Definition: treelist.c:63
WORD nFromPage
Definition: commdlg.h:471
smooth NULL
Definition: ftsmooth.c:416
#define PD_RETURNDC
Definition: commdlg.h:155
DWORD fwType
Definition: wingdi.h:1658
LPCSTR lpszOutput
Definition: wingdi.h:1656
LPCSTR lpszDatatype
Definition: wingdi.h:1657
static const WCHAR L[]
Definition: oid.c:1250
Definition: time.h:76
int cbSize
Definition: wingdi.h:1654
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
HWND hwndOwner
Definition: commdlg.h:466
BOOL WINAPI DeleteDC(_In_ HDC)
LPCSTR lpszDocName
Definition: wingdi.h:1655
DWORD lStructSize
Definition: commdlg.h:465
WORD nToPage
Definition: commdlg.h:472
#define malloc
Definition: debug_ros.c:4
DWORD Flags
Definition: commdlg.h:470
#define StartDoc
Definition: wingdi.h:4460
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
HDC hDC
Definition: commdlg.h:469
HANDLE hDevMode
Definition: commdlg.h:467
DOCINFOA DOCINFO
Definition: wingdi.h:4392
int WINAPI EndDoc(_In_ HDC)
static int Display_DrawText(HDC hDC, DISPLAYDATA *pData, int nYPos)
Definition: display.c:82

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;
342  GetScrollInfo(hwnd, SB_VERT, &si);
343  nOldPos = si.nPos;
344 
345  /* Set the new page size */
346  si.fMask = SIF_PAGE;
347  si.nPage = rect.bottom;
348  SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
349 
350  /* Get the new scroll pos */
351  si.fMask = SIF_POS;
352  GetScrollInfo(hwnd, SB_VERT, &si);
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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define SB_VERT
Definition: winuser.h:553
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SIF_PAGE
Definition: winuser.h:1219
& rect
Definition: startmenu.cpp:1413
smooth NULL
Definition: ftsmooth.c:416
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

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);
373  GetScrollInfo(hwnd, SB_VERT, &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;
405  SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
407  }
408 
409  return 0;
410 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
#define SB_VERT
Definition: winuser.h:553
BOOL WINAPI UpdateWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define SB_THUMBPOSITION
Definition: winuser.h:572
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
#define SB_THUMBTRACK
Definition: winuser.h:573
INT INT nPos
Definition: msvc.h:57
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define min(a, b)
Definition: monoChain.cc:55
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
#define LOWORD(l)
Definition: pedump.c:82
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define lstrcpynW
Definition: compat.h:397
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4509

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 {
171  TEXTMETRIC tm;
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);
197  GetTextMetrics(hDC, &tm);
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);
239  ReleaseDC(hwnd, hDC);
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;
250  SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
251 
252  return 0;
253 }
#define HDC
Definition: msvc.h:22
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_VERT
Definition: winuser.h:553
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
LONG lfHeight
Definition: dimm.idl:59
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GetTextMetrics
Definition: wingdi.h:4452
#define SIF_PAGE
Definition: winuser.h:1219
& rect
Definition: startmenu.cpp:1413
#define lstrcpynW
Definition: compat.h:397
struct _OUTLINETEXTMETRICW * LPOUTLINETEXTMETRICW
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
unsigned char * LPBYTE
Definition: typedefs.h:52
static int CALLBACK EnumFontFamProcW(const LOGFONTW *lpelfe, const TEXTMETRICW *lptm, DWORD FontType, LPARAM lParam)
Definition: display.c:147
#define TMPF_TRUETYPE
Definition: wingdi.h:1295
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
Definition: bufpool.h:45
unsigned int BOOL
Definition: ntddk_ex.h:94
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned short WORD
Definition: ntddk_ex.h:93
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
unsigned char BYTE
Definition: mem.h:68
Definition: time.h:76
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define TMPF_VECTOR
Definition: wingdi.h:1294
#define SIF_POS
Definition: winuser.h:1220
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define MAX_SIZES
Definition: display.h:11
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)
#define LOGPIXELSY
Definition: wingdi.h:718
WCHAR * pch
Definition: msvc.h:81
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define GetWindowLongPtr
Definition: treelist.c:73
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1888
WCHAR * LPWSTR
Definition: xmlstorage.h:184
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
static int Display_DrawText(HDC hDC, DISPLAYDATA *pData, int nYPos)
Definition: display.c:82

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:
557  return Display_OnVScroll(hwnd, wParam);
558 
559  case FVM_SETTYPEFACE:
561 
562  case FVM_SETSTRING:
563  return Display_SetString(hwnd, (WCHAR *)lParam);
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
static LRESULT Display_SetTypeFace(HWND hwnd, PLOGFONTW pLogFont)
Definition: display.c:168
static LRESULT Display_OnPaint(HWND hwnd)
Definition: display.c:304
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint16_t * PWSTR
Definition: typedefs.h:54
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static LRESULT Display_OnCreate(HWND hwnd)
Definition: display.c:269
static LRESULT Display_OnVScroll(HWND hwnd, WPARAM wParam)
Definition: display.c:366
LRESULT Display_GetFullName(HWND hwnd, INT length, PWSTR ptr)
Definition: display.c:525
#define FVM_SETTYPEFACE
Definition: display.h:4
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_SIZE
Definition: winuser.h:1593
#define WM_PAINT
Definition: winuser.h:1602
#define FVM_SETSTRING
Definition: display.h:5
#define FVM_GETFULLNAME
Definition: display.h:6
static LRESULT Display_OnSize(HWND hwnd)
Definition: display.c:331
#define WM_CREATE
Definition: winuser.h:1590
LPARAM lParam
Definition: combotst.c:139
#define WM_VSCROLL
Definition: winuser.h:1720
static LRESULT Display_SetString(HWND hwnd, LPCWSTR pszString)
Definition: display.c:256

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  {
158  if (pntmw->ntmFlags & (NTM_TT_OPENTYPE | NTM_PS_OPENTYPE))
159  {
160  *pfOpenType = TRUE;
161  return FALSE;
162  }
163  }
164  return TRUE;
165 }
#define TRUE
Definition: types.h:120
struct tagNEWTEXTMETRICW * PNEWTEXTMETRICW
BOOL * PBOOL
Definition: windef.h:161
#define NTM_PS_OPENTYPE
Definition: wingdi.h:26
LPARAM lParam
Definition: combotst.c:139
static LPTEXTMETRICW lptm
Definition: font.c:42
#define NTM_TT_OPENTYPE
Definition: wingdi.h:27
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1091

Referenced by Display_SetTypeFace().

Variable Documentation

◆ g_FontTitle

WCHAR g_FontTitle[]

Definition at line 39 of file fontview.c.

Referenced by wWinMain().

◆ g_NumFonts

INT g_NumFonts

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().