4 * Copyright (c) 2004 Zach Gorman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 #include "wine/test.h"
31 static void test_DrawTextCalcRect(void)
35 HFONT hFont, hOldFont;
37 const char text[] = "Example text for testing DrawText in "
40 RECT rect = { 0, 0, 100, 0 };
43 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
44 0, 0, 200, 200, 0, 0, 0, NULL);
45 ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError());
47 ok(hdc != 0, "GetDC error %lu\n", GetLastError());
48 trace("hdc %p\n", hdc);
51 /* LOGFONT initialization */
52 memset(&lf, 0, sizeof(lf));
53 lf.lfCharSet = ANSI_CHARSET;
54 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
55 lf.lfWeight = FW_DONTCARE;
56 lf.lfHeight = 0; /* mapping mode dependent */
57 lf.lfQuality = DEFAULT_QUALITY;
58 lstrcpyA(lf.lfFaceName, "Arial");
60 /* DrawText in MM_HIENGLISH with DT_CALCRECT */
61 SetMapMode(hdc, MM_HIENGLISH);
62 lf.lfHeight = 100 * 9 / 72; /* 9 point */
63 hFont = CreateFontIndirectA(&lf);
64 ok(hFont != 0, "CreateFontIndirectA error %lu\n",
66 hOldFont = SelectObject(hdc, hFont);
68 ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
69 DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
70 DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
72 trace("MM_HIENGLISH rect.bottom %ld\n", rect.bottom);
73 todo_wine ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
74 "DT_CALCRECT should return a negative rectangle bottom. "
75 "(bot=%ld)\n", rect.bottom);
77 SelectObject(hdc, hOldFont);
78 ok(DeleteObject(hFont), "DeleteObject error %lu\n",
82 /* DrawText in MM_TEXT with DT_CALCRECT */
83 SetMapMode(hdc, MM_TEXT);
84 lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc,
85 LOGPIXELSY), 72); /* 9 point */
86 hFont = CreateFontIndirectA(&lf);
87 ok(hFont != 0, "CreateFontIndirectA error %lu\n",
89 hOldFont = SelectObject(hdc, hFont);
91 ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
92 DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
93 DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
95 trace("MM_TEXT rect.bottom %ld\n", rect.bottom);
96 ok(rect.bottom > 0, "In MM_TEXT, DrawText with DT_CALCRECT "
97 "should return a positive rectangle bottom. (bot=%ld)\n",
100 SelectObject(hdc, hOldFont);
101 ok(DeleteObject(hFont), "DeleteObject error %lu\n",
105 ok(ReleaseDC(hwnd, hdc), "ReleaseDC error %lu\n",
107 ok(DestroyWindow(hwnd), "DestroyWindow error %lu\n",
113 test_DrawTextCalcRect();