panel size and xrc

RAPPAZ Francois <[email protected]> Thu, 28 May 2015 13:19:16 +0000
Newsgroups gmane.comp.lang.perl.wxperl
Message-ID <[email protected]>
Hi there,

I'm using two xrc files with the perl code (below), to
 - load an application main panel (nav_test.xrc) with a row of buttons at the bottom
 - load a second file that defines the content (content_test.xrc): fields, combo and so one
- set the size of the application main windows

My problem is that the content is squeezed in the upper left corner, instead of being spread in the whole area. See the red arrows here http://homeweb3.unifr.ch/rappazf/Pub/slides/resize.gif
The whole test can be found here http://homeweb3.unifr.ch/rappazf/Pub/test_xrc.zip
Or below

Thanks

François

Testxrc.pl:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
use strict;
use warnings;

package Dnav;

use Wx qw[:everything];
use Wx::XRC;
use Carp qw( carp croak ); 

sub new {
 	my( $class, $href) = @_;
	my $self->{xrc} = Wx::XmlResource->new();
	$self->{xrc}->InitAllHandlers();
    	$self->{xrc}->Load("nav_test.xrc") or die("Can't load dnav_test.xrc");
	$self->{frame} = $self->{xrc}->LoadFrame(undef, 'mainwindow');
      	bless $self, $class;
}

sub load_panel {
	 my ($self, $path) = @_;
	 my $xrc =  Wx::XmlResource->new;
         my $where_name= "m_panel_for_content";  
	 my $top_name ="m_panel1";
	 my $where = Wx::Window::FindWindowByLabel($where_name, $self->{frame});
	 croak("Can't locate $where_name in mainwindow") unless($where);
	$xrc->InitAllHandlers();
	$xrc->Load($path) or die("Can't load xrc file from $path");
	my $p = $xrc->LoadPanel($where, $top_name );
	croak ("Can't load $top_name into $where_name") unless($p);
}

package Forms;
use base qw(Wx::App);
#use Dnav;
use Wx::XRC;
use Wx qw( :everything);

sub new {
	my ( $class, $href ) = @_;
	my $self = $class->SUPER::new();
 	my $nav = Dnav->new();
  	$nav->load_panel("content_test.xrc");
   	my $frame = $nav->{frame};
   	$frame->SetSize([800,800]); 
   	$frame->Show;     
   	$self->SetTopWindow($frame);
	return $self;
}

sub OnInit {
1;
}

package main;


my $app =  Forms->new();
$app->MainLoop;

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
nav_test.xrc
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
	<object class="wxFrame" name="mainwindow">
		<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
		<title></title>
		<centered>1</centered>
		<aui_managed>0</aui_managed>
		<object class="wxBoxSizer">
			<orient>wxVERTICAL</orient>
			<object class="sizeritem">
				<option>1</option>
				<flag>wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL</flag>
				<border>5</border>
				<object class="wxPanel" name="m_panel_for_content">
					<style>wxTAB_TRAVERSAL</style>
				</object>
			</object>
			<object class="sizeritem">
				<option>0</option>
				<flag>wxALL|wxALIGN_CENTER_HORIZONTAL</flag>
				<border>5</border>
				<object class="wxPanel" name="m_panel_for_buttons">
					<style>wxTAB_TRAVERSAL</style>
					<object class="wxBoxSizer">
						<orient>wxHORIZONTAL</orient>
						<object class="sizeritem">
							<option>0</option>
							<flag>wxALL</flag>
							<border>5</border>
							<object class="wxButton" name="m_button1">
								<label>MyButton</label>
								<default>0</default>
							</object>
						</object>
						<object class="sizeritem">
							<option>0</option>
							<flag>wxALL</flag>
							<border>5</border>
							<object class="wxButton" name="m_button2">
								<label>MyButton</label>
								<default>0</default>
							</object>
						</object>
						<object class="sizeritem">
							<option>0</option>
							<flag>wxALL</flag>
							<border>5</border>
							<object class="wxButton" name="m_button3">
								<label>MyButton</label>
								<default>0</default>
							</object>
						</object>
						<object class="sizeritem">
							<option>0</option>
							<flag>wxALL</flag>
							<border>5</border>
							<object class="wxButton" name="m_button4">
								<label>MyButton</label>
								<default>0</default>
							</object>
						</object>
					</object>
				</object>
			</object>
		</object>
		<object class="wxMenuBar" name="m_menubar1">
			<label>MyMenuBar</label>
			<object class="wxMenu" name="m_menu1">
				<label>MyMenu</label>
			</object>
			<object class="wxMenu" name="m_menu2">
				<label>MyMenu</label>
			</object>
		</object>
	</object>
</resource>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

