From c826213d964ac70ee34a6427eab557a0f25da524 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 27 Feb 2000 16:48:27 +0000 Subject: [PATCH] Added bitmap create git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/bitmap.h | 2 ++ include/wx/gtk1/bitmap.h | 2 ++ src/gtk/bitmap.cpp | 18 +++++++++++++----- src/gtk1/bitmap.cpp | 18 +++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 17ef650888..5096d3b8b5 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -74,6 +74,8 @@ public: bool operator != ( const wxBitmap& bmp ); bool Ok() const; + bool Create(int width, int height, int depth = -1); + int GetHeight() const; int GetWidth() const; int GetDepth() const; diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 17ef650888..5096d3b8b5 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -74,6 +74,8 @@ public: bool operator != ( const wxBitmap& bmp ); bool Ok() const; + bool Create(int width, int height, int depth = -1); + int GetHeight() const; int GetWidth() const; int GetDepth() const; diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index b85f97f63d..38d20c606c 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -243,15 +243,24 @@ wxBitmap::wxBitmap() wxBitmap::wxBitmap( int width, int height, int depth ) { - wxCHECK_RET( (width > 0) && (height > 0), wxT("invalid bitmap size") ) + Create( width, height, depth ); + + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); +} + +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_RET( (depth == visual->depth) || - (depth == 1), wxT("invalid bitmap depth") ) + wxCHECK_MSG( (depth == visual->depth) || + (depth == 1), FALSE, wxT("invalid bitmap depth") ) m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; @@ -268,9 +277,8 @@ wxBitmap::wxBitmap( int width, int height, int 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") ) diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index b85f97f63d..38d20c606c 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -243,15 +243,24 @@ wxBitmap::wxBitmap() wxBitmap::wxBitmap( int width, int height, int depth ) { - wxCHECK_RET( (width > 0) && (height > 0), wxT("invalid bitmap size") ) + Create( width, height, depth ); + + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); +} + +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_RET( (depth == visual->depth) || - (depth == 1), wxT("invalid bitmap depth") ) + wxCHECK_MSG( (depth == visual->depth) || + (depth == 1), FALSE, wxT("invalid bitmap depth") ) m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; @@ -268,9 +277,8 @@ wxBitmap::wxBitmap( int width, int height, int 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") ) -- 2.45.2