]> Dogcows Code - chaz/openbox/commitdiff
stacked cycling menu works now. add a highlighted flag to otk widgets
authorDana Jansens <danakj@orodu.net>
Sat, 8 Feb 2003 08:13:02 +0000 (08:13 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 8 Feb 2003 08:13:02 +0000 (08:13 +0000)
otk/button.cc
otk/button.hh
otk/label.cc
otk/label.hh
scripts/stackedcycle.py

index 8d63ed0c3b71a6268b353904d31040a668907ddd..1e128784f91aa4811a2efb3b3956cbce03c58e87 100644 (file)
@@ -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
index 53d08a8645a145d11d4cfac95fc0a61e212d59b2..09fc0d6b6494aa28bf9c36e8b1379b2f88e3a7ad 100644 (file)
@@ -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;
 };
index 0c18b5d03cc001616f4d4a87c8ef65a9cd218713..c56f91f8022aebfbc7920e48d76b3c3a440f187a 100644 (file)
@@ -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();
index 1b31ae79a5b91703096c71f80e295f9241bbb095..b3e9c16655256dcbfc9fa682c3446426a7205be7 100644 (file)
@@ -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;
 };
 
 }
index fc086aad788c7deaa077bb3846f08add29d9f639..c951f6b30a92d7f53a7add2c709bedce41f43bef 100644 (file)
@@ -112,10 +112,10 @@ class _cycledata:
             w = otk.Label(self.widget)
             if current and c.window() == current.window():
                 self.menupos = i
-                #w.focus() XXX
+                w.setHighlighted(1)
                 pass
             else:
-                #w.unfocus() XXX
+                w.setHighlighted(0)
                 pass
             self.menuwidgets.append(w)
 
@@ -192,7 +192,7 @@ class _cycledata:
 
         if not len(self.clients): return # don't both doing anything
         
-        #self.menuwidgets[self.menupos].unfocus() XXX
+        self.menuwidgets[self.menupos].setHighlighted(0)
         if forward:
             self.menupos += 1
         else:
@@ -200,7 +200,7 @@ class _cycledata:
         # wrap around
         if self.menupos < 0: self.menupos = len(self.clients) - 1
         elif self.menupos >= len(self.clients): self.menupos = 0
-        #self.menuwidgets[self.menupos].focus() XXX
+        self.menuwidgets[self.menupos].setHighlighted(1)
         if ACTIVATE_WHILE_CYCLING:
             self.activatetarget(0) # activate, but dont deiconify/unshade/raise
 
This page took 0.034874 seconds and 4 git commands to generate.