diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 52c2f98cea..61ce45e2de 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -709,7 +709,7 @@ public: wxDataViewItem GetCurrentItem() const; void SetCurrentItem(const wxDataViewItem& item); - virtual wxDataViewItem GetTopItem() const { return wxDataViewItem(0); } + virtual wxDataViewItem GetTopItem() const { return wxDataViewItem(NULL); } virtual int GetCountPerPage() const { return wxNOT_FOUND; } // Currently focused column of the current item or NULL if no column has focus diff --git a/include/wx/dc.h b/include/wx/dc.h index cc0a48238e..088c22c683 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -1327,7 +1327,7 @@ public: : m_dc(thdc.m_dc), m_hdc(thdc.m_hdc) { - const_cast(thdc).m_hdc = 0; + const_cast(thdc).m_hdc = NULL; } ~TempHDC() diff --git a/include/wx/dynlib.h b/include/wx/dynlib.h index 0f035d904f..4ea6b8a60c 100644 --- a/include/wx/dynlib.h +++ b/include/wx/dynlib.h @@ -231,9 +231,9 @@ public: // return the platform standard DLL extension (with leading dot) static wxString GetDllExt(wxDynamicLibraryCategory cat = wxDL_LIBRARY); - wxDynamicLibrary() : m_handle(0) { } + wxDynamicLibrary() : m_handle(NULL) { } wxDynamicLibrary(const wxString& libname, int flags = wxDL_DEFAULT) - : m_handle(0) + : m_handle(NULL) { Load(libname, flags); } @@ -243,7 +243,7 @@ public: ~wxDynamicLibrary() { Unload(); } // return true if the library was loaded successfully - bool IsLoaded() const { return m_handle != 0; } + bool IsLoaded() const { return m_handle != NULL; } // load the library with the given name (full or not), return true if ok bool Load(const wxString& libname, int flags = wxDL_DEFAULT); @@ -256,13 +256,13 @@ public: // detach the library object from its handle, i.e. prevent the object from // unloading the library in its dtor -- the caller is now responsible for // doing this - wxDllType Detach() { wxDllType h = m_handle; m_handle = 0; return h; } + wxDllType Detach() { wxDllType h = m_handle; m_handle = NULL; return h; } // unload the given library handle (presumably returned by Detach() before) static void Unload(wxDllType handle); // unload the library, also done automatically in dtor - void Unload() { if ( IsLoaded() ) { Unload(m_handle); m_handle = 0; } } + void Unload() { if ( IsLoaded() ) { Unload(m_handle); m_handle = NULL; } } // Return the raw handle from dlopen and friends. wxDllType GetLibHandle() const { return m_handle; } @@ -363,7 +363,7 @@ public: protected: // common part of GetSymbol() and HasSymbol() - void *DoGetSymbol(const wxString& name, bool *success = 0) const; + void* DoGetSymbol(const wxString& name, bool* success = NULL) const; #ifdef wxHAVE_DYNLIB_ERROR // log the error after a dlxxx() function failure diff --git a/include/wx/dynload.h b/include/wx/dynload.h index 7cb4d25bac..79239cbf11 100644 --- a/include/wx/dynload.h +++ b/include/wx/dynload.h @@ -123,7 +123,7 @@ public: void Unload(); bool IsLoaded() const { return m_entry && m_entry->IsLoaded(); } - void *GetSymbol(const wxString &symbol, bool *success = 0) + void* GetSymbol(const wxString& symbol, bool* success = NULL) { return m_entry->GetSymbol( symbol, success ); } diff --git a/include/wx/event.h b/include/wx/event.h index fd25c7a1ca..482758b7a2 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -91,7 +91,7 @@ typedef int wxEventType; wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj) #define wxDECLARE_EVENT_TABLE_TERMINATOR() \ - wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) + wxEventTableEntry(wxEVT_NULL, 0, 0, NULL, NULL) // generate a new unique event type extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); diff --git a/include/wx/gdiobj.h b/include/wx/gdiobj.h index 81d1f46a6b..d8e7956006 100644 --- a/include/wx/gdiobj.h +++ b/include/wx/gdiobj.h @@ -66,7 +66,7 @@ public: virtual bool IsFree() const { return false; } // Returns handle. - virtual WXHANDLE GetResourceHandle() const { return 0; } + virtual WXHANDLE GetResourceHandle() const { return NULL; } #endif // defined(__WXMSW__) protected: diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index 554413d44c..00a318983d 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -257,7 +257,7 @@ public: // pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants. // You can set different header/footer for odd and even pages - void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = 0); + void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int* sizes = NULL); // Sets fonts to be used when displaying HTML page. (if size null then default sizes used) // Sets font sizes to be relative to the given size or the system diff --git a/include/wx/msw/dib.h b/include/wx/msw/dib.h index 3b068879bc..29cf56a202 100644 --- a/include/wx/msw/dib.h +++ b/include/wx/msw/dib.h @@ -73,11 +73,11 @@ public: // create a bitmap compatible with the given HDC (or screen by default) and // return its handle, the caller is responsible for freeing it (using // DeleteObject()) - HBITMAP CreateDDB(HDC hdc = 0) const; + HBITMAP CreateDDB(HDC hdc = NULL) const; // get the handle from the DIB and reset it, i.e. this object won't destroy // the DIB after this (but the caller should do it) - HBITMAP Detach() { HBITMAP hbmp = m_handle; m_handle = 0; return hbmp; } + HBITMAP Detach() { HBITMAP hbmp = m_handle; m_handle = NULL; return hbmp; } #if defined(__WXMSW__) && wxUSE_PALETTE // create a palette for this DIB (always a trivial/default one for 24bpp) @@ -92,7 +92,7 @@ public: // --------- // return true if DIB was successfully created, false otherwise - bool IsOk() const { return m_handle != 0; } + bool IsOk() const { return m_handle != NULL; } // get the bitmap size wxSize GetSize() const { DoGetObject(); return wxSize(m_width, m_height); } @@ -121,7 +121,7 @@ public: // a plain DIB or a DIB section (in which case the last parameter must be // non NULL) static HBITMAP ConvertToBitmap(const BITMAPINFO *pbi, - HDC hdc = 0, + HDC hdc = NULL, const void *bits = NULL); // create a plain DIB (not a DIB section) from a DDB, the caller is @@ -242,7 +242,7 @@ private: inline void wxDIB::Init() { - m_handle = 0; + m_handle = NULL; m_ownsHandle = true; m_data = NULL; diff --git a/include/wx/msw/enhmeta.h b/include/wx/msw/enhmeta.h index bd6c5f729e..80f380cf31 100644 --- a/include/wx/msw/enhmeta.h +++ b/include/wx/msw/enhmeta.h @@ -43,7 +43,7 @@ public: bool Play(wxDC *dc, wxRect *rectBound = NULL); // accessors - virtual bool IsOk() const wxOVERRIDE { return m_hMF != 0; } + virtual bool IsOk() const wxOVERRIDE { return m_hMF != NULL; } wxSize GetSize() const; int GetWidth() const { return GetSize().x; } @@ -59,7 +59,7 @@ public: // Detach the HENHMETAFILE from this object, i.e. don't delete the handle // in the dtor -- the caller is now responsible for doing this, e.g. using // Free() method below. - WXHANDLE Detach() { WXHANDLE h = m_hMF; m_hMF = 0; return h; } + WXHANDLE Detach() { WXHANDLE h = m_hMF; m_hMF = NULL; return h; } // Destroy the given HENHMETAFILE object. static void Free(WXHANDLE handle); diff --git a/include/wx/msw/font.h b/include/wx/msw/font.h index 70ede34b88..ed75e8890f 100644 --- a/include/wx/msw/font.h +++ b/include/wx/msw/font.h @@ -65,7 +65,7 @@ public: underlined, face, encoding); } - wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0) + wxFont(const wxNativeFontInfo& info, WXHFONT hFont = NULL) { Create(info, hFont); } @@ -90,7 +90,7 @@ public: encoding)); } - bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0); + bool Create(const wxNativeFontInfo& info, WXHFONT hFont = NULL); virtual ~wxFont(); diff --git a/include/wx/msw/gdiimage.h b/include/wx/msw/gdiimage.h index 9f39219c67..94b6f01091 100644 --- a/include/wx/msw/gdiimage.h +++ b/include/wx/msw/gdiimage.h @@ -36,7 +36,7 @@ public: { m_width = m_height = m_depth = 0; - m_handle = 0; + m_handle = NULL; } wxGDIImageRefData(const wxGDIImageRefData& data) : wxGDIRefData() @@ -50,7 +50,7 @@ public: } // accessors - virtual bool IsOk() const wxOVERRIDE { return m_handle != 0; } + virtual bool IsOk() const wxOVERRIDE { return m_handle != NULL; } void SetSize(int w, int h) { m_width = w; m_height = h; } @@ -104,7 +104,7 @@ public: // accessors WXHANDLE GetHandle() const - { return IsNull() ? 0 : GetGDIImageData()->m_handle; } + { return IsNull() ? NULL : GetGDIImageData()->m_handle; } void SetHandle(WXHANDLE handle) { AllocExclusive(); GetGDIImageData()->m_handle = handle; } diff --git a/include/wx/msw/ole/automtn.h b/include/wx/msw/ole/automtn.h index 1d1eb33af3..beea810f6e 100644 --- a/include/wx/msw/ole/automtn.h +++ b/include/wx/msw/ole/automtn.h @@ -67,7 +67,7 @@ public: // Low-level invocation function. Pass either an array of variants, // or an array of pointers to variants. bool Invoke(const wxString& member, int action, - wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const; + wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = NULL) const; // Invoke a member function wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]); diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index e413799050..9dc7357958 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -162,7 +162,8 @@ protected: // implicitly convertible to HANDLE, which is a pointer. static HANDLE InvalidHandle() { - return reinterpret_cast(INVALID_VALUE); + wxUIntPtr h = INVALID_VALUE; + return reinterpret_cast(h); } void DoClose() @@ -449,7 +450,7 @@ private: class MemoryHDC { public: - MemoryHDC(HDC hdc = 0) { m_hdc = ::CreateCompatibleDC(hdc); } + MemoryHDC(HDC hdc = NULL) { m_hdc = ::CreateCompatibleDC(hdc); } ~MemoryHDC() { ::DeleteDC(m_hdc); } operator HDC() const { return m_hdc; } @@ -483,7 +484,7 @@ public: ~SelectInHDC() { if ( m_hdc ) ::SelectObject(m_hdc, m_hgdiobj); } // return true if the object was successfully selected - operator bool() const { return m_hgdiobj != 0; } + operator bool() const { return m_hgdiobj != NULL; } private: HDC m_hdc; @@ -578,7 +579,7 @@ class MonoBitmap : public AutoHBITMAP { public: MonoBitmap(int w, int h) - : AutoHBITMAP(::CreateBitmap(w, h, 1, 1, 0)) + : AutoHBITMAP(::CreateBitmap(w, h, 1, 1, NULL)) { } }; diff --git a/include/wx/msw/registry.h b/include/wx/msw/registry.h index 783706f4e4..ae43a075ba 100644 --- a/include/wx/msw/registry.h +++ b/include/wx/msw/registry.h @@ -136,7 +136,7 @@ public: size_t *pnValues, // number of values size_t *pnMaxValueLen) const; // return true if the key is opened - bool IsOpened() const { return m_hKey != 0; } + bool IsOpened() const { return m_hKey != NULL; } // for "if ( !key ) wxLogError(...)" kind of expressions operator bool() const { return m_dwLastError == 0; } diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 230d099b27..47203237f1 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -453,7 +453,7 @@ public: // The brush returned from here must remain valid at least until the next // event loop iteration. Returning 0, as is done by default, indicates // there is no custom background brush. - virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; } + virtual WXHBRUSH MSWGetCustomBgBrush() { return NULL; } // this function should return the brush to paint the children controls // background or 0 if this window doesn't impose any particular background diff --git a/include/wx/object.h b/include/wx/object.h index 1dd57cd654..f210ec0faf 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -150,7 +150,7 @@ name##PluginSentinel m_pluginsentinel // The 'this' pointer is always true, so use this version // to cast the this pointer and avoid compiler warnings. #define wxDynamicCastThis(className) \ - (IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0) + (IsKindOf(&className::ms_classInfo) ? (className*)this : NULL) template inline T *wxCheckCast(const void *ptr) diff --git a/include/wx/quantize.h b/include/wx/quantize.h index 366194f1f3..b3a722df8c 100644 --- a/include/wx/quantize.h +++ b/include/wx/quantize.h @@ -52,13 +52,13 @@ public: // If you pass a palette pointer, you must free the palette yourself. static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours = 236, - unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); + unsigned char** eightBitData = NULL, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); // This version sets a palette in the destination image so you don't // have to manage it yourself. static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236, - unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); + unsigned char** eightBitData = NULL, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); //// Helpers diff --git a/include/wx/rtti.h b/include/wx/rtti.h index 34d8d387bf..55deaf301a 100644 --- a/include/wx/rtti.h +++ b/include/wx/rtti.h @@ -62,7 +62,7 @@ public: ~wxClassInfo(); wxObject *CreateObject() const - { return m_objectConstructor ? (*m_objectConstructor)() : 0; } + { return m_objectConstructor ? (*m_objectConstructor)() : NULL; } bool IsDynamic() const { return (NULL != m_objectConstructor); } const wxChar *GetClassName() const { return m_className; } diff --git a/include/wx/thread.h b/include/wx/thread.h index 872609ca30..5e90bb63ab 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -598,7 +598,7 @@ public: protected: // exits from the current thread - can be called only from this thread - void Exit(ExitCode exitcode = 0); + void Exit(ExitCode exitcode = NULL); // entry point for the thread - called by Run() and executes in the context // of this thread. diff --git a/include/wx/translation.h b/include/wx/translation.h index 3d5d5b0b83..df43a6def8 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -247,7 +247,7 @@ protected: virtual wxString GetResourceType() const { return "MOFILE"; } // returns module to load resources from - virtual WXHINSTANCE GetModule() const { return 0; } + virtual WXHINSTANCE GetModule() const { return NULL; } }; #endif // __WINDOWS__ diff --git a/include/wx/utils.h b/include/wx/utils.h index 8e0996f24a..0a8e6371c6 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -840,7 +840,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded(); size_t *outLen, const wxString& resourceName, const wxChar* resourceType = wxUserResourceStr, - WXHINSTANCE module = 0); + WXHINSTANCE module = NULL); // This function allocates a new buffer and makes a copy of the resource // data, remember to delete[] the buffer. And avoid using it entirely if @@ -851,7 +851,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded(); wxLoadUserResource(const wxString& resourceName, const wxChar* resourceType = wxUserResourceStr, int* pLen = NULL, - WXHINSTANCE module = 0); + WXHINSTANCE module = NULL); #endif // __WINDOWS__ #endif diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index d239f6cfeb..97686b0221 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -858,21 +858,20 @@ template<> struct wxStrtoxCharType template inline double wxStrtod(const wxString& nptr, T endptr) { - // Explicit comparison with 0 required when using T=nullptr with MSVS 2012. - if (endptr != 0) + if (!endptr) { - // note that it is important to use c_str() here and not mb_str() or - // wc_str(), because we store the pointer into (possibly converted) - // buffer in endptr and so it must be valid even when wxStrtod() returns - typedef typename wxStrtoxCharType::Type CharType; - return wxStrtod((CharType)nptr.c_str(), - wxStrtoxCharType::AsPointer(endptr)); + // when we don't care about endptr, use the string representation that + // doesn't require any conversion (it doesn't matter for this function + // even if its UTF-8): + wxStringCharType** p = NULL; + return wxStrtod(nptr.wx_str(), p); } - // when we don't care about endptr, use the string representation that - // doesn't require any conversion (it doesn't matter for this function - // even if its UTF-8): - wxStringCharType** p = NULL; - return wxStrtod(nptr.wx_str(), p); + // note that it is important to use c_str() here and not mb_str() or + // wc_str(), because we store the pointer into (possibly converted) + // buffer in endptr and so it must be valid even when wxStrtod() returns + typedef typename wxStrtoxCharType::Type CharType; + return wxStrtod((CharType)nptr.c_str(), + wxStrtoxCharType::AsPointer(endptr)); } template inline double wxStrtod(const wxCStrData& nptr, T endptr) @@ -891,15 +890,15 @@ inline double wxStrtod(const wxCStrData& nptr, T endptr) template \ inline rettype name(const wxString& nptr, T endptr, int base) \ { \ - if (endptr) \ + if (!endptr) \ { \ - typedef typename wxStrtoxCharType::Type CharType; \ - return name((CharType)nptr.c_str(), \ - wxStrtoxCharType::AsPointer(endptr), \ - base); \ + wxStringCharType** p = NULL; \ + return name(nptr.wx_str(), p, base); \ } \ - wxStringCharType** p = NULL; \ - return name(nptr.wx_str(), p, base); \ + typedef typename wxStrtoxCharType::Type CharType; \ + return name((CharType)nptr.c_str(), \ + wxStrtoxCharType::AsPointer(endptr), \ + base); \ } \ template \ inline rettype name(const wxCStrData& nptr, T endptr, int base) \