… | |
… | |
587 | } |
587 | } |
588 | |
588 | |
589 | sub DESTROY { |
589 | sub DESTROY { |
590 | my ($self) = @_; |
590 | my ($self) = @_; |
591 | |
591 | |
|
|
592 | return if CFClient::in_destruct; |
|
|
593 | |
592 | delete $WIDGET{$self+0}; |
594 | delete $WIDGET{$self+0}; |
593 | |
595 | |
594 | eval { $self->destroy }; |
596 | eval { $self->destroy }; |
595 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
597 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
596 | } |
598 | } |
… | |
… | |
1080 | my $self = $class->SUPER::new ( |
1082 | my $self = $class->SUPER::new ( |
1081 | bg => [1, 1, 1, 1], |
1083 | bg => [1, 1, 1, 1], |
1082 | border_bg => [1, 1, 1, 1], |
1084 | border_bg => [1, 1, 1, 1], |
1083 | border => 0.6, |
1085 | border => 0.6, |
1084 | can_events => 1, |
1086 | can_events => 1, |
1085 | min_w => 16, |
1087 | min_w => 64, |
1086 | min_h => 16, |
1088 | min_h => 32, |
1087 | %arg, |
1089 | %arg, |
1088 | ); |
1090 | ); |
1089 | |
1091 | |
1090 | $self->{title_widget} = new CFClient::UI::Label |
1092 | $self->{title_widget} = new CFClient::UI::Label |
1091 | align => 0, |
1093 | align => 0, |
… | |
… | |
1826 | |
1828 | |
1827 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1829 | my $idx = $self->{layout}->xy_to_index ($x, $y); |
1828 | |
1830 | |
1829 | # byte-index to char-index |
1831 | # byte-index to char-index |
1830 | my $text = $self->{text}; |
1832 | my $text = $self->{text}; |
1831 | utf8::encode $text; |
1833 | utf8::encode $text; $text = substr $text, 0, $idx; utf8::decode $text; |
1832 | $self->{cursor} = length substr $text, 0, $idx; |
1834 | $self->{cursor} = length $text; |
1833 | |
1835 | |
1834 | $self->_set_text ($self->{text}); |
1836 | $self->_set_text ($self->{text}); |
1835 | $self->update; |
1837 | $self->update; |
1836 | |
1838 | |
1837 | 1 |
1839 | 1 |
… | |
… | |
3814 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
3816 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
3815 | |
3817 | |
3816 | $w = 0 if $w < 0; |
3818 | $w = 0 if $w < 0; |
3817 | $h = 0 if $h < 0; |
3819 | $h = 0 if $h < 0; |
3818 | |
3820 | |
|
|
3821 | $w = max $widget->{min_w}, $w; |
|
|
3822 | $h = max $widget->{min_h}, $h; |
|
|
3823 | |
|
|
3824 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
|
|
3825 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
|
|
3826 | |
3819 | $w = int $w + 0.5; |
3827 | $w = int $w + 0.5; |
3820 | $h = int $h + 0.5; |
3828 | $h = int $h + 0.5; |
3821 | |
3829 | |
3822 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
3830 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
3823 | $widget->{old_w} = $widget->{w}; |
3831 | $widget->{old_w} = $widget->{w}; |