summaryrefslogtreecommitdiff
path: root/src/WindowCmd.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/WindowCmd.hh')
-rw-r--r--src/WindowCmd.hh45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh
index f979f2b..34699ad 100644
--- a/src/WindowCmd.hh
+++ b/src/WindowCmd.hh
@@ -63,49 +63,4 @@ private:
63 Action m_action; 63 Action m_action;
64}; 64};
65 65
66/// accesses values in current window
67template <typename Ret, typename Def=Ret>
68class WindowAccessor: public FbTk::Accessor<Ret> {
69public:
70 typedef Ret (FluxboxWindow:: *Getter)() const;
71 typedef void (FluxboxWindow:: *Setter)(Ret);
72 WindowAccessor(Getter g, Setter s, Def def):
73 m_getter(g), m_setter(s), m_def(def) { }
74
75 operator Ret() const {
76 FluxboxWindow *fbwin = WindowCmd<void>::window();
77 return fbwin ? (fbwin->*m_getter)() : m_def;
78 }
79 FbTk::Accessor<Ret> &operator =(const Ret &val) {
80 FluxboxWindow *fbwin = WindowCmd<void>::window();
81 if (fbwin)
82 (fbwin->*m_setter)(val);
83 return *this;
84 }
85
86private:
87 Getter m_getter;
88 Setter m_setter;
89 Def m_def;
90};
91
92/// same as above but only reads
93template <typename Ret, typename Def=Ret>
94class ConstWindowAccessor: public FbTk::Accessor<Ret> {
95public:
96 typedef Ret (FluxboxWindow:: *Getter)() const;
97 ConstWindowAccessor(Getter g, Def def):
98 m_getter(g), m_def(def) { }
99
100 operator Ret() const {
101 FluxboxWindow *fbwin = WindowCmd<void>::window();
102 return fbwin ? (fbwin->*m_getter)() : m_def;
103 }
104 FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; }
105
106private:
107 Getter m_getter;
108 Def m_def;
109};
110
111#endif // WINDOWCMD_HH 66#endif // WINDOWCMD_HH