]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/scout-gfx/include/user_state
09fa96dafae00ae1779cda973ce8a0395ea05253
[l4.git] / l4 / pkg / scout-gfx / include / user_state
1 // vi:ft=cpp
2 /*
3  * \brief   User state manager
4  * \date    2005-11-16
5  * \author  Norman Feske <norman.feske@genode-labs.com>
6  */
7
8 /*
9  * Copyright (C) 2005-2009
10  * Genode Labs, Feske & Helmuth Systementwicklung GbR
11  *
12  * This file is part of the Genode OS framework, which is distributed
13  * under the terms of the GNU General Public License version 2.
14  */
15
16 #pragma once
17
18 #include <l4/scout-gfx/widget>
19 #include <l4/scout-gfx/window>
20
21 namespace Scout_gfx {
22
23 class User_state : public Parent_widget
24 {
25 private:
26
27   Widget *_mfocus;    /* element that owns the current mouse focus */
28 //  Widget *_dst;       /* current link destination                  */
29   Widget *_active;    /* currently activated element               */
30   Point _am;
31   Point    _v;   /* current view offset                       */
32
33   /**
34    * Assign new mouse focus element
35    */
36   void _assign_mfocus(Widget *e, int force = 0);
37
38 public:
39
40   /**
41    * Constructor
42    */
43   User_state()
44   : _mfocus(0),/* _dst(0),*/ _active(0), _v(Point(0, 0))
45   {}
46
47   /**
48    * Accessor functions
49    */
50   //Point m() const { return _m; }
51   //Point v() const { return _v; }
52
53   /**
54    * Apply input event to mouse focus state
55    */
56   Widget *handle_event(Event const &ev);
57
58   /********************
59    ** Parent element **
60    ********************/
61
62   void forget(Widget *e)
63   {
64     if (_mfocus == e) _mfocus = 0;
65 //    if (_dst    == e) _dst    = 0;
66     if (_active == e) _active = 0;
67   }
68
69   void draw(Mag_gfx::Canvas *c, Mag_gfx::Point const &p)
70   {
71     //Rect r = geometry() + p;
72     Parent_widget::draw(c, p);
73   }
74
75   void size(Mag_gfx::Area const &s) { _size = s; }
76 };
77
78 }