setUnfocusTexture(style->labelUnfocusBackground());
}
+void FocusLabel::fitString(const std::string &str)
+{
+ const Font *ft = style()->labelFont();
+ fitSize(ft->measureString(str), ft->height());
+}
+
+void FocusLabel::fitSize(int w, int h)
+{
+ unsigned int sidemargin = style()->bevelWidth() * 2;
+ resize(w + sidemargin * 2, h);
+}
+
+void FocusLabel::update()
+{
+ if (_dirty) {
+ int w = _rect.width(), h = _rect.height();
+ const Font *ft = style()->labelFont();
+ unsigned int sidemargin = style()->bevelWidth() * 2;
+ if (!_fixed_width)
+ w = ft->measureString(_text) + sidemargin * 2;
+ if (!_fixed_height)
+ h = ft->height();
+ internalResize(w, h);
+ }
+ FocusWidget::update();
+}
+
void FocusLabel::renderForeground()
{
- otk::Widget::renderForeground();
+ FocusWidget::renderForeground();
const Font *ft = style()->labelFont();
RenderColor *text_color = (isFocused() ? style()->textFocusColor()
virtual void renderForeground();
+ virtual void update();
+
+ void fitString(const std::string &str);
+ void fitSize(int w, int h);
+
virtual void setStyle(RenderStyle *style);
private:
setTexture(style->labelUnfocusBackground());
}
+void Label::fitString(const std::string &str)
+{
+ const Font *ft = style()->labelFont();
+ fitSize(ft->measureString(str), ft->height());
+}
+
+void Label::fitSize(int w, int h)
+{
+ unsigned int sidemargin = style()->bevelWidth() * 2;
+ resize(w + sidemargin * 2, h);
+}
+
+void Label::update()
+{
+ if (_dirty) {
+ int w = _rect.width(), h = _rect.height();
+ const Font *ft = style()->labelFont();
+ unsigned int sidemargin = style()->bevelWidth() * 2;
+ if (!_fixed_width)
+ w = ft->measureString(_text) + sidemargin * 2;
+ if (!_fixed_height)
+ h = ft->height();
+ internalResize(w, h);
+ }
+ Widget::update();
+}
+
void Label::renderForeground(void)
{
- otk::Widget::renderForeground();
+ Widget::renderForeground();
const Font *ft = style()->labelFont();
unsigned int sidemargin = style()->bevelWidth() * 2;
virtual void renderForeground(void);
+ virtual void update();
+
+ void fitString(const std::string &str);
+ void fitSize(int w, int h);
+
virtual void setStyle(RenderStyle *style);
private:
t = t[:24] + "..." + t[-24:]
titles.append(t)
_list_windows.append(c)
- l = font.measureString(t) + 10 # add margin
+ l = font.measureString(t)
if l > longest: longest = l
if len(titles) > 1:
for t in titles:
w = otk.FocusLabel(_list_widget)
- w.resize(longest, height)
+ w.fitSize(longest, height)
w.setText(t)
w.unfocus()
_list_labels.append(w)
//! Returns the window's stacking layer
inline StackLayer layer() const { return _layer; }
+ //! Returns the logical size of the window
+ /*!
+ The "logical" size of the window is refers to the user's perception of the
+ size of the window, and is the value that should be displayed to the user.
+ For example, with xterms, this value it the number of characters being
+ displayed in the terminal, instead of the number of pixels.
+ */
+ const otk::Point &logicalSize() const { return _logical_size; }
+
//! Applies the states requested when the window mapped
/*!
This should be called only once, during the window mapping process. It