From: Vadim Zeitlin Date: Thu, 6 Jan 2000 15:42:32 +0000 (+0000) Subject: 1. more HP-UX warning fixes (almost done...) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6f2a55e34ab1f8fa99dfd2f7ca5488685395db28 1. more HP-UX warning fixes (almost done...) 2. added a macro WXUNUSED_UNLESS_DEBUG() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 3410ccafa3..ce50b160a6 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -972,23 +972,23 @@ public: // ------------------------------------------------------------------------ // return the timespan for the given number of seconds - static wxTimeSpan Seconds(int sec) { return wxTimeSpan(0, 0, sec); } + static wxTimeSpan Seconds(long sec) { return wxTimeSpan(0, 0, sec); } static wxTimeSpan Second() { return Seconds(1); } // return the timespan for the given number of minutes - static wxTimeSpan Minutes(int min) { return wxTimeSpan(0, min, 0 ); } + static wxTimeSpan Minutes(long min) { return wxTimeSpan(0, min, 0 ); } static wxTimeSpan Minute() { return Minutes(1); } // return the timespan for the given number of hours - static wxTimeSpan Hours(int hours) { return wxTimeSpan(hours, 0, 0); } + static wxTimeSpan Hours(long hours) { return wxTimeSpan(hours, 0, 0); } static wxTimeSpan Hour() { return Hours(1); } // return the timespan for the given number of days - static wxTimeSpan Days(int days) { return Hours(24 * days); } + static wxTimeSpan Days(long days) { return Hours(24 * days); } static wxTimeSpan Day() { return Days(1); } // return the timespan for the given number of weeks - static wxTimeSpan Weeks(int days) { return Days(7 * days); } + static wxTimeSpan Weeks(long days) { return Days(7 * days); } static wxTimeSpan Week() { return Weeks(1); } // default ctor constructs the 0 time span @@ -997,10 +997,10 @@ public: // from separate values for each component, date set to 0 (hours are // not restricted to 0..24 range, neither are minutes, seconds or // milliseconds) - inline wxTimeSpan(int hours, - int minutes = 0, - int seconds = 0, - int milliseconds = 0); + inline wxTimeSpan(long hours, + long minutes = 0, + long seconds = 0, + long milliseconds = 0); // default copy ctor is ok diff --git a/include/wx/datetime.inl b/include/wx/datetime.inl index 0420e98f74..49567d1327 100644 --- a/include/wx/datetime.inl +++ b/include/wx/datetime.inl @@ -362,10 +362,10 @@ wxDateTime wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, // wxTimeSpan construction // ---------------------------------------------------------------------------- -wxTimeSpan::wxTimeSpan(int hours, int minutes, int seconds, int milliseconds) +wxTimeSpan::wxTimeSpan(long hours, long minutes, long seconds, long milliseconds) { // assign first to avoid precision loss - m_diff = (long)hours; + m_diff = hours; m_diff *= 60l; m_diff += minutes; m_diff *= 60l; diff --git a/include/wx/defs.h b/include/wx/defs.h index 9d7dcf0338..9ac82a237a 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -317,6 +317,13 @@ typedef int wxWindowID; #define WXUNUSED(identifier) identifier #endif +// some arguments are only used in debug mode, but unused in release one +#ifdef __WXDEBUG__ + #define WXUNUSED_UNLESS_DEBUG(param) param +#else + #define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param) +#endif + // ---------------------------------------------------------------------------- // portable calling conventions macros // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/region.h b/include/wx/gtk/region.h index 457ecbd4dd..ff139cb0f5 100644 --- a/include/wx/gtk/region.h +++ b/include/wx/gtk/region.h @@ -107,7 +107,7 @@ public: wxRegionIterator(); wxRegionIterator(const wxRegion& region); - void Reset() { m_current = 0; } + void Reset() { m_current = 0u; } void Reset(const wxRegion& region); operator bool () const; @@ -125,8 +125,8 @@ public: wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } private: - long m_current; - wxRegion m_region; + size_t m_current; + wxRegion m_region; private: DECLARE_DYNAMIC_CLASS(wxRegionIterator); diff --git a/include/wx/gtk1/region.h b/include/wx/gtk1/region.h index 457ecbd4dd..ff139cb0f5 100644 --- a/include/wx/gtk1/region.h +++ b/include/wx/gtk1/region.h @@ -107,7 +107,7 @@ public: wxRegionIterator(); wxRegionIterator(const wxRegion& region); - void Reset() { m_current = 0; } + void Reset() { m_current = 0u; } void Reset(const wxRegion& region); operator bool () const; @@ -125,8 +125,8 @@ public: wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } private: - long m_current; - wxRegion m_region; + size_t m_current; + wxRegion m_region; private: DECLARE_DYNAMIC_CLASS(wxRegionIterator); diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index b25354f104..a3676830c7 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -77,7 +77,7 @@ struct wxCmdLineOption // types increases, so always use the accessor functions and don't access // the fields directly!) - void Check(wxCmdLineParamType typ) const + void Check(wxCmdLineParamType WXUNUSED_UNLESS_DEBUG(typ)) const { wxASSERT_MSG( type == typ, _T("type mismatch in wxCmdLineOption") ); } @@ -188,7 +188,7 @@ void wxCmdLineParserData::SetArguments(int argc, char **argv) } } -void wxCmdLineParserData::SetArguments(const wxString& cmdline) +void wxCmdLineParserData::SetArguments(const wxString& WXUNUSED(cmdline)) { // either use wxMSW wxApp::ConvertToStandardCommandArgs() or move its logic // here and use this method from it - but don't duplicate the code diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 6e65f76bef..27e3d04cd6 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -269,7 +269,7 @@ void wxTextValidator::OnChar(wxKeyEvent& event) if ( m_validatorWindow ) { - long keyCode = event.KeyCode(); + int keyCode = (int)event.KeyCode(); // we don't filter special keys and Delete if ( diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index e19e1ac69c..6e5f13c902 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -471,8 +471,7 @@ void wxListLineData::SetPosition( wxDC *dc, int x, int y, int window_width ) void wxListLineData::SetColumnPosition( int index, int x ) { - int i = index; - wxNode *node = m_items.Nth( i ); + wxNode *node = m_items.Nth( (size_t)index ); if (node) { wxListItemData *item = (wxListItemData*)node->Data(); @@ -613,10 +612,10 @@ void wxListLineData::SetAttributes(wxDC *dc, void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG ) { - long dev_x = dc->LogicalToDeviceX( m_bound_all.x-2 ); - long dev_y = dc->LogicalToDeviceY( m_bound_all.y-2 ); - long dev_w = dc->LogicalToDeviceXRel( m_bound_all.width+4 ); - long dev_h = dc->LogicalToDeviceYRel( m_bound_all.height+4 ); + wxCoord dev_x = dc->LogicalToDeviceX( m_bound_all.x-2 ); + wxCoord dev_y = dc->LogicalToDeviceY( m_bound_all.y-2 ); + wxCoord dev_w = dc->LogicalToDeviceXRel( m_bound_all.width+4 ); + wxCoord dev_h = dc->LogicalToDeviceYRel( m_bound_all.height+4 ); if (!m_owner->IsExposed( dev_x, dev_y, dev_w, dev_h )) { @@ -918,8 +917,8 @@ void wxListHeaderWindow::DrawCurrent() void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) { - int x = event.GetX(); - int y = event.GetY(); + wxCoord x = (wxCoord)event.GetX(); + wxCoord y = (wxCoord)event.GetY(); if (m_isDragging) { DrawCurrent(); @@ -1293,7 +1292,7 @@ void wxListMainWindow::DeleteLine( wxListLineData *line ) void wxListMainWindow::EditLabel( long item ) { - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); wxCHECK_RET( node, wxT("wrong index in wxListCtrl::Edit()") ); m_currentEdit = (wxListLineData*) node->Data(); @@ -1366,8 +1365,8 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) wxClientDC dc(this); PrepareDC(dc); - long x = dc.DeviceToLogicalX( (long)event.GetX() ); - long y = dc.DeviceToLogicalY( (long)event.GetY() ); + wxCoord x = dc.DeviceToLogicalX( (wxCoord)event.GetX() ); + wxCoord y = dc.DeviceToLogicalY( (wxCoord)event.GetY() ); /* Did we actually hit an item ? */ long hitResult = 0; @@ -1590,7 +1589,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) /* we send a list_key event up */ wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); - le.m_code = event.KeyCode(); + le.m_code = (int)event.KeyCode(); le.SetEventObject( parent ); parent->GetEventHandler()->ProcessEvent( le ); @@ -2000,7 +1999,7 @@ int wxListMainWindow::GetCountPerPage() void wxListMainWindow::SetItem( wxListItem &item ) { m_dirty = TRUE; - wxNode *node = m_lines.Nth( item.m_itemId ); + wxNode *node = m_lines.Nth( (size_t)item.m_itemId ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2017,7 +2016,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) if (stateMask & wxLIST_STATE_FOCUSED) { - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2031,10 +2030,10 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) if (stateMask & wxLIST_STATE_SELECTED) { - bool on = state & wxLIST_STATE_SELECTED; + bool on = (state & wxLIST_STATE_SELECTED) != 0; if (!on && (m_mode & wxLC_SINGLE_SEL)) return; - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2047,7 +2046,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) RefreshLine( m_current ); if (oldCurrent) RefreshLine( oldCurrent ); } - bool on = state & wxLIST_STATE_SELECTED; + bool on = (state & wxLIST_STATE_SELECTED) != 0; if (on != line->IsHilighted()) { line->Hilight( on ); @@ -2062,7 +2061,7 @@ int wxListMainWindow::GetItemState( long item, long stateMask ) int ret = wxLIST_STATE_DONTCARE; if (stateMask & wxLIST_STATE_FOCUSED) { - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2071,7 +2070,7 @@ int wxListMainWindow::GetItemState( long item, long stateMask ) } if (stateMask & wxLIST_STATE_SELECTED) { - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2083,7 +2082,7 @@ int wxListMainWindow::GetItemState( long item, long stateMask ) void wxListMainWindow::GetItem( wxListItem &item ) { - wxNode *node = m_lines.Nth( item.m_itemId ); + wxNode *node = m_lines.Nth( (size_t)item.m_itemId ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2105,7 +2104,7 @@ int wxListMainWindow::GetItemCount() void wxListMainWindow::GetItemRect( long index, wxRect &rect ) { - wxNode *node = m_lines.Nth( index ); + wxNode *node = m_lines.Nth( (size_t)index ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2122,7 +2121,7 @@ void wxListMainWindow::GetItemRect( long index, wxRect &rect ) bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) { - wxNode *node = m_lines.Nth( item ); + wxNode *node = m_lines.Nth( (size_t)item ); if (node) { wxRect rect; @@ -2322,7 +2321,7 @@ long wxListMainWindow::GetNextItem( long item, int WXUNUSED(geometry), int state long ret = 0; if (item > 0) ret = item; if(ret >= GetItemCount()) return -1; - wxNode *node = m_lines.Nth( ret ); + wxNode *node = m_lines.Nth( (size_t)ret ); while (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2338,7 +2337,7 @@ long wxListMainWindow::GetNextItem( long item, int WXUNUSED(geometry), int state void wxListMainWindow::DeleteItem( long index ) { m_dirty = TRUE; - wxNode *node = m_lines.Nth( index ); + wxNode *node = m_lines.Nth( (size_t)index ); if (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2406,8 +2405,7 @@ void wxListMainWindow::EnsureVisible( long index ) wxListLineData *oldCurrent = m_current; m_current = (wxListLineData *) NULL; - int i = index; - wxNode *node = m_lines.Nth( i ); + wxNode *node = m_lines.Nth( (size_t)index ); if (node) m_current = (wxListLineData*)node->Data(); if (m_current) MoveToFocus(); m_current = oldCurrent; @@ -2418,7 +2416,7 @@ long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(p long pos = start; wxString tmp = str; if (pos < 0) pos = 0; - wxNode *node = m_lines.Nth( pos ); + wxNode *node = m_lines.Nth( (size_t)pos ); while (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2435,7 +2433,7 @@ long wxListMainWindow::FindItem(long start, long data) { long pos = start; if (pos < 0) pos = 0; - wxNode *node = m_lines.Nth( pos ); + wxNode *node = m_lines.Nth( (size_t)pos ); while (node) { wxListLineData *line = (wxListLineData*)node->Data(); @@ -2458,7 +2456,7 @@ long wxListMainWindow::HitTest( int x, int y, int &flags ) long ret = line->IsHit( x, y ); if (ret & flags) { - flags = ret; + flags = (int)ret; return count; } node = node->Next(); @@ -2491,7 +2489,7 @@ void wxListMainWindow::InsertItem( wxListItem &item ) line->SetItem( 0, item ); if ((item.m_itemId >= 0) && (item.m_itemId < (int)m_lines.GetCount())) { - wxNode *node = m_lines.Nth( item.m_itemId ); + wxNode *node = m_lines.Nth( (size_t)item.m_itemId ); if (node) m_lines.Insert( node, line ); } else @@ -2509,7 +2507,7 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item ) wxListHeaderData *column = new wxListHeaderData( item ); if ((col >= 0) && (col < (int)m_columns.GetCount())) { - wxNode *node = m_columns.Nth( col ); + wxNode *node = m_columns.Nth( (size_t)col ); if (node) m_columns.Insert( node, column ); } diff --git a/src/generic/msgdlgg.cpp b/src/generic/msgdlgg.cpp index a574efd374..deb4be5677 100644 --- a/src/generic/msgdlgg.cpp +++ b/src/generic/msgdlgg.cpp @@ -73,7 +73,7 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, if (style & wxICON_MASK) { wxStaticBitmap *icon = new wxStaticBitmap( - this, -1, wxTheApp->GetStdIcon(style & wxICON_MASK)); + this, -1, wxTheApp->GetStdIcon((int)(style & wxICON_MASK))); icon_text->Add( icon, 0, wxCENTER ); } diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 66878cda37..31aea495e1 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -162,8 +162,8 @@ void wxSplitterWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) { - wxCoord x = event.GetX(), - y = event.GetY(); + wxCoord x = (wxCoord)event.GetX(), + y = (wxCoord)event.GetY(); // reset the cursor #ifdef __WXMOTIF__ diff --git a/src/generic/tbarsmpl.cpp b/src/generic/tbarsmpl.cpp index bda7f6ced7..d439947bb5 100644 --- a/src/generic/tbarsmpl.cpp +++ b/src/generic/tbarsmpl.cpp @@ -70,8 +70,8 @@ public: m_height = size.y; } - long GetWidth() const { return m_width; } - long GetHeight() const { return m_height; } + wxCoord GetWidth() const { return m_width; } + wxCoord GetHeight() const { return m_height; } wxCoord m_x; wxCoord m_y; @@ -303,8 +303,8 @@ bool wxToolBarSimple::Realize() m_lastX = m_xMargin; m_lastY += maxToolHeight + m_toolPacking; } - tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); - tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); + tool->m_x = (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); + tool->m_y = (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); m_lastX += maxToolWidth + m_toolPacking; } @@ -316,8 +316,8 @@ bool wxToolBarSimple::Realize() m_lastX += (maxToolWidth + m_toolPacking); m_lastY = m_yMargin; } - tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); - tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); + tool->m_x = (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); + tool->m_y = (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); m_lastY += maxToolHeight + m_toolPacking; } @@ -586,10 +586,10 @@ void wxToolBarSimple::DrawTool(wxDC& dc, wxToolBarToolBase *toolBase) } else { - long x = tool->m_x; - long y = tool->m_y; - long w = bitmap.GetWidth(); - long h = bitmap.GetHeight(); + wxCoord x = tool->m_x; + wxCoord y = tool->m_y; + wxCoord w = bitmap.GetWidth(); + wxCoord h = bitmap.GetHeight(); wxPen thick_black_pen("BLACK", 3, wxSOLID); memDC.SelectObject(bitmap); diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index a85aa6fd8d..30e26b9930 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -167,8 +167,8 @@ private: // children but has a [+] button int m_isBold :1; // render the label in bold font - int m_x, m_y; - long m_height, m_width; + wxCoord m_x, m_y; + wxCoord m_height, m_width; int m_xCross, m_yCross; int m_level; diff --git a/src/gtk/region.cpp b/src/gtk/region.cpp index 49c4d86de5..1b6cdf892e 100644 --- a/src/gtk/region.cpp +++ b/src/gtk/region.cpp @@ -333,19 +333,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject); wxRegionIterator::wxRegionIterator() { - m_current = 0; + Reset(); } wxRegionIterator::wxRegionIterator( const wxRegion& region ) { - m_region = region; - m_current = 0; + Reset(region); } void wxRegionIterator::Reset( const wxRegion& region ) { m_region = region; - m_current = 0; + Reset(); } wxRegionIterator::operator bool () const diff --git a/src/gtk1/region.cpp b/src/gtk1/region.cpp index 49c4d86de5..1b6cdf892e 100644 --- a/src/gtk1/region.cpp +++ b/src/gtk1/region.cpp @@ -333,19 +333,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject); wxRegionIterator::wxRegionIterator() { - m_current = 0; + Reset(); } wxRegionIterator::wxRegionIterator( const wxRegion& region ) { - m_region = region; - m_current = 0; + Reset(region); } void wxRegionIterator::Reset( const wxRegion& region ) { m_region = region; - m_current = 0; + Reset(); } wxRegionIterator::operator bool () const