Commit 71a4f809 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Make text in FIJIModalDialog optionally scrollable

Many dynamically created error messages would create windows that
might even be higher than the user's screen. Instead of boundless
growing this patch creates scrollable panes for the dialog's text on default,
which can be disabled via the new '-scrollable' option.
Scrollable dialogs will also be made vertically resizeable while others
remain fixed-sized.

The about dialog of FIJI Setup is  made unscrollable to attain a suitably sized window.
parent ebf6745d
......@@ -27,11 +27,13 @@ sub Populate {
my $image = delete $args->{'-image'};
my $text = delete $args->{'-text'};
my $markuptext = delete $args->{'-markuptext'};
my $scrollable = delete $args->{'-scrollable'};
my $wraplength = delete $args->{'-wraplength'};
$self->SUPER::Populate($args);
my $buttons = $self->buttons();
$scrollable = 1 if !defined($scrollable);
Tk::FIJIUtils::set_icon($self);
......@@ -53,21 +55,40 @@ sub Populate {
$self->add('Label', -image => $image)->pack(-side => 'left') if (defined $image);
my $msg_parent;
if ($scrollable) {
$msg_parent = $self->Scrolled('Pane',
'-scrollbars' => 'oe',
'-sticky' => 'nwse',
);
Tk::FIJIUtils::bind_mousewheel($self, $msg_parent);
$msg_parent->pack(
'-expand' => 1,
'-fill' => 'both',
'-anchor' => 'nw',
'-side' => 'top',
);
$self->resizable(0, 1); # Fix window's width
} else {
$msg_parent = $self;
$self->resizable(0, 0); # Fix window's size
}
if (defined $markuptext) {
# For markup txt we use Tk::Text.
# This allows us to set custom fonts and even add an URL handler
my $t = $self->add('Text',
my $t = $msg_parent->Text(
-wrap => 'word',
# relief = flat would be ideal but there is a bug in Perl::Tk
# on Linux printing that draws a light line left of the widget.
-relief => 'groove',
-borderwidth => 2,
-padx => 15,
-pady => 15
-pady => 15,
)->pack(
-side => 'right',
-fill => 'both',
-expand => 1
-expand => 1,
);
my $tag = "tag000";
foreach ($markuptext) {
......@@ -101,7 +122,7 @@ sub Populate {
}
$t->configure(-state => 'disabled');
} elsif (defined $text) {
my $lbl = $self->add('Label',
my $lbl = $msg_parent->Label(
-text => $text,
-justify => 'left',
)->pack(
......@@ -113,8 +134,6 @@ sub Populate {
} else {
$logger->debug("Neither text nor markuptext given for modal dialog");
}
$self->resizable(0, 0); # Fix window's size
}
......
......@@ -180,6 +180,7 @@ sub show_about {
-buttons => ["~Close"],
-image => $logo_image,
-markuptext => $about_text,
-scrollable => 0,
);
$d->geometry("950x".($logo_image->height()+55)."+0+0");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment