Create
Manually
To create a widget without a parent:
MyGUI::Gui::getInstance().createWidget<MyGUI::__widget_type__>("__skin_name__", __x__, __y__, __w__, __h__, MyGUI::__Align__, "__layer_name__"['', "__widget_name__"'']); MyGUI::Gui::getInstance().createWidgetReal<MyGUI::__widget_type__>("__skin_name__", __x_r__, __y_r__, __w_r__, __h_r__, MyGUI::__Align__, "__layer_name__"['', "__widget_name__"'']);
To create a child widget:
parent_ptr->createWidget<MyGUI::__widget_type__>("__skin_name__", __x__, __y__, __w__, __h__, MyGUI::__Align__ ['', "__widget_name__"'']); parent_ptr->createWidgetReal<MyGUI::__widget_type__>("__skin_name__", __x_r__, __y_r__, __w_r__, __h_r__, MyGUI::__Align__ ['', "__widget_name__"'']);
Possible widget_type values can be found at the MyGUI main page.
skin_name can be the same as the widget or any skin from the MyGUI main page.
x, y, w, h is the widget position, width, and height in pixels.
x_r, y_r, w_r, h_r is the widget position width and height relative to its parent (or the screen, if it doesn't have a parent) in coordinates from 0 to 1.
Possible align values can be found in the align table.
All layer_names can be found in the standard layers.
widget_name is an optional parameter.
Find
To find a widget (for example a Button)
MyGUI::Button* button = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("button_name");
If you don't care about the widget type, you can write:
MyGUI::Widget* any_widget = MyGUI::Gui::getInstance().findWidget__T__("widget_name");
Destroy
To destroy widgets you need to have pointers to them of the form (widget_ptr). Then write
MyGUI::Gui::getInstance().destroyWidget(__widget_ptr__);
If you don't have a pointer to your widget, you should get it by searching for it by name.
MyGUI::Widget* widget = MyGUI::Gui::getInstance().findWidgetT("widget_name"); MyGUI::Gui::getInstance().destroyWidget(widget);