⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messaging.html

📁 一个小巧的嵌入式图形系统wGUI, 可以用VC编译
💻 HTML
字号:
<html><head>	<title>wGui - Messaging Framework</title></head><body>	<h1>wGui - Messaging Framework</h1>	<p>wGui has a messaging framework which it uses for passing messages and events between objects.</p>	<h2>Messages</h2>	<p>Message objects are used to notify other objects of events (such as user input) and as a method of passing information.	All message objects are derived from the CMessage class which simply provides an identifier of the message type,	and an optional destination for the message (so that other objects know to ignore the message).</p>	<p>There are a number of derived message classes, like CMouseMessage, which are translated from SDL mouse events.	Since all user input is translated into messages, this allows the programmer to simulate user input programmatically.	A CKeyboardMessage object will look the same if it came from an SDL keyboard event, or was created by the programmer.</p>	<h2>Message Server</h2>	<p>Message objects are managed by a message server.  The server is responsible for queing and distributing messages.	An application requires one and only one message server.  This is handled by the CMessageServer class.	CMessageServer is a singleton, and doesn't need to be instantiated by the programmer.  Simply calling it's static Instance() method	will instantiate a server if required and will return a reference to it.</p>	<p>Messages are distributed to clients on a priority basis.  Higher priority clients get messages before lower priority clients.	For clients of the same priority, there is no predetermined order in which they receive messages (though the current implimentation	dictates that they will get them in the order in which they register with the server).  The destination value of a message is ignored	by the server, it is up to the clients to inspect that value and ignore messages that are not destined for them (this allows a client	to intercept messages not destined for another object).</p>	<p>A message will be passed to all clients registered for that message in order until one returns <i>true</i> from their message handler.	The <i>true</i> indicates that the client handled the message.</p>	<p>The <a href="Application.html">Application</a> is responsible for checking the Server queue and telling it to dispatch the next message.</p>	<h2>Message Clients</h2>	<p>Message clients are any objects that can receive messages.  The CMessageClient class is the base from which such objects should be derived.	Clients must also register with the server to receive messages.  When registering, the client specifies what types of messages it wants to	receive, and optionally the priority.  By registering at a higher priority than other objects, a client can ensure that it receives the message first.</p>	<p>	This can be useful for modifying or filtering the message before it was passed on to the other objects.  For example if you wanted to be	able to reverse the left and right mouse buttons, instead of rewriting every object, an object would be created to simply reverse the button	values in a mouse message, and then pass it on.  This object would then just have to register itself with the server at a higher priority than	the other controls in the application.</p>	<p>CMessageClient defines an overidable MessageHandler function which is what recieves the messages from the server.  If a client handles	a message, it should generally return <i>true</i> from the handler to indicate to the server that it has done something with the message.	Once a client returns <i>true</i>, the server will stop sending that message to other clients.  If the client doesn't do anything with a message	or is modifying a message that should be passed on to other objects (as in the mouse button switching example), the handler should return	<i>false</i> so that the server continues to distribute the message.  All of the controls in wGui are also message clients, many of which register	for mouse messages, so it is possible to cause strange behavior by eating the messages before the controls get them.</p>	<h2>Mouse Messages</h2>	<p>Mouse messages represent a special case for the messaging system.  When a mouse message is sent, a CView object will call	OnMouseButtonDown() or OnMouseButtonUp() for it's clients.  These handlers should determine which window is on 'top' and ensure that	only that window processes the mouse button event.  The regular mouse message is still passed to all message clients that requested it,	but it should be used for notification purposes only.  Message clients shouldn't return true from their HandleMessage() methods for	mouse button messages.</p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -