Design Pattern Examples
Overview of object-oriented design patterns
HandlerChain_MessageWindow.h File Reference

Declaration of the MessageWindow support functions, MessageWindow_Create(), MessageWindow_Destroy(), MessageWindow_ProcessMessage(), and MessageWindow_ToString(), as used in the HandlerChain Pattern. More...

#include <stdbool.h>
#include "HandlerChain_Message.h"
Include dependency graph for HandlerChain_MessageWindow.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __HANDLERCHAIN_WINDOW_H__
 

Functions

int MessageWindow_Create (const char *title, int x, int y, int w, int h)
 Create a MessageWindow object with the given properties and return the ID of the object.
 
void MessageWindow_Destroy (int windowId)
 Destroy the MessageWindow object with the given ID. Removes the window from any message handling as well.
 
bool MessageWindow_ProcessMessage (int windowId, Message *message)
 Pass a Message object to a window for processing.
 
bool MessageWindow_ToString (int windowId, DynamicString *output)
 Convert the specified window to a string representation.
 

Detailed Description

Macro Definition Documentation

◆ __HANDLERCHAIN_WINDOW_H__

#define __HANDLERCHAIN_WINDOW_H__

Definition at line 10 of file HandlerChain_MessageWindow.h.

Function Documentation

◆ MessageWindow_Create()

int MessageWindow_Create ( const char *  title,
int  x,
int  y,
int  w,
int  h 
)

Create a MessageWindow object with the given properties and return the ID of the object.

Parameters
titleTitle of the window.
xHorizontal position of the upper left corner of the window.
yVertical position of the upper left corner of the window.
wWidth of the window.
hHeight of the window.
Returns
Returns the ID of the window, if successfully created; otherwise, returns false.

Definition at line 318 of file HandlerChain_MessageWindow.c.

References _AppendWindowToList(), _Window::_closeBox, _nextWindowId, _Window::_title, _Window::_windowBox, _Window::_windowId, CLOSE_HEIGHT, CLOSE_WIDTH, HandlerChain_AddWindow(), WindowRectangle::Right, WindowRectangle::Top, and WindowRectangle_Initialize().

Referenced by _HandlerChain_ConstructWindowChain().

◆ MessageWindow_Destroy()

void MessageWindow_Destroy ( int  windowId)

Destroy the MessageWindow object with the given ID. Removes the window from any message handling as well.

Parameters
windowIdID of the MessageWindow to destroy.

Definition at line 354 of file HandlerChain_MessageWindow.c.

References _FindWindow(), and _RemoveWindowFromList().

Referenced by _HandleDestroyMessage().

◆ MessageWindow_ProcessMessage()

bool MessageWindow_ProcessMessage ( int  windowId,
Message message 
)

Pass a Message object to a window for processing.

Parameters
windowIdThe ID of the window who will get the message.
messageThe Message object to process.
Returns
Returns true if the message was handled and no further windows should be notified; otherwise return false to allow the message to be passed to subsequent windows.

Definition at line 367 of file HandlerChain_MessageWindow.c.

References _FindWindow(), _HandleButtonDownMessage(), _HandleButtonUpMessage(), _HandleCloseMessage(), _HandleDestroyMessage(), ButtonDown, ButtonUp, Close, Destroy, and Message::MessageType.

Referenced by HandlerChain_SendMessage().

◆ MessageWindow_ToString()

bool MessageWindow_ToString ( int  windowId,
DynamicString output 
)

Convert the specified window to a string representation.

Parameters
windowIdID of the window to convert.
outputA DynamicString that returns the string version of the window. Call DynamicString_Initialize() on this object before passing as an argument.
Returns
Returns true if the message window was converted to a string; otherwise, returns false, indicating an out of memory condition (or a NULL argument).

Definition at line 409 of file HandlerChain_MessageWindow.c.

References _FindWindow(), _Window::_selected, _Window::_title, _Window::_windowBox, _Window::_windowId, DynamicString_Append(), DynamicString_Clear(), formatstring(), DynamicString::string, and WindowRectangle_ToString().

Referenced by HandlerChain_ToString().