expose a preferredWidth of *Button's
This commit is contained in:
parent
59d9b0703b
commit
cc80230bd8
5 changed files with 16 additions and 0 deletions
|
@ -55,6 +55,8 @@ public:
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
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);
|
||||
|
|
|
@ -279,3 +279,10 @@ bool IconButton::setOrientation(FbTk::Orientation orient) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
bool setOrientation(FbTk::Orientation orient);
|
||||
|
||||
virtual unsigned int preferredWidth() const;
|
||||
|
||||
const FbTk::Signal<> &titleChanged() { return m_title_changed; }
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue