ReactOS 0.4.15-dev-8241-g63935f8
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
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}
#define ok(value,...)
Definition: atltest.h:57
HFONT hFont
Definition: main.c:53
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HDC hdc
Definition: main.c:9
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
int ret
INT WINAPI DrawTextA(HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
Definition: font.c:373
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define WHITE_BRUSH
Definition: wingdi.h:902
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define DT_CALCRECT
Definition: winuser.h:526

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));
417 for (i = 0; i < ARRAYSIZE(s_entries); ++i)
418 {
420 }
421
422 SelectObject(hdc, hbmOld);
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 ARRAYSIZE(array)
Definition: filtermapper.c:47
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
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
ULONG_PTR SIZE_T
Definition: typedefs.h:80
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define OPAQUE
Definition: wingdi.h:949
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI DeleteDC(_In_ HDC)

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 39 of file DrawText.c.

Referenced by START_TEST().