Cosmetic change, plugin work, various reaorganization (Frontend, Control, CilBackend)
[circ.git] / Circ.Frontend.GtkSharp / MessagesPanel.cs
blob2b37b4402e399e9ad314fe7f579305c9443e557c
2 using System;
3 using Circ.Lib;
4 using Gtk;
5 using Gdk;
7 namespace Circ.Frontend.GtkSharp
10 public class MessagesPanel: TextView
12 TextTagTable textTags;
13 TextBuffer buffer;
14 TextMark endMark;
16 Gdk.Color background;
18 public MessagesPanel(): base()
20 this.Editable = false;
21 //this.DoubleBuffered = true;
22 this.WrapMode = Gtk.WrapMode.Word;
23 this.CursorVisible = false;
24 this.LeftMargin = 3;
25 this.RightMargin = 3;
26 this.CanFocus = false;
28 background = new Gdk.Color ();
29 Gdk.Color.Parse ("#eeeeec", ref background);
30 this.ModifyBg (StateType.Normal, background);
31 this.ModifyBase (StateType.Normal, background);
33 RgbColor textColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
34 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.Aqua);
35 this.ModifyText(StateType.Normal, new Gdk.Color(textColor.Red, textColor.Green, textColor.Blue));
37 InitTextTags();
39 this.buffer = new TextBuffer(textTags);
40 this.Buffer = buffer;
41 this.endMark = buffer.CreateMark("end", buffer.EndIter, false);
42 //this.buffer.InsertText += InsertionHandler;
45 private void InitTextTags()
47 textTags = new TextTagTable();
49 // Instanciation
50 //TextTag message = new TextTag("message");
51 TextTag author = new TextTag("author");
52 TextTag hl = new TextTag("hl");
53 TextTag itsme = new TextTag("itsme");
54 TextTag notice = new TextTag("notice");
55 TextTag time = new TextTag("time");
58 // Tuning (follow Tango color scheme)
59 RgbColor hlColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
60 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.DarkRed);
61 hl.ForegroundGdk = new Gdk.Color(hlColor.Red, hlColor.Green, hlColor.Blue);
62 hl.PixelsBelowLines = 3;
64 //message.ForegroundGdk = new Color(46, 52, 54);
65 //message.PixelsBelowLines = 3;
67 RgbColor authorColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
68 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.DarkBlue);
69 author.ForegroundGdk = new Color(authorColor.Red, authorColor.Green, authorColor.Blue);
70 author.Weight = Pango.Weight.Bold;
72 RgbColor meColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
73 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.Brown);
74 itsme.ForegroundGdk = new Color(meColor.Red, meColor.Green, meColor.Blue);
76 textTags.Add(author);
77 textTags.Add(hl);
78 textTags.Add(notice);
79 textTags.Add(time);
80 textTags.Add(itsme);
83 internal void ScrollToEnd()
85 this.ScrollMarkOnscreen(endMark);