aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/GContext.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/GContext.hh')
-rw-r--r--src/FbTk/GContext.hh101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/FbTk/GContext.hh b/src/FbTk/GContext.hh
new file mode 100644
index 0000000..c192879
--- /dev/null
+++ b/src/FbTk/GContext.hh
@@ -0,0 +1,101 @@
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.4 2003/10/09 16:48:09 rathnor 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
32namespace FbTk {
33
34class FbDrawable;
35class Font;
36
37/// wrapper for X GC
38class GContext {
39public:
40 /// for FbTk drawable
41 explicit GContext(const FbTk::FbDrawable &drawable);
42 /// for X drawable
43 explicit GContext(Drawable drawable);
44
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 &font) {}
66
67 /// set font id
68 inline void setFont(int fid) {
69 XSetFont(m_display, m_gc, fid);
70 }
71
72 inline void setClipMask(const FbTk::FbPixmap &mask) {
73 XSetClipMask(m_display, m_gc, mask.drawable());
74 }
75
76 inline void setClipOrigin(int x, int y) {
77 XSetClipOrigin(m_display, m_gc, x, y);
78 }
79
80 inline void setGraphicsExposure(bool value) {
81 XSetGraphicsExposures(m_display, m_gc, value);
82 }
83
84 inline void setFunction(int func) {
85 XSetFunction(m_display, m_gc, func);
86 }
87
88 inline void setSubwindowMode(int mode) {
89 XSetSubwindowMode(m_display, m_gc, mode);
90 }
91
92 inline GC gc() const { return m_gc; }
93
94private:
95 Display *m_display; // worth caching
96 GC m_gc;
97};
98
99} // end namespace FbTk
100
101#endif // FBTK_GCONTEXT_HH