mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-12 12:05:29 +00:00
4d92d54b3f
[about 60% of the marshalling patch that I lost. The rest to come tomorrow.] * generator/BoxedGen.cs, StructGen.cs: Move most of this to StructBase, delete large chunks duplicated from ClassBase. * generator/IGeneratable.cs: Add MarshalReturnType, FromNativeReturn. * generator/ClassBase.cs: Move ctor stuff here. Add a CallByName overload with no parameters for the "self" reference. * generator/EnumGen.cs, CallbackGen.cs: Implement new MarshalReturnType, FromNativeReturn. * generator/Method.cs: Use container_type.MarshalType, CallByName, and SymbolTable.FromNativeReturn when generating call and import sigs. * generator/OpaqueGen.cs: Added. * generator/Property.cs: Handle boxed and opaques differently. * generator/SymbolTable.cs: Update for the opaque stuff and the new Return methods. Also change GetClassGen to simply call the as operator. * glib/Boxed.cs: Update for struct usage -- this is now a wrapper for the purposes of using with Value. * glib/Opaque.cs: Added. New base class for opaque structs. * glue/textiter.c, gtk/TextIter.custom: Remove. * gnome/Program.cs: Update for new struct marshalling. * parser/Metadata.pm: Use our own getChildrenByTagName. * parser/README: Update for new requirements (was out of sync with build.pl) * parser/gapi2xml.pl: Hide struct like const in field elements. * parser/gapi_pp.pl: Handle embedded union fields (poorly). * sample/test/TestColorSelection.cs: Comment out null color tests for now. svn path=/trunk/gtk-sharp/; revision=6186
118 lines
2.8 KiB
C#
118 lines
2.8 KiB
C#
//
|
|
// TestColorSelection.cs
|
|
//
|
|
// Author: Duncan Mak (duncan@ximian.com)
|
|
//
|
|
// Copyright (C) 2002, Duncan Mak, Ximian Inc.
|
|
//
|
|
|
|
using System;
|
|
|
|
using Gtk;
|
|
using GtkSharp;
|
|
|
|
namespace WidgetViewer {
|
|
public class TestColorSelection
|
|
{
|
|
static ColorSelectionDialog window = null;
|
|
static Dialog dialog = null;
|
|
|
|
public static Gtk.Window Create ()
|
|
{
|
|
HBox options = new HBox (false, 0);
|
|
CheckButton check_button = null;
|
|
|
|
window = new ColorSelectionDialog ("Color selection dialog");
|
|
window.ColorSelection.HasOpacityControl = true;
|
|
window.ColorSelection.HasPalette = true;
|
|
|
|
window.SetDefaultSize (250, 200);
|
|
window.VBox.PackStart (options, false, false, 0);
|
|
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);
|
|
|
|
window.ColorSelection.ColorChanged += new EventHandler (Color_Changed);
|
|
window.OkButton.Clicked += new EventHandler (Color_Selection_OK);
|
|
window.CancelButton.Clicked += new EventHandler (Color_Selection_Cancel);
|
|
|
|
options.ShowAll ();
|
|
|
|
return window;
|
|
}
|
|
|
|
static void Opacity_Callback (object o, EventArgs args)
|
|
{
|
|
window.ColorSelection.HasOpacityControl = ((ToggleButton )o).Active;
|
|
}
|
|
|
|
static void Palette_Callback (object o, EventArgs args)
|
|
{
|
|
window.ColorSelection.HasPalette = ((ToggleButton )o).Active;
|
|
}
|
|
|
|
static void Color_Changed (object o, EventArgs args)
|
|
{
|
|
Gdk.Color color = window.ColorSelection.CurrentColor;
|
|
}
|
|
|
|
static void Color_Selection_OK (object o, EventArgs args)
|
|
{
|
|
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)
|
|
{
|
|
if (dialog != null)
|
|
dialog.Destroy ();
|
|
window.Destroy ();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|