1 #include "UnitTest.h" 2 #include "Gwen/Controls/TabControl.h" 3 #include "Gwen/Controls/RadioButtonController.h" 4 5 using namespace Gwen; 6 7 class TabControl2 : public GUnit 8 { 9 public: 10 Controls::TabControl* m_pDockControlLeft; 11 GWEN_CONTROL_INLINE(TabControl2,GUnit)12 GWEN_CONTROL_INLINE(TabControl2, GUnit) 13 { 14 { 15 m_pDockControlLeft = new Controls::TabControl(this); 16 m_pDockControlLeft->SetBounds(10, 10, 200, 200); 17 18 { 19 Controls::TabButton* pButton = m_pDockControlLeft->AddPage(L"Controls"); 20 Base* pPage = pButton->GetPage(); 21 22 { 23 Controls::RadioButtonController* pRadio = new Controls::RadioButtonController(pPage); 24 pRadio->SetBounds(10, 10, 100, 100); 25 26 pRadio->AddOption("Top")->Select(); 27 pRadio->AddOption("Bottom"); 28 pRadio->AddOption("Left"); 29 pRadio->AddOption("Right"); 30 31 pRadio->onSelectionChange.Add(this, &ThisClass::OnDockChange); 32 } 33 } 34 35 m_pDockControlLeft->AddPage(L"Red"); 36 m_pDockControlLeft->AddPage(L"Green"); 37 m_pDockControlLeft->AddPage(L"Blue"); 38 } 39 40 { 41 Controls::TabControl* pDragMe = new Controls::TabControl(this); 42 pDragMe->SetBounds(220, 10, 200, 200); 43 44 pDragMe->AddPage(L"You"); 45 pDragMe->AddPage(L"Can"); 46 pDragMe->AddPage(L"Reorder")->SetImage(L"test16.png"); 47 pDragMe->AddPage(L"These"); 48 pDragMe->AddPage(L"Tabs"); 49 50 pDragMe->SetAllowReorder(true); 51 } 52 } 53 OnDockChange(Gwen::Controls::Base * pControl)54 void OnDockChange(Gwen::Controls::Base* pControl) 55 { 56 Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*)pControl; 57 58 if (rc->GetSelectedLabel() == L"Top") m_pDockControlLeft->SetTabStripPosition(Pos::Top); 59 if (rc->GetSelectedLabel() == L"Bottom") m_pDockControlLeft->SetTabStripPosition(Pos::Bottom); 60 if (rc->GetSelectedLabel() == L"Left") m_pDockControlLeft->SetTabStripPosition(Pos::Left); 61 if (rc->GetSelectedLabel() == L"Right") m_pDockControlLeft->SetTabStripPosition(Pos::Right); 62 } 63 64 Gwen::Font m_Font; 65 }; 66 67 DEFINE_UNIT_TEST(TabControl2, L"TabControl");