10#include "helpers/formatstring.h"
21 if (position != NULL && output != NULL)
23 char* buffer =
formatstring(
"x=%2d,y=%2d", position->
X, position->
Y);
29 printf(
" Error! out of memory condition appending message position as string in MessagePosition_ToString()!\n");
35 printf(
" Error! Out of memory formatting position in MessagePosition_ToString()!\n");
68 if (message != NULL && output != NULL)
70 const char* messageTypeAsString = NULL;
74 messageTypeAsString =
"Close";
78 messageTypeAsString =
"ButtonDown";
82 messageTypeAsString =
"ButtonUp";
90 messageTypeAsString =
"Unknown message type";
105 printf(
" Error! Out of memory condition in Message_ToString() while appending string to output!\n");
111 printf(
" Error! out of memory formatting message in Message_ToString()!\n");
bool Message_ToString(Message *message, DynamicString *output)
Convert a Message object to a string representation.
void Message_Initialize(Message *message, MessageType type, int x, int y)
Initialize a Message structure.
bool MessagePosition_ToString(MessagePosition *position, DynamicString *output)
Convert a MessagePosition object to a string representation.
Declaration of the Message and MessagePosition structures, along with the functions,...
MessageType
Type of message handled by MessageWindow.
@ ButtonUp
Take an action on the currently selected window.
@ ButtonDown
Selects a window based on position.
@ Destroy
Window is being told to destroy itself. This is sent in response to seeing the Close message.
@ Close
Window is asked to close itself, generally sent by the window itself in response to a button up in a ...
void DynamicString_Clear(DynamicString *string)
Clear a DynamicString object, releasing any allocated memory. Resets to an empty string.
void DynamicString_Initialize(DynamicString *string)
Initialize a DynamicString object to an empty string.
bool DynamicString_Append(DynamicString *string, const char *s)
Append the specified string to the DynamicString object.
Represents a string that can be grown dynamically.
char * string
The string that can grow.
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...
MessageType MessageType
Value from the MessageType enumeration indicating the type of this message.
Position of the message in global coordinates (same scope of coordinates as windows)....