1. Herbert Breunung
  2. Kephra

Commits

Herbert Breunung  committed b74e4bf

got event and splitter finally right

  • Participants
  • Parent commits 9acec37
  • Branches default

Comments (0)

Files changed (6)

File lib/Kephra.pm

View file
 
 package Kephra;
 our $NAME     = __PACKAGE__;    # name of entire application
-our $VERSION  = '0.5.0.001';
+our $VERSION  = '0.5.0.002';
 
 sub start {
     #start_worker_thread();

File lib/Kephra/App.pm

View file
 use strict;
 use warnings;
-require Wx;
+use Wx;
+use Kephra::App::Window;
 
 package Kephra::App;
 our @ISA = 'Wx::App';
 
 sub OnInit {
     my $app = shift;
-    require Kephra::App::Window;
-    my $frame = Kephra::App::Window->new(__PACKAGE__);
+    my $frame = $app->{'win'} = Kephra::App::Window->new(__PACKAGE__);
 
     $frame->Center();
     $frame->Show();
 }
 
 sub OnExit {
+    my $app = shift;
     1;
 }
 

File lib/Kephra/App/EditPanel.pm

View file
 use strict;
 use warnings;
-require Wx;
-#require Wx::STC;
-require Wx::Scintilla;
+use Wx;
+#use Wx::STC;
+use Wx::Scintilla;
 
 package Kephra::App::EditPanel;
 #our @ISA = 'Wx::StyledTextCtrl';
     $ep->SetAcceleratorTable(
         Wx::AcceleratorTable->new(
             [&Wx::wxACCEL_CTRL, ord 'b', &Wx::wxID_CLOSE],
-            [&Wx::wxACCEL_NORMAL, ord 'w', &Wx::wxID_CLOSE],
-            [&Wx::wxACCEL_CTRL|&Wx::wxACCEL_ALT, ord 'b', &Wx::wxID_CLOSE],
-            [&Wx::wxACCEL_CTRL|&Wx::wxACCEL_ALT, &Wx::WXK_RIGHT, &Wx::wxID_CLOSE],
+            [&Wx::wxACCEL_NORMAL, &Wx::WXK_NUMPAD_ENTER, &Wx::wxID_CLOSE],
+            #[&Wx::wxACCEL_CTRL|&Wx::wxACCEL_ALT, ord 'b', &Wx::wxID_CLOSE],
+            #[&Wx::wxACCEL_CTRL|&Wx::wxACCEL_ALT, &Wx::WXK_RIGHT, &Wx::wxID_CLOSE],
     ));
     #$ep->SetAcceleratorTable( Wx::AcceleratorTable->new() );
-    Wx::Event::EVT_MENU( $ep, 1000, sub { $ep->AddText('1') } );
-    Wx::Event::EVT_MENU( $ep, &Wx::wxID_CLOSE, sub { $ep->AddText('-') } );
-    Wx::Event::EVT_KEY_DOWN ($ep, sub {
-        my ($ep, $event) = @_;
-        my $key = $event->GetKeyCode;
-        if ($key == 66 and $event->ControlDown  and $event->AltDown ){ $ep->AddText('+') }
-        elsif ($key == &Wx::WXK_LEFT and $event->ControlDown ){ $ep->AddText('L') }
-        else {
-            $event->Skip;
-        }
-    } );
+    #Wx::Event::EVT_MENU( $ep, 1000, sub { $ep->AddText('1'); $_[1]->Skip; } );
+    #Wx::Event::EVT_MENU( $ep, &Wx::wxID_CLOSE, sub { $ep->AddText('-') } );
+        #Wx::Event::EVT_KEY_DOWN ($ep, sub {
+            #my ($ep, $event) = @_;
+            #my $key = $event->GetKeyCode;
+            #if ($key == 66 and $event->ControlDown  and $event->AltDown ){ $ep->AddText('+') }
+            #elsif ($key == &Wx::WXK_LEFT and $event->ControlDown ){ $ep->AddText('L') }
+            #else {
+                #$event->Skip;
+            #}
+        #} );
     #Wx::Event::EVT_STC_SAVEPOINTREACHED($ep, -1, \&Kephra::File::savepoint_reached);
     #Wx::Event::EVT_STC_SAVEPOINTLEFT($ep, -1, \&Kephra::File::savepoint_left);
     #Wx::Event::EVT_STC_CHANGE       ($ep, -1, sub {&$trigger('document.text.change')} );

File lib/Kephra/App/Menu.pm

View file
 sub main_bar {
     my $bar = Wx::MenuBar->new();
     my $file_menu = Wx::Menu->new();
-    $file_menu->Append( 1000, "New\tCtrl+N");
-    $file_menu->Append( 1001, 'Open');
-    $file_menu->Append( 1002, 'Save');
-    $file_menu->Append( 1003, 'Close');
+    my $mi = $file_menu->Append( 1000, "New      Ctrl + N");
+    #$mi->SetText("New\tCtrl+N");
+    $file_menu->Append( 1001, "Open    Ctrl + O");
+    $file_menu->Append( 1002, "Save      Ctrl + S");
+    $file_menu->Append( 1003, "Close    Ctrl + Q");
     $file_menu->AppendSeparator();
     $file_menu->Append( 1010, 'Exit');
     $bar->Append($file_menu, 'File');

File lib/Kephra/App/TabBar.pm

View file
 use strict;
 use warnings;
-require Wx;
+use Wx;
+use Kephra::App::EditPanel;
+use Kephra::App::Helper;
 
 package Kephra::App::TabBar;
 our @ISA = 'Wx::AuiNotebook';
 
-require Kephra::App::Helper;
 my $put_on_panel = Kephra::App::Helper::get('put_on_panel');
 
-
 sub new {
     my( $class, $parent) = @_;
     my $tb = $class->SUPER::new( $parent, -1, [-1,-1], [-1,-1],
 
 sub add_edit_page {
     my ($tb, $pos, $active) = @_;
-    require Kephra::App::EditPanel;
-    my $ep = Kephra::App::EditPanel->new($tb);
-    $tb->InsertPage( $pos, $put_on_panel->($ep), '<untitled>', $active );
+
+    $pos = $tb->GetPageCount unless defined $pos;
+    $active = 1              unless defined $active;
+
+    my $panel = Wx::Panel->new( $tb );
+    my $ep = Kephra::App::EditPanel->new($panel);
+    my $sizer = Wx::BoxSizer->new( &Wx::wxVERTICAL );
+    $sizer->Add( $ep, 1, &Wx::wxGROW );
+    $panel->SetSizer( $sizer );
+
+    $tb->InsertPage( $pos, $panel, '<untitled>', $active );
     $ep->set_focus() if $active;
     $tb;
 }

File lib/Kephra/App/Window.pm

View file
 sub new {
     my( $class, $title ) = @_;
     my( $win ) = $class->SUPER::new ( undef, -1, $title, [-1,-1],[800, 600] );
+    $win->SetIcon( Wx::GetWxPerlIcon() );
     $win->SetMenuBar( Kephra::App::Menu::main_bar() );
     $win->SetAcceleratorTable( Wx::AcceleratorTable->new() );
 
     my $panel = Wx::Panel->new( $win );
 
-
-
     my %sizer;
     $sizer{'panel'} = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
     $sizer{'main'} = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
 
     #my $fb = Kephra::App::Panel::FileBrowser->new($panel);
 
-    my $nb = Kephra::App::TabBar->new($panel);
-
-    #my $tl = Kephra::App::Panel::TreeLib->new($panel);
-
-
-    #my %spliter;
+    my %spliter;
     #$spliter{'left'} = Wx::SplitterWindow->new( $panel, -1 );
     #$spliter{'left'}->Initialize( $nb );
     #$spliter{'left'}->SplitVertically( $fb, $nb, 200);
     #$fb->Reparent( $spliter{'left'} );
     #$nb->Reparent( $spliter{'left'} );
+    $spliter{'middle'} = Wx::SplitterWindow->new( $panel, -1,[-1,-1],[-1,-1],&Wx::wxSP_NOBORDER  );
+    my $nbl = Kephra::App::TabBar->new($spliter{'middle'});
+    my $nbr = Kephra::App::TabBar->new($spliter{'middle'});
+    $spliter{'middle'}->SplitVertically( $nbl, $nbr, 0);
+    $spliter{'middle'}->SetSashGravity(0.5);
+
+    Wx::Event::EVT_MENU( $win, 1000, sub { $nbl->add_edit_page() } );
+    #Wx::Event::EVT_MENU( $nbl, &Wx::wxID_CLOSE, sub { $nbl->add_edit_page() } );
+    #Wx::Event::EVT_KEY_DOWN ($win, sub {
+        #my ($win, $event) = @_;
+        #my $key = $event->GetKeyCode +
+            #1000 * ($event->ShiftDown + $event->ControlDown*2 + $event->AltDown*4);
+#print "$key\n";
+        #if ($key == 2078){ $nb->add_edit_page() }
+        #else { 
+            #$event->Skip;
+        #}
+    #} );
+    #my $tl = Kephra::App::Panel::TreeLib->new($panel);    
     
-    
-    $sizer{'centercolumn'}->Add( $nb, 1, &Wx::wxGROW);
+    $sizer{'centercolumn'}->Add( $spliter{'middle'}, 1, &Wx::wxGROW);
     #$sizer{'rightcolumn'}->Add( $tl, 1, &Wx::wxGROW);