gtk-sharp2.8.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.The widget is used for creating custom user interface elements.
The widget is used for creating custom user interface elements. It's essentially a blank widget; you can draw on ->window. After creating a drawing area, the application may want to connect to:
1) Mouse and button press signals to respond to input from the user. (Use to enable events you wish to receive). 2) The signal to take any necessary actions when the widget is instantiated on a particular display. (Create GDK resources in response to this signal.) 3) The signal to take any necessary actions when the widget changes size. 4) The signal to handle redrawing the contents of the widget.
Expose events are normally delivered when a drawing area first comes onscreen, or when it's covered by another window and then uncovered (exposed). You can also force an expose event by adding to the "damage region" of the drawing area's window; and are equally good ways to do this. You'll then get an expose event for the invalid region. See also for drawing a .
using System;
using Gtk;
using Pango;
class LayoutSample : DrawingArea
{
Pango.Layout layout;
static void Main ()
{
Application.Init ();
new LayoutSample ();
Application.Run ();
}
LayoutSample ()
{
Window win = new Window ("Layout sample");
win.SetDefaultSize (400, 300);
win.DeleteEvent += OnWinDelete;
this.Realized += OnRealized;
this.ExposeEvent += OnExposed;
win.Add (this);
win.ShowAll ();
}
void OnExposed (object o, ExposeEventArgs args)
{
this.GdkWindow.DrawLayout (this.Style.TextGC (StateType.Normal), 100, 150, layout);
}
void OnRealized (object o, EventArgs args)
{
layout = new Pango.Layout (this.PangoContext);
layout.Wrap = Pango.WrapMode.Word;
layout.FontDescription = FontDescription.FromString ("Tahoma 16");
layout.SetMarkup ("Hello Pango.Layout");
}
void OnWinDelete (object o, DeleteEventArgs args)
{
Application.Quit ();
}
}
Gtk.WidgetConstructorInternal constructor
Pointer to the C object.
This is an internal constructor, and should not be used by user code.ConstructorDefault Constructor.PropertyGLib.GTypeGType Property.a Returns the native value for .ConstructorProtected Constructor.
a Chain to this constructor if you have manually registered a native value for your subclass.System.Obsolete(Message=null, IsError=False)MethodSystem.VoidSets the size of the drawing area.
a
a