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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threatpost
P
Privacy International News Feed
T
Tenable Blog
Know Your Adversary
Know Your Adversary
C
Cisco Blogs
P
Proofpoint News Feed
Spread Privacy
Spread Privacy
G
GRAHAM CLULEY
爱范儿
爱范儿
U
Unit 42
K
Kaspersky official blog
C
Cybersecurity and Infrastructure Security Agency CISA
Jina AI
Jina AI
O
OpenAI News
L
LangChain Blog
PCI Perspectives
PCI Perspectives
P
Privacy & Cybersecurity Law Blog
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
L
Lohrmann on Cybersecurity
V
V2EX
L
LINUX DO - 热门话题
S
Security Affairs
量子位
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
Schneier on Security
Schneier on Security
月光博客
月光博客
MyScale Blog
MyScale Blog
C
CERT Recently Published Vulnerability Notes
AWS News Blog
AWS News Blog
博客园 - 叶小钗
Forbes - Security
Forbes - Security
W
WeLiveSecurity
T
Troy Hunt's Blog
J
Java Code Geeks
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
Google Online Security Blog
Google Online Security Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
TaoSecurity Blog
TaoSecurity Blog
H
Help Net Security
The Cloudflare 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来触发之前注册的回调函数。

完整的类图: