X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa50c0e3bfe333bf527177ada29fe24fbc6f6353..d14e03f5b719ce6dbe4a0e81b22ae8436bd230ae:/src/univ/radiobox.cpp diff --git a/src/univ/radiobox.cpp b/src/univ/radiobox.cpp index bb6aa6eda1..a01ada44bd 100644 --- a/src/univ/radiobox.cpp +++ b/src/univ/radiobox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: univ/radiobox.cpp +// Name: src/univ/radiobox.cpp // Purpose: wxRadioBox implementation // Author: Vadim Zeitlin // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "univradiobox.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -99,7 +95,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) void wxRadioBox::Init() { m_selection = -1; - m_majorDim = 0; } wxRadioBox::wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title, @@ -178,7 +173,7 @@ bool wxRadioBox::Create(wxWindow *parent, Append(n, choices); // majorDim default value is 0 which means make one row/column - SetMajorDim(majorDim == 0 ? n : majorDim); + SetMajorDim(majorDim == 0 ? n : majorDim, style); if ( size == wxDefaultSize ) { @@ -215,26 +210,6 @@ wxRadioBox::~wxRadioBox() // wxRadioBox init // ---------------------------------------------------------------------------- -void wxRadioBox::SetMajorDim(int majorDim) -{ - wxCHECK_RET( majorDim != 0, _T("major radiobox dimension can't be 0") ); - - m_majorDim = majorDim; - - int minorDim = (GetCount() + m_majorDim - 1) / m_majorDim; - - if ( GetWindowStyle() & wxRA_SPECIFY_COLS ) - { - m_numCols = majorDim; - m_numRows = minorDim; - } - else // wxRA_SPECIFY_ROWS - { - m_numCols = minorDim; - m_numRows = majorDim; - } -} - void wxRadioBox::Append(int count, const wxString *choices) { if ( !count ) @@ -329,6 +304,13 @@ bool wxRadioBox::Enable(int n, bool enable) return m_buttons[n]->Enable(enable); } +bool wxRadioBox::IsItemEnabled(int n) const +{ + wxCHECK_MSG( IsValid(n), false, _T("invalid index in wxRadioBox::IsItemEnabled") ); + + return m_buttons[n]->IsEnabled(); +} + bool wxRadioBox::Show(int n, bool show) { wxCHECK_MSG( IsValid(n), false, _T("invalid index in wxRadioBox::Show") ); @@ -336,6 +318,13 @@ bool wxRadioBox::Show(int n, bool show) return m_buttons[n]->Show(show); } +bool wxRadioBox::IsItemShown(int n) const +{ + wxCHECK_MSG( IsValid(n), false, _T("invalid index in wxRadioBox::IsItemShown") ); + + return m_buttons[n]->IsShown(); +} + // ---------------------------------------------------------------------------- // methods forwarded to the static box // ---------------------------------------------------------------------------- @@ -346,7 +335,7 @@ bool wxRadioBox::Enable(bool enable) return false; // also enable/disable the buttons - size_t count = m_buttons.GetCount(); + const size_t count = m_buttons.GetCount(); for ( size_t n = 0; n < count; n++ ) { Enable(n, enable); @@ -361,7 +350,7 @@ bool wxRadioBox::Show(bool show) return false; // also show/hide the buttons - size_t count = m_buttons.GetCount(); + const size_t count = m_buttons.GetCount(); for ( size_t n = 0; n < count; n++ ) { Show(n, show); @@ -386,7 +375,7 @@ void wxRadioBox::DoSetToolTip(wxToolTip *tooltip) wxControl::DoSetToolTip(tooltip); // Also set them for all Radio Buttons - size_t count = m_buttons.GetCount(); + const size_t count = m_buttons.GetCount(); for ( size_t n = 0; n < count; n++ ) { if (tooltip) @@ -403,10 +392,10 @@ void wxRadioBox::DoSetToolTip(wxToolTip *tooltip) wxSize wxRadioBox::GetMaxButtonSize() const { - int widthMax, heightMax, width, height; + int widthMax, heightMax, width = 0, height = 0; widthMax = heightMax = 0; - int count = GetCount(); + const int count = GetCount(); for ( int n = 0; n < count; n++ ) { m_buttons[n]->GetBestSize(&width, &height); @@ -424,8 +413,8 @@ wxSize wxRadioBox::DoGetBestClientSize() const { wxSize sizeBtn = GetMaxButtonSize(); - sizeBtn.x *= m_numCols; - sizeBtn.y *= m_numRows; + sizeBtn.x *= GetColumnCount(); + sizeBtn.y *= GetRowCount(); // add a border around all buttons sizeBtn.x += 2*BOX_BORDER_X; @@ -453,15 +442,15 @@ void wxRadioBox::DoMoveWindow(int x0, int y0, int width, int height) int x = x0, y = y0; - int count = GetCount(); - for ( int n = 0; n < count; n++ ) + const size_t count = GetCount(); + for ( size_t n = 0; n < count; n++ ) { m_buttons[n]->SetSize(x, y, sizeBtn.x, sizeBtn.y); if ( GetWindowStyle() & wxRA_TOPTOBOTTOM ) { // from top to bottom - if ( (n + 1) % m_numRows ) + if ( (n + 1) % GetRowCount() ) { // continue in this column y += sizeBtn.y; @@ -476,7 +465,7 @@ void wxRadioBox::DoMoveWindow(int x0, int y0, int width, int height) else // wxRA_LEFTTORIGHT: mirror the code above { // from left to right - if ( (n + 1) % m_numCols ) + if ( (n + 1) % GetColumnCount() ) { // continue in this row x += sizeBtn.x; @@ -534,4 +523,3 @@ bool wxRadioBox::OnKeyDown(wxKeyEvent& event) } #endif // wxUSE_RADIOBOX -