2 #include "wmcallback.h"
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
{
19 mutable WMPixmap wPixmap
;
21 // how often to execute callbacks and update display, in milliseconds
24 // list of periods of individual callbacks (in units of wUpdateFreq)
25 vector
<int> wFuncPeriod
;
30 void real_deactivate();
32 // should be called only by a WMApp.
37 void run_timed_functions();
43 const WMWindow
* window() const; // returns "this"
45 // override these to make them no-ops; windows have no parents
47 void setparent(const WMFrame
*);
48 void setparent(const WMFrame
&);
51 int updatefreq() const;
52 WMPixmap
& pixmap() const;
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 -----------------------------------------
68 WMWindow::activate() { WMFrame::activate(); }
71 WMWindow::deactivate() { WMFrame::deactivate(); }
74 WMWindow::hide() { WMFrame::hide(); }
76 inline const WMWindow
*
77 WMWindow::window() const { return this; }
80 WMWindow::parent() { return 0; }
83 WMWindow::setparent(const WMFrame
*) { }
86 WMWindow::setparent(const WMFrame
&) { }
89 WMWindow::app() const { return wApp
; }
92 WMWindow::updatefreq() const { return wUpdateFreq
; }
95 WMWindow::setupdatefreq(int milliseconds
) { wUpdateFreq
= milliseconds
; }
98 WMWindow::add_timed_function(int period
, data_func f
, void *datap
)
100 WMCallback::addcallback(f
, datap
);
101 wFuncPeriod
.push_back(period
);
105 WMWindow::add_timed_function(int period
, widget_func f
, WMWidget
*w
,
108 WMCallback::addcallback(f
, w
, datap
);
109 wFuncPeriod
.push_back(period
);
113 WMWindow::clear_timed_functions()
115 WMCallback::clearcallbacks();
120 WMWindow::pixmap() const { return wPixmap
; }
123 WMWindow::press(int button
, int x
, int y
)
124 { return WMFrame::press(button
, x
, y
); }
127 WMWindow::release(int button
, int x
, int y
)
128 { return WMFrame::release(button
, x
, y
); }