Added SILC Thread Queue API
[crypto.git] / apps / silcer / src / silcerchatview.hh
1 /*
2
3   silcerchatview.hh 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2001 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   Code is mostly ripped from Gabber, thus code also copyrighted by:
19   Copyright (C) 1999-2001 Dave Smith & Julian Missig
20 */
21
22 #ifndef SILCERCHATVIEW_HH
23 #define SILCERCHATVIEW_HH
24
25 extern "C" {
26 #include "xtext.h"
27 }
28
29 #include <gtk/gtkframe.h>
30 #include <gtk/gtkvscrollbar.h>
31 #include <gtk--/container.h>
32 #include <gtk--/paned.h>
33 #include <gtk--/widget.h>
34
35 typedef const string COLOR_T;
36
37 COLOR_T BLACK       = "\0030";
38 COLOR_T WHITE       = "\0031";
39 COLOR_T BLUE        = "\0032";
40 COLOR_T GREEN       = "\0033";
41 COLOR_T RED         = "\0034";
42 COLOR_T YELLOWBROWN = "\0035";
43 COLOR_T PURPLE      = "\0036";
44 COLOR_T ORANGE      = "\0037";
45 COLOR_T YELLOW      = "\0038";
46 COLOR_T GREEN2      = "\0039";
47 COLOR_T AQUA        = "\00310";
48 COLOR_T LIGHTAQUA   = "\00311";
49 COLOR_T BLUE2       = "\00312";
50 COLOR_T PINK        = "\00313";
51 COLOR_T GREY        = "\00314";
52 COLOR_T LIGHTGREY   = "\00315";
53 COLOR_T BLUEMARKBACK= "\00316";
54 COLOR_T WHITEMARKFORE= "\00317";
55 COLOR_T WHITEFORE   = "\00318";
56 COLOR_T BLACKBACK   = "\00319";
57
58
59 class SilcerChatView
60 {
61 public:
62   SilcerChatView(Gtk::Widget *owner, Gtk::Container *parent, 
63                  gboolean indent = true);
64   SilcerChatView(Gtk::Widget *owner, Gtk::Paned *parent, 
65                  gboolean indent = true);
66   ~SilcerChatView();
67   void render(const string &message, const string &username, 
68               const string &timestamp, COLOR_T &delimiter_color);
69   void render_error(const string &message, const string &error, 
70                     const string &timestamp, COLOR_T &delimiter_color);
71   void clearbuffer();
72   string get_chars();
73   GtkXText *_xtext;
74   GtkFrame *_frmChat;
75   GtkVScrollbar *_vsChat;
76
77  protected:
78   void print(const string &s);
79   void print(const string &left, const string &right);
80   void on_word_clicked(char* word, GdkEventButton *evt);
81   static void _on_word_clicked_stub(GtkXText *xtext, char *word, 
82                                     GdkEventButton *evt, 
83                                     SilcerChatView *_this);
84 };
85
86 #endif /* SILCERCHATVIEW_HH */