Source

Kephra / lib / Kephra / App / Window.pm

use strict;
use warnings;
use Wx;
use Kephra::App::Menu;
use Kephra::App::TabBar;
use Kephra::App::Panel::FileBrowser;
use Kephra::App::Panel::Input;
use Kephra::App::Panel::Output;
use Kephra::App::Panel::TreeLib;
use Kephra::App::Panel::Notepad;

package Kephra::App::Window;
our @ISA = 'Wx::Frame';

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->GetMenuBar->SetAcceleratorTable( Wx::AcceleratorTable->new() );

    # some pabel and sizers 
    my (%panel, %sizer, %splitter);
    $panel{'main'}    = Wx::Panel->new( $win );
    $splitter{'left'}  = Wx::SplitterWindow->new( $panel{'main'}, -1 );
    $splitter{'right'} = Wx::SplitterWindow->new( $splitter{'left'}, -1 );
    $splitter{'below'} = Wx::SplitterWindow->new( $splitter{'right'}, -1 );
    $splitter{'edit'}  = Wx::SplitterWindow->new( $splitter{'below'}, -1 );

    for my $name (qw /main left right edit below/) {
        $panel{ $name } = Wx::Panel->new( $splitter{ $name } ) unless $name eq 'main';
        $sizer{ $name } = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
        $sizer{ $name } = Wx::BoxSizer->new( &Wx::wxVERTICAL ) if $name eq 'below';
        $panel{ $name }->SetSizer( $sizer{ $name } );
    }

    my $nbl = Kephra::App::TabBar->new( $panel{'edit'} );
    $sizer{'edit'}->Add( $nbl, 1, &Wx::wxGROW );
    my $fb = Kephra::App::Panel::FileBrowser->new( $panel{'left'} );
    $sizer{'left'}->Add( $fb, 1, &Wx::wxGROW );
    my $tl = Kephra::App::Panel::TreeLib->new( $panel{'right'} );
    $sizer{'right'}->Add( $tl, 1, &Wx::wxGROW );
    my $op = Kephra::App::Panel::Output->new( $panel{'below'} );
    $sizer{'below'}->Add( $op, 1, &Wx::wxGROW );

    $splitter{'left'}->SplitVertically( $panel{'left'}, $splitter{'right'}, 200);
    $splitter{'left'}->SetSashGravity(0);
    $splitter{'left'}->SetSashPosition(200);
    $splitter{'left'}->SetMinimumPaneSize(140);
    $splitter{'right'}->SplitVertically( $splitter{'below'}, $panel{'right'}, -200);
    $splitter{'right'}->SetSashGravity(1);
    $splitter{'right'}->SetSashPosition(-200);
    $splitter{'right'}->SetMinimumPaneSize(140);
    $splitter{'below'}->SplitHorizontally( $splitter{'edit'}, $panel{'below'}, -200);
    $splitter{'below'}->SetSashGravity(1);
    $splitter{'below'}->SetSashPosition(-200);
    $splitter{'below'}->SetMinimumPaneSize(100);
    $splitter{'edit'}->Initialize( $panel{'edit'} );

    #Wx::Event::EVT_SPLITTER_DCLICK( ,sub {});
    #&Wx::wxSP_NOBORDER  );

    Wx::Event::EVT_MENU( $win, 1000, sub { $nbl->add_edit_page() } );

    #Wx::Event::EVT_CLOSE($frame, sub{$frame->Close; $_[1]->Skip });


    $sizer{'main'}->Add( $splitter{'left'}, 1, &Wx::wxGROW);
    $sizer{'win'} = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
    $sizer{'win'}->Add( $panel{'main'}, 1, &Wx::wxGROW );
    $win->SetSizer( $sizer{'win'});
    return $win;
}


1;