Esempio n. 1
0
/*
  <ButtonPic x="250px" y="50px"
             width="120px" height="110px"
             action="localGame"
             picture="menu/i_play.png"
             text="Play" />
*/
bool ButtonPic::LoadXMLConfiguration(void)
{
  if (NULL == profile || NULL == widgetNode) {
    //TODO error ... xml attributs not initialized !
    return false;
  }
  XmlReader * xmlFile = profile->GetXMLDocument();

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

  std::string picture("menu/pic_not_found.png");
  if (!xmlFile->ReadStringAttr(widgetNode, "picture", picture)) {
    //TODO error
    return false;
  }

  picture = profile->relative_path + picture;
  Surface surface(picture.c_str());
  m_img_normal = surface;

  std::string labelText("No Text");
  xmlFile->ReadStringAttr(widgetNode, "text", labelText);
  txt_label = new Text(_(labelText.c_str()), dark_gray_color, Font::FONT_SMALL, Font::FONT_BOLD, false);
  //txt_label->SetMaxWidth(size.x);

  return true;
}
Esempio n. 2
0
bool PictureTextCBox::LoadXMLConfiguration()
{
  if (NULL == profile || NULL == widgetNode) {
    return false;
  }

  XmlReader * xmlFile = profile->GetXMLDocument();

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

  Text::LoadXMLConfiguration(xmlFile, widgetNode);

  std::string file;
  Surface tmp;

  xmlFile->ReadStringAttr(widgetNode, "pictureEnabled", file);
  file = profile->relative_path + file;
  if (!tmp.ImgLoad(file)) {
    file = profile->relative_path + "menu/enabled.png";
    if (!tmp.ImgLoad(file)) {
      Error("XML Loading -> PictureTextCBox: can't load " + file);
    }
  }
  m_enabled = tmp.DisplayFormatAlpha();

  xmlFile->ReadStringAttr(widgetNode, "picture", file);
  file = profile->relative_path + file;
  if (!tmp.ImgLoad(file)) {
    Error("XML Loading -> PictureTextCBox: Node 'picture': can't load the file : " + file);
  }
  m_image = tmp.DisplayFormatAlpha();

  xmlFile->ReadStringAttr(widgetNode, "pictureDisabledFront", file);
  file = profile->relative_path + file;
  if (!tmp.ImgLoad(file)) {
    file = profile->relative_path + "menu/disabled_front.png";
    if (!tmp.ImgLoad(file)) {
      Error("XML Loading -> PictureTextCBox: can't load " + file);
    }
  }
  m_disabled_front = tmp.DisplayFormatAlpha();

  xmlFile->ReadStringAttr(widgetNode, "pictureDisabledBack", file);
  file = profile->relative_path + file;
  if (!tmp.ImgLoad(file)) {
    file = profile->relative_path + "menu/disabled_back.png";
    if (!tmp.ImgLoad(file)) {
      Error("XML Loading -> PictureTextCBox: can't load " + file);
    }
  }
  m_disabled_back = tmp.DisplayFormatAlpha();

  return true;
}
Esempio n. 3
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;
}
Esempio n. 4
0
bool Label::LoadXMLConfiguration()
{
  if (NULL == profile || NULL == widgetNode) {
    return false;
  }

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

  Text::LoadXMLConfiguration(profile->GetXMLDocument(),
                             widgetNode);

  return true;
}