X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/521bf4ff3ef47059265beff5d53c9e1162beb122..1fbfbfb0bf19e11ec98c2c1002cd561f16bc0b72:/src/os2/radiobox.cpp diff --git a/src/os2/radiobox.cpp b/src/os2/radiobox.cpp index fa60f8f8de..19ff8a2bac 100644 --- a/src/os2/radiobox.cpp +++ b/src/os2/radiobox.cpp @@ -12,13 +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/wxchar.h" + #include "wx/crt.h" #include "wx/string.h" #include "wx/bitmap.h" #include "wx/brush.h" - #include "wx/radiobox.h" #endif #include "wx/os2/private.h" @@ -73,13 +76,13 @@ wxRadioBox::wxRadioBox() wxRadioBox::~wxRadioBox() { - m_isBeingDeleted = true; + SendDestroyEvent(); if (m_hWnd) 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); @@ -94,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++) { @@ -117,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); @@ -136,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; @@ -184,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]; @@ -412,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) { @@ -429,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 { @@ -516,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()") ); @@ -525,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 @@ -550,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) { @@ -595,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; @@ -603,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; @@ -619,7 +607,7 @@ 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), wxEmptyString, wxT("invalid radiobox index") ); return wxGetWindowText(m_ahRadioButtons[nNum]); @@ -628,11 +616,12 @@ wxString wxRadioBox::GetString( int nNum ) const // 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 @@ -701,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])) { @@ -729,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) ); @@ -750,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)) { @@ -764,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; @@ -790,15 +776,12 @@ 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") ); m_pnRadioWidth[nItem] = m_pnRadioHeight[nItem] = -1; - ::WinSetWindowText((HWND)m_ahRadioButtons[nItem], (PSZ)rsLabel.c_str()); + ::WinSetWindowText((HWND)m_ahRadioButtons[nItem], rsLabel.c_str()); } // end of wxRadioBox::SetString bool wxRadioBox::SetStringSelection(const wxString& rsStr) @@ -814,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); } @@ -829,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()") ); @@ -959,3 +937,5 @@ MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd, (MPARAM)lParam ) ); } // end of wxRadioBoxWndProc + +#endif // wxUSE_RADIOBOX