forked from mia/Aegisub
More incomplete float spin code
Originally committed to SVN as r1237.
This commit is contained in:
parent
f8770b2999
commit
a2ef89c752
2 changed files with 22 additions and 11 deletions
|
@ -38,6 +38,7 @@
|
||||||
// Headers
|
// Headers
|
||||||
#include <wx/wxprec.h>
|
#include <wx/wxprec.h>
|
||||||
#include "float_spin.h"
|
#include "float_spin.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
@ -47,14 +48,12 @@ FloatSpinCtrl::FloatSpinCtrl(wxWindow* parent,wxWindowID id,const wxPoint& pos,c
|
||||||
: wxPanel(parent,id,pos,size,style,name)
|
: wxPanel(parent,id,pos,size,style,name)
|
||||||
{
|
{
|
||||||
// Set data
|
// Set data
|
||||||
min = _min;
|
|
||||||
max = _max;
|
|
||||||
step = _step;
|
|
||||||
value = initial;
|
value = initial;
|
||||||
|
|
||||||
// Create sub-controls
|
// Create sub-controls
|
||||||
text = new wxTextCtrl(this,-1,wxString::Format(_T("%f"),initial));
|
text = new wxTextCtrl(this,-1,_T(""));
|
||||||
button = new wxSpinButton(this,-1,wxDefaultPosition,wxSize(-1,20),wxSP_VERTICAL);
|
button = new wxSpinButton(this,-1,wxDefaultPosition,wxSize(-1,20),wxSP_VERTICAL);
|
||||||
|
SetRange(_min,_max,_step);
|
||||||
|
|
||||||
// Set sizer
|
// Set sizer
|
||||||
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -62,22 +61,33 @@ FloatSpinCtrl::FloatSpinCtrl(wxWindow* parent,wxWindowID id,const wxPoint& pos,c
|
||||||
sizer->Add(button,0,wxEXPAND,0);
|
sizer->Add(button,0,wxEXPAND,0);
|
||||||
SetSizer(sizer);
|
SetSizer(sizer);
|
||||||
sizer->SetSizeHints(this);
|
sizer->SetSizeHints(this);
|
||||||
|
|
||||||
|
// Update text
|
||||||
|
UpdateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// Set value
|
// Set value
|
||||||
void FloatSpinCtrl::SetValue(double value) {
|
void FloatSpinCtrl::SetValue(double _value) {
|
||||||
|
value = _value;
|
||||||
|
button->SetValue(int(value/step));
|
||||||
|
text->SetValue(PrettyFloatD(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// Set range
|
// Set range
|
||||||
void FloatSpinCtrl::SetRange(double min,double max) {
|
void FloatSpinCtrl::SetRange(double _min,double _max,double _step) {
|
||||||
|
min = _min;
|
||||||
|
max = _max;
|
||||||
|
step = _step;
|
||||||
|
button->SetRange(int(min/step),int(max/step));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////
|
///////////////
|
||||||
// Set step
|
// Update text
|
||||||
void FloatSpinCtrl::SetStep(double step) {
|
void FloatSpinCtrl::UpdateText() {
|
||||||
|
text->SetValue(PrettyFloatD(value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,13 @@ private:
|
||||||
double step;
|
double step;
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
|
void UpdateText();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FloatSpinCtrl(wxWindow* parent,wxWindowID id=-1,const wxPoint& pos=wxDefaultPosition,const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS, double min = 0.0, double max = 100.0, double initial = 0.0, double step = 1.0, const wxString& name = _T("wxSpinCtrl"));
|
FloatSpinCtrl(wxWindow* parent,wxWindowID id=-1,const wxPoint& pos=wxDefaultPosition,const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS, double min = 0.0, double max = 100.0, double initial = 0.0, double step = 1.0, const wxString& name = _T("wxSpinCtrl"));
|
||||||
|
|
||||||
void SetValue(double value);
|
void SetValue(double value);
|
||||||
void SetRange(double min,double max);
|
void SetRange(double min,double max,double step);
|
||||||
void SetStep(double step);
|
|
||||||
|
|
||||||
double GetValue() { return value; }
|
double GetValue() { return value; }
|
||||||
double GetMin() { return min; }
|
double GetMin() { return min; }
|
||||||
|
|
Loading…
Reference in a new issue