aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-27 00:12:17 (GMT)
committerfluxgen <fluxgen>2003-04-27 00:12:17 (GMT)
commit4e9eac4824ba042f0a192b51758ce68293c16582 (patch)
tree8ad0854e3168f8cadce1b9dad61a708895a6242c
parent5a543f8d7c9ef71eb979f896c7de7cb631d21fd8 (diff)
downloadfluxbox_paul-4e9eac4824ba042f0a192b51758ce68293c16582.zip
fluxbox_paul-4e9eac4824ba042f0a192b51758ce68293c16582.tar.bz2
assign new pixmap via constructor and operator
-rw-r--r--src/FbTk/FbPixmap.cc79
-rw-r--r--src/FbTk/FbPixmap.hh12
2 files changed, 84 insertions, 7 deletions
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index 7f358d1..c966ab6 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbPixmap.cc,v 1.1 2003/04/25 12:29:49 fluxgen Exp $ 22// $Id: FbPixmap.cc,v 1.2 2003/04/27 00:12:17 fluxgen Exp $
23 23
24#include "FbPixmap.hh" 24#include "FbPixmap.hh"
25#include "App.hh" 25#include "App.hh"
@@ -31,11 +31,20 @@ FbPixmap::FbPixmap():m_pm(0),
31 m_depth(0) { } 31 m_depth(0) { }
32 32
33FbPixmap::FbPixmap(const FbPixmap &the_copy):m_pm(0), 33FbPixmap::FbPixmap(const FbPixmap &the_copy):m_pm(0),
34 m_width(0), m_height(0), 34 m_width(0), m_height(0),
35 m_depth(0) { 35 m_depth(0) {
36 copy(the_copy); 36 copy(the_copy);
37} 37}
38 38
39FbPixmap::FbPixmap(Pixmap pm):m_pm(0),
40 m_width(0), m_height(0),
41 m_depth(0) {
42 if (pm == 0)
43 return;
44 // assign X pixmap to this
45 (*this) = pm;
46}
47
39FbPixmap::FbPixmap(Drawable src, 48FbPixmap::FbPixmap(Drawable src,
40 unsigned int width, unsigned int height, 49 unsigned int width, unsigned int height,
41 int depth):m_pm(0), 50 int depth):m_pm(0),
@@ -96,9 +105,69 @@ FbPixmap &FbPixmap::operator = (const FbPixmap &the_copy) {
96 return *this; 105 return *this;
97} 106}
98 107
99void FbPixmap::copy(const FbPixmap &the_copy) { 108FbPixmap &FbPixmap::operator = (Pixmap pm) {
109 // free pixmap before we set new
100 free(); 110 free();
101 create(the_copy.drawable(), the_copy.width(), the_copy.height(), the_copy.depth()); 111
112 if (pm == 0)
113 return *this;
114
115 // get width, height and depth for the pixmap
116 Window root;
117 int x, y;
118 unsigned int border_width, bpp;
119 XGetGeometry(FbTk::App::instance()->display(),
120 pm,
121 &root,
122 &x, &y,
123 &m_width, &m_height,
124 &border_width,
125 &bpp);
126
127 m_depth = bpp;
128
129 m_pm = pm;
130
131 return *this;
132}
133
134void FbPixmap::copy(const FbPixmap &the_copy) {
135
136 bool create_new = false;
137
138 if (the_copy.width() != width() ||
139 the_copy.height() != height() ||
140 the_copy.depth() != depth() ||
141 drawable() == 0)
142 create_new = true;
143
144 if (create_new)
145 free();
146
147 if (the_copy.drawable() != 0) {
148 if (create_new) {
149 create(the_copy.drawable(),
150 the_copy.width(), the_copy.height(),
151 the_copy.depth());
152 }
153
154 if (drawable()) {
155 Display *dpy = FbTk::App::instance()->display();
156 GC temp_gc = XCreateGC(dpy,
157 drawable(),
158 0, 0);
159
160 copyArea(the_copy.drawable(),
161 temp_gc,
162 0, 0,
163 0, 0,
164 width(), height());
165
166 XFreeGC(dpy, temp_gc);
167
168 }
169
170 }
102} 171}
103 172
104void FbPixmap::free() { 173void FbPixmap::free() {
diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh
index 05f05e3..a8f9472 100644
--- a/src/FbTk/FbPixmap.hh
+++ b/src/FbTk/FbPixmap.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbPixmap.hh,v 1.1 2003/04/25 12:29:49 fluxgen Exp $ 22// $Id: FbPixmap.hh,v 1.2 2003/04/27 00:10:28 fluxgen Exp $
23 23
24#ifndef FBTK_FBPIXMAP_HH 24#ifndef FBTK_FBPIXMAP_HH
25#define FBTK_FBPIXMAP_HH 25#define FBTK_FBPIXMAP_HH
@@ -32,11 +32,16 @@ namespace FbTk {
32class FbPixmap { 32class FbPixmap {
33public: 33public:
34 FbPixmap(); 34 FbPixmap();
35 FbPixmap(const FbPixmap &copy); 35 /// copy pixmap
36 explicit FbPixmap(const FbPixmap &copy);
37 /// creates a FbPixmap from X pixmap
38 explicit FbPixmap(Pixmap pm);
36 FbPixmap(Drawable src, 39 FbPixmap(Drawable src,
37 unsigned int width, unsigned int height, 40 unsigned int width, unsigned int height,
38 int depth); 41 int depth);
42
39 ~FbPixmap(); 43 ~FbPixmap();
44
40 void copyArea(Drawable src, GC gc, 45 void copyArea(Drawable src, GC gc,
41 int src_x, int src_y, 46 int src_x, int src_y,
42 int dest_x, int dest_y, 47 int dest_x, int dest_y,
@@ -48,7 +53,10 @@ public:
48 void fillPolygon(GC gc, XPoint *points, int npoints, 53 void fillPolygon(GC gc, XPoint *points, int npoints,
49 int shape, int mode); 54 int shape, int mode);
50 void copy(const FbPixmap &the_copy); 55 void copy(const FbPixmap &the_copy);
56
51 FbPixmap &operator = (const FbPixmap &copy); 57 FbPixmap &operator = (const FbPixmap &copy);
58 /// sets new pixmap
59 FbPixmap &operator = (Pixmap pm);
52 60
53 inline Drawable drawable() const { return m_pm; } 61 inline Drawable drawable() const { return m_pm; }
54 inline unsigned int width() const { return m_width; } 62 inline unsigned int width() const { return m_width; }