Consistent wxWindow::Enable with wxRadioBox::Enable for control and its items. wxRadioBox of PalmOS. Little source cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-02-21 21:02:41 +00:00
parent 1814658d67
commit 1a87edf286
24 changed files with 381 additions and 268 deletions

View File

@@ -2,6 +2,14 @@
wxWidgets 2.5 Change Log - For more verbose changes, see the manual wxWidgets 2.5 Change Log - For more verbose changes, see the manual
------------------------------------------------------------------- -------------------------------------------------------------------
2.5.5
-----
wxPalmOS:
- native wxRadioBox implementation
2.5.4 2.5.4
----- -----

View File

@@ -129,11 +129,11 @@ for further details.
\membersection{wxRadioBox::Enable}\label{wxradioboxenable} \membersection{wxRadioBox::Enable}\label{wxradioboxenable}
\func{void}{Enable}{\param{bool}{ enable = {\tt true}}} \func{virtual bool}{Enable}{\param{bool}{ enable = {\tt true}}}
Enables or disables the entire radiobox. Enables or disables the entire radiobox.
\func{void}{Enable}{\param{int}{ n}, \param{bool}{ enable = {\tt true}}} \func{virtual bool}{Enable}{\param{int}{ n}, \param{bool}{ enable = {\tt true}}}
Enables or disables an individual button in the radiobox. Enables or disables an individual button in the radiobox.
@@ -152,6 +152,10 @@ individual button in the radiobox.}
\end{twocollist}} \end{twocollist}}
} }
\wxheading{See also}
\helpref{wxWindow::Enable}{wxwindowenable}
\membersection{wxRadioBox::FindString}\label{wxradioboxfindstring} \membersection{wxRadioBox::FindString}\label{wxradioboxfindstring}

View File

@@ -6,7 +6,7 @@
// Created: 2003/03/18 // Created: 2003/03/18
// RCS-ID: $Id: // RCS-ID: $Id:
// Copyright: (c) 2003 David Elliott // Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_RADIOBOX_H__ #ifndef __WX_COCOA_RADIOBOX_H__
@@ -89,8 +89,8 @@ public:
virtual wxString GetString(int n) const; virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label); virtual void SetString(int n, const wxString& label);
// change the individual radio button state // change the individual radio button state
virtual void Enable(int n, bool enable = TRUE); virtual bool Enable(int n, bool enable = true);
virtual void Show(int n, bool show = TRUE); virtual void Show(int n, bool show = true);
// layout parameters // layout parameters
virtual int GetColumnCount() const; virtual int GetColumnCount() const;
virtual int GetRowCount() const; virtual int GetRowCount() const;

View File

@@ -88,7 +88,7 @@ public:
void SetString( int n, const wxString& label ); void SetString( int n, const wxString& label );
void Show( int item, bool show ); void Show( int item, bool show );
void Enable( int item, bool enable ); virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const; virtual wxString GetStringSelection() const;
virtual bool SetStringSelection( const wxString& s ); virtual bool SetStringSelection( const wxString& s );

View File

@@ -88,7 +88,7 @@ public:
void SetString( int n, const wxString& label ); void SetString( int n, const wxString& label );
void Show( int item, bool show ); void Show( int item, bool show );
void Enable( int item, bool enable ); virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const; virtual wxString GetStringSelection() const;
virtual bool SetStringSelection( const wxString& s ); virtual bool SetStringSelection( const wxString& s );

View File

@@ -67,19 +67,19 @@ public:
virtual wxString GetString(int item) const; virtual wxString GetString(int item) const;
virtual void SetString(int item, const wxString& label) ; virtual void SetString(int item, const wxString& label) ;
virtual void Enable(int item, bool enable); virtual bool Enable(int item, bool enable = true);
virtual void Show(int item, bool show) ; virtual void Show(int item, bool show) ;
virtual int GetColumnCount() const ; virtual int GetColumnCount() const ;
virtual int GetRowCount() const ; virtual int GetRowCount() const ;
virtual bool Enable(bool enable = TRUE); virtual bool Enable(bool enable = true);
virtual wxString GetLabel() const; virtual wxString GetLabel() const;
virtual void SetLabel(const wxString& label) ; virtual void SetLabel(const wxString& label) ;
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = true);
// Other external functions // Other external functions
void Command(wxCommandEvent& event); void Command(wxCommandEvent& event);
void SetFocus(); void SetFocus();
@@ -95,7 +95,7 @@ protected:
int m_noItems; int m_noItems;
int m_noRowsOrCols; int m_noRowsOrCols;
// Internal functions // Internal functions
virtual wxSize DoGetBestSize() const ; virtual wxSize DoGetBestSize() const ;
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,

View File

@@ -67,19 +67,18 @@ public:
virtual wxString GetString(int item) const; virtual wxString GetString(int item) const;
virtual void SetString(int item, const wxString& label) ; virtual void SetString(int item, const wxString& label) ;
virtual void Enable(int item, bool enable); virtual bool Enable(int item, bool enable = true);
virtual void Show(int item, bool show) ; virtual void Show(int item, bool show) ;
virtual int GetColumnCount() const ; virtual int GetColumnCount() const ;
virtual int GetRowCount() const ; virtual int GetRowCount() const ;
virtual bool Enable(bool enable = true);
virtual bool Enable(bool enable = TRUE);
virtual wxString GetLabel() const; virtual wxString GetLabel() const;
virtual void SetLabel(const wxString& label) ; virtual void SetLabel(const wxString& label) ;
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = true);
// Other external functions // Other external functions
void Command(wxCommandEvent& event); void Command(wxCommandEvent& event);
void SetFocus(); void SetFocus();
@@ -95,7 +94,7 @@ protected:
int m_noItems; int m_noItems;
int m_noRowsOrCols; int m_noRowsOrCols;
// Internal functions // Internal functions
virtual wxSize DoGetBestSize() const ; virtual wxSize DoGetBestSize() const ;
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,

View File

@@ -83,7 +83,7 @@ public:
void SetString(int item, const wxString& label) ; void SetString(int item, const wxString& label) ;
wxString GetString(int item) const; wxString GetString(int item) const;
virtual bool Enable(bool enable = true); virtual bool Enable(bool enable = true);
void Enable(int item, bool enable); virtual bool Enable(int item, bool enable = true);
void Show(int item, bool show) ; void Show(int item, bool show) ;
virtual bool Show(bool show = true) ; virtual bool Show(bool show = true) ;
@@ -123,7 +123,6 @@ protected:
private: private:
void Init(); void Init();
DECLARE_DYNAMIC_CLASS(wxRadioBox) DECLARE_DYNAMIC_CLASS(wxRadioBox)
}; };

View File

