if (!bitmap.Ok()) return false;
- wxCHECK_MSG( bitmap.GetBitmap(), false, wxT("Cannot create mask from colour bitmap") );
+ wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
GdkGC *gc = gdk_gc_new( m_bitmap );
- gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );
+ gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetPixmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );
g_object_unref (gc);
~wxBitmapRefData();
GdkPixmap *m_pixmap;
- GdkBitmap *m_bitmap;
GdkPixbuf *m_pixbuf;
wxMask *m_mask;
int m_width;
wxBitmapRefData::wxBitmapRefData()
{
m_pixmap = (GdkPixmap *) NULL;
- m_bitmap = (GdkBitmap *) NULL;
m_pixbuf = (GdkPixbuf *) NULL;
m_mask = (wxMask *) NULL;
m_width = 0;
{
if (m_pixmap)
g_object_unref (m_pixmap);
- if (m_bitmap)
- g_object_unref (m_bitmap);
if (m_pixbuf)
g_object_unref (m_pixbuf);
delete m_mask;
//-----------------------------------------------------------------------------
-#define M_BMPDATA ((wxBitmapRefData *)m_refData)
+#define M_BMPDATA wx_static_cast(wxBitmapRefData*, m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
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( wxGetRootWindow()->window, width, height, 1 );
- M_BMPDATA->m_bpp = 1;
- }
- else if (depth == 32)
+ M_BMPDATA->m_bpp = depth;
+ if (depth == 32)
{
M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true,
8, width, height);
- M_BMPDATA->m_bpp = 32;
}
else
{
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
- M_BMPDATA->m_bpp = visual->depth;
}
return Ok();
GdkImage *img = (GdkImage*) NULL;
if (GetPixmap())
img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() );
- else if (GetBitmap())
- img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() );
else
wxFAIL_MSG( wxT("Ill-formed bitmap") );
GdkGC *gc = NULL;
GdkPixmap *dstpix = NULL;
- if (GetPixmap())
+ if (GetDepth() != 1)
{
GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() );
if (visual == NULL)
char *dst = NULL;
long dstbyteperline = 0;
- if (GetBitmap())
+ if (GetDepth() == 1)
{
bpp = 1;
dstbyteperline = width/8*M_BMPDATA->m_bpp;
SetHeight( height );
SetWidth( width );
- SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
+ SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 );
// Blit picture
- GdkGC *data_gc = gdk_gc_new( GetBitmap() );
+ GdkGC *data_gc = gdk_gc_new( GetPixmap() );
- gdk_draw_image( GetBitmap(), data_gc, data_image, 0, 0, 0, 0, width, height );
+ gdk_draw_image( GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height );
g_object_unref (data_image);
g_object_unref (data_gc);
0, 0,
GetWidth(), GetHeight() );
}
- else if (GetBitmap())
- {
- gdk_image = gdk_image_get( GetBitmap(),
- 0, 0,
- GetWidth(), GetHeight() );
- }
else
{
wxFAIL_MSG( wxT("Ill-formed bitmap") );
int blue_shift_left = 0;
bool use_shift = false;
- if (GetPixmap())
+ if (GetDepth() != 1)
{
GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() );
if (visual == NULL)
use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR);
}
- if (GetBitmap())
+ else
{
bpp = 1;
}
m_refData = new wxBitmapRefData();
M_BMPDATA->m_mask = (wxMask *) NULL;
- M_BMPDATA->m_bitmap = gdk_bitmap_create_from_data
+ M_BMPDATA->m_pixmap = gdk_bitmap_create_from_data
(
wxGetRootWindow()->window,
(gchar *) bits,
M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1;
- wxASSERT_MSG( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") );
+ wxASSERT_MSG( M_BMPDATA->m_pixmap, wxT("couldn't create bitmap") );
}
}
return (m_refData != NULL) &&
(
M_BMPDATA->m_pixbuf ||
- M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
+ M_BMPDATA->m_pixmap
);
}
}
else
{
- if (ret.GetPixmap())
+ if (ret.GetDepth() != 1)
{
GdkGC *gc = gdk_gc_new( ret.GetPixmap() );
gdk_draw_drawable( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
}
else
{
- GdkGC *gc = gdk_gc_new( ret.GetBitmap() );
+ GdkGC *gc = gdk_gc_new( ret.GetPixmap() );
GdkColor col;
col.pixel = 0xFFFFFF;
gdk_gc_set_foreground( gc, &col );
col.pixel = 0;
gdk_gc_set_background( gc, &col );
- gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
+ gdk_wx_draw_bitmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
g_object_unref (gc);
}
}
PurgeOtherRepresentations(Pixmap);
}
-void wxBitmap::SetBitmap( GdkPixmap *bitmap )
-{
- if (!m_refData)
- m_refData = new wxBitmapRefData();
-
- M_BMPDATA->m_bitmap = bitmap;
- PurgeOtherRepresentations(Pixmap);
-}
-
GdkPixmap *wxBitmap::GetPixmap() const
{
wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") );
return M_BMPDATA->m_pixmap != NULL;
}
-GdkBitmap *wxBitmap::GetBitmap() const
-{
- wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, wxT("invalid bitmap") );
-
- return M_BMPDATA->m_bitmap;
-}
-
GdkPixbuf *wxBitmap::GetPixbuf() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
- bool is_mono = (bitmap.GetBitmap() != NULL);
+ bool is_mono = bitmap.GetDepth() == 1;
// scale/translate size and position
int xx = XLOG2DEV(x);
GdkGC *gc = gdk_gc_new( bitmap2 );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
- gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
+ gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 );
GdkGC *gc = gdk_gc_new( bitmap );
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
- gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
+ gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 );
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok()))
{
- if (m_brush.GetStipple()->GetPixmap())
+ if (m_brush.GetStipple()->GetDepth() != 1)
{
gdk_gc_set_fill( m_brushGC, GDK_TILED );
gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() );
else
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
- gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() );
+ gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetPixmap() );
}
}
if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok()))
{
- if (m_backgroundBrush.GetStipple()->GetPixmap())
+ if (m_backgroundBrush.GetStipple()->GetDepth() != 1)
{
gdk_gc_set_fill( m_bgGC, GDK_TILED );
gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
else
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
- gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() );
+ gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
}
}
m_selected = bitmap;
if (m_selected.Ok())
{
- if (m_selected.GetPixmap())
- {
- m_window = m_selected.GetPixmap();
- }
- else
- {
- m_window = m_selected.GetBitmap();
- }
+ m_window = m_selected.GetPixmap();
m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
{
wxPen pen( penOrig );
if ( m_selected.Ok() &&
- m_selected.GetBitmap() &&
+ m_selected.GetDepth() == 1 &&
(pen != *wxTRANSPARENT_PEN) )
{
pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
{
wxBrush brush( brushOrig );
if ( m_selected.Ok() &&
- m_selected.GetBitmap() &&
+ m_selected.GetDepth() == 1 &&
(brush != *wxTRANSPARENT_BRUSH) )
{
brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
wxBrush brush(brushOrig);
if ( m_selected.Ok() &&
- m_selected.GetBitmap() &&
+ m_selected.GetDepth() == 1 &&
(brush != *wxTRANSPARENT_BRUSH) )
{
brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
void wxMemoryDC::SetTextForeground( const wxColour& col )
{
- if ( m_selected.Ok() && m_selected.GetBitmap() )
+ if ( m_selected.Ok() && m_selected.GetDepth() == 1 )
{
wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
}
void wxMemoryDC::SetTextBackground( const wxColour &col )
{
- if (m_selected.Ok() && m_selected.GetBitmap())
+ if (m_selected.Ok() && m_selected.GetDepth() == 1)
{
wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
}