bool Demo6Sample::handleAddRow(const CEGUI::EventArgs&)
{
    using namespace CEGUI;

    // get access to the widgets that contain details about the row to add
    MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList"));
    Editbox* idbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/RowColIDBox"));
    Editbox* textbox = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/ColumnPanel/RowTextBox"));

    // get the ID of the initial column item to set
    CEGUI::uint id = atoi(idbox->getText().c_str());
    // get the text that is to be set initially into the specified column of the new row
    String text = textbox->getText();

    // reset input boxes
    idbox->setText("");
    textbox->setText("");

    // construct a new ListboxTextItem with the required string
    ListboxTextItem* item = new ListboxTextItem(text);
    // set the selection brush to use for this item.
    item->setSelectionBrushImage(&ImagesetManager::getSingleton().get("TaharezLook").getImage("MultiListSelectionBrush"));

    // attempt to add a new row, using the new ListboxTextItem as the initial content for one of the columns
    CEGUI_TRY
    {
        mcl->addRow(item, id);
    }
    // something went wrong, so cleanup the ListboxTextItem
    CEGUI_CATCH (InvalidRequestException)
    {
        delete item;
    }

    // event was handled.
    return true;
}
Esempio n. 2
0
void GVEvent::UpdateAddAttrDisplay(const UIData::tagGoodAttr* pGoodAttr)
{
    //更新物品附加属性显示
    if(!pGoodAttr)
        return;
    MultiColumnList* mclbox = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("GoodsTreeFrame/AddProperty/MultiColumnList"));
    if(!mclbox)
        return;
    //清空行
    mclbox->resetList();
    for(size_t size = 0 ; size < pGoodAttr->vecAddAttr.size(); ++size)
    {
        //设置每一行的值
        mclbox->addRow();
        const UIData::tagAddAttr &addAttr = pGoodAttr->vecAddAttr[size];
        mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodItemType(addAttr.wType).c_str()),0,(CEGUI::uint)size);
        mclbox->setItem(new MyListItem(PropertyHelper::boolToString(addAttr.bEnable)),1,(CEGUI::uint)size);
        mclbox->setItem(new MyListItem(PropertyHelper::boolToString(addAttr.bHide)),2,(CEGUI::uint)size);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(addAttr.lValue1)),3,(CEGUI::uint)size);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(addAttr.lValue2)),4,(CEGUI::uint)size);
    }
}
Esempio n. 3
0
void GVEvent::UpdateSuitAttrDisplay(const UIData::tagGoodAttr *pGoodAttr)
{
    //更新套装属性
    if(!pGoodAttr)
        return;
    MultiColumnList* mclbox = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("GoodsTreeFrame/GroupBoxSuitAtrr/MultiColumnList"));
    if(!mclbox)
        return;
    //清空行
    mclbox->resetList();
    for(CEGUI::uint i = 0 ; i < pGoodAttr->vecSuitAttr.size() ; ++i)
    {
        //设置每一行的值
        mclbox->addRow();
        const UIData::tagSuitAttr& suitAttr = pGoodAttr->vecSuitAttr[i];
        mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodItemType(suitAttr.wType).c_str()),0,i);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.lValue1)),1,i);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.lValue2)),2,i);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.wSuitNum)),3,i);
    }
}
Esempio n. 4
0
void handle_destination_change(){

	using namespace CEGUI;

 	struct search_param *search=&search_param;
	struct search_list_result *res;

	MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox"));


	if (SDL_dest.current_search==SRCH_COUNTRY)
	{	
		Editbox* country_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox"));
		String content=country_edit->getText();

		mcl->resetList();
		dbg(0,"Starting a country search : %s\n",content.c_str());

		search->attr.type=attr_country_all;

		// FIXME the following codeblock could be shared between country, town and street search
		search->attr.u.str=(char *)content.c_str();

		search_list_search(search->sl, &search->attr, 1);
		while((res=search_list_get_result(search->sl))) {
			ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->country->name));
			itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");

			mcl->addRow(itemListbox,0);
		}

	} else if (SDL_dest.current_search==SRCH_TOWN)
	{	
		
		Editbox* town_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox"));
		String content=town_edit->getText();


		mcl->resetList();

		if(strlen(content.c_str())<4){

		}  else {
			dbg(0,"town searching for %s\n",content.c_str());
			search->attr.type=attr_town_name;
			search->attr.u.str=(char *)content.c_str();

			search_list_search(search->sl, &search->attr, 1);
			while((res=search_list_get_result(search->sl))) {
				ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->town->name));
				itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");

				mcl->addRow(itemListbox,0);

				char x [256];
				sprintf(x,"%li",res->c->x);
				ListboxTextItem* xitem = new ListboxTextItem(x);
			
				char y [256];
				sprintf(y,"%li",res->c->y);
			
				ListboxTextItem* yitem = new ListboxTextItem(y);
			
				try
				{
					mcl->setItem(xitem, 3, mcl->getRowCount()-1);
					mcl->setItem(yitem, 4, mcl->getRowCount()-1);
				}
				// something went wrong, so cleanup the ListboxTextItem.
				catch (InvalidRequestException)
				{
// 					delete item;
				}
	
			}

		}


	} else if (SDL_dest.current_search==SRCH_STREET)
	{	
		Editbox* street_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox"));
		
		String content=street_edit->getText();
		if(strlen(content.c_str())<1){

		}  else {
			// dbg(1,"street searching for %s\n",content.c_str());
			search->attr.type=attr_street_name;
			search->attr.u.str=(char *)content.c_str();

			mcl->resetList();

			search_list_search(search->sl, &search->attr, 1);
			while((res=search_list_get_result(search->sl))) {
				ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->street->name));
				itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");

				mcl->addRow(itemListbox,0);

				char x [256];
				sprintf(x,"%li",res->c->x);
				ListboxTextItem* xitem = new ListboxTextItem(x);
			
				char y [256];
				sprintf(y,"%li",res->c->y);
			
				ListboxTextItem* yitem = new ListboxTextItem(y);
			
				try
				{
					mcl->setItem(xitem, 3, mcl->getRowCount()-1);
					mcl->setItem(yitem, 4, mcl->getRowCount()-1);
				}
				// something went wrong, so cleanup the ListboxTextItem.
				catch (InvalidRequestException)
				{
// 					delete item;
				}

	
			}
			}
	}

}
Esempio n. 5
0
bool handleItemSelect(int r)
{
	using namespace CEGUI;

	MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox"));
	
	ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0));
	ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1));
	ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2));


	Window* country_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox"));
	Window* twn_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox"));
	Window* street_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox"));

	if(SDL_dest.current_search==SRCH_COUNTRY){
		country_edit->setText(item->getText());
		twn_edit->activate();
		SDL_dest.current_search=SRCH_TOWN;
		WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");

	} else 	if(SDL_dest.current_search==SRCH_TOWN){
		twn_edit->setText(item->getText());

		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x"));
		Dest_x->setText(itemx->getText().c_str());

		Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y"));
		Dest_y->setText(itemy->getText().c_str());

		mcl->resetList();

		SDL_dest.current_search=SRCH_STREET;
		street_edit->activate();
		WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");

	} else if(SDL_dest.current_search==SRCH_STREET){
		street_edit->setText(item->getText());

		WindowManager::getSingleton().getWindow("Navit/Keyboard")->hide();

		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x"));
		Dest_x->setText(itemx->getText().c_str());

		Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y"));
		Dest_y->setText(itemy->getText().c_str());

		mcl->resetList();

		SDL_dest.current_search=SRCH_STREET;

		WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");


	} else if (SDL_dest.current_search==SRCH_NUMBER){

		struct coord pos;
		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		pos.x=atoi(itemx->getText().c_str());
		pos.y=atoi(itemy->getText().c_str());

		route_to(pos.x,pos.y);
	}

	return true;
}
Esempio n. 6
0
/*************************************************************************
    Create the windows and widgets for the demo
*************************************************************************/
void Demo6Sample::createDemoWindows(void)
{
    using namespace CEGUI;
    ListboxTextItem* itm;

    WindowManager& winMgr = WindowManager::getSingleton();
    Window* root = winMgr.getWindow("root_wnd");

    // create the main list.
    MultiColumnList* mcl = static_cast<MultiColumnList*>(winMgr.createWindow("TaharezLook/MultiColumnList", "Demo6/MainList"));
    root->addChildWindow(mcl);
    mcl->setPosition(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.1f)));
    mcl->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.8f)));

    // create frame window for control panel
    FrameWindow* fwnd = static_cast<FrameWindow*>(winMgr.createWindow("TaharezLook/FrameWindow", "Demo6/ControlPanel"));
    root->addChildWindow(fwnd);
    fwnd->setPosition(UVector2(cegui_reldim(0.53f), cegui_reldim( 0.03f)));
    fwnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    fwnd->setSize(UVector2(cegui_reldim(0.44f), cegui_reldim( 0.94f)));
    fwnd->setText("Demo 6 - Control Panel");

    // create combo-box.
    Combobox* cbbo = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "Demo6/ControlPanel/SelModeBox"));
    fwnd->addChildWindow(cbbo);
    cbbo->setPosition(UVector2(cegui_reldim(0.04f), cegui_reldim( 0.06f)));
    cbbo->setSize(UVector2(cegui_reldim(0.66f), cegui_reldim( 0.33f)));
    //cbbo->setSortingEnabled(true);

    // populate combobox with possible selection modes
    const CEGUI::Image* sel_img = &ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("MultiListSelectionBrush");
    itm = new ListboxTextItem("Full Row (Single)", 0);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Full Row (Multiple)", 1);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Full Column (Single)", 2);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Full Column (Multiple)", 3);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Single Cell (Single)", 4);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Single Cell (Multiple)", 5);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Nominated Column (Single)", 6);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Nominated Column (Multiple)", 7);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    ListboxTextItem* pStore = itm;
    itm = new ListboxTextItem("Nominated Row (Single)", 8);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    itm = new ListboxTextItem("Nominated Row (Multiple)", 9);
    itm->setSelectionBrushImage(sel_img);
    cbbo->addItem(itm);
    cbbo->setReadOnly(true);
    // Now change the text to test the sorting
    pStore->setText("Abracadabra");
    //cbbo->setSortingEnabled(false);
    cbbo->setSortingEnabled(true);
    //cbbo->handleUpdatedListItemData();

    // column control section
    Window* st = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/ColumnPanel");
    fwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.12f)));
    st->setSize(UVector2(cegui_reldim(0.96f), cegui_reldim( 0.25f)));
    st->setText("Column Control");
    st->setProperty("VertFormatting", "TopAligned");

    Window* label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label1");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("ID Code:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label2");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Width:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label3");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.44f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Caption:");

    PushButton* btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/ControlPanel/ColumnPanel/AddColButton"));
    st->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.81f), cegui_reldim( 0.32f)));
    btn->setSize(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.2f)));
    btn->setText("Add");

    Editbox* ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/NewColIDBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");
    ebox->setText("Test -- ");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/NewColWidthBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/NewColTextBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.44f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.36f), cegui_reldim( 0.2f)));
    ebox->setValidationString(".*");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label4");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.55f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("ID Code:");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/DelColIDBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.67f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/ControlPanel/ColumnPanel/DelColButton"));
    st->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.67f)));
    btn->setSize(UVector2(cegui_reldim(0.4f), cegui_reldim( 0.2f)));
    btn->setText("Delete Column");

    // Row control box
    st = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/RowControl");
    fwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.38f)));
    st->setSize(UVector2(cegui_reldim(0.96f), cegui_reldim( 0.25f)));
    st->setText("Row Control");
    st->setProperty("VertFormatting", "TopAligned");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label5");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Col ID:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label6");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.55f), cegui_reldim( 0.12f)));
    label->setText("Item Text:");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/RowColIDBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/RowTextBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.55f), cegui_reldim( 0.2f)));
    ebox->setValidationString(".*");

    btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/ControlPanel/ColumnPanel/AddRowButton"));
    st->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.81f), cegui_reldim( 0.32f)));
    btn->setSize(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.2f)));
    btn->setText("Add");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label7");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.55f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Row Idx:");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/DelRowIdxBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.67f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/ControlPanel/ColumnPanel/DelRowButton"));
    st->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.67f)));
    btn->setSize(UVector2(cegui_reldim(0.4f), cegui_reldim( 0.2f)));
    btn->setText("Delete Row");

    // set item box
    st = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/SetItemPanel");
    fwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.65f)));
    st->setSize(UVector2(cegui_reldim(0.96f), cegui_reldim( 0.25f)));
    st->setText("Item Modification");
    st->setProperty("VertFormatting", "TopAligned");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label8");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Row Idx:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label9");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Col ID:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/Label10");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.44f), cegui_reldim( 0.2f)));
    label->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.12f)));
    label->setText("Item Text:");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/SetItemRowBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/SetItemIDBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.23f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    ebox->setValidationString("\\d*");

    ebox = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "Demo6/ControlPanel/ColumnPanel/SetItemTextBox"));
    st->addChildWindow(ebox);
    ebox->setPosition(UVector2(cegui_reldim(0.44f), cegui_reldim( 0.32f)));
    ebox->setSize(UVector2(cegui_reldim(0.36f), cegui_reldim( 0.2f)));
    ebox->setValidationString(".*");

    btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/ControlPanel/ColumnPanel/SetItemButton"));
    st->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.81f), cegui_reldim( 0.32f)));
    btn->setSize(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.2f)));
    btn->setText("Set");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/RowCount");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.55f)));
    label->setSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 0.12f)));
    label->setText("Current Row Count:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/ColCount");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.67f)));
    label->setSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 0.12f)));
    label->setText("Current Column Count:");

    label = winMgr.createWindow("TaharezLook/StaticText", "Demo6/ControlPanel/SelCount");
    st->addChildWindow(label);
    label->setProperty("FrameEnabled", "false");
    label->setProperty("BackgroundEnabled", "false");
    label->setPosition(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.79f)));
    label->setSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 0.12f)));
    label->setText("Current Selected Count:");

    btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "Demo6/QuitButton"));
    fwnd->addChildWindow(btn);
    btn->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.93f)));
    btn->setSize(UVector2(cegui_reldim(0.50f), cegui_reldim( 0.05f)));
    btn->setText("Quit This Demo!");
}
Esempio n. 7
0
bool Demo6Sample::handleSelectModeChanged(const CEGUI::EventArgs& e)
{
    using namespace CEGUI;

    // get access to list
    MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList"));
    // get access to the combobox
    Combobox* combo = static_cast<Combobox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/SelModeBox"));

    // find the selected item in the combobox
    ListboxItem* item = combo->findItemWithText(combo->getText(), 0);

    // set new selection mode according to ID of selected ListboxItem
    if (item)
    {
        switch (item->getID())
        {
        case 0:
            mcl->setSelectionMode(MultiColumnList::RowSingle);
            break;

        case 1:
            mcl->setSelectionMode(MultiColumnList::RowMultiple);
            break;

        case 2:
            mcl->setSelectionMode(MultiColumnList::ColumnSingle);
            break;

        case 3:
            mcl->setSelectionMode(MultiColumnList::ColumnMultiple);
            break;

        case 4:
            mcl->setSelectionMode(MultiColumnList::CellSingle);
            break;

        case 5:
            mcl->setSelectionMode(MultiColumnList::CellMultiple);
            break;

        case 6:
            mcl->setSelectionMode(MultiColumnList::NominatedColumnSingle);
            break;

        case 7:
            mcl->setSelectionMode(MultiColumnList::NominatedColumnMultiple);
            break;

        case 8:
            mcl->setSelectionMode(MultiColumnList::NominatedRowSingle);
            break;

        case 9:
            mcl->setSelectionMode(MultiColumnList::NominatedRowMultiple);
            break;

        default:
            mcl->setSelectionMode(MultiColumnList::RowSingle);
            break;

        }
    }

    // event was handled.
    return true;
}
Esempio n. 8
0
  UiTest(const uvec2 & )  {
    Gui::init(uvec2(100, 200));
    gameList = Fics::GameSummary::parseList(Platform::getResourceString(Resource::MISC_GAMELIST_TXT));
    try {
      WindowManager & wmgr = WindowManager::getSingleton();
      rootWindow = wmgr.createWindow("DefaultWindow", "root");
      System::getSingleton().getDefaultGUIContext().setRootWindow(rootWindow);
      rootWindow->addChild(wmgr.loadLayoutFromFile("Login.layout"));


      //rb->setSelected(tc->getTabPanePosition() == TabControl::Top);
      //rb->subscribeEvent(
      //  RadioButton::EventSelectStateChanged,
      //  Event::Subscriber(&TabControlDemo::handleTabPanePos, this));
      //    bool handleTabPanePos(const EventArgs& e)
      //dumpWindows(rootWindow);
      rootWindow->getChild("LoginWindow/Login")->
        subscribeEvent(PushButton::EventClicked, [&](const EventArgs& e) -> bool {
          return true;
        });

#if 0
      rootWindow->addChild(wmgr.loadLayoutFromFile("TabControl.layout"));
      TabControl* tc = static_cast<TabControl*>(rootWindow->getChild("TabControl"));

      //// Add some pages to tab control
      tc->addTab(wmgr.loadLayoutFromFile("TabPage1.layout"));
      tc->addTab(wmgr.loadLayoutFromFile("TabPage2.layout"));

      MultiColumnList* mcl = static_cast<MultiColumnList*>(rootWindow->getChild("TabControl/Page1/MultiColumnList"));

      //MultiColumnList* mcl = static_cast<CEGUI::MultiColumnList*>(
      //  wmgr.createWindow("TaharezLook/MultiColumnList", "WidgetPropertiesDisplay")
      //);
      //Create the properties display window
      //mcl->setSize(CEGUI::USize(cegui_reldim(0.9f), cegui_reldim(0.9f)));
      //mcl->setPosition(CEGUI::UVector2(cegui_reldim(0.05f), cegui_reldim(0.05f)));
      //rootWindow->addChild(mcl);
      dumpWindows(rootWindow);



      //mcl->setShowHorzScrollbar(false);
      //mcl->setUserColumnDraggingEnabled(false);
      //mcl->setUserColumnSizingEnabled(true);

      //mcl->addColumn("Name", 0, cegui_reldim(0.45f));
      //mcl->addColumn("Type ", 1, cegui_reldim(0.25f));
      //mcl->addColumn("Value", 2, cegui_reldim(0.8f));


      //d_widgetPropertiesDisplayWindow->setSortColumnByID(0);
      //d_widgetPropertiesDisplayWindow->setSortDirection(CEGUI::ListHeaderSegment::Ascending);

      mcl->addColumn("Id", 0, cegui_reldim(0.05f));
      mcl->addColumn("Type", 1, cegui_reldim(0.07f));
      mcl->addColumn("Player (White)", 2, cegui_reldim(0.15f));
      mcl->addColumn("Rating", 3, cegui_reldim(0.07f));
      mcl->addColumn("Player (Black)", 4, cegui_reldim(0.15f));
      mcl->addColumn("Rating", 5, cegui_reldim(0.07f));
      mcl->addColumn("Private", 6, cegui_reldim(0.05f));
      mcl->addColumn("Rated", 7, cegui_reldim(0.05f));
      for (int i = 0; i < gameList.size(); ++i) {
        Fics::GameSummary & g = gameList[i];
        
        mcl->addRow();
        mcl->setItem(new ListboxTextItem(Platform::format("%d", g.id)), 0, i);
        mcl->setItem(new ListboxTextItem(g.private_ ? "Y" : "N"), 6, i);
        mcl->setItem(new ListboxTextItem(g.rated ? "Y" : "N"), 7, i);
        mcl->setItem(new ListboxTextItem(Chess::getTypeName(g.type)), 1, i);
        for (int j = 0; j < 2; ++j) {
          mcl->setItem(new ListboxTextItem(g.players[j]), 2 + (j * 2), i);
          mcl->setItem(new ListboxTextItem(Platform::format("%d", g.ratings[j])), 3 + (j * 2), i);
        }
      }
      // Add some empty rows to the MCL
      //multilineColumnList->addRow();
      //multilineColumnList->addRow();
      //multilineColumnList->addRow();
      //multilineColumnList->addRow();
      //multilineColumnList->addRow();

      //// Set first row item texts for the MCL
      //multilineColumnList->setItem(new MyListItem("Laggers World"), 0, 0);
      //multilineColumnList->setItem(new MyListItem("yourgame.some-server.com"), 1, 0);
      //multilineColumnList->setItem(new MyListItem("[colour='FFFF0000']1000ms"), 2, 0);

      //// Set second row item texts for the MCL
      //multilineColumnList->setItem(new MyListItem("Super-Server"), 0, 1);
      //multilineColumnList->setItem(new MyListItem("whizzy.fakenames.net"), 1, 1);
      //multilineColumnList->setItem(new MyListItem("[colour='FF00FF00']8ms"), 2, 1);

      //// Set third row item texts for the MCL
      //multilineColumnList->setItem(new MyListItem("Cray-Z-Eds"), 0, 2);
      //multilineColumnList->setItem(new MyListItem("crayzeds.notarealserver.co.uk"), 1, 2);
      //multilineColumnList->setItem(new MyListItem("[colour='FF00FF00']43ms"), 2, 2);

      //// Set fourth row item texts for the MCL
      //multilineColumnList->setItem(new MyListItem("Fake IPs"), 0, 3);
      //multilineColumnList->setItem(new MyListItem("123.320.42.242"), 1, 3);
      //multilineColumnList->setItem(new MyListItem("[colour='FFFFFF00']63ms"), 2, 3);

      //// Set fifth row item texts for the MCL
      //multilineColumnList->setItem(new MyListItem("Yet Another Game Server"), 0, 4);
      //multilineColumnList->setItem(new MyListItem("abc.abcdefghijklmn.org"), 1, 4);
      //multilineColumnList->setItem(new MyListItem("[colour='FFFF6600']284ms"), 2, 4);
      //FrameWindow* fWnd = static_cast<FrameWindow*>(
      //wmgr.createWindow("TaharezLook/FrameWindow", "testWindow"));
      //myRoot->addChild(fWnd);

      //FrameWindow * frame = static_cast<FrameWindow*>(rootWindow->getChild("Frame"));
      //fWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
      //fWnd->setSize(USize(UDim(0.5f, 0.0f), UDim(0.5f, 0.0f)));
      //fWnd->setText("Hello World!");
#endif
    } catch (CEGUI::Exception & ex) {
      SAY(ex.getMessage().c_str());
    }
  }
