(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:
Vadim Zeitlin
2000-05-18 12:29:02 +00:00
parent 7a5a0c9f34
commit 0bd879bad6
2 changed files with 63 additions and 2 deletions

View File

@@ -449,6 +449,8 @@ private:
class WXDLLEXPORT wxGridCellFloatEditor : public wxGridCellTextEditor
{
public:
wxGridCellFloatEditor(int width = -1, int precision = -1);
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler);
@@ -462,12 +464,16 @@ public:
virtual wxGridCellEditor *Clone() const
{ return new wxGridCellFloatEditor; }
// parameters string format is "width,precision"
virtual void SetParameters(const wxString& params);
protected:
// string representation of m_valueOld
wxString GetString() const
{ return wxString::Format(_T("%g"), m_valueOld); }
wxString GetString() const;
private:
int m_width,
m_precision;
double m_valueOld;
};

View File

@@ -813,6 +813,12 @@ void wxGridCellNumberEditor::SetParameters(const wxString& params)
// wxGridCellFloatEditor
// ----------------------------------------------------------------------------
wxGridCellFloatEditor::wxGridCellFloatEditor(int width, int precision)
{
m_width = width;
m_precision = precision;
}
void wxGridCellFloatEditor::Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler)
@@ -884,6 +890,55 @@ void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
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
// ----------------------------------------------------------------------------