aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-04-15 16:41:11 (GMT)
committersimonb <simonb>2006-04-15 16:41:11 (GMT)
commit7c7908443302fc66929e19804f0fbd655d4c7f34 (patch)
tree6839a7379b4cc514a5a4ce20ebf0a53123d20ba2 /src/IconButton.cc
parent83a3429c395299b5acb85a3f372091037fe12603 (diff)
downloadfluxbox-7c7908443302fc66929e19804f0fbd655d4c7f34.zip
fluxbox-7c7908443302fc66929e19804f0fbd655d4c7f34.tar.bz2
implement vertical toolbar placement options
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 770944f..ab53196 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -39,7 +39,6 @@
39#include "FbTk/RefCount.hh" 39#include "FbTk/RefCount.hh"
40#include "FbTk/Menu.hh" 40#include "FbTk/Menu.hh"
41 41
42
43#ifdef HAVE_CONFIG_H 42#ifdef HAVE_CONFIG_H
44#include "config.h" 43#include "config.h"
45#endif // HAVE_CONFIG_H 44#endif // HAVE_CONFIG_H
@@ -241,13 +240,30 @@ void IconButton::update(FbTk::Subject *subj) {
241 if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) { 240 if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) {
242 // setup icon window 241 // setup icon window
243 m_icon_window.show(); 242 m_icon_window.show();
244 int new_height = height() - 2*m_icon_window.y(); // equally padded 243 unsigned int w = width();
245 int new_width = new_height; 244 unsigned int h = height();
246 m_icon_window.resize((new_width>0) ? new_width : 1, (new_height>0) ? new_height : 1); 245 FbTk::translateSize(orientation(), w, h);
246 int iconx = 1, icony = 1;
247 unsigned int neww = w, newh = h;
248 if (newh > 2*icony)
249 newh -= 2*icony;
250 else
251 newh = 1;
252 neww = newh;
253
254 FbTk::translateCoords(orientation(), iconx, icony, w, h);
255 FbTk::translatePosition(orientation(), iconx, icony, neww, newh, 0);
256
257 neww = newh;
258 m_icon_window.moveResize(iconx, icony, neww, newh);
247 259
248 m_icon_pixmap.copy(hints->icon_pixmap, DefaultDepth(display, screen), screen); 260 m_icon_pixmap.copy(hints->icon_pixmap, DefaultDepth(display, screen), screen);
249 m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height()); 261 m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height());
250 262
263 // rotate the icon or not?? lets go not for now, and see what they say...
264 // need to rotate mask too if we do do this
265 m_icon_pixmap.rotate(orientation());
266
251 m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable()); 267 m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable());
252 } else { 268 } else {
253 // no icon pixmap 269 // no icon pixmap
@@ -259,6 +275,7 @@ void IconButton::update(FbTk::Subject *subj) {
259 if(m_use_pixmap && (hints->flags & IconMaskHint)) { 275 if(m_use_pixmap && (hints->flags & IconMaskHint)) {
260 m_icon_mask.copy(hints->icon_mask, 0, 0); 276 m_icon_mask.copy(hints->icon_mask, 0, 0);
261 m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height()); 277 m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height());
278 m_icon_mask.rotate(orientation());
262 } else 279 } else
263 m_icon_mask = 0; 280 m_icon_mask = 0;
264 281
@@ -304,4 +321,20 @@ void IconButton::drawText(int x, int y, FbTk::FbDrawable *drawable) {
304 FbTk::TextButton::drawText(1, y, drawable); 321 FbTk::TextButton::drawText(1, y, drawable);
305} 322}
306 323
324bool IconButton::setOrientation(FbTk::Orientation orient) {
325 if (orientation() == orient)
326 return true;
327
328 if (FbTk::TextButton::setOrientation(orient)) {
329 int iconx = 1, icony = 1;
330 unsigned int tmpw = width(), tmph = height();
331 FbTk::translateSize(orient, tmpw, tmph);
332 FbTk::translateCoords(orient, iconx, icony, tmpw, tmph);
333 FbTk::translatePosition(orient, iconx, icony, m_icon_window.width(), m_icon_window.height(), 0);
334 m_icon_window.move(iconx, icony);
335 return true;
336 } else {
337 return false;
338 }
339}
307 340