aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-09-10 21:37:05 (GMT)
committerfluxgen <fluxgen>2003-09-10 21:37:05 (GMT)
commitd9f17a17c3aed77392cbe0a07ff1e16d8e0ed561 (patch)
tree1196f4a9caba6367abf8c7e426034185f4ffb9c6 /src/FbTk
parent8c9818a84bb6d0da24e1f91bc227ebea655bfdb1 (diff)
downloadfluxbox_paul-d9f17a17c3aed77392cbe0a07ff1e16d8e0ed561.zip
fluxbox_paul-d9f17a17c3aed77392cbe0a07ff1e16d8e0ed561.tar.bz2
cleaning
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/FbPixmap.cc41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index 5be9e7b..0ea6aa1 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -19,10 +19,11 @@
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.7 2003/08/12 00:25:23 fluxgen Exp $ 22// $Id: FbPixmap.cc,v 1.8 2003/09/10 21:37:05 fluxgen Exp $
23 23
24#include "FbPixmap.hh" 24#include "FbPixmap.hh"
25#include "App.hh" 25#include "App.hh"
26#include "GContext.hh"
26 27
27#include <X11/Xutil.h> 28#include <X11/Xutil.h>
28#include <iostream> 29#include <iostream>
@@ -115,20 +116,14 @@ void FbPixmap::copy(const FbPixmap &the_copy) {
115 116
116 if (drawable()) { 117 if (drawable()) {
117 Display *dpy = FbTk::App::instance()->display(); 118 Display *dpy = FbTk::App::instance()->display();
118 GC temp_gc = XCreateGC(dpy, 119 GContext gc(drawable());
119 drawable(), 120
120 0, 0);
121
122 copyArea(the_copy.drawable(), 121 copyArea(the_copy.drawable(),
123 temp_gc, 122 gc.gc(),
124 0, 0, 123 0, 0,
125 0, 0, 124 0, 0,
126 width(), height()); 125 width(), height());
127
128 XFreeGC(dpy, temp_gc);
129
130 } 126 }
131
132 } 127 }
133} 128}
134 129
@@ -178,17 +173,16 @@ void FbPixmap::rotate() {
178 // reverse height/width for new pixmap 173 // reverse height/width for new pixmap
179 FbPixmap new_pm(drawable(), height(), width(), depth()); 174 FbPixmap new_pm(drawable(), height(), width(), depth());
180 175
181 GC gc = XCreateGC(dpy, drawable(), 0, 0); 176 GContext gc(drawable());
182 177
183 // copy new area 178 // copy new area
184 for (int y = 0; y < height(); ++y) { 179 for (int y = 0; y < height(); ++y) {
185 for (int x = 0; x < width(); ++x) { 180 for (int x = 0; x < width(); ++x) {
186 XSetForeground(dpy, gc, XGetPixel(src_image, x, y)); 181 gc.setForeground(XGetPixel(src_image, x, y));
187 // revers coordinates 182 // revers coordinates
188 XDrawPoint(dpy, new_pm.drawable(), gc, y, x); 183 XDrawPoint(dpy, new_pm.drawable(), gc.gc(), y, x);
189 } 184 }
190 } 185 }
191 XFreeGC(dpy, gc);
192 186
193 XDestroyImage(src_image); 187 XDestroyImage(src_image);
194 // free old pixmap and set new from new_pm 188 // free old pixmap and set new from new_pm
@@ -218,8 +212,7 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
218 // create new pixmap with dest size 212 // create new pixmap with dest size
219 FbPixmap new_pm(drawable(), dest_width, dest_height, depth()); 213 FbPixmap new_pm(drawable(), dest_width, dest_height, depth());
220 214
221 GC gc = XCreateGC(dpy, drawable(), 0, 0); 215 GContext gc(drawable());
222
223 // calc zoom 216 // calc zoom
224 float zoom_x = static_cast<float>(width())/static_cast<float>(dest_width); 217 float zoom_x = static_cast<float>(width())/static_cast<float>(dest_width);
225 float zoom_y = static_cast<float>(height())/static_cast<float>(dest_height); 218 float zoom_y = static_cast<float>(height())/static_cast<float>(dest_height);
@@ -229,16 +222,13 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
229 for (int tx=0; tx<dest_width; ++tx, src_x += zoom_x) { 222 for (int tx=0; tx<dest_width; ++tx, src_x += zoom_x) {
230 src_y = 0; 223 src_y = 0;
231 for (int ty=0; ty<dest_height; ++ty, src_y += zoom_y) { 224 for (int ty=0; ty<dest_height; ++ty, src_y += zoom_y) {
232 XSetForeground(dpy, gc, XGetPixel(src_image, 225 gc.setForeground(XGetPixel(src_image,
233 static_cast<int>(src_x), 226 static_cast<int>(src_x),
234 static_cast<int>(src_y))); 227 static_cast<int>(src_y)));
235 XDrawPoint(dpy, new_pm.drawable(), gc, tx, ty); 228 XDrawPoint(dpy, new_pm.drawable(), gc.gc(), tx, ty);
236
237 } 229 }
238 } 230 }
239 231
240 XFreeGC(dpy, gc);
241
242 XDestroyImage(src_image); 232 XDestroyImage(src_image);
243 233
244 // free old pixmap and set new from new_pm 234 // free old pixmap and set new from new_pm
@@ -250,6 +240,11 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
250 m_pm = new_pm.release(); 240 m_pm = new_pm.release();
251} 241}
252 242
243void FbPixmap::resize(unsigned int width, unsigned int height) {
244 FbPixmap pm(drawable(), width, height, depth());
245 *this = pm.release();
246}
247
253Pixmap FbPixmap::release() { 248Pixmap FbPixmap::release() {
254 Pixmap ret = m_pm; 249 Pixmap ret = m_pm;
255 m_pm = 0; 250 m_pm = 0;