_ButtonA Gtk_Toggle_Button is like a regular button, but can be in one of two states, "active" or "inactive". Its visual aspect is modified when the state is changed.
You should consider using a Gtk_Check_Button instead, since it looks nicer and provides more visual clues that the button can be toggled.
Widget Hierarchy |
|---|
GObject (see section Package Glib.Object)
Gtk_Object (see section Package Gtk.Object)
\___ Gtk_Widget (see section Package Gtk.Widget)
\___ Gtk_Container (see section Package Gtk.Container)
\___ Gtk_Bin (see section Package Gtk.Bin)
\___ Gtk_Button (see section Package Gtk.Button)
\___ Gtk_Toggle_Button (see section Package Gtk.Toggle
|
Signals |
|---|
Subprograms |
|---|
procedure Gtk_New (Toggle_Button : out Gtk_Toggle_Button; Label : UTF8_String := ""); | ||
|
Initialize a button. | ||
procedure Gtk_New_With_Mnemonic (Toggle_Button : out Gtk_Toggle_Button; Label : UTF8_String); | ||
|
Create a Gtk_Toggle_Button containing Label. The Label will be created | ||
procedure Initialize_With_Mnemonic (Toggle_Button : access Gtk_Toggle_Button_Record'Class; Label : UTF8_String); | ||
|
Internal initialization function.
| ||
function Get_Type return Glib.GType; | ||
|
Return the internal value associated with a Gtk_Toggle_Button.
| ||
procedure Set_Mode (Toggle_Button : access Gtk_Toggle_Button_Record; Draw_Indicator : Boolean); | ||
|
Change the mode of the button. | ||
function Get_Mode (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; | ||
|
Return the mode of the button.
| ||
procedure Set_Active (Toggle_Button : access Gtk_Toggle_Button_Record; Is_Active : Boolean); | ||
|
Change the state of the button. | ||
function Get_Active (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; | ||
|
Return true if the button is in its active state, i.e is pressed.
| ||
procedure Set_Inconsistent (Toggle_Button : access Gtk_Toggle_Button_Record; Setting : Boolean := True); | ||
|
If the user has selected a range of elements (such as some text or | ||
function Get_Inconsistent (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; | ||
|
Get the value set by Set_Inconsistent.
| ||
Signals emission | ||
procedure Toggled (Toggle_Button : access Gtk_Toggle_Button_Record); | ||
|
Emit the toggled signal on this widget. | ||
Example |
|---|
-- This example creates a toggle button with a pixmap in it
with Gtk.Toggle_Button, Gdk.Pixmap, Gdk.Bitmap, Gtk.Pixmap;
with Gtk.Style, Gtk.Enums;
procedure Toggle is
Toggle : Gtk.Toggle_Button.Gtk_Toggle_Button;
Style : Gtk.Style.Gtk_Style;
Pixmap : Gdk.Pixmap.Gdk_Pixmap;
Mask : Gdk.Bitmap.Gdk_Bitmap;
PixmapWid : Gtk.Pixmap.Gtk_Pixmap;
begin
-- Do not specify a label
Gtk.Toggle_Button.Gtk_New (Toggle);
Style := Gtk.Toggle_Button.Get_Style (Toggle);
Gdk.Pixmap.Create_From_Xpm
(Pixmap,
Gtk.Toggle_Button.Get_Window (Toggle),
Mask,
Gtk.Style.Get_Bg (Style, Gtk.Enums.State_Normal),
"icon.xpm");
Gtk.Pixmap.Gtk_New (PixmapWid, Pixmap, Mask);
-- Add the pixmap to the button
Gtk.Toggle_Button.Add (Toggle, PixmapWid);
end Toggle;