From 5c519b6cf79f6a3036285f1c458fb6f61bad02cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Fri, 8 Oct 2004 18:49:13 +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@29736 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/ptr_scpd.h | 17 ++++++----- src/common/cmndata.cpp | 66 ++++++++++++++++++++--------------------- src/common/gdicmn.cpp | 2 +- src/msw/fdrepdlg.cpp | 2 +- src/msw/font.cpp | 2 +- src/msw/mdi.cpp | 5 ++-- src/msw/ole/automtn.cpp | 13 +++++--- src/msw/tbar95.cpp | 2 +- src/msw/textctrl.cpp | 15 ++++++---- src/msw/timer.cpp | 2 +- 10 files changed, 68 insertions(+), 58 deletions(-) diff --git a/include/wx/ptr_scpd.h b/include/wx/ptr_scpd.h index 0804211086..85427a13cf 100644 --- a/include/wx/ptr_scpd.h +++ b/include/wx/ptr_scpd.h @@ -40,26 +40,27 @@ */ #ifdef __WATCOMC__ - #define wxPRE_NO_WARNING_SCOPE for(int i=0;i<1;i++) - #define wxPOST_NO_WARNING_SCOPE + #define wxFOR_ONCE(name) for(int name=0; name<1; name++) + #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name)) + #define wxPOST_NO_WARNING_SCOPE(name) #else - #define wxPRE_NO_WARNING_SCOPE do - #define wxPOST_NO_WARNING_SCOPE while ( 0 ) + #define wxPRE_NO_WARNING_SCOPE(name) do + #define wxPOST_NO_WARNING_SCOPE(name) while ( 0 ) #endif #define wxCHECKED_DELETE(ptr) \ - wxPRE_NO_WARNING_SCOPE \ + wxPRE_NO_WARNING_SCOPE(scope_var1) \ { \ typedef char complete[sizeof(*ptr)]; \ delete ptr; \ - } wxPOST_NO_WARNING_SCOPE + } wxPOST_NO_WARNING_SCOPE(scope_var1) #define wxCHECKED_DELETE_ARRAY(ptr) \ - wxPRE_NO_WARNING_SCOPE \ + wxPRE_NO_WARNING_SCOPE(scope_var2) \ { \ typedef char complete[sizeof(*ptr)]; \ delete [] ptr; \ - } wxPOST_NO_WARNING_SCOPE + } wxPOST_NO_WARNING_SCOPE(scope_var2) /* These scoped pointers are *not* assignable and cannot be used within a container. Look for wxDECLARE_SHARED_PTR for this diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index e10ea9b085..07040ea1e8 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -383,7 +383,7 @@ void wxPrintData::ConvertToNative() //// Orientation - devMode->dmOrientation = m_printOrientation; + devMode->dmOrientation = (short)m_printOrientation; //// Collation @@ -392,7 +392,7 @@ void wxPrintData::ConvertToNative() //// Number of copies - devMode->dmCopies = m_printNoCopies; + devMode->dmCopies = (short)m_printNoCopies; devMode->dmFields |= DM_COPIES; //// Printer name @@ -418,8 +418,8 @@ void wxPrintData::ConvertToNative() if (m_paperId == wxPAPER_NONE) { // DEVMODE is in tenths of a milimeter - devMode->dmPaperWidth = m_paperSize.x * 10; - devMode->dmPaperLength = m_paperSize.y * 10; + devMode->dmPaperWidth = (short)(m_paperSize.x * 10); + devMode->dmPaperLength = (short)(m_paperSize.y * 10); devMode->dmPaperSize = DMPAPER_USER; devMode->dmFields |= DM_PAPERWIDTH; devMode->dmFields |= DM_PAPERLENGTH; @@ -431,7 +431,7 @@ void wxPrintData::ConvertToNative() wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); if (paper) { - devMode->dmPaperSize = paper->GetPlatformId(); + devMode->dmPaperSize = (short)paper->GetPlatformId(); devMode->dmFields |= DM_PAPERSIZE; } } @@ -439,43 +439,43 @@ void wxPrintData::ConvertToNative() //// Duplex - int duplex; + short duplex; switch (m_duplexMode) { - case wxDUPLEX_HORIZONTAL: { - duplex = DMDUP_HORIZONTAL; break; - } - case wxDUPLEX_VERTICAL: { - duplex = DMDUP_VERTICAL; break; - } - default: - case wxDUPLEX_SIMPLEX: { - duplex = DMDUP_SIMPLEX; break; - } + case wxDUPLEX_HORIZONTAL: + duplex = DMDUP_HORIZONTAL; + break; + case wxDUPLEX_VERTICAL: + duplex = DMDUP_VERTICAL; + break; + default: + // in fact case wxDUPLEX_SIMPLEX: + duplex = DMDUP_SIMPLEX; + break; } devMode->dmDuplex = duplex; devMode->dmFields |= DM_DUPLEX; //// Quality - int quality; + short quality; switch (m_printQuality) { - case wxPRINT_QUALITY_MEDIUM: { - quality = DMRES_MEDIUM; break; - } - case wxPRINT_QUALITY_LOW: { - quality = DMRES_LOW; break; - } - case wxPRINT_QUALITY_DRAFT: { - quality = DMRES_DRAFT; break; - } - case wxPRINT_QUALITY_HIGH: { - quality = DMRES_HIGH; break; - } - default: { - quality = m_printQuality; break; - } + case wxPRINT_QUALITY_MEDIUM: + quality = DMRES_MEDIUM; + break; + case wxPRINT_QUALITY_LOW: + quality = DMRES_LOW; + break; + case wxPRINT_QUALITY_DRAFT: + quality = DMRES_DRAFT; + break; + case wxPRINT_QUALITY_HIGH: + quality = DMRES_HIGH; + break; + default: + quality = (short)m_printQuality; + break; } devMode->dmPrintQuality = quality; devMode->dmFields |= DM_PRINTQUALITY; @@ -499,7 +499,7 @@ void wxPrintData::ConvertToNative() case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break; default: - devMode->dmDefaultSource = DMBIN_USER + m_bin - wxPRINTBIN_USER; + devMode->dmDefaultSource = (short)(DMBIN_USER + m_bin - wxPRINTBIN_USER); break; } diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 27236ce40a..099a576d94 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -255,7 +255,7 @@ void wxColourDatabase::Initialize() static const struct wxColourDesc { const wxChar *name; - int r,g,b; + unsigned char r,g,b; } wxColourTable[] = { diff --git a/src/msw/fdrepdlg.cpp b/src/msw/fdrepdlg.cpp index c839d458af..81e37f95dd 100644 --- a/src/msw/fdrepdlg.cpp +++ b/src/msw/fdrepdlg.cpp @@ -178,7 +178,7 @@ void wxFindReplaceDialogImpl::InitString(const wxString& str, *ppStr = new wxChar[len]; wxStrcpy(*ppStr, str); - *pLen = len; + *pLen = (WORD)len; } void wxFindReplaceDialogImpl::InitFindWhat(const wxString& str) diff --git a/src/msw/font.cpp b/src/msw/font.cpp index 4b96f6029e..7a718ff004 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -615,7 +615,7 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family) facename = _T("MS Sans Serif"); } - lf.lfPitchAndFamily = DEFAULT_PITCH | ff_family; + lf.lfPitchAndFamily = (BYTE)(DEFAULT_PITCH) | ff_family; if ( !wxStrlen(lf.lfFaceName) ) { diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 3d2ac43e30..be4d08a41b 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -817,7 +817,8 @@ void wxMDIChildFrame::DoSetClientSize(int width, int height) MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); - wxSizeEvent event(wxSize(width, height), m_windowId); + wxSize size(width, height); + wxSizeEvent event(size, m_windowId); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); } @@ -1318,7 +1319,7 @@ void wxMDIChildFrame::OnIdle(wxIdleEvent& event) { Show(true); } - + // MDI child frames get their WM_SIZE when they're constructed but at this // moment they don't have any children yet so all child windows will be // positioned incorrectly when they are added later - to fix this, we diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp index e4114afd26..2fa498ccc6 100644 --- a/src/msw/ole/automtn.cpp +++ b/src/msw/ole/automtn.cpp @@ -200,7 +200,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action, excep.pfnDeferredFillIn = NULL; hr = ((IDispatch*)m_dispatchPtr)->Invoke(dispIds[0], IID_NULL, LOCALE_SYSTEM_DEFAULT, - action, &dispparams, vReturnPtr, &excep, &uiArgErr); + (WORD)action, &dispparams, vReturnPtr, &excep, &uiArgErr); for (i = 0; i < namedArgStringCount; i++) { @@ -617,7 +617,7 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant) wxDateTime date( variant.GetDateTime() ); oleVariant.vt = VT_DATE; - if (!OleDateFromTm(date.GetYear(), date.GetMonth(), date.GetDay(), + if (!OleDateFromTm((WORD)date.GetYear(), date.GetMonth(), date.GetDay(), date.GetHour(), date.GetMinute(), date.GetSecond(), oleVariant.date)) return false; } @@ -702,7 +702,12 @@ bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant) if (!TmFromOleDate(oleVariant.date, tmTemp)) return false; - wxDateTime date(tmTemp.tm_yday, (wxDateTime::Month) tmTemp.tm_mon, tmTemp.tm_year, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec); + wxDateTime date((wxDateTime::wxDateTime_t) tmTemp.tm_yday, + (wxDateTime::Month) tmTemp.tm_mon, + tmTemp.tm_year, + (wxDateTime::wxDateTime_t) tmTemp.tm_hour, + (wxDateTime::wxDateTime_t) tmTemp.tm_min, + (wxDateTime::wxDateTime_t) tmTemp.tm_sec); variant = date; #endif @@ -1108,7 +1113,7 @@ static void ReleaseVariant(VARIANTARG *pvarg) VARIANTARG _huge *pvargArray; long lLBound, lUBound, l; - vt = pvarg->vt & 0xfff; // mask off flags + vt = (VARTYPE)(pvarg->vt & 0xfff); // mask off flags // check if an array. If so, free its contents, then the array itself. if (V_ISARRAY(pvarg)) diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 23c0d42f76..dc5299dbf6 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -871,7 +871,7 @@ bool wxToolBar::Realize() TBBUTTONINFO tbbi; tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_SIZE; - tbbi.cx = size.x; + tbbi.cx = (WORD)size.x; if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO, tool->GetId(), (LPARAM)&tbbi) ) { diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index b6a7a6a53d..36b2359fbe 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -991,8 +991,8 @@ bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event) size_t lenOld = GetValue().length(); wxUint32 code = event.GetRawKeyCode(); - ::keybd_event(code, 0, 0 /* key press */, 0); - ::keybd_event(code, 0, KEYEVENTF_KEYUP, 0); + ::keybd_event((BYTE)code, 0, 0 /* key press */, 0); + ::keybd_event((BYTE)code, 0, KEYEVENTF_KEYUP, 0); // assume that any alphanumeric key changes the total number of characters // in the control - this should work in 99% of cases @@ -2122,9 +2122,12 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case WM_SETCURSOR: // ok, so it is hardcoded - do we really nee to // customize it? - ::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND))); - *result = TRUE; - break; + { + wxCursor cur(wxCURSOR_HAND); + ::SetCursor(GetHcursorOf(cur)); + *result = TRUE; + break; + } case WM_MOUSEMOVE: case WM_LBUTTONDOWN: @@ -2403,7 +2406,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) const wxArrayInt& tabs = style.GetTabs(); - pf.cTabCount = wxMin(tabs.GetCount(), MAX_TAB_STOPS); + pf.cTabCount = (SHORT)wxMin(tabs.GetCount(), MAX_TAB_STOPS); size_t i; for (i = 0; i < (size_t) pf.cTabCount; i++) { diff --git a/src/msw/timer.cpp b/src/msw/timer.cpp index 2d07b922a0..348f147c1e 100644 --- a/src/msw/timer.cpp +++ b/src/msw/timer.cpp @@ -150,7 +150,7 @@ wxTimerProc(HWND WXUNUSED(hwnd), UINT idTimer, DWORD WXUNUSED(dwTime)) { - wxTimerMap::iterator node = g_timerMap.find(idTimer); + wxTimerMap::iterator node = g_timerMap.find((unsigned long)idTimer); wxCHECK_RET( node != g_timerMap.end(), wxT("bogus timer id in wxTimerProc") ); -- 2.45.2