1 // 2 // TestRange.cs 3 // 4 // Author: Duncan Mak (duncan@ximian.com) 5 // 6 // Copyright (C) 2002, Duncan Mak, Ximian Inc. 7 // 8 9 using System; 10 11 using Gtk; 12 13 namespace WidgetViewer { 14 15 public class TestRange 16 { 17 static Window window = null; 18 Create()19 public static Gtk.Window Create () 20 { 21 window = new Window ("GtkRange"); 22 window.SetDefaultSize (250, 200); 23 24 VBox box1 = new VBox (false, 0); 25 window.Add (box1); 26 27 VBox box2 = new VBox (false, 0); 28 box2.BorderWidth = 10; 29 box1.PackStart (box2, true, true, 0); 30 31 Adjustment adjustment = new Adjustment (0.0, 0.0, 101.0, 0.1, 1.0, 1.0); 32 33 HScale hscale = new HScale (adjustment); 34 hscale.SetSizeRequest (150, -1); 35 ((Range) hscale).UpdatePolicy = UpdateType.Delayed; 36 37 hscale.Digits = 1; 38 hscale.DrawValue = true; 39 box2.PackStart (hscale, true, true, 0); 40 41 HScrollbar hscrollbar = new HScrollbar (adjustment); 42 ((Range) hscrollbar).UpdatePolicy = UpdateType.Continuous; 43 box2.PackStart (hscrollbar, true, true, 0); 44 45 hscale = new HScale (adjustment); 46 hscale.DrawValue = true; 47 hscale.FormatValue += new FormatValueHandler (reformat_value); 48 49 box2.PackStart (hscale, true, true, 0); 50 51 HBox hbox = new HBox (false, 0); 52 VScale vscale = new VScale (adjustment); 53 vscale.SetSizeRequest (-1, 200); 54 vscale.Digits = 2; 55 vscale.DrawValue = true; 56 hbox.PackStart (vscale, true, true, 0); 57 58 vscale = new VScale (adjustment); 59 vscale.SetSizeRequest (-1, 200); 60 vscale.Digits = 2; 61 vscale.DrawValue = true; 62 ((Range) vscale).Inverted = true; 63 hbox.PackStart (vscale, true, true, 0); 64 65 vscale = new VScale (adjustment); 66 vscale.DrawValue = true; 67 vscale.FormatValue += new FormatValueHandler (reformat_value); 68 hbox.PackStart (vscale, true, true, 0); 69 70 box2.PackStart (hbox, true, true, 0); 71 72 box1.PackStart (new HSeparator (), false, true, 0); 73 74 box2 = new VBox (false, 10); 75 box2.BorderWidth = 10; 76 box1.PackStart (box2, false, true, 0); 77 78 Button button = new Button (Stock.Close); 79 button.Clicked += new EventHandler (Close_Button); 80 box2.PackStart (button, true, true, 0); 81 button.CanDefault = true; 82 button.GrabDefault (); 83 84 window.ShowAll (); 85 return window; 86 } 87 Close_Button(object o, EventArgs args)88 static void Close_Button (object o, EventArgs args) 89 { 90 window.Destroy (); 91 } 92 reformat_value(object o, FormatValueArgs args)93 static void reformat_value (object o, FormatValueArgs args) 94 { 95 int x = (int) args.Value; 96 args.RetVal = x.ToString (); 97 } 98 } 99 } 100