Index

Package: Themes

Description

package Themes is

Classes

Theme (abstract)

type Theme is abstract new Limited_Object with private;

Ancestors:

Immediate Children:

Themes.Ked.Ked_Theme

Primitive operations:

Border_Width
Construct (overriding Objects.Construct)
Delete (overriding Objects.Delete)
Label_Height
Objects.To_String (Inherited)
A Theme is an abstract class used by widgets to provide the GUI's look and feel. The Theme is a singleton object.

Types

Align_Type

type Align_Type is ( Align_Left, Align_Center, Align_Right );
enumeration for text/icon alignment

Border_Type

type Border_Type is ( Border_None, Border_Raised, Border_Sunk, Border_Line );
enumeration of border styles

Color_Purpose

type Color_Purpose is ( Background,
                            Foreground,
                            Selected,
                            Selected_Text,
                            Text );
enumeration of the different purposes a widget has for user-defined colors. not all widgets use colors for every purpose.

Colors_Array

type Colors_Array is array (Color_Purpose) of Color_Type;
an array of colors, one for each potential purpose in a widget

A_Theme

type A_Theme is access all Theme'Class;

Constants & Global variables

DEFAULT_FONT_NAME (String)

DEFAULT_FONT_NAME : constant String := "standard";

DEFAULT_FONT_SIZE (Positive)

DEFAULT_FONT_SIZE : constant Positive := 14;
default gui font

Subprograms & Entries

Border_Width

function Border_Width
( this: access Theme ) return Natural;
Returns the width in pixels of borders drawn by the Theme.

Color

function Color
( this: access Theme;
purpose: Color_Purpose ) return Color_Type;
Returns the Theme's default color for a 'purpose'.

Draw_Border

procedure Draw_Border
( this: access Theme;
dc: Drawing_Context;
border: Border_Type;
x1, y1, x2, y2: Integer;
color: Color_Type );
Draws a rectangular border from x1, y1 to x2, y2 using 'border' as the border type and 'color' as the border's dominant color.

Draw_Box

procedure Draw_Box
( this: access Theme;
dc: Drawing_Context;
x1, y1, x2, y2: Integer;
color: Color_Type;
border: Border_Type := Border_None );
Draws a filled rectangle of 'color' (unless 'color' is transparent) from x1, y1 to x2, y2 and a border of type 'border' with 'color' as the border's dominant color.

Draw_Label

procedure Draw_Label
( this: access Theme;
dc: Drawing_Context;
x1, y1, x2, y2: Integer;
icon: A_Bitmap;
text: String;
fontName: String;
fontSize: Positive;
color: Color_Type;
align: Align_Type;
smooth: Boolean := False );
Draws a label composed of the given icon, some horizontal spacing, and the given text. If the icon or the text is ommitted, the spacing that would separate the two will also be ommitted. The 'smooth' argument enables text anti-aliasing. The 'align' argument determines the alignment for the icon and text as a group within the width of the area given for the label by x1 and x2. The label will be centered vertically between y1 and y2.

Get_Bitmap (abstract)

function Get_Bitmap
( this: access Theme;
id: Natural ) return A_Bitmap is abstract;
Synchronously retrieves a bitmap by tile id.

Get_Font

function Get_Font
( this: not null access Theme'Class;
name: String;
size: Positive ) return Font_Type;
Returns a reference to a previously loaded font. If the font by this name and in this size has not been loaded previously, it will be reloaded in the new size 'size'. If the font 'name' is unknown or it can't be reloaded in the requested size, an exception will be raised.

Get_Text_Height

function Get_Text_Height
( this: not null access Theme'Class;
fontName: String;
fontSize: Positive ) return Natural;
Returns the height in pixels of any text drawn in the given font. Zero is returned if the font hasn't been loaded.

Get_ID (abstract)

function Get_ID
( this: access Theme;
name: String ) return Natural is abstract;
Returns the id number of a tile referenced by name in the theme's tile library.

Get_Scaling_Filter

function Get_Scaling_Filter
( this: not null access Theme'Class ) return Filter_Type;
Returns the theme's current scaling filter type.

Get_Text_Width

function Get_Text_Width
( this: not null access Theme'Class;
text: String;
fontName: String;
fontSize: Positive ) return Natural;
Returns the width in pixels of 'text' in the given font. Zero is returned if the font hasn't been loaded.

Label_Height

function Label_Height
( this: access Theme;
icon: A_Bitmap;
text: String;
fontName: String;
fontSize: Positive ) return Natural;
Returns the minimum height in pixels required to draw a label with the given icon and text. If Draw_Label is overridden, this function should also be appropriately overridden to return the correct height.

Label_Width

function Label_Width
( this: access Theme;
icon: A_Bitmap;
text: String;
fontName: String;
fontSize: Positive ) return Natural;
Returns the minimum width in pixels required to draw a label with the given icon and text. If Draw_Label is overridden, this function should also be appropriately overridden to return the correct width.

Register_Font

procedure Register_Font
( this: not null access Theme'Class;
path: String;
name: String );
Registers a font file with a font name. The font will be loaded first at size DEFAULT_FONT_SIZE. If the file at 'path' can't be loaded, a Resource_Error exception will be raised.

Set_Scaling_Filter

procedure Set_Scaling_Filter
( this: not null access Theme'Class;
filter: Filter_Type );
Sets the theme's current scaling filter type.

Create_Theme

procedure Create_Theme;
Creates the global theme instance. Raises an exception on error.

Delete_Theme

procedure Delete_Theme;
Deletes the global theme instance.

Get

function Get return A_Theme;
Returns a reference to the global theme or null, if it has not been created.