| 1 | 1 | ▶ | use v5.12; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 0 | ▶ | use Wx; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 4 | |||
| 5 | package Kephra::App::Dialog; | ||
| 6 | |||
| 7 | |||
| 8 | sub _parent { undef } | ||
| 9 | |||
| 10 | # standard dialogs | ||
| 11 | |||
| 12 | sub message { | ||
| 13 | $_[1] = $_[1] || 'Kephra Message'; | ||
| 14 | splice @_, 2, 0, &Wx::wxOK | &Wx::wxSTAY_ON_TOP; | ||
| 15 | _box( @_ ); | ||
| 16 | } | ||
| 17 | sub info { | ||
| 18 | $_[1] = $_[1] || 'Kephra Information'; | ||
| 19 | splice @_, 2, 0, &Wx::wxOK | &Wx::wxICON_INFORMATION | &Wx::wxSTAY_ON_TOP; | ||
| 20 | _box( @_ ); | ||
| 21 | } | ||
| 22 | sub warning { | ||
| 23 | $_[1] = $_[1] || 'Kephra Warning'; | ||
| 24 | splice @_, 2, 0, &Wx::wxOK | &Wx::wxICON_WARNING | &Wx::wxSTAY_ON_TOP; | ||
| 25 | _box( @_ ); | ||
| 26 | } | ||
| 27 | sub yes_no { | ||
| 28 | $_[1] = $_[1] || 'Kephra Question'; | ||
| 29 | splice @_, 2, 0, &Wx::wxYES_NO | &Wx::wxICON_QUESTION | &Wx::wxSTAY_ON_TOP; | ||
| 30 | _box( @_ ); | ||
| 31 | } | ||
| 32 | sub yes_no_cancel { | ||
| 33 | $_[1] = $_[1] || 'Kephra Question'; | ||
| 34 | splice @_, 2, 0, &Wx::wxYES_NO | &Wx::wxCANCEL | &Wx::wxICON_QUESTION | &Wx::wxSTAY_ON_TOP; | ||
| 35 | _box( @_ ); | ||
| 36 | } | ||
| 37 | sub _box { # $message, $title, $style, $parent | ||
| 38 | #Kephra::Log::warning('need at least a message as first parameter', 2) unless $_[0]; | ||
| 39 | $_[3] = $_[3] || _parent(); | ||
| 40 | Wx::MessageBox( @_ ); | ||
| 41 | } | ||
| 42 | |||
| 43 | sub get_file_open { | ||
| 44 | my $dir = shift // '.'; | ||
| 45 | my $title = shift // 'Open File ...'; | ||
| 46 | my $filter = shift // '(*)|*'; | ||
| 47 | my $parent = shift // _parent(); | ||
| 48 | Wx::FileSelector( $title, $dir, '', '', $filter, &Wx::wxFD_OPEN, $parent); | ||
| 49 | } | ||
| 50 | |||
| 51 | sub get_files_open { | ||
| 52 | my $dir = shift // '.'; | ||
| 53 | my $title = shift // 'Open File ...'; | ||
| 54 | my $filter = shift // '(*)|*'; | ||
| 55 | my $parent = shift // _parent(); | ||
| 56 | my $dialog = Wx::FileDialog->new | ||
| 57 | ($parent, $title, $dir, '', $filter, &Wx::wxFD_OPEN | &Wx::wxFD_MULTIPLE); | ||
| 58 | if ($dialog->ShowModal != &Wx::wxID_CANCEL) { | ||
| 59 | return $dialog->GetPaths; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | sub get_file_save { | ||
| 64 | my $dir = shift // '.'; | ||
| 65 | my $title = shift // 'Save File As ...'; | ||
| 66 | my $filter = shift // '(*)|*'; | ||
| 67 | my $parent = shift // _parent(); | ||
| 68 | Wx::FileSelector( $title, $dir, '', '', $filter, &Wx::wxFD_SAVE, $parent); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub get_dir { Wx::DirSelector ( @_[0,1], 0, [-1,-1], _parent()) } | ||
| 72 | sub get_font { Wx::GetFontFromUser ( _parent(), $_[0]) } | ||
| 73 | sub get_text { Wx::GetTextFromUser ( $_[0], $_[1], "", _parent()) } | ||
| 74 | sub get_number {Wx::GetNumberFromUser( $_[0], '', $_[1],$_[2], 0, 100000, _parent())} | ||
| 75 | |||
| 76 | # own dialogs | ||
| 77 | #sub find { | ||
| 78 | #require Kephra::App::Dialog::Search; &Kephra::App::Dialog::Search::find; | ||
| 79 | #} | ||
| 80 | #sub replace { | ||
| 81 | #require Kephra::App::Dialog::Search; &Kephra::App::Dialog::Search::replace; | ||
| 82 | #} | ||
| 83 | #sub choose_color { | ||
| 84 | #require Kephra::App::Dialog::Color; Kephra::App::Dialog::Color::choose_color(); | ||
| 85 | #} | ||
| 86 | sub about { | ||
| 87 | require Kephra::App::Dialog::About; | ||
| 88 | Kephra::App::Dialog::About->new( shift )->ShowModal; | ||
| 89 | } | ||
| 90 | sub config { | ||
| 91 | require Kephra::App::Dialog::Config; | ||
| 92 | Kephra::App::Dialog::Config::create( )->ShowModal; | ||
| 93 | } | ||
| 94 | sub documentation { | ||
| 95 | require Kephra::App::Dialog::Documentation; | ||
| 96 | Kephra::App::Dialog::Documentation->new( shift )->ShowModal; | ||
| 97 | } | ||
| 98 | sub keymap { | ||
| 99 | require Kephra::App::Dialog::Keymap; | ||
| 100 | Kephra::App::Dialog::Keymap->new( shift )->ShowModal; | ||
| 101 | } | ||
| 102 | |||
| 103 | #sub notify_file_changed { | ||
| 104 | #require Kephra::App::Dialog::Notify; &Kephra::App::Dialog::Notify::file_changed; | ||
| 105 | #} | ||
| 106 | #sub notify_file_deleted { | ||
| 107 | #require Kephra::App::Dialog::Notify; &Kephra::App::Dialog::Notify::file_deleted; | ||
| 108 | #} | ||
| 109 | #sub save_on_exit { | ||
| 110 | #require Kephra::App::Dialog::Exit; &Kephra::App::Dialog::Exit::save_on_exit; | ||
| 111 | #} | ||
| 112 | |||
| 113 | |||
| 114 | 1; | ||