ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI/MessageWindow.pm
Revision: 1.3
Committed: Mon Jul 23 18:13:33 2007 UTC (16 years, 11 months ago) by elmex
Branch: MAIN
Changes since 1.2: +35 -74 lines
Log Message:
checking in some refactored code

File Contents

# Content
1 package CFPlus::UI::MessageWindow;
2
3 use strict;
4 use utf8;
5
6 use CFPlus::UI::ChatView;
7
8 our @ISA = CFPlus::UI::Toplevel::;
9
10 sub new {
11 my $class = shift;
12
13 my $self = $class->SUPER::new (
14 name => "message_window",
15 title => "Messages",
16 border_bg => [1, 1, 1, 1],
17 x => "max",
18 y => 0,
19 force_w => $::WIDTH * 0.4,
20 force_h => $::HEIGHT * 0.5,
21 child => (my $nb = CFPlus::UI::Notebook->new (expand => 1)),
22 has_close_button => 1
23 );
24
25 my $chatview = $self->{main_log} = CFPlus::UI::ChatView->new (expand => 1);
26 $nb->add_tab ("Log" => $chatview, "This is the main log of the server.");
27 $self->{nb} = $nb;
28 #d# $self->add_chat (foo => 'bar');
29
30 $self
31 }
32
33 sub add_chat {
34 my ($self, $title, $cmdprefix) = @_;
35
36 my $nb = $self->{nb};
37
38 # only proof-of-concept code:
39 my $fo = CFPlus::UI::Button->new (markup => "test");
40 my $vb = $fo->{c_tab} = CFPlus::UI::HBox->new;
41 $vb->add (my $b = CFPlus::UI::Button->new (expand => 1, markup => "FICKEN!!!!"));
42 $b->connect (activate => sub { $vb->emit ('activate'); 1 });
43 $fo->connect (activate => sub {
44 my $fo = shift;
45 my @chld = $nb->pages;
46 my $cur = pop @chld;
47 while (@chld && $cur != $fo) {
48 $cur = pop @chld;
49 }
50 $cur = pop @chld;
51 $nb->remove ($fo);
52 $nb->set_current_page ($cur);
53 0
54 });
55 $nb->add ($fo);
56 }
57
58 sub message {
59 my ($self, $para) = @_;
60 $self->{main_log}->message ($para);
61 }
62
63 sub activate_console {
64 my ($self, $preset) = @_;
65 $self->{main_log}->activate_console ($preset);
66 }
67
68 sub set_fontsize {
69 my ($self, $size) = @_;
70 $self->{main_log}->set_fontsize ($size);
71 }
72
73 sub set_max_para {
74 my ($self, $max_par) = @_;
75 $self->{main_log}->set_max_para ($max_par);
76 }
77
78 1;
79