2 * COPYRIGHT: See COPYING in the top level directory
3 * AUTHOR: See gditest-- (initial changes by Mark Tempel)
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.
19 #define nelem(x) (sizeof (x) / sizeof *(x))
22 LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
24 void PolygonTest ( HDC hdc )
27 HBRUSH RedBrush, OldBrush;
29 POINT PointsAlternate[] =
37 POINT PointsWinding[] =
100 //create a pen to draw the shape
101 Pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
103 RedBrush = CreateSolidBrush(RGB(0xff, 0, 0));
106 OldPen = (HPEN)SelectObject(hdc, Pen);
107 OldBrush = (HBRUSH)SelectObject(hdc, RedBrush);
109 Mode = GetPolyFillMode(hdc);
111 RoundRect ( hdc, 32, 8, 48, 24, 8, 8 );
113 SetPolyFillMode(hdc, ALTERNATE);
114 Polygon(hdc,PointsAlternate,nelem(PointsAlternate));
116 SetPolyFillMode(hdc, WINDING);
117 Polygon(hdc,PointsWinding,nelem(PointsWinding));
119 Rectangle ( hdc, 1, 1, 10, 10 );
120 Polygon(hdc,Tri1,nelem(Tri1));
121 Polygon(hdc,Tri2,nelem(Tri2));
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 );
140 // switch to null pen to make surey they display correctly
141 DeleteObject ( SelectObject(hdc, OldPen) );
142 Pen = CreatePen ( PS_NULL, 0, 0 );
144 OldPen = (HPEN)SelectObject(hdc, Pen);
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 );
154 SetPolyFillMode(hdc, Mode);
155 DeleteObject ( SelectObject(hdc, OldPen) );
156 DeleteObject ( SelectObject(hdc, OldBrush) );
160 void shaptest( HDC hdc )
162 //Test the Polygon routine.
168 WinMain(HINSTANCE hInstance,
169 HINSTANCE hPrevInstance,
177 wc.lpszClassName = "ShapTestClass";
178 wc.lpfnWndProc = MainWndProc;
179 wc.style = CS_VREDRAW | CS_HREDRAW;
180 wc.hInstance = hInstance;
181 wc.hIcon = (HICON)LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
182 wc.hCursor = (HCURSOR)LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
183 wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
184 wc.lpszMenuName = NULL;
187 if (RegisterClass(&wc) == 0)
189 fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
190 (unsigned int)GetLastError());
194 hWnd = CreateWindow("ShapTestClass",
196 WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
207 fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
208 (unsigned int)GetLastError());
212 tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
213 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
214 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
216 ShowWindow(hWnd, nCmdShow);
218 while(GetMessage(&msg, NULL, 0, 0))
220 TranslateMessage(&msg);
221 DispatchMessage(&msg);
229 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
238 hDC = BeginPaint(hWnd, &ps);
248 return DefWindowProc(hWnd, msg, wParam, lParam);