package CFPlus::UI::MessageWindow; use strict; use utf8; use CFPlus::UI::ChatView; our @ISA = CFPlus::UI::Toplevel::; sub new { my $class = shift; my $self = $class->SUPER::new ( name => "message_window", title => "Messages", border_bg => [1, 1, 1, 1], x => "max", y => 0, force_w => $::WIDTH * 0.4, force_h => $::HEIGHT * 0.5, child => (my $nb = CFPlus::UI::Notebook->new (expand => 1)), has_close_button => 1 ); my $chatview = $self->{main_log} = CFPlus::UI::ChatView->new (expand => 1); $nb->add_tab ("Log" => $chatview, "This is the main log of the server."); $self->{nb} = $nb; #d# $self->add_chat (foo => 'bar'); $self } sub add_chat { my ($self, $title, $cmdprefix) = @_; my $nb = $self->{nb}; # only proof-of-concept code: my $fo = CFPlus::UI::Button->new (markup => "test"); my $vb = $fo->{c_tab} = CFPlus::UI::HBox->new; $vb->add (my $b = CFPlus::UI::Button->new (expand => 1, markup => "FICKEN!!!!")); $b->connect (activate => sub { $vb->emit ('activate'); 1 }); $fo->connect (activate => sub { my $fo = shift; my @chld = $nb->pages; my $cur = pop @chld; while (@chld && $cur != $fo) { $cur = pop @chld; } $cur = pop @chld; $nb->remove ($fo); $nb->set_current_page ($cur); 0 }); $nb->add ($fo); } sub message { my ($self, $para) = @_; $self->{main_log}->message ($para); } sub activate_console { my ($self, $preset) = @_; $self->{main_log}->activate_console ($preset); } sub set_fontsize { my ($self, $size) = @_; $self->{main_log}->set_fontsize ($size); } sub set_max_para { my ($self, $max_par) = @_; $self->{main_log}->set_max_para ($max_par); } 1;