content_test.xrc
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
	<object class="wxPanel" name="m_panel1">
		<style>wxTAB_TRAVERSAL</style>
		<object class="wxBoxSizer">
			<orient>wxVERTICAL</orient>
			<object class="sizeritem">
				<option>0</option>
				<flag></flag>
				<border>5</border>
				<object class="wxBoxSizer">
					<orient>wxHORIZONTAL</orient>
					<object class="spacer">
						<option>0</option>
						<flag>wxEXPAND</flag>
						<border>5</border>
						<size>1,0</size>
					</object>
					<object class="sizeritem">
						<option>0</option>
						<flag></flag>
						<border>5</border>
						<object class="wxBoxSizer">
							<orient>wxHORIZONTAL</orient>
							<object class="sizeritem">
								<option>0</option>
								<flag>wxALL|wxEXPAND</flag>
								<border>5</border>
								<object class="wxStaticText" name="m_staticText1">
									<label>Id commande</label>
									<wrap>-1</wrap>
								</object>
							</object>
							<object class="sizeritem">
								<option>1</option>
								<flag>wxALL</flag>
								<border>5</border>
								<object class="wxTextCtrl" name="idref">
									<value></value>
									<maxlength>0</maxlength>
								</object>
							</object>
							<object class="sizeritem">
								<option>0</option>
								<flag>wxALL</flag>
								<border>5</border>
								<object class="wxStaticText" name="m_staticText2">
									<label>Email</label>
									<wrap>-1</wrap>
								</object>
							</object>
							<object class="sizeritem">
								<option>1</option>
								<flag>wxALL</flag>
								<border>5</border>
								<object class="wxTextCtrl" name="email">
									<value></value>
									<maxlength>0</maxlength>
								</object>
							</object>
							<object class="sizeritem">
								<option>0</option>
								<flag>wxALL</flag>
								<border>5</border>
								<object class="wxStaticText" name="m_staticText4">
									<label>Credit</label>
									<wrap>-1</wrap>
								</object>
							</object>
						</object>
					</object>
					<object class="sizeritem">
						<option>1</option>
						<flag>wxEXPAND</flag>
						<border>5</border>
						<object class="wxBoxSizer">
							<orient>wxVERTICAL</orient>
							<object class="sizeritem">
								<option>0</option>
								<flag>wxALL</flag>
								<border>5</border>
								<object class="wxComboBox" name="id_credit">
									<value>Combo!</value>
									<content />
								</object>
							</object>
						</object>
					</object>
				</object>
			</object>
			<object class="sizeritem">
				<option>0</option>
				<flag>wxEXPAND</flag>
				<border>5</border>
				<object class="wxBoxSizer">
					<orient>wxHORIZONTAL</orient>
					<object class="sizeritem">
						<option>0</option>
						<flag>wxALL</flag>
						<border>5</border>
						<object class="wxStaticText" name="m_staticText41">
							<label>Doi:</label>
							<wrap>-1</wrap>
						</object>
					</object>
					<object class="spacer">
						<option>0</option>
						<flag>wxEXPAND</flag>
						<border>5</border>
						<size>50,0</size>
					</object>
					<object class="sizeritem">
						<option>1</option>
						<flag>wxALL|wxEXPAND</flag>
						<border>5</border>
						<object class="wxTextCtrl" name="doi">
							<style>wxTE_MULTILINE|wxTE_PROCESS_ENTER</style>
							<value></value>
							<maxlength>0</maxlength>
						</object>
					</object>
				</object>
			</object>
			<object class="sizeritem">
				<option>1</option>
				<flag>wxEXPAND</flag>
				<border>5</border>
				<object class="wxStaticBoxSizer">
					<orient>wxVERTICAL</orient>
					<label>Reference de l&apos;article</label>
					<object class="sizeritem">
						<option>1</option>
						<flag>wxEXPAND|wxALL</flag>
						<border>5</border>
						<object class="wxScrolledWindow" name="m_scrolledWindow2">
							<style>wxHSCROLL|wxVSCROLL</style>
							<scrollrate>5,5</scrollrate>
							<object class="wxBoxSizer">
								<orient>wxHORIZONTAL</orient>
								<object class="sizeritem">
									<option>0</option>
									<flag>wxALL</flag>
									<border>5</border>
									<object class="wxStaticText" name="m_staticText7">
										<label>Ref:</label>
										<wrap>-1</wrap>
									</object>
								</object>
								<object class="sizeritem">
									<option>1</option>
									<flag>wxALL|wxEXPAND</flag>
									<border>5</border>
									<object class="wxTextCtrl" name="ref">
										<style>wxTE_MULTILINE</style>
										<value></value>
										<maxlength>0</maxlength>
									</object>
								</object>
							</object>
						</object>
					</object>
				</object>
			</object>
		</object>
	</object>
</resource>