expose a preferredWidth of *Button's
Thomas Lübking thomas.luebking@gmail.com
5 files changed,
16 insertions(+),
0 deletions(-)
M
src/FbTk/Button.hh
→
src/FbTk/Button.hh
@@ -55,6 +55,8 @@ /// sets background color
virtual void setBackgroundColor(const Color &color); virtual bool setOrientation(FbTk::Orientation orient) { return orient == FbTk::ROT0; } + virtual unsigned int preferredWidth() const { return width(); } + /** @name eventhandlers */
M
src/FbTk/TextButton.cc
→
src/FbTk/TextButton.cc
@@ -112,6 +112,10 @@ unsigned int TextButton::textWidth() const {
return font().textWidth(text()); } +unsigned int TextButton::preferredWidth() const { + return m_bevel + m_left_padding + m_right_padding + textWidth(); +} + void TextButton::renderForeground(FbWindow &win, FbDrawable &drawable) { // (win should always be *this, no need to check) drawText(0, 0, &drawable);
M
src/FbTk/TextButton.hh
→
src/FbTk/TextButton.hh
@@ -62,6 +62,7 @@ FbTk::Orientation orientation() const { return m_orientation; }
unsigned int textWidth() const; int bevel() const { return m_bevel; } + virtual unsigned int preferredWidth() const; protected: virtual void drawText(int x_offset, int y_offset, FbDrawable *drawable_override);
M
src/IconButton.cc
→
src/IconButton.cc
@@ -279,3 +279,10 @@ }
return false; } +unsigned int IconButton::preferredWidth() const { + unsigned int r = TextButton::preferredWidth(); + if (m_icon_pixmap.drawable()) + r += m_icon_window.width() + 1; + return r; +} +
M
src/IconButton.hh
→
src/IconButton.hh
@@ -65,6 +65,8 @@ const Focusable &win() const { return m_win; }
bool setOrientation(FbTk::Orientation orient); + virtual unsigned int preferredWidth() const; + const FbTk::Signal<> &titleChanged() { return m_title_changed; } protected: