]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag/include/server/view
d207c33c217352335767110ad0efe387ad8d193f
[l4.git] / l4 / pkg / mag / include / server / view
1 // vi:ft=cpp
2 /*
3  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11
12 #include <l4/mag-gfx/geometry>
13 #include <l4/mag-gfx/gfx_colors>
14 #include <l4/mag/server/mode>
15 #include <l4/re/event>
16
17 namespace Mag_gfx {
18 class Canvas;
19 }
20
21
22 namespace Mag_server {
23
24 using namespace Mag_gfx;
25
26 class View_stack;
27
28 class View : public Rect
29 {
30 private:
31   friend class View_stack;
32
33   unsigned _flags;
34
35   View *_n;
36   View **_pn;
37
38   View(View const &);
39   void operator = (View const &);
40
41 protected:
42   explicit View(Rect const &size, unsigned flags = 0)
43   : Rect(size), _flags(flags), _n(0), _pn(0)
44   {}
45
46   View *next() const { return _n; }
47
48 public:
49   static Rgb32::Color frame_color() { return Rgb32::Color(255, 200, 127); }
50   static Rgb32::Color kill_color() { return Rgb32::Color(255, 0, 0); }
51   enum
52   {
53     F_transparent = 1,
54     F_need_frame  = 2,
55     F_ignore = 4,
56     F_focused = 8,
57   };
58
59   void set_geometry(Rect const &p)
60   { this->Rect::operator = (p); }
61
62   Area size() const { return Area(w(), h()); }
63
64   bool transparent() const { return _flags & F_transparent; }
65   bool need_frame() const { return _flags & F_need_frame; }
66   bool ignore() const { return _flags & F_ignore; }
67   bool focused() const { return _flags & F_focused; }
68
69   void set_focus(bool on)
70   {
71     if (on)
72       _flags |= F_focused;
73     else
74       _flags &= ~F_focused;
75   }
76
77   virtual void draw(Canvas *, View_stack const *, Mode) const = 0;
78   virtual void handle_event(L4Re::Event_buffer::Event const &, Point const &) {}
79   virtual ~View() {}
80
81 };
82
83 }