bool Zonsole::handleInput(const EventArgs &e) { // get string from input field String s = inputWnd->getText(); if (s.length() > 0) { // add message to output buffer ListboxTextItem *i = new ListboxTextItem(s); Listbox *l = (Listbox *)bufferWnd; l->addItem(i); handleCmd(s.c_str()); // make sure the scrollbar stays at the bottom Scrollbar *scroll = (Scrollbar *)bufferWnd->getChild("Zonsole/Buffer__auto_vscrollbar__"); scroll->setScrollPosition(scroll->getDocumentSize()); // clear the input field inputWnd->setText("\0"); if (autoCompleteWnd->isVisible()) autoCompleteWnd->hide(); } return true; }
Rect FalagardListbox::getListRenderArea(void) const { Listbox* lb = (Listbox*)d_window; // get WidgetLookFeel for the assigned look. const WidgetLookFeel& wlf = getLookNFeel(); bool v_visible = lb->getVertScrollbar()->isVisible(true); bool h_visible = lb->getHorzScrollbar()->isVisible(true); // if either of the scrollbars are visible, we might want to use another text rendering area if (v_visible || h_visible) { String area_name("ItemRenderingArea"); if (h_visible) { area_name += "H"; } if (v_visible) { area_name += "V"; } area_name += "Scroll"; if (wlf.isNamedAreaDefined(area_name)) { return wlf.getNamedArea(area_name).getArea().getPixelRect(*lb); } } // default to plain ItemRenderingArea return wlf.getNamedArea("ItemRenderingArea").getArea().getPixelRect(*lb); }
Listbox* ListboxFactory::create (Control* par, const ListboxParameters& parms, const ustring& name) { Listbox* result = new Listbox (parms); result->set_name (name); result->init_control (par); return result; }
void CEGUIListbox::Init (Window* widget) { Listbox *listbox = reinterpret_cast<Listbox *> (widget); listbox->subscribeEvent (Window::EventMouseClick, Event::Subscriber (&CEGUIListbox::OnMouseClick, this)); m_ceListbox = listbox; m_widgetName = new char[strlen (widget->getName().c_str()) + 1]; strcpy (m_widgetName, widget->getName().c_str()); }
void CEGUIListbox::Init (const orxSTRING widgetName) { const orxSTRING windowName = m_manager->GetName (); Window *rootWindow = CEGUI::System::getSingleton ().getGUISheet (); Window *window = rootWindow->getChild (windowName); Listbox *listbox = reinterpret_cast<Listbox *> ( window->getChild (widgetName)); listbox->subscribeEvent (Window::EventMouseClick, Event::Subscriber (&CEGUIListbox::OnMouseClick, this)); m_ceListbox = listbox; m_widgetName = new char[strlen (widgetName) + 1]; strcpy (m_widgetName, widgetName); }
Control* createListbox(const Loader& e) { int width = e.attribute("width", 0); int height= e.attribute("height", 0); int event = e.attribute("event", 0); Listbox* list = new Listbox(width, height, e.style(), event); // Child items for(XML::iterator i=e->begin(); i!=e->end(); ++i) { if(strcmp(i->name(), "item")==0) { const char* itm = i->text()? i->text(): i->attribute("name"); list->addItem(itm, i->attribute("selected",0)>0); } } return list; }
bool GUILobby::OnEnter() { CEGUI::Window* parent = NULL; // decide where to attach the console main window parent = parent ? parent : CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow(); // attach this window if parent is valid if (parent) parent->addChild(d_root); Listbox* lbox = static_cast<Listbox*>(d_root->getChild("RoomList")); lbox->resetList(); return true; }
void FalagardListbox::render() { Listbox* lb = (Listbox*)d_window; // render frame and stuff before we handle the items cacheListboxBaseImagery(); // // Render list items // Vector3 itemPos; Size itemSize; Rect itemClipper, itemRect; float widest = lb->getWidestItemWidth(); // calculate position of area we have to render into Rect itemsArea(getListRenderArea()); // set up some initial positional details for items itemPos.d_x = itemsArea.d_left - lb->getHorzScrollbar()->getScrollPosition(); itemPos.d_y = itemsArea.d_top - lb->getVertScrollbar()->getScrollPosition(); itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ(); float alpha = lb->getEffectiveAlpha(); // loop through the items size_t itemCount = lb->getItemCount(); for (size_t i = 0; i < itemCount; ++i) { ListboxItem* listItem = lb->getListboxItemFromIndex(i); itemSize.d_height = listItem->getPixelSize().d_height; // allow item to have full width of box if this is wider than items itemSize.d_width = ceguimax(itemsArea.getWidth(), widest); // calculate destination area for this item. itemRect.d_left = itemPos.d_x; itemRect.d_top = itemPos.d_y; itemRect.setSize(itemSize); itemClipper = itemRect.getIntersection(itemsArea); // skip this item if totally clipped if (itemClipper.getWidth() == 0) { itemPos.d_y += itemSize.d_height; continue; } // draw this item listItem->draw(lb->getRenderCache(), itemRect, itemPos.d_z, alpha, &itemClipper); // update position ready for next item itemPos.d_y += itemSize.d_height; } }
Listbox* PanelContainer::makeListbox(Ogre::Real x, Ogre::Real y, size_t width, size_t height, const vector<Ogre::String>& items, unsigned int nbDisplayedElements) { Listbox* listBox = new Listbox(x, y, width, height, items, nbDisplayedElements, this); listBox->setBackgroundImageButtons(getPanelColors()->listboxButtonPreviousOveredSpriteName, getPanelColors()->listboxButtonPreviousNotOveredSpriteName, getPanelColors()->listboxButtonPreviousInactiveSpriteName, getPanelColors()->listboxButtonPreviousClickedSpriteName, getPanelColors()->listboxButtonNextOveredSpriteName, getPanelColors()->listboxButtonNextNotOveredSpriteName, getPanelColors()->listboxButtonNextInactiveSpriteName, getPanelColors()->listboxButtonNextClickedSpriteName); addItem(listBox); return listBox; }
bool GUILobby::Notify(BasePacket* pPacket) { switch(pPacket->GetPacketID()) { case CGSF::ChatRes: { SFProtobufPacket<SFPacketStore::ChatRes>* pChatRes = (SFProtobufPacket<SFPacketStore::ChatRes>*)pPacket; std::string name = pChatRes->GetData().sender(); std::string szMessage = pChatRes->GetData().message(); // get the text entry editbox //Editbox* editbox = static_cast<Editbox*>(d_root->getChild(EntryBoxID)); // get history window // MultiLineEditbox* history = static_cast<MultiLineEditbox*>(d_root->getChild(HistoryID)); // append new text to history output //history->setText(history->getText() + szMessage); // scroll to bottom of history output //history->setCaretIndex(static_cast<size_t>(-1)); } break; case CGSF::RoomList: { SFProtobufPacket<SFPacketStore::RoomList>* pRoomList = (SFProtobufPacket<SFPacketStore::RoomList>*)pPacket; Listbox* lbox = static_cast<Listbox*>(d_root->getChild("RoomList")); lbox->resetList(); for(int i=0; i < pRoomList->GetData().info_size(); i++) { const SFPacketStore::RoomList::RoomInfo& info = pRoomList->GetData().info(i); //_PeerInfo PeerInfo; //SF_GETPACKET_ARG(&PeerInfo, Peer.info(), _PeerInfo); MyListItem* item = new MyListItem(info.roomname().c_str()); item->setSelectionColours(CEGUI::Colour(0.3f, 0.7f, 1.0f, 1.0f)); item->roomIndex = info.roomindex(); lbox->addItem(item); if(lbox->getType().compare("WindowsLook/Listbox") == 0) { item->setTextColours(CEGUI::Colour(0.0f, 0.0f, 0.0f, 1.0f)); } } } break; case CGSF::EnterRoom: { SFProtobufPacket<SFPacketStore::EnterRoom>* pEnterRoom = (SFProtobufPacket<SFPacketStore::EnterRoom>*)pPacket; } break; } return true; }
void refreshPageList() { Window* root = d_guiContext->getRootWindow(); // Check if the windows exists Listbox* lbox = 0; TabControl* tc = 0; if (root->isChild("Frame/TabControl/Page1/PageList")) { lbox = static_cast<Listbox*>(root->getChild( "Frame/TabControl/Page1/PageList")); } if (root->isChild("Frame/TabControl")) { tc = static_cast<TabControl*>(root->getChild( "Frame/TabControl")); } if (lbox && tc) { lbox->resetList(); for (size_t i = 0; i < tc->getTabCount(); i++) { lbox->addItem(new MyListItem( tc->getTabContentsAtIndex(i)->getName())); } } }