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

Declaration of the WindowRectangle structure and its support functions, WindowRectangle_Initialize(), WindowRectangle_PointInside(), and WindowRectangle_ToString(), as used in the HandlerChain Pattern. More...

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

Go to the source code of this file.

Classes

struct  WindowRectangle
 Represents a rectangular region, with upper left and lower right coordinates. More...
 

Macros

#define __HANDLERCHAIN_WINDOWRECTANGLE_H__
 

Functions

void WindowRectangle_Initialize (WindowRectangle *rectangle, int x, int y, int width, int height)
 Initialize the specified WindowRectangle based on the given position and size in some arbitrary space. Ensures a minimum size.
 
bool WindowRectangle_PointInside (WindowRectangle *rectangle, MessagePosition *point)
 Determine if the given WindowRectangle object contains the given MessagePosition.
 
bool WindowRectangle_ToString (WindowRectangle *rectangle, DynamicString *output)
 Convert the given WindowRectangle to a string representation.
 

Detailed Description

Declaration of the WindowRectangle structure and its support functions, WindowRectangle_Initialize(), WindowRectangle_PointInside(), and WindowRectangle_ToString(), as used in the HandlerChain Pattern.

Definition in file HandlerChain_WindowRectangle.h.

Macro Definition Documentation

◆ __HANDLERCHAIN_WINDOWRECTANGLE_H__

#define __HANDLERCHAIN_WINDOWRECTANGLE_H__

Definition at line 10 of file HandlerChain_WindowRectangle.h.

Function Documentation

◆ WindowRectangle_Initialize()

void WindowRectangle_Initialize ( WindowRectangle rectangle,
int  x,
int  y,
int  width,
int  height 
)

Initialize the specified WindowRectangle based on the given position and size in some arbitrary space. Ensures a minimum size.

Parameters
rectangleA WindowRectangle object to initialize.
xHorizontal position of the upper left corner.
yVertical position of the upper left corner.
widthWidth of the rectangle.
heightHeight of the rectangle.

Definition at line 29 of file HandlerChain_WindowRectangle.c.

References WindowRectangle::Bottom, WindowRectangle::Left, MINIMUM_HEIGHT, MINIMUM_WIDTH, WindowRectangle::Right, and WindowRectangle::Top.

Referenced by MessageWindow_Create().

◆ WindowRectangle_PointInside()

bool WindowRectangle_PointInside ( WindowRectangle rectangle,
MessagePosition point 
)

Determine if the given WindowRectangle object contains the given MessagePosition.

Parameters
rectangleA WindowRectangle object to examine.
pointA MessagePosition object specifying a point in the same space as the rectangle value.
Returns
Returns true if the MessagePosition is in the WindowRectangle; otherwise, returns false.

Definition at line 51 of file HandlerChain_WindowRectangle.c.

References WindowRectangle::Bottom, WindowRectangle::Left, WindowRectangle::Right, WindowRectangle::Top, MessagePosition::X, and MessagePosition::Y.

Referenced by _HandleButtonDownMessage(), and _HandleButtonUpMessage().

◆ WindowRectangle_ToString()

bool WindowRectangle_ToString ( WindowRectangle rectangle,
DynamicString output 
)

Convert the given WindowRectangle to a string representation.

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

Definition at line 70 of file HandlerChain_WindowRectangle.c.

References WindowRectangle::Bottom, DynamicString_Append(), formatstring(), WindowRectangle::Left, WindowRectangle::Right, and WindowRectangle::Top.

Referenced by MessageWindow_ToString().