]> Dogcows Code - chaz/openbox/blobdiff - otk/rendertexture.hh
load and set the titles justification
[chaz/openbox] / otk / rendertexture.hh
index df38ddf679229415f2d5901876ccdd52a78dc87e..54fbd9c26d3ed480ed9b67519cc3b9077b0f4671 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,31 +67,64 @@ 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 *color, const RenderColor *secondary_color,
-                const RenderColor *bevel_dark_color,
-                const RenderColor *bevel_light_color,
-                const RenderColor *border_color,
-                const RenderColor *interlace_color)
-    : _parent_relative(parent_relative),
+                const RGB &color,
+                const RGB &secondary_color,
+                const RGB &border_color,
+                const RGB &interlace_color)
+    : _screen(screen),
+      _parent_relative(parent_relative),
       _relief(relief),
       _bevel(bevel),
       _border(border),
       _gradient(gradient),
       _interlaced(interlaced),
-      _color(color),
-      _secondary_color(secondary_color),
-      _bevel_dark_color(bevel_dark_color),
-      _bevel_light_color(bevel_light_color),
-      _border_color(border_color),
-      _interlace_color(interlace_color)
-    {
-      assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
-      assert(!_border || _border_color);
-      assert(!_interlaced || _interlace_color);
-      assert(_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);
+    assert(_color);
+    assert(_secondary_color);
+    assert(_border_color);
+    assert(_interlace_color);
+  }
+  
+  virtual ~RenderTexture() {
+    delete _color;
+    delete _secondary_color;
+    if (_bevel_dark_color) delete _bevel_dark_color;
+    if (_bevel_dark_color) delete _bevel_light_color;
+    delete _border_color;
+    delete _interlace_color;
+  }
 
   //! If true, the texture is not rendered at all, so all options are ignored
   inline bool parentRelative() const { return _parent_relative; }
This page took 0.021911 seconds and 4 git commands to generate.