allow burning DVDs with multiple titles where playback automatically jumps to the...
[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 #define MAX_LAYER 16
10
11 class eWidgetDesktop;class eWidgetDesktop;
12
13 class eWidget
14 {
15         friend class eWidgetDesktop;
16 public:
17         eWidget(eWidget *parent);
18         virtual ~eWidget();
19
20         void move(ePoint pos);
21         void resize(eSize size);
22         
23         ePoint position() const { return m_position; }
24         eSize size() const { return m_size; }
25
26         void invalidate(const gRegion &region = gRegion::invalidRegion());
27         
28                 /* the window were to attach childs to. Normally, this 
29                    is "this", but it can be overridden in case a widget
30                    has a "client area", which is implemented as a child
31                    widget. eWindow overrides this, for example. */
32         virtual eWidget *child() { return this; }
33
34         void show();
35         void hide();
36         
37         void destruct();
38         
39         SWIG_VOID(int) getStyle(ePtr<eWindowStyle> &SWIG_NAMED_OUTPUT(style)) { if (!m_style) return 1; style = m_style; return 0; }
40         void setStyle(eWindowStyle *style) { m_style = style; }
41         
42         void setBackgroundColor(const gRGB &col);
43         void clearBackgroundColor();
44         
45         void setZPosition(int z);
46         void setTransparent(int transp);
47         
48                 /* untested code */
49         int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
50                 /* ... */
51                 
52         int isTransparent() { return m_vis & wVisTransparent; }
53         
54         ePoint getAbsolutePosition();
55         
56         eWidgetAnimation m_animation;
57 private:
58         eWidgetDesktop *m_desktop;
59
60         enum { 
61                 wVisShow = 1,
62                 wVisTransparent = 2,
63         };
64         
65         int m_vis;      
66
67         int m_layer;
68
69         ePtrList<eWidget> m_childs;
70         ePoint m_position;
71         eSize m_size;
72                 /* will be accounted when there's a client offset */
73         eSize m_client_offset;
74         eWidget *m_parent;
75         
76         ePtr<eWindowStyle> m_style;
77         
78         void insertIntoParent();
79         void doPaint(gPainter &painter, const gRegion &region, int layer);
80         void recalcClipRegionsWhenVisible();
81         
82         void parentRemoved();
83         
84         gRGB m_background_color;
85         int m_have_background_color;
86         
87         eWidget *m_current_focus, *m_focus_owner;
88         
89         int m_z_position;
90         int m_notify_child_on_position_change;
91 protected:
92         void mayKillFocus();
93 public:
94
95                 // all in local space!
96         gRegion m_clip_region, m_visible_region, m_visible_with_childs;
97         struct eWidgetDesktopCompBuffer *m_comp_buffer[MAX_LAYER];
98         
99         enum eWidgetEvent
100         {
101                 evtPaint,
102                 evtKey,
103                 evtChangedPosition,
104                 evtChangedSize,
105                 
106                 evtParentChangedPosition,
107                 
108                 evtParentVisibilityChanged,
109                 evtWillChangePosition, /* new size is eRect *data */
110                 evtWillChangeSize,
111                 
112                 evtAction,
113                 
114                 evtFocusGot,
115                 evtFocusLost,
116                 
117                 evtUserWidget,
118         };
119         virtual int event(int event, void *data = 0, void *data2 = 0);
120         void setFocus(eWidget *focus);
121
122                 /* enable this if you need the absolute position of the widget */
123         void setPositionNotifyChild(int n) { m_notify_child_on_position_change = 1; }
124
125         void notifyShowHide();
126 };
127
128 extern eWidgetDesktop *getDesktop(int which);
129
130 #endif