1 | /** |
---|
2 | * This program illustrates the bug of the GpiBox() API call: |
---|
3 | * GpiBox() draws the rectangle 1 pixel taller when |
---|
4 | * rounded corners and (DRO_FILL or DRO_OUTLINEFILL) are specified. |
---|
5 | * |
---|
6 | * The bug is definitely present on: |
---|
7 | * Aurora + XR_E002 and GeForce2 MX + SNAP 2.0.0 |
---|
8 | * Aurora + XR_E002 and GeForce4 Ti + SNAP 2.2.0 |
---|
9 | * |
---|
10 | * dmik@go.ru |
---|
11 | * 13-Apr-2003 |
---|
12 | */ |
---|
13 | |
---|
14 | #define INCL_BASE |
---|
15 | #define INCL_PM |
---|
16 | #include <os2.h> |
---|
17 | |
---|
18 | #define WNDCLASS "GpiBoxBug" |
---|
19 | #define WNDTITLE "GpiBox Bug" |
---|
20 | |
---|
21 | /** |
---|
22 | * |
---|
23 | */ |
---|
24 | void DrawBox (HPS hps, int x, int y, int width, int height, int rndx, int rndy, int style) |
---|
25 | { |
---|
26 | POINTL pnt; |
---|
27 | pnt.x = x, pnt.y = y; |
---|
28 | GpiMove (hps, &pnt); |
---|
29 | pnt.x += width; pnt.y += height; |
---|
30 | GpiBox (hps, style, &pnt, rndx, rndy); |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * |
---|
35 | */ |
---|
36 | MRESULT WMPaint (HWND hwnd, HPS ahps) |
---|
37 | { |
---|
38 | HPS hps; |
---|
39 | |
---|
40 | hps = WinBeginPaint (hwnd, ahps, NULL); |
---|
41 | |
---|
42 | DrawBox (hps, 10, 10, 49, 49, 0, 0, DRO_OUTLINE); |
---|
43 | DrawBox (hps, 31, 10, 49, 49, 0, 0, DRO_FILL); |
---|
44 | DrawBox (hps, 52, 10, 49, 49, 0, 0, DRO_OUTLINEFILL); |
---|
45 | |
---|
46 | DrawBox (hps, 10, 70, 49, 49, 0, 0, DRO_OUTLINE); |
---|
47 | DrawBox (hps, 10, 91, 49, 49, 0, 0, DRO_FILL); |
---|
48 | DrawBox (hps, 10, 112, 49, 49, 0, 0, DRO_OUTLINEFILL); |
---|
49 | |
---|
50 | DrawBox (hps, 110, 10, 49, 49, 10, 10, DRO_OUTLINE); |
---|
51 | DrawBox (hps, 131, 10, 49, 49, 10, 10, DRO_FILL); |
---|
52 | DrawBox (hps, 152, 10, 49, 49, 10, 10, DRO_OUTLINEFILL); |
---|
53 | |
---|
54 | DrawBox (hps, 110, 70, 49, 49, 10, 10, DRO_OUTLINE); |
---|
55 | DrawBox (hps, 110, 91, 49, 49, 10, 10, DRO_FILL); |
---|
56 | DrawBox (hps, 110, 112, 49, 49, 10, 10, DRO_OUTLINEFILL); |
---|
57 | |
---|
58 | WinEndPaint (hps); |
---|
59 | |
---|
60 | return 0; |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * |
---|
65 | */ |
---|
66 | MRESULT EXPENTRY WindowProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
---|
67 | { |
---|
68 | static HPS hps = 0; |
---|
69 | |
---|
70 | switch (msg) { |
---|
71 | |
---|
72 | case WM_CREATE: |
---|
73 | hps = WinGetPS (hwnd); |
---|
74 | GpiSetColor (hps, CLR_RED); |
---|
75 | GpiSetBackColor (hps, CLR_BLACK); |
---|
76 | GpiSetBackMix (hps, BM_OVERPAINT); |
---|
77 | GpiSetPattern (hps, PATSYM_BLANK); |
---|
78 | return (MRESULT)FALSE; |
---|
79 | |
---|
80 | case WM_ERASEBACKGROUND: |
---|
81 | WinFillRect ((HPS)mp1, (PRECTL)mp2, SYSCLR_DIALOGBACKGROUND); |
---|
82 | return FALSE; |
---|
83 | |
---|
84 | case WM_CALCVALIDRECTS: |
---|
85 | return (MPARAM)(CVR_ALIGNLEFT | CVR_ALIGNBOTTOM); |
---|
86 | |
---|
87 | case WM_PAINT: |
---|
88 | return WMPaint (hwnd, hps); |
---|
89 | |
---|
90 | case WM_DESTROY: |
---|
91 | WinReleasePS (hps); |
---|
92 | return 0; |
---|
93 | } |
---|
94 | |
---|
95 | return WinDefWindowProc (hwnd, msg, mp1, mp2); |
---|
96 | } |
---|
97 | |
---|
98 | /** |
---|
99 | * ENTRY POINT |
---|
100 | */ |
---|
101 | void main() |
---|
102 | { |
---|
103 | HAB hab; |
---|
104 | HMQ hmq; |
---|
105 | QMSG qmsg; |
---|
106 | HWND hwnd, hwndC; |
---|
107 | ULONG fcflags; |
---|
108 | |
---|
109 | hab = WinInitialize (0); |
---|
110 | hmq = WinCreateMsgQueue (hab, 0 ); |
---|
111 | |
---|
112 | if (hmq) { |
---|
113 | WinRegisterClass (hab, WNDCLASS, (PFNWP)WindowProc, 0 /*CS_SIZEREDRAW*/, 0 ); |
---|
114 | |
---|
115 | fcflags = FCF_TITLEBAR | FCF_SIZEBORDER | FCF_SYSMENU | FCF_MINBUTTON | FCF_MAXBUTTON; |
---|
116 | hwnd = WinCreateStdWindow ( |
---|
117 | HWND_DESKTOP, |
---|
118 | FS_TASKLIST | FS_SHELLPOSITION, |
---|
119 | &fcflags, |
---|
120 | WNDCLASS, |
---|
121 | WNDTITLE, |
---|
122 | 0, |
---|
123 | 0, |
---|
124 | 0, |
---|
125 | &hwndC |
---|
126 | ); |
---|
127 | |
---|
128 | if (hwnd && hwndC) { |
---|
129 | WinSetWindowPos (hwnd, HWND_TOP, 0, 0, 250, 250, |
---|
130 | SWP_ACTIVATE | SWP_ZORDER | SWP_SHOW | SWP_SIZE); |
---|
131 | while (WinGetMsg (hab, &qmsg, 0, 0, 0)) |
---|
132 | WinDispatchMsg (hab, &qmsg); |
---|
133 | WinDestroyWindow (hwnd); |
---|
134 | } |
---|
135 | WinDestroyMsgQueue (hmq); |
---|
136 | } |
---|
137 | |
---|
138 | WinTerminate (hab); |
---|
139 | } |
---|
140 | |
---|