📄 sample_demo6.cpp
字号:
/***********************************************************************
filename: Sample_Demo6.cpp
created: 20/8/2005
author: Paul D Turner
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#include "Sample_Demo6.h"
#include "CEGUI.h"
#include "CEGuiBaseApplication.h"
#include <stdlib.h>
#include <stdio.h>
#include <string>
int main(int argc, char *argv[])
{
// This is a basic start-up for the sample application which is
// object orientated in nature, so we just need an instance of
// the CEGuiSample based object and then tell that sample application
// to run. All of the samples will use code similar to this in the
// main/WinMain function.
Demo6Sample app;
return app.run();
}
/*************************************************************************
Sample specific initialisation goes here.
*************************************************************************/
bool Demo6Sample::initialiseSample()
{
using namespace CEGUI;
// we will 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", "root_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);
// do demo stuff
createDemoWindows();
initDemoEventWiring();
// success!
return true;
}
/*************************************************************************
Cleans up resources allocated in the initialiseSample call.
*************************************************************************/
void Demo6Sample::cleanupSample()
{
// nothing to do here!
}
/*************************************************************************
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)));
// 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);
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);
// 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 = 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");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -