mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 01:15:42 +00:00
Update to make shaptest be a windowed application.
svn path=/trunk/; revision=4392
This commit is contained in:
parent
87a1ef504f
commit
9bb9270ac0
1 changed files with 100 additions and 64 deletions
|
@ -2,13 +2,18 @@
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* AUTHOR: See gditest-- (initial changes by Mark Tempel)
|
* AUTHOR: See gditest-- (initial changes by Mark Tempel)
|
||||||
* shaptest
|
* shaptest
|
||||||
* This test application is for testing shape drawing GDI routines.
|
*
|
||||||
* Much code is taken from gditest (just look at the revision history).
|
* This is a windowed application that should draw two polygons. One
|
||||||
|
* is drawn with ALTERNATE fill, the other is drawn with WINDING fill.
|
||||||
|
* This is used to test out the Polygon() implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
extern BOOL STDCALL GdiDllInitialize(HANDLE hInstance, DWORD Event, LPVOID Reserved);
|
|
||||||
|
HFONT tf;
|
||||||
|
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
void __stdcall PolygonTest(HDC Desktop)
|
void __stdcall PolygonTest(HDC Desktop)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +24,6 @@ void __stdcall PolygonTest(HDC Desktop)
|
||||||
POINT lpPointsAlternate[5];
|
POINT lpPointsAlternate[5];
|
||||||
POINT lpPointsWinding[5];
|
POINT lpPointsWinding[5];
|
||||||
DWORD Mode;
|
DWORD Mode;
|
||||||
printf("In PolygonTest()\n");
|
|
||||||
|
|
||||||
//create a pen to draw the shape
|
//create a pen to draw the shape
|
||||||
BluePen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0xff));
|
BluePen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0xff));
|
||||||
|
@ -49,9 +53,7 @@ void __stdcall PolygonTest(HDC Desktop)
|
||||||
lpPointsWinding[4].x = 210;
|
lpPointsWinding[4].x = 210;
|
||||||
lpPointsWinding[4].y = 40; //{210,40};
|
lpPointsWinding[4].y = 40; //{210,40};
|
||||||
|
|
||||||
printf("Selecting in a blue pen.\n");
|
|
||||||
OldPen = (HPEN)SelectObject(Desktop, BluePen);
|
OldPen = (HPEN)SelectObject(Desktop, BluePen);
|
||||||
printf("Drawing a 5 point star.\n");
|
|
||||||
OldBrush = (HBRUSH)SelectObject(Desktop, RedBrush);
|
OldBrush = (HBRUSH)SelectObject(Desktop, RedBrush);
|
||||||
|
|
||||||
Mode = GetPolyFillMode(Desktop);
|
Mode = GetPolyFillMode(Desktop);
|
||||||
|
@ -72,7 +74,7 @@ void __stdcall PolygonTest(HDC Desktop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void shaptest( void ){
|
void shaptest( HDC DevCtx ){
|
||||||
HDC Desktop, MyDC, DC24;
|
HDC Desktop, MyDC, DC24;
|
||||||
HPEN RedPen, GreenPen, BluePen, WhitePen;
|
HPEN RedPen, GreenPen, BluePen, WhitePen;
|
||||||
HBITMAP MyBitmap, DIB24;
|
HBITMAP MyBitmap, DIB24;
|
||||||
|
@ -84,73 +86,107 @@ void shaptest( void ){
|
||||||
int sec,Xmod,Ymod;
|
int sec,Xmod,Ymod;
|
||||||
char tbuf[5];
|
char tbuf[5];
|
||||||
|
|
||||||
// Set up a DC called Desktop that accesses DISPLAY
|
|
||||||
Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
|
|
||||||
if (Desktop == NULL){
|
|
||||||
printf("Can't create desktop\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ei
|
|
||||||
BlueBrush = CreateSolidBrush( RGB(0, 0, 0xff) );
|
BlueBrush = CreateSolidBrush( RGB(0, 0, 0xff) );
|
||||||
DefBrush = SelectObject( Desktop, BlueBrush );
|
DefBrush = SelectObject( DevCtx, BlueBrush );
|
||||||
|
|
||||||
hRgn1 = CreateRectRgn( 1, 2, 100, 101 );
|
SelectObject( DevCtx, DefBrush );
|
||||||
hRgn2 = CreateRectRgn( 10, 20, 150, 151 );
|
|
||||||
hRgn3 = CreateRectRgn( 1, 1, 1, 1);
|
|
||||||
CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR );
|
|
||||||
|
|
||||||
//PaintRgn( Desktop, hRgn3 );
|
|
||||||
SelectObject( Desktop, DefBrush );
|
|
||||||
DeleteObject( BlueBrush );
|
DeleteObject( BlueBrush );
|
||||||
|
|
||||||
// Create a blue pen and select it into the DC
|
// Create a blue pen and select it into the DC
|
||||||
BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
|
BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
|
||||||
SelectObject(Desktop, BluePen);
|
SelectObject(DevCtx, BluePen);
|
||||||
|
|
||||||
|
//Test the Polygon routine.
|
||||||
|
PolygonTest(DevCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Test font support
|
int WINAPI
|
||||||
GreenPen = CreatePen(PS_SOLID, 3, RGB(0, 0xff, 0));
|
WinMain(HINSTANCE hInstance,
|
||||||
RedPen = CreatePen(PS_SOLID, 3, RGB(0xff, 0, 0));
|
HINSTANCE hPrevInstance,
|
||||||
|
LPSTR lpszCmdLine,
|
||||||
|
int nCmdShow)
|
||||||
|
{
|
||||||
|
WNDCLASS wc;
|
||||||
|
MSG msg;
|
||||||
|
HWND hWnd;
|
||||||
|
|
||||||
|
wc.lpszClassName = "ShapTestClass";
|
||||||
|
wc.lpfnWndProc = MainWndProc;
|
||||||
|
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||||
|
wc.hInstance = hInstance;
|
||||||
|
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
|
||||||
|
wc.lpszMenuName = NULL;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
if (RegisterClass(&wc) == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
|
||||||
|
GetLastError());
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
hWnd = CreateWindow("ShapTestClass",
|
||||||
|
"Shaptest",
|
||||||
|
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
hInstance,
|
||||||
|
NULL);
|
||||||
|
if (hWnd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
|
||||||
|
GetLastError());
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||||
SelectObject(Desktop, tf);
|
|
||||||
SetTextColor(Desktop, RGB(0xff, 0xff, 0xff));
|
|
||||||
|
|
||||||
//Test 3 Test the Polygon routine.
|
ShowWindow(hWnd, nCmdShow);
|
||||||
PolygonTest(Desktop);
|
|
||||||
|
|
||||||
//Countdown our exit.
|
while(GetMessage(&msg, NULL, 0, 0))
|
||||||
TextOutA(Desktop, 70, 110, "Exiting app in: ", 16);
|
|
||||||
#define TIME_OUT 30
|
|
||||||
for (sec = 0; sec < TIME_OUT; ++sec)
|
|
||||||
{
|
{
|
||||||
sprintf(tbuf,"%d",TIME_OUT - sec);
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
Xmod = (sec % 10) * 20;
|
|
||||||
Ymod = (sec / 10) * 20;
|
|
||||||
|
|
||||||
TextOutA(Desktop, 200 + Xmod , 110 + Ymod, tbuf, strlen(tbuf));
|
|
||||||
Sleep( 1500 );
|
|
||||||
}
|
}
|
||||||
// Free up everything
|
|
||||||
DeleteDC(Desktop);
|
DeleteObject(tf);
|
||||||
DeleteDC(MyDC);
|
|
||||||
|
return msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
printf("Entering ShapTest (with polygon)..\n");
|
PAINTSTRUCT ps;
|
||||||
|
HDC hDC;
|
||||||
|
RECT clr, wir;
|
||||||
|
char spr[100], sir[100];
|
||||||
|
|
||||||
Sleep( 1000 );
|
switch(msg)
|
||||||
|
{
|
||||||
|
|
||||||
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
|
case WM_PAINT:
|
||||||
|
hDC = BeginPaint(hWnd, &ps);
|
||||||
shaptest();
|
shaptest( hDC );
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue