diff options
author | fluxgen <fluxgen> | 2003-08-12 00:19:14 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-12 00:19:14 (GMT) |
commit | 687d1a802198ef377a5df087a821ffae697c74bc (patch) | |
tree | 5f340b06c5d8ac9d09d888e0c8c344942ae6091e | |
parent | 062da9647fa0b07094ffeb42f72be0333a2be773 (diff) | |
download | fluxbox-687d1a802198ef377a5df087a821ffae697c74bc.zip fluxbox-687d1a802198ef377a5df087a821ffae697c74bc.tar.bz2 |
added empty pixmap and change icon2winmap to a std list
-rw-r--r-- | src/IconbarTool.cc | 114 | ||||
-rw-r--r-- | src/IconbarTool.hh | 12 |
2 files changed, 89 insertions, 37 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 26dd8da..6e4b8ae 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -20,7 +20,7 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: IconbarTool.cc,v 1.1 2003/08/11 15:42:29 fluxgen Exp $ | 23 | // $Id: IconbarTool.cc,v 1.2 2003/08/12 00:19:14 fluxgen Exp $ |
24 | 24 | ||
25 | #include "IconbarTool.hh" | 25 | #include "IconbarTool.hh" |
26 | 26 | ||
@@ -29,6 +29,7 @@ | |||
29 | #include "IconbarTheme.hh" | 29 | #include "IconbarTheme.hh" |
30 | #include "Window.hh" | 30 | #include "Window.hh" |
31 | #include "IconButton.hh" | 31 | #include "IconButton.hh" |
32 | #include "Workspace.hh" | ||
32 | 33 | ||
33 | #include <iostream> | 34 | #include <iostream> |
34 | using namespace std; | 35 | using namespace std; |
@@ -42,39 +43,36 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
42 | ToolbarItem(ToolbarItem::RELATIVE), | 43 | ToolbarItem(ToolbarItem::RELATIVE), |
43 | m_screen(screen), | 44 | m_screen(screen), |
44 | m_icon_container(parent), | 45 | m_icon_container(parent), |
45 | m_theme(theme) { | 46 | m_theme(theme), |
47 | m_focused_pm(0), | ||
48 | m_unfocused_pm(0), | ||
49 | m_empty_pm(0) { | ||
46 | 50 | ||
47 | theme.reconfigSig().attach(this); | 51 | theme.reconfigSig().attach(this); |
52 | |||
48 | screen.clientListSig().attach(this); | 53 | screen.clientListSig().attach(this); |
54 | screen.currentWorkspaceSig().attach(this); | ||
49 | 55 | ||
50 | // for debug | 56 | update(0); |
51 | /* FbTk::RefCount<FbTk::Command> show_text(new ShowTextCmd()); | ||
52 | FbTk::Button *button = new TextButton(m_icon_container, theme.focusedText().font(), "ONE WINDOW"); | ||
53 | button->setOnClick(show_text); | ||
54 | button->setGC(theme.focusedText().textGC()); | ||
55 | button->setBackgroundColor(theme.focusedTexture().color()); | ||
56 | button->clear(); | ||
57 | m_icon_container.insertItem(button); | ||
58 | |||
59 | button = new TextButton(m_icon_container, theme.focusedText().font(), "ONE WINDOW"); | ||
60 | button->setOnClick(show_text); | ||
61 | button->setGC(theme.focusedText().textGC()); | ||
62 | button->setBackgroundColor(theme.focusedTexture().color()); | ||
63 | button->clear(); | ||
64 | m_icon_container.insertItem(button); | ||
65 | |||
66 | button = new TextButton(m_icon_container, theme.focusedText().font(), "ONE WINDOW"); | ||
67 | button->setOnClick(show_text); | ||
68 | button->setGC(theme.focusedText().textGC()); | ||
69 | button->setBackgroundColor(theme.focusedTexture().color()); | ||
70 | button->clear(); | ||
71 | m_icon_container.insertItem(button); | ||
72 | |||
73 | m_icon_container.showSubwindows(); | ||
74 | */ | ||
75 | renderTheme(); | 57 | renderTheme(); |
76 | } | 58 | } |
77 | 59 | ||
60 | IconbarTool::~IconbarTool() { | ||
61 | while (!m_icon_list.empty()) { | ||
62 | delete m_icon_list.back(); | ||
63 | m_icon_list.pop_back(); | ||
64 | } | ||
65 | |||
66 | // remove cached images | ||
67 | if (m_focused_pm) | ||
68 | m_screen.imageControl().removeImage(m_focused_pm); | ||
69 | if (m_unfocused_pm) | ||
70 | m_screen.imageControl().removeImage(m_focused_pm); | ||
71 | if (m_empty_pm) | ||
72 | m_screen.imageControl().removeImage(m_empty_pm); | ||
73 | |||
74 | } | ||
75 | |||
78 | void IconbarTool::move(int x, int y) { | 76 | void IconbarTool::move(int x, int y) { |
79 | m_icon_container.move(x, y); | 77 | m_icon_container.move(x, y); |
80 | } | 78 | } |
@@ -108,6 +106,41 @@ unsigned int IconbarTool::height() const { | |||
108 | } | 106 | } |
109 | 107 | ||
110 | void IconbarTool::update(FbTk::Subject *subj) { | 108 | void IconbarTool::update(FbTk::Subject *subj) { |
109 | // just focus signal? | ||
110 | if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { | ||
111 | renderTheme(); | ||
112 | return; | ||
113 | } | ||
114 | |||
115 | // ok, we got some signal that we need to update our iconbar container | ||
116 | |||
117 | // remove all clients and add them again...the only way to do it now | ||
118 | m_icon_container.removeAll(); | ||
119 | |||
120 | while (!m_icon_list.empty()) { | ||
121 | delete m_icon_list.back(); | ||
122 | m_icon_list.pop_back(); | ||
123 | } | ||
124 | |||
125 | // get current workspace and all it's clients | ||
126 | Workspace &space = *m_screen.currentWorkspace(); | ||
127 | // build a ItemList and add it (faster than adding single items) | ||
128 | Container::ItemList items; | ||
129 | Workspace::Windows::iterator it = space.windowList().begin(); | ||
130 | Workspace::Windows::iterator it_end = space.windowList().end(); | ||
131 | for (; it != it_end; ++it) { | ||
132 | // we just want windows that has clients | ||
133 | if ((*it)->clientList().size() == 0) | ||
134 | continue; | ||
135 | |||
136 | IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), **it); | ||
137 | items.push_back(button); | ||
138 | m_icon_list.push_back(button); | ||
139 | (*it)->focusSig().attach(this); | ||
140 | } | ||
141 | |||
142 | m_icon_container.showSubwindows(); | ||
143 | m_icon_container.insertItems(items); | ||
111 | 144 | ||
112 | renderTheme(); | 145 | renderTheme(); |
113 | } | 146 | } |
@@ -118,7 +151,7 @@ void IconbarTool::renderTheme() { | |||
118 | m_focused_pm = 0; | 151 | m_focused_pm = 0; |
119 | } else { | 152 | } else { |
120 | m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), | 153 | m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), |
121 | m_icon_container.maxHeightPerClient(), | 154 | m_icon_container.height(), |
122 | m_theme.focusedTexture()); | 155 | m_theme.focusedTexture()); |
123 | } | 156 | } |
124 | 157 | ||
@@ -130,19 +163,34 @@ void IconbarTool::renderTheme() { | |||
130 | m_unfocused_pm = 0; | 163 | m_unfocused_pm = 0; |
131 | } else { | 164 | } else { |
132 | m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), | 165 | m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), |
133 | m_icon_container.maxHeightPerClient(), | 166 | m_icon_container.height(), |
134 | m_theme.unfocusedTexture()); | 167 | m_theme.unfocusedTexture()); |
135 | } | 168 | } |
136 | if (tmp) | 169 | if (tmp) |
137 | m_screen.imageControl().removeImage(tmp); | 170 | m_screen.imageControl().removeImage(tmp); |
138 | 171 | ||
172 | // if we dont have any icons then we should render empty texture | ||
173 | tmp = m_empty_pm; | ||
174 | if (m_theme.emptyTexture().type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | ||
175 | m_empty_pm = 0; | ||
176 | m_icon_container.setBackgroundColor(m_theme.emptyTexture().color()); | ||
177 | } else { | ||
178 | m_empty_pm = m_screen.imageControl().renderImage(m_icon_container.width(), m_icon_container.height(), | ||
179 | m_theme.emptyTexture()); | ||
180 | m_icon_container.setBackgroundPixmap(m_empty_pm); | ||
181 | } | ||
182 | |||
183 | if (tmp) | ||
184 | m_screen.imageControl().removeImage(m_empty_pm); | ||
139 | 185 | ||
140 | // update buttons | 186 | // update buttons |
141 | Icon2WinMap::iterator icon_it = m_icon2winmap.begin(); | 187 | IconList::iterator icon_it = m_icon_list.begin(); |
142 | Icon2WinMap::iterator icon_it_end = m_icon2winmap.end(); | 188 | IconList::iterator icon_it_end = m_icon_list.end(); |
143 | for (; icon_it != icon_it_end; ++icon_it) { | 189 | for (; icon_it != icon_it_end; ++icon_it) { |
144 | IconButton &button = *(*icon_it).second; | 190 | |
145 | if (button.win().isFocused()) { | 191 | IconButton &button = *(*icon_it); |
192 | |||
193 | if (button.win().isFocused()) { // focused texture | ||
146 | button.setGC(m_theme.focusedText().textGC()); | 194 | button.setGC(m_theme.focusedText().textGC()); |
147 | button.setFont(m_theme.focusedText().font()); | 195 | button.setFont(m_theme.focusedText().font()); |
148 | button.setJustify(m_theme.focusedText().justify()); | 196 | button.setJustify(m_theme.focusedText().justify()); |
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 6711324..31c6f24 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh | |||
@@ -20,7 +20,7 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: IconbarTool.hh,v 1.1 2003/08/11 15:42:29 fluxgen Exp $ | 23 | // $Id: IconbarTool.hh,v 1.2 2003/08/12 00:18:43 fluxgen Exp $ |
24 | 24 | ||
25 | #ifndef ICONBARTOOL_HH | 25 | #ifndef ICONBARTOOL_HH |
26 | #define ICONBARTOOL_HH | 26 | #define ICONBARTOOL_HH |
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include "FbTk/Observer.hh" | 31 | #include "FbTk/Observer.hh" |
32 | 32 | ||
33 | #include <map> | 33 | #include <list> |
34 | 34 | ||
35 | #include <X11/Xlib.h> | 35 | #include <X11/Xlib.h> |
36 | 36 | ||
@@ -42,6 +42,8 @@ class FluxboxWindow; | |||
42 | class IconbarTool: public ToolbarItem, public FbTk::Observer { | 42 | class IconbarTool: public ToolbarItem, public FbTk::Observer { |
43 | public: | 43 | public: |
44 | IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen); | 44 | IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen); |
45 | ~IconbarTool(); | ||
46 | |||
45 | void move(int x, int y); | 47 | void move(int x, int y); |
46 | void resize(unsigned int width, unsigned int height); | 48 | void resize(unsigned int width, unsigned int height); |
47 | void moveResize(int x, int y, | 49 | void moveResize(int x, int y, |
@@ -59,10 +61,12 @@ private: | |||
59 | BScreen &m_screen; | 61 | BScreen &m_screen; |
60 | Container m_icon_container; | 62 | Container m_icon_container; |
61 | const IconbarTheme &m_theme; | 63 | const IconbarTheme &m_theme; |
64 | // cached pixmaps | ||
62 | Pixmap m_focused_pm, m_unfocused_pm; | 65 | Pixmap m_focused_pm, m_unfocused_pm; |
66 | Pixmap m_empty_pm; ///< pixmap for empty container | ||
63 | 67 | ||
64 | typedef std::map<FluxboxWindow *, IconButton *> Icon2WinMap; | 68 | typedef std::list<IconButton *> IconList; |
65 | Icon2WinMap m_icon2winmap; | 69 | IconList m_icon_list; |
66 | }; | 70 | }; |
67 | 71 | ||
68 | #endif // ICONBARTOOL_HH | 72 | #endif // ICONBARTOOL_HH |