- if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
-};
-
-wxBitmap::wxBitmap( const int width, const int height, const int depth )
-{
- m_refData = new wxBitmapRefData();
- M_BMPDATA->m_mask = NULL;
- M_BMPDATA->m_pixmap =
- gdk_pixmap_new( (GdkWindow*) &gdk_root_parent, width, height, depth );
- gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
- M_BMPDATA->m_bpp = depth;
-
- if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
-};
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::wxBitmap( int width, int height, int depth )
+{
+ wxCHECK_RET( (width > 0) && (height > 0), _T("invalid bitmap size") )
+
+ GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+ if (depth == -1) depth = gdk_window_get_visual( parent )->depth;
+
+ wxCHECK_RET( (depth == gdk_window_get_visual( parent )->depth) ||
+ (depth == 1), _T("invalid bitmap depth") )
+
+ m_refData = new wxBitmapRefData();
+ M_BMPDATA->m_mask = (wxMask *) NULL;
+ M_BMPDATA->m_width = width;
+ M_BMPDATA->m_height = height;
+ if (depth == 1)
+ {
+ M_BMPDATA->m_bitmap = gdk_pixmap_new( parent, 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;
+ }
+
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}
+
+wxBitmap::wxBitmap( const char **bits )
+{
+ wxCHECK_RET( bits != NULL, _T("invalid bitmap data") )
+
+ 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 );
+
+ if (mask)
+ {
+ M_BMPDATA->m_mask = new wxMask();
+ M_BMPDATA->m_mask->m_bitmap = 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; // ?
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}