… | |
… | |
246 | } |
246 | } |
247 | |
247 | |
248 | # return top left coordinates |
248 | # return top left coordinates |
249 | sub _topleft { |
249 | sub _topleft { |
250 | my ($self, $x, $y) = @_; |
250 | my ($self, $x, $y) = @_; |
|
|
251 | |
|
|
252 | $self->{parent} |
|
|
253 | or Carp::confess "no parent widget in _topleft\n";#d# |
251 | |
254 | |
252 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
255 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
253 | } |
256 | } |
254 | |
257 | |
255 | # translate global coordinates to local coordinate system |
258 | # translate global coordinates to local coordinate system |
… | |
… | |
1469 | |
1472 | |
1470 | if ($sym == 13) { |
1473 | if ($sym == 13) { |
1471 | unshift @{$self->{history}}, |
1474 | unshift @{$self->{history}}, |
1472 | my $txt = $self->get_text; |
1475 | my $txt = $self->get_text; |
1473 | $self->{history_pointer} = -1; |
1476 | $self->{history_pointer} = -1; |
|
|
1477 | $self->{history_saveback} = ''; |
1474 | $self->emit (activate => $txt); |
1478 | $self->emit (activate => $txt); |
1475 | $self->update; |
1479 | $self->update; |
1476 | |
1480 | |
1477 | } elsif ($sym == CFClient::SDLK_UP) { |
1481 | } elsif ($sym == CFClient::SDLK_UP) { |
1478 | if ($self->{history_pointer} < 0) { |
1482 | if ($self->{history_pointer} < 0) { |
1479 | $self->{history_saveback} = $self->get_text; |
1483 | $self->{history_saveback} = $self->get_text; |
1480 | } |
1484 | } |
|
|
1485 | if (@{$self->{history} || []} > 0) { |
1481 | $self->{history_pointer}++; |
1486 | $self->{history_pointer}++; |
1482 | if ($self->{history_pointer} >= @{$self->{history}}) { |
1487 | if ($self->{history_pointer} >= @{$self->{history} || []}) { |
1483 | $self->{history_pointer} = @{$self->{history}} - 1; |
1488 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
|
|
1489 | } |
|
|
1490 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
1484 | } |
1491 | } |
1485 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1486 | |
1492 | |
1487 | } elsif ($sym == CFClient::SDLK_DOWN) { |
1493 | } elsif ($sym == CFClient::SDLK_DOWN) { |
1488 | $self->{history_pointer}--; |
1494 | $self->{history_pointer}--; |
1489 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
1495 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
1490 | |
1496 | |
… | |
… | |
1821 | |
1827 | |
1822 | sub new { |
1828 | sub new { |
1823 | my ($class, %arg) = @_; |
1829 | my ($class, %arg) = @_; |
1824 | |
1830 | |
1825 | my $self = $class->SUPER::new ( |
1831 | my $self = $class->SUPER::new ( |
1826 | tooltip => $arg{type}, |
1832 | tooltip => $arg{type}, |
1827 | can_hover => 1, |
1833 | can_hover => 1, |
|
|
1834 | can_events => 1, |
1828 | %arg, |
1835 | %arg, |
1829 | ); |
1836 | ); |
1830 | |
1837 | |
1831 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1838 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1832 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
1839 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |