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
This commit is contained in:
@@ -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}
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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__)
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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(),
|
||||
|
@@ -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);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
// <20> 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;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// <20> 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
|
||||
|
@@ -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);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
// <20> 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;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// <20> 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;
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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 )
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user