diff options
Diffstat (limited to 'src/FbTk/GContext.hh')
-rw-r--r-- | src/FbTk/GContext.hh | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/FbTk/GContext.hh b/src/FbTk/GContext.hh new file mode 100644 index 0000000..5112b22 --- /dev/null +++ b/src/FbTk/GContext.hh | |||
@@ -0,0 +1,114 @@ | |||
1 | // GContext.hh for FbTk - fluxbox toolkit | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | // $Id: GContext.hh,v 1.8 2004/01/11 12:53:46 fluxgen Exp $ | ||
23 | |||
24 | #ifndef FBTK_GCONTEXT_HH | ||
25 | #define FBTK_GCONTEXT_HH | ||
26 | |||
27 | #include "Color.hh" | ||
28 | //#include "FbPixmap.hh" | ||
29 | |||
30 | #include <X11/Xlib.h> | ||
31 | |||
32 | namespace FbTk { | ||
33 | |||
34 | class FbDrawable; | ||
35 | class Font; | ||
36 | |||
37 | /// wrapper for X GC | ||
38 | class GContext { | ||
39 | public: | ||
40 | /// for FbTk drawable | ||
41 | explicit GContext(const FbTk::FbDrawable &drawable); | ||
42 | /// for X drawable | ||
43 | explicit GContext(Drawable drawable); | ||
44 | GContext(Drawable d, const FbTk::GContext &gc); | ||
45 | virtual ~GContext(); | ||
46 | |||
47 | inline void setForeground(const FbTk::Color &color) { | ||
48 | setForeground(color.pixel()); | ||
49 | } | ||
50 | |||
51 | inline void setForeground(long pixel_value) { | ||
52 | XSetForeground(m_display, m_gc, | ||
53 | pixel_value); | ||
54 | } | ||
55 | |||
56 | inline void setBackground(const FbTk::Color &color) { | ||
57 | setBackground(color.pixel()); | ||
58 | } | ||
59 | |||
60 | inline void setBackground(long pixel_value) { | ||
61 | XSetBackground(m_display, m_gc, pixel_value); | ||
62 | } | ||
63 | |||
64 | /// not implemented | ||
65 | inline void setFont(const FbTk::Font &) {} | ||
66 | |||
67 | /// set font id | ||
68 | inline void setFont(int fid) { | ||
69 | XSetFont(m_display, m_gc, fid); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | inline void setClipMask(const FbTk::FbPixmap &mask) { | ||
74 | XSetClipMask(m_display, m_gc, mask.drawable()); | ||
75 | } | ||
76 | */ | ||
77 | inline void setClipOrigin(int x, int y) { | ||
78 | XSetClipOrigin(m_display, m_gc, x, y); | ||
79 | } | ||
80 | |||
81 | inline void setGraphicsExposure(bool value) { | ||
82 | XSetGraphicsExposures(m_display, m_gc, value); | ||
83 | } | ||
84 | |||
85 | inline void setFunction(int func) { | ||
86 | XSetFunction(m_display, m_gc, func); | ||
87 | } | ||
88 | |||
89 | inline void setSubwindowMode(int mode) { | ||
90 | XSetSubwindowMode(m_display, m_gc, mode); | ||
91 | } | ||
92 | inline void setFillStyle(int style) { | ||
93 | XSetFillStyle(m_display, m_gc, style); | ||
94 | } | ||
95 | inline void setFillRule(int rule) { | ||
96 | XSetFillRule(m_display, m_gc, rule); | ||
97 | } | ||
98 | |||
99 | void copy(GC gc); | ||
100 | void copy(const GContext &gc); | ||
101 | inline GContext &operator = (const GContext ©_gc) { copy(copy_gc); return *this; } | ||
102 | inline GContext &operator = (GC copy_gc) { copy(copy_gc); return *this; } | ||
103 | inline GC gc() const { return m_gc; } | ||
104 | |||
105 | private: | ||
106 | GContext(const GContext &cont); | ||
107 | |||
108 | static Display *m_display; // worth caching | ||
109 | GC m_gc; | ||
110 | }; | ||
111 | |||
112 | } // end namespace FbTk | ||
113 | |||
114 | #endif // FBTK_GCONTEXT_HH | ||