1
// GContext.hh for FbTk - fluxbox toolkit
2
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
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:
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
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.
22
// $Id: GContext.hh 3954 2005-04-26 01:41:55Z simonb $
24
#ifndef FBTK_GCONTEXT_HH
25
#define FBTK_GCONTEXT_HH
28
#include "FbPixmap.hh"
41
typedef enum { JOINMITER= JoinMiter,
46
typedef enum { LINESOLID= LineSolid,
47
LINEONOFFDASH= LineOnOffDash,
48
LINEDOUBLEDASH= LineDoubleDash
51
typedef enum { CAPNOTLAST= CapNotLast,
54
CAPPROJECTING= CapProjecting
58
explicit GContext(const FbTk::FbDrawable &drawable);
60
explicit GContext(Drawable drawable);
61
GContext(Drawable d, const FbTk::GContext &gc);
64
inline void setForeground(const FbTk::Color &color) {
65
setForeground(color.pixel());
68
inline void setForeground(long pixel_value) {
69
XSetForeground(m_display, m_gc,
73
inline void setBackground(const FbTk::Color &color) {
74
setBackground(color.pixel());
77
inline void setBackground(long pixel_value) {
78
XSetBackground(m_display, m_gc, pixel_value);
81
inline void setTile(Drawable draw) {
82
XSetTile(m_display, m_gc, draw);
85
inline void setTile(const FbTk::FbPixmap &draw) {
86
setTile(draw.drawable());
90
inline void setFont(const FbTk::Font &) {}
93
inline void setFont(int fid) {
94
XSetFont(m_display, m_gc, fid);
97
inline void setClipMask(const FbTk::FbPixmap &mask) {
98
XSetClipMask(m_display, m_gc, mask.drawable());
101
inline void setClipOrigin(int x, int y) {
102
XSetClipOrigin(m_display, m_gc, x, y);
105
inline void setGraphicsExposure(bool value) {
106
XSetGraphicsExposures(m_display, m_gc, value);
109
inline void setFunction(int func) {
110
XSetFunction(m_display, m_gc, func);
113
inline void setSubwindowMode(int mode) {
114
XSetSubwindowMode(m_display, m_gc, mode);
116
inline void setFillStyle(int style) {
117
XSetFillStyle(m_display, m_gc, style);
119
inline void setFillRule(int rule) {
120
XSetFillRule(m_display, m_gc, rule);
123
inline void setLineAttributes(unsigned int width,
128
XSetLineAttributes(m_display, m_gc, width, line_style, cap_style, join_style);
133
void copy(const GContext &gc);
135
inline GContext &operator = (const GContext ©_gc) { copy(copy_gc); return *this; }
136
inline GContext &operator = (GC copy_gc) { copy(copy_gc); return *this; }
137
inline GC gc() const { return m_gc; }
140
GContext(const GContext &cont);
142
static Display *m_display; // worth caching
146
} // end namespace FbTk
148
#endif // FBTK_GCONTEXT_HH