fix: the symbolrate for cable somehow got into the sat-setup and vice versa
[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 #include <lib/gui/ewidgetanimation.h>
8
9 class eWidgetDesktop;class eWidgetDesktop;
10
11 class eWidget
12 {
13         friend class eWidgetDesktop;
14 public:
15         eWidget(eWidget *parent);
16         
17         void move(ePoint pos);
18         void resize(eSize size);
19         
20         ePoint position() const { return m_position; }
21         eSize size() const { return m_size; }
22
23         void invalidate(const gRegion &region = gRegion::invalidRegion());
24         
25                 /* the window were to attach childs to. Normally, this 
26                    is "this", but it can be overridden in case a widget
27                    has a "client area", which is implemented as a child
28                    widget. eWindow overrides this, for example. */
29         virtual eWidget *child() { return this; }
30
31         void show();
32         void hide();
33         
34         void destruct();
35         
36         int getStyle(ePtr<eWindowStyle> &style) { if (!m_style) return 1; style = m_style; return 0; }
37         void setStyle(eWindowStyle *style) { m_style = style; }
38         
39         void setBackgroundColor(const gRGB &col);
40         void clearBackgroundColor();
41         
42         void setZPosition(int z);
43         
44                 /* untested code */
45         int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
46                 /* ... */
47         
48         eWidgetAnimation m_animation;
49 private:
50         eWidgetDesktop *m_desktop;
51
52         enum { 
53                 wVisShow = 1,
54                 wVisTransparent = 2,
55         };
56         
57         int m_vis;      
58
59         ePtrList<eWidget> m_childs;
60         ePoint m_position;
61         eSize m_size;
62                 /* will be accounted when there's a client offset */
63         eSize m_client_offset;
64         eWidget *m_parent;
65         
66         ePtr<eWindowStyle> m_style;
67         
68         void insertIntoParent();
69         void doPaint(gPainter &painter, const gRegion &region);
70         void recalcClipRegionsWhenVisible();
71         
72         gRGB m_background_color;
73         int m_have_background_color;
74         
75         eWidget *m_current_focus, *m_focus_owner;
76         
77         int m_z_position;
78         
79 protected:
80         virtual ~eWidget();
81         void mayKillFocus();
82 public:
83
84                 // all in local space!
85         gRegion m_clip_region, m_visible_region, m_visible_with_childs;
86         struct eWidgetDesktopCompBuffer *m_comp_buffer;
87         
88         enum eWidgetEvent
89         {
90                 evtPaint,
91                 evtKey,
92                 evtChangedPosition,
93                 evtChangedSize,
94                 
95                 evtWillShow,
96                 evtWillHide,
97                 evtWillChangePosition, /* new size is eRect *data */
98                 evtWillChangeSize,
99                 
100                 evtAction,
101                 
102                 evtFocusGot,
103                 evtFocusLost,
104                 
105                 evtUserWidget,
106         };
107         virtual int event(int event, void *data = 0, void *data2 = 0);
108         void setFocus(eWidget *focus);
109 };
110
111 extern eWidgetDesktop *getDesktop();
112
113 #endif