5
// Aaron Bockover <abockover@novell.com>
7
// Adapted for Docky by:
8
// Chris Szikszoy <chris@szikszoy.com>
10
// Copyright (C) 2008 Novell, Inc.
12
// Permission is hereby granted, free of charge, to any person obtaining
13
// a copy of this software and associated documentation files (the
14
// "Software"), to deal in the Software without restriction, including
15
// without limitation the rights to use, copy, modify, merge, publish,
16
// distribute, sublicense, and/or sell copies of the Software, and to
17
// permit persons to whom the Software is furnished to do so, subject to
18
// the following conditions:
20
// The above copyright notice and this permission notice shall be
21
// included in all copies or substantial portions of the Software.
23
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
namespace Docky.Widgets
37
[System.ComponentModel.ToolboxItem(true)]
38
public class WrapLabel : Widget
41
private bool use_markup = false;
42
private bool wrap = true;
43
private Pango.Layout layout;
47
WidgetFlags |= WidgetFlags.NoWindow;
50
private void CreateLayout ()
56
layout = new Pango.Layout (PangoContext);
57
layout.Wrap = Pango.WrapMode.Word;
60
private void UpdateLayout ()
66
layout.Ellipsize = wrap ? Pango.EllipsizeMode.None : Pango.EllipsizeMode.End;
73
layout.SetMarkup (text);
75
layout.SetText (text);
81
protected override void OnStyleSet (Style previous_style)
85
base.OnStyleSet (previous_style);
88
protected override void OnRealized ()
90
GdkWindow = Parent.GdkWindow;
94
protected override void OnSizeAllocated (Gdk.Rectangle allocation)
98
layout.Width = (int)(allocation.Width * Pango.Scale.PangoScale);
99
layout.GetPixelSize (out lw, out lh);
103
base.OnSizeAllocated (allocation);
106
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
108
if (evnt.Window == GdkWindow) {
109
Gtk.Style.PaintLayout (Style, GdkWindow, State, false,
110
evnt.Area, this, null, Allocation.X, Allocation.Y, layout);
116
public void MarkupFormat (string format, params object [] args)
118
if (args == null || args.Length == 0) {
123
for (int i = 0; i < args.Length; i++) {
124
if (args[i] is string) {
125
args[i] = GLib.Markup.EscapeText ((string)args[i]);
129
Markup = String.Format (format, args);
140
public string Markup {