6#include "helpers/formatstring.h"
12 int MessageWindow::_nextWindowId = 1;
15 MessageWindow::shared_ptr_t MessageWindow::CreateWindow(std::string title,
16 int x,
int y,
int width,
int height,
HandlerChain* handlerChain)
18 MessageWindow::shared_ptr_t window;
19 window = std::make_shared<MessageWindow>(
_nextWindowId, title, x, y,
20 width, height, handlerChain);
23 if (handlerChain !=
nullptr)
36 bool messageProcessed =
false;
58 return messageProcessed;
64 bool messageProcessed =
false;
72 messageProcessed =
true;
88 return messageProcessed;
94 bool messageProcessed =
false;
103 messageProcessed =
true;
113 return messageProcessed;
Declaration of the MessageWindow class and WindowRectangle class used in the HandlerChain Pattern.
Represents a list of handlers that all implement the IMessageHandler interface. This list can be dyna...
void SendMessage(Message *message)
Send a message to each of the handlers in the list, protected by a multi-threading lock.
void AddHandler(IMessageHandler::shared_ptr_t window)
Add an instance of the IMessageHandler interface to end of the list of handlers, protected by a multi...
void RemoveHandler(IMessageHandler::shared_ptr_t window)
Remove an instance of the IMessageHandler interface from the list, protected by a multi-threading loc...
Represents a rectangular region that can handle messages directed to that region.
static int _nextWindowId
Used for assigning a unique ID to each created window.
std::string _title
Title/Name of this window.
bool _PointInWindow(MessagePosition position)
Determine if the specified point is in this MessageWindow's region.
HandlerChain * _handlerChain
The HandlerChain to which this window belongs (as an IMessageHandler object).
bool _selected
Whether this window has been selected (a button click occurred within the window).
bool _PointInCloseBox(MessagePosition position)
Determine if the specified point is in this MessageWindow's "close" region.
The namespace containing all Design Pattern Examples implemented in C++.
@ Close
Window is asked to close itself, generally sent by the window itself in response to a button up in a ...
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
Represents a message sent to the windows. A message contains a type and a position.
MessagePosition Position
Position of message when the message was sent. In a real system, this would generally represent the p...