Commits

Herbert Breunung committed 2fefb3e

alkey camo and x bottom call both same exit routine

Comments (0)

Files changed (3)

lib/Kephra/API.pm

 use Kephra::App::Panel::Editor;
 
 my %widget_caller = (
-	main_win     => sub { $Kephra::App::Window::_ref },
+	win          => sub { $Kephra::App::Window::_ref },
 	main_window  => sub { $Kephra::App::Window::_ref },
 	doc_bar      => sub { Kephra::App::Panel::Editor::_active_docbar() },
 	document_bar => sub { Kephra::App::Panel::Editor::_active_docbar() },

lib/Kephra/App.pm

 our $_ref;
 
 sub OnInit {
-    $_ref = shift;
-    my $win = Kephra::App::Window->new(__PACKAGE__);
+	$_ref = shift;
+	my $win = Kephra::App::Window->new(__PACKAGE__);
 
-    Kephra::File::new();
+	Kephra::File::new();
 
-    $win->Center();
-    $win->Refresh();   # remove visual clutter on start
-    $win->Show();
+	$win->Center();
+	$win->Refresh();   # remove visual clutter on start
+	$win->Show();
 
-    1;
+	1;
 }
 
 sub exit {
-    Kephra::Window::close();
+	Wx::wxTheClipboard->Flush;
+	my $win = Kephra::API::widget('win');
+	$win->destroy();
 }
 
 sub OnExit {
-    my $app = shift;
-    1;
+	my $app = shift;
+	1;
 }
 
 # $app->ExitMainLoop(1);

lib/Kephra/App/Window.pm

 
 sub new {
     my( $class, $title ) = @_;
-    my( $win ) = $_ref = $class->SUPER::new ( undef, -1, $title, [-1,-1],[800, 600] );
-    $win->SetIcon( Wx::GetWxPerlIcon() );
+    my( $self ) = $_ref = $class->SUPER::new ( undef, -1, $title, [-1,-1],[800, 600] );
+    $self->SetIcon( Wx::GetWxPerlIcon() );
 
     # container var for all panel, sizer and splitter
     my (%panel, %sizer, %splitter);
-    $splitter{'left'}  = Wx::SplitterWindow->new( $win,              -1 );
+    $splitter{'left'}  = Wx::SplitterWindow->new( $self,              -1 );
     $splitter{'right'} = Wx::SplitterWindow->new( $splitter{'left'}, -1 );
     $splitter{'below'} = Wx::SplitterWindow->new( $splitter{'right'},-1 );
     $panel   {'above'} = Wx::Panel         ->new( $splitter{'below'});
     my $treelib     = Kephra::App::Panel::TreeLib    ->new( $panel{'right'} );
    #my $orgpad      = Kephra::App::Panel::OrgPad     ->new( $panel{'right'} );
     #my $scratchsheet= Kephra::App::Panel::ScratchSheet->new( $panel{'right'} );
-    my $statusbar   = Kephra::App::Bar::Status       ->new( $win );
+    my $statusbar   = Kephra::App::Bar::Status       ->new( $self );
 
     $splitter{'left'}->SplitVertically( $panel{'left'}, $splitter{'right'}, 200);
     $splitter{'left'}->SetSashGravity(0);
     $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'} );
+    $self->SetSizer( $sizer{'main'} );
 
-    $win->SetMenuBar( Kephra::App::Bar::Menu::get() );
-    $win->GetMenuBar->SetAcceleratorTable( Wx::AcceleratorTable->new() );
+    $self->SetMenuBar( Kephra::App::Bar::Menu::get() );
+    $self->GetMenuBar->SetAcceleratorTable( Wx::AcceleratorTable->new() );
     
-    #Wx::Event::EVT_SPLITTER_DCLICK( ,sub {});
-    #&Wx::wxSP_NOBORDER  );
-    #Wx::Event::EVT_CLOSE($frame, sub{$frame->Close; $_[1]->Skip });
+    
+    #Wx::Event::EVT_SPLITTER_DCLICK( ,sub {});  #&Wx::wxSP_NOBORDER  );
+    Wx::Event::EVT_CLOSE( $self, sub{ Kephra::App::exit(); });
 
-    return $win;
+    return $self;
 }
 
-sub close { $_ref->Close() }
+sub close   { $_ref->Close() }
+sub destroy { $_ref->Destroy() }
 
 1;