PuzzleSDK
UIRadioButtonTest类 参考

#include <UIRadioButtonTest.h>

+ 类 UIRadioButtonTest 继承关系图:
+ UIRadioButtonTest 的协作图:

Public 成员函数

 CREATE_FUNC (UIRadioButtonTest)
 
 UIRadioButtonTest ()
 
 ~UIRadioButtonTest ()
 
virtual bool init () override
 
void addRadioButton (Ref *sender)
 
void deleteRadioButton (Ref *sender)
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Private 属性

cocos2d::ui::RadioButtonGroup * _radioButtonGroup
 
cocos2d::ui::Text * _allowNoSelectionText
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 UIScene
cocos2d::Layer * _uiLayer
 
cocos2d::ui::Layout * _widget
 
cocos2d::ui::Text * _sceneTitle
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 UIRadioButtonTest.h33 行定义.

构造及析构函数说明

◆ UIRadioButtonTest()

UIRadioButtonTest::UIRadioButtonTest ( )

在文件 UIRadioButtonTest.cpp39 行定义.

39 :
40_radioButtonGroup(nullptr),
42{
43}
cocos2d::ui::RadioButtonGroup * _radioButtonGroup
cocos2d::ui::Text * _allowNoSelectionText

◆ ~UIRadioButtonTest()

UIRadioButtonTest::~UIRadioButtonTest ( )

在文件 UIRadioButtonTest.cpp44 行定义.

45{
46}

成员函数说明

◆ addRadioButton()

void UIRadioButtonTest::addRadioButton ( Ref *  sender)

在文件 UIRadioButtonTest.cpp111 行定义.

112{
113 Vec2 pos;
114 if(_radioButtonGroup->getNumberOfRadioButtons() > 0)
115 {
116 RadioButton* lastRadioButton = _radioButtonGroup->getRadioButtonByIndex((int)_radioButtonGroup->getNumberOfRadioButtons() - 1);
117 pos = lastRadioButton->getPosition();
118 }
119 else
120 {
121 pos.x = startPosX - BUTTON_WIDTH;
122 pos.y = _widget->getContentSize().height / 2.0f + 10;
123 }
124
125 RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png");
126 pos.x += BUTTON_WIDTH;
127 radioButton->setPosition(pos);
128 _radioButtonGroup->addRadioButton(radioButton);
129 _uiLayer->addChild(radioButton);
130}
static float startPosX
static const float BUTTON_WIDTH
cocos2d::Layer * _uiLayer
Definition: UIScene.h:44
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 _radioButtonGroup, UIScene::_uiLayer, UIScene::_widget, BUTTON_WIDTH , 以及 startPosX.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

◆ CREATE_FUNC()

UIRadioButtonTest::CREATE_FUNC ( UIRadioButtonTest  )

◆ deleteRadioButton()

void UIRadioButtonTest::deleteRadioButton ( Ref *  sender)

在文件 UIRadioButtonTest.cpp132 行定义.

133{
134 if(_radioButtonGroup->getNumberOfRadioButtons() > 0)
135 {
136 RadioButton* radioButton = _radioButtonGroup->getRadioButtonByIndex((int)_radioButtonGroup->getNumberOfRadioButtons() - 1);
137 _radioButtonGroup->removeRadioButton(radioButton);
138 _uiLayer->removeChild(radioButton);
139 }
140}

引用了 _radioButtonGroup , 以及 UIScene::_uiLayer.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

◆ init()

bool UIRadioButtonTest::init ( )
overridevirtual

重载 UIScene .

在文件 UIRadioButtonTest.cpp51 行定义.

52{
53 if (UIScene::init())
54 {
55 Size widgetSize = _widget->getContentSize();
56
57 // Create a radio button group
58 _radioButtonGroup = RadioButtonGroup::create();
59 _uiLayer->addChild(_radioButtonGroup);
60
61 // Create the radio buttons
62 static const int NUMBER_OF_BUTTONS = 5;
63 startPosX = widgetSize.width / 2.0f - ((NUMBER_OF_BUTTONS - 1) / 2.0f) * BUTTON_WIDTH;
64 for(int i = 0; i < NUMBER_OF_BUTTONS; ++i)
65 {
66 RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png");
67 float posX = startPosX + BUTTON_WIDTH * i;
68 radioButton->setPosition(Vec2(posX, widgetSize.height / 2.0f + 10));
69 radioButton->setScale(1.2f);
70 _radioButtonGroup->addRadioButton(radioButton);
71 _uiLayer->addChild(radioButton);
72 }
73
74 // Add button
75 Button* addButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
76 addButton->setTitleText("Add");
77 addButton->setPosition(Vec2(widgetSize.width / 2.0f - 100, widgetSize.height / 2.0f - 65));
78 addButton->addClickEventListener(CC_CALLBACK_1(UIRadioButtonTest::addRadioButton, this));
79 addButton->setScale(0.7f);
80 _uiLayer->addChild(addButton);
81
82 // Delete button
83 Button* deleteButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
84 deleteButton->setTitleText("Delete");
85 deleteButton->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - 65));
86 deleteButton->addClickEventListener(CC_CALLBACK_1(UIRadioButtonTest::deleteRadioButton, this));
87 deleteButton->setScale(0.7f);
88 _uiLayer->addChild(deleteButton);
89
90 // Toggle button
91 Button* allowNoSelectionToggle = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
92 allowNoSelectionToggle->setTitleText("Toggle Allow-No-Selection");
93 allowNoSelectionToggle->setPosition(Vec2(widgetSize.width / 2.0f + 100, widgetSize.height / 2.0f - 65));
94 allowNoSelectionToggle->addClickEventListener([this](Ref*) {
95 _radioButtonGroup->setAllowedNoSelection(!_radioButtonGroup->isAllowedNoSelection());
96 _allowNoSelectionText->setString(_radioButtonGroup->isAllowedNoSelection() ? "No selection is allowed." : "No selection is disallowed.");
97 });
98 allowNoSelectionToggle->setScale(0.7f);
99 _uiLayer->addChild(allowNoSelectionToggle);
100
101 // Add a label for toggle
102 _allowNoSelectionText = Text::create("No selection is disallowed.", "fonts/Marker Felt.ttf", 20);
103 _allowNoSelectionText->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 70));
105
106 return true;
107 }
108 return false;
109}
void deleteRadioButton(Ref *sender)
void addRadioButton(Ref *sender)
virtual bool init() override
Definition: UIScene.cpp:46

引用了 _allowNoSelectionText, _radioButtonGroup, UIScene::_uiLayer, UIScene::_widget, addRadioButton(), BUTTON_WIDTH, deleteRadioButton(), UIScene::init() , 以及 startPosX.

+ 函数调用图:

类成员变量说明

◆ _allowNoSelectionText

cocos2d::ui::Text* UIRadioButtonTest::_allowNoSelectionText
private

在文件 UIRadioButtonTest.h48 行定义.

被这些函数引用 init().

◆ _radioButtonGroup

cocos2d::ui::RadioButtonGroup* UIRadioButtonTest::_radioButtonGroup
private

在文件 UIRadioButtonTest.h47 行定义.

被这些函数引用 addRadioButton(), deleteRadioButton() , 以及 init().


该类的文档由以下文件生成: