From 373a5fb355f4023f96b14bbf8161cbd1de5b846e Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Thu, 7 Oct 2004 13:36:41 +0000 Subject: [PATCH] Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/window.h | 2 +- include/wx/ptr_scpd.h | 16 ++++++++++++---- src/msw/accel.cpp | 6 +++--- src/msw/dib.cpp | 4 ++-- src/msw/font.cpp | 4 ++-- src/msw/fontenum.cpp | 2 +- src/msw/fontutil.cpp | 2 +- src/msw/frame.cpp | 2 +- src/msw/palette.cpp | 2 +- src/msw/window.cpp | 8 ++++---- 10 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index d3739f665a..d582c1b941 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -491,7 +491,7 @@ inline void wxWindowMSW::SetTransparent(bool WXUNUSED(t)) { } // kbd code translation WXDLLEXPORT int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam = 0); -WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual); +WXDLLEXPORT WXWORD wxCharCodeWXToMSW(int id, bool *IsVirtual); // window creation helper class: before creating a new HWND, instantiate an // object of this class on stack - this allows to process the messages sent to diff --git a/include/wx/ptr_scpd.h b/include/wx/ptr_scpd.h index 2000d346a3..0804211086 100644 --- a/include/wx/ptr_scpd.h +++ b/include/wx/ptr_scpd.h @@ -39,19 +39,27 @@ still force a semicolon after the macro */ +#ifdef __WATCOMC__ + #define wxPRE_NO_WARNING_SCOPE for(int i=0;i<1;i++) + #define wxPOST_NO_WARNING_SCOPE +#else + #define wxPRE_NO_WARNING_SCOPE do + #define wxPOST_NO_WARNING_SCOPE while ( 0 ) +#endif + #define wxCHECKED_DELETE(ptr) \ - do \ + wxPRE_NO_WARNING_SCOPE \ { \ typedef char complete[sizeof(*ptr)]; \ delete ptr; \ - } while ( 0 ) + } wxPOST_NO_WARNING_SCOPE #define wxCHECKED_DELETE_ARRAY(ptr) \ - do \ + wxPRE_NO_WARNING_SCOPE \ { \ typedef char complete[sizeof(*ptr)]; \ delete [] ptr; \ - } while ( 0 ) + } wxPOST_NO_WARNING_SCOPE /* These scoped pointers are *not* assignable and cannot be used within a container. Look for wxDECLARE_SHARED_PTR for this diff --git a/src/msw/accel.cpp b/src/msw/accel.cpp index cad9c19c30..a5feca7c4b 100644 --- a/src/msw/accel.cpp +++ b/src/msw/accel.cpp @@ -92,7 +92,7 @@ wxAcceleratorTable::wxAcceleratorTable(const wxString& resource) M_ACCELDATA->m_ok = (hAccel != 0); } -extern int wxCharCodeWXToMSW(int id, bool *isVirtual); +extern WXWORD wxCharCodeWXToMSW(int id, bool *isVirtual); // Create from an array wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) @@ -114,13 +114,13 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[] bool isVirtual; - WORD key = (WORD)wxCharCodeWXToMSW(entries[i].GetKeyCode(), &isVirtual); + WORD key = wxCharCodeWXToMSW(entries[i].GetKeyCode(), &isVirtual); if (isVirtual) fVirt |= FVIRTKEY; arr[i].fVirt = fVirt; arr[i].key = key; - arr[i].cmd = entries[i].GetCommand(); + arr[i].cmd = (WORD)entries[i].GetCommand(); } M_ACCELDATA->m_hAccel = ::CreateAcceleratorTable(arr, n); diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 0589ec323e..a76592f9b0 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -118,7 +118,7 @@ bool wxDIB::Create(int width, int height, int depth) info->bmiHeader.biHeight = height; info->bmiHeader.biPlanes = 1; - info->bmiHeader.biBitCount = depth; + info->bmiHeader.biBitCount = (WORD)depth; info->bmiHeader.biSizeImage = GetLineSize(width, depth)*height; m_handle = ::CreateDIBSection @@ -603,7 +603,7 @@ wxPalette *wxDIB::CreatePalette() const // initialize the palette header pPalette->palVersion = 0x300; // magic number, not in docs but works - pPalette->palNumEntries = biClrUsed; + pPalette->palNumEntries = (WORD)biClrUsed; // and the colour table (it starts right after the end of the header) const RGBQUAD *pRGB = (RGBQUAD *)((char *)&ds.dsBmih + ds.dsBmih.biSize); diff --git a/src/msw/font.cpp b/src/msw/font.cpp index d79b4b74a6..4b96f6029e 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -578,7 +578,7 @@ void wxNativeFontInfo::SetFaceName(wxString facename) void wxNativeFontInfo::SetFamily(wxFontFamily family) { - int ff_family; + BYTE ff_family; wxString facename; switch ( family ) @@ -647,7 +647,7 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding) } } - lf.lfCharSet = info.charset; + lf.lfCharSet = (BYTE)info.charset; } bool wxNativeFontInfo::FromString(const wxString& s) diff --git a/src/msw/fontenum.cpp b/src/msw/fontenum.cpp index 07a79b78f4..8dca8b0909 100644 --- a/src/msw/fontenum.cpp +++ b/src/msw/fontenum.cpp @@ -166,7 +166,7 @@ void wxFontEnumeratorHelper::DoEnumerate() (LPARAM)this) ; #else // __WIN32__ LOGFONT lf; - lf.lfCharSet = m_charset; + lf.lfCharSet = (BYTE)m_charset; wxStrncpy(lf.lfFaceName, m_facename, WXSIZEOF(lf.lfFaceName)); lf.lfPitchAndFamily = 0; ::EnumFontFamiliesEx(hDC, &lf, (wxFONTENUMPROC)wxFontEnumeratorProc, diff --git a/src/msw/fontutil.cpp b/src/msw/fontutil.cpp index dbf009105a..266971d30a 100644 --- a/src/msw/fontutil.cpp +++ b/src/msw/fontutil.cpp @@ -164,7 +164,7 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info) LOGFONT lf; wxZeroMemory(lf); // all default values - lf.lfCharSet = info.charset; + lf.lfCharSet = (BYTE)info.charset; wxStrncpy(lf.lfFaceName, info.facename, WXSIZEOF(lf.lfFaceName)); HFONT hfont = ::CreateFontIndirect(&lf); diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index f80a8f8da6..edc5c5c22c 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -982,7 +982,7 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara break; case WM_EXITMENULOOP: - processed = HandleMenuLoop(wxEVT_MENU_CLOSE, wParam); + processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); break; case WM_QUERYDRAGICON: diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp index 4a73bb28b2..0d46158e02 100644 --- a/src/msw/palette.cpp +++ b/src/msw/palette.cpp @@ -87,7 +87,7 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre return false; npPal->palVersion = 0x300; - npPal->palNumEntries = n; + npPal->palNumEntries = (WORD)n; int i; for (i = 0; i < n; i ++) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 7daffb9b2a..02e5c2cfcf 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5045,10 +5045,10 @@ int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam) return id; } -int wxCharCodeWXToMSW(int id, bool *isVirtual) +WXWORD wxCharCodeWXToMSW(int id, bool *isVirtual) { *isVirtual = true; - int keySym; + WXWORD keySym; switch (id) { case WXK_CANCEL: keySym = VK_CANCEL; break; @@ -5117,7 +5117,7 @@ int wxCharCodeWXToMSW(int id, bool *isVirtual) default: { *isVirtual = false; - keySym = id; + keySym = (WORD)id; break; } } @@ -5127,7 +5127,7 @@ int wxCharCodeWXToMSW(int id, bool *isVirtual) bool wxGetKeyState(wxKeyCode key) { bool bVirtual; - int vkey = wxCharCodeWXToMSW(key, &bVirtual); + WORD vkey = wxCharCodeWXToMSW(key, &bVirtual); SHORT state; switch (key) -- 2.45.2