@@ -92,7 +92,7 @@ public:
virtual int GetCount() const; virtual int GetCount() const;
virtual wxString GetString(int n) const; virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label); virtual void SetString(int n, const wxString& label);
virtual void Enable(int n, bool enable = true); virtual bool Enable(int n, bool enable = true);
virtual void Show(int n, bool show = true); virtual void Show(int n, bool show = true);
virtual int GetColumnCount() const { return GetNumHor(); } virtual int GetColumnCount() const { return GetNumHor(); }
virtual int GetRowCount() const { return GetNumVer(); } virtual int GetRowCount() const { return GetNumVer(); }

View File

@@ -101,10 +101,8 @@ public:
void Command(wxCommandEvent& rEvent); void Command(wxCommandEvent& rEvent);
bool ContainsHWND(WXHWND hWnd) const; bool ContainsHWND(WXHWND hWnd) const;
virtual bool Enable(bool bEnable = TRUE); virtual bool Enable(bool bEnable = true);
void Enable( int nItem virtual bool Enable(int nItem, bool bEnable = true);
,bool bEnable
);
int FindString(const wxString& sStr) const; int FindString(const wxString& sStr) const;
virtual WXHBRUSH OnCtlColor( WXHDC hDC virtual WXHBRUSH OnCtlColor( WXHDC hDC
@@ -119,7 +117,7 @@ public:
); );
void SendNotificationEvent(void); void SendNotificationEvent(void);
virtual void Show( int nItem virtual void Show( int nItem
,bool bShow = TRUE ,bool bShow = true
) ; ) ;
bool Show(bool bShow); bool Show(bool bShow);
MRESULT WindowProc( WXUINT uMsg MRESULT WindowProc( WXUINT uMsg

View File

@@ -17,6 +17,7 @@
#endif #endif
class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxRadioButton;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRadioBox // wxRadioBox
@@ -25,7 +26,10 @@ class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxRadioBox : public wxControl, public wxRadioBoxBase class WXDLLEXPORT wxRadioBox : public wxControl, public wxRadioBoxBase
{ {
public: public:
wxRadioBox(); wxRadioBox():m_radios(wxKEY_INTEGER,32)
{
Init();
}
wxRadioBox(wxWindow *parent, wxRadioBox(wxWindow *parent,
wxWindowID id, wxWindowID id,
@@ -37,10 +41,13 @@ public:
long style = wxRA_SPECIFY_COLS, long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator, const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr) const wxString& name = wxRadioBoxNameStr)
:m_radios(wxKEY_INTEGER,n+1)
{ {
Init();
(void)Create(parent, id, title, pos, size, n, choices, majorDim, (void)Create(parent, id, title, pos, size, n, choices, majorDim,
style, val, name); style, val, name);
} }
wxRadioBox(wxWindow *parent, wxRadioBox(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -51,7 +58,9 @@ public:
long style = wxRA_SPECIFY_COLS, long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator, const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr) const wxString& name = wxRadioBoxNameStr)
:m_radios(wxKEY_INTEGER,choices.GetCount()+1)
{ {
Init();
(void)Create(parent, id, title, pos, size, choices, majorDim, (void)Create(parent, id, title, pos, size, choices, majorDim,
style, val, name); style, val, name);
} }
@@ -86,11 +95,17 @@ public:
virtual int GetCount() const; virtual int GetCount() const;
virtual wxString GetString(int n) const; virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label); virtual void SetString(int n, const wxString& label);
virtual void Enable(int n, bool enable = true); virtual bool Enable(int n, bool enable = true);
virtual void Show(int n, bool show = true); virtual void Show(int n, bool show = true);
virtual int GetColumnCount() const; virtual int GetColumnCount() const;
virtual int GetRowCount() 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);
virtual wxPoint GetClientAreaOrigin() const;
virtual bool Show(bool show = true); virtual bool Show(bool show = true);
void SetFocus(); void SetFocus();
virtual bool Enable(bool enable = true); virtual bool Enable(bool enable = true);
@@ -134,12 +149,17 @@ protected:
int m_noRowsOrCols; int m_noRowsOrCols;
int m_selectedButton; int m_selectedButton;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
private: private:
void Init();
wxRadioButton *GetRadioButton(int i);
wxPoint m_pos;
wxSize m_size;
wxHashTable m_radios;
DECLARE_DYNAMIC_CLASS(wxRadioBox) DECLARE_DYNAMIC_CLASS(wxRadioBox)
DECLARE_NO_COPY_CLASS(wxRadioBox) DECLARE_NO_COPY_CLASS(wxRadioBox)
}; };

View File

@@ -32,7 +32,7 @@ class WXDLLEXPORT wxRadioBoxBase : public wxItemContainerImmutable
{ {
public: public:
// change the individual radio button state // change the individual radio button state
virtual void Enable(int n, bool enable = true) = 0; virtual bool Enable(int n, bool enable = true) = 0;
virtual void Show(int n, bool show = true) = 0; virtual void Show(int n, bool show = true) = 0;
// layout parameters // layout parameters

View File

@@ -95,7 +95,7 @@ public:
virtual wxString GetString(int n) const; virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label); virtual void SetString(int n, const wxString& label);
virtual void Enable(int n, bool enable = true); virtual bool Enable(int n, bool enable = true);
virtual void Show(int n, bool show = true); virtual void Show(int n, bool show = true);
// we also override the wxControl methods to avoid virtual function hiding // we also override the wxControl methods to avoid virtual function hiding

View File

@@ -4,9 +4,9 @@
// Author: David Elliott // Author: David Elliott
// Modified by: // Modified by:
// Created: 2003/02/15 // Created: 2003/02/15
// RCS-ID: $Id: // RCS-ID: $Id:
// Copyright: (c) 2003 David Elliott // Copyright: (c) 2003 David Elliott
// Licence: wxWidgets licence // Licence: wxWidgets licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -91,8 +91,10 @@ void wxRadioBox::SetString(int n, const wxString& label)
} }
// change the individual radio button state // change the individual radio button state
void wxRadioBox::Enable(int n, bool enable) bool wxRadioBox::Enable(int n, bool enable)
{ {
// TODO
return false;
} }
void wxRadioBox::Show(int n, bool show) void wxRadioBox::Show(int n, bool show)

View File

@@ -517,11 +517,11 @@ int wxRadioBox::GetSelection(void) const
wxString wxRadioBox::GetString( int n ) const wxString wxRadioBox::GetString( int n ) const
{ {
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( n ); wxList::compatibility_iterator node = m_boxes.Item( n );
wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") ); wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
@@ -575,19 +575,21 @@ bool wxRadioBox::Enable( bool enable )
return true; return true;
} }
void wxRadioBox::Enable( int item, bool enable ) bool wxRadioBox::Enable( int item, bool enable )
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( item ); wxList::compatibility_iterator node = m_boxes.Item( item );
wxCHECK_RET( node, wxT("radiobox wrong index") ); wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->GetData() ); GtkButton *button = GTK_BUTTON( node->GetData() );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) ); GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable ); gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
return true;
} }
void wxRadioBox::Show( int item, bool show ) void wxRadioBox::Show( int item, bool show )
@@ -608,7 +610,7 @@ void wxRadioBox::Show( int item, bool show )
wxString wxRadioBox::GetStringSelection() const wxString wxRadioBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.GetFirst(); wxList::compatibility_iterator node = m_boxes.GetFirst();
while (node) while (node)
@@ -629,7 +631,7 @@ wxString wxRadioBox::GetStringSelection() const
} }
wxFAIL_MSG( wxT("wxRadioBox none selected") ); wxFAIL_MSG( wxT("wxRadioBox none selected") );
return wxT(""); return wxEmptyString;
} }
bool wxRadioBox::SetStringSelection( const wxString &s ) bool wxRadioBox::SetStringSelection( const wxString &s )

