示例#1
0
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;
}
示例#2
0
文件: guifile.cpp 项目: sgynn/base
		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;
		}
示例#3
0
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;

}
示例#4
-25
  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()));
      }
    }
  }