5 #include <Application.h>
10 class TestView1
: public BView
{
13 TestView1(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
14 : BView(frame
, name
, resizeFlags
, flags
)
16 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
17 SetHighColor(ViewColor());
20 virtual void Draw(BRect updateRect
)
23 region
.Include(BRect(20, 20, 40, 40));
24 region
.Include(BRect(30, 30, 80, 80));
25 ConstrainClippingRegion(®ion
);
27 SetHighColor(255, 0, 0, 255);
28 FillRect(BRect(0, 0, 100, 100));
30 ConstrainClippingRegion(NULL
);
32 SetHighColor(0, 0, 0, 255);
33 StrokeLine(BPoint(2, 2), BPoint(80, 80));
37 class TestView2
: public BView
{
40 TestView2(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
41 : BView(frame
, name
, resizeFlags
, flags
)
43 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
44 SetHighColor(ViewColor());
47 virtual void AttachedToWindow()
52 virtual void Draw(BRect updateRect
)
57 region
.Include(BRect(20, 20, 40, 40));
58 region
.Include(BRect(30, 30, 80, 80));
59 ConstrainClippingRegion(®ion
);
61 SetHighColor(255, 128, 0, 255);
62 FillRect(BRect(0, 0, 100, 100));
64 ConstrainClippingRegion(NULL
);
66 SetHighColor(0, 0, 0, 255);
67 StrokeLine(BPoint(2, 2), BPoint(80, 80));
71 class TestView3
: public BView
{
74 TestView3(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
75 : BView(frame
, name
, resizeFlags
, flags
)
77 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
78 SetHighColor(ViewColor());
81 virtual void AttachedToWindow()
86 virtual void Draw(BRect updateRect
)
89 region
.Include(BRect(20, 20, 40, 40));
90 region
.Include(BRect(30, 30, 80, 80));
91 ConstrainClippingRegion(®ion
);
93 SetHighColor(55, 255, 128, 255);
94 FillRect(BRect(0, 0, 100, 100));
99 ConstrainClippingRegion(®ion
);
101 SetHighColor(155, 255, 128, 255);
102 FillRect(BRect(0, 0, 100, 100));
104 // ConstrainClippingRegion(NULL);
106 SetHighColor(0, 0, 0, 255);
107 StrokeLine(BPoint(2, 2), BPoint(80, 80));
108 SetHighColor(255, 0, 0, 255);
109 StrokeLine(BPoint(2, 2), BPoint(4, 2));
112 SetHighColor(0, 0, 0, 255);
113 StrokeLine(BPoint(4, 2), BPoint(82, 80));
117 class TestView4
: public BView
{
120 TestView4(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
121 : BView(frame
, name
, resizeFlags
, flags
)
123 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
124 SetHighColor(ViewColor());
127 virtual void AttachedToWindow()
132 virtual void Draw(BRect updateRect
)
135 region
.Include(BRect(20, 20, 40, 40));
136 region
.Include(BRect(30, 30, 140, 140));
137 ConstrainClippingRegion(®ion
);
139 SetHighColor(55, 255, 128, 255);
140 FillRect(BRect(0, 0, 200, 200));
142 // NOTE: This exposes broken behavior of the ZETA
143 // (probably R5 too) app_server. The new origin
144 // is not taken into account
147 ConstrainClippingRegion(®ion
);
151 SetHighColor(155, 255, 128, 255);
152 FillRect(BRect(0, 0, 200, 200));
154 ConstrainClippingRegion(NULL
);
156 SetHighColor(0, 0, 0, 255);
157 SetDrawingMode(B_OP_OVER
);
158 DrawString("Text is scaled.", BPoint(20, 30));
161 DrawString("Text is scaled.", BPoint(20, 30));
163 StrokeLine(BPoint(2, 2), BPoint(80, 80));
167 SetHighColor(0, 0, 0, 255);
168 StrokeLine(BPoint(4, 2), BPoint(82, 80));
172 class TestView5
: public BView
{
175 TestView5(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
176 : BView(frame
, name
, resizeFlags
, flags
)
178 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
179 SetHighColor(ViewColor());
182 virtual void AttachedToWindow()
186 virtual void Draw(BRect updateRect
)
189 region
.Include(BRect(0, 0, 40, 40));
190 region
.Include(BRect(30, 30, 140, 140));
191 ConstrainClippingRegion(®ion
);
193 SetHighColor(55, 255, 128, 255);
194 FillRect(BRect(0, 0, 200, 200));
197 ConstrainClippingRegion(®ion
);
200 SetHighColor(155, 55, 128, 255);
201 FillRect(BRect(0, 0, 200, 200));
204 SetHighColor(255, 0, 0);
205 StrokeLine(Bounds().LeftTop(), Bounds().RightBottom());
210 class TestView6
: public BView
{
213 TestView6(BRect frame
, const char* name
, uint32 resizeFlags
, uint32 flags
)
214 : BView(frame
, name
, resizeFlags
, flags
)
216 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
217 SetHighColor(ViewColor());
220 virtual void AttachedToWindow()
224 virtual void Draw(BRect updateRect
)
227 region
.Include(BRect(0, 0, 40, 40));
228 region
.Include(BRect(30, 30, 140, 140));
229 ConstrainClippingRegion(®ion
);
231 SetHighColor(55, 255, 128, 255);
232 FillRect(BRect(0, 0, 200, 200));
236 ConstrainClippingRegion(®ion
);
238 SetHighColor(155, 55, 128, 255);
239 FillRect(BRect(0, 0, 200, 200));
242 SetHighColor(255, 0, 0);
243 StrokeLine(Bounds().LeftTop(), Bounds().RightBottom());
249 main(int argc
, char** argv
)
251 BApplication
* app
= new BApplication(
252 "application/x.vnd-Haiku.ClippingRegion");
254 BRect
frame(50.0, 50.0, 300.0, 250.0);
258 // window = new BWindow(frame, "Test1", B_TITLED_WINDOW,
259 // B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
261 // view = new TestView1(window->Bounds(), "test1", B_FOLLOW_ALL,
263 // window->AddChild(view);
266 // frame.OffsetBy(20, 20);
267 // window = new BWindow(frame, "Test2", B_TITLED_WINDOW,
268 // B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
270 // view = new TestView2(window->Bounds(), "test2", B_FOLLOW_ALL,
272 // window->AddChild(view);
275 // frame.OffsetBy(20, 20);
276 // window = new BWindow(frame, "Test3", B_TITLED_WINDOW,
277 // B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
279 // view = new TestView3(window->Bounds(), "test3", B_FOLLOW_ALL,
281 // window->AddChild(view);
284 // frame.OffsetBy(20, 20);
285 // window = new BWindow(frame, "Test4", B_TITLED_WINDOW,
286 // B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
288 // view = new TestView4(window->Bounds(), "test4", B_FOLLOW_ALL,
290 // window->AddChild(view);
294 frame
.OffsetBy(20, 20);
295 window
= new BWindow(frame
, "Test5", B_TITLED_WINDOW
,
296 B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE
);
298 view
= new TestView5(window
->Bounds(), "test5", B_FOLLOW_ALL
,
300 window
->AddChild(view
);
303 frame
.OffsetBy(20, 20);
304 window
= new BWindow(frame
, "Test6", B_TITLED_WINDOW
,
305 B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE
);
307 view
= new TestView6(window
->Bounds(), "test6", B_FOLLOW_ALL
,
309 window
->AddChild(view
);