2001-10-07 Mike Kestner <mkestner@speakeasy.net>

* glib/Object.cs : Added public Handle property.  It would be nice
	if I could make the RawObject public for get and protected for set,
	but that doesn't appear to be possible with C# properties.
	* gtk/Container.cs : New class with 2 of the 3 props and the Add/Remove
	methods only implemented.
	* gtk/Widget.cs : Added SizeRequest prop which is a combination of
	HeightRequest and SizeRequest. Embrace and extend gtk...
	* gtk/Window.cs : Derive from newly added Container subclass.
	* sample/ButtonApp.cs : Simple tire-kicking app.

svn path=/trunk/gtk-sharp/; revision=1112
This commit is contained in:
Mike Kestner 2001-10-07 00:41:52 +00:00
parent 58dc5f24bf
commit aa1077bbb1
7 changed files with 203 additions and 5 deletions

View file

@ -1,3 +1,15 @@
2001-10-07 Mike Kestner <mkestner@speakeasy.net>
* glib/Object.cs : Added public Handle property. It would be nice
if I could make the RawObject public for get and protected for set,
but that doesn't appear to be possible with C# properties.
* gtk/Container.cs : New class with 2 of the 3 props and the Add/Remove
methods only implemented.
* gtk/Widget.cs : Added SizeRequest prop which is a combination of
HeightRequest and SizeRequest. Embrace and extend gtk...
* gtk/Window.cs : Derive from newly added Container subclass.
* sample/ButtonApp.cs : Simple tire-kicking app.
2001-10-06 Mike Kestner <mkestner@speakeasy.net>
* gtk/Button.cs : Implemented 3 constructors, 5 methods, 4 properties,

View file

@ -58,8 +58,9 @@ namespace GLib {
///
/// <remarks>
/// The raw GObject reference associated with this wrapper.
/// Only subclasses of Object should need to access this
/// unmanaged pointer.
/// Only subclasses of Object can access this read/write
/// property. For public read-only access, use the
/// Handle property.
/// </remarks>
protected IntPtr RawObject {
@ -72,6 +73,22 @@ namespace GLib {
}
}
/// <summary>
/// Handle Property
/// </summary>
///
/// <remarks>
/// The raw GObject reference associated with this object.
/// Subclasses can use RawObject property for read/write
/// access.
/// </remarks>
public IntPtr Handle {
get {
return _obj;
}
}
/// <summary>
/// Events Property
/// </summary>
@ -81,7 +98,7 @@ namespace GLib {
/// object indexed by the Gtk+ signal name.
/// </remarks>
public EventHandlerList Events {
protected EventHandlerList Events {
get {
if (_events == null)
_events = new EventHandlerList ();

100
gtk/Container.cs Normal file
View file

@ -0,0 +1,100 @@
// Gtk.Container.cs - GtkContainer class wrapper implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001 Mike Kestner
namespace Gtk {
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Container Class
/// </summary>
///
/// <remarks>
/// Abstract class which provides the capability to embed a
/// widget within its boundaries.
/// </remarks>
public abstract class Container : Widget {
/// <summary>
/// BorderWidth Property
/// </summary>
///
/// <remarks>
/// The Width, in pixels, of the border around the
/// Container.
/// </remarks>
public int BorderWidth {
get {
int val;
GetProperty ("border-width", out val);
return val;
}
set {
SetProperty ("border-width", value);
}
}
// FIXME: Implement Child property.
/// <summary>
/// ResizeMode Property
/// </summary>
///
/// <remarks>
/// Indicates the resizing policy for the Container.
/// </remarks>
public ResizeMode ResizeMode {
get {
int val;
GetProperty ("border-width", out val);
return (ResizeMode) val;
}
set {
SetProperty ("border-width", (int) value);
}
}
/// <summary>
/// Add Method
/// </summary>
///
/// <remarks>
/// Adds a child Widget to the Container.
/// </remarks>
[DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
static extern void gtk_container_add (IntPtr obj, IntPtr child);
public void Add (Widget child)
{
gtk_container_add (Handle, child.Handle);
}
/// <summary>
/// Remove Method
/// </summary>
///
/// <remarks>
/// Remove a child Widget from the Container.
/// </remarks>
[DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
static extern void gtk_container_remove (IntPtr obj,
IntPtr child);
public void Remove (Widget child)
{
gtk_container_remove (Handle, child.Handle);
}
}
}

View file

@ -8,6 +8,7 @@ namespace Gtk {
using System;
using System.Collections;
using System.Drawing;
using System.Runtime.InteropServices;
using GLib;
using Gdk;
@ -213,6 +214,24 @@ namespace Gtk {
}
}
/// <summary>
/// SizeRequest Property
/// </summary>
///
/// <remarks>
/// The desired size in pixels for the widget.
/// </remarks>
public Size SizeRequest {
get {
return new Size (WidthRequest, HeightRequest);
}
set {
WidthRequest = value.Width;
HeightRequest = value.Height;
}
}
/// <summary>
/// Visible Property
/// </summary>

View file

@ -11,7 +11,15 @@ namespace Gtk {
using System.Drawing;
using System.Runtime.InteropServices;
public class Window : Widget {
/// <summary>
/// Window Class
/// </summary>
///
/// <remarks>
/// A Top Level Window object.
/// </remarks>
public class Window : Container {
/// <summary>
/// Window Object Constructor

41
sample/ButtonApp.cs Executable file
View file

@ -0,0 +1,41 @@
// ButtonApp.cs - Gtk.Button class Test implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001 Mike Kestner
namespace GtkSamples {
using Gtk;
using System;
using System.Drawing;
public class ButtonApp {
public static int Main (string[] args)
{
Application.Init (ref args);
Window win = new Window ("Button Tester");
win.DeleteEvent += new EventHandler (Window_Delete);
Button btn = new Button ();
btn.Clicked += new EventHandler (btn_click);
btn.SizeRequest = new Size (32, 24);
btn.Show ();
win.Add (btn);
win.Show ();
Application.Run ();
return 0;
}
static void btn_click (object obj, EventArgs args)
{
Console.WriteLine ("Button Clicked");
}
static void Window_Delete (object obj, EventArgs args)
{
Application.Quit ();
}
}
}

View file

@ -3,7 +3,8 @@ all:
@echo "'make unix' is broken for now."
windows:
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /recurse:*.cs
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll HelloWorld.cs
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
unix:
@echo "'make unix' is broken for now."