没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
CEGUI 文档
这份文档主要讲解的是 Sample_Demo6 例子。
首先我们来看下头文件,我们会发现同 Demo4 一样,都包含了两个相同的引用,声明了
两个相同的初始化和清理的函数,这两个函数一般是必要的。
#include "CEGuiSample.h"
#include "CEGUI.h"
// Sample class
class Demo6Sample : public CEGuiSample
{
public:
// method to initialse the samples windows and events.
bool initialiseSample(); 初始化
// method to perform any required cleanup operations.
void cleanupSample(void); 清除
protected:
// helper methods
void createDemoWindows(void); //创建窗口
void initDemoEventWiring(void); //初始化事件
// event handlers事件回调函数
bool handleQuit(const CEGUI::EventArgs& e); //退出
bool handleAddColumn(const CEGUI::EventArgs& e); //添加列
bool handleDeleteColumn(const CEGUI::EventArgs& e); //删除列
bool handleAddRow(const CEGUI::EventArgs& e); //添加行
bool handleDeleteRow(const CEGUI::EventArgs& e); //删除行
bool handleSetItem(const CEGUI::EventArgs& e); //设置项
bool handleSelectChanged(const CEGUI::EventArgs& e); //所选项发
生改变时触发事件
bool handleSelectModeChanged(const CEGUI::EventArgs& e);//所选模
式发生改变时触发事件
bool handleContentsChanged(const CEGUI::EventArgs& e); //内容
发生改变时触发事件
};
#endif // end of guard _Sample_Demo6_h_
我们看到在头文件中,声明了许多 handle 事件的回调函数,这些函数都是用来处理
demo6 中对应的控件的事件消息的,具体的效果,大家可以运行 demo 后查看。下面我
们具体来分析下.cpp 文件。
首先看下引用的头文件:
#include "Sample_Demo6.h"
#include "CEGUI.h" 这个头文件是必须引用的,不必深究
#include "CEGuiBaseApplication.h"
#include <stdlib.h>
#include <stdio.h>
#include <string>
接下来是 main 函数,我们发现 demo6 的 main 函数和 demo4 的 main 函数一模一样,
所以我们在以后写自己的 demo 时,main 函数中也之需要这两个函数就行了。
int main(int argc, char *argv[])
{
Demo6Sample app;
return app.run();
}
最开始还是先实现 initialiseSample()这个函数,初始化必须的一些窗口样式,在
第一篇文档中,我们讲到了 CEGUI 必须要加载三种文件:scheme、font 和
imageset。在这个函数中,我们会看到这些数据文件的加载。
bool Demo6Sample::initialiseSample()
{
using namespace CEGUI; //所有 CEGUI 的例子都必须加载此命名空间
// we will use of the WindowManager. //获取一个 WindowManager 的静态
对象
WindowManager& winMgr = WindowManager::getSingleton();
// load scheme and set up defaults 此处导入的是 scheme 数据文件
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().createImagesetFromImageFi
le("BackgroundImage", "GPN-2000-001437.tga");
// here we will use a StaticImage as the root, then we can use it to
place a background image 创建一个窗口,命名为 root_wnd,即为根窗口
Window* background =
winMgr.createWindow("TaharezLook/StaticImage", "root_wnd");
// set position and size 这里的设置窗口位置和大小已经比较熟悉了吧,
cegui_reldim 中的数字是按照根窗口的比率来定的。
//位置设定为左上角点在最左上位置。
background->setPosition(UVector2(cegui_reldim(0),
cegui_reldim( 0)));
//大小设定为整个窗口的大小
background->setSize(UVector2(cegui_reldim(1),
cegui_reldim( 1)));
// disable frame and standard background
这里的 setProperty 讲解过了,大家可以通过实例改变下参数来查看不同的效果。
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
//这句话挺重要的,setGUISheet()方法是将 background 设置为根窗口!
//调用 System 对象的 setGUISheet 方法将指定一个窗体做为 GUI 的根窗体。这将取代当
前任何的根窗体,即使前一个窗体链还没有给销毁。可以通过 setGUISheet 方法来简
单实现翻转 GUI 页
System::getSingleton().setGUISheet(background);
// do demo stu? 这两个函数我们将会在下面讲到…
createDemoWindows();
initDemoEventWiring();
// success!
return true; 这句代码很重要,每个函数最后都要返回 true
这样 CEGUI 就知道初始化成功了,否则 CEGUI 就要抛出
异常
}
至于 cleanupSample()这里没有必要再讲了,这些例子中都无需进行清理操作。
void Demo6Sample::cleanupSample()
{
// nothing to do here!
}
现在我们开始讲解 createDemoWindows()函数,这个函数是用来构建我们需要的
窗口的,先截图给大家观赏一下具体的效果:
剩余14页未读,继续阅读
资源评论
FOREVER_MOUSE_123
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 2013-2022vc运行命令库
- probleme.exe
- 基于python完成对csv文件的读取并且通过flask框架显示
- 基于SpringBoot的“体质测试数据分析及可视化”的设计与实现.zip
- c语言-c语言编程基础之leetcode题解第21题合并两个有序链表.zip
- 快速开发API服务的框架
- c语言-c语言编程基础之leetcode题解第20题有效的括号.zip
- c语言-c语言编程基础之leetcode题解第19题删除链表的倒数第N个结点.zip
- c语言-c语言编程基础之leetcode题解第17题电话号码的字母组合.zip
- c语言-c语言编程基础之leetcode题解第16题最接近的三数之和.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功