~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/FbTk/GContext.hh

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// GContext.hh for FbTk - fluxbox toolkit
2
 
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
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 3954 2005-04-26 01:41:55Z simonb $
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
 
 
41
 
    typedef enum { JOINMITER= JoinMiter,
42
 
                   JOINROUND= JoinRound,
43
 
                   JOINBEVEL= JoinBevel
44
 
    } JoinStyle;
45
 
 
46
 
    typedef enum { LINESOLID= LineSolid,
47
 
                   LINEONOFFDASH= LineOnOffDash,
48
 
                   LINEDOUBLEDASH= LineDoubleDash
49
 
    } LineStyle;
50
 
 
51
 
    typedef enum { CAPNOTLAST= CapNotLast,
52
 
                   CAPBUTT= CapButt,
53
 
                   CAPROUND= CapRound,
54
 
                   CAPPROJECTING= CapProjecting
55
 
    } CapStyle;
56
 
  
57
 
    /// for FbTk drawable
58
 
    explicit GContext(const FbTk::FbDrawable &drawable);
59
 
    /// for X drawable
60
 
    explicit GContext(Drawable drawable);
61
 
    GContext(Drawable d, const FbTk::GContext &gc);
62
 
    virtual ~GContext();
63
 
 
64
 
    inline void setForeground(const FbTk::Color &color) {
65
 
        setForeground(color.pixel());
66
 
    }
67
 
 
68
 
    inline void setForeground(long pixel_value) {
69
 
        XSetForeground(m_display, m_gc,
70
 
                       pixel_value);
71
 
    }
72
 
 
73
 
    inline void setBackground(const FbTk::Color &color) {
74
 
        setBackground(color.pixel());
75
 
    }
76
 
 
77
 
    inline void setBackground(long pixel_value) {
78
 
        XSetBackground(m_display, m_gc, pixel_value);
79
 
    }
80
 
 
81
 
    inline void setTile(Drawable draw) {
82
 
        XSetTile(m_display, m_gc, draw);
83
 
    }
84
 
 
85
 
    inline void setTile(const FbTk::FbPixmap &draw) {
86
 
        setTile(draw.drawable());
87
 
    }
88
 
 
89
 
    /// not implemented
90
 
    inline void setFont(const FbTk::Font &) {}
91
 
 
92
 
    /// set font id
93
 
    inline void setFont(int fid) {
94
 
        XSetFont(m_display, m_gc, fid);
95
 
    }
96
 
 
97
 
    inline void setClipMask(const FbTk::FbPixmap &mask) {
98
 
        XSetClipMask(m_display, m_gc, mask.drawable());
99
 
    }
100
 
 
101
 
    inline void setClipOrigin(int x, int y) {
102
 
        XSetClipOrigin(m_display, m_gc, x, y);
103
 
    }
104
 
 
105
 
    inline void setGraphicsExposure(bool value) {
106
 
        XSetGraphicsExposures(m_display, m_gc, value);
107
 
    }
108
 
 
109
 
    inline void setFunction(int func) {
110
 
        XSetFunction(m_display, m_gc, func);
111
 
    }
112
 
 
113
 
    inline void setSubwindowMode(int mode) {
114
 
        XSetSubwindowMode(m_display, m_gc, mode);
115
 
    }
116
 
    inline void setFillStyle(int style) {
117
 
        XSetFillStyle(m_display, m_gc, style);
118
 
    }
119
 
    inline void setFillRule(int rule) {
120
 
        XSetFillRule(m_display, m_gc, rule);
121
 
    }
122
 
 
123
 
    inline void setLineAttributes(unsigned int width, 
124
 
                                  int line_style, 
125
 
                                  int cap_style, 
126
 
                                  int join_style) {
127
 
 
128
 
        XSetLineAttributes(m_display, m_gc, width, line_style, cap_style, join_style);
129
 
    }
130
 
      
131
 
 
132
 
    void copy(GC gc);
133
 
    void copy(const GContext &gc);
134
 
 
135
 
    inline GContext &operator = (const GContext &copy_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; }
138
 
 
139
 
private:
140
 
    GContext(const GContext &cont);
141
 
 
142
 
    static Display *m_display; // worth caching
143
 
    GC m_gc;
144
 
};
145
 
 
146
 
} // end namespace FbTk
147
 
 
148
 
#endif // FBTK_GCONTEXT_HH