Index

Package: Widgets

Description

package Widgets is

Classes

Key_Action

type Key_Action is new Action with private;

Ancestors:

Primitive operations:

Actions.Construct (Inherited)
Construct
Objects.Adjust (Inherited)
Objects.Construct (Inherited)
Objects.Delete (Inherited)
Objects.Object_Read (Inherited)
Objects.Object_Write (Inherited)
Objects.To_String (Inherited)
Represents a widget action involving a keyboard key, such as a key press or release.

Resize_Action

type Resize_Action is new Action with private;

Ancestors:

Primitive operations:

Actions.Construct (Inherited)
Objects.Adjust (Inherited)
Objects.Construct (Inherited)
Objects.Delete (Inherited)
Objects.Object_Read (Inherited)
Objects.Object_Write (Inherited)
Objects.To_String (Inherited)
Represents a widget resize or move action.

Visibility_Action

type Visibility_Action is new Action with private;

Ancestors:

Primitive operations:

Actions.Construct (Inherited)
Construct
Objects.Adjust (Inherited)
Objects.Construct (Inherited)
Objects.Delete (Inherited)
Objects.Object_Read (Inherited)
Objects.Object_Write (Inherited)
Objects.To_String (Inherited)
Represents a change in the widget's visability state, either directly or indirectly via a change in an ancestor's visability.

Widget (abstract)

type Widget is abstract new Limited_Object with private;

Ancestors:

Immediate Children:

Primitive operations:

Activate_Popup
Bring_To_Front
Construct
Delete (overriding Objects.Delete)
Draw_Content
Find_Widget
Get_Min_Height
Get_Min_Width
Get_Process_Name
Get_Window (overriding Widgets.Containers.Windows.Window)
Handle_Ancestor_Hidden
Handle_Ancestor_Unhidden
Handle_Blur
Handle_Click
Handle_Descendant_Hidden
Handle_Descendant_Unhidden
Handle_Disabled
Handle_Enabled
Handle_Enter
Handle_Exit
Handle_Focus
Handle_Hidden
Handle_Key_Held
Handle_Key_Press
Handle_Key_Release
Handle_Mouse_Held
Handle_Mouse_Move
Handle_Mouse_Press
Handle_Mouse_Release
Handle_Mouse_Scroll
Handle_Resize
Handle_Unhidden
Objects.Construct (Inherited)
Pack
Set_Dirty
Set_Parent
To_String (overriding Objects.To_String)
Translate_To_Content
Translate_To_Window
A Widget is the most basic component of the GUI. A widget represents a control element, display element, or container in the interface. Widgets are organized as a tree, ultimately rooted at a Window widget, with each widget having one parent. Widgets are part of an event-based interface model, where Action_Listeners listen for and handle Actions that are generated by widgets when a change occurs or input is received.

Types

A_Key_Action

type A_Key_Action is access all Key_Action'Class;

Key_Listener (abstract)

type Key_Listener is limited interface and Action_Listener;
This is the interface to implement in order to listen to key actions. When a key action occurs, the listener will be notified of the type of action performed and the widget that received the key action.

A_Key_Listener

type A_Key_Listener is access all Key_Listener'Class;

A_Key_Handler

type A_Key_Handler is
        access procedure( action  : A_Key_Action;
                          handled : out Boolean );
A simple procedure to handle a key action, used by Simple_Key_Listener.

A_Resize_Action

type A_Resize_Action is access all Resize_Action'Class;

Resize_Listener (abstract)

type Resize_Listener is limited interface and Action_Listener;
This is the interface to implement in order to listen to resize actions. When a resize action occurs, the listener will be notified of the source widget's content size changed.

A_Resize_Listener

type A_Resize_Listener is access all Resize_Listener'Class;

A_Visibility_Action

type A_Visibility_Action is access all Visibility_Action'Class;

Visibility_Listener (abstract)

type Visibility_Listener is limited interface and Action_Listener;
Implement this interface to receive notifications when a widget's visibility changes.