Esempio n. 9
0
bool handleItemSelect(int r)
{
	using namespace CEGUI;
	extern CEGUI::Window* myRoot;

	MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox"));
	
	ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0));
	ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1));
	ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2));


	Window* country_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/CountryEditbox"));
	Window* twn_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/TownEditbox"));
	Window* street_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/StreetEditbox"));

	if(SDL_dest.current_search==SRCH_COUNTRY){
		country_edit->setText(item->getText());
		// Need to record the country here 
		twn_edit->activate();
		SDL_dest.current_search=SRCH_TOWN;
		myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText("");

	} else 	if(SDL_dest.current_search==SRCH_TOWN){
		twn_edit->setText(item->getText());
// 		SDL_dest.town_street_assoc=atoi(item_assoc->getText().c_str());
// 		SDL_dest.town=atoi(itemid->getText().c_str());
// 		printf(" town %s , id=%lx, assoc=%li\n",item->getText().c_str(),SDL_dest.town_street_assoc,SDL_dest.town_street_assoc);


		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x"));
		Dest_x->setText(itemx->getText().c_str());

		Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y"));
		Dest_y->setText(itemy->getText().c_str());

		mcl->resetList();

		SDL_dest.current_search=SRCH_STREET;
		street_edit->activate();
		myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText("");

	} else if(SDL_dest.current_search==SRCH_STREET){
		street_edit->setText(item->getText());

		myRoot->getChild("Navit/Keyboard")->hide();

		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x"));
		Dest_x->setText(itemx->getText().c_str());

		Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y"));
		Dest_y->setText(itemy->getText().c_str());

		mcl->resetList();

		SDL_dest.current_search=SRCH_STREET;

		myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText("");


		/*
		ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1));
		int segment_id=atoi(itemid->getText().c_str());
		printf("street seg id : %li\n",segment_id);

		extern struct container *co;
		struct block_info res_blk_inf;
		struct street_str *res_str;
		street_get_by_id(co->map_data, 33, segment_id,&res_blk_inf,&res_str );

		struct street_coord * streetcoord;
		streetcoord=street_coord_get(&res_blk_inf,res_str);

		printf("Street coordinates : %i,%i\n",streetcoord->c->x,streetcoord->c->y);

	 	char xbuff [256];
		sprintf(xbuff,"%li",streetcoord->c->x);
	 	char ybuff [256];
		sprintf(ybuff,"%li",streetcoord->c->y);

		Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x"));
		Dest_x->setText(xbuff);

		Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y"));
		Dest_y->setText(ybuff);

		struct street_name name;
// 		printf("street_name_get_by_id returns : %i\n",street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid));
		street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid);
// 		printf("name1:%s / name2%s\n",name.name1,name.name2);

		struct street_name_number_info num;
		struct street_name_info inf;

		SDL_dest.current_search=SRCH_NUMBER;
		mcl->resetList();

		while (street_name_get_info(&inf, &name)) {
			while(street_name_get_number_info(&num,&inf)){
// 				printf(" House Number : %i -> %i\n",num.first,num.last);
				for(int i=num.first;i<=num.last;i+=2){
					add_number_to_list(i,num.c->x,num.c->y);
				}
			}
		}
		*/
// 		route_to(streetcoord->c->x,streetcoord->c->y);
	} else if (SDL_dest.current_search==SRCH_NUMBER){

		struct coord pos;
		ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
		ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
	
		pos.x=atoi(itemx->getText().c_str());
		pos.y=atoi(itemy->getText().c_str());

		route_to(pos.x,pos.y);
	}

	return true;
}
Esempio n. 10
0
    void FalagardMultiColumnList::render()
    {
        MultiColumnList* w = (MultiColumnList*)d_window;
        const ListHeader* header = w->getListHeader();
        const Scrollbar* vertScrollbar = w->getVertScrollbar();
        const Scrollbar* horzScrollbar = w->getHorzScrollbar();

        // render general stuff before we handle the items
        cacheListboxBaseImagery();

        //
        // Render list items
        //
        Vector3f itemPos;
        Sizef itemSize;
        Rectf itemClipper, itemRect;

        // calculate position of area we have to render into
        Rectf itemsArea(getListRenderArea());

        // set up initial positional details for items
        itemPos.d_y = itemsArea.top() - vertScrollbar->getScrollPosition();
        itemPos.d_z = 0.0f;

        const float alpha = w->getEffectiveAlpha();

        // loop through the items
        for (uint i = 0; i < w->getRowCount(); ++i)
        {
            // set initial x position for this row.
            itemPos.d_x = itemsArea.left() - horzScrollbar->getScrollPosition();

            // calculate height for this row.
            itemSize.d_height = w->getHighestRowItemHeight(i);

            // loop through the columns in this row
            for (uint j = 0; j < w->getColumnCount(); ++j)
            {
                // allow item to use full width of the column
                itemSize.d_width = CoordConverter::asAbsolute(header->getColumnWidth(j), header->getPixelSize().d_width);

                ListboxItem* item = w->getItemAtGridReference(MCLGridRef(i,j));

                // is the item for this column set?
                if (item)
                {
                    // calculate destination area for this item.
                    itemRect.left(itemPos.d_x);
                    itemRect.top(itemPos.d_y);
                    itemRect.setSize(itemSize);
                    itemClipper = itemRect.getIntersection(itemsArea);

                    // skip this item if totally clipped
                    if (itemClipper.getWidth() == 0)
                    {
                        itemPos.d_x += itemSize.d_width;
                        continue;
                    }

                    // draw this item
                    item->draw(w->getGeometryBuffer(), itemRect, alpha, &itemClipper);
                }

                // update position for next column.
                itemPos.d_x += itemSize.d_width;
            }

            // update position ready for next row
            itemPos.d_y += itemSize.d_height;
        }
    }