View File

@@ -517,11 +517,11 @@ int wxRadioBox::GetSelection(void) const
wxString wxRadioBox::GetString( int n ) const wxString wxRadioBox::GetString( int n ) const
{ {
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( n ); wxList::compatibility_iterator node = m_boxes.Item( n );
wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") ); wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
@@ -575,19 +575,21 @@ bool wxRadioBox::Enable( bool enable )
return true; return true;
} }
void wxRadioBox::Enable( int item, bool enable ) bool wxRadioBox::Enable( int item, bool enable )
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( item ); wxList::compatibility_iterator node = m_boxes.Item( item );
wxCHECK_RET( node, wxT("radiobox wrong index") ); wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->GetData() ); GtkButton *button = GTK_BUTTON( node->GetData() );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) ); GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable ); gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
return true;
} }
void wxRadioBox::Show( int item, bool show ) void wxRadioBox::Show( int item, bool show )
@@ -608,7 +610,7 @@ void wxRadioBox::Show( int item, bool show )
wxString wxRadioBox::GetStringSelection() const wxString wxRadioBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.GetFirst(); wxList::compatibility_iterator node = m_boxes.GetFirst();
while (node) while (node)
@@ -629,7 +631,7 @@ wxString wxRadioBox::GetStringSelection() const
} }
wxFAIL_MSG( wxT("wxRadioBox none selected") ); wxFAIL_MSG( wxT("wxRadioBox none selected") );
return wxT(""); return wxEmptyString;
} }
bool wxRadioBox::SetStringSelection( const wxString &s ) bool wxRadioBox::SetStringSelection( const wxString &s )

View File

