diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-02-08 08:13:02 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-02-08 08:13:02 +0000 |
| commit | f51f1c775f3f09cf184ead323d111985c888d52e (patch) | |
| tree | 22bfcdb158b450c2f7e971b206f37e5c873d79e3 /otk | |
| parent | e72d9d90f9f29809dead53968395c2c8ae5470f0 (diff) | |
stacked cycling menu works now. add a highlighted flag to otk widgets
Diffstat (limited to 'otk')
| -rw-r--r-- | otk/button.cc | 13 | ||||
| -rw-r--r-- | otk/button.hh | 4 | ||||
| -rw-r--r-- | otk/label.cc | 19 | ||||
| -rw-r--r-- | otk/label.hh | 5 |
4 files changed, 25 insertions, 16 deletions
diff --git a/otk/button.cc b/otk/button.cc index 8d63ed0c..1e128784 100644 --- a/otk/button.cc +++ b/otk/button.cc @@ -9,8 +9,10 @@ namespace otk { Button::Button(Widget *parent) - : Label(parent), _default(false), _pressed(false) + : Label(parent), + _pressed(false) { + setHighlighted(false); setHorizontalJustify(RenderStyle::CenterJustify); setVerticalJustify(RenderStyle::CenterJustify); styleChanged(*RenderStyle::style(screen())); @@ -53,16 +55,9 @@ void Button::buttonReleaseHandler(const XButtonEvent &e) release(e.button); } -void Button::setDefault(bool d) -{ - _default = d; - styleChanged(*RenderStyle::style(screen())); - refresh(); -} - void Button::styleChanged(const RenderStyle &style) { - if (_default) { + if (isHighlighted()) { if (_pressed) _texture = style.buttonPressFocusBackground(); else diff --git a/otk/button.hh b/otk/button.hh index 53d08a86..09fc0d6b 100644 --- a/otk/button.hh +++ b/otk/button.hh @@ -12,9 +12,6 @@ public: Button(Widget *parent); virtual ~Button(); - virtual inline bool isDefault() const { return _default; } - virtual void setDefault(bool d); - virtual inline bool isPressed() const { return _pressed; } virtual void press(unsigned int mouse_button); @@ -26,7 +23,6 @@ public: virtual void styleChanged(const RenderStyle &style); private: - bool _default; bool _pressed; unsigned int _mouse_button; }; diff --git a/otk/label.cc b/otk/label.cc index 0c18b5d0..c56f91f8 100644 --- a/otk/label.cc +++ b/otk/label.cc @@ -16,7 +16,8 @@ Label::Label(Widget *parent) : Widget(parent), _text(""), _justify_horz(RenderStyle::LeftTopJustify), - _justify_vert(RenderStyle::LeftTopJustify) + _justify_vert(RenderStyle::LeftTopJustify), + _highlight(true) { styleChanged(*RenderStyle::style(screen())); } @@ -37,6 +38,13 @@ void Label::setVerticalJustify(RenderStyle::Justify j) refresh(); } +void Label::setHighlighted(bool h) +{ + _highlight = h; + styleChanged(*RenderStyle::style(screen())); + refresh(); +} + void Label::setText(const ustring &text) { bool utf = text.utf8(); @@ -77,8 +85,13 @@ void Label::calcDefaultSizes() void Label::styleChanged(const RenderStyle &style) { - _texture = style.labelFocusBackground(); - _forecolor = style.textFocusColor(); + if (_highlight) { + _texture = style.labelFocusBackground(); + _forecolor = style.textFocusColor(); + } else { + _texture = style.labelUnfocusBackground(); + _forecolor = style.textUnfocusColor(); + } _font = style.labelFont(); Widget::styleChanged(style); calcDefaultSizes(); diff --git a/otk/label.hh b/otk/label.hh index 1b31ae79..b3e9c166 100644 --- a/otk/label.hh +++ b/otk/label.hh @@ -20,6 +20,9 @@ public: inline const ustring& getText(void) const { return _text; } void setText(const ustring &text); + virtual inline bool isHighlighted() const { return _highlight; } + virtual void setHighlighted(bool h); + RenderStyle::Justify horizontalJustify() const { return _justify_horz; } virtual void setHorizontalJustify(RenderStyle::Justify j); RenderStyle::Justify verticalJustify() const { return _justify_vert; } @@ -53,6 +56,8 @@ private: RenderStyle::Justify _justify_vert; //! The drawing offset for the text int _drawx; + //! If the widget is highlighted or not + bool _highlight; }; } |
