惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
V
Visual Studio Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
The Cloudflare Blog
B
Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
M
MIT News - Artificial intelligence
Know Your Adversary
Know Your Adversary
I
InfoQ
T
The Exploit Database - CXSecurity.com
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Spread Privacy
Spread Privacy
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
Simon Willison's Weblog
Simon Willison's Weblog
月光博客
月光博客
博客园 - Franky
Project Zero
Project Zero
G
Google Developers Blog
S
SegmentFault 最新的问题
博客园 - 聂微东
P
Privacy & Cybersecurity Law Blog
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
S
Security @ Cisco Blogs
Martin Fowler
Martin Fowler
A
Arctic Wolf
T
Tenable Blog
L
LINUX DO - 最新话题
TaoSecurity Blog
TaoSecurity Blog
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

博客园 - SweetDream

如何使用SecureCRT连接ubuntu (转) 转 linux共享 VC++中的char,wchar_t,TCHAR(转载) 【转】Linux内核学习笔记(5)连载---实模式、保护模式和虚拟8086方式 concept 计算机英语 C++备忘录(记录一些不常使用的语法规则) Effective STL 笔记 <容器> VS2005 快捷键 网摘 君心莫邪 迭代器(iterators) 空间配置器(allocator) 函数返回引用或指针的选择 【转】最节省时间的方法——学习 C++数据类型速查 C++不定参数 Lua 与 C 交互(2) Lua 与 C 交互(1)
Cegui的事件机制
SweetDream · 2008-10-18 · via 博客园 - SweetDream

                  Cegui中的事件机制用的是观察者模式。需要订阅事件的类必须从EventSet继承:

订阅的一个感兴趣的事件调用EventSetsubscribeEvent,比如RenderDisplaySize改变感兴趣,它可以通过以下代码来订阅:

    // subscribe to hear about display mode changes

    d_rendererCon = d_renderer->subscribeEvent(Renderer::EventDisplaySizeChanged, Event::Subscriber(&CEGUI::System::handleDisplaySizeChange, this));

         subscribeEvent的第一个参数为字符串,在Cegui中是通过字符串匹配来来触发相应事件;第二个参数是对触发的回调函数的一个封装。


一旦订阅好自己感兴趣的事件后,接着就是等着它触发了。

void DirectX9Renderer::setDisplaySize(const Size& sz)

{

     if (d_display_area.getSize() != sz)

     {

         d_display_area.setSize(sz);

         EventArgs args;

         fireEvent(EventDisplaySizeChanged, args, EventNamespace);

     }

}

从上面代码可以看到当DisplaySize改变的时候会生成一个EventArgs对象,然后调用fireEvent函数,EventArgs 是回调参数,用过C#的朋友一定很熟悉它.


最后fireEvent则根据传入的字符串EventDisplaySizeChanged来触发之前注册的回调函数。

完整的类图: