// headers
// ---------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "radiobox.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
m_size = wxSize(0,0);
}
-int wxRadioBox::GetCount() const
+unsigned 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,
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;
// 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)
m_pos.y=0;
+ m_label = title;
+
if(!wxControl::Create(parent, id, m_pos, m_size, style, val, name))
return false;
int i = 0;
- for ( int j = 0; j < minor; j++ )
+ for ( unsigned int j = 0; j < minor; j++ )
{
- for ( int k = 0; k < m_majorDim; k++ )
+ for ( unsigned 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(
{
}
-wxRadioButton *wxRadioBox::GetRadioButton(int i)
+wxRadioButton *wxRadioBox::GetRadioButton(int i) const
{
return (wxRadioButton *)m_radios.Get(i);
}
void wxRadioBox::DoMoveWindow(int x, int y, int width, int height)
{
+ wxRect oldRect = GetRect();
+
+ m_pos.x = x;
+ m_pos.y = y;
m_size.x = width;
m_size.y = height;
const bool use_cols = HasFlag(wxRA_SPECIFY_COLS);
- const int n = GetCount();
- int minor = n / m_majorDim;
- if(n % m_majorDim > 0) minor++;
+ const unsigned int n = GetCount();
+ unsigned int minor = n / GetMajorDim();
+ if(n % GetMajorDim() > 0)
+ minor++;
- int i = 0;
- for ( int j = 0; j < minor; j++ )
+ unsigned int i = 0;
+ for ( unsigned int j = 0; j < minor; j++ )
{
- for ( int k = 0; k < m_majorDim; k++ )
+ for ( unsigned 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)
- rb->SetSize(end.x-start.x-1,end.y-start.y-1);
+ {
+ rb->SetSize(start.x,start.y,end.x-start.x-1,end.y-start.y-1);
+ }
i++;
}
}
}
+
+ // refresh old and new area
+ GetParent()->RefreshRect(oldRect.Union(GetRect()));
}
// get the origin of the client area in the client coordinates
wxPoint wxRadioBox::GetClientAreaOrigin() const
{
- return GetParent()->GetClientAreaOrigin() + GetPosition();
+ return GetPosition();
}
-void wxRadioBox::SetString(int item, const wxString& label)
+void wxRadioBox::SetString(unsigned int item, const wxString& label)
{
+ wxRadioButton *btn = GetRadioButton(item);
+ if(btn)
+ btn->SetLabel(label);
}
void wxRadioBox::SetSelection(int N)
}
// Find string for position
-wxString wxRadioBox::GetString(int item) const
+wxString wxRadioBox::GetString(unsigned int item) const
{
- wxString ret;
-
- return ret;
+ wxRadioButton *btn = GetRadioButton(item);
+ if(btn)
+ return btn->GetLabel();
+ return wxEmptyString;
}
// ----------------------------------------------------------------------------
{
}
-bool wxRadioBox::Show(bool show)
+// Enable all subcontrols
+bool wxRadioBox::Enable(bool enable)
{
- return false;
+ for(unsigned int i=0; i<GetCount(); i++)
+ Enable(i, enable);
+ return true;
}
// Enable a specific button
-bool wxRadioBox::Enable(int item, bool enable)
+bool wxRadioBox::Enable(unsigned int item, bool enable)
{
wxRadioButton *btn = GetRadioButton(item);
if(btn)
return false;
}
-// Enable all subcontrols
-bool wxRadioBox::Enable(bool enable)
+bool wxRadioBox::Show(bool show)
{
- for(int i=0; i<GetCount(); i++)
- Enable(i, enable);
+ for(unsigned int i=0; i<GetCount(); i++)
+ Show(i, show);
return true;
}
// Show a specific button
-void wxRadioBox::Show(int item, bool show)
+bool wxRadioBox::Show(unsigned int item, bool show)
+{
+ wxRadioButton *btn = GetRadioButton(item);
+ if(btn)
+ {
+ bool ret = btn->Show(show);
+ RefreshRect(btn->GetRect());
+ return ret;
+ }
+ return false;
+}
+
+wxString wxRadioBox::GetLabel()
+{
+ return m_label;
+}
+
+void wxRadioBox::SetLabel(const wxString& label)
{
+ m_label = label;
+}
+
+void wxRadioBox::Refresh(bool eraseBack, const wxRect *rect)
+{
+ wxRect area = GetRect();
+
+ if(rect)
+ {
+ area.Offset(rect->GetPosition());
+ area.SetSize(rect->GetSize());
+ }
+
+ GetParent()->RefreshRect(area);
}
void wxRadioBox::Command(wxCommandEvent & event)