1 /* 2 * Copyright 2015-2016, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "TableCellFloatEditor.h" 7 8 #include <ctype.h> 9 10 #include <Variant.h> 11 12 #include "IntegerValue.h" 13 #include "ValueFormatter.h" 14 15 TableCellFloatEditor(::Value * initialValue,ValueFormatter * formatter)16TableCellFloatEditor::TableCellFloatEditor(::Value* initialValue, 17 ValueFormatter* formatter) 18 : 19 TableCellTextControlEditor(initialValue, formatter) 20 { 21 } 22 23 ~TableCellFloatEditor()24TableCellFloatEditor::~TableCellFloatEditor() 25 { 26 } 27 28 29 bool ValidateInput() const30TableCellFloatEditor::ValidateInput() const 31 { 32 BVariant variantValue; 33 if (!InitialValue()->ToVariant(variantValue)) 34 return false; 35 36 return GetValueFormatter()->ValidateFormattedValue(Text(), 37 variantValue.Type()); 38 } 39 40 41 status_t GetValueForInput(::Value * & _output) const42TableCellFloatEditor::GetValueForInput(::Value*& _output) const 43 { 44 BVariant variantValue; 45 if (!InitialValue()->ToVariant(variantValue)) 46 return B_NO_MEMORY; 47 48 return GetValueFormatter()->GetValueFromFormattedInput(Text(), 49 variantValue.Type(), _output); 50 } 51 52 53