summaryrefslogtreecommitdiff
path: root/src/FbTk/FbPixmap.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-03-26 04:02:30 (GMT)
committersimonb <simonb>2006-03-26 04:02:30 (GMT)
commitaf74a2284551c8511b66d77112c7bf32831c1522 (patch)
tree35a8830352f5facc1fc9c58b82c0c6dce8fc921e /src/FbTk/FbPixmap.cc
parent872f6a0e1e4230f702ad69fa2d7e10a2fa78b7a3 (diff)
downloadfluxbox_lack-af74a2284551c8511b66d77112c7bf32831c1522.zip
fluxbox_lack-af74a2284551c8511b66d77112c7bf32831c1522.tar.bz2
rotated fonts, buttons, containers. Used for tabs for now
Diffstat (limited to 'src/FbTk/FbPixmap.cc')
-rw-r--r--src/FbTk/FbPixmap.cc56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index 77a65c6..0df087d 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -201,25 +201,63 @@ void FbPixmap::copy(Pixmap pm, int depth, int screen_num) {
201 XFreeGC(display(), gc); 201 XFreeGC(display(), gc);
202} 202}
203 203
204void FbPixmap::rotate() { 204void FbPixmap::rotate(FbTk::Orientation orient) {
205 if (orient == ROT0)
206 return;
207
208 unsigned int oldw = width(), oldh = height();
209 unsigned int neww = oldw, newh = oldh;
210 translateSize(orient, neww, newh);
205 211
206 // make an image copy 212 // make an image copy
207 XImage *src_image = XGetImage(display(), drawable(), 213 XImage *src_image = XGetImage(display(), drawable(),
208 0, 0, // pos 214 0, 0, // pos
209 width(), height(), // size 215 oldw, oldh, // size
210 ~0, // plane mask 216 ~0, // plane mask
211 ZPixmap); // format 217 ZPixmap); // format
212 // reverse height/width for new pixmap 218 // reverse height/width for new pixmap
213 FbPixmap new_pm(drawable(), height(), width(), depth()); 219 FbPixmap new_pm(drawable(), neww, newh, depth());
214 220
215 GContext gc(drawable()); 221 GContext gc(drawable());
216 222
217 // copy new area 223 if (orient == ROT180) {
218 for (unsigned int y = 0; y < height(); ++y) { 224 unsigned int srcx, srcy, destx, desty;
219 for (unsigned int x = 0; x < width(); ++x) { 225 for (srcy = 0, desty = oldh; srcy < oldh; ++srcy, --desty) {
220 gc.setForeground(XGetPixel(src_image, x, y)); 226 for (srcx = 0, destx = oldw; srcx < oldw; ++srcx, --destx) {
221 // revers coordinates 227 gc.setForeground(XGetPixel(src_image, srcx, srcy));
222 XDrawPoint(display(), new_pm.drawable(), gc.gc(), y, x); 228 XDrawPoint(display(), new_pm.drawable(), gc.gc(), destx, desty);
229 }
230 }
231 } else {
232 // need to flip x and y
233
234 // set start, end and direction based on rotation
235 // NOTE that startx etc are in the direction of the OLD pixmap
236 unsigned int startx, starty;
237 int dirx, diry;
238 switch (orient) {
239 case ROT90:
240 startx = neww-1;
241 starty = 0;
242 dirx = -1;
243 diry = 1;
244 break;
245 case ROT270:
246 startx = 0;
247 starty = newh-1;
248 dirx = 1;
249 diry = -1;
250 break;
251 }
252
253
254 // copy new area
255 unsigned int srcx, srcy, destx, desty;
256 for (srcy = 0, destx = startx; srcy < oldh; ++srcy, destx+=dirx) {
257 for (srcx = 0, desty = starty; srcx < oldw; ++srcx, desty+=diry) {
258 gc.setForeground(XGetPixel(src_image, srcx, srcy));
259 XDrawPoint(display(), new_pm.drawable(), gc.gc(), destx, desty);
260 }
223 } 261 }
224 } 262 }
225 263