Index

Package: Buttons

Description

package Widgets.Buttons is
Copyright (c) 2012 Kevin Wellwood All rights reserved. This source code is distributed under the Modified BSD License. For terms and conditions, see license.txt.

Classes

Button_Action

type Button_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 action involving a Button, like a press or release.

Button (abstract)

type Button is abstract new Widget with private;

Ancestors:

Immediate Children:

Primitive operations:

Add_Listener
Construct
Dispatch_Action
Draw_Content (overriding Widgets.Draw_Content)
Get_Min_Height (overriding Widgets.Get_Min_Height)
Get_Min_Width (overriding Widgets.Get_Min_Width)
Objects.Construct (Inherited)
Remove_Listener
Set_Color (overriding Widgets.Set_Color)
To_String (overriding Widgets.To_String)
Toggle_State
Widgets.Activate_Popup (Inherited)
Widgets.Bring_To_Front (Inherited)
Widgets.Construct (Inherited)
Widgets.Delete (Inherited)
Widgets.Draw (Inherited)
Widgets.Find_Widget_At (Inherited)
Widgets.Get_Color (Inherited)
Widgets.Get_Process_Name (Inherited)
Widgets.Get_View (Inherited)
Widgets.Get_Window (Inherited)
Widgets.Handle_Rooted (Inherited)
Widgets.Handle_Shown (Inherited)
Widgets.Is_Rooted (Inherited)
Widgets.Is_Showing (Inherited)
Widgets.On_Blur (Inherited)
Widgets.On_Click (Inherited)
Widgets.On_Descendant_Shown (Inherited)
Widgets.On_Disabled (Inherited)
Widgets.On_Enabled (Inherited)
Widgets.On_Enter (Inherited)
Widgets.On_Exit (Inherited)
Widgets.On_Focus (Inherited)
Widgets.On_Key_Press (Inherited)
Widgets.On_Key_Release (Inherited)
Widgets.On_Key_Typed (Inherited)
Widgets.On_Mouse_Held (Inherited)
Widgets.On_Mouse_Move (Inherited)
Widgets.On_Mouse_Press (Inherited)
Widgets.On_Mouse_Release (Inherited)
Widgets.On_Mouse_Scroll (Inherited)
Widgets.On_Resize (Inherited)
Widgets.On_Rooted (Inherited)
Widgets.On_Shown (Inherited)
Widgets.Pack (Inherited)
Widgets.Set_Border (Inherited)
Widgets.Set_Parent (Inherited)
Widgets.Set_Zoom (Inherited)
Widgets.Translate_To_Content (Inherited)
Widgets.Translate_To_Window (Inherited)
A Button is a simple control widget with two states: on and off. A button notifies listeners of each event, so that a listener can know when a button is pressed by the user, release, held down for a period of time, or clicked. This abstract class is intended to be extended by a subclass that implements a specific behavior, like toggling, or a button that goes back to Off as soon as the mouse is released.

Types

A_Button_Action

type A_Button_Action is access all Button_Action'Class;

Button_Listener (abstract)

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

A_Button_Listener

type A_Button_Listener is access all Button_Listener'Class;

A_Button

type A_Button is access all Button'Class;

Constants & Global variables

Held (Actions.Action_Id)

Held    : constant Action_Id;
button is pressed down

Release (Actions.Action_Id)

Release : constant Action_Id;
button is held down for the repeat delay

Click (Actions.Action_Id)

Click   : constant Action_Id;
button is released

Subprograms & Entries

Handle_Action (abstract)

procedure Handle_Action
( this: access Button_Listener;
action: A_Button_Action ) is abstract;
Handles the button action 'action'.

Add_Listener

procedure Add_Listener
( this: access Button;
listener: not null A_Button_Listener );
Registers 'listener' as an Button_Action listener.

Contrast_Text

procedure Contrast_Text
( this: not null access Button'Class;
enabled: Boolean );
If contasting text is enabled, the text of the button will be displayed as either white or black, whichever contrasts most with the button's foreground color.

Get_State

function Get_State
( this: not null access Button'Class ) return Boolean;
Returns the state of the button: True if it's on and False if it's off.

Get_Text

function Get_Text
( this: not null access Button'Class ) return String;
Returns the button's text.

Remove_Listener

procedure Remove_Listener
( this: access Button;
listener: not null A_Button_Listener );
Unregisters 'listener' as an Button_Action listener.

Set_Align

procedure Set_Align
( this: not null access Button'Class;
align: Align_Type );
Sets the horizontal alignment for the button's icon and text.

Set_Color

procedure Set_Color
( this: access Button;
purpose: Color_Purpose;
color: Allegro_Color );
Sets the color to be used for a specific purpose. Setting the Foreground color to Transparent will cause the button to become transparent.

Set_Icon

procedure Set_Icon
( this: access Button;
icon: String );
Sets the button's icon by filename.

Set_Shade_Disabled

procedure Set_Shade_Disabled
( this: not null access Button'Class;
shade: Float );
Sets the shade applied to the button's foreground color when it is disabled. Use 1.0 for no shading, < 1.0 to darken and > 1.0 to lighten.

Set_Shade_On

procedure Set_Shade_On
(this: not null access Button'Class;
shade: Float );
Sets the shade applied to the button's foreground color when its state is On / Pressed down. Use 1.0 for no shading, < 1.0 to darken and > 1.0 to lighten.

Set_Shade_Hover

procedure Set_Shade_Hover
( this: not null access Button'Class;
shade: Float );
Sets the shade applied to the button's foreground color when the mouse hovers over it. Use 1.0 for no shading, < 1.0 to darken and > 1.0 to lighten.

Set_State

procedure Set_State
( this: access Button;
on: Boolean );
Sets the state of the button. If the state changes, a Press or Release action will occur as appopriate.

Set_Text

procedure Set_Text
( this: access Button;
text: String );
Sets the button's text.

Toggle_State

procedure Toggle_State
( this: access Button );
Toggles the state of the button to the opposite of the current state. A Press or Release action will occur as appopriate.