diff --git a/include/wx/image.h b/include/wx/image.h index 09aa6ed4a2..05523dd6f0 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -89,6 +89,7 @@ class WXDLLEXPORT wxImage: public wxObject public: wxImage(); wxImage( int width, int height ); + wxImage( int width, int height, unsigned char* data, bool static_data = FALSE ); wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY ); wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY ); wxImage( const wxString& name, const wxString& mimetype ); @@ -106,6 +107,7 @@ public: #endif void Create( int width, int height ); + void Create( int width, int height, unsigned char* data, bool static_data = FALSE ); void Destroy(); // return the new image with size width*height @@ -156,7 +158,8 @@ public: char unsigned *GetData() const; void SetData( char unsigned *data ); - + void SetData( char unsigned *data, int new_width, int new_height ); + void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); unsigned char GetMaskRed() const; unsigned char GetMaskGreen() const; diff --git a/src/common/image.cpp b/src/common/image.cpp index c563e42248..2632b75583 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -56,6 +56,7 @@ public: bool m_hasMask; unsigned char m_maskRed,m_maskGreen,m_maskBlue; bool m_ok; + bool m_static; }; wxImageRefData::wxImageRefData() @@ -68,11 +69,12 @@ wxImageRefData::wxImageRefData() m_maskGreen = 0; m_maskBlue = 0; m_hasMask = FALSE; + m_static = FALSE; } wxImageRefData::~wxImageRefData() { - if (m_data) + if (m_data && !m_static) free( m_data ); } @@ -93,6 +95,11 @@ wxImage::wxImage( int width, int height ) Create( width, height ); } +wxImage::wxImage( int width, int height, unsigned char* data, bool static_data ) +{ + Create( width, height, data, static_data ); +} + wxImage::wxImage( const wxString& name, long type ) { LoadFile( name, type ); @@ -146,6 +153,26 @@ void wxImage::Create( int width, int height ) } } +void wxImage::Create( int width, int height, unsigned char* data, bool static_data ) +{ + UnRef(); + + m_refData = new wxImageRefData(); + + M_IMGDATA->m_data = data; + if (M_IMGDATA->m_data) + { + M_IMGDATA->m_width = width; + M_IMGDATA->m_height = height; + M_IMGDATA->m_ok = TRUE; + M_IMGDATA->m_static = static_data; + } + else + { + UnRef(); + } +} + void wxImage::Destroy() { UnRef(); @@ -340,6 +367,34 @@ void wxImage::SetData( char unsigned *data ) m_refData = newRefData; } +void wxImage::SetData( char unsigned *data, int new_width, int new_height ) +{ + wxImageRefData *newRefData = new wxImageRefData(); + + if (m_refData) + { + newRefData->m_width = new_width; + newRefData->m_height = new_height; + newRefData->m_data = data; + newRefData->m_ok = TRUE; + newRefData->m_maskRed = M_IMGDATA->m_maskRed; + newRefData->m_maskGreen = M_IMGDATA->m_maskGreen; + newRefData->m_maskBlue = M_IMGDATA->m_maskBlue; + newRefData->m_hasMask = M_IMGDATA->m_hasMask; + } + else + { + newRefData->m_width = new_width; + newRefData->m_height = new_height; + newRefData->m_data = data; + newRefData->m_ok = TRUE; + } + + UnRef(); + + m_refData = newRefData; +} + void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) { wxCHECK_RET( Ok(), wxT("invalid image") ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a52621f8d4..91580d8320 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2579,9 +2579,15 @@ void wxWindow::OnInternalIdle() bool child_already_resized = FALSE; if (IsTopLevel() && !m_isFrame) - child_already_resized = gtk_pizza_child_resized( GTK_PIZZA(m_wxwindow->parent), m_wxwindow ); + { + child_already_resized = ((m_wxwindow->parent) && + (gtk_pizza_child_resized( GTK_PIZZA(m_wxwindow->parent), m_wxwindow ))); + } else - child_already_resized = gtk_pizza_child_resized( GTK_PIZZA(m_widget->parent), m_widget ); + { + child_already_resized = ((m_widget->parent) && + (gtk_pizza_child_resized( GTK_PIZZA(m_widget->parent), m_widget ))); + } if (child_already_resized) { diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index a52621f8d4..91580d8320 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2579,9 +2579,15 @@ void wxWindow::OnInternalIdle() bool child_already_resized = FALSE; if (IsTopLevel() && !m_isFrame) - child_already_resized = gtk_pizza_child_resized( GTK_PIZZA(m_wxwindow->parent), m_wxwindow ); + { + child_already_resized = ((m_wxwindow->parent) && + (gtk_pizza_child_resized( GTK_PIZZA(m_wxwindow->parent), m_wxwindow ))); + } else - child_already_resized = gtk_pizza_child_resized( GTK_PIZZA(m_widget->parent), m_widget ); + { + child_already_resized = ((m_widget->parent) && + (gtk_pizza_child_resized( GTK_PIZZA(m_widget->parent), m_widget ))); + } if (child_already_resized) {