limited with Game_Views;
package Widgets.Buttons.Toggles is
-- A Toggle_Button is a variation of a button that toggles its state when
-- pressed with a mouse or activated with the keyboard. It's state remains
-- until the mouse presses on it again to toggle the state back again.
type Toggle_Button is new Button with private;
type A_Toggle_Button is access all Toggle_Button'Class;
-- Creates a new toggle button within 'view' with id 'id'. 'text' is the
-- button's text and 'icon' is the filename of the icon to use. Both are
-- optional but at least one should be specified or the button will be
-- blank. The default state of the new button is False.
function Create_Toggle_Button( view : not null access Game_Views.Game_View'Class;
id : String;
text : String := "";
icon : String := "" ) return A_Button;
pragma Precondition( id'Length > 0 );
pragma Postcondition( Create_Toggle_Button'Result /= null );
private
type Toggle_Button is new Button with null record;
-- Handles Space, Enter and Keypad-Enter keys to toggle the state of the
-- button.
function Handle_Key_Press( this : access Toggle_Button;
evt : not null A_Key_Event ) return Boolean;
-- Handles a left mouse button press to toggle the state of the button. The
-- other mouse buttons are not used.
procedure Handle_Mouse_Press( this : access Toggle_Button;
evt : not null A_Mouse_Button_Event );
end Widgets.Buttons.Toggles;