~bas-dotbas/do/win32-next

« back to all changes in this revision

Viewing changes to Do/src/UI/SymbolDisplayLabel.cs

  • Committer: djsiegel at gmail
  • Date: 2007-10-13 21:55:22 UTC
  • Revision ID: djsiegel@gmail.com-20071013215522-n0vjgog0tyjfnpno
Restructured plugins library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// RoundedFrame.cs created with MonoDevelop
2
 
// User: dave at 11:15 AM 8/25/2007
3
 
//
4
 
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
5
 
//
6
 
 
7
 
using System;
8
 
 
9
 
using Gtk;
10
 
using Gdk;
11
 
 
12
 
using Do.PluginLib;
13
 
 
14
 
namespace Do.UI
15
 
{
16
 
        
17
 
        public class SymbolDisplayLabel : Label
18
 
        {
19
 
                
20
 
                // const string displayFormat = " <big>{0}</big> \n {1} ";
21
 
                
22
 
                // Description only:
23
 
                const string displayFormat = "<span size=\"medium\"> {1} </span>";
24
 
                
25
 
                string highlight;
26
 
                string name, description;
27
 
                
28
 
                public SymbolDisplayLabel () : base ()
29
 
                {
30
 
                        highlight = name = description = "";
31
 
                        Build ();
32
 
                }
33
 
                
34
 
                void Build ()
35
 
                {
36
 
                        UseMarkup = true;
37
 
                        Ellipsize = Pango.EllipsizeMode.End;
38
 
                        Justify = Justification.Center;
39
 
                        ModifyFg (StateType.Normal, Style.White);
40
 
                }
41
 
                
42
 
                public IObject DisplayObject {
43
 
                        set {
44
 
                                IObject displayObject;
45
 
                                
46
 
                                displayObject = value;
47
 
                                name = description = highlight = "";
48
 
                                if (displayObject != null) {
49
 
                                        name = displayObject.Name;
50
 
                                        description = displayObject.Description;
51
 
                                }
52
 
                                SetDisplayLabel (name, description);
53
 
                        }
54
 
                }
55
 
                
56
 
                public void SetDisplayLabel (string name, string description) {
57
 
                        this.name = (name == null ? "" : name);
58
 
                        this.description = (description == null ? "" : description);
59
 
                        highlight = "";
60
 
                        UpdateText ();
61
 
                }
62
 
                
63
 
                public string Highlight {
64
 
                        get { return highlight; }
65
 
                        set {
66
 
                                highlight = (value == null ? "" : value);
67
 
                                UpdateText ();
68
 
                        }
69
 
                }
70
 
                
71
 
                void UpdateText ()
72
 
                {
73
 
                        string highlighted, safe_name, safe_description;
74
 
 
75
 
                        safe_name = Util.Appearance.MarkupSafeString (name);
76
 
                        safe_description = Util.Appearance.MarkupSafeString (description);
77
 
                        highlighted = Util.FormatCommonSubstrings(safe_name,
78
 
                                                                                                                                                                                                highlight,
79
 
                                                                                                                                                                                                "<u>{0}</u>");
80
 
                        Markup = string.Format (displayFormat, highlighted, safe_description);
81
 
                }
82
 
                
83
 
        }
84
 
}