本文整理汇总了C++中UIControl::AddEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ UIControl::AddEvent方法的具体用法?C++ UIControl::AddEvent怎么用?C++ UIControl::AddEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIControl
的用法示例。
在下文中一共展示了UIControl::AddEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadResources
void UIScrollViewTest::LoadResources()
{
Font *font = FTFont::Create("~res:/Fonts/korinna.ttf");
DVASSERT(font);
font->SetSize(14);
font->SetColor(Color::White());
UIYamlLoader::Load( this, "~res:/UI/Test/ScrollScreen.yaml" );
scrollView = DynamicTypeCheck<UIScrollView *>( FindByName( "Scrollview" ) );
UIControl* innerControl = FindByName("UIControl1");
if (innerControl)
{
innerControl->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0);
innerControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT);
}
UIControl *control = FindByName("HorizontalScrollbar");
if( control )
{
UIScrollBar *horizontalScrollbar = DynamicTypeCheck<UIScrollBar *>( control );
horizontalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0);
horizontalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL);
horizontalScrollbar->GetSlider()->GetBackground()->SetLeftRightStretchCap(10);
horizontalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_HORIZONTAL );
horizontalScrollbar->SetDelegate(scrollView);
}
control = FindByName("VerticalScrollbar");
if( control )
{
UIScrollBar *verticalScrollbar = DynamicTypeCheck<UIScrollBar *>( control );
verticalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/VerticalScroll", 0);
verticalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_VERTICAL);
verticalScrollbar->GetSlider()->GetBackground()->SetTopBottomStretchCap(10);
verticalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_VERTICAL );
verticalScrollbar->SetDelegate(scrollView);
}
UIControl *testControl4 = new UIControl(Rect(1200, 1400, 250, 250));
testControl4->SetDebugDraw(true);
testControl4->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000));
testControl4->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
testControl4->SetName("CONTROL_4");
testControl4->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed));
scrollView->AddControlToContainer(testControl4);
UIControl *testControlChild = new UIControl(Rect(100, 100, 150, 150));
testControlChild->SetDebugDraw(true);
testControlChild->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000));
testControlChild->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
testControlChild->SetName("CONTROL_3");
testControlChild->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed));
UIControl *testControl = new UIControl(Rect(50, 0, 150, 150));
testControl->SetDebugDraw(true);
testControl->GetBackground()->SetColor(Color(0.3333, 0.6667, 0.4980, 1.0000));
testControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
testControl->SetName("CONTROL_2");
testControl->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed));
testControl->AddControl(testControlChild);
UIButton *testButton = new UIButton(Rect(10, 50, 250, 100));
testButton->SetDebugDraw(true);
testButton->SetStateFont(STATE_NORMAL, font);
testButton->SetStateText(STATE_NORMAL, L"First button");
testButton->GetBackground()->SetColor(Color(0.6667, 0.6667, 0.4980, 1.0000));
testButton->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
testButton->SetName("CONTROL_1");
testButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed));
testButton->AddControl(testControl);
scrollView->AddControlToContainer(testButton);
testMessageText = new UIStaticText(Rect(10, 10, 300, 30));
testMessageText->SetFont(font);
testMessageText->SetTextColor(Color(0.0, 1.0, 0.0, 1.0));
testMessageText->GetBackground()->SetColor(Color(0.5, 0.0, 0.25, 1.0));
testMessageText->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
AddControl(testMessageText);
finishTestBtn = new UIButton(Rect(10, 310, 300, 30));
finishTestBtn->SetStateFont(0xFF, font);
finishTestBtn->SetStateFontColor(0xFF, Color(1.0, 0.0, 0.0, 0.75));
finishTestBtn->SetStateText(0xFF, L"Finish test");
finishTestBtn->SetDebugDraw(true);
finishTestBtn->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed));
AddControl(finishTestBtn);
}