[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


Package Gtk.Toggle_Button

A 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.

togglebutton

Widget Hierarchy

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_Button)

Signals

Subprograms

procedure Gtk_New              
  (Toggle_Button      : out    Gtk_Toggle_Button;
   Label              : in     String := "");

Initialize a button.
If Label is "", then no label is created inside the button and you will have to provide your own child through a call to Gtk.Container.Add. This is the recommended way to put a pixmap inside a toggle button.


function Get_Type              return Gtk.Gtk_Type;

Return the internal value associated with a Gtk_Toggle_Button.


procedure Set_Mode             
  (Toggle_Button      : access Gtk_Toggle_Button_Record;
   Draw_Indicator     : in     Boolean);

Change the mode of the button.
If Draw_Indicator is False, then the button is hidden.


procedure Set_Active           
  (Toggle_Button      : access Gtk_Toggle_Button_Record;
   Is_Active          : in     Boolean);

Change the state of the button.
When Is_Active is True, the button is drawn as a pressed 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.


function Is_Active             
  (Toggle_Button      : access Gtk_Toggle_Button_Record)
   return Boolean;

Deprecated: this is the old name of Get_Active.


Signals emission


procedure Toggled              
  (Toggle_Button      : access Gtk_Toggle_Button_Record);

Emit the toggled signal on this widget.
Note that the state of the button is not changed, only the callbacks are called.


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;

 


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]