diff --git a/sample/test/ChangeLog b/sample/test/ChangeLog index d3f259a38..1e0269aea 100644 --- a/sample/test/ChangeLog +++ b/sample/test/ChangeLog @@ -1,3 +1,29 @@ +2002-07-16 Duncan Mak + + * TestCheckButton.cs: + * TestTooltip.cs: Added copyright material. + + * TestColorSelection.cs: Attempt to do something new after color + is selected. ColorSelection.CurrentColor (get) doesn't seem to + work right now, bug 27834. + + * TestDialog.cs: Removed debugging messages and beautified the dialog. + + * TestFlipping.cs: New test to show widget flipping. + + * TestRadioButton.cs: Changed the constructors used to build the + radio buttons to work around bug 27833. + + * Makefile: Added TestFlipping.cs. + + * WidgetViewer.cs (AddWindow): Another convenience method for + adding new Test dialogs. + +2002-07-15 Duncan Mak + + * WidgetViewer.cs (AddButton): New convenience method so that I don't have to type + the same thing when adding a new test button. + 2002-07-13 Duncan Mak * *.cs: Added copyright material. diff --git a/sample/test/Makefile b/sample/test/Makefile index 0279afff2..d37cec0ab 100644 --- a/sample/test/Makefile +++ b/sample/test/Makefile @@ -3,6 +3,7 @@ MCS=mcs all: $(MCS) -o WidgetViewer.exe -r glib-sharp -r gdk-sharp -r gtk-sharp \ TestCheckButton.cs TestColorSelection.cs TestFileSelection.cs TestRadioButton.cs \ - TestRange.cs TestStatusbar.cs TestToolbar.cs TestDialog.cs WidgetViewer.cs + TestRange.cs TestStatusbar.cs TestToolbar.cs TestDialog.cs TestFlipping.cs \ + WidgetViewer.cs clean: rm -f *.exe *~ diff --git a/sample/test/TestCheckButton.cs b/sample/test/TestCheckButton.cs index ee71ffd79..3dcf958c3 100644 --- a/sample/test/TestCheckButton.cs +++ b/sample/test/TestCheckButton.cs @@ -1,3 +1,11 @@ +// +// TestCheckButton.cs +// +// Author: Duncan Mak (duncan@ximian.com) +// +// Copyright (C) 2002, Duncan Mak, Ximian Inc. +// + using System; using Gtk; diff --git a/sample/test/TestColorSelection.cs b/sample/test/TestColorSelection.cs index c7da8eb6d..245a8e337 100644 --- a/sample/test/TestColorSelection.cs +++ b/sample/test/TestColorSelection.cs @@ -1,4 +1,3 @@ - // // TestColorSelection.cs // @@ -16,6 +15,7 @@ namespace WidgetViewer { public class TestColorSelection { static ColorSelectionDialog window = null; + static Dialog dialog = null; public static Gtk.Window Create () { @@ -31,10 +31,12 @@ namespace WidgetViewer { window.VBox.BorderWidth = 10; check_button = new CheckButton("Show Opacity"); + check_button.Active = true; options.PackStart (check_button, false, false, 0); check_button.Toggled += new EventHandler (Opacity_Callback); check_button = new CheckButton("Show Palette"); + check_button.Active = true; options.PackEnd (check_button, false, false, 0); check_button.Toggled += new EventHandler (Palette_Callback); @@ -64,13 +66,54 @@ namespace WidgetViewer { static void Color_Selection_OK (object o, EventArgs args) { - Gdk.Color color = window.ColorSelection.CurrentColor; - window.ColorSelection.CurrentColor = color; + Gdk.Color selected = window.ColorSelection.CurrentColor; + + if (selected == null) { + Console.WriteLine ("Color selection failed."); + return; + } + + Display_Result (selected); } static void Color_Selection_Cancel (object o, EventArgs args) { + SignalArgs sa = (SignalArgs) args; + if (dialog != null) + dialog.Destroy (); window.Destroy (); + sa.RetVal = true; + } + + static void Display_Result (Gdk.Color color) + { + + if (color == null) + Console.WriteLine ("Null color"); + + dialog = new Dialog (); + dialog.Title = "Selected Color"; + + DrawingArea da = new DrawingArea (); + + da.ModifyBg (StateType.Normal, color); + + Console.WriteLine (da); + + dialog.VBox.PackStart (da, true, true, 0); + + Button button = new Button ("OK"); + button.Clicked += new EventHandler (Close_Button); + button.CanDefault = true; + dialog.ActionArea.PackStart (button, true, true, 0); + button.GrabDefault (); + + dialog.ShowAll (); + } + + static void Close_Button (object o, EventArgs args) + { + Color_Selection_Cancel (o, args); } } } diff --git a/sample/test/TestDialog.cs b/sample/test/TestDialog.cs index 4a052e7f0..59cc510a4 100644 --- a/sample/test/TestDialog.cs +++ b/sample/test/TestDialog.cs @@ -1,4 +1,3 @@ - // // TestDialog.cs // @@ -23,9 +22,10 @@ namespace WidgetViewer { { window = new Dialog (); window.Response += new EventHandler (Print_Response); + window.SetDefaultSize (200, 100); window.Title = "GtkDialog"; - Button button = new ToggleButton ("OK"); + Button button = new Button ("OK"); button.Clicked += new EventHandler (Close_Button); button.CanDefault = true; window.ActionArea.PackStart (button, true, true, 0); @@ -36,7 +36,7 @@ namespace WidgetViewer { window.ActionArea.PackStart (toggle_button, true, true, 0); toggle_button = new ToggleButton ("Toggle Separator"); - button.Clicked += new EventHandler (Separator_Toggle); + toggle_button.Clicked += new EventHandler (Separator_Toggle); window.ActionArea.PackStart (toggle_button, true, true, 0); window.ShowAll (); @@ -61,8 +61,7 @@ namespace WidgetViewer { static void Label_Toggle (object o, EventArgs args) { if (label == null) { - Console.WriteLine ("Null label"); - label = new Label ("Text label"); + label = new Label ("This is Text label inside a Dialog"); label.SetPadding (10, 10); window.VBox.PackStart (label, true, true, 0); label.Show (); @@ -74,7 +73,8 @@ namespace WidgetViewer { static void Separator_Toggle (object o, EventArgs args) { - window.HasSeparator = ((ToggleButton) o).Active; + window.HasSeparator = (!((ToggleButton) o).Active); } } } + diff --git a/sample/test/TestFlipping.cs b/sample/test/TestFlipping.cs new file mode 100644 index 000000000..1ecf7cc83 --- /dev/null +++ b/sample/test/TestFlipping.cs @@ -0,0 +1,71 @@ +// +// TestFlipping.cs +// +// Author: Duncan Mak (duncan@ximian.com) +// +// Copyright (C) 2002, Duncan Mak, Ximian Inc. +// + +using System; + +using Gtk; +using GtkSharp; + +namespace WidgetViewer { + public class TestFlipping { + + static Dialog window = null; + static CheckButton check_button = null; + static Button button = null; + static Label label = null; + + public static Gtk.Window Create () + { + window = new Dialog (); + window.Title = "Bi-directional flipping"; + window.SetDefaultSize (200, 100); + + label = new Label ("Label direction: Left-to-right"); + label.UseMarkup = true; + label.SetPadding (3, 3); + window.VBox.PackStart (label, true, true, 0); + + check_button = new CheckButton ("Toggle label direction"); + window.VBox.PackStart (check_button, true, true, 2); + + if (window.Direction == TextDirection.Ltr) + check_button.Active = true; + + check_button.Toggled += new EventHandler (Toggle_Flip); + check_button.BorderWidth = 10; + + button = new Button ("close"); + button.Clicked += new EventHandler (Close_Button); + button.CanDefault = true; + + window.ActionArea.PackStart (button, true, true, 0); + button.GrabDefault (); + + window.ShowAll (); + return window; + } + + static void Toggle_Flip (object o, EventArgs args) + { + if (((CheckButton) o).Active) { + check_button.Direction = TextDirection.Ltr; + label.Markup = "Label direction: Left-to-right"; + } else { + check_button.Direction = TextDirection.Rtl; + label.Markup = "Label direction: Right-to-left"; + } + } + + static void Close_Button (object o, EventArgs args) + { + SignalArgs sa = (SignalArgs) args; + window.Destroy (); + sa.RetVal = true; + } + } +} diff --git a/sample/test/TestRadioButton.cs b/sample/test/TestRadioButton.cs index 27e9d0c3f..b5028c880 100644 --- a/sample/test/TestRadioButton.cs +++ b/sample/test/TestRadioButton.cs @@ -29,17 +29,18 @@ namespace WidgetViewer { box2.BorderWidth = 10; box1.PackStart (box2, true, true, 0); - radio_button = new RadioButton (new GLib.SList (IntPtr.Zero), "Button 1"); + radio_button = RadioButton.NewWithLabel (new GLib.SList (IntPtr.Zero), "Button 1"); + Console.WriteLine (radio_button); box2.PackStart (radio_button, true, true, 0); - radio_button = new RadioButton (radio_button.Group, "Button 2"); + radio_button = RadioButton.NewWithLabelFromWidget (radio_button, "Button 2"); radio_button.Active = true; box2.PackStart (radio_button, true, true, 0); - radio_button = new RadioButton (radio_button.Group, "Button 3"); + radio_button = RadioButton.NewWithLabelFromWidget (radio_button, "Button 3"); box2.PackStart (radio_button, true, true, 0); - radio_button = new RadioButton (radio_button.Group, "Inconsistent"); + radio_button = RadioButton.NewWithLabelFromWidget (radio_button, "Inconsistent"); radio_button.Inconsistent = true; box2.PackStart (radio_button, true, true, 0); @@ -49,16 +50,16 @@ namespace WidgetViewer { box2.BorderWidth = 10; box1.PackStart (box2, true, true, 0); - radio_button = new RadioButton (new GLib.SList (IntPtr.Zero), "Button 4"); + radio_button = RadioButton.NewWithLabel (new GLib.SList (IntPtr.Zero), "Button 4"); radio_button.Mode = false; box2.PackStart (radio_button, true, true, 0); - radio_button = new RadioButton (radio_button.Group, "Button 5"); + radio_button = RadioButton.NewWithLabelFromWidget (radio_button, "Button 5"); radio_button.Active = true; radio_button.Mode = false; box2.PackStart (radio_button, true, true, 0); - radio_button = new RadioButton (radio_button.Group, "Button 6"); + radio_button = RadioButton.NewWithLabelFromWidget (radio_button, "Button 6"); radio_button.Mode = false; box2.PackStart (radio_button, true, true, 0); diff --git a/sample/test/TestTooltip.cs b/sample/test/TestTooltip.cs index b8babfd2e..e0fe0c2f2 100644 --- a/sample/test/TestTooltip.cs +++ b/sample/test/TestTooltip.cs @@ -1,3 +1,11 @@ +// +// TestToolTip.cs +// +// Author: Duncan Mak (duncan@ximian.com) +// +// Copyright (C) 2002, Duncan Mak, Ximian Inc. +// + using System; using Gtk; diff --git a/sample/test/WidgetViewer.cs b/sample/test/WidgetViewer.cs index 7e11d8e85..c90d47aab 100644 --- a/sample/test/WidgetViewer.cs +++ b/sample/test/WidgetViewer.cs @@ -12,12 +12,12 @@ using Gtk; using GtkSharp; namespace WidgetViewer { - public class Viewer { static Window window = null; static Window viewer = null; static Button button = null; + static VBox box2 = null; static void Main () { @@ -29,41 +29,19 @@ namespace WidgetViewer { VBox box1 = new VBox (false, 0); window.Add (box1); - VBox box2 = new VBox (false, 5); + box2 = new VBox (false, 5); box2.BorderWidth = 10; box1.PackStart (box2, true, true, 0); - button = new Button ("Check Buttons"); - button.Clicked += new EventHandler (Check_Buttons); - box2.PackStart (button, false, false, 0); - - button = new Button ("Color Selection"); - button.Clicked += new EventHandler (Color_Selection); - box2.PackStart (button, false, false, 0); - - button = new Button ("Dialog"); - button.Clicked += new EventHandler (Dialog); - box2.PackStart (button, false, false, 0); - - button = new Button ("File Selection"); - button.Clicked += new EventHandler (File_Selection); - box2.PackStart (button, false, false, 0); - - button = new Button ("Radio Buttons"); - button.Clicked += new EventHandler (Radio_Buttons); - box2.PackStart (button, false, false, 0); - - button = new Button ("Range Controls"); - button.Clicked += new EventHandler (Range_Controls); - box2.PackStart (button, false, false, 0); - - button = new Button ("Statusbar"); - button.Clicked += new EventHandler (Statusbar); - box2.PackStart (button, false, false, 0); - - button = new Button ("Toolbar"); - button.Clicked += new EventHandler (Toolbar); - box2.PackStart (button, false, false, 0); + AddButton ("Bi-directional flipping", new EventHandler (Flipping)); + AddButton ("Check Buttons", new EventHandler (Check_Buttons)); + AddButton ("Color Selection", new EventHandler (Color_Selection)); + AddButton ("Dialog", new EventHandler (Dialog)); + AddButton ("File Selection", new EventHandler (File_Selection)); + AddButton ("Radio Buttons", new EventHandler (Radio_Buttons)); + AddButton ("Range Controls", new EventHandler (Range_Controls)); + AddButton ("Statusbar", new EventHandler (Statusbar)); + AddButton ("Toolbar", new EventHandler (Toolbar)); box1.PackStart (new HSeparator (), false, false, 0); @@ -79,6 +57,20 @@ namespace WidgetViewer { Application.Run (); } + static void AddButton (string caption, EventHandler handler) + { + button = new Button (caption); + button.Clicked += handler; + box2.PackStart (button, false, false, 0); + } + + static void AddWindow (Window dialog) + { + viewer = dialog; + viewer.DeleteEvent += new EventHandler (Viewer_Delete); + viewer.ShowAll (); + } + static void Window_Delete (object o, EventArgs args) { SignalArgs sa = (SignalArgs) args; @@ -100,57 +92,47 @@ namespace WidgetViewer { static void Check_Buttons (object o, EventArgs args) { - viewer = TestCheckButton.Create (); - viewer.ShowAll (); + AddWindow (TestCheckButton.Create ()); } static void Color_Selection (object o, EventArgs args) { - viewer = TestColorSelection.Create (); - viewer.ShowAll (); + AddWindow (TestColorSelection.Create ()); } static void File_Selection (object o, EventArgs args) { - viewer = TestFileSelection.Create (); - viewer.DeleteEvent += new EventHandler (Viewer_Delete); - viewer.ShowAll (); + AddWindow (TestFileSelection.Create ()); } static void Radio_Buttons (object o, EventArgs args) { - viewer = TestRadioButton.Create (); - viewer.DeleteEvent += new EventHandler (Viewer_Delete); - viewer.ShowAll (); + AddWindow (TestRadioButton.Create ()); } static void Range_Controls (object o, EventArgs args) { - viewer = TestRange.Create (); - viewer.DeleteEvent += new EventHandler (Viewer_Delete); - viewer.ShowAll (); + AddWindow (TestRange.Create ()); } static void Statusbar (object o, EventArgs args) { - viewer = TestStatusbar.Create (); - viewer.DeleteEvent += new EventHandler (Viewer_Delete); - viewer.ShowAll (); + AddWindow (TestStatusbar.Create ()); } static void Toolbar (object o, EventArgs args) { - viewer = TestToolbar.Create (); - viewer.DeleteEvent += new EventHandler (Window_Delete); - viewer.ShowAll (); + AddWindow (TestToolbar.Create ()); } static void Dialog (object o, EventArgs args) { - viewer = TestDialog.Create (); - viewer.DeleteEvent += new EventHandler (Window_Delete); - viewer.ShowAll (); + AddWindow (TestDialog.Create ()); } + static void Flipping (object o, EventArgs args) + { + AddWindow (TestFlipping.Create ()); + } } }