- added missing actions (sorry)
[enigma2.git] / lib / gui / ewindow.cpp
1 #include <lib/gui/ewindow.h>
2 #include <lib/gui/ewidgetdesktop.h>
3
4 #include <lib/gui/ewindowstyle.h>
5
6 eWindow::eWindow(eWidgetDesktop *desktop): eWidget(0)
7 {
8         setStyle(new eWindowStyleSimple());
9
10                 /* we are the parent for the child window. */
11                 /* as we are in the constructor, this is thread safe. */
12         m_child = this;
13         m_child = new eWidget(this);
14         desktop->addRootWidget(this, 0);
15 }
16
17 eWindow::~eWindow()
18 {
19         getDesktop()->removeRootWidget(this);
20 }
21
22 void eWindow::setTitle(const std::string &string)
23 {
24         if (m_title == string)  
25                 return;
26         m_title = string;
27         event(evtTitleChanged);
28 }
29
30 int eWindow::event(int event, void *data, void *data2)
31 {
32         switch (event)
33         {
34         case evtWillChangeSize:
35         {
36                 ePtr<eWindowStyle> style;
37                 if (!getStyle(style))
38                 {
39                         const eSize &new_size = *static_cast<eSize*>(data);
40 //                      eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
41                         style->handleNewSize(this, new_size);
42                 }
43                 break;
44         }
45         case evtPaint:
46         {
47                 ePtr<eWindowStyle> style;
48                 if (!getStyle(style))
49                 {
50                         gPainter &painter = *static_cast<gPainter*>(data2);
51                         style->paintWindowDecoration(this, painter, m_title);
52                 } else
53                         eDebug("no style :(");
54                 return 0;
55         }
56         default:
57                 break;
58         }
59         return eWidget::event(event, data, data2);
60 }
61