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

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

#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include "helpers/formatstring.h"
#include "HandlerChain_WindowRectangle.h"
Include dependency graph for HandlerChain_WindowRectangle.c:

Go to the source code of this file.

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.
 

Variables

const int MINIMUM_WIDTH = 4
 Minimum width of a window (to accommodate a close box).
 
const int MINIMUM_HEIGHT = 4
 Minimum height of a window (to accommodate a close box).
 

Detailed Description

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().

Variable Documentation

◆ MINIMUM_HEIGHT

const int MINIMUM_HEIGHT = 4

Minimum height of a window (to accommodate a close box).

Definition at line 23 of file HandlerChain_WindowRectangle.c.

Referenced by WindowRectangle_Initialize().

◆ MINIMUM_WIDTH

const int MINIMUM_WIDTH = 4

Minimum width of a window (to accommodate a close box).

Definition at line 19 of file HandlerChain_WindowRectangle.c.

Referenced by WindowRectangle_Initialize().