Commits

Herbert Breunung committed 34eeddb

put phasers right that widget ref are stored on time, good widget API has to come

  • Participants
  • Parent commits 0a45a50

Comments (0)

Files changed (4)

lib/Kephra/API.pm

 package Kephra::API;
 
 my %widget = (
-	main_win => $Kephra::App::win,
-	main_window => $Kephra::App::win,
-	doc_bar => $Kephra::App::win->{'tabbar'}{'lo'},
-	document_bar => $Kephra::App::win->{'tabbar'}{'lo'},
+	main_win => => $Kephra::App::Window::_ref,
+	main_window => $Kephra::App::Window::_ref,
+	doc_bar => $Kephra::App::Window::_ref->{'tabbar'}{'lo'},
+	document_bar => $Kephra::App::Window::_ref->{'tabbar'}{'lo'},
 );
 
 
 # gui parts of main window
-sub _app   { $Kephra::App::app }
-sub widget {
+sub _app   { $Kephra::App::_ref }
+sub widget { # widget names are same as in the config
 	my $name = shift;
 	die "requested widget withou name from Kephra::API::widget " unless $name;
 	my $demand = $widget{ $name };

lib/Kephra/App.pm

 
 package Kephra::App;
 our @ISA = 'Wx::App';
-our $app;
-our $win;
+our $_ref;
 
 sub OnInit {
-    $app = shift;
-    my $frame = $win = Kephra::App::Window->new(__PACKAGE__);
+    $_ref = shift;
+    my $win = Kephra::App::Window->new(__PACKAGE__);
 
-    $frame->Center();
-    $frame->Refresh();   # remove visual clutter on start
-    $frame->Show();
+    $win->Center();
+    $win->Refresh();   # remove visual clutter on start
+    $win->Show();
+
     1;
 }
 

lib/Kephra/App/Bar/Menu.pm

 use strict;
 use warnings;
 
-package Kephra::API;
+use Kephra::API;
+
 package Kephra::App::Bar::Menu;
 
 sub get {
     $bar->Append($help_menu, 'Help');
 
     my $win = Kephra::API::widget('main_window');
-
-    Wx::Event::EVT_MENU( $win, 1000, sub { Kephra::API::widget('doc_bar')->add_edit_page() } );
+print "--- $win", keys %$win;
+    #Wx::Event::EVT_MENU( $win, 1000, sub { } );
+    #Wx::Event::EVT_MENU( $win, 1000, sub { Kephra::API::widget('doc_bar')->add_edit_page() } );
 
     return $bar;
 }

lib/Kephra/App/Window.pm

 use strict;
 use warnings;
 use Wx;
+use Kephra::API;
 use Kephra::App::Bar::Menu;
 use Kephra::App::Bar::MainTool;
 use Kephra::App::Bar::Tab;
 
 package Kephra::App::Window;
 our @ISA = 'Wx::Frame';
+our $_ref;
 
 sub new {
     my( $class, $title ) = @_;
-    my( $win ) = $class->SUPER::new ( undef, -1, $title, [-1,-1],[800, 600] );
+    my( $win ) = $_ref = $class->SUPER::new ( undef, -1, $title, [-1,-1],[800, 600] );
     $win->SetIcon( Wx::GetWxPerlIcon() );
-    $win->SetMenuBar( Kephra::App::Bar::Menu::get() );
-    $win->GetMenuBar->SetAcceleratorTable( Wx::AcceleratorTable->new() );
 
     # container var for all panel, sizer and splitter
     my (%panel, %sizer, %splitter);
                                                                or $name eq 'below';
         $panel{ $name }->SetSizer( $sizer{ $name } );
     }
-    my $tabbar_lo   = $win->{'tabbar'}{'lo'} = Kephra::App::Bar::Tab       ->new( $panel{'edit'} );
-    my $searchbar   = $win->{'searchbar'} = Kephra::App::Bar::Search       ->new( $panel{'above'} );
+    my $tabbar_lo   = $win->{'tabbar'}{'lo'}  = Kephra::App::Bar::Tab          ->new( $panel{'edit'} );
+    my $searchbar   = Kephra::App::Bar::Search       ->new( $panel{'above'} );
     my $iounit      = Kephra::App::Panel::IOUnit     ->new( $panel{'below'} );
     my $filebrowser = Kephra::App::Panel::FileBrowser->new( $panel{'left'} );
    #my $projectman  = Kephra::App::Panel::ProjectManarger->new( $panel{'left'} );
     $splitter{'below'}->SetMinimumPaneSize(100);
     $splitter{'edit'}->Initialize( $panel{'edit'} );
 
-    $sizer{'edit'} ->Add( $tabbarright,    1, &Wx::wxGROW );
+    $sizer{'edit'} ->Add( $tabbar_lo,       1, &Wx::wxGROW );
     $sizer{'above'}->Add( $splitter{'edit'},1, &Wx::wxGROW );
     $sizer{'above'}->Add( $searchbar,       0, &Wx::wxGROW );
-    $sizer{'below'}->Add( $iounit,         1, &Wx::wxGROW );
-    $sizer{'right'}->Add( $treelib,       1, &Wx::wxGROW );
-    $sizer{'left'} ->Add( $filebrowser,  1, &Wx::wxGROW );
+    $sizer{'below'}->Add( $iounit,          1, &Wx::wxGROW );
+    $sizer{'right'}->Add( $treelib,         1, &Wx::wxGROW );
+    $sizer{'left'} ->Add( $filebrowser,     1, &Wx::wxGROW );
 
     $sizer{'main'} = Wx::BoxSizer->new( &Wx::wxVERTICAL );
     $sizer{'main'}->Add( $splitter{'left'}, 1, &Wx::wxGROW);
     $sizer{'main'}->Add( $statusbar,        0, &Wx::wxGROW);
     $win->SetSizer( $sizer{'main'} );
+print Kephra::API::widget('main_window'), "\n";
+    $win->SetMenuBar( Kephra::App::Bar::Menu::get() );
+    $win->GetMenuBar->SetAcceleratorTable( Wx::AcceleratorTable->new() );
     
     #Wx::Event::EVT_SPLITTER_DCLICK( ,sub {});
     #&Wx::wxSP_NOBORDER  );