wxMask *GetMask() const;
void SetMask( wxMask *mask );
+
+ wxBitmap GetSubBitmap( const wxRect& rect ) const;
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
wxMask *GetMask() const;
void SetMask( wxMask *mask );
+
+ wxBitmap GetSubBitmap( const wxRect& rect ) const;
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
dc.SetPen( *wxWHITE_PEN );
dc.DrawRectangle( 150, 30, 100, 100 );
- if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 250, 140 );
+ if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 280, 30 );
dc.DrawText( "PNG handler", 30, 135 );
- if (my_horse_png && my_horse_png->Ok()) dc.DrawBitmap( *my_horse_png, 30, 150 );
+ if (my_horse_png && my_horse_png->Ok())
+ {
+ dc.DrawBitmap( *my_horse_png, 30, 150 );
+ wxRect rect(0,0,100,100);
+ wxBitmap sub( my_horse_png->GetSubBitmap(rect) );
+ dc.DrawText( "GetSubBitmap()", 280, 190 );
+ dc.DrawBitmap( sub, 280, 210 );
+ }
dc.DrawText( "JPEG handler", 30, 365 );
if (my_horse_jpeg && my_horse_jpeg->Ok()) dc.DrawBitmap( *my_horse_jpeg, 30, 380 );
for (unsigned int i=0; i<m_paths.Count(); i++)
{
- dir_item = new wxDirItemData(m_paths[i],m_names[i]);
+ dir_item = new wxDirItemData(m_paths[i],m_names[i]);
#ifdef __WXMSW__
- id = AppendItem( parent, m_names[i], -1, -1, dir_item);
+ id = AppendItem( parent, m_names[i], -1, -1, dir_item);
#else
- id = AppendItem( parent, m_names[i], 0, 1, dir_item);
+ id = AppendItem( parent, m_names[i], 0, -1, dir_item);
+ SetItemImage( id, 1, wxTreeItemIcon_Expanded );
#endif
if (dir_item->m_hasSubDirs) SetItemHasChildren(id);
}
M_BMPDATA->m_mask = mask;
}
+wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
+{
+ wxCHECK_MSG( Ok() &&
+ (rect.x >= 0) && (rect.y >= 0) &&
+ (rect.x+rect.width <= M_BMPDATA->m_width) && (rect.y+rect.height <= M_BMPDATA->m_height),
+ wxNullBitmap, wxT("invalid bitmap or bitmap region") );
+
+ wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp );
+ wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
+
+ if (ret.GetPixmap())
+ {
+ GdkGC *gc = gdk_gc_new( ret.GetPixmap() );
+ gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
+ gdk_gc_destroy( gc );
+ }
+ else
+ {
+ GdkGC *gc = gdk_gc_new( ret.GetBitmap() );
+ gdk_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
+ gdk_gc_destroy( gc );
+ }
+
+ if (GetMask())
+ {
+ wxMask *mask = new wxMask;
+ GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+ mask->m_bitmap = gdk_pixmap_new( parent, 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 );
+ gdk_gc_destroy( gc );
+
+ ret.SetMask( mask );
+ }
+
+ return ret;
+}
+
bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
M_BMPDATA->m_mask = mask;
}
+wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
+{
+ wxCHECK_MSG( Ok() &&
+ (rect.x >= 0) && (rect.y >= 0) &&
+ (rect.x+rect.width <= M_BMPDATA->m_width) && (rect.y+rect.height <= M_BMPDATA->m_height),
+ wxNullBitmap, wxT("invalid bitmap or bitmap region") );
+
+ wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp );
+ wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
+
+ if (ret.GetPixmap())
+ {
+ GdkGC *gc = gdk_gc_new( ret.GetPixmap() );
+ gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
+ gdk_gc_destroy( gc );
+ }
+ else
+ {
+ GdkGC *gc = gdk_gc_new( ret.GetBitmap() );
+ gdk_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height );
+ gdk_gc_destroy( gc );
+ }
+
+ if (GetMask())
+ {
+ wxMask *mask = new wxMask;
+ GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+ mask->m_bitmap = gdk_pixmap_new( parent, 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 );
+ gdk_gc_destroy( gc );
+
+ ret.SetMask( mask );
+ }
+
+ return ret;
+}
+
bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );