1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
//
// TestSizeGroup.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// Copyright (C) 2002, Duncan Mak, Ximian Inc.
//
using System;
using Gtk;
namespace WidgetViewer {
public class TestSizeGroup {
static Dialog window = null;
static SizeGroup size_group = null;
public static Gtk.Window Create ()
{
window = new Dialog ();
window.Title = "Sized groups";
window.Resizable = false;
VBox vbox = new VBox (false, 5);
window.VBox.PackStart (vbox, true, true, 0);
vbox.BorderWidth = 5;
size_group = new SizeGroup (SizeGroupMode.Horizontal);
Frame frame = new Frame ("Color Options");
vbox.PackStart (frame, true, true, 0);
Table table = new Table (2, 2, false);
table.BorderWidth = 5;
table.RowSpacing = 5;
table.ColumnSpacing = 10;
frame.Add (table);
string [] colors = {"Red", "Green", "Blue", };
string [] dashes = {"Solid", "Dashed", "Dotted", };
string [] ends = {"Square", "Round", "Arrow", };
Add_Row (table, 0, size_group, "_Foreground", colors);
Add_Row (table, 1, size_group, "_Background", colors);
frame = new Frame ("Line Options");
vbox.PackStart (frame, false, false, 0);
table = new Table (2, 2, false);
table.BorderWidth = 5;
table.RowSpacing = 5;
table.ColumnSpacing = 10;
frame.Add (table);
Add_Row (table, 0, size_group, "_Dashing", dashes);
Add_Row (table, 1, size_group, "_Line ends", ends);
CheckButton check_button = new CheckButton ("_Enable grouping");
vbox.PackStart (check_button, false, false, 0);
check_button.Active = true;
check_button.Toggled += new EventHandler (Button_Toggle_Cb);
Button close_button = new Button (Stock.Close);
close_button.Clicked += new EventHandler (Close_Button);
window.ActionArea.PackStart (close_button, false, false, 0);
window.ShowAll ();
return window;
}
static OptionMenu Create_OptionMenu (string [] strings)
{
Menu menu = new Menu ();
MenuItem menu_item = null;
foreach (string str in strings) {
menu_item = new MenuItem (str);
menu_item.Show ();
menu.Append (menu_item);
}
OptionMenu option_menu = new OptionMenu ();
option_menu.Menu = menu;
return option_menu;
}
static void Add_Row (Table table, uint row, SizeGroup size_group,
string label_text, string [] options)
{
Label label = new Label (label_text);
label.SetAlignment (0, 1);
table.Attach (label,
0, 1, row, row + 1,
AttachOptions.Expand, AttachOptions.Fill,
0, 0);
OptionMenu option_menu = Create_OptionMenu (options);
size_group.AddWidget (option_menu);
table.Attach (option_menu,
1, 2, row, row + 1,
AttachOptions.Expand, AttachOptions.Expand,
0, 0);
}
static void Button_Toggle_Cb (object o, EventArgs args)
{
Toggle_Grouping ((ToggleButton) o, size_group);
}
static void Toggle_Grouping (ToggleButton check_button,
SizeGroup size_group)
{
SizeGroupMode mode;
if (check_button.Active)
mode = SizeGroupMode.Horizontal;
else
mode = SizeGroupMode.None;
size_group.Mode = mode;
}
static void Close_Button (object o, EventArgs args)
{
window.Destroy ();
}
}
}
|