all repos — fluxbox @ cc80230bd85dbaf1036b4cf37259d3146229fb00

custom fork of the fluxbox windowmanager

expose a preferredWidth of *Button's
Thomas Lübking thomas.luebking@gmail.com
commit

cc80230bd85dbaf1036b4cf37259d3146229fb00

parent

59d9b0703ba8efb24893528f2eb9c84aaa8f5f83

5 files changed, 16 insertions(+), 0 deletions(-)

jump to
M src/FbTk/Button.hhsrc/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.ccsrc/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.hhsrc/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.ccsrc/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.hhsrc/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: