mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-26 02:05:41 +00:00
246d4e1620
gratuitous differences from the C version. Make comment and indent style consistent. Don't use "this." where not needed. Override OnDeleteEvent rather than connecting one's own DeleteEvent signal. * sample/GtkDemo/DemoApplicationWindow.cs (static DemoApplicationWindow): register the Gtk logo icon with StockManager so it shows up correctly in the toolbar. (AddActions): Register the radio items as radio items so they work right. * sample/GtkDemo/DemoHyperText.cs (EventAfter): handle link-clicking from Widget.WidgetEventAfter (as in the C version), rather than ButtonRelease, now that WidgetEventAfter is wrapped. * sample/GtkDemo/DemoImages.cs (DemoImages): use Gtk.Image.LoadFromResource (particularly to make the animation work right). (OnDestroyed): handle clean up (remove the timeout, etc) * sample/GtkDemo/DemoMain.cs (LoadStream): Fix handling of blank lines and whitespace to match the C version. * sample/GtkDemo/DemoPixbuf.cs (Expose): Use System.Runtime.InteropServices.Marshal.Copy() to copy pixbuf.Pixels to pass to DrawRgbImageDithalign, to make this more like the C version (and probably faster?) (timeout): Remove the FIXME since it seems to work now * sample/GtkDemo/DemoStockBrowser.cs: Simplify a bunch. Use reflection to get the C# names of the stock icons rather than trying to correctly re-mangle the ids. Display the Label with the accelerator underlined. * sample/GtkDemo/DemoTextView.cs (AttachWidgets): use Gtk.Image.LoadFromResource, so the image is properly loaded as an animation, not a static image. Don't set the combobox's "Active" property (for consistency with the C version). (InsertText): Fix miscellaneous differences with the C version. Remove some leftover cruft from earlier workarounds for gtk# bugs. * sample/GtkDemo/DemoTreeStore.cs (AddColumns): Make this more like the C version so the checkboxes are sensitized and hidden correctly on a per-row basis. * sample/GtkDemo/DemoUIManager.cs: Make the radio menu items work. * sample/GtkDemo/README: * sample/GtkDemo/TODO: update svn path=/trunk/gtk-sharp/; revision=42481
131 lines
3.6 KiB
C#
131 lines
3.6 KiB
C#
/* Size Groups
|
|
*
|
|
* SizeGroup provides a mechanism for grouping a number of
|
|
* widgets together so they all request the same amount of space.
|
|
* This is typically useful when you want a column of widgets to
|
|
* have the same size, but you can't use a Table widget.
|
|
*
|
|
* Note that size groups only affect the amount of space requested,
|
|
* not the size that the widgets finally receive. If you want the
|
|
* widgets in a SizeGroup to actually be the same size, you need
|
|
* to pack them in such a way that they get the size they request
|
|
* and not more. For example, if you are packing your widgets
|
|
* into a table, you would not include the Gtk.Fill flag.
|
|
*/
|
|
|
|
using System;
|
|
using Gtk;
|
|
|
|
namespace GtkDemo
|
|
{
|
|
[Demo ("Size Group", "DemoSizeGroup.cs")]
|
|
public class DemoSizeGroup : Dialog
|
|
{
|
|
private SizeGroup sizeGroup;
|
|
|
|
static string [] colors = { "Red", "Green", "Blue" };
|
|
static string [] dashes = { "Solid", "Dashed", "Dotted" };
|
|
static string [] ends = { "Square", "Round", "Arrow" };
|
|
|
|
public DemoSizeGroup () : base ("SizeGroup", null, DialogFlags.DestroyWithParent,
|
|
Gtk.Stock.Close, Gtk.ResponseType.Close)
|
|
{
|
|
Resizable = false;
|
|
|
|
VBox vbox = new VBox (false, 5);
|
|
this.VBox.PackStart (vbox, true, true, 0);
|
|
vbox.BorderWidth = 5;
|
|
|
|
sizeGroup = new SizeGroup (SizeGroupMode.Horizontal);
|
|
|
|
// Create one frame holding color options
|
|
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);
|
|
|
|
AddRow (table, 0, sizeGroup, "_Foreground", colors);
|
|
AddRow (table, 1, sizeGroup, "_Background", colors);
|
|
|
|
// And another frame holding line style options
|
|
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);
|
|
|
|
AddRow (table, 0, sizeGroup, "_Dashing", dashes);
|
|
AddRow (table, 1, sizeGroup, "_Line ends", ends);
|
|
|
|
// And a check button to turn grouping on and off
|
|
CheckButton checkButton = new CheckButton ("_Enable grouping");
|
|
vbox.PackStart (checkButton, false, false, 0);
|
|
checkButton.Active = true;
|
|
checkButton.Toggled += new EventHandler (ToggleGrouping);
|
|
|
|
ShowAll ();
|
|
}
|
|
|
|
// Convenience function to create a combo box holding a number of strings
|
|
private ComboBox CreateComboBox (string [] strings)
|
|
{
|
|
ComboBox combo = ComboBox.NewText ();
|
|
|
|
foreach (string str in strings)
|
|
combo.AppendText (str);
|
|
|
|
combo.Active = 0;
|
|
return combo;
|
|
}
|
|
|
|
private void AddRow (Table table, uint row, SizeGroup sizeGroup, string labelText, string [] options)
|
|
{
|
|
Label label = new Label (labelText);
|
|
label.SetAlignment (0, 1);
|
|
|
|
table.Attach (label,
|
|
0, 1, row, row + 1,
|
|
AttachOptions.Expand | AttachOptions.Fill, 0,
|
|
0, 0);
|
|
|
|
ComboBox combo = CreateComboBox (options);
|
|
label.MnemonicWidget = combo;
|
|
|
|
sizeGroup.AddWidget (combo);
|
|
table.Attach (combo,
|
|
1, 2, row, row + 1,
|
|
0, 0,
|
|
0, 0);
|
|
}
|
|
|
|
private void ToggleGrouping (object o, EventArgs args)
|
|
{
|
|
ToggleButton checkButton = (ToggleButton)o;
|
|
|
|
// SizeGroupMode.None is not generally useful, but is useful
|
|
// here to show the effect of SizeGroupMode.Horizontal by
|
|
// contrast
|
|
SizeGroupMode mode;
|
|
|
|
if (checkButton.Active)
|
|
mode = SizeGroupMode.Horizontal;
|
|
else
|
|
mode = SizeGroupMode.None;
|
|
|
|
sizeGroup.Mode = mode;
|
|
}
|
|
|
|
protected override void OnResponse (Gtk.ResponseType responseId)
|
|
{
|
|
Destroy ();
|
|
}
|
|
}
|
|
}
|