]> icculus.org git repositories - mikachu/openbox.git/blob - otk/texture.hh
change how the widgets' _dirty flag works so that all inheritence levels of the widge...
[mikachu/openbox.git] / otk / texture.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef TEXTURE_HH
3 #define TEXTURE_HH
4
5 #include "color.hh"
6 #include "util.hh"
7
8 #include <string>
9
10 namespace otk {
11
12 class BImageControl;
13
14 class BTexture {
15 public:
16   enum Type {
17     // No texture
18     NoTexture           = (0),    
19     // bevel options
20     Flat                = (1l<<0),
21     Sunken              = (1l<<1),
22     Raised              = (1l<<2),
23     // textures
24     Solid               = (1l<<3),
25     Gradient            = (1l<<4),
26     // gradients
27     Horizontal          = (1l<<5),
28     Vertical            = (1l<<6),
29     Diagonal            = (1l<<7),
30     CrossDiagonal       = (1l<<8),
31     Rectangle           = (1l<<9),
32     Pyramid             = (1l<<10),
33     PipeCross           = (1l<<11),
34     Elliptic            = (1l<<12),
35     // bevel types
36     Bevel1              = (1l<<13),
37     Bevel2              = (1l<<14),
38     // flat border
39     Border              = (1l<<15),
40     // inverted image
41     Invert              = (1l<<16),
42     // parent relative image
43     Parent_Relative     = (1l<<17),
44     // fake interlaced image
45     Interlaced          = (1l<<18)
46   };
47
48   BTexture(unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
49   BTexture(const std::string &_description,
50            unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
51
52   void setColor(const BColor &_color);
53   void setColorTo(const BColor &_colorTo) { ct = _colorTo; }
54   void setBorderColor(const BColor &_borderColor) { bc = _borderColor; }
55
56   const BColor &color(void) const { return c; }
57   const BColor &colorTo(void) const { return ct; }
58   const BColor &lightColor(void) const { return lc; }
59   const BColor &shadowColor(void) const { return sc; }
60   const BColor &borderColor(void) const { return bc; }
61
62   unsigned long texture(void) const { return t; }
63   void setTexture(const unsigned long _texture) { t  = _texture; }
64   void addTexture(const unsigned long _texture) { t |= _texture; }
65
66   BTexture &operator=(const BTexture &tt);
67   inline bool operator==(const BTexture &tt)
68   { return (c == tt.c && ct == tt.ct && lc == tt.lc &&
69             sc == tt.sc && t == tt.t); }
70   inline bool operator!=(const BTexture &tt)
71   { return (! operator==(tt)); }
72
73   unsigned int screen(void) const { return scrn; }
74   void setScreen(const unsigned int _screen);
75   void setImageControl(BImageControl* _ctrl) { ctrl = _ctrl; }
76   const std::string &description(void) const { return descr; }
77   void setDescription(const std::string &d);
78
79   Pixmap render(const unsigned int width, const unsigned int height,
80                 const Pixmap old = 0);
81
82 private:
83   BColor c, ct, lc, sc, bc;
84   std::string descr;
85   unsigned long t;
86   BImageControl *ctrl;
87   unsigned int scrn;
88 };
89
90 }
91
92 #endif // TEXTURE_HH