Suggesting the Appearance of Styles

Suggesting the Appearance of Styles — Setting style hints

Functions

Types and Values

Includes

#include <libchimara/glk.h>

Description

There are no guarantees of how styles will look, but you can make suggestions.

Initially, no hints are set for any window type or style. Note that having no hint set is not the same as setting a hint with value 0.

These functions do not affect existing windows. They affect the windows which you create subsequently. If you want to set hints for all your game windows, call glk_stylehint_set() before you start creating windows. If you want different hints for different windows, change the hints before creating each window.

This policy makes life easier for the interpreter. It knows everything about a particular window's appearance when the window is created, and it doesn't have to change it while the window exists.

Hints are hints. The interpreter may ignore them, or give the player a choice about whether to accept them. Also, it is never necessary to set hints. You don't have to suggest that style_Preformatted be fixed-width, or style_Emphasized be boldface or italic; they will have appropriate defaults. Hints are for situations when you want to change the appearance of a style from what it would ordinarily be. The most common case when this is appropriate is for the styles style_User1 and style_User2.

There are currently ten style hints defined. More may be defined in the future.

Again, when passing a style hint to a Glk function, any value is actually legal. If the interpreter does not recognize the stylehint value, it will ignore it.

This policy allows for the future definition of style hints without breaking old Glk libraries.

Functions

glk_stylehint_set ()

void
glk_stylehint_set (glui32 wintype,
                   glui32 styl,
                   glui32 hint,
                   glsi32 val);

Sets a hint about the appearance of one style for a particular type of window. You can also set wintype to wintype_AllTypes, which sets a hint for all types of window.

There is no equivalent constant to set a hint for all styles of a single window type.

Parameters

wintype

The window type to set a style hint on, or wintype_AllTypes.

 

styl

The style to set a hint for.

 

hint

The type of style hint, one of the stylehint_ constants.

 

val

The style hint. The meaning of this depends on hint .

 

glk_stylehint_clear ()

void
glk_stylehint_clear (glui32 wintype,
                     glui32 styl,
                     glui32 hint);

Clears a hint about the appearance of one style for a particular type of window to its default value. You can also set wintype to wintype_AllTypes, which clears a hint for all types of window.

There is no equivalent constant to reset a hint for all styles of a single window type.

Parameters

wintype

The window type to set a style hint on, or wintype_AllTypes.

 

styl

The style to set a hint for.

 

hint

The type of style hint, one of the stylehint_ constants.

 

Types and Values

stylehint_Indentation

#define stylehint_Indentation (0)

How much to indent lines of text in the given style. May be a negative number, to shift the text out (left) instead of in (right). The exact metric isn't precisely specified; you can assume that +1 is the smallest indentation possible which is clearly visible to the player.


stylehint_ParaIndentation

#define stylehint_ParaIndentation (1)

How much to indent the first line of each paragraph. This is in addition to the indentation specified by stylehint_Indentation. This too may be negative, and is measured in the same units as stylehint_Indentation.


stylehint_Justification

#define stylehint_Justification (2)

The value of this hint must be one of the constants stylehint_just_LeftFlush, stylehint_just_LeftRight (full justification), stylehint_just_Centered, or stylehint_just_RightFlush.


stylehint_Size

#define stylehint_Size (3)

How much to increase or decrease the font size. This is relative; 0 means the interpreter's default font size will be used, positive numbers increase it, and negative numbers decrease it. Again, +1 is the smallest size increase which is easily visible.

The amount of this increase may not be constant. +1 might increase an 8-point font to 9-point, but a 16-point font to 18-point.


stylehint_Weight

#define stylehint_Weight (4)

The value of this hint must be 1 for heavy-weight fonts (boldface), 0 for normal weight, and -1 for light-weight fonts.


stylehint_Oblique

#define stylehint_Oblique (5)

The value of this hint must be 1 for oblique fonts (italic), or 0 for normal angle.


stylehint_Proportional

#define stylehint_Proportional (6)

The value of this hint must be 1 for proportional-width fonts, or 0 for fixed-width.


stylehint_TextColor

#define stylehint_TextColor (7)

The foreground color of the text. This is encoded in the 32-bit hint value: the top 8 bits must be zero, the next 8 bits are the red value, the next 8 bits are the green value, and the bottom 8 bits are the blue value. Color values range from 0 to 255.

So 0x00000000 is black, 0x00FFFFFF is white, and 0x00FF0000 is bright red.


stylehint_BackColor

#define stylehint_BackColor (8)

The background color behind the text. This is encoded the same way as stylehint_TextColor.


stylehint_ReverseColor

#define stylehint_ReverseColor (9)

The value of this hint must be 0 for normal printing (stylehint_TextColor on stylehint_BackColor), or 1 for reverse printing (stylehint_BackColor on stylehint_TextColor).

Some libraries may support this hint but not the stylehint_TextColor and stylehint_BackColor hints. Other libraries may take the opposite tack; others may support both, or neither.


stylehint_just_LeftFlush

#define   stylehint_just_LeftFlush (0)

A value for stylehint_Justification representing left-justified text.


stylehint_just_LeftRight

#define   stylehint_just_LeftRight (1)

A value for stylehint_Justification representing fully justified text.


stylehint_just_Centered

#define   stylehint_just_Centered (2)

A value for stylehint_Justification representing centered text.


stylehint_just_RightFlush

#define   stylehint_just_RightFlush (3)

A value for stylehint_Justification representing right-justified text.