示例#1
0
文件: winmain.cpp 项目: cpzhang/zen
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR lpstrCmdLine, int nCmdShow)
{
	createGlobal();
	FrameWindow mw;
	mw.CreateEx();
	mw.ShowWindow(SW_MAXIMIZE);
	mw.UpdateWindow();
	MSG m;
	::ZeroMemory(&m, sizeof(m));
	for (;;)
	{
		::ZeroMemory(&m, sizeof(m));
		if (::PeekMessage(&m, NULL, 0, 0, PM_NOREMOVE))
		{
			::GetMessage(&m, NULL, 0, 0);
			if (m.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&m);
			::DispatchMessage(&m);
		}
		else
		{
			mw.onIdle();
		}
	}
	destroyGlobal();
	return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow)
{
    INITCOMMONCONTROLSEX ctls;
    ctls.dwSize = sizeof(INITCOMMONCONTROLSEX);
    ctls.dwICC = ICC_BAR_CLASSES;

    InitCommonControlsEx(&ctls);

    CreateDeveloperConsole();


    if (!LoadConfigFile("settings.cfg", g_options))
    {
        MessageBox(NULL, L"Could not load config file", L"Error", MB_OK);
        return 0;
    }

    RECT rct;

    rct.left = 0;
    rct.top = 0;
    rct.right = stoi(g_options["window_width"]);
    rct.bottom = stoi(g_options["window_height"]);

    AdjustWindowRectEx(&rct, WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, TRUE, WS_EX_OVERLAPPEDWINDOW);

    FrameWindow frameWindow;

    bool res = frameWindow.CreateEx(WS_EX_OVERLAPPEDWINDOW,
                                    g_mainWinClassName,
                                    L"WP Lab 3",
                                    WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                                    CW_USEDEFAULT, 0,
                                    rct.right - rct.left, rct.bottom - rct.top,
                                    NULL, NULL,
                                    hInstance);
    

    if (!res)
    {
        MessageBox(NULL, L"Could not create the window!", L"Error!", MB_OK|MB_ICONERROR);
        return 0;
    }

    frameWindow.Show(nCmdShow);
    frameWindow.Update();

    MSG msg;

    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}
示例#3
0
bool GuiConfig::handleConfigControlsBut(const CEGUI::EventArgs& e)
{
	WindowEventArgs* evt = (WindowEventArgs*)&e;
	FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "BinderPopup");
	wnd->setTitleBarEnabled(false);
	wnd->setCloseButtonEnabled(false);
	root->addChildWindow(wnd);

	wnd->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0.30f)));
	wnd->setSize(UVector2(cegui_reldim(1.1f), cegui_reldim( 0.15f)));
	wnd->setAlpha(0.88f);

	wnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
	wnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));

	Window* label2 = winMgr.createWindow("TaharezLook/StaticText", "BinderPopupLabel");
	wnd->addChildWindow(label2);
	label2->setProperty("FrameEnabled", "false");
	label2->setProperty("BackgroundEnabled", "false");
	label2->setPosition(UVector2(cegui_reldim(0.10f), cegui_reldim( 0.1f)));
	label2->setSize(UVector2(cegui_reldim(0.8f), cegui_reldim( 0.8f)));
	label2->setText(GLoc->GetString("AskForInput").c_str());


	winMgr.getWindow("Config Window")->setVisible(false);
//	mCurrentState = GUI_GETCONTROLBIND;
	mbControlBinding = true;

	mBindingButtonIndex = evt->window->getID();
	return true;
}
示例#4
0
void Add_KeyBoard_key(CEGUI::String key,int x,int y,int w){
	
	using namespace CEGUI;
//	char button_name [5];
//	sprintf(button_name,"%s",key);
	FrameWindow* wnd = (FrameWindow*)WindowManager::getSingleton().createWindow("TaharezLook/Button", key);
	CEGUI::WindowManager::getSingleton().getWindow("Navit/Keyboard")->addChildWindow(wnd);
	wnd->setPosition(UVector2(cegui_absdim(x), cegui_absdim( y)));
	wnd->setSize(UVector2(cegui_absdim(w), cegui_absdim( 40)));
	wnd->setText(key);
	wnd->subscribeEvent(PushButton::EventClicked, Event::Subscriber(Handle_Virtual_Key_Down));
	
}	
示例#5
0
    Rect FalagardFrameWindow::getUnclippedInnerRect(void) const
    {
        FrameWindow* w = (FrameWindow*)d_window;
        if (w->isRolledup())
            return Rect(0,0,0,0);

        // build name of area to fetch
        String areaName("Client");
        areaName += w->getTitlebar()->isVisible() ? "WithTitle" : "NoTitle";
        areaName += w->isFrameEnabled() ? "WithFrame" : "NoFrame";

        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        return wlf.getNamedArea(areaName).getArea().getPixelRect(*w, w->getUnclippedPixelRect());
    }
