diff options
author | fluxgen <fluxgen> | 2003-04-27 00:12:17 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-04-27 00:12:17 (GMT) |
commit | 4e9eac4824ba042f0a192b51758ce68293c16582 (patch) | |
tree | 8ad0854e3168f8cadce1b9dad61a708895a6242c /src/FbTk/FbPixmap.cc | |
parent | 5a543f8d7c9ef71eb979f896c7de7cb631d21fd8 (diff) | |
download | fluxbox-4e9eac4824ba042f0a192b51758ce68293c16582.zip fluxbox-4e9eac4824ba042f0a192b51758ce68293c16582.tar.bz2 |
assign new pixmap via constructor and operator
Diffstat (limited to 'src/FbTk/FbPixmap.cc')
-rw-r--r-- | src/FbTk/FbPixmap.cc | 79 |
1 files changed, 74 insertions, 5 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 | ||
33 | FbPixmap::FbPixmap(const FbPixmap &the_copy):m_pm(0), | 33 | FbPixmap::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 | ||
39 | FbPixmap::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 | |||
39 | FbPixmap::FbPixmap(Drawable src, | 48 | FbPixmap::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 | ||
99 | void FbPixmap::copy(const FbPixmap &the_copy) { | 108 | FbPixmap &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 | |||
134 | void 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 | ||
104 | void FbPixmap::free() { | 173 | void FbPixmap::free() { |