GWEN_CONTROL_INLINE(PageControl, GUnit) { Gwen::Controls::PageControl* control = new Gwen::Controls::PageControl(this); control->SetSize(500, 300); control->SetPageCount(5); control->onPageChanged.Add(this, &ThisClass::OnPageChanged); control->onFinish.Add(this, &ThisClass::OnFinish); // Page 0 { Gwen::Controls::Button* pButton = new Gwen::Controls::Button(control->GetPage(0)); pButton->Dock(Pos::Fill); pButton->SetText("This button is fill docked on page 0"); } // Page 1 { Gwen::Controls::Button* pButton = new Gwen::Controls::Button(control->GetPage(1)); pButton->Dock(Pos::Top); pButton->SetText("This button is top docked on page 1"); } // Page 2 { Gwen::Controls::Button* pButton = new Gwen::Controls::Button(control->GetPage(2)); pButton->SetSize(400, 1000); pButton->SetPos(50, 50); pButton->SetText("This button is long to test scrolling (page 2)"); } }
void CustomControlWindowApp::addControls() { Gwen::Controls::Button *btn = new Gwen::Controls::Button( mCanvas ); btn->SetBounds( getWindowCenter().x - 40, getWindowCenter().y - 20, 80, 40 ); btn->SetText( "Click Me" ); btn->onPress.Add( this, &CustomControlWindowApp::buttonPressed ); btn->AddAccelerator( "x" ); }
void onButtonA( Gwen::Controls::Base* pControl ) { Gwen::Controls::Button* but = (Gwen::Controls::Button*) pControl; // int dep = but->IsDepressed(); int tog = but->GetToggleState(); if (m_data->m_toggleButtonCallback) (*m_data->m_toggleButtonCallback)(m_buttonId,tog); }
void onButtonPress( Gwen::Controls::Base* pControl ) { if (m_callback) { bool buttonState = true; if (m_buttonControl->IsToggle()) { buttonState = m_buttonControl->GetToggleState(); } ( *m_callback )( m_buttonId, buttonState, m_userPointer ); } }
AngelUIHandle UserInterface::AddButton(const String& label, Vec2i position, void (*callback)(), bool center, const String& font, Vec2i padding) { Gwen::Controls::Button* button = new Gwen::Controls::Button(AngelCanvas); if (font != "") { button->SetFont(Gwen::Utility::StringToUnicode(font), 20, false); } button->SetText(label); button->SetPadding(Gwen::Padding(padding.X, padding.Y, padding.X, padding.Y)); button->SizeToContents(); if (center) { Gwen::Point size = button->GetSize(); button->SetPos(position.X - (size.x / 2), position.Y - (size.y / 2)); } else { button->SetPos(position.X, position.Y); } button->onPress.Add(&handler, &EventHandler::OnPress); handler.AddButtonCallback(button, callback); _elements.insert(button); return button; }
void GwenParameterInterface::registerButtonParameter(ButtonParams& params) { Gwen::Controls::Button* button = new Gwen::Controls::Button(m_gwenInternalData->m_demoPage->GetPage()); MyButtonEventHandler* handler = new MyButtonEventHandler(params.m_callback,params.m_buttonId,params.m_userPointer); button->SetText(params.m_name); button->onPress.Add( handler, &MyButtonEventHandler::onButtonPress ); m_paramInternalData->m_buttons.push_back(button); m_paramInternalData->m_buttonEventHandlers.push_back(handler); button->SetPos( 5, m_gwenInternalData->m_curYposition ); button->SetWidth(220); m_gwenInternalData->m_curYposition+=22; }
void CLoadState::Begin() { // Load References SingletonPointer<CMainState> MainState; SingletonPointer<CMainMenuState> MenuState; Canvas = GUIManager->GetCanvas(); // Init Canvas Canvas->SetBackgroundColor(Gwen::Color(32, 48, 48)); Canvas->SetDrawBackground(true); // Top Label Gwen::Controls::Label * BigLabel = new Gwen::Controls::Label(Canvas); BigLabel->SetFont(GUIManager->GetLargeFont()); BigLabel->SetText(L"Loading..."); BigLabel->SetBounds(10, 10, 1590, 300); BigLabel->SetTextColor(Gwen::Color(255, 255, 255, 84)); GUIManager->Draw(0, true); Context->Window->SwapBuffers(); AddLabel(L"Initializing System..."); CGUIEventManager * Forwarder = new CGUIEventManager(GUIManager->GetCanvas(), Context->Window); AddLabel(L"Loading Scene Shaders..."); LoadShaders(); AddLabel(L"Loading Scene Objects..."); LoadScene(); AddLabel(L"Menu is Starting..."); if (GetConfirmation) { Gwen::Controls::Button * Button = new Gwen::Controls::Button(GUIManager->GetCanvas()); Button->SetBounds(250, 650, 250, 35); Button->SetText(L"Continue"); Button->onPress.Add(& Handler, & CLoadStateEventHandler::OnFinish); } else { OnFinish(); } }
GWEN_CONTROL_INLINE( PanelListPanel, GUnit ) { m_PLP = new Gwen::Controls::PanelListPanel( this ); m_PLP->Dock( Pos::Fill ); m_PLP->SetPadding( Gwen::Padding( 10, 10 )); m_PLP->SetVertical(); m_PLP->SetSizeToChildren( false ); for ( int i = 0; i < 16; i++) { Gwen::String testName = "TEST" + Utility::ToString( i ); Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_PLP ); testButton->SetText( testName ); } Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar( this ); pStatus->Dock( Pos::Bottom ); { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "Horizontal" ); pButton->onPress.Add( this, &PanelListPanel::GoHorizontal ); pStatus->AddControl( pButton, false ); } { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "Vertical" ); pButton->onPress.Add( this, &PanelListPanel::GoVertical ); pStatus->AddControl( pButton, true ); } }
AngelUIHandle UserInterface::ShowChoiceBox(const String& choiceLabel, const StringList& labels, void (*callback)(int), const String& font, Vec2i padding, bool modal) { Gwen::Controls::WindowControl* box = new Gwen::Controls::WindowControl(AngelCanvas); box->SetTitle(choiceLabel); Gwen::TextObject fontTextObject = Gwen::Utility::StringToUnicode(font); Vec2i maxSize; std::vector<Gwen::Controls::Button*> buttons; for (unsigned int i=0; i < labels.size(); i++) { Gwen::Controls::Button* button = new Gwen::Controls::Button(box); buttons.push_back(button); if (font != "") { button->SetFont(fontTextObject, 20, false); } button->SetText(labels[i]); button->SetPadding(Gwen::Padding(padding.X, padding.Y, padding.X, padding.Y)); button->SizeToContents(); Gwen::Point size = button->GetSize(); if (maxSize.X < size.x) { maxSize.X = size.x; } if (maxSize.Y < size.y) { maxSize.Y = size.y; } button->onPress.Add(&handler, &EventHandler::OnPress); } for (unsigned int i=0; i < buttons.size(); i++) { buttons[i]->SetPos(maxSize.X / 2 - (buttons[i]->GetSize().x / 2), i * (maxSize.Y + padding.Y)); } box->SetSize(maxSize.X + (padding.X * 2), buttons.size() * (maxSize.Y + padding.Y) + (padding.Y * 3)); box->SetPos((AngelCanvas->GetSize().x / 2) - (box->GetSize().x / 2), (AngelCanvas->GetSize().y / 2) - (box->GetSize().y / 2)); if (modal) { box->MakeModal(); } box->SetDeleteOnClose(true); box->SetClosable(false); handler.AddChoiceCallback(box, callback); _elements.insert(box); return box; }
void GwenUserInterface::registerToggleButton(int buttonId, const char* name) { assert(m_data); assert(m_data->m_demoPage); Gwen::Controls::Button* but = new Gwen::Controls::Button(m_data->m_demoPage->GetPage()); ///some heuristic to find the button location int ypos = m_data->m_handlers.size()*20; but->SetPos(10, ypos ); but->SetWidth( 100 ); //but->SetBounds( 200, 30, 300, 200 ); MyButtonHander* handler = new MyButtonHander(m_data, buttonId); m_data->m_handlers.push_back(handler); but->onToggle.Add(handler, &MyButtonHander::onButtonA); but->SetIsToggle(true); but->SetToggleState(false); but->SetText(name); }
MyWindow ( Gwen::Controls::Base* pParent) : Gwen::Controls::WindowControl( pParent ) { SetTitle( L"FEM Settings" ); SetSize( 200, 300 ); this->Dock( Gwen::Pos::Left ); m_TextOutput = new Gwen::Controls::ListBox( this ); m_TextOutput->Dock( Gwen::Pos::Bottom ); m_TextOutput->SetHeight( 100 ); { Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox( this ); pGroup->SetPos(5, 5); pGroup->SetSize(170, 45); // pGroup->Dock( Gwen::Pos::Fill ); pGroup->SetText( "Young modulus" ); Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( pGroup ); pSlider->SetPos( 5, 10 ); pSlider->SetSize( 130, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetValue( 25 ); pSlider->onValueChanged.Add( this, &MyWindow::SliderMoved); } Gwen::Controls::CheckBoxWithLabel* labeled = new Gwen::Controls::CheckBoxWithLabel( this ); labeled->SetPos( 10, 55); labeled->Checkbox()->SetChecked(true); labeled->Label()->SetText( "Stifness warping" ); // labeled->Checkbox()->onChecked.Add( handler, &MyHander::OnCheckedStiffnessWarping ); // labeled->Checkbox()->onUnChecked.Add( handler, &MyHander::OnUncheckedStiffnessWarping ); labeled->Checkbox()->onCheckChanged.Add( this, &MyWindow::OnCheckChangedStiffnessWarping ); // Gwen::Align::PlaceBelow( labeled, check, 10 ); if (0) { Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox( this ); pGroup->SetPos(5, 55); pGroup->SetSize(170, 45); // pGroup->Dock( Gwen::Pos::Fill ); pGroup->SetText( "Gravity" ); Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( pGroup); pSlider->SetPos( 5, 10 ); pSlider->SetSize( 130, 20 ); pSlider->SetRange( 0, 100 ); pSlider->SetValue( 25 ); pSlider->SetNotchCount( 10 ); pSlider->SetClampToNotches( true ); // pSlider->onValueChanged.Add( this, &Slider::SliderMoved ); } Gwen::Controls::Button* pButton = new Gwen::Controls::Button( this ); pButton->onPress.Add(this, &MyWindow::onButtonA); pButton->SetBounds( 5, 110, 170, 45); pButton->SetText( "Toggle simulation" ); }
CGUIControlPanelWidget::CGUIControlPanelWidget() { Window = new Gwen::Controls::WindowControl(GUIManager->GetCanvas()); Window->SetDeleteOnClose(false); Window->SetBounds(30, 600, 660 + 30 + 165 + 165, 85); Window->SetTitle("Control Panel"); Window->SetClosable(false); Gwen::Controls::Button * EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(15, 10, 150, 35); EnableButton->SetText("Volume Controls"); EnableButton->onPress.Add(this, & CGUIControlPanelWidget::OnToggleVolume); EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(180, 10, 150, 35); EnableButton->SetText("Terrain Controls"); EnableButton->onPress.Add(this, & CGUIControlPanelWidget::OnToggleTerrain); EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(345, 10, 150, 35); EnableButton->SetText("Glyph Controls"); EnableButton->onPress.Add(this, & CGUIControlPanelWidget::OnToggleGlyph); EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(510, 10, 150, 35); EnableButton->SetText("Scene Controls"); EnableButton->onPress.Add(this, & CGUIControlPanelWidget::OnToggleScene); EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(675, 10, 150, 35); EnableButton->SetText("Shark Controls"); EnableButton->onPress.Add(this, &CGUIControlPanelWidget::OnToggleShark); EnableButton = new Gwen::Controls::Button(Window); EnableButton->SetBounds(840, 10, 150, 35); EnableButton->SetText("Graph Display"); EnableButton->onPress.Add(this, &CGUIControlPanelWidget::OnToggleGraph); }
GWEN_CONTROL_INLINE( CrossSplitter, GUnit ) { m_bSplittersVisible = false; m_iCurZoom = 0; m_Splitter = new Gwen::Controls::CrossSplitter( this ); m_Splitter->SetPos(0, 0); m_Splitter->Dock( Pos::Fill ); { Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter ); testButton->SetText( "TOPLEFT"); m_Splitter->SetPanel( 0, testButton ); } { Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter ); testButton->SetText( "TOPRIGHT"); m_Splitter->SetPanel( 1, testButton ); } { Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter ); testButton->SetText( "BOTTOMRIGHT"); m_Splitter->SetPanel( 2, testButton ); } { Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter ); testButton->SetText( "BOTTOMLEFT"); m_Splitter->SetPanel( 3, testButton ); } //Status bar to hold unit testing buttons Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar( this ); pStatus->Dock( Pos::Bottom ); { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "Zoom" ); pButton->onPress.Add( this, &CrossSplitter::ZoomTest ); pStatus->AddControl( pButton, false ); } { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "UnZoom" ); pButton->onPress.Add( this, &CrossSplitter::UnZoomTest ); pStatus->AddControl( pButton, false ); } { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "CenterPanels" ); pButton->onPress.Add( this, &CrossSplitter::CenterPanels ); pStatus->AddControl( pButton, true ); } { Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus ); pButton->SetText( "Splitters" ); pButton->onPress.Add( this, &CrossSplitter::ToggleSplitters ); pStatus->AddControl( pButton, true ); } }