aboutsummaryrefslogtreecommitdiff
path: root/src/IconBar.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2002-12-01 13:42:15 (GMT)
committerrathnor <rathnor>2002-12-01 13:42:15 (GMT)
commit28b5c604490094e187494dcc566bd3d7a05a2c25 (patch)
tree8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/IconBar.cc
parentb9134162f9633784d9097df18769a699a62650fe (diff)
downloadfluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip
fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/IconBar.cc')
-rw-r--r--src/IconBar.cc382
1 files changed, 191 insertions, 191 deletions
diff --git a/src/IconBar.cc b/src/IconBar.cc
index 9446165..aeef15d 100644
--- a/src/IconBar.cc
+++ b/src/IconBar.cc
@@ -19,7 +19,7 @@
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.20 2002/11/30 20:10:42 fluxgen Exp $ 22// $Id: IconBar.cc,v 1.21 2002/12/01 13:41:57 rathnor Exp $
23 23
24#include "IconBar.hh" 24#include "IconBar.hh"
25#include "i18n.hh" 25#include "i18n.hh"
@@ -31,8 +31,8 @@
31 31
32IconBarObj::IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin) 32IconBarObj::IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin)
33{ 33{
34 m_fluxboxwin = fluxboxwin; 34 m_fluxboxwin = fluxboxwin;
35 m_iconwin = iconwin; 35 m_iconwin = iconwin;
36} 36}
37 37
38IconBarObj::~IconBarObj() { 38IconBarObj::~IconBarObj() {
@@ -44,26 +44,26 @@ IconBarObj::~IconBarObj() {
44// window 44// window
45//------------------------------------ 45//------------------------------------
46unsigned int IconBarObj::width() const { 46unsigned int IconBarObj::width() const {
47 Window root; 47 Window root;
48 48
49 unsigned int width, height; 49 unsigned int width, height;
50 unsigned int border_width, depth; //not used 50 unsigned int border_width, depth; //not used
51 int x, y; //not used 51 int x, y; //not used
52 52
53 Display *m_display = Fluxbox::instance()->getXDisplay(); 53 Display *m_display = Fluxbox::instance()->getXDisplay();
54 54
55 XGetGeometry(m_display, m_iconwin, &root, &x, &y, 55 XGetGeometry(m_display, m_iconwin, &root, &x, &y,
56 &width, &height, &border_width, &depth); 56 &width, &height, &border_width, &depth);
57 57
58 return width; 58 return width;
59} 59}
60 60
61 61
62IconBar::IconBar(BScreen *scrn, Window parent): 62IconBar::IconBar(BScreen *scrn, Window parent):
63m_screen(scrn), 63 m_screen(scrn),
64m_parent(parent) 64 m_parent(parent)
65{ 65{
66 m_display = scrn->getBaseDisplay()->getXDisplay(); 66 m_display = scrn->getBaseDisplay()->getXDisplay();
67} 67}
68 68
69IconBar::~IconBar() { 69IconBar::~IconBar() {
@@ -76,17 +76,17 @@ IconBar::~IconBar() {
76//-------------------------------------------- 76//--------------------------------------------
77Window IconBar::addIcon(FluxboxWindow *fluxboxwin) { 77Window IconBar::addIcon(FluxboxWindow *fluxboxwin) {
78 78
79 Window iconwin = createIconWindow(fluxboxwin, m_parent); 79 Window iconwin = createIconWindow(fluxboxwin, m_parent);
80 decorate(iconwin); 80 decorate(iconwin);
81 //add window object to list 81 //add window object to list
82 m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin)); 82 m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin));
83 //reposition all icons to fit windowbar 83 //reposition all icons to fit windowbar
84 repositionIcons(); 84 repositionIcons();
85 85
86 XMapSubwindows(m_display, iconwin); 86 XMapSubwindows(m_display, iconwin);
87 XMapWindow(m_display, iconwin); 87 XMapWindow(m_display, iconwin);
88 88
89 return iconwin; 89 return iconwin;
90} 90}
91 91
92//----------- delIcon ------------------- 92//----------- delIcon -------------------
@@ -96,20 +96,20 @@ Window IconBar::addIcon(FluxboxWindow *fluxboxwin) {
96// returns None if no window was found 96// returns None if no window was found
97//--------------------------------------- 97//---------------------------------------
98Window IconBar::delIcon(FluxboxWindow *fluxboxwin) { 98Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
99 Window retwin = None; 99 Window retwin = None;
100 IconBarObj *obj = findIcon(fluxboxwin); 100 IconBarObj *obj = findIcon(fluxboxwin);
101 if (obj) { 101 if (obj) {
102 IconList::iterator it = 102 IconList::iterator it =
103 std::find(m_iconlist.begin(), m_iconlist.end(), obj); 103 std::find(m_iconlist.begin(), m_iconlist.end(), obj);
104 if (it != m_iconlist.end()) { 104 if (it != m_iconlist.end()) {
105 m_iconlist.erase(it); 105 m_iconlist.erase(it);
106 retwin = obj->getIconWin(); 106 retwin = obj->getIconWin();
107 delete obj; 107 delete obj;
108 XDestroyWindow(m_display, retwin); 108 XDestroyWindow(m_display, retwin);
109 repositionIcons(); 109 repositionIcons();
110 } 110 }
111 } 111 }
112 return retwin; 112 return retwin;
113} 113}
114 114
115//------------ loadTheme --------------- 115//------------ loadTheme ---------------
@@ -117,25 +117,25 @@ Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
117// with the size width * height 117// with the size width * height
118//-------------------------------------- 118//--------------------------------------
119void IconBar::loadTheme(unsigned int width, unsigned int height) { 119void IconBar::loadTheme(unsigned int width, unsigned int height) {
120 BImageControl *image_ctrl = m_screen->getImageControl(); 120 BImageControl *image_ctrl = m_screen->getImageControl();
121 Pixmap tmp = m_focus_pm; 121 Pixmap tmp = m_focus_pm;
122 const FbTk::Texture *texture = &(m_screen->getWindowStyle()->tab.l_focus); 122 const FbTk::Texture *texture = &(m_screen->getWindowStyle()->tab.l_focus);
123 123
124 //If we are working on a PARENTRELATIVE, change to right focus value 124 //If we are working on a PARENTRELATIVE, change to right focus value
125 if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { 125 if (texture->type() & FbTk::Texture::PARENTRELATIVE ) {
126 texture = &(m_screen->getWindowStyle()->tab.t_focus); 126 texture = &(m_screen->getWindowStyle()->tab.t_focus);
127 } 127 }
128 128
129 if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { 129 if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
130 m_focus_pm = None; 130 m_focus_pm = None;
131 m_focus_pixel = texture->color().pixel(); 131 m_focus_pixel = texture->color().pixel();
132 } else { 132 } else {
133 m_focus_pm = 133 m_focus_pm =
134 image_ctrl->renderImage(width, height, *texture); 134 image_ctrl->renderImage(width, height, *texture);
135 } 135 }
136 136
137 if (tmp) 137 if (tmp)
138 image_ctrl->removeImage(tmp); 138 image_ctrl->removeImage(tmp);
139} 139}
140 140
141//------------ decorate ------------------ 141//------------ decorate ------------------
@@ -144,12 +144,12 @@ void IconBar::loadTheme(unsigned int width, unsigned int height) {
144//---------------------------------------- 144//----------------------------------------
145void IconBar::decorate(Window win) { 145void IconBar::decorate(Window win) {
146 146
147 XSetWindowBorderWidth(m_display, win, m_screen->getWindowStyle()->tab.border_width); 147 XSetWindowBorderWidth(m_display, win, m_screen->getWindowStyle()->tab.border_width);
148 XSetWindowBorder(m_display, win, m_screen->getWindowStyle()->tab.border_color.pixel()); 148 XSetWindowBorder(m_display, win, m_screen->getWindowStyle()->tab.border_color.pixel());
149 if (m_focus_pm) 149 if (m_focus_pm)
150 XSetWindowBackgroundPixmap(m_display, win, m_focus_pm); 150 XSetWindowBackgroundPixmap(m_display, win, m_focus_pm);
151 else 151 else
152 XSetWindowBackground(m_display, win, m_focus_pixel); 152 XSetWindowBackground(m_display, win, m_focus_pixel);
153} 153}
154 154
155 155
@@ -158,7 +158,7 @@ void IconBar::decorate(Window win) {
158// theme, pos and width 158// theme, pos and width
159//---------------------------------------- 159//----------------------------------------
160void IconBar::reconfigure() { 160void IconBar::reconfigure() {
161 repositionIcons(); 161 repositionIcons();
162 162
163} 163}
164//---------- exposeEvent ----------------- 164//---------- exposeEvent -----------------
@@ -166,66 +166,66 @@ void IconBar::reconfigure() {
166// just redraws all the icons 166// just redraws all the icons
167//---------------------------------------- 167//----------------------------------------
168void IconBar::exposeEvent(XExposeEvent *ee) { 168void IconBar::exposeEvent(XExposeEvent *ee) {
169 IconBarObj *obj=0; 169 IconBarObj *obj=0;
170 IconList::iterator it = m_iconlist.begin(); 170 IconList::iterator it = m_iconlist.begin();
171 IconList::iterator it_end = m_iconlist.end(); 171 IconList::iterator it_end = m_iconlist.end();
172 for (; it != it_end; ++it) { 172 for (; it != it_end; ++it) {
173 if ((*it)->getIconWin() == ee->window) { 173 if ((*it)->getIconWin() == ee->window) {
174 obj = (*it); 174 obj = (*it);
175 break; 175 break;
176 } 176 }
177 } 177 }
178 178
179 if (obj) { 179 if (obj) {
180 180
181 Window root; 181 Window root;
182 unsigned int width, height; 182 unsigned int width, height;
183 unsigned int border_width, depth; //not used 183 unsigned int border_width, depth; //not used
184 int x, y; 184 int x, y;
185 XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, 185 XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height,
186 &border_width, &depth); 186 &border_width, &depth);
187 187
188 //max width on every icon 188 //max width on every icon
189 unsigned int icon_width = width / m_iconlist.size(); 189 unsigned int icon_width = width / m_iconlist.size();
190 190
191 //load right size of theme 191 //load right size of theme
192 loadTheme(icon_width, height); 192 loadTheme(icon_width, height);
193 193
194 draw(obj, icon_width); 194 draw(obj, icon_width);
195 195
196 } 196 }
197} 197}
198 198
199//------------ repositionIcons ------------ 199//------------ repositionIcons ------------
200// Calculates and moves/resizes the icons 200// Calculates and moves/resizes the icons
201//----------------------------------------- 201//-----------------------------------------
202void IconBar::repositionIcons() { 202void IconBar::repositionIcons() {
203 if (m_iconlist.size() == 0) 203 if (m_iconlist.size() == 0)
204 return; 204 return;
205 205
206 Window root; 206 Window root;
207 unsigned int width, height; 207 unsigned int width, height;
208 unsigned int border_width, depth; //not used 208 unsigned int border_width, depth; //not used
209 int x, y; 209 int x, y;
210 XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, 210 XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height,
211 &border_width, &depth); 211 &border_width, &depth);
212 212
213 //max width on every icon 213 //max width on every icon
214 unsigned int icon_width = width / m_iconlist.size(); 214 unsigned int icon_width = width / m_iconlist.size();
215 215
216 //load right size of theme 216 //load right size of theme
217 loadTheme(icon_width, height); 217 loadTheme(icon_width, height);
218 218
219 IconList::iterator it = m_iconlist.begin(); 219 IconList::iterator it = m_iconlist.begin();
220 IconList::iterator it_end = m_iconlist.end(); 220 IconList::iterator it_end = m_iconlist.end();
221 for (x = 0; it != it_end; ++it, x += icon_width) { 221 for (x = 0; it != it_end; ++it, x += icon_width) {
222 Window iconwin = (*it)->getIconWin(); 222 Window iconwin = (*it)->getIconWin();
223 XMoveResizeWindow(m_display, iconwin, 223 XMoveResizeWindow(m_display, iconwin,
224 x, 0, 224 x, 0,
225 icon_width, height); 225 icon_width, height);
226 draw((*it), icon_width); 226 draw((*it), icon_width);
227 decorate(iconwin); 227 decorate(iconwin);
228 } 228 }
229 229
230} 230}
231 231
@@ -234,73 +234,73 @@ void IconBar::repositionIcons() {
234// returns the created X Window 234// returns the created X Window
235//---------------------------------------------- 235//----------------------------------------------
236Window IconBar::createIconWindow(FluxboxWindow *fluxboxwin, Window parent) { 236Window IconBar::createIconWindow(FluxboxWindow *fluxboxwin, Window parent) {
237 unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | 237 unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
238 CWColormap | CWOverrideRedirect | CWEventMask; 238 CWColormap | CWOverrideRedirect | CWEventMask;
239 XSetWindowAttributes attrib; 239 XSetWindowAttributes attrib;
240 attrib.background_pixmap = None; 240 attrib.background_pixmap = None;
241 attrib.background_pixel = attrib.border_pixel = 241 attrib.background_pixel = attrib.border_pixel =
242 fluxboxwin->getScreen()->getWindowStyle()->tab.border_color.pixel(); 242 fluxboxwin->getScreen()->getWindowStyle()->tab.border_color.pixel();
243 attrib.colormap = fluxboxwin->getScreen()->colormap(); 243 attrib.colormap = fluxboxwin->getScreen()->colormap();
244 attrib.override_redirect = True; 244 attrib.override_redirect = True;
245 attrib.event_mask = ButtonPressMask | ButtonReleaseMask | 245 attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
246 ButtonMotionMask | ExposureMask | EnterWindowMask; 246 ButtonMotionMask | ExposureMask | EnterWindowMask;
247 247
248 //create iconwindow 248 //create iconwindow
249 Window iconwin = XCreateWindow(m_display, parent, 0, 0, 1, 1, 0, 249 Window iconwin = XCreateWindow(m_display, parent, 0, 0, 1, 1, 0,
250 fluxboxwin->getScreen()->getDepth(), InputOutput, fluxboxwin->getScreen()->getVisual(), 250 fluxboxwin->getScreen()->getDepth(), InputOutput, fluxboxwin->getScreen()->getVisual(),
251 attrib_mask, &attrib); 251 attrib_mask, &attrib);
252 252
253 return iconwin; 253 return iconwin;
254} 254}
255 255
256//------------ draw ------------------ 256//------------ draw ------------------
257// Draws theme and string to Window w 257// Draws theme and string to Window w
258//------------------------------------ 258//------------------------------------
259void IconBar::draw(const IconBarObj * const obj, int width) const { 259void IconBar::draw(const IconBarObj * const obj, int width) const {
260 if (!obj) 260 if (!obj)
261 return; 261 return;
262 262
263 const FluxboxWindow * const fluxboxwin = obj->getFluxboxWin(); 263 const FluxboxWindow * const fluxboxwin = obj->getFluxboxWin();
264 Window iconwin = obj->getIconWin(); 264 Window iconwin = obj->getIconWin();
265 unsigned int title_text_w; 265 unsigned int title_text_w;
266 266
267 title_text_w = m_screen->getWindowStyle()->font.textWidth( 267 title_text_w = m_screen->getWindowStyle()->font.textWidth(
268 fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); 268 fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size());
269 int l = title_text_w; 269 int l = title_text_w;
270 unsigned int dlen=fluxboxwin->getIconTitle().size(); 270 unsigned int dlen=fluxboxwin->getIconTitle().size();
271 unsigned int bevel_w = m_screen->getBevelWidth(); 271 unsigned int bevel_w = m_screen->getBevelWidth();
272 int dx=bevel_w*2; 272 int dx=bevel_w*2;
273 273
274 for (; dlen >= 0; dlen--) { 274 for (; dlen >= 0; dlen--) {
275 l = m_screen->getWindowStyle()->tab.font.textWidth( 275 l = m_screen->getWindowStyle()->tab.font.textWidth(
276 fluxboxwin->getIconTitle().c_str(), dlen); 276 fluxboxwin->getIconTitle().c_str(), dlen);
277 l += (bevel_w * 4); 277 l += (bevel_w * 4);
278 278
279 if (l < width) 279 if (l < width)
280 break; 280 break;
281 } 281 }
282 282
283 switch (m_screen->getWindowStyle()->tab.justify) { 283 switch (m_screen->getWindowStyle()->tab.justify) {
284 case DrawUtil::Font::RIGHT: 284 case DrawUtil::Font::RIGHT:
285 dx += width - l; 285 dx += width - l;
286 break; 286 break;
287 case DrawUtil::Font::CENTER: 287 case DrawUtil::Font::CENTER:
288 dx += (width - l) / 2; 288 dx += (width - l) / 2;
289 break; 289 break;
290 default: 290 default:
291 break; 291 break;
292 } 292 }
293 293
294 //Draw title to m_iconwin 294 //Draw title to m_iconwin
295 295
296 XClearWindow(m_display, iconwin); 296 XClearWindow(m_display, iconwin);
297 297
298 m_screen->getWindowStyle()->tab.font.drawText( 298 m_screen->getWindowStyle()->tab.font.drawText(
299 iconwin, 299 iconwin,
300 m_screen->getScreenNumber(), 300 m_screen->getScreenNumber(),
301 m_screen->getWindowStyle()->tab.l_text_focus_gc, 301 m_screen->getWindowStyle()->tab.l_text_focus_gc,
302 fluxboxwin->getIconTitle().c_str(), dlen, 302 fluxboxwin->getIconTitle().c_str(), dlen,
303 dx, 1+ m_screen->getWindowStyle()->tab.font.ascent()); 303 dx, 1+ m_screen->getWindowStyle()->tab.font.ascent());
304 304
305} 305}
306 306
@@ -312,16 +312,16 @@ void IconBar::draw(const IconBarObj * const obj, int width) const {
312//---------------------------------- 312//----------------------------------
313FluxboxWindow *IconBar::findWindow(Window w) { 313FluxboxWindow *IconBar::findWindow(Window w) {
314 314
315 IconList::iterator it = m_iconlist.begin(); 315 IconList::iterator it = m_iconlist.begin();
316 IconList::iterator it_end = m_iconlist.end(); 316 IconList::iterator it_end = m_iconlist.end();
317 for (; it != it_end; ++it) { 317 for (; it != it_end; ++it) {
318 IconBarObj *tmp = (*it); 318 IconBarObj *tmp = (*it);
319 if (tmp) 319 if (tmp)
320 if (tmp->getIconWin() == w) 320 if (tmp->getIconWin() == w)
321 return tmp->getFluxboxWin(); 321 return tmp->getFluxboxWin();
322 } 322 }
323 323
324 return 0; 324 return 0;
325} 325}
326 326
327//----------- findIcon --------------- 327//----------- findIcon ---------------
@@ -332,28 +332,28 @@ FluxboxWindow *IconBar::findWindow(Window w) {
332 332
333IconBarObj *IconBar::findIcon(FluxboxWindow *fluxboxwin) { 333IconBarObj *IconBar::findIcon(FluxboxWindow *fluxboxwin) {
334 334
335 IconList::iterator it = m_iconlist.begin(); 335 IconList::iterator it = m_iconlist.begin();
336 IconList::iterator it_end = m_iconlist.end(); 336 IconList::iterator it_end = m_iconlist.end();
337 for (; it != it_end; ++it) { 337 for (; it != it_end; ++it) {
338 IconBarObj *tmp = (*it); 338 IconBarObj *tmp = (*it);
339 if (tmp) 339 if (tmp)
340 if (tmp->getFluxboxWin() == fluxboxwin) 340 if (tmp->getFluxboxWin() == fluxboxwin)
341 return tmp; 341 return tmp;
342 } 342 }
343 343
344 return 0; 344 return 0;
345} 345}
346 346
347const IconBarObj *IconBar::findIcon(const FluxboxWindow * const fluxboxwin) const { 347const IconBarObj *IconBar::findIcon(const FluxboxWindow * const fluxboxwin) const {
348 348
349 IconList::const_iterator it = m_iconlist.begin(); 349 IconList::const_iterator it = m_iconlist.begin();
350 IconList::const_iterator it_end = m_iconlist.end(); 350 IconList::const_iterator it_end = m_iconlist.end();
351 for (; it != it_end; ++it) { 351 for (; it != it_end; ++it) {
352 IconBarObj *tmp = (*it); 352 IconBarObj *tmp = (*it);
353 if (tmp) 353 if (tmp)
354 if (tmp->getFluxboxWin() == fluxboxwin) 354 if (tmp->getFluxboxWin() == fluxboxwin)
355 return tmp; 355 return tmp;
356 } 356 }
357 357
358 return 0; 358 return 0;
359} 359}