(re?)added support for params to wxGridCellFloatEditor
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7419 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -449,6 +449,8 @@ private:
|
|||||||
class WXDLLEXPORT wxGridCellFloatEditor : public wxGridCellTextEditor
|
class WXDLLEXPORT wxGridCellFloatEditor : public wxGridCellTextEditor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
wxGridCellFloatEditor(int width = -1, int precision = -1);
|
||||||
|
|
||||||
virtual void Create(wxWindow* parent,
|
virtual void Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
wxEvtHandler* evtHandler);
|
wxEvtHandler* evtHandler);
|
||||||
@@ -462,12 +464,16 @@ public:
|
|||||||
virtual wxGridCellEditor *Clone() const
|
virtual wxGridCellEditor *Clone() const
|
||||||
{ return new wxGridCellFloatEditor; }
|
{ return new wxGridCellFloatEditor; }
|
||||||
|
|
||||||
|
// parameters string format is "width,precision"
|
||||||
|
virtual void SetParameters(const wxString& params);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// string representation of m_valueOld
|
// string representation of m_valueOld
|
||||||
wxString GetString() const
|
wxString GetString() const;
|
||||||
{ return wxString::Format(_T("%g"), m_valueOld); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_width,
|
||||||
|
m_precision;
|
||||||
double m_valueOld;
|
double m_valueOld;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -813,6 +813,12 @@ void wxGridCellNumberEditor::SetParameters(const wxString& params)
|
|||||||
// wxGridCellFloatEditor
|
// wxGridCellFloatEditor
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxGridCellFloatEditor::wxGridCellFloatEditor(int width, int precision)
|
||||||
|
{
|
||||||
|
m_width = width;
|
||||||
|
m_precision = precision;
|
||||||
|
}
|
||||||
|
|
||||||
void wxGridCellFloatEditor::Create(wxWindow* parent,
|
void wxGridCellFloatEditor::Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
wxEvtHandler* evtHandler)
|
wxEvtHandler* evtHandler)
|
||||||
@@ -884,6 +890,55 @@ void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGridCellFloatEditor::SetParameters(const wxString& params)
|
||||||
|
{
|
||||||
|
if ( !params )
|
||||||
|
{
|
||||||
|
// reset to default
|
||||||
|
m_width =
|
||||||
|
m_precision = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long tmp;
|
||||||
|
if ( params.BeforeFirst(_T(',')).ToLong(&tmp) )
|
||||||
|
{
|
||||||
|
m_width = (int)tmp;
|
||||||
|
|
||||||
|
if ( params.AfterFirst(_T(',')).ToLong(&tmp) )
|
||||||
|
{
|
||||||
|
m_precision = (int)tmp;
|
||||||
|
|
||||||
|
// skip the error message below
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxLogDebug(_T("Invalid wxGridCellFloatEditor parameter string '%s' ignored"), params.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxGridCellFloatEditor::GetString() const
|
||||||
|
{
|
||||||
|
wxString fmt;
|
||||||
|
if ( m_width == -1 )
|
||||||
|
{
|
||||||
|
// default width/precision
|
||||||
|
fmt = _T("%g");
|
||||||
|
}
|
||||||
|
else if ( m_precision == -1 )
|
||||||
|
{
|
||||||
|
// default precision
|
||||||
|
fmt.Printf(_T("%%%d.g"), m_width);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fmt.Printf(_T("%%%d.%dg"), m_width, m_precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxString::Format(fmt, m_valueOld);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGridCellBoolEditor
|
// wxGridCellBoolEditor
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user