aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Button.hh2
-rw-r--r--src/FbTk/TextButton.cc4
-rw-r--r--src/FbTk/TextButton.hh1
-rw-r--r--src/IconButton.cc7
-rw-r--r--src/IconButton.hh2
5 files changed, 16 insertions, 0 deletions
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
index 1f65799..c3276a6 100644
--- a/src/FbTk/Button.hh
+++ b/src/FbTk/Button.hh
@@ -55,6 +55,8 @@ public:
55 virtual void setBackgroundColor(const Color &color); 55 virtual void setBackgroundColor(const Color &color);
56 virtual bool setOrientation(FbTk::Orientation orient) { return orient == FbTk::ROT0; } 56 virtual bool setOrientation(FbTk::Orientation orient) { return orient == FbTk::ROT0; }
57 57
58 virtual unsigned int preferredWidth() const { return width(); }
59
58 /** 60 /**
59 @name eventhandlers 61 @name eventhandlers
60 */ 62 */
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 4d05ecd..0cc1b51 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -112,6 +112,10 @@ unsigned int TextButton::textWidth() const {
112 return font().textWidth(text()); 112 return font().textWidth(text());
113} 113}
114 114
115unsigned int TextButton::preferredWidth() const {
116 return m_bevel + m_left_padding + m_right_padding + textWidth();
117}
118
115void TextButton::renderForeground(FbWindow &win, FbDrawable &drawable) { 119void TextButton::renderForeground(FbWindow &win, FbDrawable &drawable) {
116 // (win should always be *this, no need to check) 120 // (win should always be *this, no need to check)
117 drawText(0, 0, &drawable); 121 drawText(0, 0, &drawable);
diff --git a/src/FbTk/TextButton.hh b/src/FbTk/TextButton.hh
index fe92cc3..90c7c3d 100644
--- a/src/FbTk/TextButton.hh
+++ b/src/FbTk/TextButton.hh
@@ -62,6 +62,7 @@ public:
62 unsigned int textWidth() const; 62 unsigned int textWidth() const;
63 int bevel() const { return m_bevel; } 63 int bevel() const { return m_bevel; }
64 64
65 virtual unsigned int preferredWidth() const;
65 66
66protected: 67protected:
67 virtual void drawText(int x_offset, int y_offset, FbDrawable *drawable_override); 68 virtual void drawText(int x_offset, int y_offset, FbDrawable *drawable_override);
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 4997365..4b0b423 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -279,3 +279,10 @@ bool IconButton::setOrientation(FbTk::Orientation orient) {
279 return false; 279 return false;
280} 280}
281 281
282unsigned int IconButton::preferredWidth() const {
283 unsigned int r = TextButton::preferredWidth();
284 if (m_icon_pixmap.drawable())
285 r += m_icon_window.width() + 1;
286 return r;
287}
288
diff --git a/src/IconButton.hh b/src/IconButton.hh
index 876cfe2..d3cb3d8 100644
--- a/src/IconButton.hh
+++ b/src/IconButton.hh
@@ -65,6 +65,8 @@ public:
65 65
66 bool setOrientation(FbTk::Orientation orient); 66 bool setOrientation(FbTk::Orientation orient);
67 67
68 virtual unsigned int preferredWidth() const;
69
68 const FbTk::Signal<> &titleChanged() { return m_title_changed; } 70 const FbTk::Signal<> &titleChanged() { return m_title_changed; }
69 71
70protected: 72protected: