本文整理汇总了C++中FrameWindow类的典型用法代码示例。如果您正苦于以下问题:C++ FrameWindow类的具体用法?C++ FrameWindow怎么用?C++ FrameWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrameWindow类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tWinMain
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;
}
示例2: WinMain
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: handleConfigControlsBut
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: Add_KeyBoard_key
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: getUnclippedInnerRect
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: new_desktop_cb
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();
}
示例7: WindowNavigator
/*************************************************************************
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: render
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: cegui_reldim
/*************************************************************************
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");
//.........这里部分代码省略.........
示例10: cegui_reldim
//.........这里部分代码省略.........
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");
示例11: cegui_reldim
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);
//.........这里部分代码省略.........
示例12: switch
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: initialiseCEGUICommonDialogs
//----------------------------------------------------------------------------//
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;
}