示例#6
0
文件: Menu.C 项目: bbidulock/flwm
static void
new_desktop_cb(Fl_Widget*, void*)
{
  if (!new_desktop_input) {
    FrameWindow* w = new FrameWindow(190,90);
    new_desktop_input = new Fl_Input(10,30,170,25,"New desktop name:");
    new_desktop_input->align(FL_ALIGN_TOP_LEFT);
    new_desktop_input->labelfont(FL_BOLD);
    Fl_Return_Button* b = new Fl_Return_Button(100,60,80,20,"OK");
    b->callback(new_desktop_ok_cb);
    Fl_Button* b2 = new Fl_Button(10,60,80,20,"Cancel");
    b2->callback(cancel_cb);
    w->set_non_modal();
    w->end();
  }
  char buf[120];
  sprintf(buf, "Desktop %d", Desktop::available_number());
  new_desktop_input->value(buf);
  new_desktop_input->window()->hotspot(new_desktop_input);
  new_desktop_input->window()->show();
}
/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool FormNavigationSample::initialise(CEGUI::GUIContext* gui_context)
{
    d_usedFiles = CEGUI::String(__FILE__);

    SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
    gui_context->getCursor().setDefaultImage("TaharezLook/MouseArrow");

    WindowManager& win_mgr = WindowManager::getSingleton();
    d_root = (DefaultWindow*)win_mgr.createWindow("DefaultWindow", "Root");

    Font& default_font = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
    gui_context->setDefaultFont(&default_font);

    gui_context->setRootWindow(d_root);

    d_navigationStrategy = new LinearNavigationStrategy;
    d_windowNavigator = new WindowNavigator(getNavigationMappings(), d_navigationStrategy);
    gui_context->setWindowNavigator(d_windowNavigator);

    FrameWindow* wnd = (FrameWindow*)win_mgr.createWindow("TaharezLook/FrameWindow",
        "Sample Window");
    d_root->addChild(wnd);

    wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
    wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    wnd->setMaxSize(USize(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    wnd->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim( 0.1f)));

    wnd->setText("Phony form");

    createForm(wnd);

    return true;
}
示例#8
0
    void FalagardFrameWindow::render()
    {
        FrameWindow* w = (FrameWindow*)d_window;
        // do not render anything for the rolled-up state.
        if (w->isRolledup())
            return;

        // build state name
        String stateName(w->isDisabled() ? "Disabled" : (w->isActive() ? "Active" : "Inactive"));
        stateName += w->getTitlebar()->isVisible() ? "WithTitle" : "NoTitle";
        stateName += w->isFrameEnabled() ? "WithFrame" : "NoFrame";

        const StateImagery* imagery;

        try
        {
            // get WidgetLookFeel for the assigned look.
            const WidgetLookFeel& wlf = getLookNFeel();
            // try and get imagery for our current state
            imagery = &wlf.getStateImagery(stateName);
        }
        catch (UnknownObjectException&)
        {
            // log error so we know imagery is missing, and then quit.
            return;
        }

        // peform the rendering operation.
        imagery->render(*w);
    }
