2001-06-26 17:05:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Program: wxWindows Widgets Sample
|
|
|
|
// Name: radiobox.cpp
|
|
|
|
// Purpose: Part of the widgets sample showing wxRadioBox
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 15.04.01
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 2001 Vadim Zeitlin
|
|
|
|
// License: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// for compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/log.h"
|
|
|
|
|
2003-03-23 10:12:41 -05:00
|
|
|
#include "wx/bitmap.h"
|
2001-06-26 17:05:06 -04:00
|
|
|
#include "wx/button.h"
|
|
|
|
#include "wx/checkbox.h"
|
|
|
|
#include "wx/radiobox.h"
|
|
|
|
#include "wx/statbox.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/sizer.h"
|
|
|
|
|
|
|
|
#include "widgets.h"
|
2002-04-09 06:31:37 -04:00
|
|
|
#if 1
|
2001-06-26 17:05:06 -04:00
|
|
|
#include "icons/radiobox.xpm"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// control ids
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
RadioPage_Reset = 100,
|
|
|
|
RadioPage_Update,
|
|
|
|
RadioPage_Selection,
|
|
|
|
RadioPage_Label,
|
|
|
|
RadioPage_LabelBtn,
|
|
|
|
RadioPage_Radio
|
|
|
|
};
|
|
|
|
|
|
|
|
// layout direction radiobox selections
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
RadioDir_Default,
|
|
|
|
RadioDir_LtoR,
|
|
|
|
RadioDir_TtoB
|
|
|
|
};
|
|
|
|
|
|
|
|
// default values for the number of radiobox items
|
2002-09-08 14:11:02 -04:00
|
|
|
static const unsigned int DEFAULT_NUM_ENTRIES = 12;
|
|
|
|
static const unsigned int DEFAULT_MAJOR_DIM = 3;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// RadioWidgetsPage
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class RadioWidgetsPage : public WidgetsPage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RadioWidgetsPage(wxNotebook *notebook, wxImageList *imaglist);
|
|
|
|
virtual ~RadioWidgetsPage();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// event handlers
|
|
|
|
void OnCheckOrRadioBox(wxCommandEvent& event);
|
|
|
|
void OnRadioBox(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnButtonReset(wxCommandEvent& event);
|
|
|
|
void OnButtonRecreate(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnButtonSelection(wxCommandEvent& event);
|
|
|
|
void OnButtonSetLabel(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnUpdateUIReset(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUIUpdate(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUISelection(wxUpdateUIEvent& event);
|
|
|
|
|
|
|
|
// reset the wxRadioBox parameters
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
// (re)create the wxRadioBox
|
|
|
|
void CreateRadio();
|
|
|
|
|
|
|
|
// the controls
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
// the check/radio boxes for styles
|
|
|
|
wxCheckBox *m_chkVert;
|
|
|
|
wxRadioBox *m_radioDir;
|
|
|
|
|
|
|
|
// the gauge itself and the sizer it is in
|
|
|
|
wxRadioBox *m_radio;
|
|
|
|
wxSizer *m_sizerRadio;
|
|
|
|
|
|
|
|
// the text entries for command parameters
|
|
|
|
wxTextCtrl *m_textNumBtns,
|
|
|
|
*m_textMajorDim,
|
|
|
|
*m_textCurSel,
|
|
|
|
*m_textSel,
|
|
|
|
*m_textLabel,
|
|
|
|
*m_textLabelBtns;
|
|
|
|
|
|
|
|
private:
|
2001-11-25 10:18:38 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_WIDGETS_PAGE(RadioWidgetsPage)
|
2001-06-26 17:05:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event tables
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(RadioWidgetsPage, WidgetsPage)
|
|
|
|
EVT_BUTTON(RadioPage_Reset, RadioWidgetsPage::OnButtonReset)
|
|
|
|
|
|
|
|
EVT_BUTTON(RadioPage_Update, RadioWidgetsPage::OnButtonRecreate)
|
|
|
|
EVT_BUTTON(RadioPage_LabelBtn, RadioWidgetsPage::OnButtonRecreate)
|
|
|
|
|
|
|
|
EVT_BUTTON(RadioPage_Selection, RadioWidgetsPage::OnButtonSelection)
|
|
|
|
EVT_BUTTON(RadioPage_Label, RadioWidgetsPage::OnButtonSetLabel)
|
|
|
|
|
|
|
|
EVT_UPDATE_UI(RadioPage_Update, RadioWidgetsPage::OnUpdateUIUpdate)
|
|
|
|
EVT_UPDATE_UI(RadioPage_Selection, RadioWidgetsPage::OnUpdateUISelection)
|
|
|
|
|
|
|
|
EVT_RADIOBOX(RadioPage_Radio, RadioWidgetsPage::OnRadioBox)
|
|
|
|
|
2003-12-11 05:32:15 -05:00
|
|
|
EVT_CHECKBOX(wxID_ANY, RadioWidgetsPage::OnCheckOrRadioBox)
|
|
|
|
EVT_RADIOBOX(wxID_ANY, RadioWidgetsPage::OnCheckOrRadioBox)
|
2001-06-26 17:05:06 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
IMPLEMENT_WIDGETS_PAGE(RadioWidgetsPage, _T("Radio"));
|
|
|
|
|
|
|
|
RadioWidgetsPage::RadioWidgetsPage(wxNotebook *notebook,
|
|
|
|
wxImageList *imaglist)
|
|
|
|
: WidgetsPage(notebook)
|
|
|
|
{
|
|
|
|
imaglist->Add(wxBitmap(radio_xpm));
|
|
|
|
|
|
|
|
// init everything
|
|
|
|
m_chkVert = (wxCheckBox *)NULL;
|
|
|
|
|
|
|
|
m_textNumBtns =
|
|
|
|
m_textLabelBtns =
|
|
|
|
m_textLabel = (wxTextCtrl *)NULL;
|
|
|
|
|
|
|
|
m_radio =
|
|
|
|
m_radioDir = (wxRadioBox *)NULL;
|
|
|
|
m_sizerRadio = (wxSizer *)NULL;
|
|
|
|
|
|
|
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
|
|
|
// left pane
|
2003-12-11 05:32:15 -05:00
|
|
|
wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
|
|
|
|
|
|
|
|
m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Vertical layout"));
|
|
|
|
|
|
|
|
static const wxString layoutDir[] =
|
|
|
|
{
|
|
|
|
_T("default"),
|
|
|
|
_T("left to right"),
|
|
|
|
_T("top to bottom")
|
|
|
|
};
|
|
|
|
|
2003-12-11 05:32:15 -05:00
|
|
|
m_radioDir = new wxRadioBox(this, wxID_ANY, _T("Numbering:"),
|
2001-06-26 17:05:06 -04:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2002-04-09 06:31:37 -04:00
|
|
|
WXSIZEOF(layoutDir), layoutDir,
|
|
|
|
1, wxRA_SPECIFY_COLS);
|
2001-06-26 17:05:06 -04:00
|
|
|
sizerLeft->Add(m_radioDir, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
// if it's not defined, we can't change the radiobox direction
|
|
|
|
#ifndef wxRA_LEFTTORIGHT
|
|
|
|
m_radioDir->Disable();
|
|
|
|
#endif // wxRA_LEFTTORIGHT
|
|
|
|
|
|
|
|
wxSizer *sizerRow;
|
2002-04-09 06:31:37 -04:00
|
|
|
sizerRow = CreateSizerWithTextAndLabel(_T("&Major dimension:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textMajorDim);
|
|
|
|
sizerLeft->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
2002-04-09 06:31:37 -04:00
|
|
|
sizerRow = CreateSizerWithTextAndLabel(_T("&Number of buttons:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textNumBtns);
|
|
|
|
sizerLeft->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
wxButton *btn;
|
|
|
|
btn = new wxButton(this, RadioPage_Update, _T("&Update"));
|
|
|
|
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 5);
|
|
|
|
|
|
|
|
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
|
|
|
|
|
|
|
btn = new wxButton(this, RadioPage_Reset, _T("&Reset"));
|
|
|
|
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
|
|
|
|
|
|
|
|
// middle pane
|
2003-12-11 05:32:15 -05:00
|
|
|
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, _T("&Change parameters"));
|
2001-06-26 17:05:06 -04:00
|
|
|
wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
|
|
|
|
|
2002-04-09 06:31:37 -04:00
|
|
|
sizerRow = CreateSizerWithTextAndLabel(_T("Current selection:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textCurSel);
|
|
|
|
sizerMiddle->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(RadioPage_Selection,
|
2002-04-09 06:31:37 -04:00
|
|
|
_T("&Change selection:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textSel);
|
|
|
|
sizerMiddle->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(RadioPage_Label,
|
2002-04-09 06:31:37 -04:00
|
|
|
_T("&Label for box:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textLabel);
|
|
|
|
sizerMiddle->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(RadioPage_LabelBtn,
|
2002-04-09 06:31:37 -04:00
|
|
|
_T("&Label for buttons:"),
|
2003-12-11 05:32:15 -05:00
|
|
|
wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
&m_textLabelBtns);
|
|
|
|
sizerMiddle->Add(sizerRow, 0, wxGROW | wxALL, 5);
|
|
|
|
|
|
|
|
// right pane
|
|
|
|
wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
|
2002-04-09 06:31:37 -04:00
|
|
|
sizerRight->SetMinSize(150, 0);
|
2001-06-26 17:05:06 -04:00
|
|
|
m_sizerRadio = sizerRight; // save it to modify it later
|
|
|
|
|
|
|
|
Reset();
|
|
|
|
CreateRadio();
|
|
|
|
|
|
|
|
// the 3 panes panes compose the window
|
|
|
|
sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
|
|
|
|
sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10);
|
2002-04-09 06:31:37 -04:00
|
|
|
sizerTop->Add(sizerRight, 0, wxGROW | (wxALL & ~wxRIGHT), 10);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// final initializations
|
|
|
|
SetSizer(sizerTop);
|
|
|
|
|
|
|
|
sizerTop->Fit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioWidgetsPage::~RadioWidgetsPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// operations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioWidgetsPage::Reset()
|
|
|
|
{
|
2002-09-08 14:11:02 -04:00
|
|
|
m_textMajorDim->SetValue(wxString::Format(_T("%u"), DEFAULT_MAJOR_DIM));
|
|
|
|
m_textNumBtns->SetValue(wxString::Format(_T("%u"), DEFAULT_NUM_ENTRIES));
|
2001-06-26 17:05:06 -04:00
|
|
|
m_textLabel->SetValue(_T("I'm a radiobox"));
|
|
|
|
m_textLabelBtns->SetValue(_T("item"));
|
|
|
|
|
2003-12-11 05:32:15 -05:00
|
|
|
m_chkVert->SetValue(false);
|
2001-06-26 17:05:06 -04:00
|
|
|
m_radioDir->SetSelection(RadioDir_Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::CreateRadio()
|
|
|
|
{
|
|
|
|
int sel;
|
|
|
|
if ( m_radio )
|
|
|
|
{
|
|
|
|
sel = m_radio->GetSelection();
|
|
|
|
|
Deprecated wxSizer::Remove( wxWindow* ), s/Remove/Detach/ in most places.
Made wxSizer child list typesafe. I've not added the wxList implicit
conversion kludge yet, let's see who complains first perhaps..
Deprecated wxSizer::{G,S}etOption in favour of {G,S}etProportion in line
with the parameter name change in the docs.
Added {G,S}etSpacer consistent with the accessors for windows/sizers.
Made all wxSizer index parameters size_t -- we support no sensible
interpretation for negative indexes in them. Hopefully this will
cause no real problems, but code doing (eg. Remove( 0 )) will need
to change to use 0u to resolve the ambiguity with overloaded members.
This is probably a Good Thing though, ymmv.
s/FALSE/false/g ; s/TRUE/true/g ; s/wxASSERT/wxASSERT_MSG/g in sizer.{cpp,h}
Fixed (I hope) the brokenness in wxSizer::Show -- I have no code to test
this yet, so it's a blind change, but spacers should now be hidden correctly
instead of ignored, and it should be properly reversable over multiple
calls now too.
removed pointless private scoping around DECLARE_CLASS macros.
Replace 0's I added previously with NULL -- not like that will end the
email thread either..
Added Add( wxSizerItem * ) & co. There are probably a couple of other
places we can usefully do something like this too. Stopped short of
refactoring everything to raise some issues about sizer method recursion
on -dev.
Updated wxSizer docs some more, they are still incomplete but getting
better.
wrapped KeyCode in wxDEPRECATED, converted all (gtk build) instances
to GetKeyCode. There may be a few left for other ports.
Fixed a couple of other random compile warnings along the way.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-01-07 05:22:07 -05:00
|
|
|
m_sizerRadio->Detach( m_radio );
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
delete m_radio;
|
|
|
|
}
|
|
|
|
else // first time creation, no old selection to preserve
|
|
|
|
{
|
|
|
|
sel = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long count;
|
|
|
|
if ( !m_textNumBtns->GetValue().ToULong(&count) )
|
|
|
|
{
|
|
|
|
wxLogWarning(_T("Should have a valid number for number of items."));
|
|
|
|
|
|
|
|
// fall back to default
|
|
|
|
count = DEFAULT_NUM_ENTRIES;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long majorDim;
|
|
|
|
if ( !m_textMajorDim->GetValue().ToULong(&majorDim) )
|
|
|
|
{
|
|
|
|
wxLogWarning(_T("Should have a valid major dimension number."));
|
|
|
|
|
|
|
|
// fall back to default
|
|
|
|
majorDim = DEFAULT_MAJOR_DIM;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString *items = new wxString[count];
|
|
|
|
|
|
|
|
wxString labelBtn = m_textLabelBtns->GetValue();
|
|
|
|
for ( size_t n = 0; n < count; n++ )
|
|
|
|
{
|
2002-09-08 14:11:02 -04:00
|
|
|
items[n] = wxString::Format(_T("%s %lu"),
|
|
|
|
labelBtn.c_str(), (unsigned long)n + 1);
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int flags = m_chkVert->GetValue() ? wxRA_VERTICAL
|
|
|
|
: wxRA_HORIZONTAL;
|
|
|
|
|
|
|
|
#ifdef wxRA_LEFTTORIGHT
|
|
|
|
switch ( m_radioDir->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( _T("unexpected wxRadioBox layout direction") );
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case RadioDir_Default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RadioDir_LtoR:
|
|
|
|
flags |= wxRA_LEFTTORIGHT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RadioDir_TtoB:
|
|
|
|
flags |= wxRA_TOPTOBOTTOM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif // wxRA_LEFTTORIGHT
|
|
|
|
|
|
|
|
m_radio = new wxRadioBox(this, RadioPage_Radio,
|
|
|
|
m_textLabel->GetValue(),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
count, items,
|
|
|
|
majorDim,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
delete [] items;
|
|
|
|
|
|
|
|
if ( sel >= 0 && (size_t)sel < count )
|
|
|
|
{
|
|
|
|
m_radio->SetSelection(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sizerRadio->Add(m_radio, 1, wxGROW);
|
|
|
|
m_sizerRadio->Layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event handlers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
|
|
|
|
CreateRadio();
|
|
|
|
}
|
|
|
|
|
2003-07-31 09:59:28 -04:00
|
|
|
void RadioWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
|
|
|
CreateRadio();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnRadioBox(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int sel = m_radio->GetSelection();
|
2003-12-11 06:25:46 -05:00
|
|
|
int event_sel = event.GetSelection();
|
|
|
|
wxUnusedVar(event_sel);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
wxLogMessage(_T("Radiobox selection changed, now %d"), sel);
|
|
|
|
|
2003-12-11 06:25:46 -05:00
|
|
|
wxASSERT_MSG( sel == event_sel,
|
2001-06-26 17:05:06 -04:00
|
|
|
_T("selection should be the same in event and radiobox") );
|
|
|
|
|
|
|
|
m_textCurSel->SetValue(wxString::Format(_T("%d"), sel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnButtonRecreate(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
CreateRadio();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnButtonSetLabel(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_radio->wxControl::SetLabel(m_textLabel->GetValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnButtonSelection(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
unsigned long sel;
|
|
|
|
if ( !m_textSel->GetValue().ToULong(&sel) ||
|
|
|
|
(sel >= (size_t)m_radio->GetCount()) )
|
|
|
|
{
|
|
|
|
wxLogWarning(_T("Invalid number specified as new selection."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_radio->SetSelection(sel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnUpdateUIUpdate(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
unsigned long n;
|
|
|
|
event.Enable( m_textNumBtns->GetValue().ToULong(&n) &&
|
|
|
|
m_textMajorDim->GetValue().ToULong(&n) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnUpdateUISelection(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
unsigned long n;
|
|
|
|
event.Enable( m_textSel->GetValue().ToULong(&n) &&
|
|
|
|
(n < (size_t)m_radio->GetCount()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioWidgetsPage::OnUpdateUIReset(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
// only enable it if something is not set to default
|
|
|
|
bool enable = m_chkVert->GetValue();
|
|
|
|
|
|
|
|
if ( !enable )
|
|
|
|
{
|
|
|
|
unsigned long numEntries;
|
|
|
|
|
|
|
|
enable = !m_textNumBtns->GetValue().ToULong(&numEntries) ||
|
|
|
|
numEntries != DEFAULT_NUM_ENTRIES;
|
|
|
|
|
|
|
|
if ( !enable )
|
|
|
|
{
|
|
|
|
unsigned long majorDim;
|
|
|
|
|
|
|
|
enable = !m_textMajorDim->GetValue().ToULong(&majorDim) ||
|
|
|
|
majorDim != DEFAULT_MAJOR_DIM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Enable(enable);
|
|
|
|
}
|
|
|
|
|
2002-08-01 15:12:24 -04:00
|
|
|
#endif
|