]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/mag/include/server/view
update
[l4.git] / l4 / pkg / mag / include / server / view
index d207c33c217352335767110ad0efe387ad8d193f..0c34f01ebbe1db336f0209d8b01e754dd7383c4c 100644 (file)
@@ -9,9 +9,12 @@
  */
 #pragma once
 
+#include <l4/cxx/dlist>
 #include <l4/mag-gfx/geometry>
+#include <l4/mag-gfx/font>
 #include <l4/mag-gfx/gfx_colors>
 #include <l4/mag/server/mode>
+#include <l4/mag/server/session>
 #include <l4/re/event>
 
 namespace Mag_gfx {
@@ -24,36 +27,43 @@ namespace Mag_server {
 using namespace Mag_gfx;
 
 class View_stack;
+class Session;
 
-class View : public Rect
+class View : public cxx::D_list_item<View>, public Rect
 {
 private:
   friend class View_stack;
 
-  unsigned _flags;
-
-  View *_n;
-  View **_pn;
-
   View(View const &);
   void operator = (View const &);
 
+  unsigned _flags;
+  Point _label_pos;
+  Area _label_sz;
+
 protected:
   explicit View(Rect const &size, unsigned flags = 0)
-  : Rect(size), _flags(flags), _n(0), _pn(0)
+  : Rect(size), _flags(flags)
   {}
 
-  View *next() const { return _n; }
-
 public:
+  enum Consts
+  {
+    Label_sep = 8  // space between session label and view title
+  };
+
   static Rgb32::Color frame_color() { return Rgb32::Color(255, 200, 127); }
   static Rgb32::Color kill_color() { return Rgb32::Color(255, 0, 0); }
   enum
   {
-    F_transparent = 1,
-    F_need_frame  = 2,
-    F_ignore = 4,
-    F_focused = 8,
+    F_transparent = 0x01,
+    F_need_frame  = 0x02,
+    F_ignore      = 0x04,
+    F_focused     = 0x08,
+    F_background  = 0x10,
+    F_above       = 0x20,
+    F_no_label    = 0x40,
+    F_super_view  = 0x80,
   };
 
   void set_geometry(Rect const &p)
@@ -65,6 +75,18 @@ public:
   bool need_frame() const { return _flags & F_need_frame; }
   bool ignore() const { return _flags & F_ignore; }
   bool focused() const { return _flags & F_focused; }
+  bool background() const { return _flags & F_background; }
+  bool above() const { return _flags & F_above; }
+  bool super_view() const { return _flags & F_super_view; }
+
+  void set_as_background() { _flags |= F_background; }
+  void set_above(bool on)
+  {
+    if (on)
+      _flags |= F_above;
+    else
+      _flags &= ~F_above;
+  }
 
   void set_focus(bool on)
   {
@@ -78,6 +100,26 @@ public:
   virtual void handle_event(L4Re::Event_buffer::Event const &, Point const &) {}
   virtual ~View() {}
 
+  virtual Session *session() const { return 0; }
+
+  char const *title() const { return 0; }
+  Area calc_label_sz(Font const *font);
+  Point label_pos() const { return _label_pos; }
+  void label_pos(Point const &pos) { _label_pos = pos; }
+  Area label_sz() const { return _label_sz; }
+
+  int frame_width() const { return 4; }
 };
 
+
+inline
+Area
+View::calc_label_sz(Font const *font)
+{
+  char const *const l1 = session()->label();
+  char const *const l2 = title();
+  _label_sz = Area(font->str_w(l1) + (l2 ? (Label_sep + font->str_w(l2) + 2) : 2), font->str_h(l1) + 2);
+  return _label_sz;
+}
+
 }