use Wx; use Wx::XRC; package MyPanel; use base 'Wx::Panel'; sub new { my $class = shift; my $self = $class->SUPER::new(); $self->OnInit(@_); return $self; } sub OnInit { my $self = shift; my $parent = shift; my $xrc = shift; $xrc->LoadPanel($parent, 'panel_1'); return $self; } ################################################# # # package MyApp; # # ################################################# use strict; use vars qw(@ISA); @ISA = qw(Wx::App); sub OnInit { my($this) = @_; my($frame) = MyFrame->new( undef, -1, "Test"); $frame->SetSize(Wx::Size->new(640, 480)); $frame->CenterOnScreen; $frame->Show(1); $frame->SetIcon( Wx::GetWxPerlIcon() ); $this->SetTopWindow($frame); return 1; } ################################################# # # package MyFrame; # # ################################################# use strict; use vars qw(@ISA); use Wx::Html; @ISA = qw(Wx::Frame); use Wx qw(:everything); use Wx::Event qw(:everything); sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( @_ ); # Splitter $this->{main_splitter} = Wx::SplitterWindow->new($this, -1, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER ); # Minimum size for the framework of the html list box $this->{main_splitter}->SetMinimumPaneSize(175); $this->{listbox_pane} = Wx::Panel->new($this->{main_splitter}, -1, wxDefaultPosition, wxDefaultSize, ); $this->{html_list} = Wx::SimpleHtmlListBox->new($this->{listbox_pane}, -1, wxDefaultPosition, wxDefaultSize, [], wxSIMPLE_BORDER ); $this->{html_list}->SetBackgroundColour(Wx::Colour->new(255,255,255)); $this->{html_list}->Append( 'Notebook_1' ); $this->{html_list}->Append( 'Notebook_2' ); EVT_LISTBOX( $this, $this->{html_list}, \&OnModuleClick ); $this->{notebook_pane} = Wx::Panel->new($this->{main_splitter}, -1, wxDefaultPosition, wxDefaultSize, ); $this->__do_layout(); return $this; } sub __do_layout { my $self = shift; $self->{main_sizer} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{notebook_sizer} = Wx::GridSizer->new(1, 1, 0, 0); $self->{listbox_sizer}= Wx::FlexGridSizer->new(1, 1, 10, 10); $self->{listbox_sizer}->Add($self->{html_list}, 0, wxEXPAND, 0); $self->{listbox_pane}->SetSizer($self->{listbox_sizer}); $self->{listbox_sizer}->AddGrowableRow(0); $self->{listbox_sizer}->AddGrowableCol(0); $self->{notebook_pane}->SetSizer($self->{notebook_sizer}); $self->{main_splitter}->SplitVertically($self->{listbox_pane}, $self->{notebook_pane}, 200 ); $self->{main_sizer}->Add($self->{main_splitter}, 1, wxEXPAND, 0); $self->SetSizer($self->{main_sizer}); $self->{main_sizer}->Fit($self); $self->Layout(); } sub OnModuleClick { my( $self, $event ) = @_; my $cursor=Wx::BusyCursor->new(); if ( $self->{html_list}->GetString( $event->GetInt ) eq 'Notebook_1') { $self->{xrc} = Wx::XmlResource->new(); $self->{xrc}->InitAllHandlers(); $self->{xrc}->Load('notebook1.xrc'); $self->{panel} = MyPanel->new($self->{notebook_pane}, $self->{xrc}); } else { $self->{xrc} = Wx::XmlResource->new(); $self->{xrc}->InitAllHandlers(); $self->{xrc}->Load('notebook2.xrc'); $self->{panel} = MyPanel->new($self->{notebook_pane}, $self->{xrc}); } undef $cursor; } package main; my($app) = MyApp->new(); $app->MainLoop();