summaryrefslogtreecommitdiff
path: root/src/IconBar.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconBar.cc')
-rw-r--r--src/IconBar.cc107
1 files changed, 54 insertions, 53 deletions
diff --git a/src/IconBar.cc b/src/IconBar.cc
index 331204e..0da5a4e 100644
--- a/src/IconBar.cc
+++ b/src/IconBar.cc
@@ -19,16 +19,18 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: IconBar.cc,v 1.8 2002/01/20 02:10:37 fluxgen Exp $ 22// $Id: IconBar.cc,v 1.9 2002/02/04 22:43:15 fluxgen Exp $
23 23
24#include "IconBar.hh" 24#include "IconBar.hh"
25#include "i18n.hh" 25#include "i18n.hh"
26#include "Screen.hh" 26#include "Screen.hh"
27 27
28#include <algorithm>
29
28IconBarObj::IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin) 30IconBarObj::IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin)
29{ 31{
30m_fluxboxwin = fluxboxwin; 32 m_fluxboxwin = fluxboxwin;
31m_iconwin = iconwin; 33 m_iconwin = iconwin;
32} 34}
33 35
34IconBarObj::~IconBarObj() { 36IconBarObj::~IconBarObj() {
@@ -39,12 +41,10 @@ IconBar::IconBar(BScreen *scrn, Window parent):
39m_screen(scrn), 41m_screen(scrn),
40m_parent(parent) 42m_parent(parent)
41{ 43{
42 m_iconlist = new IconList;
43 m_display = scrn->getBaseDisplay()->getXDisplay(); 44 m_display = scrn->getBaseDisplay()->getXDisplay();
44} 45}
45 46
46IconBar::~IconBar() { 47IconBar::~IconBar() {
47 delete m_iconlist;
48} 48}
49 49
50//------------ addIcon ----------------------- 50//------------ addIcon -----------------------
@@ -57,7 +57,7 @@ Window IconBar::addIcon(FluxboxWindow *fluxboxwin) {
57 Window iconwin = createIconWindow(fluxboxwin, m_parent); 57 Window iconwin = createIconWindow(fluxboxwin, m_parent);
58 decorate(iconwin); 58 decorate(iconwin);
59 //add window object to list 59 //add window object to list
60 m_iconlist->insert(new IconBarObj(fluxboxwin, iconwin)); 60 m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin));
61 //reposition all icons to fit windowbar 61 //reposition all icons to fit windowbar
62 repositionIcons(); 62 repositionIcons();
63 63
@@ -77,11 +77,15 @@ Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
77 Window retwin = None; 77 Window retwin = None;
78 IconBarObj *obj = findIcon(fluxboxwin); 78 IconBarObj *obj = findIcon(fluxboxwin);
79 if (obj) { 79 if (obj) {
80 m_iconlist->remove(obj); 80 IconList::iterator it =
81 retwin = obj->getIconWin(); 81 std::find(m_iconlist.begin(), m_iconlist.end(), obj);
82 delete obj; 82 if (it != m_iconlist.end()) {
83 XDestroyWindow(m_display, retwin); 83 m_iconlist.erase(it);
84 repositionIcons(); 84 retwin = obj->getIconWin();
85 delete obj;
86 XDestroyWindow(m_display, retwin);
87 repositionIcons();
88 }
85 } 89 }
86 return retwin; 90 return retwin;
87} 91}
@@ -93,28 +97,22 @@ Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
93void IconBar::loadTheme(unsigned int width, unsigned int height) { 97void IconBar::loadTheme(unsigned int width, unsigned int height) {
94 BImageControl *image_ctrl = m_screen->getImageControl(); 98 BImageControl *image_ctrl = m_screen->getImageControl();
95 Pixmap tmp = m_focus_pm; 99 Pixmap tmp = m_focus_pm;
96 BTexture *texture = &(m_screen->getWindowStyle()->tab.l_focus); 100 BTexture *texture = &(m_screen->getWindowStyle()->tab.l_focus);
97
98 if (texture->getTexture() & BImage::PARENTRELATIVE ) {
99 101
100 BTexture *pt = &(m_screen->getWindowStyle()->tab.t_focus); 102 //If we are working on a PARENTRELATIVE, change to right focus value
101 if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) { 103 if (texture->getTexture() & BImage::PARENTRELATIVE ) {
102 m_focus_pm = None; 104 texture = &(m_screen->getWindowStyle()->tab.t_focus);
103 m_focus_pixel = pt->getColor()->getPixel(); 105 }
104 } else
105 m_focus_pm =
106 image_ctrl->renderImage(width, height, pt);
107 106
108 } else { 107 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
109 108 m_focus_pm = None;
110 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) { 109 m_focus_pixel = texture->getColor()->getPixel();
111 m_focus_pm = None; 110 } else {
112 m_focus_pixel = texture->getColor()->getPixel(); 111 m_focus_pm =
113 } else 112 image_ctrl->renderImage(width, height, texture);
114 m_focus_pm =
115 image_ctrl->renderImage(width, height, texture);
116 } 113 }
117 if (tmp) image_ctrl->removeImage(tmp); 114
115 if (tmp) image_ctrl->removeImage(tmp);
118} 116}
119 117
120//------------ decorate ------------------ 118//------------ decorate ------------------
@@ -146,10 +144,11 @@ void IconBar::reconfigure() {
146//---------------------------------------- 144//----------------------------------------
147void IconBar::exposeEvent(XExposeEvent *ee) { 145void IconBar::exposeEvent(XExposeEvent *ee) {
148 IconBarObj *obj=0; 146 IconBarObj *obj=0;
149 IconListIterator it(m_iconlist); 147 IconList::iterator it = m_iconlist.begin();
150 for (; it.current(); it++) { 148 IconList::iterator it_end = m_iconlist.end();
151 if (it.current()->getIconWin() == ee->window) { 149 for (; it != it_end; ++it) {
152 obj = it.current(); 150 if ((*it)->getIconWin() == ee->window) {
151 obj = (*it);
153 break; 152 break;
154 } 153 }
155 } 154 }
@@ -164,7 +163,7 @@ void IconBar::exposeEvent(XExposeEvent *ee) {
164 &border_width, &depth); 163 &border_width, &depth);
165 164
166 //max width on every icon 165 //max width on every icon
167 unsigned int icon_width = width / m_iconlist->count(); 166 unsigned int icon_width = width / m_iconlist.size();
168 167
169 //load right size of theme 168 //load right size of theme
170 loadTheme(icon_width, height); 169 loadTheme(icon_width, height);
@@ -178,7 +177,7 @@ void IconBar::exposeEvent(XExposeEvent *ee) {
178// Calculates and moves/resizes the icons 177// Calculates and moves/resizes the icons
179//----------------------------------------- 178//-----------------------------------------
180void IconBar::repositionIcons(void) { 179void IconBar::repositionIcons(void) {
181 if (!m_iconlist->count()) 180 if (m_iconlist.size() == 0)
182 return; 181 return;
183 182
184 Window root; 183 Window root;
@@ -189,19 +188,19 @@ void IconBar::repositionIcons(void) {
189 &border_width, &depth); 188 &border_width, &depth);
190 189
191 //max width on every icon 190 //max width on every icon
192 unsigned int icon_width = width / m_iconlist->count(); 191 unsigned int icon_width = width / m_iconlist.size();
193 192
194 //load right size of theme 193 //load right size of theme
195 loadTheme(icon_width, height); 194 loadTheme(icon_width, height);
196 195
197 IconListIterator it(m_iconlist); 196 IconList::iterator it = m_iconlist.begin();
198 197 IconList::iterator it_end = m_iconlist.end();
199 for (x = 0; it.current(); it++, x+=icon_width) { 198 for (x = 0; it != it_end; ++it, x += icon_width) {
200 Window iconwin = it.current()->getIconWin(); 199 Window iconwin = (*it)->getIconWin();
201 XMoveResizeWindow(m_display, iconwin, 200 XMoveResizeWindow(m_display, iconwin,
202 x, 0, 201 x, 0,
203 icon_width, height); 202 icon_width, height);
204 draw(it.current(), icon_width); 203 draw((*it), icon_width);
205 decorate(iconwin); 204 decorate(iconwin);
206 } 205 }
207 206
@@ -244,7 +243,9 @@ void IconBar::draw(IconBarObj *obj, int width) {
244 unsigned int title_len = strlen(title); 243 unsigned int title_len = strlen(title);
245 unsigned int title_text_w; 244 unsigned int title_text_w;
246 245
247 if (I18n::instance()->multibyte()) { 246 const int multibyte = I18n::instance()->multibyte();
247
248 if (multibyte) {
248 XRectangle ink, logical; 249 XRectangle ink, logical;
249 XmbTextExtents(m_screen->getWindowStyle()->font.set, 250 XmbTextExtents(m_screen->getWindowStyle()->font.set,
250 title, title_len, &ink, &logical); 251 title, title_len, &ink, &logical);
@@ -260,7 +261,7 @@ void IconBar::draw(IconBarObj *obj, int width) {
260 int dx=bevel_w*2; 261 int dx=bevel_w*2;
261 262
262 for (; dlen >= 0; dlen--) { 263 for (; dlen >= 0; dlen--) {
263 if (I18n::instance()->multibyte()) { 264 if (multibyte) {
264 XRectangle ink, logical; 265 XRectangle ink, logical;
265 XmbTextExtents(m_screen->getWindowStyle()->tab.font.set, 266 XmbTextExtents(m_screen->getWindowStyle()->tab.font.set,
266 title, dlen, 267 title, dlen,
@@ -290,7 +291,7 @@ void IconBar::draw(IconBarObj *obj, int width) {
290 291
291 XClearWindow(m_display, iconwin); 292 XClearWindow(m_display, iconwin);
292 293
293 if (I18n::instance()->multibyte()) { 294 if (multibyte) {
294 XmbDrawString(m_display, iconwin, 295 XmbDrawString(m_display, iconwin,
295 m_screen->getWindowStyle()->tab.font.set, 296 m_screen->getWindowStyle()->tab.font.set,
296 m_screen->getWindowStyle()->tab.l_text_focus_gc, dx, 297 m_screen->getWindowStyle()->tab.l_text_focus_gc, dx,
@@ -313,10 +314,10 @@ void IconBar::draw(IconBarObj *obj, int width) {
313//---------------------------------- 314//----------------------------------
314FluxboxWindow *IconBar::findWindow(Window w) { 315FluxboxWindow *IconBar::findWindow(Window w) {
315 316
316 IconListIterator it(m_iconlist); 317 IconList::iterator it = m_iconlist.begin();
317 318 IconList::iterator it_end = m_iconlist.end();
318 for (; it.current(); it++) { 319 for (; it != it_end; ++it) {
319 IconBarObj *tmp = it.current(); 320 IconBarObj *tmp = (*it);
320 if (tmp) 321 if (tmp)
321 if (tmp->getIconWin() == w) 322 if (tmp->getIconWin() == w)
322 return tmp->getFluxboxWin(); 323 return tmp->getFluxboxWin();
@@ -333,10 +334,10 @@ FluxboxWindow *IconBar::findWindow(Window w) {
333 334
334IconBarObj *IconBar::findIcon(FluxboxWindow *fluxboxwin) { 335IconBarObj *IconBar::findIcon(FluxboxWindow *fluxboxwin) {
335 336
336 IconListIterator it(m_iconlist); 337 IconList::iterator it = m_iconlist.begin();
337 338 IconList::iterator it_end = m_iconlist.end();
338 for (; it.current(); it++) { 339 for (; it != it_end; ++it) {
339 IconBarObj *tmp = it.current(); 340 IconBarObj *tmp = (*it);
340 if (tmp) 341 if (tmp)
341 if (tmp->getFluxboxWin() == fluxboxwin) 342 if (tmp->getFluxboxWin() == fluxboxwin)
342 return tmp; 343 return tmp;