static DataField * LoadDataField(const XMLNode &node, const CallBackTableEntry *LookUpTable) { TCHAR data_type[32]; TCHAR display_format[32]; TCHAR edit_format[32]; double step; bool fine; _tcscpy(data_type, StringToStringDflt(node.getAttribute(_T("DataType")), _T(""))); _tcscpy(display_format, StringToStringDflt(node. getAttribute(_T("DisplayFormat")), _T(""))); _tcscpy(edit_format, StringToStringDflt(node.getAttribute(_T("EditFormat")), _T(""))); fixed min = fixed(StringToFloatDflt(node.getAttribute(_T("Min")), INT_MIN)); fixed max = fixed(StringToFloatDflt(node.getAttribute(_T("Max")), INT_MAX)); step = StringToFloatDflt(node.getAttribute(_T("Step")), 1); fine = StringToIntDflt(node.getAttribute(_T("Fine")), false); DataField::DataAccessCallback callback = (DataField::DataAccessCallback) GetCallBack(LookUpTable, node, _T("OnDataAccess")); if (_tcsicmp(data_type, _T("enum")) == 0) return new DataFieldEnum(callback); if (_tcsicmp(data_type, _T("filereader")) == 0) { DataFieldFileReader *df = new DataFieldFileReader(callback); if (StringToIntDflt(node.getAttribute(_T("Nullable")), true)) df->AddNull(); return df; } if (_tcsicmp(data_type, _T("boolean")) == 0) return new DataFieldBoolean(false, _("On"), _("Off"), callback); if (_tcsicmp(data_type, _T("double")) == 0) return new DataFieldFloat(edit_format, display_format, min, max, fixed_zero, fixed(step), fine, callback); if (_tcsicmp(data_type, _T("time")) == 0) { DataFieldTime *df = new DataFieldTime((int)min, (int)max, 0, (unsigned)step, callback); unsigned max_token = StringToIntDflt(node.getAttribute(_T("MaxTokens")), 2); df->SetMaxTokenNumber(max_token); return df; } if (_tcsicmp(data_type, _T("integer")) == 0) return new DataFieldInteger(edit_format, display_format, (int)min, (int)max, 0, (int)step, callback); if (_tcsicmp(data_type, _T("string")) == 0) return new DataFieldString(_T(""), callback); return NULL; }
WndProperty * RowFormWidget::AddTime(const TCHAR *label, const TCHAR *help, int min_value, int max_value, unsigned step, int value, unsigned max_tokens, DataField::DataAccessCallback callback) { WndProperty *edit = Add(label, help); DataFieldTime *df = new DataFieldTime(min_value, max_value, value, step, callback); df->SetMaxTokenNumber(max_tokens); edit->SetDataField(df); return edit; }