diff --git a/doc/ChangeLog b/doc/ChangeLog index 37ea78dc5..7fd9ff5db 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,6 +2,7 @@ * en/Gdk/Threads.xml: document * en/Gtk/TreeSelection.xml: add example + * en/Pango/Layout.xml: add example of drawing text to a Layout 2004-04-12 Mike Kestner diff --git a/doc/en/Pango/Layout.xml b/doc/en/Pango/Layout.xml index 48663b3d5..8b8643f49 100644 --- a/doc/en/Pango/Layout.xml +++ b/doc/en/Pango/Layout.xml @@ -16,6 +16,55 @@ The represents and entire paragraph of text. It is initialized with a , UTF-8 string and set of attributes for that string. Once that is done, the set of formatted lines can be extracted from the object, the layout can be rendered, and conversion between logical character positions within the layout's text, and the physical position of the resulting glyphs can be made. There are also a number of parameters to adjust the formatting of a . It is possible, as well, to ignore the 2-D setup, and simply treat the results of a as a list of lines. + + +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 (); + } +} + + GLib.Object