@@ -62,8 +62,8 @@ wxRadioBox::wxRadioBox()
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, // <20> wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&,
// const wxSize&, int, const wxString[], int, long, // const wxSize&, int, const wxString[], int, long,
// const wxValidator&, const wxString&) // const wxValidator&, const wxString&)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Contructor, creating and showing a radiobox // Contructor, creating and showing a radiobox
@@ -78,10 +78,10 @@ wxRadioBox::wxRadioBox()
wxRadioBox::~wxRadioBox() wxRadioBox::~wxRadioBox()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = true;
wxRadioButton *next,*current; wxRadioButton *next,*current;
current=m_radioButtonCycle->NextInCycle(); current=m_radioButtonCycle->NextInCycle();
next=current->NextInCycle(); next=current->NextInCycle();
while (current!=m_radioButtonCycle) { while (current!=m_radioButtonCycle) {
@@ -89,7 +89,7 @@ wxRadioBox::~wxRadioBox()
current=next; current=next;
next=current->NextInCycle(); next=current->NextInCycle();
} }
delete current; delete current;
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -115,23 +115,23 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
int majorDim, long style, int majorDim, long style,
const wxValidator& val, const wxString& name) const wxValidator& val, const wxString& name)
{ {
m_macIsUserPane = FALSE ; m_macIsUserPane = false ;
if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
return false; return false;
int i; int i;
m_noItems = n; m_noItems = n;
m_noRowsOrCols = majorDim; m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL; m_radioButtonCycle = NULL;
if (majorDim==0) if (majorDim==0)
m_majorDim = n ; m_majorDim = n ;
else else
m_majorDim = majorDim ; m_majorDim = majorDim ;
m_label = label ; m_label = label ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
@@ -139,12 +139,12 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
bounds.right = bounds.left + 100 ; bounds.right = bounds.left + 100 ;
if ( bounds.bottom <= bounds.top ) if ( bounds.bottom <= bounds.top )
bounds.bottom = bounds.top + 100 ; bounds.bottom = bounds.top + 100 ;
m_peer = new wxMacControl() ; m_peer = new wxMacControl() ;
verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
wxRadioButton *radBtn = new wxRadioButton wxRadioButton *radBtn = new wxRadioButton
@@ -160,11 +160,11 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_radioButtonCycle = radBtn ; m_radioButtonCycle = radBtn ;
// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);
} }
SetSelection(0); SetSelection(0);
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
return TRUE; return true;
} }
@@ -177,10 +177,10 @@ bool wxRadioBox::Enable(bool enable)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if (!wxControl::Enable(enable)) if (!wxControl::Enable(enable))
return false; return false;
current = m_radioButtonCycle; current = m_radioButtonCycle;
for (i = 0; i < m_noItems; i++) { for (i = 0; i < m_noItems; i++) {
current->Enable(enable); current->Enable(enable);
@@ -194,21 +194,21 @@ bool wxRadioBox::Enable(bool enable)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Enables or disables an given button // Enables or disables an given button
void wxRadioBox::Enable(int item, bool enable) bool wxRadioBox::Enable(int item, bool enable)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return false;
i = 0; i = 0;
current = m_radioButtonCycle; current = m_radioButtonCycle;
while (i != item) { while (i != item) {
i++; i++;
current = current->NextInCycle(); current = current->NextInCycle();
} }
current->Enable(enable); return current->Enable(enable);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -230,10 +230,10 @@ wxString wxRadioBox::GetString(int item) const
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return wxEmptyString; return wxEmptyString;
i = 0; i = 0;
current = m_radioButtonCycle; current = m_radioButtonCycle;
while (i != item) { while (i != item) {
@@ -252,14 +252,14 @@ int wxRadioBox::GetSelection() const
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
i=0; i=0;
current=m_radioButtonCycle; current=m_radioButtonCycle;
while (!current->GetValue()) { while (!current->GetValue()) {
i++; i++;
current=current->NextInCycle(); current=current->NextInCycle();
} }
return i; return i;
} }
@@ -290,7 +290,7 @@ void wxRadioBox::SetString(int item,const wxString& label)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -305,14 +305,14 @@ void wxRadioBox::SetString(int item,const wxString& label)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> SetSelection // <20> SetSelection
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Sets a button by passing the desired position. This does not cause // Sets a button by passing the desired position. This does not cause
// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted // wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted
void wxRadioBox::SetSelection(int item) void wxRadioBox::SetSelection(int item)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -322,21 +322,21 @@ void wxRadioBox::SetSelection(int item)
current=current->NextInCycle(); current=current->NextInCycle();
} }
current->SetValue(true); current->SetValue(true);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> Show(bool) // <20> Show(bool)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Shows or hides the entire radiobox // Shows or hides the entire radiobox
bool wxRadioBox::Show(bool show) bool wxRadioBox::Show(bool show)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
wxControl::Show(show); wxControl::Show(show);
current=m_radioButtonCycle; current=m_radioButtonCycle;
for (i=0;i<m_noItems;i++) { for (i=0;i<m_noItems;i++) {
current->Show(show); current->Show(show);
@@ -348,13 +348,13 @@ bool wxRadioBox::Show(bool show)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> Show(int, bool) // <20> Show(int, bool)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Shows or hides the given button // Shows or hides the given button
void wxRadioBox::Show(int item, bool show) void wxRadioBox::Show(int item, bool show)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -386,7 +386,7 @@ void wxRadioBox::SetFocus()
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
i=0; i=0;
current=m_radioButtonCycle; current=m_radioButtonCycle;
while (!current->GetValue()) { while (!current->GetValue()) {
@@ -408,14 +408,14 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
// define the position // define the position
int x_current, y_current; int x_current, y_current;
int x_offset,y_offset; int x_offset,y_offset;
int widthOld, heightOld; int widthOld, heightOld;
GetSize(&widthOld, &heightOld); GetSize(&widthOld, &heightOld);
x_offset = x; x_offset = x;
y_offset = y; y_offset = y;
GetPosition(&x_current, &y_current); GetPosition(&x_current, &y_current);
@@ -423,18 +423,18 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
x_offset = x_current; x_offset = x_current;
if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
y_offset = y_current; y_offset = y_current;
// define size // define size
int charWidth,charHeight; int charWidth,charHeight;
int maxWidth,maxHeight; int maxWidth,maxHeight;
int eachWidth[128],eachHeight[128]; int eachWidth[128],eachHeight[128];
int totWidth,totHeight; int totWidth,totHeight;
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
charWidth/=52; charWidth/=52;
maxWidth=-1; maxWidth=-1;
maxHeight=-1; maxHeight=-1;
for (i = 0 ; i < m_noItems; i++) for (i = 0 ; i < m_noItems; i++)
@@ -445,12 +445,12 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i]; if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i];
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i]; if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
} }
totHeight = GetRowCount() * ( maxHeight ) ; totHeight = GetRowCount() * ( maxHeight ) ;
totWidth = GetColumnCount() * (maxWidth + charWidth) ; totWidth = GetColumnCount() * (maxWidth + charWidth) ;
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ; wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
// only change our width/height if asked for // only change our width/height if asked for
if ( width == -1 ) if ( width == -1 )
{ {
@@ -459,7 +459,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else else
width = widthOld; width = widthOld;
} }
if ( height == -1 ) if ( height == -1 )
{ {
if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
@@ -467,21 +467,21 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else else
height = heightOld; height = heightOld;
} }
wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO); wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
// arrange radiobuttons // arrange radiobuttons
int x_start,y_start; int x_start,y_start;
x_start = 0; x_start = 0;
y_start = 0 ; y_start = 0 ;
x_offset = x_start; x_offset = x_start;
y_offset = y_start; y_offset = y_start;
current=m_radioButtonCycle; current=m_radioButtonCycle;
for ( i = 0 ; i < m_noItems; i++) for ( i = 0 ; i < m_noItems; i++)
{ {
if (i&&((i%m_majorDim)==0)) // not to do for the zero button! if (i&&((i%m_majorDim)==0)) // not to do for the zero button!
@@ -497,10 +497,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
y_offset += maxHeight ; /*+ charHeight/2;*/ y_offset += maxHeight ; /*+ charHeight/2;*/
} }
} }
current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]);
current=current->NextInCycle(); current=current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS) if (m_windowStyle & wxRA_SPECIFY_ROWS)
y_offset += maxHeight ; /*+ charHeight/2;*/ y_offset += maxHeight ; /*+ charHeight/2;*/
else else
@@ -514,16 +514,16 @@ wxSize wxRadioBox::DoGetBestSize() const
int maxWidth, maxHeight; int maxWidth, maxHeight;
int eachWidth, eachHeight; int eachWidth, eachHeight;
int totWidth, totHeight; int totWidth, totHeight;
wxFont font = /*GetParent()->*/GetFont(); wxFont font = /*GetParent()->*/GetFont();
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight, NULL, NULL, &font); &charWidth, &charHeight, NULL, NULL, &font);
charWidth /= 52; charWidth /= 52;
maxWidth = -1; maxWidth = -1;
maxHeight = -1; maxHeight = -1;
for (int i = 0 ; i < m_noItems; i++) for (int i = 0 ; i < m_noItems; i++)
{ {
GetTextExtent(GetString(i), &eachWidth, &eachHeight,NULL, NULL, &font); GetTextExtent(GetString(i), &eachWidth, &eachHeight,NULL, NULL, &font);
@@ -532,20 +532,20 @@ wxSize wxRadioBox::DoGetBestSize() const
if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxWidth < eachWidth) maxWidth = eachWidth;
if (maxHeight < eachHeight) maxHeight = eachHeight; if (maxHeight < eachHeight) maxHeight = eachHeight;
} }
totHeight = GetRowCount() * (maxHeight ) ; totHeight = GetRowCount() * (maxHeight ) ;
totWidth = GetColumnCount() * (maxWidth + charWidth) ; totWidth = GetColumnCount() * (maxWidth + charWidth) ;
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ; wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
totWidth = sz.x ; totWidth = sz.x ;
totHeight = sz.y ; totHeight = sz.y ;
// handle radio box title as well // handle radio box title as well
GetTextExtent(GetTitle(), &eachWidth, NULL); GetTextExtent(GetTitle(), &eachWidth, NULL);
eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ; eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;
if (totWidth < eachWidth) if (totWidth < eachWidth)
totWidth = eachWidth; totWidth = eachWidth;
return wxSize(totWidth, totHeight); return wxSize(totWidth, totHeight);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -583,6 +583,3 @@ int wxRadioBox::GetColumnCount() const
} }
#endif #endif

View File

