From 346dacc633a68e14315cdd13f79c31b6e86f124f Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 11 Aug 2003 14:59:07 +0000 Subject: added copy for X Pixmap --- src/FbTk/FbPixmap.cc | 33 ++++++++++++++++++++++++++++++++- src/FbTk/FbPixmap.hh | 3 ++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 75ab8d7..f96a872 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.cc,v 1.5 2003/07/10 11:55:01 fluxgen Exp $ +// $Id: FbPixmap.cc,v 1.6 2003/08/11 14:58:49 fluxgen Exp $ #include "FbPixmap.hh" #include "App.hh" @@ -132,6 +132,37 @@ void FbPixmap::copy(const FbPixmap &the_copy) { } } +void FbPixmap::copy(Pixmap pm) { + free(); + if (pm == 0) + return; + + // get width, height and depth for the pixmap + Window root; + int x, y; + unsigned int border_width, bpp; + unsigned int new_width, new_height; + + XGetGeometry(FbTk::App::instance()->display(), + pm, + &root, + &x, &y, + &new_width, &new_height, + &border_width, + &bpp); + // create new pixmap and copy area + create(root, new_width, new_height, bpp); + // determine screen gc + Display *disp = FbTk::App::instance()->display(); + XWindowAttributes attr; + XGetWindowAttributes(disp, root, &attr); + GC gc = DefaultGCOfScreen(attr.screen); + XCopyArea(disp, pm, drawable(), gc, + 0, 0, + width(), height(), + 0, 0); +} + void FbPixmap::rotate() { Display *dpy = FbTk::App::instance()->display(); diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index 787c06f..f901aa0 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.hh,v 1.5 2003/07/10 11:55:01 fluxgen Exp $ +// $Id: FbPixmap.hh,v 1.6 2003/08/11 14:59:07 fluxgen Exp $ #ifndef FBTK_FBPIXMAP_HH #define FBTK_FBPIXMAP_HH @@ -45,6 +45,7 @@ public: ~FbPixmap(); void copy(const FbPixmap &the_copy); + void copy(Pixmap pixmap); /// rotates the pixmap 90 deg, not implemented! void rotate(); /// scales the pixmap to specified size -- cgit v0.11.2