3
// Copyright (C) 2008 Jason Smith
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
namespace Do.Interface.Widgets
29
public class TextFrame : Frame
31
protected Label label;
32
protected string labelText;
33
protected bool isFocused;
35
protected float focused_fill_transparency = 0.4f;
36
protected float unfocused_fill_transparency = 0.1f;
37
protected float focused_frame_transparency = 0.3f;
38
protected float unfocused_frame_transparency = 0.075f;
40
public string LabelText
42
get { return labelText; }
45
label.Markup = string.Format("<b>{0}</b>", value);
56
protected virtual void Build ()
59
label.Ellipsize = Pango.EllipsizeMode.End;
60
label.ModifyFg (StateType.Normal, Style.White);
68
get { return isFocused; }
75
protected override Cairo.LinearGradient GetGradient ()
79
r = (double) frameColor.Red / ushort.MaxValue;
80
g = (double) frameColor.Green / ushort.MaxValue;
81
b = (double) frameColor.Blue / ushort.MaxValue;
83
Cairo.LinearGradient grad = new Cairo.LinearGradient (0, 0, x+width, 0);
84
grad.AddColorStop (.1, new Cairo.Color (r, g, b, 0));
85
grad.AddColorStop (.35, new Cairo.Color (r, g, b, fillAlpha));
86
grad.AddColorStop (.65, new Cairo.Color (r, g, b, fillAlpha));
87
grad.AddColorStop (.9, new Cairo.Color (r, g, b, 0));
93
protected virtual void UpdateFocus ()
95
FillAlpha = (IsFocused ? focused_fill_transparency : unfocused_fill_transparency);
96
FrameAlpha = (IsFocused ? focused_frame_transparency : unfocused_frame_transparency);