A_Visibility_Listener

type A_Visibility_Listener is access all Visibility_Listener'Class;

Animated (abstract)

type Animated is limited interface and Process;
Implement the Animated interface to automatically run a widget as a process when it's visible. Animated extends Process, so the implementor must have a Tick procedure that will be automatically called. The widget subclass does not need to attach itself to a Process_Manager; that is handled automatically.

A_Widget

type A_Widget is access all Widget'Class;

Constants & Global variables

Key_Press (Actions.Action_Id)

Key_Press   : constant Action_Id;

Key_Held (Actions.Action_Id)

Key_Held    : constant Action_Id;
key pressed down

Key_Release (Actions.Action_Id)

Key_Release : constant Action_Id;
key held for the key repeat delay

Widget_Resized (Actions.Action_Id)

Widget_Resized : constant Action_Id;

Change_Visibility (Actions.Action_Id)

Change_Visibility : constant Action_Id;

Subprograms & Entries

Get_Key

function Get_Key
( this: not null access Key_Action'Class ) return Integer;
Returns the scancode of the key involved in the action.

Get_Modifiers

function Get_Modifiers
( this: not null access Key_Action'Class ) return Modifiers_Array;
Returns the state of all modifier keys at the time of the action.

Handle_Action (abstract)

procedure Handle_Action
( this: access Key_Listener;
action: A_Key_Action;
handled: out Boolean ) is abstract;
Handles the key action 'action'. If 'handled' returns True, the action will not be propagated to the next registered listener.

Handle_Action (abstract)

procedure Handle_Action
( this: access Resize_Listener;
action: A_Resize_Action ) is abstract;
Handles the resize action 'action'.

Is_Visible

function Is_Visible
( this: not null access Visibility_Action'Class ) return Boolean;
Returns True if the source widget is now visible.

Handle_Action (abstract)

procedure Handle_Action
( this: access Visibility_Listener;
action: A_Visibility_Action ) is abstract;
Handles the visibility action 'action'.

Add_Listener

procedure Add_Listener
( this: not null access Widget'Class;
listener: not null A_Key_Listener );
Adds an object as a listener for key actions, such as press, release and held actions.

Add_Listener

procedure Add_Listener
( this: not null access Widget'Class;
key: Integer;
modifiers: Modifiers_Pattern;
handler: not null A_Key_Handler );
Adds the handler procedure as a simple listener. The listener can't be removed and can be added multiple times.

Add_Listener

procedure Add_Listener
( this: not null access Widget'Class;
key: Integer;
handler: not null A_Key_Handler );
Adds the handler procedure as a simple listener. The listener can't be removed and can be added multiple times. The key modifiers will match any combination so this procedure is equivalent to calling Add_Listener with modifiers => MODIFIERS_ANY.

Add_Listener

procedure Add_Listener
( this: not null access Widget'Class;
listener: not null A_Resize_Listener );
Adds an object as a listener for resize actions. Resize listeners are notified when the widget's content size changes.

Add_Listener

procedure Add_Listener
( this: not null access Widget'Class;
listener: not null A_Visibility_Listener );
Adds an object as a listener for visibility actions. Visibility listeners are notified when the widget becomes visible or hidden.

Draw

procedure Draw
( this: access Widget;
bmp: not null A_Bitmap;
x, y: Integer );
Draws the widget and children to bmp, redrawing contents if necessary

Get_Attribute

function Get_Attribute
( this: not null access Widget'Class;
name: String ) return Integer;
Returns the value of the specified attribute as an integer. If the attribute is not an integer, it will be converted. If the attribute does not exist or can not be converted then VALUE_NOT_FOUND or INVALID_CONVERSION will be raised, respectively.

Get_Attribute

function Get_Attribute
( this: not null access Widget'Class;
name: String ) return String;
Returns the value of the specified attribute as a string. If the attribute is not an string, it will be converted. If the attribute does not exist or can not be converted then VALUE_NOT_FOUND or INVALID_CONVERSION will be raised, respectively.

Get_Border

function Get_Border
( this: not null access Widget'Class ) return Border_Type;
Returns the widget's drawn border type

Get_Color

function Get_Color
( this: access Widget;
purpose: Color_Purpose ) return Color_Type;
Returns the color used by the widget for a specific purpose. Not all color purposes apply to every widget.

Get_Font_Name

function Get_Font_Name
( this: not null access Widget'Class ) return String;
Returns the name of the widget's font.

Get_Font_Size

function Get_Font_Size
( this: not null access Widget'Class ) return Positive;
Returns the point size of the widget's font.

Get_Height

function Get_Height
( this: not null access Widget'Class ) return Integer;
Returns the screen height of the widget (height of the viewport)

Get_Id

function Get_Id
( this: not null access Widget'Class ) return String;
Returns the unique id of the widget

Get_View

function Get_View
( this: access Widget ) return access Game_Views.Game_View'Class;
Returns the view controlling this widget.

Get_Width

function Get_Width
( this: not null access Widget'Class ) return Natural;
Returns the screen width of the widget (width of the viewport).

Get_Zoom

function Get_Zoom
( this: not null access Widget'Class ) return Float;
Returns the zoom factor of the widget. Numbers greater than one mean the view of the widget is zoomed in.

Is_Enabled

function Is_Enabled
( this: not null access Widget'Class ) return Boolean;
Returns true if the widget is current enabled.

Is_Visible

function Is_Visible
( this: not null access Widget'Class ) return Boolean;
Returns true if the widget is currently visible.

Move

procedure Move
( this: not null access Widget'Class;
xdist, ydist: Integer );
Moves the widget within its parent's content region.

Move_To

procedure Move_To
( this: not null access Widget'Class;
x, y: Integer );
Moves the widget to an absolute location with its parent's content region. The top left of the widget is positioned at x, y.

Remove_Listener

procedure Remove_Listener
( this: not null access Widget'Class;
listener: not null A_Key_Listener );
Unregisters 'listener' as a key action listener.

Remove_Listener

procedure Remove_Listener
( this: not null access Widget'Class;
listener: not null A_Resize_Listener );
Unregisters 'listener' as a resize action listener.

Remove_Listener

procedure Remove_Listener
( this: not null access Widget'Class;
listener: not null A_Visibility_Listener );
Unregisters 'listener' as a visibility action listener.

Redraw

procedure Redraw
( this: not null access Widget'Class );
Forces the widget to redraw itself on the next frame.

Scroll

procedure Scroll
( this: not null access Widget'Class;
x, y: Integer );
Scrolls the widget's viewport, if possible, by the given x, y distances. The positive scroll direction is down and to the right.

Scroll_To

procedure Scroll_To
( this: not null access Widget'Class;
x, y: Integer );
Scrolls the widget's viewport by moving the top left corner to the given location.

Set_Attribute

procedure Set_Attribute
( this: not null access Widget'Class;
name: String;
val: Integer );
Sets an integer attribute on the widget. Attributes are used for encapsulating minor additional data without extending a widget class.

Set_Attribute

procedure Set_Attribute
( this: not null access Widget'Class;
name: String;
val: String );
Sets a string attribute on the widget. Attributes are used for encapsulating minor additional data without extending a widget class.

Set_Border

procedure Set_Border
( this: not null access Widget'Class;
border: Border_Type );
Sets the border for the widget, if it uses one.

Set_Color

procedure Set_Color
( this: access Widget;
purpose: Color_Purpose;
color: Color_Type );
Sets the color used by the widget for a specific purpose. Not all color purposes apply to every widget.

Set_Enabled

procedure Set_Enabled
( this: not null access Widget'Class;
enabled: Boolean );
Sets whether the widget is enabled or not. If not enabled, the widget will ignore all user interaction. If a widget is disabled, all of its children are also implicitly disabled.

Set_Focusable

procedure Set_Focusable
( this: not null access Widget'Class;
focusable: Boolean );
Sets whether the widget can accept focus.

Set_Focused

procedure Set_Focused
( this: not null access Widget'Class;
focused: Boolean );
Sets the widget's focused state. This does not focus the widget. It should be called only by a Window widget.

Set_Font

procedure Set_Font
( this: not null access Widget'Class;
name: String := "";
size: Natural := 0 );
Sets the widget's font name and/or size.

Set_Layout_Center

procedure Set_Layout_Center
( this: not null access Widget'Class;
width, height: Natural );
Sets the widget's layout as centered within the parent's content area, given the viewport size.

Set_Layout_CenterH

procedure Set_Layout_CenterH
( this: not null access Widget'Class;
width: Natural;
top, bottom: Integer );
Sets the widget's layout as centered horizontally and spaced from the top and bottom of the parent's content area like layout LTRB.

Set_Layout_CenterHY

procedure Set_Layout_CenterHY
( this: not null access Widget'Class;
width: Natural;
y1, y2: Integer );
Sets the widget's layout as centered horizontally and positioned absolutely in the vertical dimension. y1 and y2 are both distances from the top of the parent's content region. Negative values will position the widget off the top edge of the parent's content.

Set_Layout_LTRB

procedure Set_Layout_LTRB
( this: not null access Widget'Class;
left, top, right, bottom: Integer );
Sets the widget's layout based on the distance of the viewport's edges from the edges of the parent's content area.

Set_Layout_LTWH

procedure Set_Layout_LTWH
( this: not null access Widget'Class;
left, top: Integer;
width, height: Natural );
Sets the widget's layout based on a size and distance from the top left edges of the parent's content area. If top or left is negative then the top left corner of the widget will be positioned relative to the bottom or right edge of the content area. If width or height is 0 then the widget's minimum width or height will be used instead.

Set_Layout_XYWH

procedure Set_Layout_XYWH
( this: not null access Widget'Class;
x, y: Integer;
width, height: Natural );
Sets the widget's layout based on a size and absolute distance from the top left corner of the parent's content area. This layout is nearly identical to LTWH except negative values for 'x' and 'y' are kept relative to the upper left. If width or height is 0 then the widget's minimum width or height will be used instead.

Set_Min_Height

procedure Set_Min_Height
( this: not null access Widget'Class;
height: Natural );
Sets the minimum height value to override the computed minimum height for the widget. If height is set to zero, the computed value is returned by Get_Min_Height.

Set_Min_Width

procedure Set_Min_Width
( this: not null access Widget'Class;
width: Natural );
Sets the minimum width value to override the computed minimum width for the widget. If width is set to zero, the computed value is returned by Get_Min_Width.

Set_Next

procedure Set_Next
( this: not null access Widget'Class;
id: String );
Sets the next widget to receive focus when tab is pressed on this widget.

Set_Prev

procedure Set_Prev
( this: not null access Widget'Class;
id: String );
Sets the next widget to receive focus when shift + tab is pressed on this widget.

Set_Transparent

procedure Set_Transparent
( this: not null access Widget'Class;
transparent: Boolean );
Set to true if the widget is partly transparent so that it will be drawn over the background.

Set_Visible

procedure Set_Visible
( this: not null access Widget'Class;
visible: Boolean );
Sets whether the widget is visible.

Set_Zoom

procedure Set_Zoom
( this: access Widget;
zoom: Float );
Sets the zoom factor. Values > 1 make the contents larger and values < 1 make the contents smaller. This does not affect the screen size of the widget; Increasing the zoom decreases the visible content area.

Smooth_Text

procedure Smooth_Text
( this: not null access Widget'Class;
enabled: Boolean );
Enable/disable font smoothing if the widget draws text. This is only a hint; it can be used to disable font smoothing, but font smoothing can only work if the conditions support it (type of font, transparency, etc.) Smooth fonts are enabled by default.

Delete

procedure Delete
( this: in out A_Widget );
Deletes the Widget and all children.