From d6b8768667852869e455805f27f81caff5271338 Mon Sep 17 00:00:00 2001 From: John Luke Date: Wed, 6 Aug 2003 22:20:11 +0000 Subject: [PATCH] add statusbar example svn path=/trunk/gtk-sharp/; revision=17146 --- doc/ChangeLog | 1 + doc/en/Gtk/Statusbar.xml | 60 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index f370780e8..0d1d9726a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,7 @@ 2003-08-06 John Luke * en/Gtk/Notebook.xml: add example, see references + * en/Gtk/Statusbar.xml: add example 2003-08-06 Xavier Amado diff --git a/doc/en/Gtk/Statusbar.xml b/doc/en/Gtk/Statusbar.xml index 38ab3827f..ebbc499c3 100644 --- a/doc/en/Gtk/Statusbar.xml +++ b/doc/en/Gtk/Statusbar.xml @@ -12,10 +12,68 @@ The Statusbar widget displays textual messages to the user. Statusbars are typically placed at the bottom of application s. A Statusbar may provide a regular commentary of the application's status (as is usually the case in a web browser, for example), or may be used to simply output a message when the status changes, (when an upload is complete in an FTP client, for example). As a finishing touch to the StatusBar, it can have a "resize grip" added in the lower right corner. This is a triangular area that can be clicked on to resize the window containing the statusbar. - Status bars in Gtk+ maintain a stack of messages. The message at the top of the each bar's stack is the one that will currently be displayed. + Status bars in Gtk maintain a stack of messages. The message at the top of the each bar's stack is the one that will currently be displayed. Any messages added to a statusbar's stack must specify a that is used to uniquely identify the source of a message. This can be generated with , given a message. Note that messages are stored in a stack, and when choosing which message to display, the stack structure is adhered to, regardless of the context identifier of a message. Messages are added to the bar's stack with , and the message at the top of the stack can be removed using . A message can be removed from anywhere in the stack if it's was recorded at the time it was added. This is done using . + + +using System; +using Gtk; +using GtkSharp; + +class StatusbarSample +{ + Statusbar sb; + const int id = 1; + int count; + + static void Main () + { + new StatusbarSample (); + } + + StatusbarSample () + { + Application.Init (); + + count = 0; + + Window win = new Window ("StatusbarSample"); + win.DeleteEvent += new DeleteEventHandler (OnWinDelete); + win.SetDefaultSize (150, 100); + + VBox vbox = new VBox (false, 1); + win.Add (vbox); + + Button btn = new Button ("Add to counter"); + btn.Clicked += new EventHandler (OnButtonClicked); + vbox.Add (btn); + + sb = new Statusbar (); + sb.Push (id, "Welcome!"); + sb.HasResizeGrip = false; + vbox.Add (sb); + + win.ShowAll (); + Application.Run (); + } + + void OnButtonClicked (object obj, EventArgs args) + { + count ++; + string message = String.Format ("Pushed {0} times", count); + sb.Pop (id); + sb.Push (id, message); + } + + void OnWinDelete (object obj, DeleteEventArgs args) + { + Application.Quit (); + } +} + + Gtk.HBox