Source

Kephra / lib / Kephra / App / Dialog / Config.pm

use strict;
use warnings;
use Wx;

package Kephra::App::Dialog::Config;
my $cache;

sub create {
	return $cache if defined $cache;
	my $dialog = $cache = Wx::Dialog->new(
		Kephra::App::Dialog::_parent(shift), -1,
		$Kephra::NAME . ' '.$Kephra::VERSION .' Configuration', [-1,-1], [800,600]
	);
	my %node;
	my $tree = Wx::Treebook->new($dialog, -1);
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'General');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'File');
	$tree->AddSubPage(Wx::Panel->new($dialog, -1), 'Open');
	$tree->AddSubPage(Wx::Panel->new($dialog, -1), 'Close');
	$tree->AddSubPage(Wx::Panel->new($dialog, -1), 'Session');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'Editor');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'Syntaxmode');
	$tree->AddSubPage(Wx::Panel->new($dialog, -1), 'Perl');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'IOUnit');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'FileBrowser');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'TreeLib');
	$tree->AddPage(Wx::Panel->new($dialog, -1), 'Plugin');
	$tree->ExpandNode($_, 1) for 1..9;

	my @button_label = qw(Accept Cancel); # from left to right
	my %button;
	$button{lc $_} = Wx::Button->new( $dialog, -1, $_ ) for @button_label;
	my $keysizer = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
	$keysizer->AddStretchSpacer();
	$keysizer->Add($button{lc($_)}, 0, &Wx::wxGROW | &Wx::wxALL, 10) for @button_label;
	my $sizer = Wx::BoxSizer->new( &Wx::wxVERTICAL );
	$sizer->Add($tree, 1, &Wx::wxGROW, 0);
	$sizer->Add(Wx::StaticLine->new($dialog, -1, [-1,-1], [-1,2]), 0, &Wx::wxTOP | &Wx::wxGROW, 10);
	$sizer->Add($keysizer, 0, &Wx::wxGROW, 0);
	$dialog->SetSizer($sizer);

	Wx::Event::EVT_BUTTON($dialog, $button{'accept'}, sub {
		$dialog->EndModal(0);
	});
	Wx::Event::EVT_BUTTON($dialog, $button{'cancel'}, sub {
		$dialog->EndModal(0);
	});

	$dialog;
}

1;