Example #1
0
bool SpinButton::LoadXMLConfiguration(void)
{
  if (NULL == profile || NULL == widgetNode) {
    return false;
  }

  ParseXMLGeometry();
  ParseXMLBorder();
  ParseXMLBackground();

  XmlReader * xmlFile = profile->GetXMLDocument();

  const xmlNode * labelNode = xmlFile->GetFirstNamedChild(widgetNode, "Label");
  if (NULL != labelNode) {
    txtLabel = new Label(profile, labelNode);
    txtLabel->LoadXMLConfiguration();
  } else {
    txtLabel = new Label("n/a", 100);
  }
  txtLabel->Pack();
  txtLabel->SetPosition(position.x,
                        position.y + (size.y / 2) - (txtLabel->GetSizeY() / 2));

  const xmlNode * valueNode = xmlFile->GetFirstNamedChild(widgetNode, "Value");
  if (NULL != valueNode) {
    txtValue = new Label(profile, valueNode);
    txtValue->LoadXMLConfiguration();
  } else {
    txtValue = new Label("0", 100);
  }
  txtValue->Pack();
  txtValue->SetPosition(position.x + size.x - txtValue->GetWidth(),
                        position.y + (size.y / 2) - (txtValue->GetSizeY() / 2));

  AbstractSpinButton::LoadXMLConfiguration();
  ValueHasChanged();

  const xmlNode * buttonMinusNode = xmlFile->GetFirstNamedChild(widgetNode, "ButtonMinus");
  if (NULL != buttonMinusNode) {
    m_minus = new Button(profile, buttonMinusNode);
    m_minus->LoadXMLConfiguration();
    m_minus->SetPosition(position.x + size.x - m_minus->GetSizeX(),
                         position.y);
  }

  const xmlNode * buttonPlusNode = xmlFile->GetFirstNamedChild(widgetNode, "ButtonPlus");
  if (NULL != buttonPlusNode) {
    m_plus = new Button(profile, buttonPlusNode);
    m_plus->LoadXMLConfiguration();
    m_plus->SetPosition(position.x + size.x - m_plus->GetSizeX(),
                        position.y + size.y - m_plus->GetSizeY());
  }

  return true;
}
bool AbstractSpinButton::LoadXMLConfiguration(void)
{
  if (NULL == profile || NULL == widgetNode) {
    return false;
  }

  XmlReader * xmlFile = profile->GetXMLDocument();

  const xmlNode * valueNode = xmlFile->GetFirstNamedChild(widgetNode, "Value");
  xmlFile->ReadIntAttr(valueNode, "initValue", m_value);
  xmlFile->ReadIntAttr(valueNode, "minValue", m_min_value);
  xmlFile->ReadIntAttr(valueNode, "maxValue", m_max_value);
  xmlFile->ReadIntAttr(valueNode, "stepValue", m_step);

  return true;
}