X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df57c15cce0a46071ffbbad00cb02c196361d37c..c13d6ac1ea199d1e3908d40d129e2fd5a4d82df7:/src/palmos/radiobox.cpp?ds=sidebyside diff --git a/src/palmos/radiobox.cpp b/src/palmos/radiobox.cpp index c089a55501..2b5f2ce256 100644 --- a/src/palmos/radiobox.cpp +++ b/src/palmos/radiobox.cpp @@ -17,10 +17,6 @@ // 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" @@ -30,20 +26,20 @@ #if wxUSE_RADIOBOX +#include "wx/radiobox.h" + #ifndef WX_PRECOMP #include "wx/bitmap.h" #include "wx/brush.h" - #include "wx/radiobox.h" #include "wx/settings.h" #include "wx/log.h" + #include "wx/radiobut.h" #endif #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif // wxUSE_TOOLTIPS -#include "wx/radiobut.h" - // TODO: wxCONSTRUCTOR #if 0 // wxUSE_EXTENDED_RTTI WX_DEFINE_FLAGS( wxRadioBoxStyle ) @@ -77,10 +73,7 @@ wxBEGIN_FLAGS( wxRadioBoxStyle ) wxFLAGS_MEMBER(wxHSCROLL) wxFLAGS_MEMBER(wxRA_SPECIFY_COLS) - wxFLAGS_MEMBER(wxRA_HORIZONTAL) wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS) - wxFLAGS_MEMBER(wxRA_VERTICAL) - wxEND_FLAGS( wxRadioBoxStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox, wxControl,"wx/radiobox.h") @@ -110,36 +103,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) // wxRadioBox // --------------------------------------------------------------------------- -int wxRadioBox::GetCount() const -{ - return 0; -} - -int wxRadioBox::GetColumnCount() const +void wxRadioBox::Init() { - return 0; + m_pos = wxPoint(0,0); + m_size = wxSize(0,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; -} - -// Radio box item -wxRadioBox::wxRadioBox() +unsigned int wxRadioBox::GetCount() const { + return m_radios.GetCount(); } bool wxRadioBox::Create(wxWindow *parent, @@ -155,27 +127,63 @@ bool wxRadioBox::Create(wxWindow *parent, const wxString& name) { // initialize members - m_majorDim = majorDim == 0 ? n : majorDim; + SetMajorDim(majorDim == 0 ? n : majorDim, style); - if(!wxControl::Create(parent, id, pos, size, style, val, name)) + if ( GetMajorDim() == 0 || n == 0 ) return false; - for(int i=0; i 0) + minor++; + if(m_size.x==wxDefaultCoord) + m_size.x=36*(use_cols?GetMajorDim():minor); + if(m_size.y==wxDefaultCoord) + 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 ( unsigned int j = 0; j < minor; j++ ) { - wxRadioButton* rb = new wxRadioButton(); - rb->SetGroup( id ); - rb->Create( - this, - wxID_ANY, - choices[i], - pos, - size, - ( n == 0 ? wxRB_GROUP : 0 ) | - ( style & wxRA_USE_CHECKBOX ) ? wxRB_USE_CHECKBOX : 0 - ); + for ( unsigned int k = 0; k < GetMajorDim(); k++ ) + { + if(iSetGroup( id ); + rb->Create( + this, + wxID_ANY, + choices[i], + start, + wxSize(end.x-start.x-1,end.y-start.y-1), + ( n == 0 ? wxRB_GROUP : 0 ) | + use_checkbox ? wxRB_USE_CHECKBOX : 0 + ); + m_radios.Put(i,rb); + i++; + } + } } - - SetSize(size); } bool wxRadioBox::Create(wxWindow *parent, @@ -199,8 +207,76 @@ wxRadioBox::~wxRadioBox() { } -void wxRadioBox::SetString(int item, const wxString& label) +wxRadioButton *wxRadioBox::GetRadioButton(int i) const +{ + return (wxRadioButton *)m_radios.Get(i); +} + +void wxRadioBox::DoGetPosition( int *x, int *y ) const +{ + *x = m_pos.x; + *y = m_pos.y; +} + +void wxRadioBox::DoGetSize( int *width, int *height ) const +{ + *width = m_size.x; + *height = m_size.y; +} + +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 unsigned int n = GetCount(); + unsigned int minor = n / GetMajorDim(); + if(n % GetMajorDim() > 0) + minor++; + + unsigned int i = 0; + for ( unsigned int j = 0; j < minor; j++ ) + { + for ( unsigned int k = 0; k < GetMajorDim(); k++ ) + { + if(iSetSize(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 GetPosition(); +} + +void wxRadioBox::SetString(unsigned int item, const wxString& label) { + wxRadioButton *btn = GetRadioButton(item); + if(btn) + btn->SetLabel(label); } void wxRadioBox::SetSelection(int N) @@ -214,11 +290,12 @@ int wxRadioBox::GetSelection() const } // 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; } // ---------------------------------------------------------------------------- @@ -240,34 +317,68 @@ wxSize wxRadioBox::DoGetBestSize() const return wxSize(0,0); } -// Restored old code. -void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) +void wxRadioBox::SetFocus() { } -void wxRadioBox::SetFocus() +// Enable all subcontrols +bool wxRadioBox::Enable(bool enable) { + for(unsigned int i=0; iEnable(enable); return false; } -// Enable a specific button -void wxRadioBox::Enable(int item, bool enable) +bool wxRadioBox::Show(bool show) { + for(unsigned int i=0; iShow(show); + RefreshRect(btn->GetRect()); + return ret; + } return false; } -// Show a specific button -void wxRadioBox::Show(int item, bool show) +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)