ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.317 by root, Sun Jul 2 18:52:05 2006 UTC vs.
Revision 1.319 by root, Sun Jul 2 21:07:26 2006 UTC

2068 my ($self) = @_; 2068 my ($self) = @_;
2069 2069
2070 (6) x 2 2070 (6) x 2
2071} 2071}
2072 2072
2073sub toggle {
2074 my ($self) = @_;
2075
2076 $self->{state} = !$self->{state};
2077 $self->emit (changed => $self->{state});
2078 $self->update;
2079}
2080
2073sub invoke_button_down { 2081sub invoke_button_down {
2074 my ($self, $ev, $x, $y) = @_; 2082 my ($self, $ev, $x, $y) = @_;
2075 2083
2076 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x} 2084 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x}
2077 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) { 2085 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) {
2078 $self->{state} = !$self->{state}; 2086 $self->toggle;
2079 $self->emit (changed => $self->{state});
2080 } else { 2087 } else {
2081 return 0 2088 return 0
2082 } 2089 }
2083 2090
2084 1 2091 1
3162 3169
3163 $self->{current} = $self->{children}[0] 3170 $self->{current} = $self->{children}[0]
3164 if @{ $self->{children} }; 3171 if @{ $self->{children} };
3165} 3172}
3166 3173
3174sub get_current_page {
3175 my ($self) = @_;
3176
3177 $self->{current}
3178}
3179
3167sub set_current_page { 3180sub set_current_page {
3168 my ($self, $page_or_widget) = @_; 3181 my ($self, $page_or_widget) = @_;
3169 3182
3170 my $widget = ref $page_or_widget 3183 my $widget = ref $page_or_widget
3171 ? $page_or_widget 3184 ? $page_or_widget
3235 tooltip => $tooltip, 3248 tooltip => $tooltip,
3236 on_activate => sub { $self->set_current_page ($widget) }, 3249 on_activate => sub { $self->set_current_page ($widget) },
3237 ); 3250 );
3238 3251
3239 $self->{multiplexer}->add ($widget); 3252 $self->{multiplexer}->add ($widget);
3253}
3254
3255sub get_current_page {
3256 my ($self) = @_;
3257
3258 $self->{multiplexer}->get_current_page
3240} 3259}
3241 3260
3242sub set_current_page { 3261sub set_current_page {
3243 my ($self, $page) = @_; 3262 my ($self, $page) = @_;
3244 3263
3449 3468
3450############################################################################# 3469#############################################################################
3451 3470
3452package CFClient::UI::Inventory; 3471package CFClient::UI::Inventory;
3453 3472
3454our @ISA = CFClient::UI::ScrolledWindow::; 3473our @ISA = CFClient::UI::Table::;
3455 3474
3456sub new { 3475sub new {
3457 my $class = shift; 3476 my $class = shift;
3458 3477
3459 my $self = $class->SUPER::new ( 3478 my $self = $class->SUPER::new (
3460 child => (new CFClient::UI::Table col_expand => [0, 1, 0]), 3479 col_expand => [0, 1, 0],
3461 @_, 3480 @_,
3462 ); 3481 );
3463 3482
3464 $self 3483 $self
3465} 3484}
3466 3485
3467sub set_items { 3486sub set_items {
3468 my ($self, $items) = @_; 3487 my ($self, $items) = @_;
3469 3488
3470 $self->{child}->clear; 3489 $self->clear;
3471 return unless $items; 3490 return unless $items;
3472 3491
3473 my @items = sort { 3492 my @items = sort {
3474 ($a->{type} <=> $b->{type}) 3493 ($a->{type} <=> $b->{type})
3475 or ($a->{name} cmp $b->{name}) 3494 or ($a->{name} cmp $b->{name})
3479 3498
3480 my $row = 0; 3499 my $row = 0;
3481 for my $item (@items) { 3500 for my $item (@items) {
3482 CFClient::Item::update_widgets $item; 3501 CFClient::Item::update_widgets $item;
3483 3502
3484 $self->{child}->add (0, $row, $item->{face_widget}); 3503 $self->add (0, $row, $item->{face_widget});
3485 $self->{child}->add (1, $row, $item->{desc_widget}); 3504 $self->add (1, $row, $item->{desc_widget});
3486 $self->{child}->add (2, $row, $item->{weight_widget}); 3505 $self->add (2, $row, $item->{weight_widget});
3487 3506
3488 $row++; 3507 $row++;
3489 } 3508 }
3490} 3509}
3491 3510

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines