void PromptBox::SetLabel(const CEGUI::String& text) { OC_CEGUI_TRY; { CEGUI::Window* messageText = mPromptBox->getChild(mPromptBox->getName() + "/MessageText"); CEGUI::Window* editbox = mPromptBox->getChild(mPromptBox->getName() + "/Editbox"); const float32 offset = 10; float32 buttonHeight = mPromptBox->getChild(mPromptBox->getName() + "/ButtonOK")->getPixelSize().d_height; float32 editboxHeight = editbox->getPixelSize().d_height; messageText->setText(text); float32 textWidth = StringConverter::FromString<float32>(messageText->getProperty("HorzExtent").c_str()); float32 textHeight = StringConverter::FromString<float32>(messageText->getProperty("VertExtent").c_str()); editbox->subscribeEvent(CEGUI::Editbox::EventKeyDown, CEGUI::Event::Subscriber(&PromptBox::OnEditboxKeyDown, this)); messageText->setArea(CEGUI::UDim(0,offset), CEGUI::UDim(0,0), CEGUI::UDim(1, -2.0f*offset), CEGUI::UDim(1, -buttonHeight-editboxHeight - offset)); mPromptBox->setWidth(CEGUI::UDim(0, textWidth + 2.0f*offset + INNER_FRAME_OFFSET)); mPromptBox->setHeight(CEGUI::UDim(0, textHeight + buttonHeight + editboxHeight + offset + INNER_FRAME_OFFSET)); mPromptBox->setXPosition(CEGUI::UDim(0.5f, -0.5f*mPromptBox->getPixelSize().d_width)); mPromptBox->setYPosition(CEGUI::UDim(0.5f, -0.5f*mPromptBox->getPixelSize().d_height)); EnsureWindowIsWideEnough(); } OC_CEGUI_CATCH; }
void MessageBox::SetText(const CEGUI::String& text) { CEGUI::Window* messageText = mMessageBox->getChild(mMessageBox->getName() + "/MessageText"); const float32 offset = 10; float32 buttonHeight = mMessageBox->getChild(mMessageBox->getName() + "/ButtonOK")->getPixelSize().d_height; messageText->setText(text); float32 textWidth = StringConverter::FromString<float32>(messageText->getProperty("HorzExtent").c_str()); float32 textHeight = StringConverter::FromString<float32>(messageText->getProperty("VertExtent").c_str()); messageText->setArea(CEGUI::UDim(0,offset), CEGUI::UDim(0,0), CEGUI::UDim(1, -2.0f*offset), CEGUI::UDim(1, -buttonHeight-offset)); mMessageBox->setWidth(CEGUI::UDim(0, textWidth + 2.0f*offset + INNER_FRAME_OFFSET)); mMessageBox->setHeight(CEGUI::UDim(0, textHeight + buttonHeight + offset + INNER_FRAME_OFFSET)); mMessageBox->setXPosition(CEGUI::UDim(0.5f, -0.5f*mMessageBox->getPixelSize().d_width)); mMessageBox->setYPosition(CEGUI::UDim(0.5f, -0.5f*mMessageBox->getPixelSize().d_height)); EnsureWindowIsWideEnough(); }
bool TabNavigation::OnEventKeyDown(const CEGUI::EventArgs& e) { const CEGUI::KeyEventArgs& args = static_cast<const CEGUI::KeyEventArgs&>(e); if (args.scancode == CEGUI::Key::Tab) // Tab or Shift+Tab { WidgetList::iterator itCurrent = Containers::find(mTabOrder.begin(), mTabOrder.end(), args.window); OC_ASSERT(itCurrent != mTabOrder.end()); WidgetList::iterator itFocus = itCurrent; CEGUI::Window* newWidget = 0; do { if (args.sysKeys & CEGUI::Shift) { // Set previous if (itFocus == mTabOrder.begin()) itFocus = mTabOrder.end(); --itFocus; } else { // Set next ++itFocus; if (itFocus == mTabOrder.end()) itFocus = mTabOrder.begin(); } newWidget = *itFocus; } while ((!newWidget->isVisible() || newWidget->isDisabled() || newWidget->getProperty("ReadOnly") == "True" ) && itFocus != itCurrent); newWidget->activate(); // Make sure active widget will be visible if (mScrollablePane) { CEGUI::Window* w = newWidget; CEGUI::Vector2 widgetOffset(0, 0); do { widgetOffset += w->getPosition().asAbsolute(w->getParentPixelSize()); w = w->getParent(); } while (w != mScrollablePane && w != 0); float32 scrollViewTop = mScrollablePane->getContentPaneArea().getSize().d_height * mScrollablePane->getVerticalScrollPosition(); float32 scrollViewBottom = scrollViewTop + mScrollablePane->getClipRect().getHeight(); if (widgetOffset.d_y < scrollViewTop || widgetOffset.d_y + newWidget->getPixelSize().d_height > scrollViewBottom) { // We need to scroll mScrollablePane->setVerticalScrollPosition(widgetOffset.d_y / mScrollablePane->getContentPaneArea().getSize().d_height); } } return true; } return false; }
bool GUIManager::handleOptionsVisibility ( CEGUI::EventArgs const & ) { CEGUI::Window *dsFrame = CEGUI::WindowManager::getSingleton().getWindow( "Sheet/DatasetFrame"); std::string prop = dsFrame->getProperty("Visible").c_str(); if (prop == "False") dsFrame->show(); else dsFrame->hide(); return true; }
/*********************************************************** handle windows enter event ***********************************************************/ bool ContainerBox::HandleInventoryEnter (const CEGUI::EventArgs& e) { const CEGUI::MouseEventArgs& dd_args = static_cast<const CEGUI::MouseEventArgs&>(e); unsigned int id = dd_args.window->getID(); CEGUI::Window* tmp = dd_args.window; std::string ttip = tmp->getProperty("Tooltip").c_str(); if(ttip == "") { CEGUI::String tmpstr((const unsigned char *)InventoryHandler::getInstance()->GetItemDescription(id).c_str()); tmp->setProperty("Tooltip", tmpstr); } return true; }
int GamePlate::getPoints() { CEGUI::Window* window = d_window->getChild("ImageWindowObject"); CEGUI::String objectImage = window->getProperty("Image"); if(objectImage.compare(HUDDemo::s_imageNameBread) == 0) return 2; else if(objectImage.compare(HUDDemo::s_imageNamePoo) == 0) return -6; else if(objectImage.compare(HUDDemo::s_imageNameSteak) == 0) return -13; else if(objectImage.compare(HUDDemo::s_imageNamePrizza) == 0) return 3; else if(objectImage.compare(HUDDemo::s_imageNameVegPeople) == 0) return 1; else if(objectImage.compare(HUDDemo::s_imageNameVegFruits) == 0) return 88; return 0; }