AG_STYLESHEET(3)

NAME
AG_StyleSheet - agar cascading style sheets

SYNOPSIS

    #include <agar/core.h>
    #include <agar/gui.h>

DESCRIPTION
The AG_StyleSheet interface allows Agar GUI style attributes to be loaded from a cascading style sheet. Agar style sheets use a particular syntax. Style sheets contain blocks of attributes which are applicable to specific Agar widget classes (and possibly, specific widget states as well). For example:

    AG_Button {
    	# Set colors for default state
    	color: rgb(125,125,125);
    	text-color: rgb(0,0,0);
    	# Set colors for "disabled" state
    	color#disabled: rgb(200,200,200);
    	text-color#disabled: rgb(125,125,125);
    	# Set colors for mouse hover state
    	color#hover: rgb(200,250,200);
    	text-color#hover: rgb(125,150,125);
    }

By default, a widget instance inherits its style attributes from its parent. The syntax allows certain attributes, such as "font-size" and "color" to be specified in relation to the parent. For example:

    	font-size: 50%;			# Half of parent font size
    	color: hsv(100%,50%,100%);	# Half of parent saturation
    	color: hsv(100%,100%,75%);	# 3/4 of parent value

The generic AG_Widget class defines the basic attributes "font-family", "font-size", "font-weight", "font-style", "color", "text-color", "line-color", "shape-color" and "border-color". For a full description of those attributes, refer to the “STYLE PROPERTIES” of the AG_Widget(3) manual page. Other Agar widget classes may define their own style attributes (these should be documented under the “STYLE PROPERTIES” section of the widget's manual page).

INITIALIZATION
void AG_InitStyleSheet(AG_StyleSheet *ss)

void AG_DestroyStyleSheet(AG_StyleSheet *css)

AG_StyleSheet * AG_LoadStyleSheet(AG_StyleSheet *css, const char *path)

int AG_LookupStyleSheet(AG_StyleSheet *css, void *widget, const char *key, char **rv)

The AG_InitStyleSheet() function initializes the given AG_StyleSheet as an empty style sheet. AG_DestroyStyleSheet() releases all resources allocated by a style sheet.

The AG_LoadStyleSheet() function loads a style sheet from path. On success, a newly allocated AG_StyleSheet is returned. If path begins with a "_" character, AG_LoadStyleSheet() will search for a statically-compiled stylesheet (i.e., "_agStyleDefault" is always available).

The AG_LookupStyleSheet() routine searches the style sheet for the specified attribute (identified by key). If the style sheet defines an attribute applicable to the specified widget instance (the widget argument), its value is returned into rv.

SEE ALSO
AG_Intro(3), AG_Widget(3), AG_Window(3)

HISTORY
The AG_StyleSheet interface first appeared in Agar 1.5.0.