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

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
GbyAI
GbyAI
WordPress大学
WordPress大学
NISL@THU
NISL@THU
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
F
Full Disclosure
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V
Visual Studio Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
V
V2EX
The Hacker News
The Hacker News
Scott Helme
Scott Helme
T
Troy Hunt's Blog
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
C
Cyber Attacks, Cyber Crime and Cyber Security
O
OpenAI News
月光博客
月光博客
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
IT之家
IT之家
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
T
Tenable Blog
Jina AI
Jina AI
T
Tor Project blog
The Cloudflare Blog
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
A
Arctic Wolf

博客园 - 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来触发之前注册的回调函数。

完整的类图: