diff options
author | fluxgen <fluxgen> | 2005-06-23 02:57:24 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2005-06-23 02:57:24 (GMT) |
commit | 18cf5862495aa6f37110c90286bb6c315a145526 (patch) | |
tree | f3c87373e0ce215ec4cbe7fb854859a78c2bb3cf /src/WindowCmd.hh | |
parent | c912f7a32aae713f24ab32464cd1f443043ad59f (diff) | |
download | fluxbox-18cf5862495aa6f37110c90286bb6c315a145526.zip fluxbox-18cf5862495aa6f37110c90286bb6c315a145526.tar.bz2 |
new files
Diffstat (limited to 'src/WindowCmd.hh')
-rw-r--r-- | src/WindowCmd.hh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh new file mode 100644 index 0000000..309e62b --- /dev/null +++ b/src/WindowCmd.hh | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef WINDOWCMD_HH | ||
2 | #define WINDOWCMD_HH | ||
3 | |||
4 | #include "FbTk/Command.hh" | ||
5 | #include "Window.hh" | ||
6 | |||
7 | /// holds context for WindowCmd | ||
8 | class WindowCmd_base { | ||
9 | public: | ||
10 | static void setWindow(FluxboxWindow *win) { s_win = win; } | ||
11 | static FluxboxWindow *window() { return s_win; } | ||
12 | protected: | ||
13 | static FluxboxWindow *s_win; | ||
14 | }; | ||
15 | |||
16 | |||
17 | /// executes action for a dynamic context set in WindowCmd_base | ||
18 | template <typename ReturnType=void> | ||
19 | class WindowCmd: public WindowCmd_base, public FbTk::Command { | ||
20 | public: | ||
21 | typedef ReturnType (FluxboxWindow::* Action)(); | ||
22 | WindowCmd(Action a):m_action(a) {} | ||
23 | void execute() { | ||
24 | if (window() != 0) | ||
25 | (*window().*m_action)(); | ||
26 | } | ||
27 | private: | ||
28 | Action m_action; | ||
29 | }; | ||
30 | |||
31 | |||
32 | #endif // WINDOWCMD_HH | ||