with Allegro.Bitmaps; use Allegro.Bitmaps;
with Allegro.Truecolor; use Allegro.Truecolor;
with Drawing_Contexts; use Drawing_Contexts;
with Font_API; use Font_API;
with Objects; use Objects;
with Scaling; use Scaling;
private with Ada.Containers.Indefinite_Ordered_Maps;
package Themes is
type Align_Type is ( Align_Left, Align_Center, Align_Right );
type Border_Type is ( Border_None, Border_Raised, Border_Sunk, Border_Line );
type Color_Purpose is ( Background,
Foreground,
Selected,
Selected_Text,
Text );
type Colors_Array is array (Color_Purpose) of Color_Type;
DEFAULT_FONT_NAME : constant String := "standard";
DEFAULT_FONT_SIZE : constant Positive := 14;
type Theme is abstract new Object with private;
type A_Theme is access all Theme'Class;
function Create_Theme return A_Theme;
pragma Postcondition( Create_Theme'Result /= null );
function Border_Width( this : access Theme ) return Natural;
function Color( this : access Theme; purpose : Color_Purpose ) return Color_Type;
procedure Draw_Border( this : access Theme;
dc : Drawing_Context;
border : Border_Type;
x1, y1,
x2, y2 : Integer;
color : Color_Type );
procedure Draw_Box( this : access Theme;
dc : Drawing_Context;
x1, y1,
x2, y2 : Integer;
color : Color_Type;
border : Border_Type := Border_None );
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 );
pragma Precondition( fontName'Length > 0 );
function Get_Bitmap( this : access Theme;
id : Natural ) return A_Bitmap is abstract;
function Get_Font( this : not null access Theme'Class;
name : String;
size : Positive ) return Font_Type;
pragma Precondition( name'Length > 0 );
function Get_Text_Height( this : not null access Theme'Class;
fontName : String;
fontSize : Positive ) return Natural;
pragma Precondition( fontName'Length > 0 );
function Get_ID( this : access Theme; name : String ) return Natural is abstract;
function Get_Scaling_Filter( this : not null access Theme'Class ) return Filter_Type;
function Get_Text_Width( this : not null access Theme'Class;
text : String;
fontName : String;
fontSize : Positive ) return Natural;
pragma Precondition( fontName'Length > 0 );
function Label_Height( this : access Theme;
icon : A_Bitmap;
text : String;
fontName : String;
fontSize : Positive ) return Natural;
pragma Precondition( fontName'Length > 0 );
function Label_Width( this : access Theme;
icon : A_Bitmap;
text : String;
fontName : String;
fontSize : Positive ) return Natural;
pragma Precondition( fontName'Length > 0 );
procedure Set_Scaling_Filter( this : not null access Theme'Class;
filter : Filter_Type );
procedure Delete( this : in out A_Theme );
pragma Postcondition( this = null );
private
package Font_Maps is new Ada.Containers.Indefinite_Ordered_Maps( String,
Font_Type,
"<",
"=" );
package Font_Paths is new Ada.Containers.Indefinite_Ordered_Maps( String,
String,
"<",
"=" );
type Theme is abstract new Object with
record
colors : Colors_Array := Colors_Array'(others => 0);
fonts : Font_Maps.Map;
fontPaths : Font_Paths.Map;
filter : Filter_Type := Filter_Nearest;
end record;
procedure Adjust( this : access Theme );
procedure Construct( this : access Theme );
procedure Delete( this : in out Theme );
function Load_Font( this : not null access Theme'Class;
path : String;
name : String;
size : Positive ) return Font_Type;
pragma Precondition( name'Length > 0 );
type Allocator is access function return A_Theme;
procedure Register_Allocator( allocate : not null Allocator );
end Themes;