From: Liney, D. <Dav...@co...> - 2002-08-29 18:15:30
|
I am using FlexGridSizer to layout a window and am having problems getting a Panel to display when added to the Sizer with the Panel or its row set not to grow. If I set it to grow then it displays. Also when I remove the Panel and have the StaticTexts as children of $this then the content displays. I want the Panel to be only as high as it needs to be to display its content (message headers) leaving the rest of the window for the message text. Which is why I don't want to set wxGROW or AddGrowableRow(). I am using a Panel so I can set the background and a border around a collection of StaticTexts. The testcase below shows the problem. If I remove the wxGROW from line 48 or comment out line 52 the the Panel doesn't display. Can someone tell me what I am doing wrong as I have tried everything I can think of without success? I am using WxPerl 0.11 with ActivePerl Build 629. Thanks, Dave Liney. ------------------------------------------------------------ #!/usr/bin/perl -w use strict; use Wx; ##### PanelSizer::Frame ##### package PanelSizer::Frame; use base qw(Wx::Frame); use Wx qw(:everything); sub new { my $class = shift; my $this = $class->SUPER::new( undef, -1, "PanelSizer", wxDefaultPosition, [ 400, 300 ]); my $headpanel = Wx::Panel->new( $this, -1, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER); $headpanel->SetBackgroundColour(wxLIGHT_GREY); my $headsizer = Wx::FlexGridSizer->new(2, 2, 0, 10); $headsizer->Add( Wx::StaticText->new($headpanel, -1, "Message ID:"), 1, wxLEFT, 2); $headsizer->Add( Wx::StaticText->new($headpanel, -1, "669948"), 1); $headsizer->Add( Wx::StaticText->new($headpanel, -1, "Date:"), 1, wxLEFT, 2); $headsizer->Add( Wx::StaticText->new($headpanel, -1, "28th August 2002"), 1); $headsizer->AddGrowableCol(1); $headpanel->SetSizer($headsizer); $headpanel->SetAutoLayout(1); my $textsizer = Wx::FlexGridSizer->new(2, 1, 0, 0); my $message = Wx::StaticText->new($this, -1, "Message text.\nMessage text.\nMessage text.\nMessage text.", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxSP_NOBORDER); $message->SetBackgroundColour(wxWHITE); $textsizer->Add($headpanel, 1, wxGROW); # Line 48 $textsizer->Add($message, 1, wxGROW); $textsizer->AddGrowableCol(0); $textsizer->AddGrowableRow(0); # Line 52 $textsizer->AddGrowableRow(1); $this->SetSizer($textsizer); $this->SetAutoLayout(1); return $this; } ##### PanelSizer::App ##### package PanelSizer::App; use base qw(Wx::App); sub OnInit { PanelSizer::Frame->new->Show(1); } ##### main ##### package main; PanelSizer::App->new->MainLoop(); |