From e45080c10b11190028e843b617564caec95e82dd Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 14 Jan 2008 18:16:37 +0000 Subject: [PATCH] make XPM data pointer parameter fully const git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51211 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/icon.tex | 4 +--- include/wx/cocoa/icon.h | 5 ++--- include/wx/gdicmn.h | 10 +++++----- include/wx/generic/icon.h | 6 ++++-- include/wx/mac/carbon/cursor.h | 5 ++--- include/wx/mac/carbon/dnd.h | 2 +- include/wx/mac/carbon/icon.h | 3 +-- include/wx/motif/icon.h | 4 +++- include/wx/msw/icon.h | 10 +++++----- include/wx/os2/icon.h | 8 +++++--- src/cocoa/icon.mm | 2 +- src/generic/icon.cpp | 6 ++++-- src/mac/carbon/cursor.cpp | 9 ++------- src/mac/carbon/icon.cpp | 8 +------- src/motif/icon.cpp | 4 +++- src/msw/icon.cpp | 2 +- src/os2/icon.cpp | 4 +--- 17 files changed, 42 insertions(+), 50 deletions(-) diff --git a/docs/latex/wx/icon.tex b/docs/latex/wx/icon.tex index 5199f35c44..3dbb8fe78d 100644 --- a/docs/latex/wx/icon.tex +++ b/docs/latex/wx/icon.tex @@ -78,9 +78,7 @@ Creates an icon from an array of bits. Creates a new icon. -\func{}{wxIcon}{\param{char**}{ bits}} - -\func{}{wxIcon}{\param{const char**}{ bits}} +\func{}{wxIcon}{\param{const char* const*}{ bits}} Creates an icon from XPM data. diff --git a/include/wx/cocoa/icon.h b/include/wx/cocoa/icon.h index 478e2271b8..be697125de 100644 --- a/include/wx/cocoa/icon.h +++ b/include/wx/cocoa/icon.h @@ -23,8 +23,7 @@ class WXDLLEXPORT wxIcon : public wxGDIObject public: wxIcon(); - wxIcon(const char **data) { CreateFromXpm(data); } - wxIcon(char **data) { CreateFromXpm((const char**)data); } + wxIcon(const char* const* data) { CreateFromXpm(data); } wxIcon(const char bits[], int width , int height ); wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); @@ -52,7 +51,7 @@ public: int GetHeight() const; WX_NSImage GetNSImage() const; - bool CreateFromXpm(const char **bits); + bool CreateFromXpm(const char* const* bits); protected: virtual wxGDIRefData *CreateGDIRefData() const; diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index a5cee500fc..8e5bf5ffd1 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -158,16 +158,16 @@ enum wxStockCursor #define wxICON(X) wxIcon(wxT(#X)) #elif defined(__WXMGL__) // Initialize from an included XPM - #define wxICON(X) wxIcon( (const char**) X##_xpm ) + #define wxICON(X) wxIcon( X##_xpm ) #elif defined(__WXDFB__) // Initialize from an included XPM - #define wxICON(X) wxIcon( (const char**) X##_xpm ) + #define wxICON(X) wxIcon( X##_xpm ) #elif defined(__WXGTK__) // Initialize from an included XPM - #define wxICON(X) wxIcon( (const char**) X##_xpm ) + #define wxICON(X) wxIcon( X##_xpm ) #elif defined(__WXMAC__) // Initialize from an included XPM - #define wxICON(X) wxIcon( (const char**) X##_xpm ) + #define wxICON(X) wxIcon( X##_xpm ) #elif defined(__WXMOTIF__) // Initialize from an included XPM #define wxICON(X) wxIcon( X##_xpm ) @@ -193,7 +193,7 @@ enum wxStockCursor defined(__WXDFB__) || \ defined(__WXCOCOA__) // Initialize from an included XPM - #define wxBITMAP(name) wxBitmap( (const char**) name##_xpm ) + #define wxBITMAP(name) wxBitmap(name##_xpm) #else // other platforms #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM) #endif // platform diff --git a/include/wx/generic/icon.h b/include/wx/generic/icon.h index 03ffbbef90..b73d919c9c 100644 --- a/include/wx/generic/icon.h +++ b/include/wx/generic/icon.h @@ -27,8 +27,10 @@ class WXDLLIMPEXP_CORE wxIcon: public wxBitmap public: wxIcon(); - wxIcon( const char **bits, int width=-1, int height=-1 ); - wxIcon( char **bits, int width=-1, int height=-1 ); + wxIcon(const char* const* bits); +#ifdef wxNEEDS_CHARPP + wxIcon(char **bits); +#endif // For compatibility with wxMSW where desired size is sometimes required to // distinguish between multiple icons in a resource. diff --git a/include/wx/mac/carbon/cursor.h b/include/wx/mac/carbon/cursor.h index 9e1d4e0a55..7b56e231f6 100644 --- a/include/wx/mac/carbon/cursor.h +++ b/include/wx/mac/carbon/cursor.h @@ -25,15 +25,14 @@ public: const char maskBits[] = NULL); wxCursor(const wxImage & image) ; - wxCursor(const char **bits) ; - wxCursor(char **bits) ; + wxCursor(const char* const* bits); wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_MACCURSOR_RESOURCE, int hotSpotX = 0, int hotSpotY = 0); wxCursor(int cursor_type); virtual ~wxCursor(); - bool CreateFromXpm(const char **bits) ; + bool CreateFromXpm(const char* const* bits); void MacInstall() const ; diff --git a/include/wx/mac/carbon/dnd.h b/include/wx/mac/carbon/dnd.h index 946be102cb..fc7dc9a300 100644 --- a/include/wx/mac/carbon/dnd.h +++ b/include/wx/mac/carbon/dnd.h @@ -39,7 +39,7 @@ class WXDLLIMPEXP_FWD_CORE wxDropSource; // the icon 'name' from an XPM file under GTK, but will expand to something // else under MSW. If you don't use it, you will have to use #ifdef in the // application code. -#define wxDROP_ICON(X) wxCursor( (const char**) X##_xpm ) +#define wxDROP_ICON(X) wxCursor(X##_xpm) //------------------------------------------------------------------------- // wxDropTarget diff --git a/include/wx/mac/carbon/icon.h b/include/wx/mac/carbon/icon.h index ead16ba56b..8fae1eb6bf 100644 --- a/include/wx/mac/carbon/icon.h +++ b/include/wx/mac/carbon/icon.h @@ -20,8 +20,7 @@ class WXDLLEXPORT wxIcon : public wxGDIObject public: wxIcon(); - wxIcon(const char **data); - wxIcon(char **data); + wxIcon(const char* const* data); wxIcon(const char bits[], int width , int height ); wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); diff --git a/include/wx/motif/icon.h b/include/wx/motif/icon.h index 0be2892759..73a295d95d 100644 --- a/include/wx/motif/icon.h +++ b/include/wx/motif/icon.h @@ -24,8 +24,10 @@ public: wxIcon(const char bits[], int width, int height); // Initialize with XPM data - wxIcon(const char **data); + wxIcon(const char* const* data); +#ifdef wxNEEDS_CHARPP wxIcon(char **data); +#endif wxIcon(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM, int desiredWidth = -1, int desiredHeight = -1) diff --git a/include/wx/msw/icon.h b/include/wx/msw/icon.h index c4b420937c..7984f79d37 100644 --- a/include/wx/msw/icon.h +++ b/include/wx/msw/icon.h @@ -48,10 +48,10 @@ public: wxIcon(const char bits[], int width, int height); // from XPM data - wxIcon(const char **data) { CreateIconFromXpm(data); } - - wxIcon(char **data) { CreateIconFromXpm((const char **)data); } - + wxIcon(const char* const* data) { CreateIconFromXpm(data); } +#ifdef wxNEEDS_CHARPP + wxIcon(char **data) { CreateIconFromXpm(wx_const_cast(const char* const*, data)); } +#endif // from resource/file wxIcon(const wxString& name, long type = wxBITMAP_TYPE_ICO_RESOURCE, @@ -85,7 +85,7 @@ protected: virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; // create from XPM data - void CreateIconFromXpm(const char **data); + void CreateIconFromXpm(const char* const* data); private: DECLARE_DYNAMIC_CLASS(wxIcon) diff --git a/include/wx/os2/icon.h b/include/wx/os2/icon.h index af4208791d..b86db3388f 100644 --- a/include/wx/os2/icon.h +++ b/include/wx/os2/icon.h @@ -44,8 +44,10 @@ public: ,int nWidth ,int nHeight ); - inline wxIcon(const char** ppData) { CreateIconFromXpm(ppData); } - inline wxIcon(char** ppData) { CreateIconFromXpm((const char**)ppData); } + wxIcon(const char* const* ppData) { CreateIconFromXpm(ppData); } +#ifdef wxNEEDS_CHARPP + wxIcon(char** ppData) { CreateIconFromXpm(wx_const_cast(const char* const*, ppData)); } +#endif wxIcon( const wxString& rName ,long lFlags = wxBITMAP_TYPE_ICO_RESOURCE ,int nDesiredWidth = -1 @@ -77,7 +79,7 @@ protected: { return new wxIconRefData; } - void CreateIconFromXpm(const char **ppData); + void CreateIconFromXpm(const char* const* ppData); private: bool m_bIsXpm; diff --git a/src/cocoa/icon.mm b/src/cocoa/icon.mm index cfc23d3cd7..44983b7272 100644 --- a/src/cocoa/icon.mm +++ b/src/cocoa/icon.mm @@ -110,7 +110,7 @@ wxGDIRefData *wxIcon::CloneGDIRefData(const wxGDIRefData *data) const return new wxIconRefData(*wx_static_cast(const wxIconRefData *, data)); } -bool wxIcon::CreateFromXpm(const char **xpm) +bool wxIcon::CreateFromXpm(const char* const* xpm) { wxBitmap bitmap(xpm); CopyFromBitmap(bitmap); diff --git a/src/generic/icon.cpp b/src/generic/icon.cpp index 0e79576a15..e545457f35 100644 --- a/src/generic/icon.cpp +++ b/src/generic/icon.cpp @@ -24,15 +24,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) -wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : +wxIcon::wxIcon(const char* const* bits) : wxBitmap( bits ) { } -wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : +#ifdef wxNEEDS_CHARPP +wxIcon::wxIcon(char **bits) : wxBitmap( bits ) { } +#endif wxIcon::wxIcon() : wxBitmap() { diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index 7326c9ca8a..0b8e4c8a7b 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -276,16 +276,11 @@ wxCursor::wxCursor( const wxImage &image ) #endif } -wxCursor::wxCursor(const char **bits) +wxCursor::wxCursor(const char* const* bits) { (void) CreateFromXpm(bits); } -wxCursor::wxCursor(char **bits) -{ - (void) CreateFromXpm((const char **)bits); -} - wxGDIRefData *wxCursor::CreateGDIRefData() const { return new wxCursorRefData; @@ -296,7 +291,7 @@ wxGDIRefData *wxCursor::CloneGDIRefData(const wxGDIRefData *data) const return new wxCursorRefData(*wx_static_cast(const wxCursorRefData *, data)); } -bool wxCursor::CreateFromXpm(const char **bits) +bool wxCursor::CreateFromXpm(const char* const* bits) { #if wxUSE_IMAGE wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") ); diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index 004b47fc6e..a19042a3e5 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -90,13 +90,7 @@ wxIcon::wxIcon( const char bits[], int width, int height ) CopyFromBitmap( bmp ) ; } -wxIcon::wxIcon( const char **bits ) -{ - wxBitmap bmp( bits ) ; - CopyFromBitmap( bmp ) ; -} - -wxIcon::wxIcon( char **bits ) +wxIcon::wxIcon(const char* const* bits) { wxBitmap bmp( bits ) ; CopyFromBitmap( bmp ) ; diff --git a/src/motif/icon.cpp b/src/motif/icon.cpp index b0a0168c51..eaa688689b 100644 --- a/src/motif/icon.cpp +++ b/src/motif/icon.cpp @@ -30,13 +30,15 @@ wxIcon::wxIcon(const char bits[], int width, int height) (void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, 1); } +#ifdef wxNEEDS_CHARPP // Create from XPM data wxIcon::wxIcon(char **data) { (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } +#endif -wxIcon::wxIcon(const char **data) +wxIcon::wxIcon(const char* const* data) { (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } diff --git a/src/msw/icon.cpp b/src/msw/icon.cpp index ebf8f49d98..ee899f2b8a 100644 --- a/src/msw/icon.cpp +++ b/src/msw/icon.cpp @@ -128,7 +128,7 @@ void wxIcon::CopyFromBitmap(const wxBitmap& bmp) #endif // __WXMICROWIN__ } -void wxIcon::CreateIconFromXpm(const char **data) +void wxIcon::CreateIconFromXpm(const char* const* data) { wxBitmap bmp(data); CopyFromBitmap(bmp); diff --git a/src/os2/icon.cpp b/src/os2/icon.cpp index 7f2746b4a2..a25b0fb21d 100644 --- a/src/os2/icon.cpp +++ b/src/os2/icon.cpp @@ -85,9 +85,7 @@ wxIcon::~wxIcon() { } -void wxIcon::CreateIconFromXpm( - const char** ppData -) +void wxIcon::CreateIconFromXpm(const char* const* ppData) { wxBitmap vBmp(ppData); -- 2.45.2