* Shop + Plugin is now functionnal, sample Plugin provided to connect to the default...
[circ.git] / Circ.Frontend.GtkSharp / MessagesPanel.cs
blob3664686f3ffe3101f87bf1e375c33d200b44f37d
1 #region License
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.
8 */
9 #endregion
10 using System;
11 using Circ.Lib;
12 using Gtk;
13 using Gdk;
15 namespace Circ.Frontend.GtkSharp
18 public class MessagesPanel: TextView
20 TextTagTable textTags;
21 TextBuffer buffer;
22 TextMark endMark;
24 Gdk.Color background;
26 public MessagesPanel(): base()
28 this.Editable = false;
29 //this.DoubleBuffered = true;
30 this.WrapMode = Gtk.WrapMode.Word;
31 this.CursorVisible = false;
32 this.LeftMargin = 3;
33 this.RightMargin = 3;
34 this.CanFocus = false;
36 background = new Gdk.Color ();
37 Gdk.Color.Parse ("#eeeeec", 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));
45 InitTextTags();
47 this.buffer = new TextBuffer(textTags);
48 this.Buffer = buffer;
49 this.endMark = buffer.CreateMark("end", buffer.EndIter, false);
50 //this.buffer.InsertText += InsertionHandler;
53 private void InitTextTags()
55 textTags = new TextTagTable();
57 // Instanciation
58 //TextTag message = new TextTag("message");
59 TextTag author = new TextTag("author");
60 TextTag hl = new TextTag("hl");
61 TextTag itsme = new TextTag("itsme");
62 TextTag notice = new TextTag("notice");
63 TextTag time = new TextTag("time");
66 // Tuning (follow Tango color scheme)
67 RgbColor hlColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
68 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.DarkRed);
69 hl.ForegroundGdk = new Gdk.Color(hlColor.Red, hlColor.Green, hlColor.Blue);
70 hl.PixelsBelowLines = 3;
72 //message.ForegroundGdk = new Color(46, 52, 54);
73 //message.PixelsBelowLines = 3;
75 RgbColor authorColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
76 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.DarkBlue);
77 author.ForegroundGdk = new Color(authorColor.Red, authorColor.Green, authorColor.Blue);
78 author.Weight = Pango.Weight.Bold;
80 RgbColor meColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
81 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.Brown);
82 itsme.ForegroundGdk = new Color(meColor.Red, meColor.Green, meColor.Blue);
84 RgbColor tiColor = LibContrast.GetBestColorFromBackground(new RgbColor((byte)(background.Red/257),
85 (byte)(background.Green/257), (byte)(background.Blue/257)), ColorPalette.Green);
86 time.ForegroundGdk = new Color(tiColor.Red, tiColor.Green, tiColor.Blue);
88 textTags.Add(author);
89 textTags.Add(hl);
90 textTags.Add(notice);
91 textTags.Add(time);
92 textTags.Add(itsme);
95 internal void ScrollToEnd()
97 this.ScrollMarkOnscreen(endMark);