X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e273151278d28cceefe6eee8c49bc6915306805d..1003169e2107a98807ed8279eeb8df7e4e90ca98:/src/palmos/radiobox.cpp diff --git a/src/palmos/radiobox.cpp b/src/palmos/radiobox.cpp index 606509e649..03b015e38c 100644 --- a/src/palmos/radiobox.cpp +++ b/src/palmos/radiobox.cpp @@ -2,10 +2,10 @@ // Name: src/palmos/radiobox.cpp // Purpose: wxRadioBox implementation // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation // Created: 10/13/04 // RCS-ID: $Id$ -// Copyright: (c) William Osborne +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -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" @@ -38,12 +34,12 @@ #include "wx/log.h" #endif -#include "wx/palmos/private.h" - #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 ) @@ -102,19 +98,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) item */ -#define RADIOBTN_PARENT_IS_RADIOBOX 0 - -// --------------------------------------------------------------------------- -// private functions -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// global vars -// --------------------------------------------------------------------------- - -// the pointer to standard radio button wnd proc -static WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL; - // =========================================================================== // implementation // =========================================================================== @@ -123,41 +106,15 @@ static WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL; // wxRadioBox // --------------------------------------------------------------------------- -int wxRadioBox::GetCount() const -{ - return 0; -} - -int wxRadioBox::GetColumnCount() const -{ - return 0; -} - -int wxRadioBox::GetRowCount() const -{ - return 0; -} - -// returns the number of rows -int wxRadioBox::GetNumVer() const +void wxRadioBox::Init() { - return 0; + m_pos = wxPoint(0,0); + m_size = wxSize(0,0); } -// returns the number of columns -int wxRadioBox::GetNumHor() const -{ - return 0; -} - -bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id) -{ - return FALSE; -} - -// Radio box item -wxRadioBox::wxRadioBox() +size_t wxRadioBox::GetCount() const { + return m_radios.GetCount(); } bool wxRadioBox::Create(wxWindow *parent, @@ -172,7 +129,64 @@ bool wxRadioBox::Create(wxWindow *parent, const wxValidator& val, const wxString& name) { - return false; + // initialize members + 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; + const bool use_cols = style & wxRA_SPECIFY_COLS; + + // get default size and position for the initial placement + m_size = size; + m_pos = pos; + int minor = n / GetMajorDim(); + if(n % GetMajorDim() > 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 ( int j = 0; j < minor; j++ ) + { + for ( 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++; + } + } + } } bool wxRadioBox::Create(wxWindow *parent, @@ -186,15 +200,86 @@ bool wxRadioBox::Create(wxWindow *parent, const wxValidator& val, const wxString& name) { - return false; + wxCArrayString chs(choices); + + return Create( parent, id, title, pos, size, chs.GetCount(), + chs.GetStrings(), majorDim, style, val, name ); } wxRadioBox::~wxRadioBox() { } +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 size_t n = GetCount(); + size_t minor = n / GetMajorDim(); + if(n % GetMajorDim() > 0) + minor++; + + size_t i = 0; + for ( int j = 0; j < minor; j++ ) + { + for ( 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(int item, const wxString& label) { + wxRadioButton *btn = GetRadioButton(item); + if(btn) + btn->SetLabel(label); } void wxRadioBox::SetSelection(int N) @@ -210,9 +295,10 @@ int wxRadioBox::GetSelection() const // Find string for position wxString wxRadioBox::GetString(int item) const { - wxString ret; - - return ret; + wxRadioButton *btn = GetRadioButton(item); + if(btn) + return btn->GetLabel(); + return wxEmptyString; } // ---------------------------------------------------------------------------- @@ -234,54 +320,71 @@ 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::GetSize(int *width, int *height) const +// Enable all subcontrols +bool wxRadioBox::Enable(bool enable) { + for(size_t i=0; iEnable(enable); + return false; } -void wxRadioBox::SetFocus() +bool wxRadioBox::Show(bool show) { + for(size_t i=0; iShow(show); + RefreshRect(btn->GetRect()); + return ret; + } return false; } -// Enable a specific button -void wxRadioBox::Enable(int item, bool enable) +wxString wxRadioBox::GetLabel() { + return m_label; } -// Enable all controls -bool wxRadioBox::Enable(bool enable) +void wxRadioBox::SetLabel(const wxString& label) { - return false; + m_label = label; } -// Show a specific button -void wxRadioBox::Show(int item, bool show) +void wxRadioBox::Refresh(bool eraseBack, const wxRect *rect) { -} + wxRect area = GetRect(); -bool wxRadioBox::ContainsHWND(WXHWND hWnd) const -{ - return false; -} + if(rect) + { + area.Offset(rect->GetPosition()); + area.SetSize(rect->GetSize()); + } -void wxRadioBox::Command(wxCommandEvent & event) -{ + GetParent()->RefreshRect(area); } -void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn) +void wxRadioBox::Command(wxCommandEvent & event) { } @@ -294,28 +397,4 @@ bool wxRadioBox::SetFont(const wxFont& font) return false; } -// ---------------------------------------------------------------------------- -// our window proc -// ---------------------------------------------------------------------------- - -WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) -{ - return 0; -} - -WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), -#if wxUSE_CTL3D - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam -#else - WXUINT WXUNUSED(message), - WXWPARAM WXUNUSED(wParam), - WXLPARAM WXUNUSED(lParam) -#endif - ) -{ - return (WXHBRUSH)0; -} - #endif // wxUSE_RADIOBOX