Skip to content

GUIAlertBox

Hampus Sandberg edited this page Apr 12, 2015 · 2 revisions

Index


Info

TODO

Struct

/*
 * @name	GUIAlertBox
 * @brief	-	A rectangular box with a title, close button, info text and two
 * 				buttons.
 * 			-	When one of the buttons are pressed the corresponding callback
 * 				function will be called.
 * 			-	The position and dimensions can be set using the object.
 * 			-	There are various color choices for flexibility.
 * 			-	The left and right button can have two rows of text.
 * 			-	The font is used for all elements of the alert box.
 * 			-	titleHeight sets the height of the title bar and also the
 * 				height of the close button.
 * 			-	leftRightButtonHeight sets the height of the left and right
 * 				button.
 * 			-	padding controls the padding of the info text and left/right
 * 				button.
 * 			-	Dimension for the info text is calculated automatically based
 * 				on the other dimension. This means you have to for example
 * 				increase the object width/height if you can't fit all of the
 * 				info text you want.
 * 			-	The text in the info is center-aligned.
 * 			-	The GUI objects should not be touched by the user, but are also
 * 				reset in case they were. (Better safe than sorry).
 */
typedef struct
{
	/* Basic information about the object */
	GUIObject object;

	/* Colors */
	guiColor backgroundColor;
	guiColor titleBackgroundColor;
	guiColor titleTextColor;
	guiColor infoTextColor;
	guiColor buttonTextColor;
	guiColor leftButtonColor;
	guiColor rightButtonColor;

	/*
	 * Pointer to callback functions that are called when a button has been
	 * pressed
	 */
	void (*actionButtonPressed)(GUIAlertBoxCallbackButton);

	/* Title, info text and button texts */
	char* title;
	char* infoText;
	char* leftButtonText[2];
	char* rightButtonText[2];
	FONT* font;

	/* Dimensions and Padding */
	uint16_t titleHeight;
	uint16_t leftRightButtonHeight;
	GUIPadding padding;

	/* Internal stuff - Do not touch! */
	GUILabel titleLabel;
	GUIStaticTextBox infoTextBox;
	GUIButton closeButton;
	GUIButton leftButton;
	GUIButton rightButton;
} GUIAlertBox;

Example Init

TODO

Clone this wiki locally