示例#1
0
文件: XML.cpp 项目: galippi/xcsoar
static void *
GetCallBack(CallBackTableEntry *LookUpTable,
            const XMLNode &node, const TCHAR* attribute)
{
  return CallBackLookup(LookUpTable,
                        StringToStringDflt(node.getAttribute(attribute), NULL));
}
示例#2
0
文件: XML.cpp 项目: galippi/xcsoar
static DataField *
LoadDataField(const XMLNode &node, CallBackTableEntry *LookUpTable,
              const DialogStyle eDialogStyle)
{
  TCHAR DataType[32];
  TCHAR DisplayFmt[32];
  TCHAR EditFormat[32];
  double Step;
  int Fine;

  _tcscpy(DataType,
          StringToStringDflt(node.getAttribute(_T("DataType")),
                             _T("")));
  _tcscpy(DisplayFmt,
          StringToStringDflt(node. getAttribute(_T("DisplayFormat")),
                             _T("")));
  _tcscpy(EditFormat,
          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")), 0);

  DataField::DataAccessCallback_t callback = (DataField::DataAccessCallback_t)
    CallBackLookup(LookUpTable,
                   StringToStringDflt(node.getAttribute(_T("OnDataAccess")),
                                      NULL));

  if (_tcsicmp(DataType, _T("enum")) == 0)
    return new DataFieldEnum(callback);

  if (_tcsicmp(DataType, _T("filereader")) == 0)
    return new DataFieldFileReader(callback);

  if (_tcsicmp(DataType, _T("boolean")) == 0)
    return new DataFieldBoolean(false, _("ON"), _("OFF"), callback);

  if (_tcsicmp(DataType, _T("double")) == 0)
    return new DataFieldFloat(EditFormat, DisplayFmt, Min, Max,
                              fixed_zero, fixed(Step), fixed(Fine),
                              callback);

  if (_tcsicmp(DataType, _T("integer")) == 0)
    return new DataFieldInteger(EditFormat, DisplayFmt, Min, Max,
                                0, (int)Step, callback);

  if (_tcsicmp(DataType, _T("string")) == 0)
    return new DataFieldString(_T(""), callback);

  return NULL;
}
示例#3
0
文件: XML.cpp 项目: davidswelt/XCSoar
static void *
GetCallBack(const CallBackTableEntry *lookup_table,
            const XMLNode &node, const TCHAR* attribute)
{
  const TCHAR *name = node.getAttribute(attribute);
  if (name == NULL)
    return NULL;

  assert(!StringIsEmpty(name));

  return CallBackLookup(lookup_table, name);
}