ReactOS 0.4.15-dev-5672-gf73ac17
shaptest.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * AUTHOR: See gditest-- (initial changes by Mark Tempel)
4 * shaptest
5 *
6 * This is a windowed application that should draw two polygons. One
7 * is drawn with ALTERNATE fill, the other is drawn with WINDING fill.
8 * This is used to test out the Polygon() implementation.
9 */
10
11#include <windows.h>
12#include <stdio.h>
13#include <assert.h>
14
15#ifndef ASSERT
16#define ASSERT assert
17#endif
18
19#define nelem(x) (sizeof (x) / sizeof *(x))
20
23
25{
26 HPEN Pen, OldPen;
27 HBRUSH RedBrush, OldBrush;
28 DWORD Mode;
29 POINT PointsAlternate[] =
30 {
31 { 20, 80 },
32 { 60, 20 },
33 { 90, 80 },
34 { 20, 40 },
35 { 100, 40 }
36 };
37 POINT PointsWinding[] =
38 {
39 { 130, 80 },
40 { 170, 20 },
41 { 200, 80 },
42 { 130, 40 },
43 { 210, 40 }
44 };
45 POINT Tri1[] =
46 {
47 { 3, 3 },
48 { 5, 3 },
49 { 3, 5 }
50 };
51 POINT Tri2[] =
52 {
53 { 7, 3 },
54 { 7, 7 },
55 { 3, 7 },
56 };
57 POINT Square1[] =
58 {
59 { 1, 15 },
60 { 3, 15 },
61 { 3, 17 },
62 { 1, 17 }
63 };
64 POINT Square2[] =
65 {
66 { 5, 15 },
67 { 7, 15 },
68 { 7, 17 },
69 { 5, 17 }
70 };
71 POINT Square3[] =
72 {
73 { 1, 23 },
74 { 3, 23 },
75 { 3, 25 },
76 { 1, 25 }
77 };
78 POINT Square4[] =
79 {
80 { 5, 23 },
81 { 7, 23 },
82 { 7, 25 },
83 { 5, 25 }
84 };
85 POINT Square5[] =
86 {
87 { 1, 31 },
88 { 3, 31 },
89 { 3, 33 },
90 { 1, 33 }
91 };
92 POINT Square6[] =
93 {
94 { 5, 31 },
95 { 7, 31 },
96 { 7, 33 },
97 { 5, 33 }
98 };
99
100 //create a pen to draw the shape
101 Pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
102 ASSERT(Pen);
103 RedBrush = CreateSolidBrush(RGB(0xff, 0, 0));
104 ASSERT(RedBrush);
105
106 OldPen = (HPEN)SelectObject(hdc, Pen);
107 OldBrush = (HBRUSH)SelectObject(hdc, RedBrush);
108
110
111 RoundRect ( hdc, 32, 8, 48, 24, 8, 8 );
112
114 Polygon(hdc,PointsAlternate,nelem(PointsAlternate));
115
117 Polygon(hdc,PointsWinding,nelem(PointsWinding));
118
119 Rectangle ( hdc, 1, 1, 10, 10 );
120 Polygon(hdc,Tri1,nelem(Tri1));
121 Polygon(hdc,Tri2,nelem(Tri2));
122
123 Rectangle ( hdc, 1, 11, 4, 14 );
124 Rectangle ( hdc, 5, 11, 8, 14 );
125 Rectangle ( hdc, 9, 11, 12, 14 );
126 Rectangle ( hdc, 13, 11, 16, 14 );
127 Polygon(hdc,Square1,nelem(Square1));
128 Polygon(hdc,Square2,nelem(Square2));
129 Rectangle ( hdc, 1, 19, 4, 22 );
130 Rectangle ( hdc, 5, 19, 8, 22 );
131 Rectangle ( hdc, 9, 19, 12, 22 );
132 Rectangle ( hdc, 13, 19, 16, 22 );
133 Polygon(hdc,Square3,nelem(Square3));
134 Polygon(hdc,Square4,nelem(Square4));
135 Rectangle ( hdc, 1, 27, 4, 30 );
136 Rectangle ( hdc, 5, 27, 8, 30 );
137 Rectangle ( hdc, 9, 27, 12, 30 );
138 Rectangle ( hdc, 13, 27, 16, 30 );
139
140 // switch to null pen to make surey they display correctly
141 DeleteObject ( SelectObject(hdc, OldPen) );
142 Pen = CreatePen ( PS_NULL, 0, 0 );
143 ASSERT(Pen);
144 OldPen = (HPEN)SelectObject(hdc, Pen);
145
146 Polygon(hdc,Square5,nelem(Square5));
147 Polygon(hdc,Square6,nelem(Square6));
148 Rectangle ( hdc, 1, 35, 4, 38 );
149 Rectangle ( hdc, 5, 35, 8, 38 );
150 Rectangle ( hdc, 9, 35, 12, 38 );
151 Rectangle ( hdc, 13, 35, 16, 38 );
152
153 //cleanup
155 DeleteObject ( SelectObject(hdc, OldPen) );
156 DeleteObject ( SelectObject(hdc, OldBrush) );
157}
158
159
161{
162 //Test the Polygon routine.
164}
165
166
167int WINAPI
169 HINSTANCE hPrevInstance,
170 LPSTR lpszCmdLine,
171 int nCmdShow)
172{
173 WNDCLASS wc;
174 MSG msg;
175 HWND hWnd;
176
177 wc.lpszClassName = "ShapTestClass";
180 wc.hInstance = hInstance;
184 wc.lpszMenuName = NULL;
185 wc.cbClsExtra = 0;
186 wc.cbWndExtra = 0;
187 if (RegisterClass(&wc) == 0)
188 {
189 fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
190 (unsigned int)GetLastError());
191 return(1);
192 }
193
194 hWnd = CreateWindow("ShapTestClass",
195 "Shaptest",
197 0,
198 0,
201 NULL,
202 NULL,
203 hInstance,
204 NULL);
205 if (hWnd == NULL)
206 {
207 fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
208 (unsigned int)GetLastError());
209 return(1);
210 }
211
215
216 ShowWindow(hWnd, nCmdShow);
217
218 while(GetMessage(&msg, NULL, 0, 0))
219 {
222 }
223
225
226 return msg.wParam;
227}
228
230{
231 PAINTSTRUCT ps;
232 HDC hDC;
233
234 switch(msg)
235 {
236
237 case WM_PAINT:
238 hDC = BeginPaint(hWnd, &ps);
239 shaptest( hDC );
240 EndPaint(hWnd, &ps);
241 break;
242
243 case WM_DESTROY:
245 break;
246
247 default:
249 }
250 return 0;
251}
252
static HDC hDC
Definition: 3dtext.c:33
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define WINDING
Definition: constants.h:279
#define ALTERNATE
Definition: constants.h:278
HINSTANCE hInstance
Definition: charmap.c:19
Definition: gdipluspen.h:23
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
#define RGB(r, g, b)
Definition: precomp.h:62
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
_In_ ULONG Mode
Definition: hubbusif.h:303
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int UINT
Definition: ndis.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define DefWindowProc
Definition: ros2win.h:31
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: shaptest.c:168
void shaptest(HDC hdc)
Definition: shaptest.c:160
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: shaptest.c:229
#define nelem(x)
Definition: shaptest.c:19
HFONT tf
Definition: shaptest.c:21
void PolygonTest(HDC hdc)
Definition: shaptest.c:24
#define ASSERT
Definition: shaptest.c:16
HBRUSH hbrBackground
Definition: winuser.h:3160
HICON hIcon
Definition: winuser.h:3158
HINSTANCE hInstance
Definition: winuser.h:3157
HCURSOR hCursor
Definition: winuser.h:3159
int cbWndExtra
Definition: winuser.h:3156
UINT style
Definition: winuser.h:3153
LPCSTR lpszMenuName
Definition: winuser.h:3161
LPCSTR lpszClassName
Definition: winuser.h:3162
WNDPROC lpfnWndProc
Definition: winuser.h:3154
int cbClsExtra
Definition: winuser.h:3155
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HICON HCURSOR
Definition: windef.h:299
#define WINAPI
Definition: msvc.h:6
#define FIXED_PITCH
Definition: wingdi.h:444
#define PS_NULL
Definition: wingdi.h:591
int WINAPI GetPolyFillMode(_In_ HDC)
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define GRAY_BRUSH
Definition: wingdi.h:898
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define ANSI_CHARSET
Definition: wingdi.h:383
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
#define TA_BASELINE
Definition: wingdi.h:928
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586
int WINAPI SetPolyFillMode(_In_ HDC, _In_ int)
Definition: dc.c:1167
#define WM_PAINT
Definition: winuser.h:1610
#define CS_VREDRAW
Definition: winuser.h:653
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:648
#define IDC_ARROW
Definition: winuser.h:682
#define IDI_APPLICATION
Definition: winuser.h:699
#define CreateWindow
Definition: winuser.h:5744
#define GetMessage
Definition: winuser.h:5780
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadIcon
Definition: winuser.h:5803
#define LoadCursor
Definition: winuser.h:5802
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5826
#define WM_DESTROY
Definition: winuser.h:1599
#define DispatchMessage
Definition: winuser.h:5755
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193