aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-25 12:29:49 (GMT)
committerfluxgen <fluxgen>2003-04-25 12:29:49 (GMT)
commit46d6a06ececf7334fe7f6dd5a2344fa43b602819 (patch)
tree4daffa39598b2d7dee2940bf60263a37529ba739 /src/FbTk
parentd2a50e03206f58557cfed0ab4bcd12a2c833eb0a (diff)
downloadfluxbox_pavel-46d6a06ececf7334fe7f6dd5a2344fa43b602819.zip
fluxbox_pavel-46d6a06ececf7334fe7f6dd5a2344fa43b602819.tar.bz2
a X pixmap wrapper
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/FbPixmap.cc130
-rw-r--r--src/FbTk/FbPixmap.hh71
2 files changed, 201 insertions, 0 deletions
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
new file mode 100644
index 0000000..7f358d1
--- /dev/null
+++ b/src/FbTk/FbPixmap.cc
@@ -0,0 +1,130 @@
1// FbPixmap.cc 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: FbPixmap.cc,v 1.1 2003/04/25 12:29:49 fluxgen Exp $
23
24#include "FbPixmap.hh"
25#include "App.hh"
26
27namespace FbTk {
28
29FbPixmap::FbPixmap():m_pm(0),
30 m_width(0), m_height(0),
31 m_depth(0) { }
32
33FbPixmap::FbPixmap(const FbPixmap &the_copy):m_pm(0),
34 m_width(0), m_height(0),
35 m_depth(0) {
36 copy(the_copy);
37}
38
39FbPixmap::FbPixmap(Drawable src,
40 unsigned int width, unsigned int height,
41 int depth):m_pm(0),
42 m_width(0), m_height(0),
43 m_depth(0) {
44
45 create(src, width, height, depth);
46}
47
48FbPixmap::~FbPixmap() {
49 free();
50}
51
52void FbPixmap::copyArea(Drawable src, GC gc,
53 int src_x, int src_y,
54 int dest_x, int dest_y,
55 unsigned int width, unsigned int height) {
56 if (m_pm == 0 || src == 0 || gc == 0)
57 return;
58 XCopyArea(FbTk::App::instance()->display(),
59 src, m_pm, gc,
60 src_x, src_y,
61 dest_x, dest_y,
62 width, height);
63}
64
65void FbPixmap::fillRectangle(GC gc, int x, int y,
66 unsigned int width, unsigned int height) {
67 if (m_pm == 0 || gc == 0)
68 return;
69 XFillRectangle(FbTk::App::instance()->display(),
70 m_pm, gc,
71 x, y,
72 width, height);
73}
74
75void FbPixmap::drawRectangle(GC gc, int x, int y,
76 unsigned int width, unsigned int height) {
77 if (m_pm == 0 || gc == 0)
78 return;
79 XDrawRectangle(FbTk::App::instance()->display(),
80 m_pm, gc,
81 x, y,
82 width, height);
83}
84
85void FbPixmap::fillPolygon(GC gc, XPoint *points, int npoints,
86 int shape, int mode) {
87 if (m_pm == 0 || gc == 0 || points == 0 || npoints == 0)
88 return;
89 XFillPolygon(FbTk::App::instance()->display(),
90 m_pm, gc, points, npoints,
91 shape, mode);
92}
93
94FbPixmap &FbPixmap::operator = (const FbPixmap &the_copy) {
95 copy(the_copy);
96 return *this;
97}
98
99void FbPixmap::copy(const FbPixmap &the_copy) {
100 free();
101 create(the_copy.drawable(), the_copy.width(), the_copy.height(), the_copy.depth());
102}
103
104void FbPixmap::free() {
105 if (m_pm != 0) {
106 XFreePixmap(FbTk::App::instance()->display(), m_pm);
107 m_pm = 0;
108 }
109 m_width = 0;
110 m_height = 0;
111 m_depth = 0;
112}
113
114void FbPixmap::create(Drawable src,
115 unsigned int width, unsigned int height,
116 int depth) {
117 if (src == 0)
118 return;
119
120 m_pm = XCreatePixmap(FbTk::App::instance()->display(),
121 src, width, height, depth);
122 if (m_pm == 0)
123 return;
124
125 m_width = width;
126 m_height = height;
127 m_depth = depth;
128}
129
130}; // end namespace FbTk
diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh
new file mode 100644
index 0000000..05f05e3
--- /dev/null
+++ b/src/FbTk/FbPixmap.hh
@@ -0,0 +1,71 @@
1// FbPixmap.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: FbPixmap.hh,v 1.1 2003/04/25 12:29:49 fluxgen Exp $
23
24#ifndef FBTK_FBPIXMAP_HH
25#define FBTK_FBPIXMAP_HH
26
27#include <X11/Xlib.h>
28
29namespace FbTk {
30
31/// a wrapper for X Pixmap
32class FbPixmap {
33public:
34 FbPixmap();
35 FbPixmap(const FbPixmap &copy);
36 FbPixmap(Drawable src,
37 unsigned int width, unsigned int height,
38 int depth);
39 ~FbPixmap();
40 void copyArea(Drawable src, GC gc,
41 int src_x, int src_y,
42 int dest_x, int dest_y,
43 unsigned int width, unsigned int height);
44 void fillRectangle(GC gc, int x, int y,
45 unsigned int width, unsigned int height);
46 void drawRectangle(GC gc, int x, int y,
47 unsigned int width, unsigned int height);
48 void fillPolygon(GC gc, XPoint *points, int npoints,
49 int shape, int mode);
50 void copy(const FbPixmap &the_copy);
51 FbPixmap &operator = (const FbPixmap &copy);
52
53 inline Drawable drawable() const { return m_pm; }
54 inline unsigned int width() const { return m_width; }
55 inline unsigned int height() const { return m_height; }
56 inline int depth() const { return m_depth; }
57
58private:
59 void free();
60 void create(Drawable src,
61 unsigned int width, unsigned int height,
62 int depth);
63 Pixmap m_pm;
64 int m_depth;
65 unsigned int m_width, m_height;
66};
67
68}; // end namespace FbTk
69
70#endif // FBTK_FBPIXMAP_HH
71