const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrl"));
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrlGTKBase"));
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
double min = 0, double max = 100, double initial = 0, double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"));
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"));
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxTE_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
events. Using this style will prevent the user from using the Enter key
for dialog navigation (e.g. activating the default button in the
dialog) under MSW.
+ @style{wxTE_LEFT}
+ Same as for wxTextCtrl: the text is left aligned.
+ @style{wxTE_CENTER}
+ Same as for wxTextCtrl: the text is centered.
+ @style{wxTE_RIGHT}
+ Same as for wxTextCtrl: the text is right aligned (this is the
+ default).
@endStyleTable
SpinBtnPage_SpinCtrlDouble
};
+// alignment radiobox values
+enum
+{
+ Align_Left,
+ Align_Centre,
+ Align_Right
+};
+
// ----------------------------------------------------------------------------
// SpinBtnWidgetsPage
// ----------------------------------------------------------------------------
*m_chkArrowKeys,
*m_chkWrap,
*m_chkProcessEnter;
+ wxRadioBox *m_radioAlign;
// the spinbtn and the spinctrl and the sizer containing them
wxSpinButton *m_spinbtn;
m_chkArrowKeys = NULL;
m_chkWrap = NULL;
m_chkProcessEnter = NULL;
+ m_radioAlign = NULL;
m_spinbtn = NULL;
m_spinctrl = NULL;
m_spinctrldbl = NULL;
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
+ static const wxString halign[] =
+ {
+ _T("left"),
+ _T("centre"),
+ _T("right"),
+ };
+
+ m_radioAlign = new wxRadioBox(this, wxID_ANY, _T("&Text alignment"),
+ wxDefaultPosition, wxDefaultSize,
+ WXSIZEOF(halign), halign, 1);
+
+ sizerLeft->Add(m_radioAlign, 0, wxGROW | wxALL, 5);
+
+ sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
+
wxButton *btn = new wxButton(this, SpinBtnPage_Reset, _T("&Reset"));
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
m_chkArrowKeys->SetValue(true);
m_chkWrap->SetValue(false);
m_chkProcessEnter->SetValue(false);
+ m_radioAlign->SetSelection(Align_Right);
}
void SpinBtnWidgetsPage::CreateSpin()
if ( m_chkProcessEnter->GetValue() )
flags |= wxTE_PROCESS_ENTER;
+ int textFlags = 0;
+ switch ( m_radioAlign->GetSelection() )
+ {
+ default:
+ wxFAIL_MSG(_T("unexpected radiobox selection"));
+ // fall through
+
+ case Align_Left:
+ textFlags |= wxALIGN_LEFT; // no-op
+ break;
+
+ case Align_Centre:
+ textFlags |= wxALIGN_CENTRE_HORIZONTAL;
+ break;
+
+ case Align_Right:
+ textFlags |= wxALIGN_RIGHT;
+ break;
+ }
+
int val = m_min;
if ( m_spinbtn )
{
m_spinctrl = new wxSpinCtrl(this, SpinBtnPage_SpinCtrl,
wxString::Format(_T("%d"), val),
wxDefaultPosition, wxDefaultSize,
- flags,
+ flags | textFlags,
m_min, m_max, val);
m_spinctrldbl = new wxSpinCtrlDouble(this, SpinBtnPage_SpinCtrlDouble,
wxString::Format(_T("%d"), val),
wxDefaultPosition, wxDefaultSize,
- flags,
+ flags | textFlags,
m_min, m_max, val, 0.1);
// Add spacers, labels and spin controls to the sizer.
class wxSpinCtrlTextGeneric : public wxTextCtrl
{
public:
- wxSpinCtrlTextGeneric(wxSpinCtrlGenericBase *spin, const wxString& value)
- : wxTextCtrl(spin->GetParent(), wxID_ANY, value, wxDefaultPosition,
- wxDefaultSize, wxTE_NOHIDESEL|wxTE_PROCESS_ENTER)
+ wxSpinCtrlTextGeneric(wxSpinCtrlGenericBase *spin, const wxString& value, long style=0)
+ : wxTextCtrl(spin->GetParent(), wxID_ANY, value, wxDefaultPosition, wxDefaultSize,
+ ( style & wxALIGN_MASK ) | wxTE_NOHIDESEL | wxTE_PROCESS_ENTER)
{
m_spin = spin;
m_max = max;
m_increment = increment;
- m_textCtrl = new wxSpinCtrlTextGeneric(this, value);
+ m_textCtrl = new wxSpinCtrlTextGeneric(this, value, style);
m_spinButton = new wxSpinCtrlButtonGeneric(this, style);
m_spin_value = m_spinButton->GetValue();
gtk_spin_button_set_value( GTK_SPIN_BUTTON(m_widget), initial);
m_value = gtk_spin_button_get_value( GTK_SPIN_BUTTON(m_widget));
+ gfloat align;
+ if ( HasFlag(wxTE_RIGHT) )
+ align = 1.0;
+ else if ( HasFlag(wxTE_CENTRE) )
+ align = 0.5;
+ else
+ align = 0.0;
+
+ gtk_entry_set_alignment(GTK_ENTRY(m_widget), align);
+
gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
(int)(m_windowStyle & wxSP_WRAP) );
WXDWORD exStyle = 0;
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
+ // propagate text alignment style to text ctrl
+ if ( style & wxTE_RIGHT )
+ msStyle |= ES_RIGHT;
+ else if ( style & wxTE_CENTER )
+ msStyle |= ES_CENTER;
+
// this control is used for numeric entry so normally using these flags by
// default shouldn't be a problem, if it is we can always add a style such
// as wxSP_NON_NUMERIC later
- msStyle |= ES_RIGHT | ES_NUMBER;
+ msStyle |= ES_NUMBER;
// calculate the sizes: the size given is the total size for both controls
// and we need to fit them both in the given width (height is the same)
}
wxSize csize = size ;
- m_text = new wxSpinCtrlText(this, value, style & wxTE_PROCESS_ENTER ? wxTE_PROCESS_ENTER : 0 );
+ m_text = new wxSpinCtrlText(this, value, style & ( wxTE_PROCESS_ENTER | wxALIGN_MASK ) );
m_btn = new wxSpinCtrlButton(this, style);
m_btn->SetRange(min, max);
XRC_ADD_STYLE(wxSP_VERTICAL);
XRC_ADD_STYLE(wxSP_ARROW_KEYS);
XRC_ADD_STYLE(wxSP_WRAP);
+ XRC_ADD_STYLE(wxTE_LEFT);
+ XRC_ADD_STYLE(wxTE_CENTER);
+ XRC_ADD_STYLE(wxTE_RIGHT);
}
wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
- GetStyle(wxT("style"), wxSP_ARROW_KEYS),
+ GetStyle(wxT("style"), wxSP_ARROW_KEYS | wxTE_RIGHT),
GetLong(wxT("min"), DEFAULT_MIN),
GetLong(wxT("max"), DEFAULT_MAX),
GetLong(wxT("value"), DEFAULT_VALUE),