From d413d078700d4d762f9960b5a12bc58d916eb988 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Thu, 1 May 2003 23:30:59 +0000 Subject: [PATCH] Add updated from John Luke . svn path=/trunk/gtk-sharp/; revision=14194 --- doc/ChangeLog | 4 ++ doc/en/Gtk/ToggleButton.xml | 139 +++++++++++++++++++++++------------- 2 files changed, 92 insertions(+), 51 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index eb3ac0e54..061c08d0a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2003-05-01 Duncan Mak + + * en/Gtk/ToggleButton.xml: Add updated from John Luke . + 2003-04-24 Pedro Martínez Juliá * en/Gtk/Combo.xml: Edit document. Ready to validate. There are a diff --git a/doc/en/Gtk/ToggleButton.xml b/doc/en/Gtk/ToggleButton.xml index 61eaa501a..1556f6809 100644 --- a/doc/en/Gtk/ToggleButton.xml +++ b/doc/en/Gtk/ToggleButton.xml @@ -13,56 +13,53 @@ Clicking again will cause the toggle button to return to it's normal state. This is useful if you need to maintain the state of a button. -namespace GtkSamples { +using Gtk; +using GtkSharp; +using System; - using Gtk; - using GtkSharp; - using System; - - public class ToggleButtonApp { +public class ToggleButtonApp { - ToggleButton btn; - - public static int Main (string[] args) - { - new ToggleButtonApp(); - return 0; - } - - public ToggleButtonApp() - { - Application.Init (); - Window win = new Window ("ToggleButton Tester"); - win.SetDefaultSize (200, 150); - win.DeleteEvent += new DeleteEventHandler (Window_Delete); - btn = new ToggleButton ("Unselected"); - btn.Active = false; - btn.Toggled += new EventHandler (btn_toggled); - win.Add (btn); - win.ShowAll (); - Application.Run (); - } - - void btn_toggled (object obj, EventArgs args) - { - Console.WriteLine ("Button Toggled"); - if (btn.Active) - { - btn.Label = "Unselected"; - } - else - { - btn.Label = "Selected"; - } - } - - static void Window_Delete (object obj, DeleteEventArgs args) - { - Application.Quit (); - args.RetVal = true; - } + ToggleButton btn; + public static int Main (string[] args) + { + new ToggleButtonApp(); + return 0; } + + public ToggleButtonApp() + { + Application.Init (); + Window win = new Window ("ToggleButton Tester"); + win.SetDefaultSize (200, 150); + win.DeleteEvent += new DeleteEventHandler (Window_Delete); + btn = new ToggleButton ("Unselected"); + btn.Active = false; + btn.Toggled += new EventHandler (btn_toggled); + win.Add (btn); + win.ShowAll (); + Application.Run (); + } + + void btn_toggled (object obj, EventArgs args) + { + Console.WriteLine ("Button Toggled"); + if (btn.Active) + { + btn.Label = "Unselected"; + } + else + { + btn.Label = "Selected"; + } + } + + static void Window_Delete (object obj, DeleteEventArgs args) + { + Application.Quit (); + args.RetVal = true; + } + } @@ -158,6 +155,15 @@ namespace GtkSamples { inside the toggle button using . + + + +Label label = new Label(); +ToggleButton btn = new ToggleButton (); +btn.Add(label); + + + @@ -172,7 +178,9 @@ namespace GtkSamples { Creates a new with a text label. a containing the message to be placed in the toggle button. an object of type ' - Creates a new with a text label. + Creates a new with a text label. + ToggleButton btn = new ToggleButton ("ToggleButton"); + @@ -249,12 +257,29 @@ namespace GtkSamples { an object of type Get or set the active. - Get: Queries a GtkToggleButton and returns it's current state. + Get: Queries a and returns it's current state. Returns if the toggle button is pressed in and if it is raised. + + +if (btn.Active) { + Console.WriteLine("The ToggleButton is pressed in"); +} +else { + Console.WriteLine("The ToggleButton is raised"); +} + + Set: Sets the status of the toggle button. Set to if you want the GtkToggleButton to be 'pressed in', and to raise it. This action causes the toggled signal to be emitted. + + +// set the togglebutton active +// and appear "pressed in" +btn.Active = true; + + @@ -268,11 +293,11 @@ namespace GtkSamples { - The DrawIndicator property + Determines the drawing style of a or an object of type an object of type The DrawIndicator property can be set to to make - or look like a normal . + or look like a normal . @@ -283,7 +308,19 @@ namespace GtkSamples { Triggered when the is clicked. - Should be connected if you wish to perform an action whenever the 's state is changed. + Should be connected if you wish to perform an action whenever the 's state is changed. + + +ToggleButton btn = new ToggleButton("ToggleButton"); +btn.Toggled += new EventHandler (btn_toggled); + +void btn_toggled (object obj, EventArgs args) +{ + // code for toggled event here +} + + +