Esempio n. 11
0
static void init_sdlgui(char * skin_layout,int fullscreen)
{
	SDL_Surface * screen;
// 	atexit (SDL_Quit);
	SDL_Init (SDL_INIT_VIDEO);
	int videoFlags;
	const SDL_VideoInfo *videoInfo;
	videoInfo = SDL_GetVideoInfo( );

	if ( !videoInfo )
	{
	    fprintf( stderr, "Video query failed: %s\n",
		     SDL_GetError( ) );
	}

	/* the flags to pass to SDL_SetVideoMode */
	videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
	videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
	videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
	videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
	
	/* This checks to see if surfaces can be stored in memory */
	if ( videoInfo->hw_available )
		videoFlags |= SDL_HWSURFACE;
	else
		videoFlags |= SDL_SWSURFACE;
	
	/* This checks if hardware blits can be done */
	if ( videoInfo->blit_hw )
		videoFlags |= SDL_HWACCEL;
	
	/* Sets up OpenGL double buffering */
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

	SDL_WM_SetCaption("NavIt - The OpenSource vector based navigation engine", NULL);

	/* get a SDL surface */
	screen = SDL_SetVideoMode( XRES, YRES, 32,
					videoFlags );

	if (screen == NULL) {
		fprintf (stderr, "Can't set SDL: %s\n", SDL_GetError ());
		exit (1);
	}
	if(fullscreen){
		SDL_WM_ToggleFullScreen(screen);
	}
	SDL_ShowCursor (SDL_ENABLE);
	SDL_EnableUNICODE (1);
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	init_GL();
	
// 	sdl_audio_init();

	try
	{
		renderer = new CEGUI::OpenGLRenderer(0,XRES,YRES);
		new CEGUI::System(renderer);

		using namespace CEGUI;

		SDL_ShowCursor(SDL_ENABLE);
		SDL_EnableUNICODE(1);
		SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
		
		CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
		(System::getSingleton().getResourceProvider());
		

		// FIXME This should maybe move to navit.xml
		static char *datafiles_path[]={
			"./gui/sdl/datafiles",
			"/usr/share/navit/datafiles",
			"/usr/local/share/navit/datafiles",
			NULL,
		};

		char **filename=datafiles_path;

		while (*filename) {	
			if (FILE * file = fopen(*filename, "r"))
			{
				fclose(file);
				break;
			}
			filename++;
		}

		if(*filename==NULL){
			// FIXME Elaborate the possible solutions
			printf("Can't find the datafiles directory for CEGUI files. Navit will probably crash :)\n");
		} else {
			printf("Loading SDL datafiles from %s\n",*filename);
		}

		rp->setResourceGroupDirectory("schemes", g_strdup_printf("%s/schemes/",*filename));
		rp->setResourceGroupDirectory("imagesets", g_strdup_printf("%s/imagesets/",*filename));
		rp->setResourceGroupDirectory("fonts", g_strdup_printf("%s/fonts/",*filename));
		rp->setResourceGroupDirectory("layouts", g_strdup_printf("%s/layouts/",*filename));
		rp->setResourceGroupDirectory("looknfeels", g_strdup_printf("%s/looknfeel/",*filename));
		rp->setResourceGroupDirectory("lua_scripts", g_strdup_printf("%s/lua_scripts/",*filename));


		CEGUI::Imageset::setDefaultResourceGroup("imagesets");
		CEGUI::Font::setDefaultResourceGroup("fonts");
		CEGUI::Scheme::setDefaultResourceGroup("schemes");
		CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
		CEGUI::WindowManager::setDefaultResourceGroup("layouts");
		CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");

		char buffer [50];
		sprintf (buffer, "%s.scheme", skin_layout);
		dbg(1,"Loading scheme : %s\n",buffer);

		CEGUI::SchemeManager::getSingleton().loadScheme(buffer);

		CEGUI::FontManager::getSingleton().createFont("DejaVuSans-10.font");
		CEGUI::FontManager::getSingleton().createFont("DejaVuSans-14.font");

		CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");

		CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();

		dbg(1,"Loading layout : %s\n",buffer);

		sprintf (buffer, "%s.layout", skin_layout);

		myRoot = CEGUI::WindowManager::getSingleton().loadWindowLayout(buffer);

 		CEGUI::System::getSingleton().setGUISheet(myRoot);

		try {

		CEGUI::WindowManager::getSingleton().getWindow("OSD/Quit")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ButtonQuit));
// 		CEGUI::WindowManager::getSingleton().getWindow("OSD/Quit")->setText(_("Quit"));

		CEGUI::WindowManager::getSingleton().getWindow("ZoomInButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ZoomIn));
// 		CEGUI::WindowManager::getSingleton().getWindow("ZoomInButton")->setText(_("ZoomIn"));

		CEGUI::WindowManager::getSingleton().getWindow("ZoomOutButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ZoomOut));
// 		CEGUI::WindowManager::getSingleton().getWindow("ZoomOutButton")->setText(_("ZoomOut"));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/CountryEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/CountryEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/TownEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/TownEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/StreetEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/StreetEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(DialogWindowSwitch));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/ViewMode")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ToggleView));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/GO")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ButtonGo));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/KB")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ShowKeyboard));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Listbox")->subscribeEvent(MultiColumnList::EventSelectionChanged, Event::Subscriber(ItemSelect));


		// Translation for StaticTexts (labels)
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Country")->setText(_("Country"));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Town")->setText(_("City"));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Street")->setText(_("Street"));

 		MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox"));

		mcl->setSelectionMode(MultiColumnList::RowSingle) ;
		mcl->addColumn("Value", 0, cegui_absdim(200.0));
		mcl->addColumn("ID", 1, cegui_absdim(70.0));
		mcl->addColumn("Assoc", 2, cegui_absdim(70.0));
		mcl->addColumn("x", 3, cegui_absdim(70.0));
		mcl->addColumn("y", 4, cegui_absdim(70.0));

 		MultiColumnList* mcl2 = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook"));

		mcl2->setSelectionMode(MultiColumnList::RowSingle) ;
		mcl2->addColumn("Instructions", 0, cegui_absdim(700.0));

 		BuildKeyboard();

		CEGUI::WindowManager::getSingleton().getWindow("OSD/Scrollbar1")->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(MoveCamera));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(RoadBookSwitch));
		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->setText(_("RoadBook"));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/nGhostButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(Switch_to_nGhost));
		// this one is maybe not needed anymore
		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton2")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(RoadBookSwitch));

		}
		catch (CEGUI::Exception& e)
		{
			fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
			printf("Missing control!...\n");
		}

	}
	catch (CEGUI::Exception& e)
	{
		fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
		printf("quiting...\n");
		exit(1);
	}
	
}
Esempio n. 12
0
static void
sdl_update_roadbook(struct navigation *nav)
{

	using namespace CEGUI;

	struct map *map;
	struct map_rect *mr;

	if (! nav)
		return;
	map=navigation_get_map(nav);
	if (! map)
		return;
	mr=map_rect_new(map, NULL);
	if (! mr)
		return;

	// First, ensure the navigation tip is visible. quick workaround for when resuming a destination
	WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->show();

	// update the 'Navigation Tip' on the main window
	try {
		struct attr attr;
		item_attr_get(map_rect_get_item(mr), attr_navigation_speech, &attr);
		map_rect_destroy(mr);
		mr=map_rect_new(map, NULL);
		WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->setText((CEGUI::utf8*)(attr.u.str));
	}
	catch (CEGUI::Exception& e)
	{
		fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
		printf("Missing control!...\n");
	}

	// Then, update the whole roadbook	
	try {

		/* Currently we use the 'Navit' text to display the roadbook, until Mineque design a button for that 		
		if(! WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->isVisible()){
			WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->show();
		}
		*/

		MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook"));
		mcl->resetList();

		item *item;
		struct attr attr;

		while ((item=map_rect_get_item(mr))) {
	 		mcl->addRow();
			item_attr_get(item, attr_navigation_short, &attr);
			ListboxTextItem* itemListbox = new ListboxTextItem(attr.u.str);
			itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
			mcl->setItem(itemListbox, 0, mcl->getRowCount()-1);
		}
		map_rect_destroy(mr);
	}
	catch (CEGUI::Exception& e)
	{
		dbg(0,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
		dbg(0,"Missing control!\n");
	}

}
Esempio n. 13
0
void CEGUISample9App::createListContent()
{
    using namespace CEGUI;

    WindowManager& winMgr = WindowManager::getSingleton();

	Combobox * cbobox = static_cast<Combobox*>(winMgr.getWindow("Demo7/Window2/Combobox"));
    // add items to the combobox list
    cbobox->addItem(new MyListItem("Combobox Item 1"));
    cbobox->addItem(new MyListItem("Combobox Item 2"));
    cbobox->addItem(new MyListItem("Combobox Item 3"));
    cbobox->addItem(new MyListItem("Combobox Item 4"));
    cbobox->addItem(new MyListItem("Combobox Item 5"));
    cbobox->addItem(new MyListItem("Combobox Item 6"));
    cbobox->addItem(new MyListItem("Combobox Item 7"));
    cbobox->addItem(new MyListItem("Combobox Item 8"));
    cbobox->addItem(new MyListItem("Combobox Item 9"));
    cbobox->addItem(new MyListItem("Combobox Item 10"));

    //
    // Multi-Column List setup
    //
    MultiColumnList* mclbox = static_cast<MultiColumnList*>(winMgr.getWindow("Demo7/Window2/MultiColumnList"));
    // Add some empty rows to the MCL
    mclbox->addRow();
    mclbox->addRow();
    mclbox->addRow();
    mclbox->addRow();
    mclbox->addRow();

    // Set first row item texts for the MCL
    mclbox->setItem(new MyListItem("Laggers World"), 0, 0);
    mclbox->setItem(new MyListItem("yourgame.some-server.com"), 1, 0);
    mclbox->setItem(new MyListItem("[colour='FFFF0000']1000ms"), 2, 0);

    // Set second row item texts for the MCL
    mclbox->setItem(new MyListItem("Super-Server"), 0, 1);
    mclbox->setItem(new MyListItem("whizzy.fakenames.net"), 1, 1);
    mclbox->setItem(new MyListItem("[colour='FF00FF00']8ms"), 2, 1);

    // Set third row item texts for the MCL
    mclbox->setItem(new MyListItem("Cray-Z-Eds"), 0, 2);
    mclbox->setItem(new MyListItem("crayzeds.notarealserver.co.uk"), 1, 2);
    mclbox->setItem(new MyListItem("[colour='FF00FF00']43ms"), 2, 2);

    // Set fourth row item texts for the MCL
    mclbox->setItem(new MyListItem("Fake IPs"), 0, 3);
    mclbox->setItem(new MyListItem("123.320.42.242"), 1, 3);
    mclbox->setItem(new MyListItem("[colour='FFFFFF00']63ms"), 2, 3);

    // Set fifth row item texts for the MCL
    mclbox->setItem(new MyListItem("Yet Another Game Server"), 0, 4);
    mclbox->setItem(new MyListItem("abc.abcdefghijklmn.org"), 1, 4);
    mclbox->setItem(new MyListItem("[colour='FFFF6600']284ms"), 2, 4);

    mclbox->setProperty("Font", "fkp-16");
}
Esempio n. 14
0
/////////////////////////////////////////////////
// zhaohang  2010/3/16
// 控件数据显示更新
void GVEvent::SetItemContentInMulList(const UIData::tagGoodAttr *pGoodAttr, CEGUI::uint RowIdx)
{
    if(pGoodAttr!=NULL)
    {
        MultiColumnList* mclbox = static_cast<MultiColumnList*>(m_wnd->getChildRecursive("GoodsTreeFrame/MultiColumnList"));
        //清空行
        mclbox->resetList();
        //设置每一行的值
        mclbox->addRow();
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwIndex)),0,RowIdx);
        mclbox->setItem(new MyListItem(pGoodAttr->strOrigName.c_str()),1,RowIdx);
        mclbox->setItem(new MyListItem(pGoodAttr->strName.c_str()),2,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::boolToString(pGoodAttr->bSave)),3,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwIconId)),4,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwGroundId)),5,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwEquipID)),6,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwValue)),7,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSilverValue)),8,RowIdx);
        mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodsType(pGoodAttr->dwType).c_str()),9,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSound)),10,RowIdx);
        mclbox->setItem(new MyListItem(pGoodAttr->strContent.c_str()),11,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSoundID1)),12,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSoundID2)),13,RowIdx);
        mclbox->setItem(new MyListItem(PropertyHelper::boolToString(pGoodAttr->bSoundSwitch)),14,RowIdx);
    }
}
Esempio n. 15
0
bool GVEvent::OnAddAttrItemSelChanged(const CEGUI::EventArgs &args)
{
    //处理附加属性条目选中消息
    MultiColumnList* mcl = static_cast<MultiColumnList*>(m_wnd->getChildRecursive("GoodsTreeFrame/AddProperty/MultiColumnList"));
    MyListItem* lti = static_cast<MyListItem*>(mcl->getFirstSelectedItem());
    if(!lti)
    {
        //更新对应的控件
        //是否有效
        Combobox* cbbo = GetCombobox("GoodsTreeFrame/AddProperty/GroupBox1");
        cbbo->setItemSelectState(1,false);
        cbbo->setItemSelectState((size_t)0,false);
        //是否隐藏
        cbbo = GetCombobox("GoodsTreeFrame/AddProperty/GroupBox11");
        cbbo->setItemSelectState(1,false);
        cbbo->setItemSelectState((size_t)0,false);
        //值1
        Editbox* edbox = GetEditbox("GoodsTreeFrame/AddProperty/EditBoxValue1");
        edbox->setText("");
        //值2
        edbox = GetEditbox("GoodsTreeFrame/AddProperty/EditBoxValue11");
        edbox->setText("");
        return false;
    }
    //获取选中的附加属性名称
    const String &strAttrName = lti->getText();
    lti = static_cast<MyListItem*>(mcl->getNextSelected(lti));
    //获取选中的附加属性是否有效
    const String &strEnable = lti->getText();
    lti = static_cast<MyListItem*>(mcl->getNextSelected(lti));
    //是否隐藏
    const String &strHide = lti->getText();
    lti = static_cast<MyListItem*>(mcl->getNextSelected(lti));
    //值1
    const String &strValue1 = lti->getText();
    lti = static_cast<MyListItem*>(mcl->getNextSelected(lti));
    //值2
    const String &strValue2 = lti->getText();

    //更新对应的控件
    Combobox* cbbo = GetCombobox("GoodsTreeFrame/AddProperty/GroupBox1");
    bool b = PropertyHelper::stringToBool(strEnable);
    //是否有效
    if( b == false)
        cbbo->setItemSelectState(1,true);
    else
        cbbo->setItemSelectState((size_t)0,true);
    b = PropertyHelper::stringToBool(strHide);
    cbbo = GetCombobox("GoodsTreeFrame/AddProperty/GroupBox11");
    //是否隐藏
    if(b == false)
        cbbo->setItemSelectState(1,true);
    else
        cbbo->setItemSelectState((size_t)0,true);
    //值1
    Editbox* edbox = GetEditbox("GoodsTreeFrame/AddProperty/EditBoxValue1");
    edbox->setText(strValue1);
    //值2
    edbox = GetEditbox("GoodsTreeFrame/AddProperty/EditBoxValue11");
    edbox->setText(strValue2);
    return true;
}