Hi Guys,
I've been a little dissapointed by Wx::StaticText->SetBackgroundColour
on GTK in that it has no effect. So I have written a little sub-class
of Wx::Panel with a child of StaticText, so that the SetBackgroundColour
will work on the Wx::Panel.
Obviously I've then had to catch the other StaticBox methods (like
SetLabel, GetLabel and Wrap), otherwise they will not work.
Here it is if you want to try it out (see below).
Here it is in action:
http://tinypic.com/usermedia.php?uo=adkBqYNLlttZj7Ibq7Bp4Ih4l5k2TGxc#.U8UEuv7tlhE
The light coloured fields are non-enterable and created with static text.
Code follows below.
Any feedback or suggestions welcome.
Regards
Steve.
package i_staticText;
use strict;
use warnings;
#
# Used for resolving GTK backgound issues with Wx::StaticBox
#
use Wx qw[:everything];
use base qw(Wx::Panel);
sub new {
my $self = shift;
my $parent = shift;
my $id = shift;
my $text=shift;
my $pos=shift;
my $size=shift;
$self= $self->SUPER::new($parent, $id, $pos, $size);
$self->SetMinSize($size);
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
$self->SetSizer($sizer);
$self->{label}=Wx::StaticText->new($self, -1, $text, $pos, $size);
$self->SetBackgroundColour(Wx::Colour->new(50, 50, 50));
$sizer->Add($self->{label}, 0, wxLEFT | wxTOP | wxBOTTOM, 3 );
return $self;
}
sub GetForegroundColour{
my $self=shift;
return $self->{label}->GetForegroundColour();
}
sub SetForegroundColour{
my $self=shift;
my $colour=shift;
$self->{label}->SetForegroundColour($colour);
return;
}
sub SetLabel{
my $self=shift;
my $text=shift;
$self->{label}->SetLabel($text);
return;
}
sub SetFont{
# Sets text font.
my $self=shift;
my $font=shift;
$self->{label}->SetFont($font);
return;
}
sub Wrap{
my $self=shift;
my $value=shift;
$value = -1 if not defined $value;
$self->{label}->Wrap($value);
return;
}
sub GetLabel{
my $self=shift;
return $self->{label}->GetLabel();
}
1;