示例#9
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!");
}
示例#10
0
/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool Demo4Sample::initialiseSample()
{
    using namespace CEGUI;

    // we will make extensive use of the WindowManager.
    WindowManager& winMgr = WindowManager::getSingleton();

    // load scheme and set up defaults
    SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
    System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
    //FontManager::getSingleton().createFont("Commonwealth-10.font");

    // load an image to use as a background
    ImagesetManager::getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

    // here we will use a StaticImage as the root, then we can use it to place a background image
    Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd");
    // set position and size
    background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
    background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
    // disable frame and standard background
    background->setProperty("FrameEnabled", "false");
    background->setProperty("BackgroundEnabled", "false");
    // set the background image
    background->setProperty("Image", "set:BackgroundImage image:full_image");
    // install this as the root GUI sheet
    System::getSingleton().setGUISheet(background);

    // now we create a DefaultWindow which we will attach all the widgets to.  We could
    // have attached them to the background StaticImage, though we want to be a bit tricky
    // since we do not wish the background to be faded by the slider - so we create this
    // container window so we can affect all the other widgets, but leave the background
    // unchanged.
    Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
    // attach this to the 'real' root
    background->addChildWindow(sheet);

    //
    // widget initialisation
    //
    // quit button
    PushButton* btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "QuitButton"));
    sheet->addChildWindow(btn);
    btn->setText("Quit!");
    btn->setPosition(UVector2(cegui_reldim(0.035f), cegui_reldim( 0.0f)));
    btn->setSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.036f)));
    btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&Demo4Sample::handleQuit, this));
    btn->setAlwaysOnTop(true);

    // Alpha-slider
    Slider* slider = static_cast<Slider*>(winMgr.createWindow("TaharezLook/Slider", "my slider"));
    sheet->addChildWindow(slider);
    slider->setPosition(UVector2(cegui_reldim(0.136f), cegui_reldim( 0.0f)));
    slider->setSize(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.075f)));
    slider->setAlwaysOnTop(true);
    // here we disable inherited alpha so that we will always be able to see the slider
    slider->setInheritsAlpha(false);
    // set up slider config
    slider->setCurrentValue(1.0f);
    slider->setClickStep(0.1f);
    // subscribe handler that will process slider position changes.
    slider->subscribeEvent(Slider::EventValueChanged, &sliderHandler);

    // big scroll bar
    Scrollbar* vscb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/LargeVerticalScrollbar", "Vert Scroll 1"));
    sheet->addChildWindow(vscb);
    vscb->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
    vscb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    vscb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    vscb->setSize(UVector2(cegui_reldim(0.035f), cegui_reldim( 0.83f)));
    vscb->setDocumentSize(100);
    vscb->setPageSize(5);
    vscb->setStepSize(1);
    vscb->setAlwaysOnTop(true);

    // mini vert scroll bar
    Scrollbar* mvsb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/VerticalScrollbar", "MiniVertScroll 1"));
    sheet->addChildWindow(mvsb);
    mvsb->setPosition(UVector2(cegui_reldim(0.99f), cegui_reldim( 0.015f)));
    mvsb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    mvsb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    mvsb->setSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.5f)));
    mvsb->setDocumentSize(360);
    mvsb->setPageSize(45);
    mvsb->setStepSize(1);
    mvsb->setAlwaysOnTop(true);

    // mini horz scroll bar
    Scrollbar* mhsb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "MiniHorzScroll 1"));
    sheet->addChildWindow(mhsb);
    mhsb->setPosition(UVector2(cegui_reldim(0.485f), cegui_reldim( 0.0f)));
    mhsb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    mhsb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    mhsb->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.015f)));
    mhsb->setDocumentSize(360);
    mhsb->setPageSize(45);
    mhsb->setStepSize(1);
    mhsb->setAlwaysOnTop(true);

    //
    // Build a window with some text and formatting options via radio buttons etc
    //
    FrameWindow* textwnd = static_cast<FrameWindow*>(winMgr.createWindow("TaharezLook/FrameWindow", "TextWindow"));
    sheet->addChildWindow(textwnd);
    textwnd->setPosition(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    textwnd->setMaxSize(UVector2(cegui_reldim(0.75f), cegui_reldim( 0.75f)));
    textwnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
    textwnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    textwnd->setCloseButtonEnabled(false);
    textwnd->setText("Crazy Eddie's GUI - Demo 4");

    Window* st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Static");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.22f)));
    st->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.6f)));

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Group label 1");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.23f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Horz. Formatting");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Group label 2");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.53f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Vert. Formatting");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Box label");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.12f), cegui_reldim( 0.15f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Formatted Output");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

	// groupbox
	st = winMgr.createWindow("TaharezLook/GroupBox", "TextWindow/GroupBox1");
	textwnd->addChildWindow(st);
	st->setPosition(UVector2(cegui_reldim(0.03f), cegui_reldim(0.08f)));
	st->setSize(UVector2(cegui_reldim(0.94f), cegui_reldim(0.90f)));
	st->setText("Text samples");

    // word-wrap checkbox
    Checkbox* cb = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "TextWindow/CB1"));
    textwnd->addChildWindow(cb);
    cb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.13f)));
    cb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    cb->setText("Word Wrap");
    // subscribe a handler to listen for when the check-box button select state changes
    cb->subscribeEvent(Checkbox::EventCheckStateChanged, &formatChangedHandler);

    // horizontal formatting radio group
    RadioButton* rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB1"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.3f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Left Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB2"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.35f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Right Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB3"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.4f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Centred");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    // vertical formatting radio group
    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB4"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.6f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Top Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB5"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.65f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Bottom Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB6"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.7f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Centred");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    // Edit box for text entry
    Editbox* eb = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "TextWindow/Editbox1"));
    textwnd->addChildWindow(eb);
    eb->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.85f)));
    eb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 0.04f)));
    eb->setSize(UVector2(cegui_reldim(0.90f), cegui_reldim( 0.08f)));
    // subscribe a handler to listen for when the text changes
    eb->subscribeEvent(Window::EventTextChanged, &textChangedHandler);

    //
    // Controls are set up.  Install initial settings
    //
    static_cast<Checkbox*>(winMgr.getWindow("TextWindow/CB1"))->setSelected(true);
    static_cast<RadioButton*>(winMgr.getWindow("TextWindow/RB1"))->setSelected(true);
    static_cast<RadioButton*>(winMgr.getWindow("TextWindow/RB4"))->setSelected(true);
    winMgr.getWindow("TextWindow/Editbox1")->setText("Come on then, edit me!");

    // success!
    return true;
}
vis_settings_panel_impl::vis_settings_panel_impl(  const app::zones_t &zones, const app::settings_t& s )
{
    GUIContext& context = System::getSingleton().getDefaultGUIContext();
    CEGUI::Window* root = context.getRootWindow();
    
	WindowManager& winMgr = WindowManager::getSingleton();

    FrameWindow* mainWindow = static_cast<FrameWindow*>(
        CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "MainWindow") );
    mainWindow->setPosition(UVector2(cegui_reldim(0.01f), cegui_reldim(0.5f)));
    //demoWindow->setSize(USize(cegui_reldim(0.3f), cegui_reldim(0.3f)));
    mainWindow->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim(0.1f)));
    mainWindow->setText( "Choose Zone" );

	auto fn_exit = [=](const CEGUI::EventArgs& args)->bool 
        {
			CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
			CEGUI::Window* root = context.getRootWindow();
			root->getChild("MainWindow")->setVisible(false);
            return true;

        };

    mainWindow->subscribeEvent( CEGUI::FrameWindow::EventCloseClicked,Event::Subscriber(fn_exit));


