#include "wx/dcmemory.h"
#include <gdk/gdk.h>
-#include <gdk/gdkprivate.h>
+#include <gtk/gtk.h>
-// in GTK+ 1.3 gdk_root_parent was renamed into gdk_parent_root
-#ifdef __WXGTK13__
- #define gdk_root_parent gdk_parent_root
-#else // GTK+ <= 1.2
- // need to get the declaration of gdk_root_parent from private header
- #include <gdk/gdkx.h>
-#endif // GTK+ 1.3/1.2
+//-----------------------------------------------------------------------------
+// data
+//-----------------------------------------------------------------------------
+
+extern GtkWidget *wxRootWindow;
//-----------------------------------------------------------------------------
// wxMask
wxImage image( bitmap );
if (!image.Ok()) return FALSE;
- GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
- m_bitmap = gdk_pixmap_new( parent, image.GetWidth(), image.GetHeight(), 1 );
+ m_bitmap = gdk_pixmap_new( wxRootWindow->window, image.GetWidth(), image.GetHeight(), 1 );
GdkGC *gc = gdk_gc_new( m_bitmap );
GdkColor color;
unsigned char green = colour.Green();
unsigned char blue = colour.Blue();
- GdkVisual *visual = gdk_visual_get_system();
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15)
wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );
- m_bitmap = gdk_pixmap_new( (GdkWindow*) &gdk_root_parent, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
+ m_bitmap = gdk_pixmap_new( wxRootWindow->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
if (!m_bitmap) return FALSE;
wxBitmap::wxBitmap( int width, int height, int depth )
{
- wxCHECK_RET( (width > 0) && (height > 0), wxT("invalid bitmap size") )
+ Create( width, height, depth );
- GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
- if (depth == -1) depth = gdk_window_get_visual( parent )->depth;
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}
- wxCHECK_RET( (depth == gdk_window_get_visual( parent )->depth) ||
- (depth == 1), wxT("invalid bitmap depth") )
+bool wxBitmap::Create( int width, int height, int depth )
+{
+ UnRef();
+
+ wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
+
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
+ if (depth == -1) depth = visual->depth;
+
+ wxCHECK_MSG( (depth == visual->depth) ||
+ (depth == 1), FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData();
M_BMPDATA->m_mask = (wxMask *) NULL;
M_BMPDATA->m_height = height;
if (depth == 1)
{
- M_BMPDATA->m_bitmap = gdk_pixmap_new( parent, width, height, 1 );
+ M_BMPDATA->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 );
M_BMPDATA->m_bpp = 1;
}
else
{
- M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
- M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+ M_BMPDATA->m_pixmap = gdk_pixmap_new( wxRootWindow->window, width, height, depth );
+ M_BMPDATA->m_bpp = visual->depth;
}
- if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+ return Ok();
}
-
bool wxBitmap::CreateFromXpm( const char **bits )
{
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
- GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
- M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
+ M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
- M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
+ M_BMPDATA->m_bpp = visual->depth; // ?
+
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE;
M_BMPDATA->m_mask = (wxMask *) NULL;
M_BMPDATA->m_bitmap =
- gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height );
+ gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height );
M_BMPDATA->m_width = width;
M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1;
if (GetMask())
{
wxMask *mask = new wxMask;
- GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
- mask->m_bitmap = gdk_pixmap_new( parent, rect.width, rect.height, 1 );
+ mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, rect.width, rect.height, 1 );
GdkGC *gc = gdk_gc_new( mask->m_bitmap );
gdk_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, 0, 0, rect.x, rect.y, rect.width, rect.height );
if (!wxFileExists(name)) return FALSE;
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
- GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
- M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name.fn_str() );
+ M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxRootWindow->window, &mask, NULL, name.fn_str() );
if (mask)
{
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
- M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+
+ M_BMPDATA->m_bpp = visual->depth;
}
else // try if wxImage can load it
{