]> Dogcows Code - chaz/openbox/commitdiff
hardcoded renderstyle
authorDana Jansens <danakj@orodu.net>
Wed, 22 Jan 2003 22:20:26 +0000 (22:20 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 22 Jan 2003 22:20:26 +0000 (22:20 +0000)
otk/rendercolor.cc
otk/rendercolor.hh
otk/renderstyle.cc
otk/renderstyle.hh
otk/rendertexture.hh

index 568e2c7c752e547ed2426b819b0da9188ed8a76e..bfc8d46104356135af96b526528b72c985a12871 100644 (file)
@@ -33,17 +33,6 @@ RenderColor::RenderColor(int screen, unsigned char red,
   create();
 }
 
-RenderColor::RenderColor(int screen, unsigned char red,
-                        unsigned char green, unsigned char blue)
-  : _screen(screen),
-    _red(red),
-    _green(green),
-    _blue(blue),
-    _gc(0)
-{
-  create();
-}
-
 RenderColor::RenderColor(int screen, RGB rgb)
   : _screen(screen),
     _red(rgb.r),
index 6000646acd94c3bf6f703bf7f255f819109bcc4f..1152e767d5259a6e43fb0291cc1117670addd234 100644 (file)
@@ -11,6 +11,7 @@ extern "C" {
 namespace otk {
 
 class RenderColor {
+public:
   struct RGB {
     int r;
     int g;
@@ -22,7 +23,8 @@ class RenderColor {
         g((color >> 8) & 0xff),
         b((color) & 0xff) {}
   };
-  
+
+private:
   struct CacheItem {
     GC gc;
     int count;
index 8803c7797a786989c7ae493d609124eb520937ba..22622931de7cc8579fbc4b595ab0022f3229b92b 100644 (file)
@@ -5,17 +5,18 @@
 #endif // HAVE_CONFIG_H
 
 #include "renderstyle.hh"
-#include "rendercolor.hh"
-#include "rendertexture.hh"
 
 namespace otk {
 
-RenderStyle(int screen, const std::string &stylefile)
+RenderStyle::RenderStyle(int screen, const std::string &stylefile)
   : _screen(screen),
     _file(stylefile)
 {
-  _text_focus_color = new RenderColor(_screen, 0x272a2f);
-  _text_unfocus_color = new RenderColor(_screen, 0x676869);
+  _text_color_focus = new RenderColor(_screen, 0x272a2f);
+  _text_color_unfocus = new RenderColor(_screen, 0x676869);
+
+  _button_color_focus = new RenderColor(_screen, 0x96ba86);
+  _button_color_unfocus = new RenderColor(_screen, 0x676869);
 
   _frame_border_color = new RenderColor(_screen, 0x181f24);
   _frame_border_width = 1;
@@ -24,7 +25,8 @@ RenderStyle(int screen, const std::string &stylefile)
   _client_border_color_unfocus = new RenderColor(_screen, 0x555657);
   _client_border_width = 1;
 
-  _titlebar_focus = new RenderTexture(false,
+  _titlebar_focus = new RenderTexture(_screen,
+                                      false,
                                       RenderTexture::Flat,
                                       RenderTexture::Bevel1,
                                       false,
@@ -33,10 +35,9 @@ RenderStyle(int screen, const std::string &stylefile)
                                       0x858687,
                                       0x373a3f,
                                       0x0,
-                                      0x0,
-                                      0x0,
                                       0x0);
-  _titlebar_unfocus = new RenderTexture(false,
+  _titlebar_unfocus = new RenderTexture(_screen,
+                                        false,
                                         RenderTexture::Flat,
                                         RenderTexture::Bevel1,
                                         false,
@@ -45,11 +46,10 @@ RenderStyle(int screen, const std::string &stylefile)
                                         0x555657,
                                         0x171a1f,
                                         0x0,
-                                        0x0,
-                                        0x0,
                                         0x0);
 
-  _label_focus = new RenderTexture(false,
+  _label_focus = new RenderTexture(_screen,
+                                   false,
                                    RenderTexture::Flat,
                                    RenderTexture::Bevel1,
                                    true,
@@ -57,11 +57,10 @@ RenderStyle(int screen, const std::string &stylefile)
                                    false,
                                    0x858687,
                                    0x373a3f,
-                                   0x0,
-                                   0x0,
                                    0x181f24,
                                    0x0);
-  _label_unfocus = new RenderTexture(false,
+  _label_unfocus = new RenderTexture(_screen,
+                                     false,
                                      RenderTexture::Sunken,
                                      RenderTexture::Bevel1,
                                      false,
@@ -69,13 +68,12 @@ RenderStyle(int screen, const std::string &stylefile)
                                      false,
                                      0x555657,
                                      0x272a2f,
-                                     //XXX,
-                                     //XXX,
                                      0x0,
                                      0x0);
 
 
-  _handle_focus = new RenderTexture(false,
+  _handle_focus = new RenderTexture(_screen,
+                                    false,
                                     RenderTexture::Flat,
                                     RenderTexture::Bevel1,
                                     true,
@@ -84,10 +82,9 @@ RenderStyle(int screen, const std::string &stylefile)
                                     0x858687,
                                     0x373a3f,
                                     0x0,
-                                    0x0,
-                                    0x0,
                                     0x0);
-  _handle_unfocus = new RenderTexture(false,
+  _handle_unfocus = new RenderTexture(_screen,
+                                      false,
                                       RenderTexture::Flat,
                                       RenderTexture::Bevel1,
                                       false,
@@ -96,14 +93,112 @@ RenderStyle(int screen, const std::string &stylefile)
                                       0x555657,
                                       0x171a1f,
                                       0x0,
-                                      0x0,
-                                      0x0,
                                       0x0);
 
+  
+  _button_unpress_focus = new RenderTexture(_screen,
+                                            false,
+                                            RenderTexture::Raised,
+                                            RenderTexture::Bevel2,
+                                            false,
+                                            RenderTexture::CrossDiagonal,
+                                            false,
+                                            0x858687,
+                                            0x272a2f,
+                                            0x0,
+                                            0x0);
+  _button_unpress_unfocus = new RenderTexture(_screen,
+                                              false,
+                                              RenderTexture::Raised,
+                                              RenderTexture::Bevel2,
+                                              false,
+                                              RenderTexture::CrossDiagonal,
+                                              false,
+                                              0x555657,
+                                              0x171a1f,
+                                              0x0,
+                                              0x0);
+
+  _button_press_focus = new RenderTexture(_screen,
+                                          false,
+                                          RenderTexture::Sunken,
+                                          RenderTexture::Bevel2,
+                                          false,
+                                          RenderTexture::CrossDiagonal,
+                                          false,
+                                          0x96ba86,
+                                          0x5a724c,
+                                          0x0,
+                                          0x0);
+  _button_press_unfocus = new RenderTexture(_screen,
+                                            false,
+                                            RenderTexture::Sunken,
+                                            RenderTexture::Bevel2,
+                                            false,
+                                            RenderTexture::CrossDiagonal,
+                                            false,
+                                            0x555657,
+                                            0x171a1f,
+                                            0x0,
+                                            0x0);
+
+  _grip_focus = new RenderTexture(_screen,
+                                  false,
+                                  RenderTexture::Flat,
+                                  RenderTexture::Bevel1,
+                                  false,
+                                  RenderTexture::Vertical,
+                                  false,
+                                  0x96ba86,
+                                  0x5a724c,
+                                  0x0,
+                                  0x0);
+  _grip_unfocus = new RenderTexture(_screen,
+                                    false,
+                                    RenderTexture::Flat,
+                                    RenderTexture::Bevel1,
+                                    false,
+                                    RenderTexture::Vertical,
+                                    false,
+                                    0x555657,
+                                    0x171a1f,
+                                    0x0,
+                                    0x0);
+
+  _label_font = new Font(_screen, "Arial,Sans-9:bold", true, 1, 0x40);
 }
 
-virtual ~RenderStyle()
+RenderStyle::~RenderStyle()
 {
+  delete _text_color_focus;
+  delete _text_color_unfocus;
+
+  delete _button_color_focus;
+  delete _button_color_unfocus;
+
+  delete _frame_border_color;
+
+  delete _client_border_color_focus; 
+  delete _client_border_color_unfocus;
+  delete _titlebar_focus;
+  delete _titlebar_unfocus;
+
+  delete _label_focus;
+  delete _label_unfocus;
+
+  delete _handle_focus;
+  delete _handle_unfocus;
+
+  delete _button_unpress_focus;
+  delete _button_unpress_unfocus;
+  delete _button_press_focus;
+  delete _button_press_unfocus;
+
+  delete _grip_focus;
+  delete _grip_unfocus;
+
+  delete _label_font;
 }
 
 }
index 0ecb8e4d974176318ce34814932a689fa9288d71..c23d45aada0c07b9930b60cc0745978cc052aa58 100644 (file)
@@ -3,6 +3,8 @@
 #define __renderstyle_hh
 
 #include "rendertexture.hh"
+#include "rendercolor.hh"
+#include "font.hh"
 
 #include <string>
 
@@ -20,11 +22,15 @@ private:
   int _screen;
   std::string _file;
   
-  RenderColor *_text_focus_color;
-  RenderColor *_text_unfocus_color;
+  RenderColor *_text_color_focus;
+  RenderColor *_text_color_unfocus;
+
+  RenderColor *_button_color_focus;
+  RenderColor *_button_color_unfocus;
 
   RenderColor *_frame_border_color;
-  int _frame_border_wirth;
+  int _frame_border_width;
+
   RenderColor *_client_border_color_focus; 
   RenderColor *_client_border_color_unfocus;
   int _client_border_width;
@@ -59,8 +65,13 @@ public:
   inline RenderColor *textFocusColor() const { return _text_color_focus; }
   inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }
 
+  inline RenderColor *buttonFocusColor() const { return _button_color_focus; }
+  inline RenderColor *buttonUnfocusColor() const
+    { return _button_color_unfocus; }
+
   inline RenderColor *frameBorderColor() const { return _frame_border_color; }
-  inline int frameBorderWidth() const { return _frame_border_wirth; }
+  inline int frameBorderWidth() const { return _frame_border_width; }
+
   inline RenderColor *clientBorderFocusColor() const
     { return _client_border_color_focus; }
   inline RenderColor *clientBorderUnfocusColor() const
@@ -75,8 +86,9 @@ public:
   inline RenderTexture *labelFocusBackground() const { return _label_focus; }
   inline RenderTexture *labelUnfocusBackground() const { return _label_unfocus;}
 
-  inline RenderTexture *handleFocusBackground() const { _handle_focus; }
-  inline RenderTexture *handleUnfocusBackground() const { _handle_unfocus; }
+  inline RenderTexture *handleFocusBackground() const { return _handle_focus; }
+  inline RenderTexture *handleUnfocusBackground() const
+    { return _handle_unfocus; }
 
   inline RenderTexture *buttonUnpressFocusBackground() const
     { return _button_unpress_focus; }
index 6afd6209d5ab8b655cc03aa3612a9816e48a5922..3a80a45ee8f36072fc0ee49f4c6dd072c120b047 100644 (file)
@@ -31,6 +31,8 @@ public:
   };
 
 private:
+  int _screen;
+  
   //! If true, the texture is not rendered at all, so all options are ignored
   bool _parent_relative;
   //! The relief type of the texture
@@ -65,27 +67,47 @@ private:
   const RenderColor *_interlace_color;
 
 public:
-  RenderTexture(bool parent_relative, ReliefType relief, BevelType bevel,
+  RenderTexture(int screen,
+                bool parent_relative, ReliefType relief, BevelType bevel,
                 bool border, GradientType gradient, bool interlaced,
                 const RenderColor::RGB &color,
                 const RenderColor::RGB &secondary_color,
-                const RenderColor::RGB &bevel_dark_color,
-                const RenderColor::RGB &bevel_light_color,
                 const RenderColor::RGB &border_color,
                 const RenderColor::RGB &interlace_color)
-    : _parent_relative(parent_relative),
+    : _screen(screen),
+      _parent_relative(parent_relative),
       _relief(relief),
       _bevel(bevel),
       _border(border),
       _gradient(gradient),
       _interlaced(interlaced),
-      _color(new RenderColor(color)),
-      _secondary_color(new RenderColor(secondary_color)),
-      _bevel_dark_color(new RenderColor(bevel_dark_color)),
-      _bevel_light_color(new RenderColor(bevel_light_color)),
-      _border_color(new RenderColor(border_color)),
-      _interlace_color(new RenderColor(interlace_color))
+      _color(new RenderColor(screen, color)),
+      _secondary_color(new RenderColor(screen, secondary_color)),
+      _bevel_dark_color(0),
+      _bevel_light_color(0),
+      _border_color(new RenderColor(screen, border_color)),
+      _interlace_color(new RenderColor(screen, interlace_color))
   {
+    if (_relief != Flat) {
+      unsigned char r, g, b;
+
+      // calculate the light bevel color
+      r = _color->red() + _color->red() / 2;
+      g = _color->green() + _color->green() / 2;
+      b = _color->blue() + _color->blue() / 2;
+      // watch for wraparound
+      if (r < _color->red()) r = 0xff;
+      if (g < _color->green()) g = 0xff;
+      if (b < _color->blue()) b = 0xff;
+      _bevel_dark_color = new RenderColor(screen, r, g, b);
+      
+      // calculate the dark bevel color
+      r = _color->red() / 4 + _color->red() / 2;
+      g = _color->green() / 4 + _color->green() / 2;
+      b = _color->blue() / 4 + _color->blue() / 2;
+      _bevel_light_color = new RenderColor(screen, r, g, b);
+    }
+    
     assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
     assert(!_border || _border_color);
     assert(!_interlaced || _interlace_color);
@@ -95,8 +117,8 @@ public:
   virtual ~RenderTexture() {
     delete _color;
     delete _secondary_color;
-    delete _bevel_dark_color;
-    delete _bevel_light_color;
+    if (_bevel_dark_color) delete _bevel_dark_color;
+     if (_bevel_dark_color) delete _bevel_light_color;
     delete _border_color;
     delete _interlace_color;
   }
This page took 0.036334 seconds and 4 git commands to generate.