- added hack for disabling actions on hidden windows. FIX ME
[enigma2.git] / lib / gui / ewidget.h
1 #ifndef __lib_gui_ewidget_h
2 #define __lib_gui_ewidget_h
3
4 #include <lib/gdi/grc.h> /* for gRegion */
5 #include <lib/base/eptrlist.h> /* for eSmartPtrList */
6 #include <lib/gui/ewindowstyle.h> /* for eWindowStyle */
7
8 class eWidget
9 {
10         friend class eWidgetDesktop;
11 public:
12         eWidget(eWidget *parent);
13         
14         void move(ePoint pos);
15         void resize(eSize size);
16         
17         ePoint position() const { return m_position; }
18         eSize size() const { return m_size; }
19
20         void invalidate(const gRegion &region = gRegion::invalidRegion());
21         
22                 /* the window were to attach childs to. Normally, this 
23                    is "this", but it can be overridden in case a widget
24                    has a "client area", which is implemented as a child
25                    widget. eWindow overrides this, for example. */
26         virtual eWidget *child() { return this; }
27
28         void show();
29         void hide();
30         
31         void destruct();
32         
33         int getStyle(ePtr<eWindowStyle> &style) { if (!m_style) return 1; style = m_style; return 0; }
34         void setStyle(eWindowStyle *style) { m_style = style; }
35         
36                 /* untested code */
37         int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
38                 /* ... */
39         
40 private:
41         eWidgetDesktop *m_desktop;
42
43         enum { 
44                 wVisShow = 1,
45                 wVisTransparent = 2,
46         };
47         
48         int m_vis;      
49
50         ePtrList<eWidget> m_childs;
51         ePoint m_position;
52         eSize m_size;
53         eWidget *m_parent;
54         
55         ePtr<eWindowStyle> m_style;
56         
57         void doPaint(gPainter &painter, const gRegion &region);
58         void recalcClipRegionsWhenVisible();
59 protected:
60         virtual ~eWidget();
61 public:
62
63                 // all in local space!
64         gRegion m_clip_region, m_visible_region, m_visible_with_childs;
65         
66         enum eWidgetEvent
67         {
68                 evtPaint,
69                 evtKey,
70                 evtChangedPosition,
71                 evtChangedSize,
72                 
73                 evtWillShow,
74                 evtWillHide,
75                 evtWillChangePosition, /* new size is eRect *data */
76                 evtWillChangeSize,
77                 
78                 evtAction,
79                 
80                 evtUserWidget,
81         };
82         virtual int event(int event, void *data = 0, void *data2 = 0);
83 };
84
85 extern eWidgetDesktop *getDesktop();
86
87 #endif