Window.h (1936B)
1 #ifndef _WINDOW_H 2 #define _WINDOW_H 3 4 #include "Region.h" 5 #include "GraphicsContext.h" 6 7 class Event; 8 9 class Window { 10 public: 11 12 Window(int id, int eventPort, Renderer *renderer = 0); 13 ~Window(); 14 void AddChild(const Rect& frame, Window *window); 15 void RemoveChild(Window *window); 16 void MoveToFront(); 17 inline int ID() const; 18 19 Window *ChildAtPoint(int x, int y); 20 21 Rect LocalToScreen(const Rect&) const; 22 Rect ScreenToLocal(const Rect&) const; 23 24 void SetVisibleRegion(const Region&); 25 inline const Rect& Frame() const; 26 inline Rect Bounds() const; 27 28 const Region& InvalidRegion() const; 29 const Region& ClipRegion() const; 30 void Invalidate(const Region&); 31 void Invalidate(const Rect&); 32 void BeginPaint(Rect &out_invalidRect); 33 void EndPaint(); 34 GraphicsContext& GC(); 35 void ResetGC(); 36 bool IsVisible() const; 37 char Color() const; 38 void SetColor(char); 39 void Show(); 40 void Hide(); 41 void PostEvent(Event*); 42 43 void DumpChildList(int level = 0); 44 45 private: 46 void UpdateClipRegion(); 47 void MoveTo(long, long); 48 void ResizeTo(long, long); 49 50 int fID; 51 Window *fNextSibling; 52 Window **fPreviousSibling; 53 Window *fChildList; 54 Window *fParent; 55 56 Region fInvalidRegion; 57 Region fCurrentRedrawRegion; 58 59 // The visible region represents what part of this window is not 60 // obscured by siblings of my parent. I maintain this 61 // when recomputing clipping for my children. 62 Region fVisibleRegion; 63 64 // The clip region is the visible region, minus parts of my window 65 // that are obscured by my children. 66 Region fClipRegion; 67 68 Rect fFrame; 69 GraphicsContext fGC; 70 bool fIsVisible; 71 bool fInRedraw; 72 int fEventPort; 73 bool fPaintMsgSent; 74 char fColor; 75 }; 76 77 inline int Window::ID() const 78 { 79 return fID; 80 } 81 82 inline const Rect& Window::Frame() const 83 { 84 return fFrame; 85 } 86 87 inline Rect Window::Bounds() const 88 { 89 Rect rect(fFrame); 90 rect.OffsetTo(0, 0); 91 return rect; 92 } 93 94 inline const Region& Window::InvalidRegion() const 95 { 96 return fInvalidRegion; 97 } 98 99 100 101 102 #endif 103