X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a4ebf7ba6189c29469eaa8c43717b18d1f61b973..38f833b10c071603eb8d7739ab31b1c07c4576f1:/src/os2/radiobox.cpp diff --git a/src/os2/radiobox.cpp b/src/os2/radiobox.cpp index 3b93efcba8..3632ef191b 100644 --- a/src/os2/radiobox.cpp +++ b/src/os2/radiobox.cpp @@ -12,14 +12,16 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_RADIOBOX + +#include "wx/radiobox.h" + #ifndef WX_PRECOMP #include - #include "wx/setup.h" #include "wx/wxchar.h" #include "wx/string.h" #include "wx/bitmap.h" #include "wx/brush.h" - #include "wx/radiobox.h" #endif #include "wx/os2/private.h" @@ -80,13 +82,13 @@ wxRadioBox::~wxRadioBox() wxRemoveHandleAssociation(this); if (m_ahRadioButtons) { - for (int i = 0; i < m_nNoItems; i++) + for (unsigned int i = 0; i < m_nNoItems; i++) { wxWindow* pWin = wxFindWinFromHandle((WXHWND)m_ahRadioButtons[i]); wxRemoveHandleAssociation(pWin); ::WinDestroyWindow((HWND)m_ahRadioButtons[i]); - } + } delete[] m_ahRadioButtons; } if (m_pnRadioWidth) @@ -95,20 +97,16 @@ wxRadioBox::~wxRadioBox() delete[] m_pnRadioHeight; } // end of wxRadioBox::~wxRadioBox -void wxRadioBox::Command ( - wxCommandEvent& rEvent -) +void wxRadioBox::Command ( wxCommandEvent& rEvent ) { SetSelection (rEvent.GetInt()); ProcessCommand(rEvent); } // end of wxRadioBox::Command -bool wxRadioBox::ContainsHWND( - WXHWND hWnd -) const +bool wxRadioBox::ContainsHWND( WXHWND hWnd ) const { - size_t nCount = GetCount(); - size_t i; + unsigned int nCount = GetCount(); + unsigned int i; for (i = 0; i < nCount; i++) { @@ -118,18 +116,16 @@ bool wxRadioBox::ContainsHWND( return false; } // end of wxRadioBox::ContainsHWND -bool wxRadioBox::Create( - wxWindow* pParent -, wxWindowID vId -, const wxString& rsTitle -, const wxPoint& rPos -, const wxSize& rSize -, const wxArrayString& asChoices -, int nMajorDim -, long lStyle -, const wxValidator& rVal -, const wxString& rsName -) +bool wxRadioBox::Create( wxWindow* pParent, + wxWindowID vId, + const wxString& rsTitle, + const wxPoint& rPos, + const wxSize& rSize, + const wxArrayString& asChoices, + int nMajorDim, + long lStyle, + const wxValidator& rVal, + const wxString& rsName ) { wxCArrayString chs(asChoices); @@ -137,25 +133,22 @@ bool wxRadioBox::Create( chs.GetStrings(), nMajorDim, lStyle, rVal, rsName); } -bool wxRadioBox::Create( - wxWindow* pParent -, wxWindowID vId -, const wxString& rsTitle -, const wxPoint& rPos -, const wxSize& rSize -, int nNum -, const wxString asChoices[] -, int nMajorDim -, long lStyle -, const wxValidator& rVal -, const wxString& rsName -) -{ - wxColour vColour; - LONG lColor; - HWND hWndParent = GetHwndOf(pParent); +bool wxRadioBox::Create( wxWindow* pParent, + wxWindowID vId, + const wxString& rsTitle, + const wxPoint& rPos, + const wxSize& rSize, + int nNum, + const wxString asChoices[], + int nMajorDim, + long lStyle, + const wxValidator& rVal, + const wxString& rsName ) +{ + wxColour vColour(*wxBLACK); + LONG lColor; + HWND hWndParent = GetHwndOf(pParent); - vColour.Set(wxString(wxT("BLACK"))); m_backgroundColour = pParent->GetBackgroundColour(); m_nSelectedButton = -1; m_nNoItems = 0; @@ -185,7 +178,7 @@ bool wxRadioBox::Create( // // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows // - m_nNoItems = nNum; + m_nNoItems = (unsigned int)nNum; SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle); m_ahRadioButtons = new WXHWND[nNum]; @@ -413,14 +406,14 @@ void wxRadioBox::DoSetSize( nStartX = nXOffset; nStartY = nYOffset; - for (int i = 0; i < m_nNoItems; i++) + for (unsigned int i = 0; i < m_nNoItems; i++) { // // The last button in the row may be wider than the other ones as the // radiobox may be wider than the sum of the button widths (as it // happens, for example, when the radiobox label is very long) // - bool bIsLastInTheRow; + bool bIsLastInTheRow; if (m_windowStyle & wxRA_SPECIFY_COLS) { @@ -430,7 +423,7 @@ void wxRadioBox::DoSetSize( // int n = i + 1; - bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems); + bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == (int)m_nNoItems); } else // winRA_SPECIFY_ROWS { @@ -517,7 +510,7 @@ void wxRadioBox::DoSetSize( } } // end of wxRadioBox::DoSetSize -bool wxRadioBox::Enable(int nItem, bool bEnable) +bool wxRadioBox::Enable(unsigned int nItem, bool bEnable) { wxCHECK_MSG( IsValid(nItem), false, wxT("invalid item in wxRadioBox::Enable()") ); @@ -526,18 +519,16 @@ bool wxRadioBox::Enable(int nItem, bool bEnable) return true; } // end of wxRadioBox::Enable -bool wxRadioBox::Enable( - bool bEnable -) +bool wxRadioBox::Enable(bool bEnable) { if ( !wxControl::Enable(bEnable) ) return false; - for (int i = 0; i < m_nNoItems; i++) + for (unsigned int i = 0; i < m_nNoItems; i++) ::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable); return true; } // end of wxRadioBox::Enable -int wxRadioBox::GetCount() const +unsigned int wxRadioBox::GetCount() const { return m_nNoItems; } // end of wxRadioBox::GetCount @@ -551,13 +542,13 @@ wxString wxRadioBox::GetLabel(int nItem) const wxSize wxRadioBox::GetMaxButtonSize() const { - int nWidthMax = 0; - int nHeightMax = 0; + int nWidthMax = 0; + int nHeightMax = 0; - for (int i = 0 ; i < m_nNoItems; i++) + for (unsigned int i = 0 ; i < m_nNoItems; i++) { - int nWidth; - int nHeight; + int nWidth; + int nHeight; if (m_pnRadioWidth[i] < 0L) { @@ -596,7 +587,7 @@ int wxRadioBox::GetSelection() const void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const { - RECT vRect; + RECT vRect; vRect.xLeft = -1; vRect.xRight = -1; @@ -604,14 +595,10 @@ void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const vRect.yBottom = -1; if (m_hWnd) - wxFindMaxSize( m_hWnd - ,&vRect - ); + wxFindMaxSize( m_hWnd, &vRect ); - for (int i = 0; i < m_nNoItems; i++) - wxFindMaxSize( m_ahRadioButtons[i] - ,&vRect - ); + for (unsigned int i = 0; i < m_nNoItems; i++) + wxFindMaxSize( m_ahRadioButtons[i], &vRect ); if (pnWidth) *pnWidth = vRect.xRight - vRect.xLeft; @@ -620,22 +607,21 @@ void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const } // end of wxRadioBox::GetSize // Find string for position -wxString wxRadioBox::GetString( - int nNum -) const +wxString wxRadioBox::GetString(unsigned int nNum) const { - wxCHECK_MSG( IsValid(nNum), wxString(""), wxT("invalid radiobox index") ); + wxCHECK_MSG( IsValid(nNum), wxEmptyString, wxT("invalid radiobox index") ); return wxGetWindowText(m_ahRadioButtons[nNum]); } // end of wxRadioBox::GetString // For single selection items only wxString wxRadioBox::GetStringSelection() const { - wxString sResult; - int nSel = GetSelection(); + wxString sResult; + int nSel = GetSelection(); - if (nSel > -1) + if (nSel != wxNOT_FOUND) sResult = GetString(nSel); + return sResult; } // end of wxRadioBox::GetStringSelection @@ -655,8 +641,8 @@ wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const // // And also wide enough for its label // - wxString sStr = wxGetWindowText(GetHwnd()); - if (!sStr.IsEmpty()) + wxString sStr = wxGetWindowText(GetHwnd()); + if (!sStr.empty()) { GetTextExtent( sStr ,&nWidthLabel @@ -704,7 +690,7 @@ bool wxRadioBox::OS2Command( WXUINT uCmd, if (wId == GetId()) return true; - for (int i = 0; i < m_nNoItems; i++) + for (unsigned int i = 0; i < m_nNoItems; i++) { if (wId == wxGetWindowId(m_ahRadioButtons[i])) { @@ -732,9 +718,10 @@ bool wxRadioBox::OS2Command( WXUINT uCmd, void wxRadioBox::SendNotificationEvent() { - wxCommandEvent vEvent( wxEVT_COMMAND_RADIOBOX_SELECTED - ,m_windowId - ); + wxCommandEvent vEvent( + wxEVT_COMMAND_RADIOBOX_SELECTED, + m_windowId + ); vEvent.SetInt( m_nSelectedButton ); vEvent.SetString( GetString(m_nSelectedButton) ); @@ -753,9 +740,7 @@ void wxRadioBox::SetFocus() } } // end of wxRadioBox::SetFocus -bool wxRadioBox::SetFont( - const wxFont& rFont -) +bool wxRadioBox::SetFont(const wxFont& rFont) { if (!wxControl::SetFont(rFont)) { @@ -767,13 +752,11 @@ bool wxRadioBox::SetFont( // // Also set the font of our radio buttons // - for (int n = 0; n < (int)m_nNoItems; n++) + for (unsigned int n = 0; n < m_nNoItems; n++) { - HWND hWndBtn = (HWND)m_ahRadioButtons[n]; + HWND hWndBtn = (HWND)m_ahRadioButtons[n]; - wxOS2SetFont( hWndBtn - ,rFont - ); + wxOS2SetFont( hWndBtn, rFont ); ::WinInvalidateRect(hWndBtn, NULL, FALSE); } return true; @@ -793,10 +776,7 @@ void wxRadioBox::SetSelection( m_nSelectedButton = nNum; } // end of wxRadioBox::SetSelection -void wxRadioBox::SetString( - int nItem -, const wxString& rsLabel -) +void wxRadioBox::SetString(unsigned int nItem, const wxString& rsLabel) { wxCHECK_RET( IsValid(nItem), wxT("invalid radiobox index") ); @@ -817,14 +797,12 @@ bool wxRadioBox::SetStringSelection(const wxString& rsStr) return false; } // end of wxRadioBox::SetStringSelection -bool wxRadioBox::Show( - bool bShow -) +bool wxRadioBox::Show(bool bShow) { if (!wxControl::Show(bShow)) return false; - for (int i = 0; i < m_nNoItems; i++) + for (unsigned int i = 0; i < m_nNoItems; i++) { ::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow); } @@ -832,10 +810,7 @@ bool wxRadioBox::Show( } // end of wxRadioBox::Show // Show a specific button -bool wxRadioBox::Show( - int nItem -, bool bShow -) +bool wxRadioBox::Show(unsigned int nItem, bool bShow) { wxCHECK_MSG( IsValid(nItem), false, wxT("invalid item in wxRadioBox::Show()") ); @@ -962,3 +937,5 @@ MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd, (MPARAM)lParam ) ); } // end of wxRadioBoxWndProc + +#endif // wxUSE_RADIOBOX