From 17a1ebd101f0653e69736416a2a28d0ada423141 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Sep 2005 19:59:19 +0000 Subject: [PATCH] first round of Intel compiler warning fixes: down from a few thousands just to slightly more than 100 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35688 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/bakefiles/files.bkl | 1 + configure | 14 ++++++--- configure.in | 39 ++++++++++++++++++++--- include/wx/app.h | 9 ++++++ include/wx/build.h | 13 ++++---- include/wx/dataobj.h | 23 ++++++-------- include/wx/defs.h | 50 +++++++++++++++++++++++------ include/wx/dynarray.h | 12 +++---- include/wx/gtk/tglbtn.h | 3 +- include/wx/gtk1/tglbtn.h | 3 +- include/wx/longlong.h | 14 ++++----- include/wx/math.h | 13 ++++++++ include/wx/motif/font.h | 2 +- include/wx/platform.h | 4 +++ include/wx/ptr_scpd.h | 2 +- include/wx/unix/private.h | 47 ++++++++++++++++++++++++++++ src/common/appbase.cpp | 13 ++++---- src/common/cshelp.cpp | 10 +++--- src/common/datetime.cpp | 10 +++--- src/common/datstrm.cpp | 11 ++----- src/common/debugrpt.cpp | 8 +++-- src/common/dynarray.cpp | 10 ++++++ src/common/extended.c | 2 +- src/common/ffile.cpp | 2 +- src/common/fileconf.cpp | 10 +++--- src/common/filename.cpp | 2 ++ src/common/fmapbase.cpp | 2 +- src/common/intl.cpp | 9 ++++-- src/common/longlong.cpp | 32 +++++++++---------- src/common/mstream.cpp | 9 ++++-- src/common/popupcmn.cpp | 22 ++++++------- src/common/sckaddr.cpp | 15 +++++---- src/common/socket.cpp | 2 +- src/common/strconv.cpp | 26 +++++++-------- src/common/stream.cpp | 14 ++++++--- src/common/string.cpp | 4 +-- src/common/txtstrm.cpp | 4 +-- src/common/uri.cpp | 2 +- src/generic/accel.cpp | 2 +- src/generic/datectlg.cpp | 22 ++++++------- src/generic/dirdlgg.cpp | 4 +-- src/generic/filedlgg.cpp | 2 +- src/generic/grid.cpp | 2 +- src/generic/laywin.cpp | 4 +-- src/generic/listctrl.cpp | 6 ++-- src/generic/prntdlgg.cpp | 17 +++++----- src/generic/splash.cpp | 2 +- src/gtk/app.cpp | 21 +++++++------ src/gtk/bitmap.cpp | 27 +++++++++++++--- src/gtk/combobox.cpp | 10 +++--- src/gtk/dcclient.cpp | 6 ++-- src/gtk/eggtrayicon.c | 3 +- src/gtk/listbox.cpp | 31 +++++++++--------- src/gtk/scrolwin.cpp | 16 +++++----- src/gtk/settings.cpp | 38 +++++++++++----------- src/gtk/tbargtk.cpp | 9 +++--- src/gtk/win_gtk.c | 26 ++++++++------- src/gtk/window.cpp | 22 +++++++------ src/gtk1/app.cpp | 21 +++++++------ src/gtk1/bitmap.cpp | 27 +++++++++++++--- src/gtk1/combobox.cpp | 10 +++--- src/gtk1/dcclient.cpp | 6 ++-- src/gtk1/eggtrayicon.c | 3 +- src/gtk1/listbox.cpp | 31 +++++++++--------- src/gtk1/scrolwin.cpp | 16 +++++----- src/gtk1/settings.cpp | 38 +++++++++++----------- src/gtk1/tbargtk.cpp | 9 +++--- src/gtk1/win_gtk.c | 26 ++++++++------- src/gtk1/window.cpp | 22 +++++++------ src/html/helpdata.cpp | 8 ++--- src/html/htmlcell.cpp | 4 +-- src/html/htmlpars.cpp | 2 +- src/html/htmlwin.cpp | 4 +-- src/html/m_image.cpp | 13 ++++---- src/motif/evtloop.cpp | 9 +++--- src/unix/dlunix.cpp | 2 +- src/unix/fontenum.cpp | 6 ++-- src/unix/gsocket.cpp | 39 +++++++++++------------ src/unix/joystick.cpp | 7 +++-- src/unix/mimetype.cpp | 7 +++-- src/unix/threadpsx.cpp | 54 ++++++++++---------------------- src/unix/utilsunx.cpp | 27 +++++++--------- src/unix/utilsx11.cpp | 66 +++++++++++++++++++++------------------ src/x11/evtloop.cpp | 17 +++++----- src/xrc/xmlres.cpp | 6 ++-- utils/wxrc/wxrc.cpp | 14 +++++---- 86 files changed, 713 insertions(+), 519 deletions(-) create mode 100644 include/wx/unix/private.h diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 372adc9c8c..3f55074e72 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -72,6 +72,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/unix/execute.h wx/unix/mimetype.h wx/unix/pipe.h + wx/unix/private.h wx/unix/stackwalk.h wx/unix/stdpaths.h diff --git a/configure b/configure index ed545dfce9..50b6b3202d 100755 --- a/configure +++ b/configure @@ -14043,7 +14043,6 @@ if test "x$XLCXX" = "xyes" -a "x$USE_AIX" = "x1"; then CXXFLAGS="$CXXFLAGS -qunique" fi - case "${host}" in powerpc-*-darwin* ) echo "$as_me:$LINENO: checking if __POWERPC__ is already defined" >&5 @@ -42627,9 +42626,16 @@ fi INCLUDES="-I\${top_builddir}lib/wx/include/${TOOLCHAIN_FULLNAME} \ -I\${top_srcdir}/include $TOOLKIT_INCLUDE" -if test "$GXX" = yes ; then - CWARNINGS="-Wall -Wundef" - CXXWARNINGS="$CWARNINGS -Wno-ctor-dtor-privacy" +if test "$GCC" = yes ; then + CWARNINGS="-Wall -wd810,869,981,1418,1572,1684" +elif test "$GCC" = yes ; then + CWARNINGS="-Wall -Wundef" +fi + +if test "$INTELCXX" = yes ; then + CXXWARNINGS="-Wall -wd279,383,444,869,981,1418,1419" +elif test "$GXX" = yes ; then + CXXWARNINGS="-Wall -Wundef -Wno-ctor-dtor-privacy" fi EXTRA_CFLAGS="$WXDEBUG $WXODBCFLAG $PROFILE $OPTIMISE" diff --git a/configure.in b/configure.in index 2832f1d180..50e59641de 100644 --- a/configure.in +++ b/configure.in @@ -1517,7 +1517,6 @@ if test "x$XLCXX" = "xyes" -a "x$USE_AIX" = "x1"; then CXXFLAGS="$CXXFLAGS -qunique" fi - dnl This case is for PowerPC OS X vs. everything else case "${host}" in powerpc-*-darwin* ) @@ -6850,10 +6849,42 @@ INCLUDES="-I\${top_builddir}lib/wx/include/${TOOLCHAIN_FULLNAME} \ -I\${top_srcdir}/include $TOOLKIT_INCLUDE" dnl C/C++ compiler options used to compile wxWidgets -if test "$GXX" = yes ; then - dnl CXXWARNINGS="-Wall -W -Wcast-qual -Werror" +dnl +dnl check for icc before gcc as icc is also recognized as gcc +if test "$GCC" = yes ; then + dnl Warnings which can't be easily suppressed in C code are disabled: + dnl + dnl remark #810: conversion from "x" to "y" may lose significant bits + dnl remark #869: parameter "foo" was never referenced + dnl remark #1572: floating-point equality and inequality comparisons + dnl are unreliable + dnl remark #1684: conversion from pointer to same-sized integral type + dnl + dnl (for others see below) + CWARNINGS="-Wall -wd810,869,981,1418,1572,1684" +elif test "$GCC" = yes ; then CWARNINGS="-Wall -Wundef" - CXXWARNINGS="$CWARNINGS -Wno-ctor-dtor-privacy" +fi + +if test "$INTELCXX" = yes ; then + dnl Intel compiler gives some warnings which simply can't be worked + dnl around or of which we have too many (810, 869) so it's impractical to + dnl keep them enabled even if in theory it would be nice and some others + dnl (279) are generated for standard macros and so there is nothing we can + dnl do about them + dnl + dnl remark #279: controlling expression is constant + dnl remark #383: value copied to temporary, reference to temporary used + dnl remark #444: destructor for base class "xxx" is not virtual + dnl remark #810: conversion from "x" to "y" may lose significant bits + dnl remark #869: parameter "foo" was never referenced + dnl remark #981: operands are evaluated in unspecified order + dnl remark #1418: external definition with no prior declaration + dnl remark #1419: external declaration in primary source file + CXXWARNINGS="-Wall -wd279,383,444,869,981,1418,1419" +elif test "$GXX" = yes ; then + dnl CXXWARNINGS="-Wall -W -Wcast-qual -Werror" + CXXWARNINGS="-Wall -Wundef -Wno-ctor-dtor-privacy" fi EXTRA_CFLAGS="$WXDEBUG $WXODBCFLAG $PROFILE $OPTIMISE" diff --git a/include/wx/app.h b/include/wx/app.h index 02c5aee54d..4508ef1bca 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -661,6 +661,7 @@ public: } \ wxAppInitializer \ wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ + DECLARE_APP(appname) \ appname& wxGetApp() { return *(appname *)wxTheApp; } // Same as IMPLEMENT_APP() normally but doesn't include themes support in @@ -684,5 +685,13 @@ public: // function #define DECLARE_APP(appname) extern appname& wxGetApp(); + +// declare the stuff defined by IMPLEMENT_APP() macro, it's not really needed +// anywhere else but at the very least it suppresses icc warnings about +// defining extern symbols without prior declaration, and it shouldn't do any +// harm +extern wxAppConsole *wxCreateApp(); +extern wxAppInitializer wxTheAppInitializer; + #endif // _WX_APP_H_BASE_ diff --git a/include/wx/build.h b/include/wx/build.h index b64fb8f5d6..6e0a6dc8ce 100644 --- a/include/wx/build.h +++ b/include/wx/build.h @@ -112,13 +112,14 @@ // Use this macro to check build options. Adding it to a file in DLL will // ensure that the DLL checks build options in same way IMPLEMENT_APP() does. #define WX_CHECK_BUILD_OPTIONS(libName) \ - static bool wxCheckBuildOptions() \ + static struct wxBuildOptionsChecker \ { \ - wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \ - libName); \ - return true; \ - } \ - static bool gs_buildOptionsCheck = wxCheckBuildOptions(); + wxBuildOptionsChecker() \ + { \ + wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \ + libName); \ + } \ + } gs_buildOptionsCheck; #if WXWIN_COMPATIBILITY_2_4 diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 57abf2ed31..12c2101f10 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -318,7 +318,13 @@ public: // ctor: you can specify the text here or in SetText(), or override // GetText() wxTextDataObject(const wxString& text = wxEmptyString) - : wxDataObjectSimple(wxUSE_UNICODE?wxDF_UNICODETEXT:wxDF_TEXT), + : wxDataObjectSimple( +#if wxUSE_UNICODE + wxDF_UNICODETEXT +#else + wxDF_TEXT +#endif + ), m_text(text) { } @@ -332,19 +338,8 @@ public: // implement base class pure virtuals // ---------------------------------- -#if wxUSE_UNICODE && defined(__WXGTK20__) - virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; } - virtual void GetAllFormats(wxDataFormat *formats, - wxDataObjectBase::Direction WXUNUSED(dir) = Get) const; - - virtual size_t GetDataSize() const { return GetDataSize(GetPreferredFormat()); } - virtual bool GetDataHere(void *buf) const { return GetDataHere(GetPreferredFormat(), buf); } - virtual bool SetData(size_t len, const void *buf) { return SetData(GetPreferredFormat(), len, buf); } - - size_t GetDataSize(const wxDataFormat& format) const; - bool GetDataHere(const wxDataFormat& format, void *pBuf) const; - bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf); -#elif wxUSE_UNICODE && defined(__WXMAC__) + // some platforms have 2 and not 1 format for text data +#if wxUSE_UNICODE && (defined(__WXGTK20__) || defined(__WXMAC__)) virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; } virtual void GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir) = Get) const; diff --git a/include/wx/defs.h b/include/wx/defs.h index b18f62f9d5..53d8655117 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -297,7 +297,23 @@ typedef int wxWindowID; truncate from a larger to smaller type, static_cast<> can't be used for it as it results in warnings when using some compilers (SGI mipspro for example) */ -#define wx_truncate_cast(t, x) ((t)(x)) +#if defined(__INTELC__) && defined(__cplusplus) + template + inline T wx_truncate_cast_impl(X x) + { + #pragma warning(push) + /* explicit conversion of a 64-bit integral type to a smaller integral type */ + #pragma warning(disable: 1683) + + return (T)x; + + #pragma warning(pop) + } + + #define wx_truncate_cast(t, x) wx_truncate_cast_impl(x) +#else /* !__INTELC__ */ + #define wx_truncate_cast(t, x) ((t)(x)) +#endif /* __INTELC__/!__INTELC__ */ /* for consistency with wxStatic/DynamicCast defined in wx/object.h */ #define wxConstCast(obj, className) wx_const_cast(className *, obj) @@ -844,29 +860,43 @@ inline wxUIntPtr wxPtrToUInt(const void *p) /* VC++ 7.1 gives warnings about casts such as below even when they're explicit with /Wp64 option, suppress them as we really know what we're - doing here + doing here. Same thing with icc with -Wall. */ -#ifdef __VISUALC__ - #pragma warning(disable: 4311) /* pointer truncation from '' to '' */ +#if defined(__VISUALC__) || defined(__INTELC__) + #pragma warning(push) + #ifdef __VISUALC__ + /* pointer truncation from '' to '' */ + #pragma warning(disable: 4311) + #elif defined(__INTELC__) + /* conversion from pointer to same-sized integral type */ + #pragma warning(disable: 1684) + #endif #endif return wx_reinterpret_cast(wxUIntPtr, p); -#ifdef __VISUALC__ - #pragma warning(default: 4311) +#if defined(__VISUALC__) || defined(__INTELC__) + #pragma warning(pop) #endif } inline void *wxUIntToPtr(wxUIntPtr p) { -#ifdef __VISUALC__ - #pragma warning(disable: 4312) /* conversion to type of greater size */ +#if defined(__VISUALC__) || defined(__INTELC__) + #pragma warning(push) + #ifdef __VISUALC__ + /* conversion to type of greater size */ + #pragma warning(disable: 4312) + #elif defined(__INTELC__) + /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */ + #pragma warning(disable: 171) + #endif #endif return wx_reinterpret_cast(void *, p); -#ifdef __VISUALC__ - #pragma warning(default: 4312) +#if defined(__VISUALC__) || defined(__INTELC__) + #pragma warning(pop) #endif } #endif /*__cplusplus*/ diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 4aaf0f8b42..a70982e87c 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -967,10 +967,10 @@ WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE // append all element of one array to another one #define WX_APPEND_ARRAY(array, other) \ { \ - size_t count = (other).size(); \ - for ( size_t n = 0; n < count; n++ ) \ + size_t wxAAcnt = (other).size(); \ + for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ { \ - (array).push_back((other)[n]); \ + (array).push_back((other)[wxAAn]); \ } \ } @@ -982,10 +982,10 @@ WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE // count on it)! #define WX_CLEAR_ARRAY(array) \ { \ - size_t count = (array).size(); \ - for ( size_t n = 0; n < count; n++ ) \ + size_t wxAAcnt = (array).size(); \ + for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ { \ - delete (array)[n]; \ + delete (array)[wxAAn]; \ } \ \ (array).clear(); \ diff --git a/include/wx/gtk/tglbtn.h b/include/wx/gtk/tglbtn.h index 8aa5434314..98e28f1210 100644 --- a/include/wx/gtk/tglbtn.h +++ b/include/wx/gtk/tglbtn.h @@ -63,7 +63,8 @@ public: bool GetValue() const; // Set the label - void SetLabel(const wxBitmap& label); + virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); } + virtual void SetLabel(const wxBitmap& label); bool Enable(bool enable = TRUE); static wxVisualAttributes diff --git a/include/wx/gtk1/tglbtn.h b/include/wx/gtk1/tglbtn.h index 8aa5434314..98e28f1210 100644 --- a/include/wx/gtk1/tglbtn.h +++ b/include/wx/gtk1/tglbtn.h @@ -63,7 +63,8 @@ public: bool GetValue() const; // Set the label - void SetLabel(const wxBitmap& label); + virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); } + virtual void SetLabel(const wxBitmap& label); bool Enable(bool enable = TRUE); static wxVisualAttributes diff --git a/include/wx/longlong.h b/include/wx/longlong.h index 6d46642dcf..a318c78a2b 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -139,10 +139,10 @@ public: // accessors // get high part long GetHi() const - { return (long)(m_ll >> 32); } + { return wx_truncate_cast(long, m_ll >> 32); } // get low part unsigned long GetLo() const - { return (unsigned long)m_ll; } + { return wx_truncate_cast(unsigned long, m_ll); } // get absolute value wxLongLongNative Abs() const { return wxLongLongNative(*this).Abs(); } @@ -157,12 +157,12 @@ public: wxASSERT_MSG( (m_ll >= LONG_MIN) && (m_ll <= LONG_MAX), _T("wxLongLong to long conversion loss of precision") ); - return (long)m_ll; + return wx_truncate_cast(long, m_ll); } #if wxABI_VERSION >= 20602 // convert to double - double ToDouble() const { return m_ll; } + double ToDouble() const { return wx_truncate_cast(double, m_ll); } #endif // ABI >= 2.6.2 // don't provide implicit conversion to wxLongLong_t or we will have an @@ -344,10 +344,10 @@ public: // accessors // get high part unsigned long GetHi() const - { return (unsigned long)(m_ll >> 32); } + { return wx_truncate_cast(unsigned long, m_ll >> 32); } // get low part unsigned long GetLo() const - { return (unsigned long)m_ll; } + { return wx_truncate_cast(unsigned long, m_ll); } // convert to native ulong long wxULongLong_t GetValue() const { return m_ll; } @@ -358,7 +358,7 @@ public: wxASSERT_MSG( m_ll <= LONG_MAX, _T("wxULongLong to long conversion loss of precision") ); - return (unsigned long)m_ll; + return wx_truncate_cast(unsigned long, m_ll); } // operations diff --git a/include/wx/math.h b/include/wx/math.h index 72628269cf..a32f1b0901 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -98,4 +98,17 @@ inline bool wxIsSameDouble(double x, double y) { return x == y; } #endif /* __cplusplus */ +#if wxUSE_APPLE_IEEE +#ifdef __cplusplus + extern "C" { +#endif + /* functions from common/extended.c */ + extern wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes); + extern void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes); +#ifdef __cplusplus + } +#endif +#endif /* wxUSE_APPLE_IEEE */ + + #endif /* _WX_MATH_H_ */ diff --git a/include/wx/motif/font.h b/include/wx/motif/font.h index d18af9c5c8..7c5efaf3a3 100644 --- a/include/wx/motif/font.h +++ b/include/wx/motif/font.h @@ -13,7 +13,7 @@ #define _WX_FONT_H_ #if __WXMOTIF20__ && !__WXLESSTIF__ - #define wxMOTIF_NEW_FONT_HANDLING 0 // safe default, change to 1 to enable + #define wxMOTIF_NEW_FONT_HANDLING 1 // safe default, change to 1 to enable #else #define wxMOTIF_NEW_FONT_HANDLING 0 #endif diff --git a/include/wx/platform.h b/include/wx/platform.h index 601f6d2ce0..606ad4a8d9 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -476,6 +476,10 @@ # endif #endif +#ifdef __INTEL_COMPILER +# define __INTELC__ +#endif + /* We get "Large Files (ILP32) not supported in strict ANSI mode." #error from HP-UX standard headers when compiling with g++ without this: diff --git a/include/wx/ptr_scpd.h b/include/wx/ptr_scpd.h index 8ab3f37971..2ebb6a6732 100644 --- a/include/wx/ptr_scpd.h +++ b/include/wx/ptr_scpd.h @@ -45,7 +45,7 @@ #define wxPOST_NO_WARNING_SCOPE(name) #else #define wxPRE_NO_WARNING_SCOPE(name) do - #define wxPOST_NO_WARNING_SCOPE(name) while ( 0 ) + #define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse ) #endif #define wxCHECKED_DELETE(ptr) \ diff --git a/include/wx/unix/private.h b/include/wx/unix/private.h new file mode 100644 index 0000000000..9d2e338107 --- /dev/null +++ b/include/wx/unix/private.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/unix/private.h +// Purpose: miscellaneous private things for Unix wx ports +// Author: Vadim Zeitlin +// Created: 2005-09-25 +// RCS-ID: $Id$ +// Copyright: (c) 2005 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_UNIX_PRIVATE_H_ +#define _WX_UNIX_PRIVATE_H_ + +// standard linux headers produce many warnings when used with icc +#if defined(__INTELC__) && defined(__LINUX__) + inline void wxFD_ZERO(fd_set *fds) + { + #pragma warning(push) + #pragma warning(disable:593) + FD_ZERO(fds); + #pragma warning(pop) + } + + inline void wxFD_SET(int fd, fd_set *fds) + { + #pragma warning(push, 1) + #pragma warning(disable:1469) + FD_SET(fd, fds); + #pragma warning(pop) + } + + inline bool wxFD_ISSET(int fd, fd_set *fds) + { + #pragma warning(push, 1) + #pragma warning(disable:1469) + return FD_ISSET(fd, fds); + #pragma warning(pop) + } +#else // !__INTELC__ + #define wxFD_ZERO(fds) FD_ZERO(fds) + #define wxFD_SET(fd, fds) FD_SET(fd, fds) + #define wxFD_ISSET(fd, fds) FD_ISSET(fd, fds) +#endif // __INTELC__/!__INTELC__ + + +#endif // _WX_UNIX_PRIVATE_H_ + diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 701f23a342..fe7471e1c7 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -721,7 +721,11 @@ static wxString GetAssertStackTrace() protected: virtual void OnStackFrame(const wxStackFrame& frame) { - m_stackTrace << wxString::Format(_T("[%02d] "), frame.GetLevel()); + m_stackTrace << wxString::Format + ( + _T("[%02d] "), + wx_truncate_cast(int, frame.GetLevel()) + ); wxString name = frame.GetName(); if ( !name.empty() ) @@ -730,11 +734,8 @@ static wxString GetAssertStackTrace() } else { - m_stackTrace << wxString::Format - ( - _T("0x%08lx"), - (unsigned long)frame.GetAddress() - ); + m_stackTrace << wxString::Format(_T("0x%08p"), + frame.GetAddress()); } if ( frame.HasSourceLocation() ) diff --git a/src/common/cshelp.cpp b/src/common/cshelp.cpp index b4887f7ddb..7e4d11a93b 100644 --- a/src/common/cshelp.cpp +++ b/src/common/cshelp.cpp @@ -330,9 +330,11 @@ wxHelpProvider::~wxHelpProvider() // wxSimpleHelpProvider // ---------------------------------------------------------------------------- +#define WINHASH_KEY(w) wxPtrToUInt(w) + wxString wxSimpleHelpProvider::GetHelp(const wxWindowBase *window) { - wxLongToStringHashMap::iterator it = m_hashWindows.find((long)window); + wxLongToStringHashMap::iterator it = m_hashWindows.find(WINHASH_KEY(window)); if ( it == m_hashWindows.end() ) { @@ -346,8 +348,8 @@ wxString wxSimpleHelpProvider::GetHelp(const wxWindowBase *window) void wxSimpleHelpProvider::AddHelp(wxWindowBase *window, const wxString& text) { - m_hashWindows.erase((long)window); - m_hashWindows[(long)window] = text; + m_hashWindows.erase(WINHASH_KEY(window)); + m_hashWindows[WINHASH_KEY(window)] = text; } void wxSimpleHelpProvider::AddHelp(wxWindowID id, const wxString& text) @@ -360,7 +362,7 @@ void wxSimpleHelpProvider::AddHelp(wxWindowID id, const wxString& text) // removes the association void wxSimpleHelpProvider::RemoveHelp(wxWindowBase* window) { - m_hashWindows.erase((long)window); + m_hashWindows.erase(WINHASH_KEY(window)); } bool wxSimpleHelpProvider::ShowHelp(wxWindowBase *window) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index c4425617ed..6622496e33 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -2373,23 +2373,23 @@ wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const // find two strings not occurring in format (this is surely // not the optimal way of doing it... improvements welcome!) - wxString fmt = format; + wxString fmt2 = format; wxString replacement = (wxChar)-1; - while ( fmt.Find(replacement) != wxNOT_FOUND ) + while ( fmt2.Find(replacement) != wxNOT_FOUND ) { replacement << (wxChar)-1; } wxString replacement2 = (wxChar)-2; - while ( fmt.Find(replacement) != wxNOT_FOUND ) + while ( fmt2.Find(replacement) != wxNOT_FOUND ) { replacement << (wxChar)-2; } // replace all occurrences of year with it - bool wasReplaced = fmt.Replace(strYear, replacement) > 0; + bool wasReplaced = fmt2.Replace(strYear, replacement) > 0; if ( !wasReplaced ) - wasReplaced = fmt.Replace(strYear2, replacement2) > 0; + wasReplaced = fmt2.Replace(strYear2, replacement2) > 0; // use strftime() to format the same date but in supported // year diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index cc82237911..0a02f17e8f 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -19,6 +19,7 @@ #if wxUSE_STREAMS #include "wx/datstrm.h" +#include "wx/math.h" // --------------------------------------------------------------------------- // wxDataInputStream @@ -78,16 +79,13 @@ wxUint8 wxDataInputStream::Read8() return (wxUint8)buf; } -// Must be at global scope for VC++ 5 -extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes); - double wxDataInputStream::ReadDouble() { #if wxUSE_APPLE_IEEE char buf[10]; m_input->Read(buf, 10); - return ConvertFromIeeeExtended((unsigned char *)buf); + return ConvertFromIeeeExtended((const wxInt8 *)buf); #else return 0.0; #endif @@ -321,15 +319,12 @@ void wxDataOutputStream::WriteString(const wxString& string) m_output->Write(buf, len); } -// Must be at global scope for VC++ 5 -extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes); - void wxDataOutputStream::WriteDouble(double d) { char buf[10]; #if wxUSE_APPLE_IEEE - ConvertToIeeeExtended(d, (unsigned char *)buf); + ConvertToIeeeExtended(d, (wxInt8 *)buf); #else #if !defined(__VMS__) && !defined(__GNUG__) # pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!" diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp index 0717408f4f..2428d18213 100644 --- a/src/common/debugrpt.cpp +++ b/src/common/debugrpt.cpp @@ -106,12 +106,16 @@ TextElement(wxXmlNode *node, const wxChar *name, const wxString& value) nodeChild->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString, value)); } +#if wxUSE_CRASHREPORT && defined(__INTEL__) + static inline void HexElement(wxXmlNode *node, const wxChar *name, unsigned long value) { TextElement(node, name, wxString::Format(_T("%08lx"), value)); } +#endif // wxUSE_CRASHREPORT + #if wxUSE_STACKWALKER // ============================================================================ @@ -371,7 +375,7 @@ bool wxDebugReport::DoAddLoadedModules(wxXmlNode *nodeModules) size_t len = 0; if ( info.GetAddress(&addr, &len) ) { - HexProperty(nodeModule, _T("address"), (unsigned long)addr); + HexProperty(nodeModule, _T("address"), wxPtrToUInt(addr)); HexProperty(nodeModule, _T("size"), len); } @@ -397,7 +401,7 @@ bool wxDebugReport::DoAddExceptionInfo(wxXmlNode *nodeContext) HexProperty(nodeExc, _T("code"), c.code); nodeExc->AddProperty(_T("name"), c.GetExceptionString()); - HexProperty(nodeExc, _T("address"), (unsigned long)c.addr); + HexProperty(nodeExc, _T("address"), wxPtrToUInt(c.addr)); #ifdef __INTEL__ wxXmlNode *nodeRegs = new wxXmlNode(wxXML_ELEMENT_NODE, _T("registers")); diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 92f5237512..b098d4854b 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -410,6 +410,12 @@ void name::insert(iterator it, const_iterator first, const_iterator last) \ _WX_DEFINE_BASEARRAY_COMMON(T, name) \ _WX_DEFINE_BASEARRAY_NOCOMMON(T, name) +#ifdef __INTELC__ + #pragma warning(push) + #pragma warning(disable: 1684) + #pragma warning(disable: 1572) +#endif + _WX_DEFINE_BASEARRAY(const void *, wxBaseArrayPtrVoid) _WX_DEFINE_BASEARRAY(short, wxBaseArrayShort) _WX_DEFINE_BASEARRAY(int, wxBaseArrayInt) @@ -417,6 +423,10 @@ _WX_DEFINE_BASEARRAY(long, wxBaseArrayLong) _WX_DEFINE_BASEARRAY(size_t, wxBaseArraySizeT) _WX_DEFINE_BASEARRAY(double, wxBaseArrayDouble) +#ifdef __INTELC__ + #pragma warning(pop) +#endif + #if wxUSE_STL #include "wx/arrstr.h" diff --git a/src/common/extended.c b/src/common/extended.c index 9ff1b19f02..b3e2bd8cd6 100644 --- a/src/common/extended.c +++ b/src/common/extended.c @@ -105,7 +105,7 @@ * and a 64-bit mantissa, with no hidden bit. ****************************************************************/ -wxFloat64 ConvertFromIeeeExtended(wxInt8* bytes) +wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes) { wxFloat64 f; wxInt32 expon; diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index cc60534821..3422506621 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -104,7 +104,7 @@ bool wxFFile::ReadAll(wxString *str, wxMBConv& conv) wxCHECK_MSG( str, false, wxT("invalid parameter") ); wxCHECK_MSG( IsOpened(), false, wxT("can't read from closed file") ); wxCHECK_MSG( Length() >= 0, false, wxT("invalid length") ); - size_t length = (size_t)Length(); + size_t length = wx_truncate_cast(size_t, Length()); wxCHECK_MSG( (wxFileOffset)length == Length(), false, wxT("huge file not supported") ); clearerr(m_fp); diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 5549cd7bb3..6e4f6ddfef 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -450,16 +450,16 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, { if ( !m_strLocalFile.empty() && !wxIsAbsolutePath(m_strLocalFile) ) { - wxString strLocal = m_strLocalFile; + const wxString strLocalOrig = m_strLocalFile; m_strLocalFile = GetLocalDir(); - m_strLocalFile << strLocal; + m_strLocalFile << strLocalOrig; } if ( !m_strGlobalFile.empty() && !wxIsAbsolutePath(m_strGlobalFile) ) { - wxString strGlobal = m_strGlobalFile; + const wxString strGlobalOrig = m_strGlobalFile; m_strGlobalFile = GetGlobalDir(); - m_strGlobalFile << strGlobal; + m_strGlobalFile << strGlobalOrig; } } @@ -664,7 +664,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) } } else { // a key - const wxChar *pEnd = pStart; + pEnd = pStart; while ( *pEnd && *pEnd != wxT('=') /* && !wxIsspace(*pEnd)*/ ) { if ( *pEnd == wxT('\\') ) { // next character may be space or not - still take it because it's diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 9b61e662e5..d1766a8179 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -1890,6 +1890,8 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess, } } #elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__)) + wxUnusedVar(dtCreate); + if ( !dtAccess && !dtMod ) { // can't modify the creation time anyhow, don't try diff --git a/src/common/fmapbase.cpp b/src/common/fmapbase.cpp index d3e2ac2825..345d06ec8b 100644 --- a/src/common/fmapbase.cpp +++ b/src/common/fmapbase.cpp @@ -573,7 +573,7 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) if ( *p == wxT('-') ) p++; - int value; + unsigned int value; if ( wxSscanf(p, wxT("%u"), &value) == 1 ) { if ( value >= 1250 ) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 1a155e493f..d7d4c60fdc 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1132,13 +1132,16 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName, return false; // get the file size (assume it is less than 4Gb...) - wxFileOffset nSize = fileMsg.Length(); - if ( nSize == wxInvalidOffset ) + wxFileOffset lenFile = fileMsg.Length(); + if ( lenFile == wxInvalidOffset ) return false; + size_t nSize = wx_truncate_cast(size_t, lenFile); + wxASSERT_MSG( nSize == lenFile, _T("message catalog bigger than 4GB?") ); + // read the whole file in memory m_pData = new size_t8[nSize]; - if ( fileMsg.Read(m_pData, (size_t)nSize) != nSize ) { + if ( fileMsg.Read(m_pData, nSize) != nSize ) { wxDELETEA(m_pData); return false; } diff --git a/src/common/longlong.cpp b/src/common/longlong.cpp index 488cb1565a..b61b13d159 100644 --- a/src/common/longlong.cpp +++ b/src/common/longlong.cpp @@ -47,14 +47,14 @@ void *wxLongLongNative::asArray() const { static unsigned char temp[8]; - temp[0] = (unsigned char)((m_ll >> 56) & 0xFF); - temp[1] = (unsigned char)((m_ll >> 48) & 0xFF); - temp[2] = (unsigned char)((m_ll >> 40) & 0xFF); - temp[3] = (unsigned char)((m_ll >> 32) & 0xFF); - temp[4] = (unsigned char)((m_ll >> 24) & 0xFF); - temp[5] = (unsigned char)((m_ll >> 16) & 0xFF); - temp[6] = (unsigned char)((m_ll >> 8) & 0xFF); - temp[7] = (unsigned char)((m_ll >> 0) & 0xFF); + temp[0] = wx_truncate_cast(unsigned char, ((m_ll >> 56) & 0xFF)); + temp[1] = wx_truncate_cast(unsigned char, ((m_ll >> 48) & 0xFF)); + temp[2] = wx_truncate_cast(unsigned char, ((m_ll >> 40) & 0xFF)); + temp[3] = wx_truncate_cast(unsigned char, ((m_ll >> 32) & 0xFF)); + temp[4] = wx_truncate_cast(unsigned char, ((m_ll >> 24) & 0xFF)); + temp[5] = wx_truncate_cast(unsigned char, ((m_ll >> 16) & 0xFF)); + temp[6] = wx_truncate_cast(unsigned char, ((m_ll >> 8) & 0xFF)); + temp[7] = wx_truncate_cast(unsigned char, ((m_ll >> 0) & 0xFF)); return temp; } @@ -63,14 +63,14 @@ void *wxULongLongNative::asArray() const { static unsigned char temp[8]; - temp[0] = (unsigned char)((m_ll >> 56) & 0xFF); - temp[1] = (unsigned char)((m_ll >> 48) & 0xFF); - temp[2] = (unsigned char)((m_ll >> 40) & 0xFF); - temp[3] = (unsigned char)((m_ll >> 32) & 0xFF); - temp[4] = (unsigned char)((m_ll >> 24) & 0xFF); - temp[5] = (unsigned char)((m_ll >> 16) & 0xFF); - temp[6] = (unsigned char)((m_ll >> 8) & 0xFF); - temp[7] = (unsigned char)((m_ll >> 0) & 0xFF); + temp[0] = wx_truncate_cast(unsigned char, ((m_ll >> 56) & 0xFF)); + temp[1] = wx_truncate_cast(unsigned char, ((m_ll >> 48) & 0xFF)); + temp[2] = wx_truncate_cast(unsigned char, ((m_ll >> 40) & 0xFF)); + temp[3] = wx_truncate_cast(unsigned char, ((m_ll >> 32) & 0xFF)); + temp[4] = wx_truncate_cast(unsigned char, ((m_ll >> 24) & 0xFF)); + temp[5] = wx_truncate_cast(unsigned char, ((m_ll >> 16) & 0xFF)); + temp[6] = wx_truncate_cast(unsigned char, ((m_ll >> 8) & 0xFF)); + temp[7] = wx_truncate_cast(unsigned char, ((m_ll >> 0) & 0xFF)); return temp; } diff --git a/src/common/mstream.cpp b/src/common/mstream.cpp index b81a7f44a0..4f1886eaee 100644 --- a/src/common/mstream.cpp +++ b/src/common/mstream.cpp @@ -50,12 +50,17 @@ wxMemoryInputStream::wxMemoryInputStream(const void *data, size_t len) wxMemoryInputStream::wxMemoryInputStream(const wxMemoryOutputStream& stream) { - ssize_t len = (ssize_t)stream.GetLength(); - if (len == wxInvalidOffset) { + const wxFileOffset lenFile = stream.GetLength(); + if ( lenFile == wxInvalidOffset ) + { m_i_streambuf = NULL; m_lasterror = wxSTREAM_EOF; return; } + + const size_t len = wx_truncate_cast(size_t, lenFile); + wxASSERT_MSG( len == lenFile, _T("huge files not supported") ); + m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read); m_i_streambuf->SetBufferIO(len); // create buffer stream.CopyTo(m_i_streambuf->GetBufferStart(), len); diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 09ca583c04..914fce2d26 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -188,7 +188,7 @@ wxPopupTransientWindow::~wxPopupTransientWindow() { if (m_handlerPopup && m_handlerPopup->GetNextHandler()) PopHandlers(); - + wxASSERT(!m_handlerFocus || !m_handlerFocus->GetNextHandler()); wxASSERT(!m_handlerPopup || !m_handlerPopup->GetNextHandler()); @@ -207,7 +207,7 @@ void wxPopupTransientWindow::PopHandlers() m_handlerPopup = NULL; } if (m_child->HasCapture()) - { + { m_child->ReleaseMouse(); } m_child = NULL; @@ -290,11 +290,11 @@ bool wxPopupTransientWindow::Show( bool show ) #ifdef __WXMSW__ if (!show && m_child && m_child->HasCapture()) - { + { m_child->ReleaseMouse(); } #endif - + bool ret = wxPopupWindow::Show( show ); #ifdef __WXGTK__ @@ -387,10 +387,10 @@ void wxPopupTransientWindow::OnIdle(wxIdleEvent& event) { m_child->CaptureMouse(); } - } + } } } -#endif +#endif // __WXMSW__ #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) @@ -483,15 +483,15 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) // dismissing a tooltip shouldn't waste a click, i.e. you // should be able to dismiss it and press the button with the // same click, so repost this event to the window beneath us - wxWindow *win = wxFindWindowAtPoint(event2.GetPosition()); - if ( win ) + wxWindow *winUnder = wxFindWindowAtPoint(event2.GetPosition()); + if ( winUnder ) { // translate the event coords to the ones of the window // which is going to get the event - win->ScreenToClient(&event2.m_x, &event2.m_y); + winUnder->ScreenToClient(&event2.m_x, &event2.m_y); - event2.SetEventObject(win); - wxPostEvent(win, event2); + event2.SetEventObject(winUnder); + wxPostEvent(winUnder, event2); } } break; diff --git a/src/common/sckaddr.cpp b/src/common/sckaddr.cpp index d7c77768b7..86a440f009 100644 --- a/src/common/sckaddr.cpp +++ b/src/common/sckaddr.cpp @@ -205,19 +205,18 @@ wxSockAddress *wxIPV4address::Clone() const wxString wxIPV4address::IPAddress() const { unsigned long raw = GAddress_INET_GetHostAddress(m_address); - return wxString::Format( - _T("%u.%u.%u.%u"), - (unsigned char)((raw>>24) & 0xff), - (unsigned char)((raw>>16) & 0xff), - (unsigned char)((raw>>8) & 0xff), - (unsigned char)(raw & 0xff) + return wxString::Format(_T("%lu.%lu.%lu.%lu"), + (raw>>24) & 0xff, + (raw>>16) & 0xff, + (raw>>8) & 0xff, + raw & 0xff ); } bool wxIPV4address::operator==(const wxIPV4address& addr) const { - if(Hostname().Cmp(addr.Hostname().c_str()) == 0 && Service() == addr.Service()) return true; - return false; + return Hostname().Cmp(addr.Hostname().c_str()) == 0 && + Service() == addr.Service(); } #if wxUSE_IPV6 diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 9bf472c517..247be68f8e 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -95,7 +95,7 @@ public: public: wxSocketState() : wxObject() {} - DECLARE_NO_COPY_CLASS(wxSocketState) + DECLARE_NO_COPY_CLASS(wxSocketState) }; // ========================================================================== diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 986bf4f82d..63de22405c 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -686,11 +686,11 @@ size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const { if ( buf && len + 3 < n ) { - unsigned char n = *opsz; + unsigned char on = *opsz; *buf++ = L'\\'; - *buf++ = (wchar_t)( L'0' + n / 0100 ); - *buf++ = (wchar_t)( L'0' + (n % 0100) / 010 ); - *buf++ = (wchar_t)( L'0' + n % 010 ); + *buf++ = (wchar_t)( L'0' + on / 0100 ); + *buf++ = (wchar_t)( L'0' + (on % 0100) / 010 ); + *buf++ = (wchar_t)( L'0' + on % 010 ); } opsz++; len += 4; @@ -1365,10 +1365,10 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) for ( ; *names; ++names ) { - const wxString name(*names); + const wxString nameCS(*names); // first try charset with explicit bytesex info (e.g. "UCS-4LE"): - wxString nameXE(name); + wxString nameXE(nameCS); #ifdef WORDS_BIGENDIAN nameXE += _T("BE"); #else // little endian @@ -1379,7 +1379,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) if ( m2w == ICONV_T_INVALID ) { // try charset w/o bytesex info (e.g. "UCS4") - m2w = iconv_open(name.ToAscii(), cname); + m2w = iconv_open(nameCS.ToAscii(), cname); // and check for bytesex ourselves: if ( m2w != ICONV_T_INVALID ) @@ -1404,11 +1404,11 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) { wxLogLastError(wxT("iconv")); wxLogError(_("Conversion to charset '%s' doesn't work."), - name.c_str()); + nameCS.c_str()); } else // ok, can convert to this encoding, remember it { - ms_wcCharsetName = name; + ms_wcCharsetName = nameCS; ms_wcNeedsSwap = wbuf[0] != (wchar_t)buf[0]; } } @@ -1485,8 +1485,8 @@ size_t wxMBConv_iconv::MB2WC(wchar_t *buf, const char *psz, size_t n) const if (ms_wcNeedsSwap) { // convert to native endianness - for ( unsigned n = 0; n < res; n++ ) - buf[n] = WC_BSWAP(buf[n]); + for ( unsigned i = 0; i < res; i++ ) + buf[n] = WC_BSWAP(buf[i]); } // NB: iconv was given only strlen(psz) characters on input, and so @@ -1543,8 +1543,8 @@ size_t wxMBConv_iconv::WC2MB(char *buf, const wchar_t *psz, size_t n) const // (doing WC_BSWAP twice on the original buffer won't help, as it // could be in read-only memory, or be accessed in some other thread) tmpbuf = (wchar_t *)malloc(inbuf + SIZEOF_WCHAR_T); - for ( size_t n = 0; n < inlen; n++ ) - tmpbuf[n] = WC_BSWAP(psz[n]); + for ( size_t i = 0; i < inlen; i++ ) + tmpbuf[n] = WC_BSWAP(psz[i]); tmpbuf[inlen] = L'\0'; psz = tmpbuf; } diff --git a/src/common/stream.cpp b/src/common/stream.cpp index 8061deeb7b..2f26e6a330 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -576,7 +576,7 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) } if (diff < 0 || diff > last_access) return wxInvalidOffset; - size_t int_diff = (size_t)diff; + size_t int_diff = wx_truncate_cast(size_t, diff); wxCHECK_MSG( (wxFileOffset)int_diff == diff, wxInvalidOffset, wxT("huge file not supported") ); SetIntPosition(int_diff); return diff; @@ -603,7 +603,7 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) } else { - size_t int_diff = (size_t)diff; + size_t int_diff = wx_truncate_cast(size_t, diff); wxCHECK_MSG( (wxFileOffset)int_diff == diff, wxInvalidOffset, wxT("huge file not supported") ); SetIntPosition(int_diff); return pos; @@ -660,7 +660,13 @@ wxStreamBase::~wxStreamBase() size_t wxStreamBase::GetSize() const { wxFileOffset length = GetLength(); - return length == wxInvalidOffset ? 0 : (size_t)length; + if ( length == wxInvalidOffset ) + return 0; + + const size_t len = wx_truncate_cast(size_t, length); + wxASSERT_MSG( len == length, _T("large files not supported") ); + + return len; } wxFileOffset wxStreamBase::OnSysSeek(wxFileOffset WXUNUSED(seek), wxSeekMode WXUNUSED(mode)) @@ -994,7 +1000,7 @@ size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer), wxFileOffset wxCountingOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) { - ssize_t new_pos = (ssize_t)pos; + ssize_t new_pos = wx_truncate_cast(ssize_t, pos); switch ( mode ) { diff --git a/src/common/string.cpp b/src/common/string.cpp index ffae5b4e12..12c4204759 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -365,8 +365,8 @@ bool wxStringBase::Alloc(size_t nLen) if ( pData->IsEmpty() ) { nLen += EXTRA_ALLOC; - wxStringData* pData = (wxStringData*) - malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); + pData = (wxStringData *) + malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); if ( pData == NULL ) { // allocation failure handled by caller diff --git a/src/common/txtstrm.cpp b/src/common/txtstrm.cpp index c6dd81ff31..61260824e2 100644 --- a/src/common/txtstrm.cpp +++ b/src/common/txtstrm.cpp @@ -348,7 +348,7 @@ void wxTextOutputStream::Write32(wxUint32 i) void wxTextOutputStream::Write16(wxUint16 i) { wxString str; - str.Printf(wxT("%u"), i); + str.Printf(wxT("%u"), (unsigned)i); WriteString(str); } @@ -356,7 +356,7 @@ void wxTextOutputStream::Write16(wxUint16 i) void wxTextOutputStream::Write8(wxUint8 i) { wxString str; - str.Printf(wxT("%u"), i); + str.Printf(wxT("%u"), (unsigned)i); WriteString(str); } diff --git a/src/common/uri.cpp b/src/common/uri.cpp index 30a0004bc1..c195d13729 100644 --- a/src/common/uri.cpp +++ b/src/common/uri.cpp @@ -113,7 +113,7 @@ wxChar wxURI::TranslateEscape(const wxChar* s) { wxASSERT_MSG( IsHex(s[0]) && IsHex(s[1]), wxT("Invalid escape sequence!")); - return (wxChar)( CharToHex(s[0]) << 4 ) | CharToHex(s[1]); + return wx_truncate_cast(wxChar, (CharToHex(s[0]) << 4 ) | CharToHex(s[1])); } wxString wxURI::Unescape(const wxString& uri) diff --git a/src/generic/accel.cpp b/src/generic/accel.cpp index 957732311e..b9a49a85e6 100644 --- a/src/generic/accel.cpp +++ b/src/generic/accel.cpp @@ -40,7 +40,7 @@ WX_DECLARE_LIST(wxAcceleratorEntry, wxAccelList); #include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxAccelList); +WX_DEFINE_LIST(wxAccelList) // ---------------------------------------------------------------------------- // wxAccelRefData: the data used by wxAcceleratorTable diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 2c2a33d58a..eda003e5f7 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -633,14 +633,14 @@ wxDatePickerCtrlGeneric::SetDateRange(const wxDateTime& lowerdate, bool wxDatePickerCtrlGeneric::SetFormat(const wxChar *fmt) { + m_format.clear(); + wxDateTime dt; dt.ParseFormat(wxT("2003-10-13"), wxT("%Y-%m-%d")); - wxString str=dt.Format(fmt); - wxChar *p=(wxChar*)str.c_str(); - - m_format=wxEmptyString; + wxString str(dt.Format(fmt)); - while (*p) + const wxChar *p = str.c_str(); + while ( *p ) { int n=wxAtoi(p); if (n == dt.GetDay()) @@ -670,19 +670,19 @@ bool wxDatePickerCtrlGeneric::SetFormat(const wxChar *fmt) m_format.Append(*p++); } - if (m_txt) + if ( m_txt ) { wxArrayString allowedChars; for ( wxChar c = _T('0'); c <= _T('9'); c++ ) allowedChars.Add(wxString(c, 1)); - const wxChar *p = m_format.c_str(); - while (*p) + const wxChar *p2 = m_format.c_str(); + while ( *p2 ) { - if (*p == '%') - p += 2; + if ( *p2 == '%') + p2 += 2; else - allowedChars.Add(wxString(*p++, 1)); + allowedChars.Add(wxString(*p2++, 1)); } #if wxUSE_VALIDATORS diff --git a/src/generic/dirdlgg.cpp b/src/generic/dirdlgg.cpp index 75585e829c..cca162da5d 100644 --- a/src/generic/dirdlgg.cpp +++ b/src/generic/dirdlgg.cpp @@ -272,7 +272,7 @@ void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event ) if (data) m_input->SetValue( data->m_path ); -}; +} void wxGenericDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) ) { @@ -282,7 +282,7 @@ void wxGenericDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) ) wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(m_dirCtrl->GetTreeCtrl()->GetSelection()); if (data) m_input->SetValue( data->m_path ); -}; +} void wxGenericDirDialog::OnShowHidden( wxCommandEvent& event ) { diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 3668542fbb..9096fef28f 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -293,7 +293,7 @@ wxString wxFileData::GetHint() const } return s; -}; +} wxString wxFileData::GetEntry( fileListFieldType num ) const { diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 3c900fa4de..2ab4374312 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -9742,7 +9742,7 @@ void wxGrid::SetRowMinimalAcceptableHeight( int height ) if ( height<0 ) return; m_minAcceptableRowHeight = height; -}; +} int wxGrid::GetColMinimalAcceptableWidth() const { diff --git a/src/generic/laywin.cpp b/src/generic/laywin.cpp index b9571b23be..524f4bf45a 100644 --- a/src/generic/laywin.cpp +++ b/src/generic/laywin.cpp @@ -159,12 +159,12 @@ void wxSashLayoutWindow::OnCalculateLayout(wxCalculateLayoutEvent& event) { // If not in query mode, resize the window. // TODO: add wxRect& form to wxWindow::SetSize - wxSize sz = GetSize(); + wxSize sz2 = GetSize(); wxPoint pos = GetPosition(); SetSize(thisRect.x, thisRect.y, thisRect.width, thisRect.height); // Make sure the sash is erased when the window is resized - if ((pos.x != thisRect.x || pos.y != thisRect.y || sz.x != thisRect.width || sz.y != thisRect.height) && + if ((pos.x != thisRect.x || pos.y != thisRect.y || sz2.x != thisRect.width || sz2.y != thisRect.height) && (GetSashVisible(wxSASH_TOP) || GetSashVisible(wxSASH_RIGHT) || GetSashVisible(wxSASH_BOTTOM) || GetSashVisible(wxSASH_LEFT))) Refresh(true); diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index cd1e3dd934..dff0f46813 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -285,7 +285,7 @@ private: WX_DECLARE_LIST(wxListItemData, wxListItemDataList); #include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxListItemDataList); +WX_DEFINE_LIST(wxListItemDataList) class wxListLineData { @@ -413,7 +413,7 @@ private: WX_DECLARE_EXPORTED_OBJARRAY(wxListLineData, wxListLineDataArray); #include "wx/arrimpl.cpp" -WX_DEFINE_OBJARRAY(wxListLineDataArray); +WX_DEFINE_OBJARRAY(wxListLineDataArray) //----------------------------------------------------------------------------- // wxListHeaderWindow (internal) @@ -519,7 +519,7 @@ private: WX_DECLARE_LIST(wxListHeaderData, wxListHeaderDataList); #include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxListHeaderDataList); +WX_DEFINE_LIST(wxListHeaderDataList) class wxListMainWindow : public wxScrolledWindow { diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index 6c575277ae..0a3d466337 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -678,8 +678,7 @@ wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog() void wxGenericPrintSetupDialog::OnPrinter(wxListEvent& event) { // Delete check mark - long item; - for (item = 0; item < m_printerListCtrl->GetItemCount(); item++) + for (long item = 0; item < m_printerListCtrl->GetItemCount(); item++) m_printerListCtrl->SetItemImage( item, -1 ); m_printerListCtrl->SetItemImage( event.GetIndex(), 0 ); @@ -690,14 +689,12 @@ void wxGenericPrintSetupDialog::OnPrinter(wxListEvent& event) } else { - wxString tmp = wxT("lpr -P"); - wxListItem item; - item.SetColumn( 1 ); - item.SetMask( wxLIST_MASK_TEXT ); - item.SetId( event.GetIndex() ); - m_printerListCtrl->GetItem( item ); - tmp += item.GetText(); - m_printerCommandText->SetValue( tmp ); + wxListItem li; + li.SetColumn( 1 ); + li.SetMask( wxLIST_MASK_TEXT ); + li.SetId( event.GetIndex() ); + m_printerListCtrl->GetItem( li ); + m_printerCommandText->SetValue( _T("lpr -P") + li.GetText() ); } } diff --git a/src/generic/splash.cpp b/src/generic/splash.cpp index 75c2601ef1..e17b168167 100644 --- a/src/generic/splash.cpp +++ b/src/generic/splash.cpp @@ -36,7 +36,7 @@ #define wxSPLASH_TIMER_ID 9999 -IMPLEMENT_DYNAMIC_CLASS(wxSplashScreen, wxFrame); +IMPLEMENT_DYNAMIC_CLASS(wxSplashScreen, wxFrame) BEGIN_EVENT_TABLE(wxSplashScreen, wxFrame) EVT_TIMER(wxSPLASH_TIMER_ID, wxSplashScreen::OnNotify) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 4f86423e29..aaf7989b30 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -72,6 +72,7 @@ #include #endif // HAVE_POLL/!HAVE_POLL +#include "wx/unix/private.h" #include "wx/gtk/win_gtk.h" #include @@ -306,23 +307,23 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) fd_set readfds; fd_set writefds; fd_set exceptfds; - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); + wxFD_ZERO(&readfds); + wxFD_ZERO(&writefds); + wxFD_ZERO(&exceptfds); unsigned int i; for ( i = 0; i < nfds; i++ ) { - wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") ); + wxASSERT_MSG( ufds[i].fd < wxFD_SETSIZE, _T("fd out of range") ); if ( ufds[i].events & G_IO_IN ) - FD_SET(ufds[i].fd, &readfds); + wxFD_SET(ufds[i].fd, &readfds); if ( ufds[i].events & G_IO_PRI ) - FD_SET(ufds[i].fd, &exceptfds); + wxFD_SET(ufds[i].fd, &exceptfds); if ( ufds[i].events & G_IO_OUT ) - FD_SET(ufds[i].fd, &writefds); + wxFD_SET(ufds[i].fd, &writefds); if ( ufds[i].fd > fdMax ) fdMax = ufds[i].fd; @@ -336,13 +337,13 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) { ufds[i].revents = 0; - if ( FD_ISSET(ufds[i].fd, &readfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &readfds ) ) ufds[i].revents |= G_IO_IN; - if ( FD_ISSET(ufds[i].fd, &exceptfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &exceptfds ) ) ufds[i].revents |= G_IO_PRI; - if ( FD_ISSET(ufds[i].fd, &writefds ) ) + if ( wxFD_ISSET(ufds[i].fd, &writefds ) ) ufds[i].revents |= G_IO_OUT; } diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index b72abe13b5..1ea0526a59 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -1590,7 +1590,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) #endif } -void wxBitmap::UngetRawData(wxPixelDataBase& data) +void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) { } @@ -1621,19 +1621,36 @@ wxBitmapHandler::~wxBitmapHandler() { } -bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) +bool wxBitmapHandler::Create(wxBitmap * WXUNUSED(bitmap), + void * WXUNUSED(data), + long WXUNUSED(type), + int WXUNUSED(width), + int WXUNUSED(height), + int WXUNUSED(depth)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } -bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) +bool wxBitmapHandler::LoadFile(wxBitmap * WXUNUSED(bitmap), + const wxString& WXUNUSED(name), + long WXUNUSED(flags), + int WXUNUSED(desiredWidth), + int WXUNUSED(desiredHeight)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } -bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +bool wxBitmapHandler::SaveFile(const wxBitmap * WXUNUSED(bitmap), + const wxString& WXUNUSED(name), + int WXUNUSED(type), + const wxPalette * WXUNUSED(palette)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 4b8aaa9de8..ee5fdba2a5 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -844,12 +844,12 @@ void wxComboBox::OnChar( wxKeyEvent &event ) if ( event.GetKeyCode() == WXK_RETURN ) { // GTK automatically selects an item if its in the list - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId()); - event.SetString( GetValue() ); - event.SetInt( GetSelection() ); - event.SetEventObject( this ); + wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId()); + eventEnter.SetString( GetValue() ); + eventEnter.SetInt( GetSelection() ); + eventEnter.SetEventObject( this ); - if (!GetEventHandler()->ProcessEvent( event )) + if (!GetEventHandler()->ProcessEvent( eventEnter )) { // This will invoke the dialog default action, such // as the clicking the default button. diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 87bbe49cab..353ecd4501 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -88,9 +88,9 @@ void gdk_wx_draw_bitmap(GdkDrawable *drawable, gint width, gint height) { - g_return_if_fail (drawable != NULL); - g_return_if_fail (src != NULL); - g_return_if_fail (gc != NULL); + wxCHECK_RET( drawable, _T("NULL drawable in gdk_wx_draw_bitmap") ); + wxCHECK_RET( src, _T("NULL src in gdk_wx_draw_bitmap") ); + wxCHECK_RET( gc, _T("NULL gc in gdk_wx_draw_bitmap") ); #ifdef __WXGTK20__ gint src_width, src_height; diff --git a/src/gtk/eggtrayicon.c b/src/gtk/eggtrayicon.c index 10aed866ae..fb6a78067c 100644 --- a/src/gtk/eggtrayicon.c +++ b/src/gtk/eggtrayicon.c @@ -148,7 +148,8 @@ egg_tray_icon_get_type (void) (GInstanceInitFunc) egg_tray_icon_init }; - our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); + our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", + &our_info, (GTypeFlags)0); } return our_type; diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 52e4bf8ff1..e5b773de69 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -106,7 +106,7 @@ static gint gtk_listitem_focus_in_callback( GtkWidget *widget, { // not yet, notify it win->m_hasFocus = TRUE; - + wxChildFocusEvent eventChildFocus(win); (void)win->GetEventHandler()->ProcessEvent(eventChildFocus); @@ -247,9 +247,9 @@ gtk_listbox_button_press_callback( GtkWidget *widget, for (i = 0; i < (int)listbox->GetCount(); i++) if (i != sel) gtk_list_unselect_item( GTK_LIST(listbox->m_list), i ); - + listbox->m_blockEvent = FALSE; - + return false; } @@ -310,21 +310,21 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis #endif // wxUSE_CHECKLISTBOX // Check or uncheck item with SPACE - if ((gdk_event->keyval == ' ') && (!ret) && + if ((gdk_event->keyval == ' ') && (!ret) && (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) || ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) ) { int sel = listbox->GtkGetIndex( widget ); - + if (sel != -1) { ret = TRUE; - + if (listbox->IsSelected( sel )) gtk_list_unselect_item( listbox->m_list, sel ); else gtk_list_select_item( listbox->m_list, sel ); - + wxCommandEvent new_event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); new_event.SetEventObject( listbox ); wxArrayInt aSelections; @@ -346,7 +346,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis listbox->GetEventHandler()->ProcessEvent( new_event ); } } - + if (ret) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); @@ -435,11 +435,11 @@ gtk_listbox_realized_callback( GtkWidget *m_widget, wxListBox *win ) { if (g_isIdle) wxapp_install_idle_handler(); - + GList *child = win->m_list->children; for (child = win->m_list->children; child != NULL; child = child->next) gtk_widget_show( GTK_WIDGET(child->data) ); - + return false; } } @@ -536,7 +536,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, gtk_signal_connect( GTK_OBJECT(m_list), "realize", GTK_SIGNAL_FUNC(gtk_listbox_realized_callback), (gpointer) this ); - + if ( style & wxLB_SORT ) { // this will change DoAppend() behaviour @@ -730,7 +730,7 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) if (GTK_WIDGET_REALIZED(m_widget)) { gtk_widget_show( list_item ); - + gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); @@ -745,8 +745,7 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) { gtk_widget_modify_style( GTK_WIDGET( list_item ), style ); GtkBin *bin = GTK_BIN( list_item ); - GtkWidget *label = GTK_WIDGET( bin->child ); - gtk_widget_modify_style( label, style ); + gtk_widget_modify_style( GTK_WIDGET( bin->child ), style ); gtk_rc_style_unref( style ); } } @@ -1131,7 +1130,7 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window ) { return TRUE; -#if 0 +#if 0 if (m_widget->window == window) return TRUE; if (GTK_WIDGET(m_list)->window == window) return TRUE; @@ -1242,7 +1241,7 @@ wxSize wxListBox::DoGetBestSize() const lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); wxSize best(lbWidth, lbHeight); - CacheBestSize(best); + CacheBestSize(best); return best; } diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 0ebddfe17e..26b690e4fd 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -1021,19 +1021,19 @@ void wxScrolledWindow::OnChar(wxKeyEvent& event) int xScroll = GetScrollPos(wxHORIZONTAL); if ( xScroll != xScrollOld ) { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, - wxHORIZONTAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxScrollWinEvent eventS(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, + wxHORIZONTAL); + eventS.SetEventObject(this); + GetEventHandler()->ProcessEvent(eventS); } int yScroll = GetScrollPos(wxVERTICAL); if ( yScroll != yScrollOld ) { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, - wxVERTICAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxScrollWinEvent eventS(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, + wxVERTICAL); + eventS.SetEventObject(this); + GetEventHandler()->ProcessEvent(eventS); } } diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index c7e586c799..ad07a8affb 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -348,20 +348,20 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); if ( !def || !def->font_desc ) - def = gtk_widget_get_default_style(); + def = gtk_widget_get_default_style(); if ( def && def->font_desc ) - { - wxNativeFontInfo info; - info.description = + { + wxNativeFontInfo info; + info.description = pango_font_description_copy(def->font_desc); - gs_objects.m_fontSystem = wxFont(info); - } - else - { + gs_objects.m_fontSystem = wxFont(info); + } + else + { GtkSettings *settings = gtk_settings_get_default(); gchar *font_name = NULL; g_object_get ( settings, - "gtk-font-name", + "gtk-font-name", &font_name, NULL); if (!font_name) @@ -369,7 +369,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) else gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name)); g_free (font_name); - } + } gtk_widget_destroy( widget ); #else gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); @@ -387,7 +387,7 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) { #ifdef __WXGTK20__ bool success = false; - + guchar *data = NULL; GdkWindow *window = NULL; if(win && GTK_WIDGET_REALIZED(win->GetHandle())) @@ -428,15 +428,15 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false))) return -1; } - + // Get the frame extents from the windowmanager. // In most cases the top extent is the titlebar, so we use the bottom extent // for the heights. - + Atom type; gint format; gulong nitems; - + #if GTK_CHECK_VERSION(2,2,0) if (!gtk_check_version(2,2,0)) { @@ -650,12 +650,12 @@ bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) { switch (index) { - case wxSYS_CAN_ICONIZE_FRAME: - return FALSE; - break; + case wxSYS_CAN_ICONIZE_FRAME: + return FALSE; + case wxSYS_CAN_DRAW_FRAME_DECORATIONS: - return TRUE; - break; + return TRUE; + default: return FALSE; } diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index a6920de7f9..555803cd80 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -428,15 +428,16 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarToolsList::compatibility_iterator node = wxToolBarToolsList::compatibility_iterator(); - if ( pos ) node = m_tools.Item(pos - 1); + if ( pos ) + node = m_tools.Item(pos - 1); while ( node ) { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - if ( !tool->IsRadio() ) + wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData(); + if ( !toolNext->IsRadio() ) break; - widget = tool->m_item; + widget = toolNext->m_item; node = node->GetPrevious(); } diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index 280f57a98b..44222ba55c 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -70,7 +70,7 @@ static void gtk_pizza_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); - + static void gtk_pizza_allocate_child (GtkPizza *pizza, GtkPizzaChild *child); static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, @@ -102,7 +102,9 @@ static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza, static GtkContainerClass *pizza_parent_class = NULL; #endif +#ifndef __WXGTK20__ static gboolean gravity_works; +#endif GtkType gtk_pizza_get_type () @@ -111,7 +113,7 @@ gtk_pizza_get_type () if (!pizza_type) { - + #ifdef __WXGTK20__ static const GTypeInfo pizza_info = { @@ -125,7 +127,7 @@ gtk_pizza_get_type () 16, /* n_preallocs */ (GInstanceInitFunc) gtk_pizza_init, }; - pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, 0); + pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, (GTypeFlags)0); #else GtkTypeInfo pizza_info = { @@ -404,7 +406,7 @@ gtk_pizza_move (GtkPizza *pizza, child->x = x; child->y = y; - + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza)) gtk_widget_queue_resize (widget); break; @@ -642,7 +644,7 @@ gtk_pizza_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL ); - + /* gdk_window_set_back_pixmap( widget->window, NULL, FALSE ); gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE ); @@ -652,10 +654,10 @@ gtk_pizza_realize (GtkWidget *widget) /* add filters for intercepting visibility and expose events */ gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza); gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza); -#endif /* we NEED gravity or we'll give up */ gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE); +#endif // !__WXGTK20__ /* cannot be done before realisation */ children = pizza->children; @@ -836,9 +838,9 @@ gtk_pizza_expose (GtkWidget *widget, #ifdef __WXGTK20__ (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event); - + return FALSE; - + #else children = pizza->children; @@ -856,9 +858,9 @@ gtk_pizza_expose (GtkWidget *widget, gtk_widget_event (child->widget, (GdkEvent*) &child_event); } } - + return TRUE; - + #endif } @@ -1104,7 +1106,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) if (pizza->bin_window) gdk_window_scroll( pizza->bin_window, -dx, -dy ); -#else +#else // !__WXGTK20__ GtkWidget *widget; XEvent xevent; XID win; @@ -1236,7 +1238,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) } } } -#endif /* __WXGTK20__ */ +#endif /* __WXGTK20__/!__WXGTK20__ */ } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 03c6f88e39..7bd13fae8e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -239,7 +239,9 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; // hack: we need something to pass to gtk_menu_popup, so we store the time of // the last click here +#ifndef __WXGTK20__ static guint32 gs_timeLastClick = 0; +#endif extern bool g_mainThreadLocked; @@ -1388,9 +1390,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if ( btnCancel ) { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject(btnCancel); - ret = btnCancel->GetEventHandler()->ProcessEvent(event); + wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + eventClick.SetEventObject(btnCancel); + ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick); } } @@ -1799,9 +1801,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, if ( !g_captureWindow ) win = FindWindowForMouseEvent(win, event.m_x, event.m_y); +#ifndef __WXGTK20__ gs_timeLastClick = gdk_event->time; -#ifndef __WXGTK20__ if (event_type == wxEVT_LEFT_DCLICK) { // GTK 1.2 crashes when intercepting double @@ -1813,7 +1815,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, return FALSE; } } -#endif +#endif // !__WXGTK20__ if (win->GetEventHandler()->ProcessEvent( event )) { @@ -1958,11 +1960,11 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, // the mouse changed window g_captureWindowHasMouse = hasMouse; - wxMouseEvent event(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW - : wxEVT_LEAVE_WINDOW); - InitMouseEvent(win, event, gdk_event); - event.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(event); + wxMouseEvent eventM(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW + : wxEVT_LEAVE_WINDOW); + InitMouseEvent(win, eventM, gdk_event); + eventM.SetEventObject(win); + win->GetEventHandler()->ProcessEvent(eventM); } } else // no capture diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 4f86423e29..aaf7989b30 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -72,6 +72,7 @@ #include #endif // HAVE_POLL/!HAVE_POLL +#include "wx/unix/private.h" #include "wx/gtk/win_gtk.h" #include @@ -306,23 +307,23 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) fd_set readfds; fd_set writefds; fd_set exceptfds; - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); + wxFD_ZERO(&readfds); + wxFD_ZERO(&writefds); + wxFD_ZERO(&exceptfds); unsigned int i; for ( i = 0; i < nfds; i++ ) { - wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") ); + wxASSERT_MSG( ufds[i].fd < wxFD_SETSIZE, _T("fd out of range") ); if ( ufds[i].events & G_IO_IN ) - FD_SET(ufds[i].fd, &readfds); + wxFD_SET(ufds[i].fd, &readfds); if ( ufds[i].events & G_IO_PRI ) - FD_SET(ufds[i].fd, &exceptfds); + wxFD_SET(ufds[i].fd, &exceptfds); if ( ufds[i].events & G_IO_OUT ) - FD_SET(ufds[i].fd, &writefds); + wxFD_SET(ufds[i].fd, &writefds); if ( ufds[i].fd > fdMax ) fdMax = ufds[i].fd; @@ -336,13 +337,13 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) { ufds[i].revents = 0; - if ( FD_ISSET(ufds[i].fd, &readfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &readfds ) ) ufds[i].revents |= G_IO_IN; - if ( FD_ISSET(ufds[i].fd, &exceptfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &exceptfds ) ) ufds[i].revents |= G_IO_PRI; - if ( FD_ISSET(ufds[i].fd, &writefds ) ) + if ( wxFD_ISSET(ufds[i].fd, &writefds ) ) ufds[i].revents |= G_IO_OUT; } diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index b72abe13b5..1ea0526a59 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -1590,7 +1590,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) #endif } -void wxBitmap::UngetRawData(wxPixelDataBase& data) +void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) { } @@ -1621,19 +1621,36 @@ wxBitmapHandler::~wxBitmapHandler() { } -bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) +bool wxBitmapHandler::Create(wxBitmap * WXUNUSED(bitmap), + void * WXUNUSED(data), + long WXUNUSED(type), + int WXUNUSED(width), + int WXUNUSED(height), + int WXUNUSED(depth)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } -bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) +bool wxBitmapHandler::LoadFile(wxBitmap * WXUNUSED(bitmap), + const wxString& WXUNUSED(name), + long WXUNUSED(flags), + int WXUNUSED(desiredWidth), + int WXUNUSED(desiredHeight)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } -bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +bool wxBitmapHandler::SaveFile(const wxBitmap * WXUNUSED(bitmap), + const wxString& WXUNUSED(name), + int WXUNUSED(type), + const wxPalette * WXUNUSED(palette)) { + wxFAIL_MSG( _T("not implemented") ); + return false; } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 4b8aaa9de8..ee5fdba2a5 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -844,12 +844,12 @@ void wxComboBox::OnChar( wxKeyEvent &event ) if ( event.GetKeyCode() == WXK_RETURN ) { // GTK automatically selects an item if its in the list - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId()); - event.SetString( GetValue() ); - event.SetInt( GetSelection() ); - event.SetEventObject( this ); + wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId()); + eventEnter.SetString( GetValue() ); + eventEnter.SetInt( GetSelection() ); + eventEnter.SetEventObject( this ); - if (!GetEventHandler()->ProcessEvent( event )) + if (!GetEventHandler()->ProcessEvent( eventEnter )) { // This will invoke the dialog default action, such // as the clicking the default button. diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 87bbe49cab..353ecd4501 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -88,9 +88,9 @@ void gdk_wx_draw_bitmap(GdkDrawable *drawable, gint width, gint height) { - g_return_if_fail (drawable != NULL); - g_return_if_fail (src != NULL); - g_return_if_fail (gc != NULL); + wxCHECK_RET( drawable, _T("NULL drawable in gdk_wx_draw_bitmap") ); + wxCHECK_RET( src, _T("NULL src in gdk_wx_draw_bitmap") ); + wxCHECK_RET( gc, _T("NULL gc in gdk_wx_draw_bitmap") ); #ifdef __WXGTK20__ gint src_width, src_height; diff --git a/src/gtk1/eggtrayicon.c b/src/gtk1/eggtrayicon.c index 10aed866ae..fb6a78067c 100644 --- a/src/gtk1/eggtrayicon.c +++ b/src/gtk1/eggtrayicon.c @@ -148,7 +148,8 @@ egg_tray_icon_get_type (void) (GInstanceInitFunc) egg_tray_icon_init }; - our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); + our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", + &our_info, (GTypeFlags)0); } return our_type; diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 52e4bf8ff1..e5b773de69 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -106,7 +106,7 @@ static gint gtk_listitem_focus_in_callback( GtkWidget *widget, { // not yet, notify it win->m_hasFocus = TRUE; - + wxChildFocusEvent eventChildFocus(win); (void)win->GetEventHandler()->ProcessEvent(eventChildFocus); @@ -247,9 +247,9 @@ gtk_listbox_button_press_callback( GtkWidget *widget, for (i = 0; i < (int)listbox->GetCount(); i++) if (i != sel) gtk_list_unselect_item( GTK_LIST(listbox->m_list), i ); - + listbox->m_blockEvent = FALSE; - + return false; } @@ -310,21 +310,21 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis #endif // wxUSE_CHECKLISTBOX // Check or uncheck item with SPACE - if ((gdk_event->keyval == ' ') && (!ret) && + if ((gdk_event->keyval == ' ') && (!ret) && (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) || ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) ) { int sel = listbox->GtkGetIndex( widget ); - + if (sel != -1) { ret = TRUE; - + if (listbox->IsSelected( sel )) gtk_list_unselect_item( listbox->m_list, sel ); else gtk_list_select_item( listbox->m_list, sel ); - + wxCommandEvent new_event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); new_event.SetEventObject( listbox ); wxArrayInt aSelections; @@ -346,7 +346,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis listbox->GetEventHandler()->ProcessEvent( new_event ); } } - + if (ret) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); @@ -435,11 +435,11 @@ gtk_listbox_realized_callback( GtkWidget *m_widget, wxListBox *win ) { if (g_isIdle) wxapp_install_idle_handler(); - + GList *child = win->m_list->children; for (child = win->m_list->children; child != NULL; child = child->next) gtk_widget_show( GTK_WIDGET(child->data) ); - + return false; } } @@ -536,7 +536,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, gtk_signal_connect( GTK_OBJECT(m_list), "realize", GTK_SIGNAL_FUNC(gtk_listbox_realized_callback), (gpointer) this ); - + if ( style & wxLB_SORT ) { // this will change DoAppend() behaviour @@ -730,7 +730,7 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) if (GTK_WIDGET_REALIZED(m_widget)) { gtk_widget_show( list_item ); - + gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); @@ -745,8 +745,7 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) { gtk_widget_modify_style( GTK_WIDGET( list_item ), style ); GtkBin *bin = GTK_BIN( list_item ); - GtkWidget *label = GTK_WIDGET( bin->child ); - gtk_widget_modify_style( label, style ); + gtk_widget_modify_style( GTK_WIDGET( bin->child ), style ); gtk_rc_style_unref( style ); } } @@ -1131,7 +1130,7 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window ) { return TRUE; -#if 0 +#if 0 if (m_widget->window == window) return TRUE; if (GTK_WIDGET(m_list)->window == window) return TRUE; @@ -1242,7 +1241,7 @@ wxSize wxListBox::DoGetBestSize() const lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); wxSize best(lbWidth, lbHeight); - CacheBestSize(best); + CacheBestSize(best); return best; } diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index 0ebddfe17e..26b690e4fd 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -1021,19 +1021,19 @@ void wxScrolledWindow::OnChar(wxKeyEvent& event) int xScroll = GetScrollPos(wxHORIZONTAL); if ( xScroll != xScrollOld ) { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, - wxHORIZONTAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxScrollWinEvent eventS(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, + wxHORIZONTAL); + eventS.SetEventObject(this); + GetEventHandler()->ProcessEvent(eventS); } int yScroll = GetScrollPos(wxVERTICAL); if ( yScroll != yScrollOld ) { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, - wxVERTICAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxScrollWinEvent eventS(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, + wxVERTICAL); + eventS.SetEventObject(this); + GetEventHandler()->ProcessEvent(eventS); } } diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index c7e586c799..ad07a8affb 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -348,20 +348,20 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) GtkWidget *widget = gtk_button_new(); GtkStyle *def = gtk_rc_get_style( widget ); if ( !def || !def->font_desc ) - def = gtk_widget_get_default_style(); + def = gtk_widget_get_default_style(); if ( def && def->font_desc ) - { - wxNativeFontInfo info; - info.description = + { + wxNativeFontInfo info; + info.description = pango_font_description_copy(def->font_desc); - gs_objects.m_fontSystem = wxFont(info); - } - else - { + gs_objects.m_fontSystem = wxFont(info); + } + else + { GtkSettings *settings = gtk_settings_get_default(); gchar *font_name = NULL; g_object_get ( settings, - "gtk-font-name", + "gtk-font-name", &font_name, NULL); if (!font_name) @@ -369,7 +369,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) else gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name)); g_free (font_name); - } + } gtk_widget_destroy( widget ); #else gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); @@ -387,7 +387,7 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) { #ifdef __WXGTK20__ bool success = false; - + guchar *data = NULL; GdkWindow *window = NULL; if(win && GTK_WIDGET_REALIZED(win->GetHandle())) @@ -428,15 +428,15 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false))) return -1; } - + // Get the frame extents from the windowmanager. // In most cases the top extent is the titlebar, so we use the bottom extent // for the heights. - + Atom type; gint format; gulong nitems; - + #if GTK_CHECK_VERSION(2,2,0) if (!gtk_check_version(2,2,0)) { @@ -650,12 +650,12 @@ bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) { switch (index) { - case wxSYS_CAN_ICONIZE_FRAME: - return FALSE; - break; + case wxSYS_CAN_ICONIZE_FRAME: + return FALSE; + case wxSYS_CAN_DRAW_FRAME_DECORATIONS: - return TRUE; - break; + return TRUE; + default: return FALSE; } diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index a6920de7f9..555803cd80 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -428,15 +428,16 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarToolsList::compatibility_iterator node = wxToolBarToolsList::compatibility_iterator(); - if ( pos ) node = m_tools.Item(pos - 1); + if ( pos ) + node = m_tools.Item(pos - 1); while ( node ) { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - if ( !tool->IsRadio() ) + wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData(); + if ( !toolNext->IsRadio() ) break; - widget = tool->m_item; + widget = toolNext->m_item; node = node->GetPrevious(); } diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index 280f57a98b..44222ba55c 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -70,7 +70,7 @@ static void gtk_pizza_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); - + static void gtk_pizza_allocate_child (GtkPizza *pizza, GtkPizzaChild *child); static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, @@ -102,7 +102,9 @@ static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza, static GtkContainerClass *pizza_parent_class = NULL; #endif +#ifndef __WXGTK20__ static gboolean gravity_works; +#endif GtkType gtk_pizza_get_type () @@ -111,7 +113,7 @@ gtk_pizza_get_type () if (!pizza_type) { - + #ifdef __WXGTK20__ static const GTypeInfo pizza_info = { @@ -125,7 +127,7 @@ gtk_pizza_get_type () 16, /* n_preallocs */ (GInstanceInitFunc) gtk_pizza_init, }; - pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, 0); + pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, (GTypeFlags)0); #else GtkTypeInfo pizza_info = { @@ -404,7 +406,7 @@ gtk_pizza_move (GtkPizza *pizza, child->x = x; child->y = y; - + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza)) gtk_widget_queue_resize (widget); break; @@ -642,7 +644,7 @@ gtk_pizza_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL ); - + /* gdk_window_set_back_pixmap( widget->window, NULL, FALSE ); gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE ); @@ -652,10 +654,10 @@ gtk_pizza_realize (GtkWidget *widget) /* add filters for intercepting visibility and expose events */ gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza); gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza); -#endif /* we NEED gravity or we'll give up */ gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE); +#endif // !__WXGTK20__ /* cannot be done before realisation */ children = pizza->children; @@ -836,9 +838,9 @@ gtk_pizza_expose (GtkWidget *widget, #ifdef __WXGTK20__ (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event); - + return FALSE; - + #else children = pizza->children; @@ -856,9 +858,9 @@ gtk_pizza_expose (GtkWidget *widget, gtk_widget_event (child->widget, (GdkEvent*) &child_event); } } - + return TRUE; - + #endif } @@ -1104,7 +1106,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) if (pizza->bin_window) gdk_window_scroll( pizza->bin_window, -dx, -dy ); -#else +#else // !__WXGTK20__ GtkWidget *widget; XEvent xevent; XID win; @@ -1236,7 +1238,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) } } } -#endif /* __WXGTK20__ */ +#endif /* __WXGTK20__/!__WXGTK20__ */ } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 03c6f88e39..7bd13fae8e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -239,7 +239,9 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; // hack: we need something to pass to gtk_menu_popup, so we store the time of // the last click here +#ifndef __WXGTK20__ static guint32 gs_timeLastClick = 0; +#endif extern bool g_mainThreadLocked; @@ -1388,9 +1390,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if ( btnCancel ) { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject(btnCancel); - ret = btnCancel->GetEventHandler()->ProcessEvent(event); + wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + eventClick.SetEventObject(btnCancel); + ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick); } } @@ -1799,9 +1801,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, if ( !g_captureWindow ) win = FindWindowForMouseEvent(win, event.m_x, event.m_y); +#ifndef __WXGTK20__ gs_timeLastClick = gdk_event->time; -#ifndef __WXGTK20__ if (event_type == wxEVT_LEFT_DCLICK) { // GTK 1.2 crashes when intercepting double @@ -1813,7 +1815,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, return FALSE; } } -#endif +#endif // !__WXGTK20__ if (win->GetEventHandler()->ProcessEvent( event )) { @@ -1958,11 +1960,11 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, // the mouse changed window g_captureWindowHasMouse = hasMouse; - wxMouseEvent event(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW - : wxEVT_LEAVE_WINDOW); - InitMouseEvent(win, event, gdk_event); - event.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(event); + wxMouseEvent eventM(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW + : wxEVT_LEAVE_WINDOW); + InitMouseEvent(win, eventM, gdk_event); + eventM.SetEventObject(win); + win->GetEventHandler()->ProcessEvent(eventM); } } else // no capture diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index de2498063f..9aa5f8d1b9 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -462,17 +462,17 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f) } else { - int cnt = 0; + int cnt2 = 0; wxHtmlHelpDataItem *parent = m_index[i].parent; for (int j = i-1; j >= 0; j--) { if (m_index[j].book == book && m_index[j].level > 0) - cnt++; + cnt2++; if (&m_index[j] == parent) break; } - wxASSERT(cnt > 0); - CacheWriteInt32(f, cnt); + wxASSERT(cnt2 > 0); + CacheWriteInt32(f, cnt2); } } return true; diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index b2db6ded54..b4538e4fa0 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -646,8 +646,6 @@ void wxHtmlContainerCell::Layout(int w) return; } - wxHtmlCell *cell = m_Cells, - *line = m_Cells; wxHtmlCell *nextCell; long xpos = 0, ypos = m_IndentTop; int xdelta = 0, ybasicpos = 0, ydiff; @@ -694,6 +692,8 @@ void wxHtmlContainerCell::Layout(int w) s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); // my own layouting: + wxHtmlCell *cell = m_Cells, + *line = m_Cells; while (cell != NULL) { switch (m_AlignVer) diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index f11ebb2af6..d6b6ab4c32 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -52,7 +52,7 @@ public: }; WX_DECLARE_OBJARRAY(wxHtmlTextPiece, wxHtmlTextPieces); -WX_DEFINE_OBJARRAY(wxHtmlTextPieces); +WX_DEFINE_OBJARRAY(wxHtmlTextPieces) class wxHtmlParserState { diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index a1f8c33629..353f589c3a 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -135,10 +135,10 @@ private: //----------------------------------------------------------------------------- WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray); -WX_DEFINE_OBJARRAY(wxHtmlHistoryArray); +WX_DEFINE_OBJARRAY(wxHtmlHistoryArray) WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList); -WX_DEFINE_LIST(wxHtmlProcessorList); +WX_DEFINE_LIST(wxHtmlProcessorList) //----------------------------------------------------------------------------- // wxHtmlWindow diff --git a/src/html/m_image.cpp b/src/html/m_image.cpp index 75fe3adbd5..c4e902cb96 100644 --- a/src/html/m_image.cpp +++ b/src/html/m_image.cpp @@ -43,7 +43,7 @@ FORCE_LINK_ME(m_image) WX_DECLARE_OBJARRAY(int, CoordArray); #include "wx/arrimpl.cpp" // this is a magic incantation which must be done! -WX_DEFINE_OBJARRAY(CoordArray); +WX_DEFINE_OBJARRAY(CoordArray) // --------------------------------------------------------------------------- @@ -692,12 +692,13 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA") } if (cel != NULL && tag.HasParam(wxT("HREF"))) { - wxString tmp = tag.GetParam(wxT("HREF")); - wxString target = wxEmptyString; - if (tag.HasParam(wxT("TARGET"))) target = tag.GetParam(wxT("TARGET")); - cel->SetLink( wxHtmlLinkInfo(tmp, target)); + wxString target; + if (tag.HasParam(wxT("TARGET"))) + target = tag.GetParam(wxT("TARGET")); + cel->SetLink(wxHtmlLinkInfo(tag.GetParam(wxT("HREF")), target)); } - if (cel != NULL) m_WParser->GetContainer()->InsertCell( cel ); + if (cel != NULL) + m_WParser->GetContainer()->InsertCell( cel ); } } diff --git a/src/motif/evtloop.cpp b/src/motif/evtloop.cpp index 9172b29717..c2f7d4ac31 100644 --- a/src/motif/evtloop.cpp +++ b/src/motif/evtloop.cpp @@ -42,6 +42,7 @@ #pragma message enable nosimpint #endif +#include "wx/unix/private.h" #include "wx/motif/private.h" static bool CheckForKeyUp(XEvent* event); @@ -424,8 +425,8 @@ static void wxInputCallback( XtPointer, int* fd, XtInputId* ) timeout.tv_sec = 0; timeout.tv_usec = 0; - FD_ZERO( &in ); - FD_SET( *fd, &in ); + wxFD_ZERO( &in ); + wxFD_SET( *fd, &in ); if( select( *fd + 1, &in, NULL, NULL, &timeout ) <= 0 ) break; @@ -445,8 +446,8 @@ static void wxBreakDispatch() timeout.tv_sec = 0; timeout.tv_usec = 0; - FD_ZERO( &in ); - FD_SET( idleFds[0], &in ); + wxFD_ZERO( &in ); + wxFD_SET( idleFds[0], &in ); if( select( idleFds[0] + 1, &in, NULL, NULL, &timeout ) > 0 ) return; diff --git a/src/unix/dlunix.cpp b/src/unix/dlunix.cpp index 08e2f9b0b8..5dc05dd279 100644 --- a/src/unix/dlunix.cpp +++ b/src/unix/dlunix.cpp @@ -293,7 +293,7 @@ public: wxDynamicLibraryDetails *details = new wxDynamicLibraryDetails; details->m_path = path; details->m_name = path.AfterLast(_T('/')); - details->m_address = wx_reinterpret_cast(void *, start); + details->m_address = wxUIntToPtr(start); details->m_length = end - start; // try to extract the library version from its name diff --git a/src/unix/fontenum.cpp b/src/unix/fontenum.cpp index d01014ad64..cf11e65ba8 100644 --- a/src/unix/fontenum.cpp +++ b/src/unix/fontenum.cpp @@ -43,8 +43,8 @@ extern GtkWidget *wxGetRootWindow(); #endif -static int -cmp_families (const void *a, const void *b) +extern "C" int wxCMPFUNC_CONV +wxCompareFamilies (const void *a, const void *b) { const char *a_name = pango_font_family_get_name (*(PangoFontFamily **)a); const char *b_name = pango_font_family_get_name (*(PangoFontFamily **)b); @@ -77,7 +77,7 @@ bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, wxTheApp->GetPangoContext(), #endif &families, &n_families ); - qsort (families, n_families, sizeof (PangoFontFamily *), cmp_families); + qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies); for (int i=0; i @@ -183,6 +179,7 @@ int _System soclose(int); #ifndef __GSOCKET_STANDALONE__ # include "wx/unix/gsockunx.h" +# include "wx/unix/private.h" # include "wx/gsocket.h" #else # include "gsockunx.h" @@ -721,9 +718,9 @@ GSocketError GSocket::Connect(GSocketStream stream) * non-blocking, it just shouldn't be called prior to knowing there is a * connection _if_ blocking sockets are being used. * If connect above returns 0, we are already connected and need to make the - * call to Enable_Events now. + * call to Enable_Events now. */ - + if (m_non_blocking || ret == 0) { gs_gui_functions->Enable_Events(this); @@ -975,18 +972,18 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags) if (m_fd == -1) return (GSOCK_LOST_FLAG & flags); - + /* Do not use a static struct, Linux can garble it */ tv.tv_sec = m_timeout / 1000; tv.tv_usec = (m_timeout % 1000) * 1000; - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); - FD_SET(m_fd, &readfds); + wxFD_ZERO(&readfds); + wxFD_ZERO(&writefds); + wxFD_ZERO(&exceptfds); + wxFD_SET(m_fd, &readfds); if (flags & GSOCK_OUTPUT_FLAG || flags & GSOCK_CONNECTION_FLAG) - FD_SET(m_fd, &writefds); - FD_SET(m_fd, &exceptfds); + wxFD_SET(m_fd, &writefds); + wxFD_SET(m_fd, &exceptfds); /* Check 'sticky' CONNECTION flag first */ result |= (GSOCK_CONNECTION_FLAG & m_detected); @@ -1009,7 +1006,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags) } /* Check for readability */ - if (FD_ISSET(m_fd, &readfds)) + if (wxFD_ISSET(m_fd, &readfds)) { char c; @@ -1038,7 +1035,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags) } /* Check for writability */ - if (FD_ISSET(m_fd, &writefds)) + if (wxFD_ISSET(m_fd, &writefds)) { if (m_establishing && !m_server) { @@ -1069,7 +1066,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags) } /* Check for exceptions and errors (is this useful in Unices?) */ - if (FD_ISSET(m_fd, &exceptfds)) + if (wxFD_ISSET(m_fd, &exceptfds)) { m_establishing = false; m_detected = GSOCK_LOST_FLAG; @@ -1250,8 +1247,8 @@ GSocketError GSocket::Input_Timeout() if (!m_non_blocking) { - FD_ZERO(&readfds); - FD_SET(m_fd, &readfds); + wxFD_ZERO(&readfds); + wxFD_SET(m_fd, &readfds); ret = select(m_fd + 1, &readfds, NULL, NULL, &tv); if (ret == 0) { @@ -1291,8 +1288,8 @@ GSocketError GSocket::Output_Timeout() if (!m_non_blocking) { - FD_ZERO(&writefds); - FD_SET(m_fd, &writefds); + wxFD_ZERO(&writefds); + wxFD_SET(m_fd, &writefds); ret = select(m_fd + 1, NULL, &writefds, NULL, &tv); if (ret == 0) { @@ -1310,7 +1307,7 @@ GSocketError GSocket::Output_Timeout() m_error = GSOCK_TIMEDOUT; return GSOCK_TIMEDOUT; } - if ( ! FD_ISSET(m_fd, &writefds) ) { + if ( ! wxFD_ISSET(m_fd, &writefds) ) { GSocket_Debug(( "GSocket_Output_Timeout is buggy!\n" )); } else { diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index 27720ea24e..fcb266cc1d 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -28,6 +28,7 @@ #include "wx/event.h" #include "wx/window.h" +#include "wx/unix/private.h" enum { wxJS_AXIS_X = 0, @@ -87,7 +88,7 @@ void* wxJoystickThread::Entry() fd_set read_fds; struct timeval time_out = {0, 0}; - FD_ZERO(&read_fds); + wxFD_ZERO(&read_fds); while (true) { if (TestDestroy()) @@ -100,9 +101,9 @@ void* wxJoystickThread::Entry() else time_out.tv_usec = 10 * 1000; // check at least every 10 msec in blocking case - FD_SET(m_device, &read_fds); + wxFD_SET(m_device, &read_fds); select(m_device+1, &read_fds, NULL, NULL, &time_out); - if (FD_ISSET(m_device, &read_fds)) + if (wxFD_ISSET(m_device, &read_fds)) { memset(&j_evt, 0, sizeof(j_evt)); read(m_device, &j_evt, sizeof(j_evt)); diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index d8f03b3876..e0bce49d8d 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -1417,7 +1417,10 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) // could adjust the code to ask confirmation if it already exists and // overwriteprompt is true, but this is currently ignored as *Associate* has // no overwrite prompt -bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt /*= true*/) +bool +wxFileTypeImpl::SetCommand(const wxString& cmd, + const wxString& verb, + bool WXUNUSED(overwriteprompt)) { wxArrayString strExtensions; wxString strDesc, strIcon; @@ -1441,7 +1444,7 @@ bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool } // ignore index on the grouds that we only have one icon in a Unix file -bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon /*= wxEmptyString*/, int /*index = 0*/) +bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int WXUNUSED(index)) { if (strIcon.empty()) return false; wxArrayString strExtensions; diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 14e588268a..94c3b21af2 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -760,7 +760,7 @@ void *wxThreadInternal::PthreadStart(wxThread *thread) wxLogTrace(TRACE_THREADS, _T("Thread %ld Entry() returned %lu."), - THR_ID(pthread), (unsigned long)pthread->m_exitcode); + THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode)); { wxCriticalSectionLocker lock(thread->m_critsect); @@ -1215,42 +1215,21 @@ void wxThread::SetPriority(unsigned int prio) case STATE_PAUSED: #ifdef HAVE_THREAD_PRIORITY_FUNCTIONS #if defined(__LINUX__) -// On Linux, pthread_setschedparam with SCHED_OTHER does not allow -// a priority other than 0. Instead, we use the BSD setpriority -// which alllows us to set a 'nice' value between 20 to -20. Only -// super user can set a value less than zero (more negative yields -// higher priority). setpriority set the static priority of a process, -// but this is OK since Linux is configured as a thread per process. - { - float fPrio; - float pSpan; - int iPrio; - - // Map Wx priorites (WXTHREAD_MIN_PRIORITY - - // WXTHREAD_MAX_PRIORITY) into BSD priorities (20 - -20). - // Do calculation of values instead of hard coding them - // to make maintenance easier. - - pSpan = ((float)(WXTHREAD_MAX_PRIORITY - WXTHREAD_MIN_PRIORITY)) / 2.0; - - // prio starts as ................... // value => (0) >= p <= (n) - - fPrio = ((float)prio) - pSpan; // value => (-n) >= p <= (+n) - - fPrio = 0.0 - fPrio; // value => (+n) <= p >= (-n) - - fPrio = fPrio * (20. / pSpan) + .5; // value => (20) <= p >= (-20) - - iPrio = (int)fPrio; - - // Clamp prio from 20 - -20; - iPrio = (iPrio > 20) ? 20 : iPrio; - iPrio = (iPrio < -20) ? -20 : iPrio; + // On Linux, pthread_setschedparam with SCHED_OTHER does not allow + // a priority other than 0. Instead, we use the BSD setpriority + // which alllows us to set a 'nice' value between 20 to -20. Only + // super user can set a value less than zero (more negative yields + // higher priority). setpriority set the static priority of a + // process, but this is OK since Linux is configured as a thread + // per process. + // + // FIXME this is not true for 2.6!! - if (setpriority(PRIO_PROCESS, 0, iPrio) == -1) - { - wxLogError(_("Failed to set thread priority %d."), prio); - } + // map wx priorites WXTHREAD_MIN_PRIORITY..WXTHREAD_MAX_PRIORITY + // to Unix priorities 20..-20 + if ( setpriority(PRIO_PROCESS, 0, -(2*prio)/5 + 20) == -1 ) + { + wxLogError(_("Failed to set thread priority %d."), prio); } #else // __LINUX__ { @@ -1541,7 +1520,8 @@ wxThread::~wxThread() if ( m_internal->GetState() != STATE_EXITED && m_internal->GetState() != STATE_NEW ) { - wxLogDebug(_T("The thread %ld is being destroyed although it is still running! The application may crash."), GetId()); + wxLogDebug(_T("The thread %ld is being destroyed although it is still running! The application may crash."), + (long)GetId()); } m_critsect.Leave(); diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index b9e17c0c14..62be2565e8 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -15,8 +15,6 @@ // headers // ---------------------------------------------------------------------------- -#include - // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -35,6 +33,9 @@ #include "wx/wfstream.h" #include "wx/unix/execute.h" +#include "wx/unix/private.h" + +#include #if wxUSE_STREAMS @@ -425,8 +426,10 @@ bool wxPipeInputStream::CanRead() const const int fd = m_file->fd(); fd_set readfds; - FD_ZERO(&readfds); - FD_SET(fd, &readfds); + + wxFD_ZERO(&readfds); + wxFD_SET(fd, &readfds); + switch ( select(fd + 1, &readfds, NULL, NULL, &tv) ) { case -1: @@ -454,13 +457,7 @@ bool wxPipeInputStream::CanRead() const // wxExecute: the real worker function // ---------------------------------------------------------------------------- -#ifdef __VMS - #pragma message disable codeunreachable -#endif - -long wxExecute(wxChar **argv, - int flags, - wxProcess *process) +long wxExecute(wxChar **argv, int flags, wxProcess *process) { // for the sync execution, we return -1 to indicate failure, but for async // case we return 0 which is never a valid PID @@ -609,7 +606,7 @@ long wxExecute(wxChar **argv, } execvp (*mb_argv, mb_argv); - + fprintf(stderr, "execvp("); // CS changed ppc to ppc_ as ppc is not available under mac os CW Mach-O for ( char **ppc_ = mb_argv; *ppc_; ppc_++ ) @@ -677,12 +674,10 @@ long wxExecute(wxChar **argv, return traits->WaitForChild(execData); } +#if !defined(__VMS) && !defined(__INTEL_COMPILER) return ERROR_RETURN_CODE; -} - -#ifdef __VMS - #pragma message enable codeunreachable #endif +} #undef ERROR_RETURN_CODE #undef ARGS_CLEANUP diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index 6510b0d3db..c31f11ee97 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -53,6 +53,10 @@ static Atom _NET_SUPPORTED = 0; if (name == 0) name = XInternAtom((display), #name, False) +// X11 Window is an int type, so use the macro to suppress warnings when +// converting to it +#define WindowCast(w) (Window)(wxPtrToUInt(w)) + // Is the window mapped? static bool IsMapped(Display *display, Window window) { @@ -159,7 +163,7 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, } XChangeProperty( (Display*)display, - (Window)window, + WindowCast(window), _NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, @@ -169,10 +173,10 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, else { XDeleteProperty( (Display*)display, - (Window)window, + WindowCast(window), _NET_WM_ICON ); } -#endif +#endif // !wxUSE_NANOX } @@ -186,7 +190,7 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, // fullscreen is to remove decorations, resize it to cover entire screen // and set WIN_LAYER_ABOVE_DOCK. // -// This doesn't always work, though. Specifically, at least kwin from +// This doesn't always work, though. Specifically, at least kwin from // KDE 3 ignores the hint. The only way to make kwin accept our request // is to emulate the way Qt does it. That is, unmap the window, set // _NET_WM_WINDOW_TYPE to _KDE_NET_WM_WINDOW_TYPE_OVERRIDE (KDE extension), @@ -198,13 +202,13 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, // window state which provides cleanest and simplest possible way of // making a window fullscreen. WM-spec is a de-facto standard adopted // by GNOME and KDE folks, but _NET_WM_STATE_FULLSCREEN isn't yet widely -// supported. As of January 2003, only GNOME 2's default WM Metacity +// supported. As of January 2003, only GNOME 2's default WM Metacity // implements, KDE will support it from version 3.2. At toolkits level, // GTK+ >= 2.1.2 uses it as the only method of making windows fullscreen // (that's why wxGTK will *not* switch to using gtk_window_fullscreen // unless it has better compatibility with older WMs). // -// +// // This is what wxWidgets does in wxSetFullScreenStateX11: // 1) if _NET_WM_STATE_FULLSCREEN is supported, use it // 2) otherwise try WM-specific hacks (KDE, IceWM) @@ -220,7 +224,7 @@ static void wxWinHintsSetLayer(Display *display, Window rootWnd, Window window, int layer) { wxX11ErrorsSuspender noerrors(display); - + XEvent xev; wxMAKE_ATOM( _WIN_LAYER, display ); @@ -264,7 +268,7 @@ static bool wxQueryWMspecSupport(Display *display, Window rootWnd, Atom feature) { wxMAKE_ATOM(_NET_SUPPORTING_WM_CHECK, display); wxMAKE_ATOM(_NET_SUPPORTED, display); - + // FIXME: We may want to cache these checks. Note that we can't simply // remember the results in global variable because the WM may go // away and be replaced by another one! One possible approach @@ -279,14 +283,14 @@ static bool wxQueryWMspecSupport(Display *display, Window rootWnd, Atom feature) // is replaced by another one). This is what GTK+ 2 does. // Let's do it only if it is needed, it requires changes to // the event loop. - + Atom type; Window *wins; Atom *atoms; int format; unsigned long after; unsigned long nwins, natoms; - + // Is the WM ICCCM supporting? XGetWindowProperty(display, rootWnd, _NET_SUPPORTING_WM_CHECK, 0, LONG_MAX, @@ -326,7 +330,7 @@ static void wxWMspecSetState(Display *display, Window rootWnd, Window window, int operation, Atom state) { wxMAKE_ATOM(_NET_WM_STATE, display); - + if ( IsMapped(display, window) ) { XEvent xev; @@ -341,7 +345,7 @@ static void wxWMspecSetState(Display *display, Window rootWnd, xev.xclient.data.l[0] = operation; xev.xclient.data.l[1] = state; xev.xclient.data.l[2] = None; - + XSendEvent(display, rootWnd, False, SubstructureRedirectMask | SubstructureNotifyMask, @@ -367,7 +371,7 @@ static void wxWMspecSetFullscreen(Display *display, Window rootWnd, static bool wxKwinRunning(Display *display, Window rootWnd) { wxMAKE_ATOM(KWIN_RUNNING, display); - + long *data; Atom type; int format; @@ -386,7 +390,7 @@ static bool wxKwinRunning(Display *display, Window rootWnd) return retval; } -// KDE's kwin is Qt-centric so much than no normal method of fullscreen +// KDE's kwin is Qt-centric so much than no normal method of fullscreen // mode will work with it. We have to carefully emulate the Qt way. static void wxSetKDEFullscreen(Display *display, Window rootWnd, Window w, bool fullscreen, wxRect *origRect) @@ -414,7 +418,7 @@ static void wxSetKDEFullscreen(Display *display, Window rootWnd, // it is necessary to unmap the window, otherwise kwin will ignore us: XSync(display, False); - + bool wasMapped = IsMapped(display, w); if (wasMapped) { @@ -423,7 +427,7 @@ static void wxSetKDEFullscreen(Display *display, Window rootWnd, } XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, - PropModeReplace, (unsigned char *) &data, lng); + PropModeReplace, (unsigned char *) &data, lng); XSync(display, False); if (wasMapped) @@ -431,8 +435,8 @@ static void wxSetKDEFullscreen(Display *display, Window rootWnd, XMapRaised(display, w); XSync(display, False); } - - wxWMspecSetState(display, rootWnd, w, + + wxWMspecSetState(display, rootWnd, w, fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, _NET_WM_STATE_STAYS_ON_TOP); XSync(display, False); @@ -442,8 +446,8 @@ static void wxSetKDEFullscreen(Display *display, Window rootWnd, // NB: like many other WMs, kwin ignores the first request for a window // position change after the window was mapped. This additional // move+resize event will ensure that the window is restored in - // exactly the same position as before it was made fullscreen - // (because wxTopLevelWindow::ShowFullScreen will call SetSize, thus + // exactly the same position as before it was made fullscreen + // (because wxTopLevelWindow::ShowFullScreen will call SetSize, thus // setting the position for the second time). XMoveResizeWindow(display, w, origRect->x, origRect->y, @@ -456,7 +460,7 @@ static void wxSetKDEFullscreen(Display *display, Window rootWnd, wxX11FullScreenMethod wxGetFullScreenMethodX11(WXDisplay* display, WXWindow rootWindow) { - Window root = (Window)rootWindow; + Window root = WindowCast(rootWindow); Display *disp = (Display*)display; // if WM supports _NET_WM_STATE_FULLSCREEN from wm-spec 1.2, use it: @@ -467,7 +471,7 @@ wxX11FullScreenMethod wxGetFullScreenMethodX11(WXDisplay* display, _T("detected _NET_WM_STATE_FULLSCREEN support")); return wxX11_FS_WMSPEC; } - + // if the user is running KDE's kwin WM, use a legacy hack because // kwin doesn't understand any other method: if (wxKwinRunning(disp, root)) @@ -475,7 +479,7 @@ wxX11FullScreenMethod wxGetFullScreenMethodX11(WXDisplay* display, wxLogTrace(_T("fullscreen"), _T("detected kwin")); return wxX11_FS_KDE; } - + // finally, fall back to ICCCM heuristic method: wxLogTrace(_T("fullscreen"), _T("unknown WM, using _WIN_LAYER")); return wxX11_FS_GENERIC; @@ -490,8 +494,8 @@ void wxSetFullScreenStateX11(WXDisplay* display, WXWindow rootWindow, // NB: please see the comment under "Fullscreen mode:" title above // for implications of changing this code. - Window wnd = (Window)window; - Window root = (Window)rootWindow; + Window wnd = WindowCast(window); + Window root = WindowCast(rootWindow); Display *disp = (Display*)display; if (method == wxX11_FS_AUTODETECT) @@ -533,7 +537,7 @@ int wxCharCodeXToWX(KeySym keySym) case XK_Control_L: case XK_Control_R: id = WXK_CONTROL; break; - case XK_Meta_L: + case XK_Meta_L: case XK_Meta_R: id = WXK_ALT; break; case XK_BackSpace: @@ -695,7 +699,7 @@ KeySym wxCharCodeWXToX(int id) case WXK_RETURN: keySym = XK_Return; break; case WXK_SHIFT: keySym = XK_Shift_L; break; case WXK_CONTROL: keySym = XK_Control_L; break; - case WXK_ALT: keySym = XK_Meta_L; break; + case WXK_ALT: keySym = XK_Meta_L; break; case WXK_MENU : keySym = XK_Menu; break; case WXK_PAUSE: keySym = XK_Pause; break; case WXK_ESCAPE: keySym = XK_Escape; break; @@ -782,7 +786,7 @@ bool wxGetKeyState(wxKeyCode key) #else #error Add code to get the DISPLAY for this platform #endif - + int iKey = wxCharCodeWXToX(key); int iKeyMask = 0; Window wDummy1, wDummy2; @@ -792,7 +796,7 @@ bool wxGetKeyState(wxKeyCode key) KeyCode keyCode = XKeysymToKeycode(pDisplay,iKey); if (keyCode == NoSymbol) return false; - + for (int i = 0; i < 8; ++i) { if ( map->modifiermap[map->max_keypermod * i] == keyCode) @@ -800,14 +804,14 @@ bool wxGetKeyState(wxKeyCode key) iKeyMask = 1 << i; } } - + XQueryPointer(pDisplay, DefaultRootWindow(pDisplay), &wDummy1, &wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, &iMask ); XFreeModifiermap(map); return (iMask & iKeyMask) != 0; } -#endif +#endif // __WXX11__ || __WXGTK__ || __WXMOTIF__ diff --git a/src/x11/evtloop.cpp b/src/x11/evtloop.cpp index 4be027f7aa..5167c4b918 100644 --- a/src/x11/evtloop.cpp +++ b/src/x11/evtloop.cpp @@ -27,6 +27,7 @@ #include "wx/timer.h" #include "wx/hash.h" #include "wx/module.h" +#include "wx/unix/private.h" #include "wx/x11/private.h" #include "X11/Xlib.h" @@ -174,14 +175,14 @@ void wxSocketTable::FillSets(fd_set* readset, fd_set* writeset, int* highest) if (entry->m_fdInput != -1) { - FD_SET(entry->m_fdInput, readset); + wxFD_SET(entry->m_fdInput, readset); if (entry->m_fdInput > *highest) * highest = entry->m_fdInput; } if (entry->m_fdOutput != -1) { - FD_SET(entry->m_fdOutput, writeset); + wxFD_SET(entry->m_fdOutput, writeset); if (entry->m_fdOutput > *highest) * highest = entry->m_fdOutput; } @@ -198,12 +199,12 @@ void wxSocketTable::ProcessEvents(fd_set* readset, fd_set* writeset) { wxSocketTableEntry* entry = (wxSocketTableEntry*) node->GetData(); - if (entry->m_fdInput != -1 && FD_ISSET(entry->m_fdInput, readset)) + if (entry->m_fdInput != -1 && wxFD_ISSET(entry->m_fdInput, readset)) { (entry->m_callbackInput) (entry->m_fdInput, entry->m_dataInput); } - if (entry->m_fdOutput != -1 && FD_ISSET(entry->m_fdOutput, writeset)) + if (entry->m_fdOutput != -1 && wxFD_ISSET(entry->m_fdOutput, writeset)) { (entry->m_callbackOutput) (entry->m_fdOutput, entry->m_dataOutput); } @@ -455,10 +456,10 @@ bool wxEventLoop::Dispatch() fd_set readset; fd_set writeset; int highest = fd; - FD_ZERO(&readset); - FD_ZERO(&writeset); + wxFD_ZERO(&readset); + wxFD_ZERO(&writeset); - FD_SET(fd, &readset); + wxFD_SET(fd, &readset); #if wxUSE_SOCKETS if (wxTheSocketTable) @@ -473,7 +474,7 @@ bool wxEventLoop::Dispatch() else { // An X11 event was pending, so get it - if (FD_ISSET( fd, &readset )) + if (wxFD_ISSET( fd, &readset )) XNextEvent( wxGlobalDisplay(), &event ); #if wxUSE_SOCKETS diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 37855b675c..ba4e864870 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -42,7 +42,7 @@ #include "wx/xrc/xmlres.h" #include "wx/arrimpl.cpp" -WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords); +WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords) wxXmlResource *wxXmlResource::ms_instance = NULL; @@ -679,7 +679,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, #include "wx/listimpl.cpp" WX_DECLARE_LIST(wxXmlSubclassFactory, wxXmlSubclassFactoriesList); -WX_DEFINE_LIST(wxXmlSubclassFactoriesList); +WX_DEFINE_LIST(wxXmlSubclassFactoriesList) wxXmlSubclassFactoriesList *wxXmlResource::ms_subclassFactories = NULL; @@ -936,7 +936,7 @@ float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv) setlocale(LC_NUMERIC, prevlocale); #endif - return value; + return wx_truncate_cast(float, value); } diff --git a/utils/wxrc/wxrc.cpp b/utils/wxrc/wxrc.cpp index 5414a3f4c2..9d90ec07eb 100644 --- a/utils/wxrc/wxrc.cpp +++ b/utils/wxrc/wxrc.cpp @@ -43,7 +43,7 @@ private: #include "wx/arrimpl.cpp" WX_DECLARE_OBJARRAY(XRCWidgetData,ArrayOfXRCWidgetData); -WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData); +WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData) class XRCWndClassData { @@ -148,7 +148,7 @@ public: }; }; WX_DECLARE_OBJARRAY(XRCWndClassData,ArrayOfXRCWndClassData); -WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData); +WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData) class XmlResApp : public wxAppConsole @@ -502,8 +502,9 @@ static wxString FileToCppArray(wxString filename, int num) wxFFile file(filename, wxT("rb")); wxFileOffset offset = file.Length(); wxASSERT_MSG( offset >= 0 , wxT("Invalid file length") ); - wxASSERT_MSG( offset == wxFileOffset(size_t(offset)) , wxT("Huge file not supported") ); - size_t lng = (size_t)offset; + + const size_t lng = wx_truncate_cast(size_t, offset); + wxASSERT_MSG( lng == offset, wxT("Huge file not supported") ); snum.Printf(_T("%i"), num); output.Printf(_T("static size_t xml_res_size_") + snum + _T(" = %i;\n"), lng); @@ -628,8 +629,9 @@ static wxString FileToPythonArray(wxString filename, int num) wxFFile file(filename, wxT("rb")); wxFileOffset offset = file.Length(); wxASSERT_MSG( offset >= 0 , wxT("Invalid file length") ); - wxASSERT_MSG( offset == wxFileOffset(size_t(offset)) , wxT("Huge file not supported") ); - size_t lng = (size_t)offset; + + const size_t lng = wx_truncate_cast(size_t, offset); + wxASSERT_MSG( offset == lng, wxT("Huge file not supported") ); snum.Printf(_T("%i"), num); output = _T(" xml_res_file_") + snum + _T(" = '''\\\n"); -- 2.45.2