diff options
Diffstat (limited to 'src/Focusable.hh')
-rw-r--r-- | src/Focusable.hh | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/Focusable.hh b/src/Focusable.hh index 21baffa..e2c7e50 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh | |||
@@ -23,19 +23,34 @@ | |||
23 | #define FOCUSABLE_HH | 23 | #define FOCUSABLE_HH |
24 | 24 | ||
25 | #include "FbTk/FbPixmap.hh" | 25 | #include "FbTk/FbPixmap.hh" |
26 | #include "FbTk/ITypeAheadable.hh" | ||
27 | #include "FbTk/Subject.hh" | ||
26 | 28 | ||
27 | #include <string> | 29 | #include <string> |
28 | 30 | ||
31 | class BScreen; | ||
29 | class FluxboxWindow; | 32 | class FluxboxWindow; |
30 | 33 | ||
31 | // base class for any object that might be "focused" | 34 | // base class for any object that might be "focused" |
32 | class Focusable { | 35 | class Focusable: public FbTk::ITypeAheadable { |
33 | public: | 36 | public: |
34 | Focusable(FluxboxWindow *fbwin = 0): m_fbwin(fbwin) { } | 37 | Focusable(BScreen &scr, FluxboxWindow *fbwin = 0): |
38 | m_screen(scr), m_fbwin(fbwin), | ||
39 | m_focused(false), m_titlesig(*this) { } | ||
35 | virtual ~Focusable() { } | 40 | virtual ~Focusable() { } |
36 | 41 | ||
37 | virtual bool focus() { return false; } | 42 | virtual bool focus() { return false; } |
38 | 43 | ||
44 | virtual bool isFocused() const { return m_focused; } | ||
45 | virtual bool acceptsFocus() const { return true; } | ||
46 | |||
47 | inline BScreen &screen() { return m_screen; } | ||
48 | inline const BScreen &screen() const { return m_screen; } | ||
49 | |||
50 | // for accessing window properties, like shaded, minimized, etc. | ||
51 | inline const FluxboxWindow *fbwindow() const { return m_fbwin; } | ||
52 | inline FluxboxWindow *fbwindow() { return m_fbwin; } | ||
53 | |||
39 | // so we can make nice buttons, menu entries, etc. | 54 | // so we can make nice buttons, menu entries, etc. |
40 | virtual const FbTk::FbPixmap &iconPixmap() const { return m_icon_pixmap; } | 55 | virtual const FbTk::FbPixmap &iconPixmap() const { return m_icon_pixmap; } |
41 | virtual bool usePixmap() const { return iconPixmap().drawable() != None; } | 56 | virtual bool usePixmap() const { return iconPixmap().drawable() != None; } |
@@ -45,15 +60,30 @@ public: | |||
45 | 60 | ||
46 | virtual const std::string &title() const { return m_title; } | 61 | virtual const std::string &title() const { return m_title; } |
47 | virtual const std::string &iconTitle() const { return m_icon_title; } | 62 | virtual const std::string &iconTitle() const { return m_icon_title; } |
63 | const std::string &iTypeString() const { return title(); } | ||
48 | 64 | ||
49 | // for accessing window properties, like shaded, minimized, etc. | 65 | class FocusSubject: public FbTk::Subject { |
50 | inline const FluxboxWindow *fbwindow() const { return m_fbwin; } | 66 | public: |
51 | inline FluxboxWindow *fbwindow() { return m_fbwin; } | 67 | FocusSubject(Focusable &w):m_win(w) { } |
68 | Focusable &win() { return m_win; } | ||
69 | const Focusable &win() const { return m_win; } | ||
70 | private: | ||
71 | Focusable &m_win; | ||
72 | }; | ||
73 | |||
74 | // used for both title and icon changes | ||
75 | FbTk::Subject &titleSig() { return m_titlesig; } | ||
76 | const FbTk::Subject &titleSig() const { return m_titlesig; } | ||
52 | 77 | ||
53 | protected: | 78 | protected: |
79 | BScreen &m_screen; | ||
80 | FluxboxWindow *m_fbwin; | ||
81 | |||
82 | bool m_focused; | ||
54 | std::string m_title, m_icon_title; | 83 | std::string m_title, m_icon_title; |
55 | FbTk::FbPixmap m_icon_pixmap, m_icon_mask; | 84 | FbTk::FbPixmap m_icon_pixmap, m_icon_mask; |
56 | FluxboxWindow *m_fbwin; | 85 | |
86 | FocusSubject m_titlesig; | ||
57 | }; | 87 | }; |
58 | 88 | ||
59 | #endif // FOCUSABLE_HH | 89 | #endif // FOCUSABLE_HH |