Commits

Herbert Breunung committed d638ede

underlay editor with panel for future messages liek in ff which are less annoying as msgboxes

Comments (0)

Files changed (5)

lib/Kephra/App/Bar/Document.pm

 	});
 	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {
 		my ($nb, $event ) = @_;
-		my $new_ed = $nb->GetPage( $event->GetSelection );
-		Kephra::DocumentStash::set_active_doc( $new_ed );
+		my $new_page = $nb->GetPage( $event->GetSelection );
+		Kephra::DocumentStash::set_active_doc( $new_page );
 		Kephra::API::widget('win')->refresh_title();
-		$new_ed->focus;
+		Wx::Window::SetFocus( $new_page );
 		$event->Skip;
 	});
 	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE( $self, -1, sub {
 	my $pages      = $self->GetPageCount;
 	my $active_pos = $self->GetSelection;
 	# my $active_ed  = $self->GetPage($active_pos);
-	# default tab insertion position is right to active tab
-	$position = 'right'                 if $position == -1;
+	$position = 'right'                 if $position eq 'default' or $position == -1;
 	$position = $pages                  if $position eq 'rightmost';
 	$position = $self->GetSelection + 1 if $position eq 'right';
 	$position = $self->GetSelection     if $position eq 'left';
 	$position = 0                       if $position eq 'leftmost';
 	$set_active = 1       unless defined $set_active;
-	my $ed = defined $panel
-		? $panel
-		: Kephra::App::Editor->new($self);
+	#my $ed = defined $panel
+		#? $panel
+		#: Kephra::App::Editor->new($self);
 
-	$self->InsertPage( $position, $ed, $label, $set_active );
+	$self->InsertPage( $position, $panel, $label, $set_active );
 	$self->set_title( $position, $label);
-	$ed->focus() if $set_active;
+	Wx::Window::SetFocus( $panel ) if $set_active;
 
 	# inserting new index to position translators
 	for   (@{$self->{'visual_panel_order'}}){ $_++ if $_ >= $position }
 	splice @{$self->{'visual_panel_order'}},  $position, 0, $position;
 	$self->refresh_internal_panel_order();
 
-	return $ed;
+	return $panel;
 }
 
 sub remove_page {

lib/Kephra/App/Panel/Editor.pm

 		$main_doc_bar->SetPageText( $main_doc_bar->GetSelection , $doc->file_name );
 	# make new editor
 	} else {
-		my $ed = Kephra::App::Editor->new( $main_doc_bar );
+		my $panel = Wx::Panel->new( $main_doc_bar );
+		my $sizer = Wx::BoxSizer->new( &Wx::wxVERTICAL );
+		my $ed = Kephra::App::Editor->new( $panel );
+		$sizer->Add($ed, 1, &Wx::wxGROW );
+		$panel->SetSizer($sizer);
+
 		$doc = Kephra::Document->new();
 		$doc->editor( $ed );
+		$doc->panel( $panel );
 		$doc->assign_file($file);
 		Kephra::DocumentStash::add( $doc );
-		$main_doc_bar->add_page( $doc->file_name, -1, 1, $ed) ;
+
+		$main_doc_bar->add_page( $doc->file_name, -1, 1, $panel) ;
 	}
 	$doc->editor->focus();
 	Kephra::API::widget('win')->refresh_title();

lib/Kephra/App/Window.pm

 sub refresh_title {
 	my $self = shift;
 	my $doc = Kephra::DocumentStash::active_doc();
-	my $title = defined $doc->file_name
+	my $title = ref $doc
 		? $doc->file_name.' ('.$doc->file_path.')'
 		: Kephra::App::Panel::Editor::active_title();
 	$title .= " - $Kephra::NAME $Kephra::VERSION";

lib/Kephra/Document.pm

 	is  => 'rw',
 	isa => sub {die "$_[0] is no editor" unless ref $_[0] eq 'Kephra::App::Editor'},
 );
+has panel => (
+	is  => 'rw',
+	isa => sub {die "$_[0] is no panel" unless ref $_[0] eq 'Wx::Panel'},
+);
 has file_path    => ( is  => 'rw', );
 has file_dir     => ( is  => 'rw', );
 has file_name    => ( is  => 'rw', );

lib/Kephra/DocumentStash.pm

 sub set_active_doc{
 	my $doc = shift;
 	warn "Kephra::DocumentStash::set_active_doc: need a parameter!" unless $doc;
-	my $new_doc = ref($doc) eq ''                  ? get_by_path($doc)       
-				: $doc->isa('Kephra::App::Editor') ? $document{$doc}         
+	my $new_doc = ref($doc) eq ''                  ? get_by_path($doc)
+				: $doc->isa('Wx::Panel')           ? get_by_panel($doc)
+				: $doc->isa('Kephra::App::Editor') ? $document{$doc}
 				: $doc->isa('Kephra::Document')    ? $document{$doc->editor} 
 				:                                    undef;
 	return unless defined $doc;
 		unless $ed->isa('Kephra::App::Editor');
 	return $document{$ed};
 }
+sub get_by_panel {
+	my $panel = shift;
+	warn "Kephra::DocumentStash::get_by_ed needs a Wx::Panel, not $panel!"
+		unless $panel->isa('Wx::Panel');
+	for my $ed (keys %document) {
+		return $document{$ed} if $document{$ed}->panel eq $panel;
+	}
+}
 sub get_by_path {
 	my $file_path = shift;
 	warn "Kephra::DocumentStash::get_by_path needs a file path as input!"