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