@@ -59,8 +59,8 @@ wxRadioBox::wxRadioBox()
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, // <20> wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&,
// const wxSize&, int, const wxString[], int, long, // const wxSize&, int, const wxString[], int, long,
// const wxValidator&, const wxString&) // const wxValidator&, const wxString&)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Contructor, creating and showing a radiobox // Contructor, creating and showing a radiobox
@@ -75,10 +75,10 @@ wxRadioBox::wxRadioBox()
wxRadioBox::~wxRadioBox() wxRadioBox::~wxRadioBox()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = true;
wxRadioButton *next,*current; wxRadioButton *next,*current;
current=m_radioButtonCycle->NextInCycle(); current=m_radioButtonCycle->NextInCycle();
next=current->NextInCycle(); next=current->NextInCycle();
while (current!=m_radioButtonCycle) { while (current!=m_radioButtonCycle) {
@@ -86,7 +86,7 @@ wxRadioBox::~wxRadioBox()
current=next; current=next;
next=current->NextInCycle(); next=current->NextInCycle();
} }
delete current; delete current;
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -116,25 +116,24 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
return false; return false;
int i; int i;
m_noItems = n; m_noItems = n;
m_noRowsOrCols = majorDim; m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL; m_radioButtonCycle = NULL;
if (majorDim==0) if (majorDim==0)
m_majorDim = n ; m_majorDim = n ;
else else
m_majorDim = majorDim ; m_majorDim = majorDim ;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlGroupBoxTextTitleProc , (long) this ) ; kControlGroupBoxTextTitleProc , (long) this ) ;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
wxRadioButton *radBtn = new wxRadioButton wxRadioButton *radBtn = new wxRadioButton
@@ -150,11 +149,11 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_radioButtonCycle = radBtn ; m_radioButtonCycle = radBtn ;
// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);
} }
SetSelection(0); SetSelection(0);
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
@@ -167,10 +166,10 @@ bool wxRadioBox::Enable(bool enable)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if (!wxControl::Enable(enable)) if (!wxControl::Enable(enable))
return false; return false;
current = m_radioButtonCycle; current = m_radioButtonCycle;
for (i = 0; i < m_noItems; i++) { for (i = 0; i < m_noItems; i++) {
current->Enable(enable); current->Enable(enable);
@@ -184,21 +183,21 @@ bool wxRadioBox::Enable(bool enable)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Enables or disables an given button // Enables or disables an given button
void wxRadioBox::Enable(int item, bool enable) bool wxRadioBox::Enable(int item, bool enable)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return false;
i = 0; i = 0;
current = m_radioButtonCycle; current = m_radioButtonCycle;
while (i != item) { while (i != item) {
i++; i++;
current = current->NextInCycle(); current = current->NextInCycle();
} }
current->Enable(enable); return current->Enable(enable);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -220,10 +219,10 @@ wxString wxRadioBox::GetString(int item) const
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return wxEmptyString; return wxEmptyString;
i = 0; i = 0;
current = m_radioButtonCycle; current = m_radioButtonCycle;
while (i != item) { while (i != item) {
@@ -242,14 +241,14 @@ int wxRadioBox::GetSelection() const
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
i=0; i=0;
current=m_radioButtonCycle; current=m_radioButtonCycle;
while (!current->GetValue()) { while (!current->GetValue()) {
i++; i++;
current=current->NextInCycle(); current=current->NextInCycle();
} }
return i; return i;
} }
@@ -280,7 +279,7 @@ void wxRadioBox::SetString(int item,const wxString& label)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -295,14 +294,14 @@ void wxRadioBox::SetString(int item,const wxString& label)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> SetSelection // <20> SetSelection
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Sets a button by passing the desired position. This does not cause // Sets a button by passing the desired position. This does not cause
// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted // wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted
void wxRadioBox::SetSelection(int item) void wxRadioBox::SetSelection(int item)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -312,21 +311,21 @@ void wxRadioBox::SetSelection(int item)
current=current->NextInCycle(); current=current->NextInCycle();
} }
current->SetValue(true); current->SetValue(true);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> Show(bool) // <20> Show(bool)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Shows or hides the entire radiobox // Shows or hides the entire radiobox
bool wxRadioBox::Show(bool show) bool wxRadioBox::Show(bool show)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
wxControl::Show(show); wxControl::Show(show);
current=m_radioButtonCycle; current=m_radioButtonCycle;
for (i=0;i<m_noItems;i++) { for (i=0;i<m_noItems;i++) {
current->Show(show); current->Show(show);
@@ -338,13 +337,13 @@ bool wxRadioBox::Show(bool show)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// <20> Show(int, bool) // <20> Show(int, bool)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Shows or hides the given button // Shows or hides the given button
void wxRadioBox::Show(int item, bool show) void wxRadioBox::Show(int item, bool show)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
if ((item < 0) || (item >= m_noItems)) if ((item < 0) || (item >= m_noItems))
return; return;
i=0; i=0;
@@ -376,7 +375,7 @@ void wxRadioBox::SetFocus()
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
i=0; i=0;
current=m_radioButtonCycle; current=m_radioButtonCycle;
while (!current->GetValue()) { while (!current->GetValue()) {
@@ -398,14 +397,14 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
int i; int i;
wxRadioButton *current; wxRadioButton *current;
// define the position // define the position
int x_current, y_current; int x_current, y_current;
int x_offset,y_offset; int x_offset,y_offset;
int widthOld, heightOld; int widthOld, heightOld;
GetSize(&widthOld, &heightOld); GetSize(&widthOld, &heightOld);
x_offset = x; x_offset = x;
y_offset = y; y_offset = y;
GetPosition(&x_current, &y_current); GetPosition(&x_current, &y_current);
@@ -413,18 +412,18 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
x_offset = x_current; x_offset = x_current;
if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
y_offset = y_current; y_offset = y_current;
// define size // define size
int charWidth,charHeight; int charWidth,charHeight;
int maxWidth,maxHeight; int maxWidth,maxHeight;
int eachWidth[128],eachHeight[128]; int eachWidth[128],eachHeight[128];
int totWidth,totHeight; int totWidth,totHeight;
SetFont(GetParent()->GetFont()); SetFont(GetParent()->GetFont());
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
charWidth/=52; charWidth/=52;
maxWidth=-1; maxWidth=-1;
maxHeight=-1; maxHeight=-1;
for (i = 0 ; i < m_noItems; i++) for (i = 0 ; i < m_noItems; i++)
@@ -435,10 +434,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i]; if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i];
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i]; if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
} }
totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ; totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
// only change our width/height if asked for // only change our width/height if asked for
if ( width == -1 ) if ( width == -1 )
{ {
@@ -447,7 +446,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else else
width = widthOld; width = widthOld;
} }
if ( height == -1 ) if ( height == -1 )
{ {
if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
@@ -455,25 +454,25 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else else
height = heightOld; height = heightOld;
} }
wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO); wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
// arrange radiobuttons // arrange radiobuttons
int x_start,y_start; int x_start,y_start;
x_start = charWidth; x_start = charWidth;
y_start = 15 ; y_start = 15 ;
if ( UMAGetSystemVersion() >= 0x1030 ) if ( UMAGetSystemVersion() >= 0x1030 )
{ {
//need to add a few more pixels for the top border on panther //need to add a few more pixels for the top border on panther
y_start = y_start + 5; //how many exactly should this be to meet the HIG? y_start = y_start + 5; //how many exactly should this be to meet the HIG?
} }
x_offset = x_start; x_offset = x_start;
y_offset = y_start; y_offset = y_start;
current=m_radioButtonCycle; current=m_radioButtonCycle;
for ( i = 0 ; i < m_noItems; i++) for ( i = 0 ; i < m_noItems; i++)
{ {
if (i&&((i%m_majorDim)==0)) // not to do for the zero button! if (i&&((i%m_majorDim)==0)) // not to do for the zero button!
@@ -489,10 +488,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
y_offset += maxHeight ; /*+ charHeight/2;*/ y_offset += maxHeight ; /*+ charHeight/2;*/
} }
} }
current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]);
current=current->NextInCycle(); current=current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS) if (m_windowStyle & wxRA_SPECIFY_ROWS)
y_offset += maxHeight ; /*+ charHeight/2;*/ y_offset += maxHeight ; /*+ charHeight/2;*/
else else
@@ -506,15 +505,15 @@ wxSize wxRadioBox::DoGetBestSize() const
int maxWidth, maxHeight; int maxWidth, maxHeight;
int eachWidth, eachHeight; int eachWidth, eachHeight;
int totWidth, totHeight; int totWidth, totHeight;
wxFont font = GetParent()->GetFont(); wxFont font = GetParent()->GetFont();
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight, NULL, NULL, &font); &charWidth, &charHeight, NULL, NULL, &font);
charWidth /= 52; charWidth /= 52;
maxWidth = -1; maxWidth = -1;
maxHeight = -1; maxHeight = -1;
for (int i = 0 ; i < m_noItems; i++) for (int i = 0 ; i < m_noItems; i++)
{ {
GetTextExtent(GetString(i), &eachWidth, &eachHeight); GetTextExtent(GetString(i), &eachWidth, &eachHeight);
@@ -523,10 +522,10 @@ wxSize wxRadioBox::DoGetBestSize() const
if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxWidth < eachWidth) maxWidth = eachWidth;
if (maxHeight < eachHeight) maxHeight = eachHeight; if (maxHeight < eachHeight) maxHeight = eachHeight;
} }
totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ; totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
if ( UMAGetSystemVersion() >= 0x1030 ) if ( UMAGetSystemVersion() >= 0x1030 )
{ {
//need to add a few more pixels for the static boxborder on panther //need to add a few more pixels for the static boxborder on panther
@@ -535,9 +534,9 @@ wxSize wxRadioBox::DoGetBestSize() const
// handle radio box title as well // handle radio box title as well
GetTextExtent(GetTitle(), &eachWidth, NULL); GetTextExtent(GetTitle(), &eachWidth, NULL);
eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ; eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;
if (totWidth < eachWidth) if (totWidth < eachWidth)
totWidth = eachWidth; totWidth = eachWidth;
return wxSize(totWidth, totHeight); return wxSize(totWidth, totHeight);
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -573,8 +572,3 @@ int wxRadioBox::GetColumnCount() const
return m_majorDim; return m_majorDim;
} }
} }

