assign new pixmap via constructor and operator
This commit is contained in:
parent
5a543f8d7c
commit
4e9eac4824
2 changed files with 84 additions and 7 deletions
|
@ -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.1 2003/04/25 12:29:49 fluxgen Exp $
|
||||
// $Id: FbPixmap.cc,v 1.2 2003/04/27 00:12:17 fluxgen Exp $
|
||||
|
||||
#include "FbPixmap.hh"
|
||||
#include "App.hh"
|
||||
|
@ -36,6 +36,15 @@ FbPixmap::FbPixmap(const FbPixmap &the_copy):m_pm(0),
|
|||
copy(the_copy);
|
||||
}
|
||||
|
||||
FbPixmap::FbPixmap(Pixmap pm):m_pm(0),
|
||||
m_width(0), m_height(0),
|
||||
m_depth(0) {
|
||||
if (pm == 0)
|
||||
return;
|
||||
// assign X pixmap to this
|
||||
(*this) = pm;
|
||||
}
|
||||
|
||||
FbPixmap::FbPixmap(Drawable src,
|
||||
unsigned int width, unsigned int height,
|
||||
int depth):m_pm(0),
|
||||
|
@ -96,9 +105,69 @@ FbPixmap &FbPixmap::operator = (const FbPixmap &the_copy) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
void FbPixmap::copy(const FbPixmap &the_copy) {
|
||||
FbPixmap &FbPixmap::operator = (Pixmap pm) {
|
||||
// free pixmap before we set new
|
||||
free();
|
||||
create(the_copy.drawable(), the_copy.width(), the_copy.height(), the_copy.depth());
|
||||
|
||||
if (pm == 0)
|
||||
return *this;
|
||||
|
||||
// get width, height and depth for the pixmap
|
||||
Window root;
|
||||
int x, y;
|
||||
unsigned int border_width, bpp;
|
||||
XGetGeometry(FbTk::App::instance()->display(),
|
||||
pm,
|
||||
&root,
|
||||
&x, &y,
|
||||
&m_width, &m_height,
|
||||
&border_width,
|
||||
&bpp);
|
||||
|
||||
m_depth = bpp;
|
||||
|
||||
m_pm = pm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FbPixmap::copy(const FbPixmap &the_copy) {
|
||||
|
||||
bool create_new = false;
|
||||
|
||||
if (the_copy.width() != width() ||
|
||||
the_copy.height() != height() ||
|
||||
the_copy.depth() != depth() ||
|
||||
drawable() == 0)
|
||||
create_new = true;
|
||||
|
||||
if (create_new)
|
||||
free();
|
||||
|
||||
if (the_copy.drawable() != 0) {
|
||||
if (create_new) {
|
||||
create(the_copy.drawable(),
|
||||
the_copy.width(), the_copy.height(),
|
||||
the_copy.depth());
|
||||
}
|
||||
|
||||
if (drawable()) {
|
||||
Display *dpy = FbTk::App::instance()->display();
|
||||
GC temp_gc = XCreateGC(dpy,
|
||||
drawable(),
|
||||
0, 0);
|
||||
|
||||
copyArea(the_copy.drawable(),
|
||||
temp_gc,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width(), height());
|
||||
|
||||
XFreeGC(dpy, temp_gc);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void FbPixmap::free() {
|
||||
|
|
|
@ -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.1 2003/04/25 12:29:49 fluxgen Exp $
|
||||
// $Id: FbPixmap.hh,v 1.2 2003/04/27 00:10:28 fluxgen Exp $
|
||||
|
||||
#ifndef FBTK_FBPIXMAP_HH
|
||||
#define FBTK_FBPIXMAP_HH
|
||||
|
@ -32,11 +32,16 @@ namespace FbTk {
|
|||
class FbPixmap {
|
||||
public:
|
||||
FbPixmap();
|
||||
FbPixmap(const FbPixmap ©);
|
||||
/// copy pixmap
|
||||
explicit FbPixmap(const FbPixmap ©);
|
||||
/// creates a FbPixmap from X pixmap
|
||||
explicit FbPixmap(Pixmap pm);
|
||||
FbPixmap(Drawable src,
|
||||
unsigned int width, unsigned int height,
|
||||
int depth);
|
||||
|
||||
~FbPixmap();
|
||||
|
||||
void copyArea(Drawable src, GC gc,
|
||||
int src_x, int src_y,
|
||||
int dest_x, int dest_y,
|
||||
|
@ -48,7 +53,10 @@ public:
|
|||
void fillPolygon(GC gc, XPoint *points, int npoints,
|
||||
int shape, int mode);
|
||||
void copy(const FbPixmap &the_copy);
|
||||
|
||||
FbPixmap &operator = (const FbPixmap ©);
|
||||
/// sets new pixmap
|
||||
FbPixmap &operator = (Pixmap pm);
|
||||
|
||||
inline Drawable drawable() const { return m_pm; }
|
||||
inline unsigned int width() const { return m_width; }
|
||||
|
|
Loading…
Reference in a new issue