-
- // The item used for viewing the real number: should be a text item.
- wxWindow *m_propertyWindow = property->GetWindow();
- if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
- return FALSE;
-
- wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
- float val = 0.0;
- if (!StringToFloat(WXSTRINGCAST value, &val))
- {
- char buf[200];
- sprintf(buf, "Value %s is not a valid real number!", (const char *)value);
- wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
- return FALSE;
- }
-
- if (val < m_realMin || val > m_realMax)
- {
- char buf[200];
- sprintf(buf, "Value must be a real number between %.2f and %.2f!", m_realMin, m_realMax);
- wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
- return FALSE;
- }
- return TRUE;
-}
-
-bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
- wxWindow *WXUNUSED(parentWindow) )
-{
- // The item used for viewing the real number: should be a text item.
- wxWindow *m_propertyWindow = property->GetWindow();
- if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
- return FALSE;
-
- wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
- if (value.Length() == 0)
- return FALSE;
-
- float f = (float)atof((const char *)value);
- property->GetValue() = f;
- return TRUE;
-}
-
-bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
- wxWindow *WXUNUSED(parentWindow) )
-{
- // The item used for viewing the real number: should be a text item.
- wxWindow *m_propertyWindow = property->GetWindow();
- if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
- return FALSE;
-
- wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
- textItem->SetValue(FloatToString(property->GetValue().RealValue()));
- return TRUE;