View File

@@ -84,7 +84,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget)); WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget));
if (label1 != "") if (!label1.empty())
{ {
wxXmString text(label1); wxXmString text(label1);
m_labelWidget = (WXWidget) m_labelWidget = (WXWidget)
@@ -94,7 +94,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
: xmLabelGadgetClass, : xmLabelGadgetClass,
(Widget)m_mainWidget, (Widget)m_mainWidget,
#else #else
xmLabelWidgetClass, xmLabelWidgetClass,
(Widget)m_mainWidget, (Widget)m_mainWidget,
#endif #endif
wxFont::GetFontTag(), fontType, wxFont::GetFontTag(), fontType,
@@ -107,7 +107,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
#else #else
XmNchildType, XmFRAME_TITLE_CHILD, XmNchildType, XmFRAME_TITLE_CHILD,
#endif #endif
XmNchildVerticalAlignment, XmNchildVerticalAlignment,
XmALIGNMENT_CENTER, XmALIGNMENT_CENTER,
NULL); NULL);
} }
@@ -149,7 +149,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
ChangeFont(false); ChangeFont(false);
SetSelection (0); SetSelection (0);
XtRealizeWidget((Widget)m_mainWidget); XtRealizeWidget((Widget)m_mainWidget);
XtManageChild (radioBoxWidget); XtManageChild (radioBoxWidget);
XtManageChild ((Widget)m_mainWidget); XtManageChild ((Widget)m_mainWidget);
@@ -186,7 +186,7 @@ void wxRadioBox::SetString(int item, const wxString& label)
return; return;
Widget widget = (Widget) m_radioButtons[item]; Widget widget = (Widget) m_radioButtons[item];
if (label != "") if (!label.empty())
{ {
wxString label1(wxStripMenuCodes(label)); wxString label1(wxStripMenuCodes(label));
wxXmString text( label1 ); wxXmString text( label1 );
@@ -253,7 +253,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_mainWidget, XmNx, xx, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNx, xx, NULL);
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_mainWidget, XmNy, yy, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNy, yy, NULL);
if (width > 0) if (width > 0)
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width, NULL);
@@ -265,12 +265,13 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
} }
// Enable a specific button // Enable a specific button
void wxRadioBox::Enable(int n, bool enable) bool wxRadioBox::Enable(int n, bool enable)
{ {
if ((n < 0) || (n >= m_noItems)) if ((n < 0) || (n >= m_noItems))
return; return false;
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable); XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
return true;
} }
// Enable all controls // Enable all controls
@@ -299,9 +300,9 @@ void wxRadioBox::Show(int n, bool show)
// It's main purpose isn't for allowing Show/Unshow dynamically, // It's main purpose isn't for allowing Show/Unshow dynamically,
// but rather to provide a way to design wxRadioBox such: // but rather to provide a way to design wxRadioBox such:
// //
// o Val1 o Val2 o Val3 // o Val1 o Val2 o Val3
// o Val4 o Val6 // o Val4 o Val6
// o Val7 o Val8 o Val9 // o Val7 o Val8 o Val9
// //
// In my case, this is a 'direction' box, and the Show(5,False) is // In my case, this is a 'direction' box, and the Show(5,False) is
// coupled with an Enable(5,False) // coupled with an Enable(5,False)
@@ -328,7 +329,7 @@ wxString wxRadioBox::GetStringSelection () const
if (sel > -1) if (sel > -1)
return this->GetString (sel); return this->GetString (sel);
else else
return wxString(""); return wxEmptyString;
} }
bool wxRadioBox::SetStringSelection (const wxString& s) bool wxRadioBox::SetStringSelection (const wxString& s)

View File

@@ -408,12 +408,13 @@ void wxRadioBox::SetFocus()
} }
// Enable a specific button // Enable a specific button
void wxRadioBox::Enable(int item, bool enable) bool wxRadioBox::Enable(int item, bool enable)
{ {
wxCHECK_RET( item >= 0 && item < GetCount(), wxCHECK_MSG( item >= 0 && item < GetCount(), false,
wxT("invalid item in wxRadioBox::Enable()") ); wxT("invalid item in wxRadioBox::Enable()") );
::EnableWindow((*m_radioButtons)[item], enable); ::EnableWindow((*m_radioButtons)[item], enable);
return true;
} }
// Show a specific button // Show a specific button
@@ -477,7 +478,7 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
int width = GetNumHor() * (sizeBtn.x + cx1) + cx1; int width = GetNumHor() * (sizeBtn.x + cx1) + cx1;
// Add extra space under the label, if it exists. // Add extra space under the label, if it exists.
if (!wxControl::GetLabel().IsEmpty()) if (!wxControl::GetLabel().empty())
height += cy1/2; height += cy1/2;
// and also wide enough for its label // and also wide enough for its label
@@ -561,7 +562,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
y_offset += cy1; y_offset += cy1;
// Add extra space under the label, if it exists. // Add extra space under the label, if it exists.
if (!wxControl::GetLabel().IsEmpty()) if (!wxControl::GetLabel().empty())
y_offset += cy1/2; y_offset += cy1/2;
int startX = x_offset; int startX = x_offset;

