change the width of our nim setup to fit in the german translation
[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         void setTransparent(int transp);
44         
45                 /* untested code */
46         int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
47                 /* ... */
48                 
49         int isTransparent() { return m_vis & wVisTransparent; }
50         
51         eWidgetAnimation m_animation;
52 private:
53         eWidgetDesktop *m_desktop;
54
55         enum { 
56                 wVisShow = 1,
57                 wVisTransparent = 2,
58         };
59         
60         int m_vis;      
61
62         ePtrList<eWidget> m_childs;
63         ePoint m_position;
64         eSize m_size;
65                 /* will be accounted when there's a client offset */
66         eSize m_client_offset;
67         eWidget *m_parent;
68         
69         ePtr<eWindowStyle> m_style;
70         
71         void insertIntoParent();
72         void doPaint(gPainter &painter, const gRegion &region);
73         void recalcClipRegionsWhenVisible();
74         
75         void parentRemoved();
76         
77         gRGB m_background_color;
78         int m_have_background_color;
79         
80         eWidget *m_current_focus, *m_focus_owner;
81         
82         int m_z_position;
83         
84 protected:
85         virtual ~eWidget();
86         void mayKillFocus();
87 public:
88
89                 // all in local space!
90         gRegion m_clip_region, m_visible_region, m_visible_with_childs;
91         struct eWidgetDesktopCompBuffer *m_comp_buffer;
92         
93         enum eWidgetEvent
94         {
95                 evtPaint,
96                 evtKey,
97                 evtChangedPosition,
98                 evtChangedSize,
99                 
100                 evtWillShow,
101                 evtWillHide,
102                 evtWillChangePosition, /* new size is eRect *data */
103                 evtWillChangeSize,
104                 
105                 evtAction,
106                 
107                 evtFocusGot,
108                 evtFocusLost,
109                 
110                 evtUserWidget,
111         };
112         virtual int event(int event, void *data = 0, void *data2 = 0);
113         void setFocus(eWidget *focus);
114 };
115
116 extern eWidgetDesktop *getDesktop();
117
118 #endif