]> icculus.org git repositories - mikachu/openbox.git/blob - src/texture.hh
rename, remove bullshit. ya
[mikachu/openbox.git] / src / texture.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Texture.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
4 // Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef TEXTURE_HH
25 #define TEXTURE_HH
26
27 #include "color.hh"
28 #include "util.hh"
29 class BImageControl;
30
31 #include <string>
32
33 class BTexture {
34 public:
35   enum Type {
36     // No texture
37     NoTexture           = (0),    
38     // bevel options
39     Flat                = (1l<<0),
40     Sunken              = (1l<<1),
41     Raised              = (1l<<2),
42     // textures
43     Solid               = (1l<<3),
44     Gradient            = (1l<<4),
45     // gradients
46     Horizontal          = (1l<<5),
47     Vertical            = (1l<<6),
48     Diagonal            = (1l<<7),
49     CrossDiagonal       = (1l<<8),
50     Rectangle           = (1l<<9),
51     Pyramid             = (1l<<10),
52     PipeCross           = (1l<<11),
53     Elliptic            = (1l<<12),
54     // bevel types
55     Bevel1              = (1l<<13),
56     Bevel2              = (1l<<14),
57     // flat border
58     Border              = (1l<<15),
59     // inverted image
60     Invert              = (1l<<16),
61     // parent relative image
62     Parent_Relative     = (1l<<17),
63     // fake interlaced image
64     Interlaced          = (1l<<18)
65   };
66
67   BTexture(const BaseDisplay * const _display = 0,
68            unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
69   BTexture(const std::string &_description,
70            const BaseDisplay * const _display = 0,
71            unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
72
73   void setColor(const BColor &_color);
74   void setColorTo(const BColor &_colorTo) { ct = _colorTo; }
75   void setBorderColor(const BColor &_borderColor) { bc = _borderColor; }
76
77   const BColor &color(void) const { return c; }
78   const BColor &colorTo(void) const { return ct; }
79   const BColor &lightColor(void) const { return lc; }
80   const BColor &shadowColor(void) const { return sc; }
81   const BColor &borderColor(void) const { return bc; }
82
83   unsigned long texture(void) const { return t; }
84   void setTexture(const unsigned long _texture) { t  = _texture; }
85   void addTexture(const unsigned long _texture) { t |= _texture; }
86
87   BTexture &operator=(const BTexture &tt);
88   inline bool operator==(const BTexture &tt)
89   { return (c == tt.c && ct == tt.ct && lc == tt.lc &&
90             sc == tt.sc && t == tt.t); }
91   inline bool operator!=(const BTexture &tt)
92   { return (! operator==(tt)); }
93
94   const BaseDisplay *display(void) const { return dpy; }
95   unsigned int screen(void) const { return scrn; }
96   void setDisplay(const BaseDisplay * const _display,
97                   const unsigned int _screen);
98   void setImageControl(BImageControl* _ctrl) { ctrl = _ctrl; }
99   const std::string &description(void) const { return descr; }
100   void setDescription(const std::string &d);
101
102   Pixmap render(const unsigned int width, const unsigned int height,
103                 const Pixmap old = 0);
104
105 private:
106   BColor c, ct, lc, sc, bc;
107   std::string descr;
108   unsigned long t;
109   const BaseDisplay *dpy;
110   BImageControl *ctrl;
111   unsigned int scrn;
112 };
113
114 #endif // TEXTURE_HH