Move all of the files in include/libc/... down to the top level include path.
[newos.git] / apps / window_server / Window.h
blobe0766d1600d477809e16a9bdbeeb354123936120
1 #ifndef _WINDOW_H
2 #define _WINDOW_H
4 #include "Region.h"
5 #include "GraphicsContext.h"
6 #include <win/Event.h>
7 #include <win/WindowFlags.h>
9 using namespace os::gui;
11 class Window {
12 public:
14 Window(int id, port_id eventPort, Renderer *renderer = 0);
15 ~Window();
16 void AddChild(const Rect& frame, Window *window, window_flags flags = WINDOW_FLAG_NONE);
17 void RemoveChild(Window *window);
18 void MoveToFront();
19 inline int ID() const;
21 Window *ChildAtPoint(int x, int y);
23 Rect LocalToScreen(const Rect&) const;
24 Rect ScreenToLocal(const Rect&) const;
26 void SetVisibleRegion(const Region&);
27 inline const Rect& Frame() const;
28 inline Rect Bounds() const;
30 const Region& InvalidRegion() const;
31 const Region& ClipRegion() const;
32 void Invalidate(const Region&);
33 void Invalidate(const Rect&); // rect in screen coords
34 void BeginPaint(Rect &out_invalidRect);
35 void EndPaint();
36 GraphicsContext& GC();
37 void ResetGC();
38 bool IsVisible() const;
39 color888 Color() const;
40 void SetColor(color888);
41 void Show();
42 void Hide();
43 void PostEvent(Event*);
45 void DumpChildList(int level = 0);
47 void MoveTo(long, long);
48 void MoveBy(long, long);
49 void ResizeTo(long, long);
51 inline window_flags Flags() const;
52 inline Window *GetTopLevelWindow() const;
54 private:
55 void UpdateClipRegion();
57 int fID;
58 Window *fNextSibling;
59 Window **fPreviousSibling;
60 Window *fChildList;
61 Window *fParent;
62 Window *fToplevelWindow;
63 window_flags fFlags;
65 Region fInvalidRegion;
66 Region fCurrentRedrawRegion;
68 // The visible region represents what part of this window is not
69 // obscured by siblings of my parent. I maintain this
70 // when recomputing clipping for my children.
71 Region fVisibleRegion;
73 // The clip region is the visible region, minus parts of my window
74 // that are obscured by my children.
75 Region fClipRegion;
77 Rect fFrame;
78 GraphicsContext fGC;
79 bool fIsVisible;
80 bool fInRedraw;
81 port_id fEventPort;
82 bool fPaintMsgSent;
83 color888 fColor;
86 inline int Window::ID() const
88 return fID;
91 inline const Rect& Window::Frame() const
93 return fFrame;
96 inline Rect Window::Bounds() const
98 Rect rect(fFrame);
99 rect.OffsetTo(0, 0);
100 return rect;
103 inline window_flags Window::Flags() const
105 return fFlags;
108 inline Window *Window::GetTopLevelWindow() const
110 return fToplevelWindow;
113 inline const Region& Window::InvalidRegion() const
115 return fInvalidRegion;
121 #endif