X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/11e62fe658531aaa2891351f19bd0a4c076717ae..80f218424f34e2ded439cc23631ea1b74c72f732:/src/motif/radiobox.cpp?ds=inline diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index f5e4182954..b529840be5 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -12,12 +12,12 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_RADIOBOX + #ifdef __VMS #define XtDisplay XTDISPLAY #endif -#include "wx/defs.h" - #include "wx/radiobox.h" #include "wx/utils.h" #include "wx/arrstr.h" @@ -48,7 +48,6 @@ void wxRadioBox::Init() m_selectedButton = -1; m_noItems = 0; m_noRowsOrCols = 0; - m_majorDim = 0 ; } bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, @@ -60,13 +59,10 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, if( !CreateControl( parent, id, pos, size, style, val, name ) ) return false; - m_noItems = n; + m_noItems = (size_t)n; m_noRowsOrCols = majorDim; - if (majorDim==0) - m_majorDim = n ; - else - m_majorDim = majorDim ; + SetMajorDim(majorDim == 0 ? n : majorDim, style); Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); @@ -107,11 +103,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, Arg args[3]; - m_majorDim = (n + m_majorDim - 1) / m_majorDim; - XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ? XmHORIZONTAL : XmVERTICAL)); - XtSetArg (args[1], XmNnumColumns, m_majorDim); + XtSetArg (args[1], XmNnumColumns, GetMajorDim()); XtSetArg (args[2], XmNadjustLast, False); Widget radioBoxWidget = @@ -203,9 +197,8 @@ void wxRadioBox::SetSelection(int n) XmToggleButtonSetState ((Widget) m_radioButtons[n], True, False); - int i; - for (i = 0; i < m_noItems; i++) - if (i != n) + for (size_t i = 0; i < m_noItems; i++) + if (i != (size_t)n) XmToggleButtonSetState ((Widget) m_radioButtons[i], False, False); m_inSetValue = false; @@ -265,8 +258,7 @@ bool wxRadioBox::Enable(bool enable) if ( !wxControl::Enable(enable) ) return false; - int i; - for (i = 0; i < m_noItems; i++) + for (size_t i = 0; i < m_noItems; i++) XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable); return true; @@ -341,8 +333,7 @@ void wxRadioBox::ChangeFont(bool keepOriginalSize) { wxWindow::ChangeFont(keepOriginalSize); - int i; - for (i = 0; i < m_noItems; i++) + for (size_t i = 0; i < m_noItems; i++) { WXWidget radioButton = m_radioButtons[i]; @@ -358,8 +349,7 @@ void wxRadioBox::ChangeBackgroundColour() int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget)); - int i; - for (i = 0; i < m_noItems; i++) + for (size_t i = 0; i < m_noItems; i++) { WXWidget radioButton = m_radioButtons[i]; @@ -375,8 +365,7 @@ void wxRadioBox::ChangeForegroundColour() { wxWindow::ChangeForegroundColour(); - int i; - for (i = 0; i < m_noItems; i++) + for (size_t i = 0; i < m_noItems; i++) { WXWidget radioButton = m_radioButtons[i]; @@ -384,23 +373,6 @@ void wxRadioBox::ChangeForegroundColour() } } -static int CalcOtherDim( int items, int dim ) -{ - return items / dim + ( items % dim ? 1 : 0 ); -} - -int wxRadioBox::GetRowCount() const -{ - return m_windowStyle & wxRA_SPECIFY_ROWS ? m_noRowsOrCols - : CalcOtherDim( GetCount(), m_noRowsOrCols ); -} - -int wxRadioBox::GetColumnCount() const -{ - return m_windowStyle & wxRA_SPECIFY_COLS ? m_noRowsOrCols - : CalcOtherDim( GetCount(), m_noRowsOrCols ); -} - void wxRadioBoxCallback (Widget w, XtPointer clientData, XmToggleButtonCallbackStruct * cbs) { @@ -409,11 +381,11 @@ void wxRadioBoxCallback (Widget w, XtPointer clientData, wxRadioBox *item = (wxRadioBox *) clientData; int sel = -1; - int i; + size_t i; const wxWidgetArray& buttons = item->GetRadioButtons(); for (i = 0; i < item->GetCount(); i++) if (((Widget)buttons[i]) == w) - sel = i; + sel = (int)i; item->SetSel(sel); if (item->InSetValue()) @@ -425,3 +397,5 @@ void wxRadioBoxCallback (Widget w, XtPointer clientData, event.SetEventObject(item); item->ProcessCommand (event); } + +#endif // wxUSE_RADIOBOX