summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-11 15:42:29 (GMT)
committerfluxgen <fluxgen>2003-08-11 15:42:29 (GMT)
commitfe1c6012e49a516e591aaca4f8c13cb645bce54a (patch)
tree47b9793ac43beef3df41c0f29bad18520da24798
parent0df2793bb7651897ff50c7587913b543bd6560bc (diff)
downloadfluxbox_lack-fe1c6012e49a516e591aaca4f8c13cb645bce54a.zip
fluxbox_lack-fe1c6012e49a516e591aaca4f8c13cb645bce54a.tar.bz2
iconbar for toolbar
-rw-r--r--src/IconbarTool.cc169
-rw-r--r--src/IconbarTool.hh68
2 files changed, 237 insertions, 0 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
new file mode 100644
index 0000000..26dd8da
--- /dev/null
+++ b/src/IconbarTool.cc
@@ -0,0 +1,169 @@
1// IconbarTool.cc
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: IconbarTool.cc,v 1.1 2003/08/11 15:42:29 fluxgen Exp $
24
25#include "IconbarTool.hh"
26
27#include "Screen.hh"
28#include "ImageControl.hh"
29#include "IconbarTheme.hh"
30#include "Window.hh"
31#include "IconButton.hh"
32
33#include <iostream>
34using namespace std;
35class ShowTextCmd: public FbTk::Command {
36 void execute() {
37 cerr<<"ShowTextCmd"<<endl;
38 }
39};
40
41IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen):
42 ToolbarItem(ToolbarItem::RELATIVE),
43 m_screen(screen),
44 m_icon_container(parent),
45 m_theme(theme) {
46
47 theme.reconfigSig().attach(this);
48 screen.clientListSig().attach(this);
49
50 // for debug
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();
76}
77
78void IconbarTool::move(int x, int y) {
79 m_icon_container.move(x, y);
80}
81
82void IconbarTool::resize(unsigned int width, unsigned int height) {
83 m_icon_container.resize(width, height);
84 renderTheme();
85}
86
87void IconbarTool::moveResize(int x, int y,
88 unsigned int width, unsigned int height) {
89
90 m_icon_container.moveResize(x, y, width, height);
91 renderTheme();
92}
93
94void IconbarTool::show() {
95 m_icon_container.show();
96}
97
98void IconbarTool::hide() {
99 m_icon_container.hide();
100}
101
102unsigned int IconbarTool::width() const {
103 return m_icon_container.width();
104}
105
106unsigned int IconbarTool::height() const {
107 return m_icon_container.height();
108}
109
110void IconbarTool::update(FbTk::Subject *subj) {
111
112 renderTheme();
113}
114
115void IconbarTool::renderTheme() {
116 Pixmap tmp = m_focused_pm;
117 if (m_theme.focusedTexture().type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
118 m_focused_pm = 0;
119 } else {
120 m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(),
121 m_icon_container.maxHeightPerClient(),
122 m_theme.focusedTexture());
123 }
124
125 if (tmp)
126 m_screen.imageControl().removeImage(tmp);
127
128 tmp = m_unfocused_pm;
129 if (m_theme.unfocusedTexture().type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
130 m_unfocused_pm = 0;
131 } else {
132 m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(),
133 m_icon_container.maxHeightPerClient(),
134 m_theme.unfocusedTexture());
135 }
136 if (tmp)
137 m_screen.imageControl().removeImage(tmp);
138
139
140 // update buttons
141 Icon2WinMap::iterator icon_it = m_icon2winmap.begin();
142 Icon2WinMap::iterator icon_it_end = m_icon2winmap.end();
143 for (; icon_it != icon_it_end; ++icon_it) {
144 IconButton &button = *(*icon_it).second;
145 if (button.win().isFocused()) {
146 button.setGC(m_theme.focusedText().textGC());
147 button.setFont(m_theme.focusedText().font());
148 button.setJustify(m_theme.focusedText().justify());
149
150 if (m_focused_pm != 0)
151 button.setBackgroundPixmap(m_focused_pm);
152 else
153 button.setBackgroundColor(m_theme.focusedTexture().color());
154
155
156 } else { // unfocused
157 button.setGC(m_theme.unfocusedText().textGC());
158 button.setFont(m_theme.unfocusedText().font());
159 button.setJustify(m_theme.unfocusedText().justify());
160
161 if (m_unfocused_pm != 0)
162 button.setBackgroundPixmap(m_unfocused_pm);
163 else
164 button.setBackgroundColor(m_theme.unfocusedTexture().color());
165 }
166
167 button.clear();
168 }
169}
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh
new file mode 100644
index 0000000..6711324
--- /dev/null
+++ b/src/IconbarTool.hh
@@ -0,0 +1,68 @@
1// IconbarTool.hh
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: IconbarTool.hh,v 1.1 2003/08/11 15:42:29 fluxgen Exp $
24
25#ifndef ICONBARTOOL_HH
26#define ICONBARTOOL_HH
27
28#include "ToolbarItem.hh"
29#include "Container.hh"
30
31#include "FbTk/Observer.hh"
32
33#include <map>
34
35#include <X11/Xlib.h>
36
37class IconbarTheme;
38class BScreen;
39class IconButton;
40class FluxboxWindow;
41
42class IconbarTool: public ToolbarItem, public FbTk::Observer {
43public:
44 IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen);
45 void move(int x, int y);
46 void resize(unsigned int width, unsigned int height);
47 void moveResize(int x, int y,
48 unsigned int width, unsigned int height);
49
50 void update(FbTk::Subject *subj);
51 void show();
52 void hide();
53 unsigned int width() const;
54 unsigned int height() const;
55
56private:
57 void renderTheme();
58
59 BScreen &m_screen;
60 Container m_icon_container;
61 const IconbarTheme &m_theme;
62 Pixmap m_focused_pm, m_unfocused_pm;
63
64 typedef std::map<FluxboxWindow *, IconButton *> Icon2WinMap;
65 Icon2WinMap m_icon2winmap;
66};
67
68#endif // ICONBARTOOL_HH