Gtk.DrawingArea Class
The Gtk.DrawingArea widget is used for creating custom user interface elements.

See Also: DrawingArea Members

Syntax

public class DrawingArea : Widget

Remarks

The Gtk.DrawingArea widget is used for creating custom user interface elements. It's essentially a blank widget; you can draw on widget->window. After creating a drawing area, the application may want to connect to:

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; Widget.QueueDrawArea and Gdk.Window.InvalidateRect are equally good ways to do this. You'll then get an expose event for the invalid region. See also Gdk.Pixbuf.RenderToDrawable for drawing a Gdk.Pixbuf.

Example

C# Example

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 ();
        }
}
	  

Requirements

Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: 2.12.0.0