fixed precision field

This commit is contained in:
Peter Schojer 2008-09-10 12:12:35 +00:00
parent a7da97f27d
commit b56a1692e1
2 changed files with 19 additions and 1 deletions

View File

@ -40,6 +40,8 @@
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/NumberFieldCell.h"
#include "Poco/WebWidgets/WebApplication.h"
#include "Poco/WebWidgets/IntFormatter.h"
#include "Poco/WebWidgets/DoubleFormatter.h"
namespace Poco {
@ -63,8 +65,15 @@ void NumberFieldCellRenderer::renderHead(const Renderable* pRenderable, const Re
poco_assert_dbg (pRenderable != 0);
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::NumberFieldCell));
const NumberFieldCell* pCell = static_cast<const Poco::WebWidgets::NumberFieldCell*>(pRenderable);
Formatter::Ptr pForm = pCell->getFormatter();
IntFormatter::Ptr pIntForm = pForm.cast<IntFormatter>();
DoubleFormatter::Ptr pDoubleForm = pForm.cast<DoubleFormatter>();
ostr << "new Ext.form.NumberField({";
if (pIntForm)
ostr << "decimalPrecision:0,";
else if (pDoubleForm)
ostr << "decimalPrecision:" << pDoubleForm->precision() << ",";
TextFieldCellRenderer::writeCellProperties(pCell, ostr);
ostr << "})";

View File

@ -57,6 +57,9 @@ public:
std::string format(const Poco::Any& value) const;
Poco::Any parse(const std::string& value) const;
int precision() const;
/// Returns the precision
protected:
~DoubleFormatter();
@ -65,6 +68,12 @@ private:
};
inline int DoubleFormatter::precision() const
{
return _precision;
}
} } // namespace Poco::WebWidgets