ReactOS  0.4.15-dev-1374-g8d3e80e
DrawText.c File Reference
#include "precomp.h"
Include dependency graph for DrawText.c:

Go to the source code of this file.

Classes

struct  YY
 
struct  TEST_ENTRY
 

Macros

#define DT_1   (DT_CALCRECT | DT_SINGLELINE | DT_LEFT | DT_TOP)
 
#define DT_2   (DT_CALCRECT | DT_SINGLELINE | DT_LEFT | DT_VCENTER)
 
#define DT_3   (DT_CALCRECT | DT_LEFT | DT_TOP)
 
#define DT_4   (DT_CALCRECT | DT_LEFT | DT_VCENTER)
 
#define DT_5   (DT_CALCRECT | DT_LEFT | DT_TOP | DT_EDITCONTROL)
 
#define DT_6   (DT_SINGLELINE | DT_LEFT | DT_TOP)
 
#define DT_7   (DT_SINGLELINE | DT_LEFT | DT_VCENTER)
 
#define DT_8   (DT_LEFT | DT_TOP)
 
#define DT_9   (DT_LEFT | DT_VCENTER)
 
#define DT_10   (DT_LEFT | DT_TOP | DT_EDITCONTROL)
 

Typedefs

typedef struct YY YY
 
typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static void DoEntry (HDC hdc, const TEST_ENTRY *pEntry)
 
 START_TEST (DrawText)
 

Variables

static const TEST_ENTRY s_entries []
 

Macro Definition Documentation

◆ DT_1

Definition at line 27 of file DrawText.c.

◆ DT_10

#define DT_10   (DT_LEFT | DT_TOP | DT_EDITCONTROL)

Definition at line 37 of file DrawText.c.

◆ DT_2

Definition at line 28 of file DrawText.c.

◆ DT_3

#define DT_3   (DT_CALCRECT | DT_LEFT | DT_TOP)

Definition at line 29 of file DrawText.c.

◆ DT_4

Definition at line 30 of file DrawText.c.

◆ DT_5

Definition at line 31 of file DrawText.c.

◆ DT_6

#define DT_6   (DT_SINGLELINE | DT_LEFT | DT_TOP)

Definition at line 33 of file DrawText.c.

◆ DT_7

Definition at line 34 of file DrawText.c.

◆ DT_8

#define DT_8   (DT_LEFT | DT_TOP)

Definition at line 35 of file DrawText.c.

◆ DT_9

#define DT_9   (DT_LEFT | DT_VCENTER)

Definition at line 36 of file DrawText.c.

Typedef Documentation

◆ TEST_ENTRY

◆ YY

typedef struct YY YY

Function Documentation

◆ DoEntry()

static void DoEntry ( HDC  hdc,
const TEST_ENTRY pEntry 
)
static

Definition at line 342 of file DrawText.c.

343 {
344  RECT rc;
345  INT ret;
346  HFONT hFont;
347  HGDIOBJ hFontOld;
348  LONG x, y, yMin, yMax;
349  LOGFONTW lf = { pEntry->font_height };
350  lstrcpyW(lf.lfFaceName, L"Tahoma");
351 
352  hFont = CreateFontIndirectW(&lf);
353  ok(hFont != NULL, "hFont is NULL\n");
354 
355  hFontOld = SelectObject(hdc, hFont);
356  {
357  rc = pEntry->input;
358 
359  if (!(pEntry->uFormat & DT_CALCRECT))
360  FillRect(hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
361 
362  ret = DrawTextA(hdc, pEntry->pszText, -1, &rc, pEntry->uFormat);
363  ok(ret == pEntry->ret,
364  "Line %d: ret %d vs %d\n", pEntry->line, ret, pEntry->ret);
365 
366  if (!(pEntry->uFormat & DT_CALCRECT))
367  {
368  yMin = rc.bottom;
369  yMax = rc.top;
370  for (y = rc.top; y < rc.bottom; ++y)
371  {
372  BOOL bNonWhiteFound = FALSE;
373  for (x = rc.left; x < rc.right; ++x)
374  {
375  if (GetPixel(hdc, x, y) != RGB(255, 255, 255))
376  {
377  bNonWhiteFound = TRUE;
378  break;
379  }
380  }
381  if (!bNonWhiteFound)
382  {
383  if (yMin > y)
384  yMin = y;
385  if (yMax < y)
386  yMax = y;
387  }
388  }
389  rc.top = yMin;
390  rc.bottom = yMax;
391  }
392 
393  ok(rc.top == pEntry->output.top,
394  "Line %d: top %ld vs %ld\n", pEntry->line, rc.top, pEntry->output.top);
395 
396  ok(rc.bottom == pEntry->output.bottom,
397  "Line %d: bottom %ld vs %ld\n", pEntry->line, rc.bottom, pEntry->output.bottom);
398  }
399  SelectObject(hdc, hFontOld);
401 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define RGB(r, g, b)
Definition: precomp.h:62
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WHITE_BRUSH
Definition: wingdi.h:901
LONG left
Definition: windef.h:306
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
HFONT hFont
Definition: main.c:53
#define FALSE
Definition: types.h:117
#define DT_CALCRECT
Definition: winuser.h:526
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int ret
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
INT WINAPI DrawTextA(HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
Definition: font.c:373
#define lstrcpyW
Definition: compat.h:608
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( DrawText  )

Definition at line 403 of file DrawText.c.

404 {
405  SIZE_T i;
406  HBITMAP hbm;
407  HGDIOBJ hbmOld;
409  ok(hdc != NULL, "hdc was NULL\n");
410 
411  hbm = CreateCompatibleBitmap(hdc, 100, 100);
412  hbmOld = SelectObject(hdc, hbm);
413 
414  SetTextColor(hdc, RGB(0, 0, 0));
415  SetBkColor(hdc, RGB(255, 255, 255));
416  SetBkMode(hdc, OPAQUE);
417  for (i = 0; i < ARRAYSIZE(s_entries); ++i)
418  {
419  DoEntry(hdc, &s_entries[i]);
420  }
421 
422  SelectObject(hdc, hbmOld);
423  DeleteObject(hbm);
424  DeleteDC(hdc);
425 }
static const TEST_ENTRY s_entries[]
Definition: DrawText.c:39
static void DoEntry(HDC hdc, const TEST_ENTRY *pEntry)
Definition: DrawText.c:342
#define RGB(r, g, b)
Definition: precomp.h:62
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:977
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
#define OPAQUE
Definition: wingdi.h:948
HDC hdc
Definition: main.c:9
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
ULONG_PTR SIZE_T
Definition: typedefs.h:80
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
BOOL WINAPI DeleteDC(_In_ HDC)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static HBITMAP
Definition: button.c:44

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 39 of file DrawText.c.

Referenced by START_TEST().