Source

Kephra / lib / Kephra / App / Frame.pm

use v5.10;
use warnings;
use Wx;
use Kephra::API;


package Kephra::App::Frame;
our @ISA = 'Wx::Frame';
our $_ref;
my $title_end = "$Kephra::NAME $Kephra::VERSION";

#Kephra::CommandList::register_cmd({
 #'window-fullscreen-toggle'=>{sub => '$win->toggle_fullscreen', label=>'Fullscreen', keys=>'F11'},
 #'iounit-focus'            =>{sub =>'$win->{"part"}{"iounit"}->focus_on_input', label => ' ', keys => 'esc'},
#});


sub new {
	my( $class, $title ) = @_;
	my( $self ) = $_ref = $class->SUPER::new ( undef, -1, $title, [-1,-1],[1000, 800] );
	$self->SetIcon( Wx::GetWxPerlIcon() );
	Kephra::App::Focus::set($self);

	#Wx::Event::EVT_CLOSE( $self, sub{ Kephra::App::close_save() });

	return $self;
}

sub close   { $_ref->Close() }
sub destroy { $_ref->Destroy() }

sub get_title { $_ref->GetTitle( )       }
sub set_title { $_ref->SetTitle( $_[1] ) }
sub refresh_title {
	my $self = shift;
	my $doc = Kephra::API::document();
	my $title = (ref $doc and $doc->file_name)
		? $doc->file_name.' ('.$doc->file_path.')'
		: Kephra::API::document()->title();
	$self->set_title( $title . " - $title_end" );
}

sub toggle_fullscreen {
	my ($self) = @_;
	$self->{fullscreen} ^= 1;
	$self->ShowFullScreen ( 
		$self->{fullscreen}, 
		&Wx::wxFULLSCREEN_NOCAPTION | &Wx::wxFULLSCREEN_NOBORDER
	);
}

1;