Пример #1
0
// Adds a new option to the select control.
int WidgetDropDown::AddOption(const Rocket::Core::String& rml, const Rocket::Core::String& value, int before, bool select, bool selectable)
{
	// Instance a new element for the option.
	Core::Element* element = Core::Factory::InstanceElement(selection_element, "*", "option", Rocket::Core::XMLAttributes());

	// Force to block display and inject the RML. Register a click handler so we can be notified of selection.
	element->SetProperty("display", "block");
	element->SetProperty("clip", "auto");
	element->SetInnerRML(rml);
	element->AddEventListener("click", this);

	int option_index;
	if (before < 0 ||
		before >= (int) options.size())
	{
		selection_element->AppendChild(element);
		options.push_back(SelectOption(element, value, selectable));
		option_index = (int) options.size() - 1;
	}
	else
	{
		selection_element->InsertBefore(element, selection_element->GetChild(before));
		options.insert(options.begin() + before, SelectOption(element, value, selectable));
		option_index = before;
	}

	element->RemoveReference();

	// Select the option if appropriate.
	if (select)
		SetSelection(option_index);

	box_layout_dirty = true;
	return option_index;
}
Пример #2
0
void LoadingScreen::DoAppendText(const std::string& str)
{
  Wait();
  {
    Core::Element* input = root->GetElementById("content");
    Core::String   content;

    input->GetInnerRML(content);
    content = Core::String(content + "<br />" + str.c_str());
    input->SetInnerRML(content);
  }
  Post();
  Refresh();
}
Пример #3
0
void UiBase::RecursiveTranslate(Core::Element* root)
{
  unsigned short it;
  Core::Element* child;

  if (!root)
    return ;
  for (it = 0 ; (child = root->GetChild(it)) ; ++it)
  {
    Core::Variant* attr = child->GetAttribute("i18n");

    if (attr)
    {
      string key = attr->Get<Core::String>().CString();

      child->SetInnerRML(i18n::T(key).c_str());
    }
    else
      RecursiveTranslate(child);
  }
}