aboutsummaryrefslogtreecommitdiff
path: root/src/WindowCmd.hh
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2007-12-27 21:55:24 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2007-12-27 21:55:24 (GMT)
commitb5c354b994bc06667abe35e2d528c0f025703c4e (patch)
tree081fd3207053a06cb50931ccec3237bc614f10eb /src/WindowCmd.hh
parent1f5cd12facc662de240b36bf3c5c14f40adf391b (diff)
downloadfluxbox-b5c354b994bc06667abe35e2d528c0f025703c4e.zip
fluxbox-b5c354b994bc06667abe35e2d528c0f025703c4e.tar.bz2
architecture astronomy
Diffstat (limited to 'src/WindowCmd.hh')
-rw-r--r--src/WindowCmd.hh45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh
index 17a4e86..d1754e9 100644
--- a/src/WindowCmd.hh
+++ b/src/WindowCmd.hh
@@ -25,6 +25,7 @@
25#define WINDOWCMD_HH 25#define WINDOWCMD_HH
26 26
27#include "FbTk/Command.hh" 27#include "FbTk/Command.hh"
28#include "FbTk/Accessor.hh"
28#include "Window.hh" 29#include "Window.hh"
29#include "WinClient.hh" 30#include "WinClient.hh"
30 31
@@ -64,5 +65,49 @@ private:
64 Action m_action; 65 Action m_action;
65}; 66};
66 67
68/// accesses values in current window
69template <typename Ret, typename Def=Ret>
70class WindowAccessor: public FbTk::Accessor<Ret> {
71public:
72 typedef Ret (FluxboxWindow:: *Getter)() const;
73 typedef void (FluxboxWindow:: *Setter)(Ret);
74 WindowAccessor(Getter g, Setter s, Def def):
75 m_getter(g), m_setter(s), m_def(def) { }
76
77 inline operator Ret() const {
78 FluxboxWindow *fbwin = WindowCmd<void>::window();
79 return fbwin ? (fbwin->*m_getter)() : m_def;
80 }
81 inline FbTk::Accessor<Ret> &operator =(const Ret &val) {
82 FluxboxWindow *fbwin = WindowCmd<void>::window();
83 if (fbwin)
84 (fbwin->*m_setter)(val);
85 return *this;
86 }
87
88private:
89 Getter m_getter;
90 Setter m_setter;
91 Def m_def;
92};
93
94/// same as above but only reads
95template <typename Ret, typename Def=Ret>
96class ConstWindowAccessor: public FbTk::Accessor<Ret> {
97public:
98 typedef Ret (FluxboxWindow:: *Getter)() const;
99 ConstWindowAccessor(Getter g, Def def):
100 m_getter(g), m_def(def) { }
101
102 inline operator Ret() const {
103 FluxboxWindow *fbwin = WindowCmd<void>::window();
104 return fbwin ? (fbwin->*m_getter)() : m_def;
105 }
106 inline FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; }
107
108private:
109 Getter m_getter;
110 Def m_def;
111};
67 112
68#endif // WINDOWCMD_HH 113#endif // WINDOWCMD_HH