2 /* Circ.Frontend.GtkSharp : GTK# frontend for Circ
3 * Copyright (C) 2007 LAVAL Jérémie
5 * This file is licensed under the terms of the LGPL.
7 * For the complete licence see the file COPYING.
15 namespace Circ
.Frontend
.GtkSharp
18 public class MessagesPanel
: TextView
20 static TextTagTable txtTags
;
26 public MessagesPanel(): base()
28 this.Editable
= false;
29 //this.DoubleBuffered = true;
30 this.WrapMode
= Gtk
.WrapMode
.Word
;
31 this.CursorVisible
= false;
34 this.CanFocus
= false;
36 background
= new Gdk
.Color ();
37 Gdk
.Color
.Parse (Options
.GetStringConfig("background"), ref background
);
38 this.ModifyBg (StateType
.Normal
, background
);
39 this.ModifyBase (StateType
.Normal
, background
);
41 RgbColor textColor
= LibContrast
.GetBestColorFromBackground(new RgbColor((byte)(background
.Red
/257),
42 (byte)(background
.Green
/257), (byte)(background
.Blue
/257)), ColorPalette
.Aqua
);
43 this.ModifyText(StateType
.Normal
, new Gdk
.Color(textColor
.Red
, textColor
.Green
, textColor
.Blue
));
44 this.ModifyFont(Pango
.FontDescription
.FromString(Options
.GetStringConfig("font")));
49 this.buffer
= new TextBuffer(txtTags
);
51 this.endMark
= buffer
.CreateMark("end", buffer
.EndIter
, false);
52 //this.buffer.InsertText += InsertionHandler;
55 private void InitTextTags()
57 txtTags
= new TextTagTable();
58 RgbColor backgroundColor
= new RgbColor((byte)(background
.Red
/257), (byte)(background
.Green
/257), (byte)(background
.Blue
/257));
61 TextTag message
= new TextTag("message");
62 TextTag author
= new TextTag("author");
63 TextTag hl
= new TextTag("hl");
64 TextTag itsme
= new TextTag("itsme");
65 TextTag notice
= new TextTag("notice");
66 TextTag time
= new TextTag("time");
69 // Tuning (follow Tango color scheme)
70 RgbColor hlColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)ColorPalette
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("hl")));
71 hl
.ForegroundGdk
= new Gdk
.Color(hlColor
.Red
, hlColor
.Green
, hlColor
.Blue
);
72 hl
.PixelsBelowLines
= 3;
74 RgbColor messageColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)Enum
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("author")));
75 message
.ForegroundGdk
= new Color(messageColor
.Red
, messageColor
.Green
, messageColor
.Blue
);
76 message
.PixelsBelowLines
= 2;
78 // This Enum.Parse() method is really really crappy
79 RgbColor authorColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)Enum
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("author")));
80 author
.ForegroundGdk
= new Color(authorColor
.Red
, authorColor
.Green
, authorColor
.Blue
);
81 author
.Weight
= Pango
.Weight
.Bold
;
83 RgbColor meColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)ColorPalette
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("self")));
84 itsme
.ForegroundGdk
= new Color(meColor
.Red
, meColor
.Green
, meColor
.Blue
);
86 RgbColor tiColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)ColorPalette
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("date")));
87 time
.ForegroundGdk
= new Color(tiColor
.Red
, tiColor
.Green
, tiColor
.Blue
);
89 RgbColor noticeColor
= LibContrast
.GetBestColorFromBackground(backgroundColor
, (ColorPalette
)ColorPalette
.Parse(typeof(ColorPalette
), Options
.GetStringConfig("notice")));
90 notice
.ForegroundGdk
= new Color(noticeColor
.Red
, noticeColor
.Green
, noticeColor
.Blue
);
100 internal void ScrollToEnd()
102 this.ScrollMarkOnscreen(endMark
);