View File

@@ -75,7 +75,7 @@ wxRadioBox::wxRadioBox()
wxRadioBox::~wxRadioBox() wxRadioBox::~wxRadioBox()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = true;
if (m_ahRadioButtons) if (m_ahRadioButtons)
{ {
@@ -247,9 +247,9 @@ bool wxRadioBox::ContainsHWND(
for (i = 0; i < nCount; i++) for (i = 0; i < nCount; i++)
{ {
if (GetRadioButtons()[i] == hWnd) if (GetRadioButtons()[i] == hWnd)
return TRUE; return true;
} }
return FALSE; return false;
} // end of wxRadioBox::ContainsHWND } // end of wxRadioBox::ContainsHWND
bool wxRadioBox::Create( bool wxRadioBox::Create(
@@ -307,14 +307,14 @@ bool wxRadioBox::Create(
,rVal ,rVal
,rsName ,rsName
)) ))
return FALSE; return false;
if (!OS2CreateControl( "STATIC" if (!OS2CreateControl( "STATIC"
,SS_GROUPBOX ,SS_GROUPBOX
,rPos ,rPos
,rSize ,rSize
,rsTitle ,rsTitle
)) ))
return FALSE; return false;
wxAssociateWinWithHandle(m_hWnd, this); wxAssociateWinWithHandle(m_hWnd, this);
@@ -363,7 +363,7 @@ bool wxRadioBox::Create(
); );
if (!hWndBtn) if (!hWndBtn)
{ {
return FALSE; return false;
} }
m_ahRadioButtons[i] = (WXHWND)hWndBtn; m_ahRadioButtons[i] = (WXHWND)hWndBtn;
SubclassRadioButton((WXHWND)hWndBtn); SubclassRadioButton((WXHWND)hWndBtn);
@@ -425,7 +425,7 @@ bool wxRadioBox::Create(
,rSize.x ,rSize.x
,rSize.y ,rSize.y
); );
return TRUE; return true;
} // end of wxRadioBox::Create } // end of wxRadioBox::Create
wxSize wxRadioBox::DoGetBestSize() const wxSize wxRadioBox::DoGetBestSize() const
@@ -669,15 +669,13 @@ void wxRadioBox::DoSetSize(
} }
} // end of wxRadioBox::DoSetSize } // end of wxRadioBox::DoSetSize
void wxRadioBox::Enable( bool wxRadioBox::Enable(int nItem, bool bEnable)
int nItem
, bool bEnable
)
{ {
wxCHECK_RET( nItem >= 0 && nItem < m_nNoItems, wxCHECK_MSG( nItem >= 0 && nItem < m_nNoItems, false,
wxT("invalid item in wxRadioBox::Enable()") ); wxT("invalid item in wxRadioBox::Enable()") );
::WinEnableWindow((HWND) m_ahRadioButtons[nItem], bEnable); ::WinEnableWindow((HWND) m_ahRadioButtons[nItem], bEnable);
return true;
} // end of wxRadioBox::Enable } // end of wxRadioBox::Enable
bool wxRadioBox::Enable( bool wxRadioBox::Enable(
@@ -685,10 +683,10 @@ bool wxRadioBox::Enable(
) )
{ {
if ( !wxControl::Enable(bEnable) ) if ( !wxControl::Enable(bEnable) )
return FALSE; return false;
for (int i = 0; i < m_nNoItems; i++) for (int i = 0; i < m_nNoItems; i++)
::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable); ::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable);
return TRUE; return true;
} // end of wxRadioBox::Enable } // end of wxRadioBox::Enable
int wxRadioBox::FindString( int wxRadioBox::FindString(
@@ -717,7 +715,7 @@ wxString wxRadioBox::GetLabel(
int nItem int nItem
) const ) const
{ {
wxCHECK_MSG(nItem >= 0 && nItem < m_nNoItems, wxT(""), wxT("invalid radiobox index") ); wxCHECK_MSG(nItem >= 0 && nItem < m_nNoItems, wxEmptyString, wxT("invalid radiobox index") );
return wxGetWindowText(m_ahRadioButtons[nItem]); return wxGetWindowText(m_ahRadioButtons[nItem]);
} // end of wxRadioBox::GetLabel } // end of wxRadioBox::GetLabel
@@ -972,7 +970,7 @@ bool wxRadioBox::OS2Command(
if (uCmd == BN_CLICKED) if (uCmd == BN_CLICKED)
{ {
if (wId == GetId()) if (wId == GetId())
return TRUE; return true;
for (int i = 0; i < m_nNoItems; i++) for (int i = 0; i < m_nNoItems; i++)
@@ -988,17 +986,17 @@ bool wxRadioBox::OS2Command(
// //
// Just ignore it // Just ignore it
// //
return FALSE; return false;
} }
if (nSelectedButton != m_nSelectedButton) if (nSelectedButton != m_nSelectedButton)
{ {
m_nSelectedButton = nSelectedButton; m_nSelectedButton = nSelectedButton;
SendNotificationEvent(); SendNotificationEvent();
} }
return TRUE; return true;
} }
else else
return FALSE; return false;
} // end of wxRadioBox::OS2Command } // end of wxRadioBox::OS2Command
void wxRadioBox::SendNotificationEvent() void wxRadioBox::SendNotificationEvent()
@@ -1033,7 +1031,7 @@ bool wxRadioBox::SetFont(
// //
// Nothing to do // Nothing to do
// //
return FALSE; return false;
} }
// //
// Also set the font of our radio buttons // Also set the font of our radio buttons
@@ -1047,7 +1045,7 @@ bool wxRadioBox::SetFont(
); );
::WinInvalidateRect(hWndBtn, NULL, FALSE); ::WinInvalidateRect(hWndBtn, NULL, FALSE);
} }
return TRUE; return true;
} // end of wxRadioBox::SetFont } // end of wxRadioBox::SetFont
void wxRadioBox::SetSelection( void wxRadioBox::SetSelection(
@@ -1084,10 +1082,10 @@ bool wxRadioBox::SetStringSelection(
if (nSel > -1) if (nSel > -1)
{ {
SetSelection(nSel); SetSelection(nSel);
return TRUE; return true;
} }
else else
return FALSE; return false;
} // end of wxRadioBox::SetStringSelection } // end of wxRadioBox::SetStringSelection
bool wxRadioBox::Show( bool wxRadioBox::Show(
@@ -1095,13 +1093,13 @@ bool wxRadioBox::Show(
) )
{ {
if (!wxControl::Show(bShow)) if (!wxControl::Show(bShow))
return FALSE; return false;
for (int i = 0; i < m_nNoItems; i++) for (int i = 0; i < m_nNoItems; i++)
{ {
::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow); ::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow);
} }
return TRUE; return true;
} // end of wxRadioBox::Show } // end of wxRadioBox::Show
// Show a specific button // Show a specific button
@@ -1160,7 +1158,7 @@ MRESULT wxRadioBtnWndProc(
,QWL_USER ,QWL_USER
); );
USHORT uVk = SHORT2FROMMP((MPARAM)lParam); USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
bool bProcessed = TRUE; bool bProcessed = true;
wxDirection eDir; wxDirection eDir;
switch(uVk) switch(uVk)
@@ -1182,7 +1180,7 @@ MRESULT wxRadioBtnWndProc(
break; break;
default: default:
bProcessed = FALSE; bProcessed = false;
// //
// Just to suppress the compiler warning // Just to suppress the compiler warning

View File

@@ -332,7 +332,7 @@ void wxControl::DoMoveWindow(int x, int y, int width, int height)
bool wxControl::Enable(bool enable) bool wxControl::Enable(bool enable)
{ {
ControlType *control = (ControlType *)GetObjectPtr(); ControlType *control = (ControlType *)GetObjectPtr();
if( (IsPalmControl()) || (control == NULL)) if( !IsPalmControl() || (control == NULL))
return false; return false;
if( CtlEnabled(control) == enable) if( CtlEnabled(control) == enable)
return false; return false;
@@ -343,7 +343,7 @@ bool wxControl::Enable(bool enable)
bool wxControl::IsEnabled() const bool wxControl::IsEnabled() const
{ {
ControlType *control = (ControlType *)GetObjectPtr(); ControlType *control = (ControlType *)GetObjectPtr();
if( (IsPalmControl()) || (control == NULL)) if( !IsPalmControl() || (control == NULL))
return false; return false;
return CtlEnabled(control); return CtlEnabled(control);
} }

View File

@@ -110,9 +110,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
// wxRadioBox // wxRadioBox
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void wxRadioBox::Init()
{
m_pos = wxPoint(0,0);
m_size = wxSize(0,0);
}
int wxRadioBox::GetCount() const int wxRadioBox::GetCount() const
{ {
return 0; return m_radios.GetCount();
} }
int wxRadioBox::GetColumnCount() const int wxRadioBox::GetColumnCount() const
@@ -137,11 +143,6 @@ int wxRadioBox::GetNumHor() const
return 0; return 0;
} }
// Radio box item
wxRadioBox::wxRadioBox()
{
}
bool wxRadioBox::Create(wxWindow *parent, bool wxRadioBox::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -155,27 +156,58 @@ bool wxRadioBox::Create(wxWindow *parent,
const wxString& name) const wxString& name)
{ {
// initialize members // initialize members
m_majorDim = majorDim == 0 ? n : majorDim; m_majorDim = majorDim == 0 ? n : wxMin(majorDim, n);
if(m_majorDim==0 || n==0) return false;
if(!wxControl::Create(parent, id, pos, size, style, val, name)) // 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 / m_majorDim;
if(n % m_majorDim > 0) minor++;
if(m_size.x==wxDefaultCoord)
m_size.x=36*(use_cols?m_majorDim:minor);
if(m_size.y==wxDefaultCoord)
m_size.y=12*(use_cols?minor:m_majorDim);
if(m_pos.x==wxDefaultCoord)
m_pos.x=0;
if(m_pos.y==wxDefaultCoord)
m_pos.y=0;
if(!wxControl::Create(parent, id, m_pos, m_size, style, val, name))
return false; return false;
for(int i=0; i<n; i++) int i = 0;
for ( int j = 0; j < minor; j++ )
{ {
wxRadioButton* rb = new wxRadioButton(); for ( int k = 0; k < m_majorDim; k++ )
rb->SetGroup( id ); {
rb->Create( if(i<n)
this, {
wxID_ANY, wxPoint start, end;
choices[i], start.x = (use_cols ? (k*m_size.x)/m_majorDim : (j*m_size.x)/minor);
pos, start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/m_majorDim);
size, end.x = (use_cols ? ((k+1)*m_size.x)/m_majorDim : ((j+1)*m_size.x)/minor);
( n == 0 ? wxRB_GROUP : 0 ) | end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/m_majorDim);
( style & wxRA_USE_CHECKBOX ) ? wxRB_USE_CHECKBOX : 0 wxRadioButton* rb = new wxRadioButton();
); rb->SetGroup( 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, bool wxRadioBox::Create(wxWindow *parent,
@@ -199,6 +231,61 @@ wxRadioBox::~wxRadioBox()
{ {
} }
wxRadioButton *wxRadioBox::GetRadioButton(int i)
{
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)
{
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++;
int i = 0;
for ( int j = 0; j < minor; j++ )
{
for ( int k = 0; k < m_majorDim; 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);
wxRadioButton* rb = GetRadioButton(i);
if(rb)
rb->SetSize(end.x-start.x-1,end.y-start.y-1);
i++;
}
}
}
}
// get the origin of the client area in the client coordinates
wxPoint wxRadioBox::GetClientAreaOrigin() const
{
return GetParent()->GetClientAreaOrigin() + GetPosition();
}
void wxRadioBox::SetString(int item, const wxString& label) void wxRadioBox::SetString(int item, const wxString& label)
{ {
} }
@@ -240,11 +327,6 @@ wxSize wxRadioBox::DoGetBestSize() const
return wxSize(0,0); 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()
{ {
} }
@@ -255,14 +337,20 @@ bool wxRadioBox::Show(bool show)
} }
// Enable a specific button // Enable a specific button
void wxRadioBox::Enable(int item, bool enable) bool wxRadioBox::Enable(int item, bool enable)
{ {
wxRadioButton *btn = GetRadioButton(item);
if(btn)
return btn->Enable(enable);
return false;
} }
// Enable all controls // Enable all subcontrols
bool wxRadioBox::Enable(bool enable) bool wxRadioBox::Enable(bool enable)
{ {
return false; for(int i=0; i<GetCount(); i++)
Enable(i, enable);
return true;
} }
// Show a specific button // Show a specific button

View File

@@ -322,11 +322,11 @@ void wxRadioBox::SetString(int n, const wxString& label)
m_buttons[n]->SetLabel(label); m_buttons[n]->SetLabel(label);
} }
void wxRadioBox::Enable(int n, bool enable) bool wxRadioBox::Enable(int n, bool enable)
{ {
wxCHECK_RET( IsValid(n), _T("invalid index in wxRadioBox::Enable") ); wxCHECK_MSG( IsValid(n), false, _T("invalid index in wxRadioBox::Enable") );
m_buttons[n]->Enable(enable); return m_buttons[n]->Enable(enable);
} }
void wxRadioBox::Show(int n, bool show) void wxRadioBox::Show(int n, bool show)