mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-27 02:05:28 +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
140 lines
3.4 KiB
C#
140 lines
3.4 KiB
C#
/* Paned Widgets
|
|
*
|
|
* The HPaned and VPaned Widgets divide their content
|
|
* area into two panes with a divider in between that the
|
|
* user can adjust. A separate child is placed into each
|
|
* pane.
|
|
*
|
|
* There are a number of options that can be set for each pane.
|
|
* This test contains both a horizontal (HPaned) and a vertical
|
|
* (VPaned) widget, and allows you to adjust the options for
|
|
* each side of each widget.
|
|
*/
|
|
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using Gtk;
|
|
|
|
namespace GtkDemo
|
|
{
|
|
[Demo ("Paned Widget", "DemoPanes.cs")]
|
|
public class DemoPanes : Gtk.Window
|
|
{
|
|
Hashtable children = new Hashtable ();
|
|
|
|
public DemoPanes () : base ("Panes")
|
|
{
|
|
VBox vbox = new VBox (false, 0);
|
|
Add (vbox);
|
|
|
|
VPaned vpaned = new VPaned ();
|
|
vbox.PackStart (vpaned, true, true, 0);
|
|
vpaned.BorderWidth = 5;
|
|
|
|
HPaned hpaned = new HPaned ();
|
|
vpaned.Add1 (hpaned);
|
|
|
|
Frame frame = new Frame ();
|
|
frame.ShadowType = ShadowType.In;
|
|
frame.SetSizeRequest (60, 60);
|
|
hpaned.Add1 (frame);
|
|
|
|
Gtk.Button button = new Button ("_Hi there");
|
|
frame.Add (button);
|
|
|
|
frame = new Frame ();
|
|
frame.ShadowType = ShadowType.In;
|
|
frame.SetSizeRequest (80, 60);
|
|
hpaned.Add2 (frame);
|
|
|
|
frame = new Frame ();
|
|
frame.ShadowType = ShadowType.In;
|
|
frame.SetSizeRequest (60, 80);
|
|
vpaned.Add2 (frame);
|
|
|
|
// Now create toggle buttons to control sizing
|
|
vbox.PackStart (CreatePaneOptions (hpaned,
|
|
"Horizontal",
|
|
"Left",
|
|
"Right"),
|
|
false, false, 0);
|
|
|
|
vbox.PackStart (CreatePaneOptions (vpaned,
|
|
"Vertical",
|
|
"Top",
|
|
"Bottom"),
|
|
false, false, 0);
|
|
|
|
ShowAll ();
|
|
}
|
|
|
|
Frame CreatePaneOptions (Paned paned, string frameLabel,
|
|
string label1, string label2)
|
|
{
|
|
Frame frame = new Frame (frameLabel);
|
|
frame.BorderWidth = 4;
|
|
|
|
Table table = new Table (3, 2, true);
|
|
frame.Add (table);
|
|
|
|
Label label = new Label (label1);
|
|
table.Attach (label, 0, 1, 0, 1);
|
|
|
|
CheckButton check = new CheckButton ("_Resize");
|
|
table.Attach (check, 0, 1, 1, 2);
|
|
check.Toggled += new EventHandler (ToggleResize);
|
|
children[check] = paned.Child1;
|
|
|
|
check = new CheckButton ("_Shrink");
|
|
table.Attach (check, 0, 1, 2, 3);
|
|
check.Active = true;
|
|
check.Toggled += new EventHandler (ToggleShrink);
|
|
children[check] = paned.Child1;
|
|
|
|
label = new Label (label2);
|
|
table.Attach (label, 1, 2, 0, 1);
|
|
|
|
check = new CheckButton ("_Resize");
|
|
table.Attach (check, 1, 2, 1, 2);
|
|
check.Active = true;
|
|
check.Toggled += new EventHandler (ToggleResize);
|
|
children[check] = paned.Child2;
|
|
|
|
check = new CheckButton ("_Shrink");
|
|
table.Attach (check, 1, 2, 2, 3);
|
|
check.Active = true;
|
|
check.Toggled += new EventHandler (ToggleShrink);
|
|
children[check] = paned.Child2;
|
|
|
|
return frame;
|
|
}
|
|
|
|
private void ToggleResize (object obj, EventArgs args)
|
|
{
|
|
ToggleButton toggle = obj as ToggleButton;
|
|
Widget child = children[obj] as Widget;
|
|
Paned paned = child.Parent as Paned;
|
|
|
|
Paned.PanedChild pc = paned[child] as Paned.PanedChild;
|
|
pc.Resize = toggle.Active;
|
|
}
|
|
|
|
private void ToggleShrink (object obj, EventArgs args)
|
|
{
|
|
ToggleButton toggle = obj as ToggleButton;
|
|
Widget child = children[obj] as Widget;
|
|
Paned paned = child.Parent as Paned;
|
|
|
|
Paned.PanedChild pc = paned[child] as Paned.PanedChild;
|
|
pc.Shrink = toggle.Active;
|
|
}
|
|
|
|
protected override bool OnDeleteEvent (Gdk.Event evt)
|
|
{
|
|
Destroy ();
|
|
return true;
|
|
}
|
|
}
|
|
}
|