Source

Kephra / lib / Kephra / App / Dialog.pm

Full commit
use strict;
use warnings;
use Wx;
use Kephra::API;
use Kephra::CommandList;

package Kephra::App::Dialog;

Kephra::CommandList::register_cmd({
 'config-global-dialog'=>{sub=>'config',       label=>'Dialog',       keys=> 'ctrl+alt+c'},
 'config-keymap-dialog'=>{sub=>'keymap',       label=>'Keymapping',   keys=> 'ctrl+alt+k'},
 'help-documentation'  =>{sub=>'documentation',label=>'Documentation',keys=> 'F1'},
 'help-about'          =>{sub=>'about',        label=>'About...',     keys=> ''},
 'help-homepage'       =>{sub=>'Kephra::App::Util::lounch_browser',   parameter => 'http://kephra.sourceforge.net/site/en/home_news.shtml',
                                               label => 'Homepage',   keys  => '', help => ''},
 'help-bugreport'      =>{sub=> 'Kephra::App::Util::lounch_browser',  parameter => 'http://sourceforge.net/tracker/?func=add&group_id=169747&atid=851593',
                                               label => 'Send a Wish',keys  => '', help => ''},
});


# supplies and checks parents of a dialog
sub _parent {
	my $parent = shift;
	return Kephra::API::main_window() unless defined $parent;
	Kephra::Log::error("need a window as parent not $parent")
		unless $parent and ref $parent and $parent->isa('Wx::Window');
	return $parent;
}

# standard dialogs

sub msg_box {
	Wx::MessageBox( @_[0,1], &Wx::wxOK | &Wx::wxSTAY_ON_TOP, _parent($_[2]) )
}
#sub info_box {
	#Wx::MessageBox(
		#@_[0,1],
		#&Wx::wxOK | &Wx::wxICON_INFORMATION | &Wx::wxSTAY_ON_TOP, 
		#_parent($_[2]),
	#);
#}
#
#sub warning_box {
	#Wx::MessageBox(
		#@_[0,1],
		#&Wx::wxOK | &Wx::wxICON_WARNING | &Wx::wxSTAY_ON_TOP,
		#Kephra::API::main_window()
	#);
#}
#
#sub get_confirm_2 {
	#Wx::MessageBox
		#(@_[0,1], &Wx::wxYES_NO | &Wx::wxICON_QUESTION | &Wx::wxSTAY_ON_TOP, _win());
#}
#
#sub get_confirm_3 {
	#Wx::MessageBox
		#( @_[0,1], &Wx::wxYES_NO | &Wx::wxCANCEL | &Wx::wxICON_QUESTION, _win() );
#}
#
#sub get_file_open {
	#Wx::FileSelector( @_[0,1], '', '', $_[2], &Wx::wxFD_OPEN, _win());
#}
#
#sub get_files_open {
	#my $dialog = Wx::FileDialog->new(
		#_win(),  @_[0,1], '', $_[2], &Wx::wxFD_OPEN | &Wx::wxFD_MULTIPLE, [-1,-1]
	#);
	#if ($dialog->ShowModal != &Wx::wxID_CANCEL) {
		#my @files = $dialog->GetPaths;
		#return \@files;
	#}
#}
#
#sub get_file_save { 
	#Wx::FileSelector( @_[0,1], '', '', $_[2], &Wx::wxFD_SAVE, _win())
#}
#
#sub get_dir  {  Wx::DirSelector      ( @_[0,1] ,0, [-1,-1], _win()) }
#sub get_font {  Wx::GetFontFromUser  ( _win(), $_[0]) }
#sub get_text {  Wx::GetTextFromUser  ( $_[0], $_[1], "", _win()) }
#sub get_number {Wx::GetNumberFromUser( $_[0], '', $_[1],$_[2], 0, 100000, _win())}
#
# own dialogs
#sub find {
	#require Kephra::App::Dialog::Search; &Kephra::App::Dialog::Search::find;
#}
#sub replace {
	#require Kephra::App::Dialog::Search; &Kephra::App::Dialog::Search::replace;
#}
#sub choose_color {
	#require Kephra::App::Dialog::Color; Kephra::App::Dialog::Color::choose_color();
#}
sub about {
	require Kephra::App::Dialog::About;
	Kephra::App::Dialog::About::create( )->ShowModal;
}
sub config {
	require Kephra::App::Dialog::Config;
	Kephra::App::Dialog::Config::create( )->ShowModal;
}
sub documentation {
	require Kephra::App::Dialog::Documentation;
	Kephra::App::Dialog::Documentation::create( )->ShowModal;
}
sub keymap {
	require Kephra::App::Dialog::Keymap;
	Kephra::App::Dialog::Keymap::create( )->ShowModal;
}

#sub notify_file_changed {
	#require Kephra::App::Dialog::Notify; &Kephra::App::Dialog::Notify::file_changed;
#}
#sub notify_file_deleted {
	#require Kephra::App::Dialog::Notify; &Kephra::App::Dialog::Notify::file_deleted;
#}
#sub save_on_exit {
	#require Kephra::App::Dialog::Exit; &Kephra::App::Dialog::Exit::save_on_exit;
#}


1;