]> git.saurik.com Git - wxWidgets.git/commitdiff
1. moved m_majorDim duplicated in many ports to wxRadioBoxBase
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 30 Nov 2005 16:28:15 +0000 (16:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 30 Nov 2005 16:28:15 +0000 (16:28 +0000)
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

19 files changed:
docs/latex/wx/radiobox.tex
include/wx/cocoa/radiobox.h
include/wx/mac/carbon/radiobox.h
include/wx/mac/classic/radiobox.h
include/wx/motif/radiobox.h
include/wx/msw/radiobox.h
include/wx/os2/radiobox.h
include/wx/palmos/radiobox.h
include/wx/radiobox.h
include/wx/univ/radiobox.h
src/cocoa/radiobox.mm
src/common/radiocmn.cpp
src/mac/carbon/radiobox.cpp
src/mac/classic/radiobox.cpp
src/motif/radiobox.cpp
src/msw/radiobox.cpp
src/os2/radiobox.cpp
src/palmos/radiobox.cpp
src/univ/radiobox.cpp

index 9ac9d109b4ea1b439913d473016eca47e0466b36..8e8e80ced85b2894278dbaed63703d65977c484c 100644 (file)
@@ -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}
index 13c2391dbce9d1677c8512393a00aead10c16a9f..d8d0aafa6ba469aff6c33086e9cf896e893c59b4 100644 (file)
@@ -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;
 };
index 0e2c6c95030867535ed56b30de40ba13bc2bc621..6a895305fe60f0cefd0fdbdbd78053aacfe9d72b 100644 (file)
@@ -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;
 
index 5ae26133787b0558c64c482b0ec5c0b886229c7a..6a895305fe60f0cefd0fdbdbd78053aacfe9d72b 100644 (file)
@@ -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;
 
index 4f5b2fce4e7fe12028a7368f85d36cdda0eade49..7b1ad3d78ba581eb1c46eba1b3efabcb68d195ea 100644 (file)
@@ -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;
index e75b32dc3113f7c6a9fa600941cea3e99a3bd174..f7b902f61952577af0d0dd4cc1cb75c7b724e773 100644 (file)
@@ -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;
 
index f78e6e8cd3c0d71d3c31b435256a1b6a75810f4d..5ec9adffae19f62edf4120077345c471f709288c 100644 (file)
@@ -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;
index 14c7808610148f474085f7e72242f9050e1d8461..03b0941b786472ebaa7af38095c7bb094c655e03 100644 (file)
@@ -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;
 
index 61a4aacc936593f67a5835af189c11678f0a752d..01c8514cdf8067cd74e79490791b2549a1682860 100644 (file)
@@ -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__)
index a90b95b29988610c795c599e55f2299165f0ebe4..7cb1bb788834e694a5e76ddd8f7f21c9d8ae54c0 100644 (file)
@@ -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;
 
index 5d04a0852862e26580176b0aa1bd17fc0c17d2db..4dc469c0ddae67616198ccebabab5b270fc0df8c 100644 (file)
@@ -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);
index 9c759147e8630d6285adc51a09d393b0ea43ca5c..0d2851632fc5bd9e2c75d49156f1d87b192535f2 100644 (file)
 // 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(),
index 55cf5b0070da8cabebd4e64ecab61689eb0d0197..f1d1b2c722ec02a2b6d505a652ce2daa25c3d69b 100644 (file)
@@ -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
index 672267db79ca67f19564d738c21c68d061615b21..39bd6b2855fce0886b661da0ceb4e038012d9a0e 100644 (file)
@@ -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;
-    }
-}
index f5e418295437014fa9bc57152c3bae4f32d50955..90e3cdd123bdd8cc59b280de68e96bf56cd5d1e6 100644 (file)
@@ -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)
 {
index 86fbd228b11d97aac6f71fbc763abbfa36c1e119..cc0ca3009a14cc1de78997fbffd2afb251e421ad 100644 (file)
@@ -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 )
             {
index b379cd372474b01f5c90c2be2c07a34ceb8f505d..9eb243c8fc11d7a808cbb0436ee80bc33e41cd9b 100644 (file)
@@ -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
index 71a7ab977557fdbd307004cd7a285971d393cc11..5fea32f9bd7bf14ec75f84ab5a40e81bd2f55ce8 100644 (file)
@@ -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(i<n)
             {
                 wxPoint start, end;
-                start.x = (use_cols ? (k*m_size.x)/m_majorDim : (j*m_size.x)/minor);
-                start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/m_majorDim);
-                end.x = (use_cols ? ((k+1)*m_size.x)/m_majorDim : ((j+1)*m_size.x)/minor);
-                end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/m_majorDim);
+                start.x = (use_cols ? (k*m_size.x)/GetMajorDim() : (j*m_size.x)/minor);
+                start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/GetMajorDim());
+                end.x = (use_cols ? ((k+1)*m_size.x)/GetMajorDim() : ((j+1)*m_size.x)/minor);
+                end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/GetMajorDim());
                 wxRadioButton* rb = new wxRadioButton();
                 rb->SetGroup( 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<n)
             {
                 wxPoint start, end;
-                start.x = (use_cols ? (k*m_size.x)/m_majorDim : (j*m_size.x)/minor);
-                start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/m_majorDim);
-                end.x = (use_cols ? ((k+1)*m_size.x)/m_majorDim : ((j+1)*m_size.x)/minor);
-                end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/m_majorDim);
+                start.x = (use_cols ? (k*m_size.x)/GetMajorDim() : (j*m_size.x)/minor);
+                start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/GetMajorDim());
+                end.x = (use_cols ? ((k+1)*m_size.x)/GetMajorDim() : ((j+1)*m_size.x)/minor);
+                end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/GetMajorDim());
                 wxRadioButton* rb = GetRadioButton(i);
                 if(rb)
                 {
index 14ea018a286e44d1a793a6a5d5288889c85f83c1..9b45f783513e5596c824a19b9ee850505804a2dd 100644 (file)
@@ -95,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,
@@ -174,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 )
     {
@@ -211,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 )
@@ -420,8 +399,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;
@@ -457,7 +436,7 @@ void wxRadioBox::DoMoveWindow(int x0, int y0, int width, int height)
         if ( GetWindowStyle() & wxRA_TOPTOBOTTOM )
         {
             // from top to bottom
-            if ( (n + 1) % m_numRows )
+            if ( (n + 1) % GetRowCount() )
             {
                 // continue in this column
                 y += sizeBtn.y;
@@ -472,7 +451,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;