现在的位置: 首页 > 综合 > 正文

MyGUI_Orge官网教程_5.窗口部件控制

2015年02月19日 ⁄ 综合 ⁄ 共 1401字 ⁄ 字号 评论关闭

创建

手工

创建一个没有父亲的窗口部件widget:

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"]);

 
创建一个子窗口部件:

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"]);

可用的widget_type值和skin_name可在MyGUI主页找到。
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是其位置、宽度、高度(像素)。

x_r, y_r, w_r, h_r 是相对于其父亲(如果没有父亲就是屏幕)的位置、宽度、高度,坐标从0到1.

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.

找到一个部件

找到一个窗口部件 (比如按钮)

MyGUI::Button* button = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("button_name");

如果你不关心部件类型,可以这样:

MyGUI::Widget* any_widget = MyGUI::Gui::getInstance().findWidgetT("widget_name");

 

销毁

为了摧毁它,你需要有这种形式的指针(widget_ptr). 然后这样写:

MyGUI::Gui::getInstance().destroyWidget(widget_ptr);

如果你没有指针,你需要用它的名字搜索获取

MyGUI::Widget* widget = MyGUI::Gui::getInstance().findWidgetT("widget_name");

MyGUI::Gui::getInstance().destroyWidget(widget);

抱歉!评论已关闭.