bool GUIApplication::onConsoleClicked(const CEGUI::EventArgs& a) { Editbox* inputBox = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("console/input")); //m_guiContext->setInputCaptureWindow(inputBox); inputBox->activate(); return true; }
bool GuiConfig::HandleConfigOK(const CEGUI::EventArgs& e) { Editbox* playerName = static_cast<Editbox*>(winMgr.getWindow("CONFIGPLAYERNAME")); /* if (_stricmp(GConfig->GetPlayerName(), playerName->getText().c_str())) { if (GClientGame) { GClientGame->SendMessageNick(playerName->getText().c_str()); } } */ bool bScreenConfigHasChanged = false; { Checkbox *pcb = (Checkbox*)winMgr.getWindow("CHKBFS"); bScreenConfigHasChanged |= GConfig->IsEnable("CHKBFS") != pcb->isSelected(); GConfig->SetEnable("CHKBFS", (int)pcb->isSelected() ); } { Checkbox *pcb = (Checkbox*)winMgr.getWindow("CHKBVSYNC"); bScreenConfigHasChanged |= GConfig->IsEnable("CHKBVSYNC") != pcb->isSelected(); GConfig->SetEnable("CHKBVSYNC", (int)pcb->isSelected() ); } GConfig->SetPlayerName(playerName->getText().c_str()); // Resolution Combobox* resCB = static_cast<Combobox*>(winMgr.getWindow("RESOLUTION")); ListboxItem *resib = resCB->getSelectedItem(); if (resib) { int selres = resCB->getItemIndex(resib); bScreenConfigHasChanged |= (GConfig->GetQuality("Width") != mResolutions[selres].width); bScreenConfigHasChanged |= (GConfig->GetQuality("Height") != mResolutions[selres].height); GConfig->SetQuality("Width", mResolutions[selres].width); GConfig->SetQuality("Height", mResolutions[selres].height); } if (bScreenConfigHasChanged) { tstring onoksschanged = ".00 "; onoksschanged += GLoc->GetString("OK"); ((ZProtoGUI*)GProtoGui)->mMessageboxGui.Show(GLoc->GetString("SCREENCHANGED"), onoksschanged.c_str(), mOnOK); Hide(); } else { mOnOK(); Hide(); } return true; }
bool Demo6Sample::handleDeleteColumn(const CEGUI::EventArgs& e) { using namespace CEGUI; // get access to the widgets that contain details about the column to delete MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList")); Editbox* idbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/DelColIDBox")); // obtain the id of the column to be deleted CEGUI::uint id = atoi(idbox->getText().c_str()); // attempt to delete the column, ignoring any errors. try { mcl->removeColumnWithID(id); } catch (InvalidRequestException) {} // reset the delete column ID box. idbox->setText(""); // event was handled. return true; }
void CEGUIEditbox::Init (const string& widgetName) { ScrollWidget::Init(widgetName); const string windowName = m_manager->GetWindowName(); // Get the root window Window *rootWindow = CEGUI::System::getSingleton().getGUISheet(); // Get the parent window. No point in searching all windows. Window *window = rootWindow->getChild(windowName); // Get recursively the widget, this will handle tabs. Window *widget = window->getChildRecursive(widgetName); orxASSERT(widget != NULL); /* * Static cast is now safe as it is guarded by assert. Assert will be * active only in debug build so -fno-rtti can be used for release build. */ orxASSERT( typeid(*widget) == typeid(Editbox) ); Editbox *editbox = static_cast<Editbox *> (widget); editbox->subscribeEvent (Editbox::EventTextAccepted, Event::Subscriber (&CEGUIEditbox::OnTextAccepted, this)); //! @todo Handle mouse events. m_ceEditbox = editbox; }
/************************************************************************* Handler for mouse button down events in editbox *************************************************************************/ bool Combobox::editbox_MouseDownHandler(const EventArgs& e) { // only interested in left button if (((const MouseEventArgs&)e).button == LeftButton) { Editbox* editbox = getEditbox(); // if edit box is read-only, show list if (editbox->isReadOnly()) { ComboDropList* droplist = getDropList(); // if there is an item with the same text as the edit box, pre-select it ListboxItem* item = droplist->findItemWithText(editbox->getText(), 0); if (item) { droplist->setItemSelectState(item, true); droplist->ensureItemIsVisible(item); } // no matching item, so select nothing else { droplist->clearAllSelections(); } showDropList(); return true; } } return false; }
bool Demo6Sample::handleDeleteRow(const CEGUI::EventArgs& e) { using namespace CEGUI; // get access to the widgets that contain details about the row to delete. MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList")); Editbox* idxbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/DelRowIdxBox")); // get index of row to delete. CEGUI::uint idx = atoi(idxbox->getText().c_str()); // attempt to delete the row, ignoring any errors. try { mcl->removeRow(idx); } catch (InvalidRequestException) {} // clear the row index box idxbox->setText(""); // event was handled. return true; }
bool Demo6Sample::handleDeleteRow(const CEGUI::EventArgs& args) { using namespace CEGUI; // get access to the widgets that contain details about the row to delete. MultiColumnList* mcl = static_cast<MultiColumnList*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("MainList")); Editbox* idxbox = static_cast<Editbox*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("ControlPanel/RowControl/DelRowIdxBox")); // get index of row to delete. CEGUI::uint idx = atoi(idxbox->getText().c_str()); // attempt to delete the row, ignoring any errors. CEGUI_TRY { mcl->removeRow(idx); } CEGUI_CATCH (InvalidRequestException) {} // clear the row index box idxbox->setText(""); // event was handled. return true; }
bool Demo6Sample::handleDeleteColumn(const CEGUI::EventArgs& args) { using namespace CEGUI; // get access to the widgets that contain details about the column to delete MultiColumnList* mcl = static_cast<MultiColumnList*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("MainList")); Editbox* idbox = static_cast<Editbox*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("ControlPanel/ColumnPanel/DelColIDBox")); // obtain the id of the column to be deleted CEGUI::uint id = atoi(idbox->getText().c_str()); // attempt to delete the column, ignoring any errors. CEGUI_TRY { mcl->removeColumnWithID(id); } CEGUI_CATCH (InvalidRequestException) {} // reset the delete column ID box. idbox->setText(""); // event was handled. return true; }
bool TreeDemoSample::handleEventSelectionChanged(const CEGUI::EventArgs& args) { using namespace CEGUI; const TreeEventArgs& treeArgs = static_cast<const TreeEventArgs&>(args); Editbox *editBox = (Editbox *)TreeDemoWindow->getChild(EditBoxID); // Three different ways to get the item selected. // TreeCtrlEntry *selectedItem = theTree->getFirstSelectedItem(); // the first selection in the list (may be more) // TreeCtrlEntry *selectedItem = theTree->getLastSelectedItem(); // the last (time-wise) selected by the user TreeItem *selectedItem = treeArgs.treeItem; // the actual item that caused this event if (selectedItem) { #if 0 // A convoluted way to get the item text. // Just here to test findFirstItemWithText. selectedItem = theTree->findFirstItemWithText(selectedItem->getText()); if (selectedItem) editBox->setText("Selected: " + selectedItem->getText()); else editBox->setText("findItemWithText failed!"); #else // The simple way to do it. editBox->setText("Selected: " + selectedItem->getText()); #endif } else editBox->setText("None Selected"); return true; }
void GVEvent::UpdateBaseAttrDisplay(const UIData::tagGoodAttr* pGoodAttr) { if(!pGoodAttr) return; //物品ID Editbox *pEditBox = GetEditbox("GoodsTreeFrame/BaseProperty/EditIndex"); if(pEditBox) { pEditBox->setText(PropertyHelper::intToString(pGoodAttr->dwIndex)); } //物品名称 pEditBox = GetEditbox("GoodsTreeFrame/BaseProperty/EditDisName"); if(pEditBox) { //std::wstring wstr()); pEditBox->setText(pGoodAttr->strName.c_str()); } //物品价格 pEditBox = GetEditbox("GoodsTreeFrame/BaseProperty/EditPrice"); if(pEditBox) pEditBox->setText(PropertyHelper::intToString(pGoodAttr->dwValue)); //物品原始名称 pEditBox = GetEditbox("GoodsTreeFrame/BaseProperty/EditOgriName"); if(pEditBox) pEditBox->setText(pGoodAttr->strOrigName.c_str()); //物品是否存数据库 Combobox* cbbo = GetCombobox("GoodsTreeFrame/BaseProperty/CombBoxIsDB"); if(pGoodAttr->bSave == false) cbbo->setItemSelectState(1,true); else cbbo->setItemSelectState(size_t(0),true); //物品类型 cbbo = GetCombobox("GoodsTreeFrame/BaseProperty/CombboxGoodType"); cbbo->setItemSelectState(pGoodAttr->dwType,true); }
/************************************************************************* Activate the edit box component of the Combobox. *************************************************************************/ void Combobox::activateEditbox(void) { Editbox* editbox = getEditbox(); if (!editbox->isActive()) { editbox->activate(); } }
bool TreeDemoSample::handleEventBranchClosed(const CEGUI::EventArgs& args) { using namespace CEGUI; const TreeEventArgs& treeArgs = static_cast<const TreeEventArgs&>(args); Editbox *editBox = (Editbox *)TreeDemoWindow->getChild(EditBoxID); editBox->setText("Closed: " + treeArgs.treeItem->getText()); return true; }
//----------------------------------------------------------------------------// void FalagardEditbox::setupVisualString(String& visual) const { Editbox* w = static_cast<Editbox*>(d_window); if (w->isTextMasked()) visual.assign(w->getText().length(), w->getMaskCodePoint()); else visual.assign(w->getTextVisual()); }
bool GUIApplication::onConsoleInput(const CEGUI::EventArgs&) { Editbox* inputBox = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("console/input")); String consoleCommand = inputBox->getText(); inputBox->setText(""); doConsoleCommand(consoleCommand); return true; }
bool GUI::handleKeyDown(const EventArgs& eventArgs) { // get the text entry editbox Editbox *editbox = static_cast<Editbox *> (guiConsole->getChild(EntryBoxID)); switch (static_cast<const KeyEventArgs&> (eventArgs).scancode) { case Key::ArrowUp: historyPosition = ceguimax(historyPosition - 1, -1); if (historyPosition >= 0) { editbox->setText(history[historyPosition]); editbox->setCaratIndex(static_cast<size_t> (-1)); } else editbox->setText(""); editbox->activate(); break; case Key::ArrowDown: historyPosition = ceguimin(historyPosition + 1, static_cast<int> (history.size())); if (historyPosition < static_cast<int> (history.size())) { editbox->setText(history[historyPosition]); editbox->setCaratIndex(static_cast<size_t> (-1)); } else editbox->setText(""); editbox->activate(); break; default: return false; } return true; }
bool Demo6Sample::handleAddColumn(const CEGUI::EventArgs& e) { using namespace CEGUI; // get access to the widgets that contain details about the column to add MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList")); Editbox* idbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/NewColIDBox")); Editbox* widthbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/NewColWidthBox")); Editbox* textbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/NewColTextBox")); // get ID for new column CEGUI::uint id = atoi(idbox->getText().c_str()); // get width to use for new column (in pixels) float width = atof(widthbox->getText().c_str()); // get column label text String text = textbox->getText(); // re-set the widget contents idbox->setText(""); widthbox->setText(""); textbox->setText(""); // ensure a minimum width of 10 pixels if (width < 10.0f) width = 10.0f; // finally, add the new column to the list. mcl->addColumn(text, id, cegui_absdim(width)); // event was handled. return true; }
bool TreeSample::handleEventSubtreeCollapsed(const CEGUI::EventArgs& args) { using namespace CEGUI; const ItemViewEventArgs& treeArgs = static_cast<const ItemViewEventArgs&>(args); Editbox *editBox = (Editbox *)d_rootWindow->getChild(EditBoxID); TreeWidget* tree = static_cast<TreeWidget*>(treeArgs.window); StandardItem* collapsed_item = tree->getModel()->getItemForIndex(treeArgs.d_index); editBox->setText("Closed: " + collapsed_item->getText()); return true; }
void Spinner::onActivated(ActivationEventArgs& e) { if (!isActive()) { Window::onActivated(e); Editbox* editbox = getEditbox(); if (!editbox->isActive()) { editbox->activate(); } } }
void Spinner::onTextInputModeChanged(WindowEventArgs& e) { Editbox* editbox = getEditbox(); // update edit box text to reflect new mode. // mute to save doing unnecessary events work. bool wasMuted = editbox->isMuted(); editbox->setMutedState(true); // Update text with new value. editbox->setText(getTextFromValue()); // restore previous mute state. editbox->setMutedState(wasMuted); fireEvent(EventTextInputModeChanged, e, EventNamespace); }
void Spinner::onTextChanged(WindowEventArgs& e) { Editbox* editbox = getEditbox(); // update only if needed if (editbox->getText() != d_text) { // done before doing base class processing so event subscribers see // 'updated' version. editbox->setText(d_text); e.handled = true; Window::onTextChanged(e); } }
CEditBoxString(int id, CEGUI::Window *pParent, float fButtonSize, const CEGUI::String &sTitle, std::string &sstring) : CEditBoxBase(id, pParent, fButtonSize, sTitle), m_sString(sstring) { using namespace CEGUI; Editbox *pEditbox = dynamic_cast<Editbox*>(m_pWindow-> createChild("OgreTray/Editbox", "EditString")); pEditbox->setPosition(UVector2(UDim(0, 0), UDim(0, 0))); pEditbox->setSize(USize(UDim(1, 0), UDim(0, fButtonSize))); pEditbox->setText(m_sString.c_str()); m_pEditbox = pEditbox; }
/************************************************************************* Handler for when text changes *************************************************************************/ void Combobox::onTextChanged(WindowEventArgs& e) { Editbox* editbox = getEditbox(); // update ourselves only if needed (prevents perpetual event loop & stack overflow) if (editbox->getText() != getText()) { // done before doing base class processing so event subscribers see 'updated' version of this. editbox->setText(getText()); ++e.handled; selectListItemWithEditboxText(); Window::onTextChanged(e); } }
//----------------------------------------------------------------------------// size_t FalagardEditbox::getCaretIndex(const String& visual_text) const { Editbox* w = static_cast<Editbox*>(d_window); size_t caretIndex = w->getCaretIndex(); #ifdef CEGUI_BIDI_SUPPORT // the char before the caret bidi type bool currCharIsRtl = false; if (!visual_text.empty() && caretIndex > 0) { size_t curCaretIndex = w->getCaretIndex(); BidiCharType charBeforeCaretType = w->getBidiVisualMapping()-> getBidiCharType(visual_text[curCaretIndex - 1]); // for neutral chars you decide by the char after for (; BCT_NEUTRAL == charBeforeCaretType && (visual_text.size() > curCaretIndex); curCaretIndex++) { charBeforeCaretType = w->getBidiVisualMapping()-> getBidiCharType(visual_text[curCaretIndex - 1]); } currCharIsRtl = (BCT_RIGHT_TO_LEFT == charBeforeCaretType); } const bool isFirstChar = caretIndex == 0; // the pos is by the char before if (!isFirstChar) caretIndex--; // we need to find the caret pos by the logical to visual map if (w->getBidiVisualMapping()->getV2lMapping().size() > caretIndex) caretIndex = w->getBidiVisualMapping()->getL2vMapping()[caretIndex]; // for non RTL char - the caret pos is after the char if (!currCharIsRtl) caretIndex++; // if first char is not rtl - we need to stand at the start of the line if (isFirstChar) { bool firstCharRtl = !visual_text.empty() && (BCT_RIGHT_TO_LEFT == w->getBidiVisualMapping()-> getBidiCharType(visual_text[0])); if (!firstCharRtl) caretIndex--; } #else CEGUI_UNUSED(visual_text); #endif return caretIndex; }
void GUIApplication::hudGotFocus() { AnimationManager& animManager = AnimationManager::getSingleton(); for (Window* w : m_animHideTargets) { if (!w->isVisible()) continue; AnimationInstance* myAnimInstance = animManager.instantiateAnimation("AreaAnimationShow"); myAnimInstance->setTargetWindow(w); myAnimInstance->start(); } m_animHideTargets.clear(); m_guiContext->getRootWindow()->getChild("console")->show(); Editbox* inputBox = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("console/input")); inputBox->activate(); }
bool GUIApplication::onSendBtnClicked(const EventArgs& args) { Window* myOutput = m_guiContext->getRootWindow()->getChild("chatWindow/output"); MultiLineEditbox* realOutput = static_cast<MultiLineEditbox*>(myOutput); Editbox* realInput = static_cast<Editbox*>(m_guiContext->getRootWindow()->getChild("chatWindow/input")); if (realOutput && realInput) { String newLine = realInput->getText(); if (newLine.empty()) newLine = "You clicked me!"; else { RemotePeersManager::getManager()->sendChatMessage(newLine.c_str()); } realOutput->appendText(newLine); realInput->setText(""); } return true; }
/************************************************************************* Handler for selections made in the drop-list *************************************************************************/ bool Combobox::droplist_SelectionAcceptedHandler(const EventArgs& e) { // copy the text from the selected item into the edit box ListboxItem* item = ((ComboDropList*)((WindowEventArgs&)e).window)->getFirstSelectedItem(); if (item) { Editbox* editbox = getEditbox(); // Put the text from the list item into the edit box editbox->setText(item->getText()); // select text if it's editable, and move caret to end if (!isReadOnly()) { editbox->setSelection(0, item->getText().length()); editbox->setCaretIndex(item->getText().length()); } editbox->setCaretIndex(0); editbox->activate(); // fire off an event of our own WindowEventArgs args(this); onListSelectionAccepted(args); } return true; }
/////////////////////////////////////////////////////////////////////////////////////////////// //Network Transport 20120618(¿ù) /////////////////////////////////////////////////////////////////////////////////////////////// bool GUILogin::handleSubmit(const CEGUI::EventArgs&) { using namespace CEGUI; // get the text entry editbox Editbox* editboxName = static_cast<Editbox*>(d_root->getChild("GameIDInput")); // get text out of the editbox String edit_text(editboxName->getText()); if(edit_text.empty()) return false; Editbox* editboxPassword = static_cast<Editbox*>(d_root->getChild("PasswordInput")); // get text out of the editbox String edit_text2(editboxPassword->getText()); if(edit_text.empty()) return false; if(edit_text2.empty()) return false; SFProtobufPacket<SFPacketStore::Login> PktLogin(CGSF::Login); // PktLogin.SetOwnerSerial(g_engine->GetLocalID()); PktLogin.GetData().set_username(edit_text.c_str()); PktLogin.GetData().set_password(edit_text2.c_str()); g_pCasualGameManager->GetNetwork()->TCPSend(&PktLogin); editboxName->setText(""); editboxPassword->setText(""); return true; }
bool GUI::handleSubmit(const EventArgs& eventArgs) { // get the text entry editbox Editbox *editbox = static_cast<Editbox *> (guiConsole->getChild(EntryBoxID)); // get text out of the editbox CEGUI::String edit_text(editbox->getText()); // if the string is not empty if (!edit_text.empty()) { // add this entry to the command history buffer history.push_back(edit_text); // reset history position historyPosition = history.size(); // this is the member function that the agent uses to send the text to the brain agent->handleText(editbox->getText().c_str()); // erase text in text entry box. editbox->setText(""); } // re-activate the text entry box editbox->activate(); return true; }
void Spinner::initialiseComponents(void) { // get all the component widgets PushButton* increaseButton = getIncreaseButton(); PushButton* decreaseButton = getDecreaseButton(); Editbox* editbox = getEditbox(); // setup component controls increaseButton->setWantsMultiClickEvents(false); increaseButton->setMouseAutoRepeatEnabled(true); decreaseButton->setWantsMultiClickEvents(false); decreaseButton->setMouseAutoRepeatEnabled(true); // perform event subscriptions. increaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleIncreaseButton, this)); decreaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleDecreaseButton, this)); editbox->subscribeEvent(Window::EventTextChanged, Event::Subscriber(&Spinner::handleEditTextChange, this)); // final initialisation setTextInputMode(Integer); setCurrentValue(0.0f); performChildWindowLayout(); }
bool Demo6Sample::handleSetItem(const CEGUI::EventArgs& e) { using namespace CEGUI; // get access to the widgets that contain details about the item to be modified MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList")); Editbox* idbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/SetItemIDBox")); Editbox* rowbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/SetItemRowBox")); Editbox* textbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/SetItemTextBox")); // get ID of column to be affected CEGUI::uint id = atoi(idbox->getText().c_str()); // get index of row to be affected CEGUI::uint row = atoi(rowbox->getText().c_str()); // get new text for item String text = textbox->getText(); // reset input boxes idbox->setText(""); rowbox->setText(""); textbox->setText(""); // create a new ListboxTextItem using the new text string ListboxTextItem* item = new ListboxTextItem(text); // set the selection brush to be used for this item. item->setSelectionBrushImage(&ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("MultiListSelectionBrush")); // attempt to set the new item in place try { mcl->setItem(item, id, row); } // something went wrong, so cleanup the ListboxTextItem. catch (InvalidRequestException) { delete item; } // event was handled. return true; }