]> 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 public:
33   enum Flags
34   {
35     F_ignore = 0x01,
36   };
37
38   struct Property_handler
39   {
40     char const *tag;
41     bool value_property;
42     void (*handler)(Session *, Property_handler const *h, cxx::String const &value);
43   };
44
45   Session()
46   : _flags(0), _bg(0), _color(Mag_gfx::Rgb32::Black), _label(0), _ntfy(0)
47   {}
48
49   void set_notifier(cxx::Notifier *n) { _ntfy = n; }
50
51   bool ignore() const { return _flags & F_ignore; }
52   void ignore(bool ign)
53   {
54     if (ign)
55       _flags |= F_ignore;
56     else
57       _flags &= ~F_ignore;
58   }
59
60   char const *label() const { return _label; }
61   Mag_gfx::Rgb32::Color color() const { return _color; }
62   View *background() const { return _bg; }
63
64   void color(Mag_gfx::Rgb32::Color color) { _color = color; }
65   void background(View *bg) { _bg = bg; }
66
67   static void set_label_prop(Session *s, Property_handler const *, cxx::String const &v);
68   static void set_color_prop(Session *s, Property_handler const *, cxx::String const &v);
69
70   virtual ~Session();
71
72 };
73
74 typedef cxx::D_list<Session> Session_list;
75
76 }