vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / newClipping / WinBorder.cpp
blob8e8901fdddb3b83f67d811799c779fcde50c02cc
1 #include <Window.h>
2 #include "MyView.h"
4 #include "WinBorder.h"
6 #include <stdio.h>
8 extern BWindow* wind;
10 WinBorder::WinBorder(BRect frame, const char* name,
11 uint32 rm, uint32 flags, rgb_color c)
12 : Layer(frame, name, rm, flags, c)
14 fColor.red = 255;
15 fColor.green = 203;
16 fColor.blue = 0;
18 fRebuildDecRegion = true;
21 WinBorder::~WinBorder()
25 void WinBorder::MovedByHook(float dx, float dy)
27 fDecRegion.OffsetBy(dx, dy);
30 void WinBorder::ResizedByHook(float dx, float dy, bool automatic)
32 fRebuildDecRegion = true;
35 void WinBorder::set_decorator_region(BRect bounds)
37 fRebuildDecRegion = false;
39 fDecRegion.MakeEmpty();
40 // NOTE: frame is in screen coords
41 fDecRegion.Include(BRect(bounds.left-4, bounds.top-4, bounds.right+4, bounds.top-1));
42 fDecRegion.Include(BRect(bounds.left-4, bounds.bottom+1, bounds.right+4, bounds.bottom+4));
43 fDecRegion.Include(BRect(bounds.left-4, bounds.top, bounds.left-1, bounds.bottom));
44 fDecRegion.Include(BRect(bounds.right+1, bounds.top, bounds.right+4, bounds.bottom));
46 // tab
47 fDecRegion.Include(BRect(bounds.left-4, bounds.top-4-10, bounds.left+bounds.Width()/2, bounds.top-4));
49 // resize rect
50 fDecRegion.Include(BRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom));
53 bool WinBorder::alter_visible_for_children(BRegion &region)
55 region.Exclude(&fDecRegion);
56 return true;
59 void WinBorder::get_user_regions(BRegion &reg)
61 if (fRebuildDecRegion)
63 set_decorator_region(Bounds());
64 ConvertToScreen2(&fDecRegion);
67 BRect screenFrame(Bounds());
68 ConvertToScreen2(&screenFrame);
69 reg.Set(screenFrame);
71 wind->Lock();
72 BRegion screenReg(GetRootLayer()->Bounds());
73 wind->Unlock();
74 reg.IntersectWith(&screenReg);
76 reg.Include(&fDecRegion);