wmcube: imported Upstream version 0.99-pre1
[dockapps.git] / wmcube / wmapp / wmwindow.h
blob20a4ef5a02eb0f8d91a46d82104d02f7c44e4c32
1 #include "wmframe.h"
2 #include "wmcallback.h"
3 #include "xwrapper.h"
5 #ifndef _WMWINDOW_H
6 #define _WMWINDOW_H
8 class WMApp;
10 // WMWindow: A 64x64 pixel square containing a number of widgets. You can
11 // set it to run callback functions at regular intervals. Only one WMWindow
12 // may be displayed at once. This is controlled by the WMApp containing a
13 // vector of WMWindows.
14 class WMWindow : private WMCallback, public WMFrame {
15 friend class WMApp;
17 private:
18 WMApp * wApp;
19 mutable WMPixmap wPixmap;
21 // how often to execute callbacks and update display, in milliseconds
22 int wUpdateFreq;
23 int wCounter;
24 // list of periods of individual callbacks (in units of wUpdateFreq)
25 vector<int> wFuncPeriod;
27 void initpixmaps();
28 void real_display();
29 void real_activate();
30 void real_deactivate();
32 // should be called only by a WMApp.
33 void display();
34 void hide();
35 void activate();
36 void deactivate();
37 void run_timed_functions();
39 public:
40 WMWindow();
41 ~WMWindow();
43 const WMWindow * window() const; // returns "this"
45 // override these to make them no-ops; windows have no parents
46 WMFrame *parent();
47 void setparent(const WMFrame *);
48 void setparent(const WMFrame &);
50 WMApp * app() const;
51 int updatefreq() const;
52 WMPixmap & pixmap() const;
54 void setapp(WMApp *);
56 void setupdatefreq(int milliseconds);
57 void add_timed_function(int period, data_func d, void * = 0);
58 void add_timed_function(int period, widget_func w, WMWidget *, void * = 0);
59 void clear_timed_functions();
61 bool press(int button, int x, int y);
62 bool release(int button, int x, int y);
65 // inline functions for WMWindow -----------------------------------------
67 inline void
68 WMWindow::activate() { WMFrame::activate(); }
70 inline void
71 WMWindow::deactivate() { WMFrame::deactivate(); }
73 inline void
74 WMWindow::hide() { WMFrame::hide(); }
76 inline const WMWindow *
77 WMWindow::window() const { return this; }
79 inline WMFrame *
80 WMWindow::parent() { return 0; }
82 inline void
83 WMWindow::setparent(const WMFrame *) { }
85 inline void
86 WMWindow::setparent(const WMFrame &) { }
88 inline WMApp *
89 WMWindow::app() const { return wApp; }
91 inline int
92 WMWindow::updatefreq() const { return wUpdateFreq; }
94 inline void
95 WMWindow::setupdatefreq(int milliseconds) { wUpdateFreq = milliseconds; }
97 inline void
98 WMWindow::add_timed_function(int period, data_func f, void *datap)
100 WMCallback::addcallback(f, datap);
101 wFuncPeriod.push_back(period);
104 inline void
105 WMWindow::add_timed_function(int period, widget_func f, WMWidget *w,
106 void *datap)
108 WMCallback::addcallback(f, w, datap);
109 wFuncPeriod.push_back(period);
112 inline void
113 WMWindow::clear_timed_functions()
115 WMCallback::clearcallbacks();
116 wFuncPeriod.clear();
119 inline WMPixmap &
120 WMWindow::pixmap() const { return wPixmap; }
122 inline bool
123 WMWindow::press(int button, int x, int y)
124 { return WMFrame::press(button, x, y); }
126 inline bool
127 WMWindow::release(int button, int x, int y)
128 { return WMFrame::release(button, x, y); }
130 #endif