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 (17 years ago) by elmex
Branch: MAIN
Changes since 1.2: +35 -74 lines
Log Message:
checking in some refactored code

File Contents

# User Rev Content
1 elmex 1.1 package CFPlus::UI::MessageWindow;
2    
3     use strict;
4     use utf8;
5    
6 elmex 1.3 use CFPlus::UI::ChatView;
7    
8 elmex 1.1 our @ISA = CFPlus::UI::Toplevel::;
9    
10     sub new {
11     my $class = shift;
12 root 1.2
13 elmex 1.1 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 elmex 1.3 child => (my $nb = CFPlus::UI::Notebook->new (expand => 1)),
22 elmex 1.1 has_close_button => 1
23     );
24 root 1.2
25 elmex 1.3 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 elmex 1.1
30     $self
31     }
32    
33 elmex 1.3 sub add_chat {
34     my ($self, $title, $cmdprefix) = @_;
35 elmex 1.1
36 elmex 1.3 my $nb = $self->{nb};
37 elmex 1.1
38 elmex 1.3 # 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 elmex 1.1
58 elmex 1.3 sub message {
59     my ($self, $para) = @_;
60     $self->{main_log}->message ($para);
61 elmex 1.1 }
62    
63     sub activate_console {
64     my ($self, $preset) = @_;
65 elmex 1.3 $self->{main_log}->activate_console ($preset);
66 elmex 1.1 }
67    
68     sub set_fontsize {
69     my ($self, $size) = @_;
70 elmex 1.3 $self->{main_log}->set_fontsize ($size);
71 elmex 1.1 }
72    
73     sub set_max_para {
74     my ($self, $max_par) = @_;
75 elmex 1.3 $self->{main_log}->set_max_para ($max_par);
76 elmex 1.1 }
77 root 1.2
78     1;
79