1
package Padre::Wx::Dialog::FilterTool;
7
use Padre::Wx::Icon ();
10
our @ISA = 'Wx::Dialog';
12
use Class::XSAccessor accessors => {
13
_butrun => '_butrun', # run button
14
_combo => '_combo', # combo box
15
_names => '_names', # list of all recent commands
16
_sizer => '_sizer', # the window sizer
22
my ( $class, $parent ) = @_;
25
my $self = $class->SUPER::new(
28
Wx::gettext('Filter through tool'),
29
Wx::wxDefaultPosition,
31
Wx::wxDEFAULT_FRAME_STYLE | Wx::wxTAB_TRAVERSAL,
33
$self->SetIcon(Padre::Wx::Icon::PADRE);
45
$self->_refresh_combo;
52
# $self->_on_butclose_clicked;
54
# handler called when the close button has been clicked.
56
sub _on_butclose_clicked {
62
# $self->_on_butrun_clicked;
64
# handler called when the run button has been clicked.
66
sub _on_butrun_clicked {
69
my $main = $self->GetParent;
71
my $tool = $self->_combo->GetValue;
73
if ( defined($tool) and ( $tool ne '' ) ) {
75
# $filtertool = Padre::DB::FilterTool->new(
76
# name => $self->_combo->GetValue,
77
# last_update => time,
79
# $filtertool->insert;
81
$main->filter_tool($tool);
94
# create the dialog itself.
96
# no params, no return values.
101
# create sizer that will host all controls
102
my $box = Wx::BoxSizer->new(Wx::wxVERTICAL);
103
my $sizer = Wx::GridBagSizer->new( 5, 5 );
104
$sizer->AddGrowableCol(1);
105
$box->Add( $sizer, 1, Wx::wxEXPAND | Wx::wxALL, 5 );
106
$self->_sizer($sizer);
108
$self->_create_fields;
109
$self->_create_buttons;
110
$self->SetSizer($box);
111
$box->SetSizeHints($self);
112
$self->CenterOnParent;
113
$self->_combo->SetFocus;
118
# $dialog->_create_fields;
120
# create the combo box with the recent commands.
122
# no params. no return values.
126
my $sizer = $self->_sizer;
128
my $lab1 = Wx::StaticText->new( $self, -1, Wx::gettext('Filter command:') );
129
my $combo = Wx::ComboBox->new( $self, -1, '' );
130
$sizer->Add( $lab1, Wx::GBPosition->new( 0, 0 ) );
131
$sizer->Add( $combo, Wx::GBPosition->new( 0, 1 ), Wx::GBSpan->new( 1, 3 ), Wx::wxEXPAND );
132
$self->_combo($combo);
137
# $dialog->_create_buttons;
139
# create the buttons pane.
141
# no params. no return values.
143
sub _create_buttons {
146
my $sizer = $self->_sizer;
149
my $bs = Wx::Button->new( $self, Wx::wxID_OK, Wx::gettext('Run') );
150
my $bc = Wx::Button->new( $self, Wx::wxID_CANCEL, Wx::gettext('Close') );
151
Wx::Event::EVT_BUTTON( $self, $bs, \&_on_butrun_clicked );
152
Wx::Event::EVT_BUTTON( $self, $bc, \&_on_butclose_clicked );
153
$sizer->Add( $bs, Wx::GBPosition->new( 2, 2 ) );
154
$sizer->Add( $bc, Wx::GBPosition->new( 2, 3 ) );
162
# $dialog->_refresh_combo;
167
my ( $self, $column, $reverse ) = @_;
169
# get list of recent commands, sorted.
170
# my @names = map { $_->name } Padre::DB::FilterTool->select('ORDER BY name');
171
# $self->_names( \@names );
173
# clear list & fill it again
174
my $combo = $self->_combo;
177
# $combo->Append($_) foreach @names;
188
Padre::Wx::Dialog::FilterTool - dialog to filter selection or document through an external tool
194
This Dialog askes for the tool which should be used to filter the current
195
selection or the whole document.
204
=item * my $dialog = Padre::Wx::Dialog::FilterTool->new( $parent )
206
Create and return a new Wx dialog allowing to select a filter tool. It needs a
207
C<$parent> window (usually padre's main window).
214
=head2 Public methods
218
=item * $dialog->show;
220
Request the dialog to be shown.
227
=head1 COPYRIGHT & LICENSE
229
Copyright 2008-2009 The Padre development team as listed in Padre.pm.
231
This program is free software; you can redistribute it and/or modify it
232
under the same terms as Perl 5 itself.
238
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
240
# This program is free software; you can redistribute it and/or
241
# modify it under the same terms as Perl 5 itself.