#if 0
	PushButton* btnExit = static_cast<PushButton*>(
        WindowManager::getSingleton().createWindow("TaharezLook/Button", btn_exit_name) );

    root->addChild(btnExit);
    btnExit->setPosition(UVector2(cegui_reldim(0.95f), cegui_reldim(0.95f)));
    btnExit->setSize( USize(cegui_reldim(0.04f), cegui_reldim(0.02f)) );
    btnExit->setText( "Exit" );
    
    btnExit->subscribeEvent(PushButton::EventClicked, 
        Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
        {

            exit_app_signal_(); 
            return true;

        })
        ); 
#endif
    

    Combobox* cbbo = static_cast<Combobox*>( CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Combobox", combo_name));
    cbbo->setPosition(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.1f)));
    //cbbo->setSize(USize(cegui_reldim(0.66f), cegui_reldim( 0.33f)));
    mainWindow->addChild(cbbo);
    root->addChild( mainWindow );

    mainWindow->setVisible(false);

    ListboxTextItem* itm;
    CEGUI::Win32StringTranscoder stc;
    const CEGUI::Image* sel_img = &ImageManager::getSingleton().get("TaharezLook/MultiListSelectionBrush");

    for (auto it = zones.begin(); it!=zones.end();++it)
    {
        itm = new ListboxTextItem(stc.stringFromStdWString(it->second), it->first);
        itm->setSelectionBrushImage(sel_img);
        cbbo->addItem(itm);
    }
    
    cbbo->subscribeEvent(Combobox::EventListSelectionAccepted, 
        Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
            {
                Combobox* combo = static_cast<Combobox*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("MainWindow/" + combo_name));
                
                ListboxItem* item = combo->findItemWithText(combo->getText(), 0);
                if (item)
                {
                    zone_changed_signal_( item->getID()); 
                }

                return true;
    
            })
        ); 

    cbbo->setReadOnly(true);
    cbbo->setSortingEnabled(false);

    //cbbo->handleUpdatedListItemData();

	CEGUI::ToggleButton*    checkbox = static_cast<ToggleButton*>( CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Checkbox", tb_name));
	checkbox->setSelected(true);
	checkbox->setText( "Lights" );
	mainWindow->addChild(checkbox);
	
    auto settingsWindow = winMgr.loadLayoutFromFile("vis_settings.layout");
	root->addChild(settingsWindow);
	subscribeEvent(setting_dlg + "/Settings/chkLights", ToggleButton::EventSelectStateChanged,
		Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
        {
            
			bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkLights");
			set_lights_signal_(wrap); 
            return true;

        }));
    
    settingsWindow->setVisible(false);

	subscribeEvent(setting_dlg + "/LWeather/edtGrassMap", CEGUI::Editbox::EventTextAccepted,
		Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
	{

		std::string param = getEditboxText(setting_dlg + "/LWeather/edtGrassMap");
		set_map_signal_(boost::lexical_cast<float>(param.empty()?"0":param)); 
		return true;

	}));

	subscribeEvent(setting_dlg + "/LWeather/btnApply", PushButton::EventClicked,
		Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
	{

		std::string param = getEditboxText(setting_dlg + "/LWeather/edtGrassMap");
		set_map_signal_(boost::lexical_cast<float>(param.empty()?"0":param)); 
		return true;

	}));

    subscribeEvent(setting_dlg + "/Settings/chkShadows", ToggleButton::EventSelectStateChanged,
        Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
    {

        bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkShadows");
        set_shadows_signal_(wrap); 
        return true;

    }));
    
    subscribeEvent(setting_dlg + "/Settings/chkShadowsParticles", ToggleButton::EventSelectStateChanged,
        Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
    {

        bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkShadowsParticles");
        set_shadows_part_signal_(wrap); 
        return true;

    }));

    setItemText(setting_dlg + "/LWeather/edtRadX"    , boost::str(boost::format("%.2f") % s.clouds[0].radius_x));
    setItemText(setting_dlg + "/LWeather/edtRadY"    , boost::str(boost::format("%.2f") % s.clouds[0].radius_y));
    setItemText(setting_dlg + "/LWeather/edtX"       , boost::str(boost::format("%.2f") % s.clouds[0].x));
    setItemText(setting_dlg + "/LWeather/edtY"       , boost::str(boost::format("%.2f") % s.clouds[0].y));
    setItemText(setting_dlg + "/LWeather/edtHeight"  , boost::str(boost::format("%.2f") % s.clouds[0].height));
    setItemText(setting_dlg + "/LWeather/edtIntensity", boost::str(boost::format("%.2f") % s.clouds[0].intensity));
    setItemText(setting_dlg + "/GWeather/edtIntensity", boost::str(boost::format("%.2f") % s.intensity));



    auto cloud_settings_callback =
    [=](const CEGUI::EventArgs& args)->bool 
    {
        app::cloud_params_t s;

        std::string edtRadX = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtRadX"));
        s.radius_x = boost::lexical_cast<float>(edtRadX.empty()?"0":edtRadX);

        std::string edtRadY = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtRadY"));
        s.radius_y = boost::lexical_cast<float>(edtRadY.empty()?"0":edtRadY);

        std::string edtX = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtX"));
        s.x = boost::lexical_cast<float>(edtX.empty()?"0":edtX);

        std::string edtY = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtY"));
        s.y = boost::lexical_cast<float>(edtY.empty()?"0":edtY);

        std::string edtHeight = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtHeight"));
        s.height = boost::lexical_cast<float>(edtHeight.empty()?"0":edtHeight);

        std::string edtIntensity = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtIntensity"));
        s.intensity = boost::lexical_cast<float>(edtIntensity.empty()?"0":edtIntensity);

        s.p_type   = 1;

        set_cloud_param_signal_(s); 
        return true;

    };

    subscribeEvent(setting_dlg + "/LWeather/edtRadX", Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback));

    subscribeEvent(setting_dlg + "/LWeather/edtRadY", Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback)); 

    subscribeEvent(setting_dlg + "/LWeather/edtX"   , Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback)); 

    subscribeEvent(setting_dlg + "/LWeather/edtY"   , Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback)); 
    
    subscribeEvent(setting_dlg + "/LWeather/edtHeight", Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback)); 

    subscribeEvent(setting_dlg + "/LWeather/edtIntensity", Editbox::EventTextAccepted,
        Event::Subscriber(cloud_settings_callback)); 

    subscribeEvent(setting_dlg + "/GWeather/edtIntensity", Editbox::EventTextAccepted,
        Event::Subscriber([=](const CEGUI::EventArgs& args)->bool 
    {
        std::string param = boost::trim_copy(getEditboxText(setting_dlg + "/GWeather/edtIntensity"));
        set_global_intensity_signal_ (boost::lexical_cast<float>(param.empty()?"0":param)); 
        return true;

    }));

}
示例#12
0
LRESULT FrameWindow::FrameWndProc(HWND hWndFrame, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    FrameWindow* frame = (FrameWindow*)GetProp(hWndFrame, L"FrameWindowPointer");

    switch(uMsg)
    {
    case WM_NCCREATE:
        if(NULL == frame)
        {
            frame = new FrameWindow(hWndFrame);
            SetProp(hWndFrame, L"FrameWindowPointer", frame);
        }
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDM_ABOUT:
            DialogBox((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUTBOX), hWndFrame, AboutDialog::About);
            break;

		case IDM_NEW:
			frame->NewDocument(wParam, lParam);
			break;

        case IDM_EXIT:
            DestroyWindow(hWndFrame);
            break;

        default:
            if(frame)
                return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	        else
		        return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
        }
        break;
        
    case WM_CREATE:
        return frame->Create(wParam, lParam);

    case WM_NCDESTROY:
        RemoveProp(hWndFrame,  L"FrameWindowPointer");  // remove the C++ object pointer from the property list
        if(frame)
            delete frame;
        PostQuitMessage(0);
        return 0;

	case WM_SIZE:
		return frame->Size(wParam, lParam);

    default:
       if(frame)
           return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	   else
		   return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
    }

       if(frame)
           return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	   else
		   return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
}
示例#13
0
文件: winmain.cpp 项目: cpzhang/zen
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR lpstrCmdLine, int nCmdShow)
{
	createGlobal();
	FrameWindow mw;
	mw.CreateEx();
	mw.ShowWindow(SW_SHOWMAXIMIZED);
	mw.UpdateWindow();
	MSG m;
	::ZeroMemory(&m, sizeof(m));
	float life = 0.0f;
	float frame = 0.0f;
	float fps = 0.0f;
	const size_t tDuration = 1000;
	const size_t tInterval = 1000/65;
	float inter = tInterval;
	for (;;)
	{
		::ZeroMemory(&m, sizeof(m));
		if (::PeekMessage(&m, NULL, 0, 0, PM_NOREMOVE))
		{
			::GetMessage(&m, NULL, 0, 0);
			if (m.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&m);
			::DispatchMessage(&m);
		}
		else
		{
			// GetTickCount only has a guaranteed resolution of 1/18th of a second, which is pretty horrible for game timing
			//Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
			float beforeRun = ::timeGetTime();
			mw.onIdle(inter);
			float afterRun = ::timeGetTime();
			float timeRun = afterRun - beforeRun;
			if (timeRun > tInterval)
			{
				inter = timeRun;
			}
			else
			{
				inter = tInterval;
			}
			++frame;
			float timeSleep = tInterval - timeRun;
			//¼ÆËãFPS
			life += inter;
			if (life >= tDuration)
			{
				fps = 1000.0f * frame / life;
				mw.setFPS(fps);
				life = 0.0f;
				frame = 0.0f;
			}
			//ÏÞÖ¡
			while(timeSleep >= 1.0f)
			{
				Sleep(1);
				--timeSleep;
			}
		}
	}
	destroyGlobal();

	return 0;
}
//----------------------------------------------------------------------------//
bool CommonDialogsSample::initialise(CEGUI::GUIContext* guiContext)
{
    using namespace CEGUI;

    d_usedFiles = CEGUI::String(__FILE__);

    // initialise the common dialogs library; this is very important!
    initialiseCEGUICommonDialogs();

    // load font and setup default if not loaded via scheme
    Font& defaultFont = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
    // Set default font for the gui context
    guiContext->setDefaultFont(&defaultFont);

    // load resources and set up system defaults
    SchemeManager::getSingleton().createFromFile("VanillaSkin.scheme");
    SchemeManager::getSingleton().createFromFile("VanillaCommonDialogs.scheme");
    guiContext->getCursor().setDefaultImage("Vanilla-Images/MouseArrow");

    // set up the root window / gui sheet
    WindowManager& winMgr = WindowManager::getSingleton();
    Window* root = winMgr.createWindow("DefaultWindow", "Root");
    guiContext->setRootWindow(root);

    // create container window for the Sample
    FrameWindow* wnd = static_cast<FrameWindow*>(
        winMgr.createWindow("Vanilla/FrameWindow"));
    root->addChild(wnd);

    wnd->setAlwaysOnTop(true);

    wnd->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.25f)));
    wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    wnd->setText("Common Dialogs Sample - Main Window");
    wnd->setCloseButtonEnabled(false);

    // Add a colour picker & label
    Window* colourPickerLabel = winMgr.createWindow("Vanilla/Label");
    wnd->addChild(colourPickerLabel);
    colourPickerLabel->setSize(USize(UDim(1.0f, 0.0f), UDim(0.0f, 30.0f)));
    colourPickerLabel->setText("Open the colour picker by clicking on the respective box:");

    CEGUI::ColourPicker* colourPicker = static_cast<CEGUI::ColourPicker*>(winMgr.createWindow("Vanilla/ColourPicker"));
    wnd->addChild(colourPicker);
    colourPicker->setPosition(UVector2(UDim(0, 20), UDim(0, 40)));
    colourPicker->setSize(USize(UDim(0, 100), UDim(0, 30)));
    colourPicker->setColour(CEGUI::Colour(1.0f, 0.0f, 0.0f, 0.5f));

    colourPicker = static_cast<CEGUI::ColourPicker*>(winMgr.createWindow("Vanilla/ColourPicker"));
    wnd->addChild(colourPicker);
    colourPicker->setPosition(UVector2(UDim(0, 20), UDim(0, 80)));
    colourPicker->setSize(USize(UDim(0, 100), UDim(0, 30)));
    colourPicker->setColour(CEGUI::Colour(0.0f, 1.0f, 1.0f, 0.0f));

    colourPicker = static_cast<CEGUI::ColourPicker*>(winMgr.createWindow("Vanilla/ColourPicker"));
    wnd->addChild(colourPicker);
    colourPicker->setPosition(UVector2(UDim(0, 20), UDim(0, 120)));
    colourPicker->setSize(USize(UDim(0, 100), UDim(0, 30)));
    colourPicker->setColour(CEGUI::Colour(0.4f, 0.4f, 0.0f, 1.0f));

    colourPicker = static_cast<CEGUI::ColourPicker*>(winMgr.createWindow("Vanilla/ColourPicker"));
    wnd->addChild(colourPicker);
    colourPicker->setPosition(UVector2(UDim(0, 20), UDim(0, 160)));
    colourPicker->setSize(USize(UDim(0, 100), UDim(0, 30)));
    colourPicker->setColour(CEGUI::Colour(1.0f, 0.2f, 0.5f, 0.8f));

    return true;
}