Align controls and their associated labels vertically centered.

This commit is contained in:
Henrik Brix Andersen 2012-08-02 23:44:42 +02:00
parent 5518ac9fa6
commit b1805ed7f3

View file

@ -76,7 +76,7 @@ sub BUILD {
if (!$self->no_labels) {
$label = Wx::StaticText->new($self->parent, -1, "$opt->{label}:", wxDefaultPosition, [$self->label_width, -1]);
$label->Wrap($self->label_width) ; # needed to avoid Linux/GTK bug
$grid_sizer->Add($label);
$grid_sizer->Add($label, 0, wxALIGN_CENTER_VERTICAL, 0);
}
my $field;
@ -109,7 +109,7 @@ sub BUILD {
Wx::StaticText->new($self->parent, -1, " y:"),
my $y_field = Wx::TextCtrl->new($self->parent, -1, $opt->{default}->[1], wxDefaultPosition, $field_size),
);
$field->Add($_) for @items;
$field->Add($_, 0, wxALIGN_CENTER_VERTICAL, 0) for @items;
if ($opt->{tooltip}) {
$_->SetToolTipString($opt->{tooltip}) for @items;
}
@ -135,13 +135,13 @@ sub BUILD {
$field->SetToolTipString($opt->{tooltip}) if $opt->{tooltip} && $field->can('SetToolTipString');
if ($opt->{sidetext}) {
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$sizer->Add($field);
$sizer->Add($field, 0, wxALIGN_CENTER_VERTICAL, 0);
my $sidetext = Wx::StaticText->new($self->parent, -1, $opt->{sidetext}, wxDefaultPosition, wxDefaultSize);
$sidetext->SetFont($sidetext_font);
$sizer->Add($sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL , 4);
$grid_sizer->Add($sizer);
} else {
$grid_sizer->Add($field, 0, $opt->{full_width} ? wxEXPAND : 0);
$grid_sizer->Add($field, 0, ($opt->{full_width} ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
}
}