From 21e0a4d5f15ea1df40d29359fc1e84085936ef3f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 30 Nov 2005 16:28:15 +0000 Subject: [PATCH] 1. moved m_majorDim duplicated in many ports to wxRadioBoxBase 2. also implement Getcolumn/RowCount() in it now and document them 3. removed various remains of old (pre-wxRadioBoxBase) cruft sorry in advance for any compilation breakage on the platforms I can't test on git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/radiobox.tex | 14 +++++++ include/wx/cocoa/radiobox.h | 3 -- include/wx/mac/carbon/radiobox.h | 5 --- include/wx/mac/classic/radiobox.h | 4 -- include/wx/motif/radiobox.h | 4 -- include/wx/msw/radiobox.h | 10 ----- include/wx/os2/radiobox.h | 5 --- include/wx/palmos/radiobox.h | 8 ---- include/wx/radiobox.h | 30 +++++++++++++-- include/wx/univ/radiobox.h | 14 ------- src/cocoa/radiobox.mm | 11 ------ src/common/radiocmn.cpp | 20 ++++++++++ src/mac/carbon/radiobox.cpp | 44 +--------------------- src/mac/classic/radiobox.cpp | 41 +------------------- src/motif/radiobox.cpp | 27 +------------- src/msw/radiobox.cpp | 43 ++++----------------- src/os2/radiobox.cpp | 53 +++++--------------------- src/palmos/radiobox.cpp | 62 +++++++++++-------------------- src/univ/radiobox.cpp | 31 +++------------- 19 files changed, 111 insertions(+), 318 deletions(-) diff --git a/docs/latex/wx/radiobox.tex b/docs/latex/wx/radiobox.tex index 9ac9d109b4..8e8e80ced8 100644 --- a/docs/latex/wx/radiobox.tex +++ b/docs/latex/wx/radiobox.tex @@ -185,6 +185,13 @@ Finds a button matching the given string, returning the position if found, or \docparam{string}{The string to find.} +\membersection{wxRadioBox::GetColumnCount}\label{wxradioboxgetcolumncount} + +\constfunc{int}{GetColumnCount}{\void} + +Returns the number of columns in the radiobox. + + \membersection{wxRadioBox::GetCount}\label{wxradioboxgetcount} \constfunc{int}{GetCount}{\void} @@ -215,6 +222,13 @@ implements the following methods:\par } +\membersection{wxRadioBox::GetRowCount}\label{wxradioboxgetrowcount} + +\constfunc{int}{GetRowCount}{\void} + +Returns the number of rows in the radiobox. + + \membersection{wxRadioBox::GetSelection}\label{wxradioboxgetselection} \constfunc{int}{GetSelection}{\void} diff --git a/include/wx/cocoa/radiobox.h b/include/wx/cocoa/radiobox.h index 13c2391dbc..d8d0aafa6b 100644 --- a/include/wx/cocoa/radiobox.h +++ b/include/wx/cocoa/radiobox.h @@ -91,9 +91,6 @@ public: // change the individual radio button state virtual bool Enable(int n, bool enable = true); virtual bool Show(int n, bool show = true); - // layout parameters - virtual int GetColumnCount() const; - virtual int GetRowCount() const; protected: virtual wxSize DoGetBestSize() const; }; diff --git a/include/wx/mac/carbon/radiobox.h b/include/wx/mac/carbon/radiobox.h index 0e2c6c9503..6a895305fe 100644 --- a/include/wx/mac/carbon/radiobox.h +++ b/include/wx/mac/carbon/radiobox.h @@ -66,10 +66,6 @@ public: virtual bool Enable(int item, bool enable = true); virtual bool Show(int item, bool show = true); - virtual int GetColumnCount() const ; - virtual int GetRowCount() const ; - - virtual bool Enable(bool enable = true); virtual wxString GetLabel() const; virtual void SetLabel(const wxString& label) ; @@ -87,7 +83,6 @@ public: protected: wxRadioButton *m_radioButtonCycle; - int m_majorDim ; int m_noItems; int m_noRowsOrCols; diff --git a/include/wx/mac/classic/radiobox.h b/include/wx/mac/classic/radiobox.h index 5ae2613378..6a895305fe 100644 --- a/include/wx/mac/classic/radiobox.h +++ b/include/wx/mac/classic/radiobox.h @@ -66,9 +66,6 @@ public: virtual bool Enable(int item, bool enable = true); virtual bool Show(int item, bool show = true); - virtual int GetColumnCount() const ; - virtual int GetRowCount() const ; - virtual bool Enable(bool enable = true); virtual wxString GetLabel() const; virtual void SetLabel(const wxString& label) ; @@ -86,7 +83,6 @@ public: protected: wxRadioButton *m_radioButtonCycle; - int m_majorDim ; int m_noItems; int m_noRowsOrCols; diff --git a/include/wx/motif/radiobox.h b/include/wx/motif/radiobox.h index 4f5b2fce4e..7b1ad3d78b 100644 --- a/include/wx/motif/radiobox.h +++ b/include/wx/motif/radiobox.h @@ -87,9 +87,6 @@ public: virtual int GetCount() const { return m_noItems; } ; void Command(wxCommandEvent& event); - int GetColumnCount() const; - int GetRowCount() const; - int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } @@ -106,7 +103,6 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO); - int m_majorDim; int m_noItems; int m_noRowsOrCols; int m_selectedButton; diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index e75b32dc31..f7b902f619 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -92,8 +92,6 @@ public: virtual bool Show(int n, bool show = true); virtual bool IsItemEnabled(int n) const; virtual bool IsItemShown(int n) const; - virtual int GetColumnCount() const { return GetNumHor(); } - virtual int GetRowCount() const { return GetNumVer(); } // override some base class methods virtual bool Show(bool show = true); @@ -117,10 +115,6 @@ public: void SendNotificationEvent(); - // get the number of buttons per column/row - int GetNumVer() const; - int GetNumHor() const; - protected: // common part of all ctors void Init(); @@ -158,10 +152,6 @@ protected: int *m_radioWidth; int *m_radioHeight; - // the number of elements in major dimension (i.e. number of columns if - // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS) - int m_majorDim; - // currently selected button or wxNOT_FOUND if none int m_selectedButton; diff --git a/include/wx/os2/radiobox.h b/include/wx/os2/radiobox.h index f78e6e8cd3..5ec9adffae 100644 --- a/include/wx/os2/radiobox.h +++ b/include/wx/os2/radiobox.h @@ -125,16 +125,12 @@ public: - virtual int GetColumnCount(void) const; virtual int GetCount(void) const; inline int GetNumberOfRowsOrCols(void) const { return m_nNoRowsOrCols; } - int GetNumHor(void) const; - int GetNumVer(void) const; void GetPosition( int* pnX ,int* pnY ) const; inline WXHWND* GetRadioButtons(void) const { return m_ahRadioButtons; } - virtual int GetRowCount(void) const; int GetSelection(void) const; void GetSize( int* pnX ,int* pnY @@ -183,7 +179,6 @@ protected: WXHWND* m_ahRadioButtons; - int m_nMajorDim ; int* m_pnRadioWidth; // for bitmaps int* m_pnRadioHeight; int m_nNoItems; diff --git a/include/wx/palmos/radiobox.h b/include/wx/palmos/radiobox.h index 14c7808610..03b0941b78 100644 --- a/include/wx/palmos/radiobox.h +++ b/include/wx/palmos/radiobox.h @@ -101,9 +101,6 @@ public: virtual void SetLabel(const wxString& label); virtual wxString GetLabel(); - virtual int GetColumnCount() const; - virtual int GetRowCount() const; - virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize( int *width, int *height ) const; virtual void DoMoveWindow(int x, int y, int width, int height); @@ -129,10 +126,6 @@ public: void SendNotificationEvent(); - // get the number of buttons per column/row - int GetNumVer() const; - int GetNumHor() const; - protected: // we can't compute our best size before the items are added to the control virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { } @@ -143,7 +136,6 @@ protected: // get the total size occupied by the radio box buttons wxSize GetTotalButtonSize(const wxSize& sizeBtn) const; - int m_majorDim; int * m_radioWidth; // for bitmaps int * m_radioHeight; diff --git a/include/wx/radiobox.h b/include/wx/radiobox.h index 61a4aacc93..01c8514cdf 100644 --- a/include/wx/radiobox.h +++ b/include/wx/radiobox.h @@ -36,9 +36,9 @@ public: virtual bool IsItemEnabled(int WXUNUSED(n)) const { return true; } virtual bool IsItemShown(int WXUNUSED(n)) const { return true; } - // layout parameters - virtual int GetColumnCount() const = 0; - virtual int GetRowCount() const = 0; + // return number of columns/rows in this radiobox + int GetColumnCount() const { return m_numCols; } + int GetRowCount() const { return m_numRows; } // return the item above/below/to the left/right of the given one int GetNextItem(int item, wxDirection dir, long style) const; @@ -51,6 +51,30 @@ public: wxDEPRECATED( int GetNumberOfRowsOrCols() const ); wxDEPRECATED( void SetNumberOfRowsOrCols(int n) ); #endif // WXWIN_COMPATIBILITY_2_4 + +protected: + wxRadioBoxBase() + { + m_majorDim = 0; + } + + // return the number of items in major direction (which depends on whether + // we have wxRA_SPECIFY_COLS or wxRA_SPECIFY_ROWS style) + int GetMajorDim() const { return m_majorDim; } + + // sets m_majorDim and also updates m_numCols/Rows + // + // the style parameter should be the style of the radiobox itself + void SetMajorDim(int majorDim, long style); + + +private: + // the number of elements in major dimension (i.e. number of columns if + // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS) and also + // the number of rows/columns calculated from it + int m_majorDim, + m_numCols, + m_numRows; }; #if defined(__WXUNIVERSAL__) diff --git a/include/wx/univ/radiobox.h b/include/wx/univ/radiobox.h index a90b95b299..7cb1bb7888 100644 --- a/include/wx/univ/radiobox.h +++ b/include/wx/univ/radiobox.h @@ -85,8 +85,6 @@ public: virtual int GetSelection() const; virtual int GetCount() const { return (int) m_buttons.GetCount(); } - virtual int GetColumnCount() const { return m_numCols; } - virtual int GetRowCount() const { return m_numRows; } virtual wxString GetString(int n) const; virtual void SetString(int n, const wxString& label); @@ -128,24 +126,12 @@ protected: // common part of all ctors void Init(); - // sets m_majorDim and calculate m_numCols and m_numRows - void SetMajorDim(int majorDim); - // calculate the max size of all buttons wxSize GetMaxButtonSize() const; // the currently selected radio button or -1 int m_selection; - // the parameters defining the button layout: majorDim meaning depends on - // the style and is the (max) number of columns if it includes - // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes - // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from - // it - int m_majorDim, - m_numCols, - m_numRows; - // all radio buttons wxArrayRadioButtons m_buttons; diff --git a/src/cocoa/radiobox.mm b/src/cocoa/radiobox.mm index 5d04a08528..4dc469c0dd 100644 --- a/src/cocoa/radiobox.mm +++ b/src/cocoa/radiobox.mm @@ -103,17 +103,6 @@ bool wxRadioBox::Show(int n, bool show) return false; } - // layout parameters -int wxRadioBox::GetColumnCount() const -{ - return 0; -} - -int wxRadioBox::GetRowCount() const -{ - return 0; -} - wxSize wxRadioBox::DoGetBestSize() const { return wxSize(50,50); diff --git a/src/common/radiocmn.cpp b/src/common/radiocmn.cpp index 9c759147e8..0d2851632f 100644 --- a/src/common/radiocmn.cpp +++ b/src/common/radiocmn.cpp @@ -34,6 +34,26 @@ // implementation // ============================================================================ +void wxRadioBoxBase::SetMajorDim(int majorDim, long style) +{ + wxCHECK_RET( majorDim != 0, _T("major radiobox dimension can't be 0") ); + + m_majorDim = majorDim; + + int minorDim = (GetCount() + m_majorDim - 1) / m_majorDim; + + if ( style & wxRA_SPECIFY_COLS ) + { + m_numCols = majorDim; + m_numRows = minorDim; + } + else // wxRA_SPECIFY_ROWS + { + m_numCols = minorDim; + m_numRows = majorDim; + } +} + int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const { int count = GetCount(), diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 55cf5b0070..f1d1b2c722 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -50,7 +50,6 @@ wxRadioBox::wxRadioBox() { m_noItems = 0; m_noRowsOrCols = 0; - m_majorDim = 0 ; m_radioButtonCycle = NULL; } @@ -119,11 +118,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; - if (majorDim==0) - m_majorDim = n ; - else - m_majorDim = majorDim ; - + SetMajorDim(majorDim == 0 ? n : majorDim, style); m_label = label ; @@ -478,7 +473,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) current=m_radioButtonCycle; for ( i = 0 ; i < m_noItems; i++) { - if (i&&((i%m_majorDim)==0)) // not to do for the zero button! + if (i&&((i%GetMajorDim())==0)) // not to do for the zero button! { if (m_windowStyle & wxRA_SPECIFY_ROWS) { @@ -542,38 +537,3 @@ wxSize wxRadioBox::DoGetBestSize() const return wxSize(totWidth, totHeight); } -//------------------------------------------------------------------------------------- -// ¥ GetNumVer -//------------------------------------------------------------------------------------- -// return the number of buttons in the vertical direction - -int wxRadioBox::GetRowCount() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return m_majorDim; - } - else - { - return (m_noItems + m_majorDim - 1)/m_majorDim; - } -} - -//------------------------------------------------------------------------------------- -// ¥ GetNumHor -//------------------------------------------------------------------------------------- -// return the number of buttons in the horizontal direction - -int wxRadioBox::GetColumnCount() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return (m_noItems + m_majorDim - 1)/m_majorDim; - } - else - { - return m_majorDim; - } -} - -#endif diff --git a/src/mac/classic/radiobox.cpp b/src/mac/classic/radiobox.cpp index 672267db79..39bd6b2855 100644 --- a/src/mac/classic/radiobox.cpp +++ b/src/mac/classic/radiobox.cpp @@ -47,7 +47,6 @@ wxRadioBox::wxRadioBox() { m_noItems = 0; m_noRowsOrCols = 0; - m_majorDim = 0 ; m_radioButtonCycle = NULL; } @@ -114,10 +113,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; - if (majorDim==0) - m_majorDim = n ; - else - m_majorDim = majorDim ; + SetMajorDim(majorDim == 0 ? n : majorDim, style); Rect bounds ; Str255 title ; @@ -469,7 +465,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) current=m_radioButtonCycle; for ( i = 0 ; i < m_noItems; i++) { - if (i&&((i%m_majorDim)==0)) // not to do for the zero button! + if (i&&((i%GetMajorDim())==0)) // not to do for the zero button! { if (m_windowStyle & wxRA_VERTICAL) { @@ -533,36 +529,3 @@ wxSize wxRadioBox::DoGetBestSize() const return wxSize(totWidth, totHeight); } -//------------------------------------------------------------------------------------- -// ¥ GetNumVer -//------------------------------------------------------------------------------------- -// return the number of buttons in the vertical direction - -int wxRadioBox::GetRowCount() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return m_majorDim; - } - else - { - return (m_noItems + m_majorDim - 1)/m_majorDim; - } -} - -//------------------------------------------------------------------------------------- -// ¥ GetNumHor -//------------------------------------------------------------------------------------- -// return the number of buttons in the horizontal direction - -int wxRadioBox::GetColumnCount() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return (m_noItems + m_majorDim - 1)/m_majorDim; - } - else - { - return m_majorDim; - } -} diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index f5e4182954..90e3cdd123 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -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, @@ -63,10 +62,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, m_noItems = 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 = @@ -384,23 +378,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) { diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 86fbd228b1..cc0ca3009a 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -131,7 +131,6 @@ void wxRadioBox::Init() { m_selectedButton = wxNOT_FOUND; m_radioButtons = NULL; - m_majorDim = 0; m_radioWidth = NULL; m_radioHeight = NULL; } @@ -149,7 +148,7 @@ bool wxRadioBox::Create(wxWindow *parent, const wxString& name) { // initialize members - m_majorDim = majorDim == 0 ? n : majorDim; + SetMajorDim(majorDim == 0 ? n : majorDim, style); // common initialization if ( !wxStaticBox::Create(parent, id, title, pos, size, style, name) ) @@ -331,32 +330,6 @@ int wxRadioBox::GetCount() const return m_radioButtons->GetCount(); } -// returns the number of rows -int wxRadioBox::GetNumVer() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return m_majorDim; - } - else - { - return (GetCount() + m_majorDim - 1)/m_majorDim; - } -} - -// returns the number of columns -int wxRadioBox::GetNumHor() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return (GetCount() + m_majorDim - 1)/m_majorDim; - } - else - { - return m_majorDim; - } -} - void wxRadioBox::SetString(int item, const wxString& label) { wxCHECK_RET( IsValid(item), wxT("invalid radiobox index") ); @@ -498,8 +471,8 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const int extraHeight = cy1; - int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight; - int width = GetNumHor() * (sizeBtn.x + cx1) + cx1; + int height = GetRowCount() * sizeBtn.y + cy1/2 + extraHeight; + int width = GetColumnCount() * (sizeBtn.x + cx1) + cx1; // Add extra space under the label, if it exists. if (!wxControl::GetLabel().empty()) @@ -580,9 +553,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) // to the right border of radiobox and thus can be wider than this. // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in - // left to right order and m_majorDim is the number of columns while + // left to right order and GetMajorDim() is the number of columns while // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and - // m_majorDim is the number of rows. + // GetMajorDim() is the number of rows. x_offset += cx1; y_offset += cy1; @@ -606,16 +579,16 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) // item is the last in its row if it is a multiple of the number of // columns or if it is just the last item int n = i + 1; - isLastInTheRow = ((n % m_majorDim) == 0) || (n == count); + isLastInTheRow = ((n % GetMajorDim()) == 0) || (n == count); } else // wxRA_SPECIFY_ROWS { // item is the last in the row if it is in the last columns - isLastInTheRow = i >= (count/m_majorDim)*m_majorDim; + isLastInTheRow = i >= (count/GetMajorDim())*GetMajorDim(); } // is this the start of new row/column? - if ( i && (i % m_majorDim == 0) ) + if ( i && (i % GetMajorDim() == 0) ) { if ( m_windowStyle & wxRA_SPECIFY_ROWS ) { diff --git a/src/os2/radiobox.cpp b/src/os2/radiobox.cpp index b379cd3724..9eb243c8fc 100644 --- a/src/os2/radiobox.cpp +++ b/src/os2/radiobox.cpp @@ -68,7 +68,6 @@ wxRadioBox::wxRadioBox() m_nNoItems = 0; m_nNoRowsOrCols = 0; m_ahRadioButtons = NULL; - m_nMajorDim = 0; m_pnRadioWidth = NULL; m_pnRadioHeight = NULL; } // end of wxRadioBox::wxRadioBox @@ -139,20 +138,20 @@ void wxRadioBox::AdjustButtons( int nX, // int n = i + 1; - bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems); + bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems); } else // winRA_SPECIFY_ROWS { // // Item is the last in the row if it is in the last columns // - bIsLastInTheRow = i >= (m_nNoItems/m_nMajorDim) * m_nMajorDim; + bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim(); } // // Is this the start of new row/column? // - if (i && (i % m_nMajorDim == 0)) + if (i && (i % GetMajorDim() == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { @@ -291,7 +290,7 @@ bool wxRadioBox::Create( m_nSelectedButton = -1; m_nNoItems = 0; - m_nMajorDim = nMajorDim == 0 ? nNum : nMajorDim; + SetMajorDim(majorDim == 0 ? n : majorDim, lStyle); m_nNoRowsOrCols = nMajorDim; // @@ -578,20 +577,20 @@ void wxRadioBox::DoSetSize( // int n = i + 1; - bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems); + bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems); } else // winRA_SPECIFY_ROWS { // // Item is the last in the row if it is in the last columns // - bIsLastInTheRow = i >= (m_nNoItems/m_nMajorDim) * m_nMajorDim; + bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim(); } // // Is this the start of new row/column? // - if (i && (i % m_nMajorDim == 0)) + if (i && (i % GetMajorDim() == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { @@ -686,11 +685,6 @@ bool wxRadioBox::Enable( return true; } // end of wxRadioBox::Enable -int wxRadioBox::GetColumnCount() const -{ - return GetNumHor(); -} // end of wxRadioBox::GetColumnCount - int wxRadioBox::GetCount() const { return m_nNoItems; @@ -742,30 +736,6 @@ wxSize wxRadioBox::GetMaxButtonSize() const return maxsize; } // end of wxRadioBox::GetMaxButtonSize -int wxRadioBox::GetNumHor() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim; - } - else - { - return m_nMajorDim; - } -} // end of wxRadioBox::GetNumHor - -int wxRadioBox::GetNumVer() const -{ - if ( m_windowStyle & wxRA_SPECIFY_ROWS ) - { - return m_nMajorDim; - } - else - { - return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim; - } -} // end of wxRadioBox::GetNumVer - void wxRadioBox::GetPosition( int* pnX, int* WXUNUSED(pnY) ) const { @@ -813,11 +783,6 @@ void wxRadioBox::GetPosition( int* pnX, *pnX = vPoint.y; } // end of wxRadioBox::GetPosition -int wxRadioBox::GetRowCount() const -{ - return GetNumVer(); -} // end of wxRadioBox::GetRowCount - // Get single selection, for single choice list items int wxRadioBox::GetSelection() const { @@ -879,8 +844,8 @@ wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const nCx1 = GetCharWidth(); nCy1 = GetCharHeight(); - nHeight = GetNumVer() * rSizeBtn.y + (2 * nCy1); - nWidth = GetNumHor() * (rSizeBtn.x + nCx1) + nCx1; + nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1); + nWidth = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1; // // And also wide enough for its label diff --git a/src/palmos/radiobox.cpp b/src/palmos/radiobox.cpp index 71a7ab9775..5fea32f9bd 100644 --- a/src/palmos/radiobox.cpp +++ b/src/palmos/radiobox.cpp @@ -117,28 +117,6 @@ int wxRadioBox::GetCount() const return m_radios.GetCount(); } -int wxRadioBox::GetColumnCount() const -{ - return 0; -} - -int wxRadioBox::GetRowCount() const -{ - return 0; -} - -// returns the number of rows -int wxRadioBox::GetNumVer() const -{ - return 0; -} - -// returns the number of columns -int wxRadioBox::GetNumHor() const -{ - return 0; -} - bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, @@ -152,8 +130,10 @@ bool wxRadioBox::Create(wxWindow *parent, const wxString& name) { // initialize members - m_majorDim = majorDim == 0 ? n : wxMin(majorDim, n); - if(m_majorDim==0 || n==0) return false; + SetMajorDim(majorDim == 0 ? n : majorDim, style); + + if ( GetMajorDim() == 0 || n == 0 ) + return false; // subtype of the native palmOS radio: checkbox or push button? const bool use_checkbox = style & wxRA_USE_CHECKBOX; @@ -162,12 +142,13 @@ bool wxRadioBox::Create(wxWindow *parent, // get default size and position for the initial placement m_size = size; m_pos = pos; - int minor = n / m_majorDim; - if(n % m_majorDim > 0) minor++; + int minor = n / GetMajorDim(); + if(n % GetMajorDim() > 0) + minor++; if(m_size.x==wxDefaultCoord) - m_size.x=36*(use_cols?m_majorDim:minor); + m_size.x=36*(use_cols?GetMajorDim():minor); if(m_size.y==wxDefaultCoord) - m_size.y=12*(use_cols?minor:m_majorDim); + m_size.y=12*(use_cols?minor:GetMajorDim()); if(m_pos.x==wxDefaultCoord) m_pos.x=0; if(m_pos.y==wxDefaultCoord) @@ -181,15 +162,15 @@ bool wxRadioBox::Create(wxWindow *parent, int i = 0; for ( int j = 0; j < minor; j++ ) { - for ( int k = 0; k < m_majorDim; k++ ) + for ( int k = 0; k < GetMajorDim(); k++ ) { if(iSetGroup( id ); rb->Create( @@ -258,21 +239,22 @@ void wxRadioBox::DoMoveWindow(int x, int y, int width, int height) const bool use_cols = HasFlag(wxRA_SPECIFY_COLS); const int n = GetCount(); - int minor = n / m_majorDim; - if(n % m_majorDim > 0) minor++; + int minor = n / GetMajorDim(); + if(n % GetMajorDim() > 0) + minor++; int i = 0; for ( int j = 0; j < minor; j++ ) { - for ( int k = 0; k < m_majorDim; k++ ) + for ( int k = 0; k < GetMajorDim(); k++ ) { if(i