]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag/include/server/session
update
[l4.git] / l4 / pkg / mag / include / server / session
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/gfx_colors>
13
14 #include <l4/cxx/string>
15 #include <l4/cxx/dlist>
16 #include <l4/cxx/observer>
17
18 namespace Mag_server {
19
20 class View;
21
22 class Session : public cxx::D_list_item<Session>
23 {
24 private:
25   unsigned _flags;
26   View *_bg;
27   Mag_gfx::Rgb32::Color _color;
28   char *_label;
29
30   cxx::Notifier *_ntfy;
31
32 protected:
33   void flags(unsigned setmask, unsigned clearmask)
34   {
35     _flags = (_flags & ~clearmask) | setmask;
36   }
37
38 public:
39   enum Flags
40   {
41     F_ignore = 0x01,
42     F_default_background = 0x02,
43   };
44
45   struct Property_handler
46   {
47     char const *tag;
48     bool value_property;
49     void (*handler)(Session *, Property_handler const *h, cxx::String const &value);
50   };
51
52   Session()
53   : _flags(0), _bg(0), _color(Mag_gfx::Rgb32::Black), _label(0), _ntfy(0)
54   {}
55
56   void set_notifier(cxx::Notifier *n) { _ntfy = n; }
57
58   bool ignore() const { return _flags & F_ignore; }
59   void ignore(bool ign)
60   {
61     if (ign)
62       _flags |= F_ignore;
63     else
64       _flags &= ~F_ignore;
65   }
66
67   unsigned flags() const { return _flags; }
68
69   char const *label() const { return _label; }
70   Mag_gfx::Rgb32::Color color() const { return _color; }
71   View *background() const { return _bg; }
72
73   void color(Mag_gfx::Rgb32::Color color) { _color = color; }
74   void background(View *bg) { _bg = bg; }
75
76   static void set_label_prop(Session *s, Property_handler const *, cxx::String const &v);
77   static void set_color_prop(Session *s, Property_handler const *, cxx::String const &v);
78
79   virtual ~Session();
80
81 };
82
83 typedef cxx::D_list<Session> Session_list;
84
85 }