49
49
# Create the search control
50
50
$self->{search} = Wx::TextCtrl->new(
52
Wx::wxDefaultPosition,
54
Wx::wxTE_PROCESS_ENTER | Wx::wxSIMPLE_BORDER,
54
Wx::TE_PROCESS_ENTER | Wx::SIMPLE_BORDER,
57
57
# Create the functions list
58
58
$self->{list} = Wx::ListBox->new(
61
Wx::wxDefaultPosition,
64
Wx::wxLB_SINGLE | Wx::wxBORDER_NONE
64
Wx::LB_SINGLE | Wx::BORDER_NONE
68
my $sizerv = Wx::BoxSizer->new(Wx::wxVERTICAL);
69
my $sizerh = Wx::BoxSizer->new(Wx::wxHORIZONTAL);
70
$sizerv->Add( $self->{search}, 0, Wx::wxALL | Wx::wxEXPAND );
71
$sizerv->Add( $self->{list}, 1, Wx::wxALL | Wx::wxEXPAND );
72
$sizerh->Add( $sizerv, 1, Wx::wxALL | Wx::wxEXPAND );
68
my $sizerv = Wx::BoxSizer->new(Wx::VERTICAL);
69
my $sizerh = Wx::BoxSizer->new(Wx::HORIZONTAL);
70
$sizerv->Add( $self->{search}, 0, Wx::ALL | Wx::EXPAND );
71
$sizerv->Add( $self->{list}, 1, Wx::ALL | Wx::EXPAND );
72
$sizerh->Add( $sizerv, 1, Wx::ALL | Wx::EXPAND );
74
74
# Fits panel layout
75
75
$self->SetSizerAndFit($sizerh);
89
89
# Handle double click on list.
90
90
# Overwrite to avoid stealing the focus back from the editor.
91
91
# On Windows this appears to kill the double-click feature entirely.
92
unless (Padre::Constant::WXWIN32) {
92
unless (Padre::Constant::WIN32) {
93
93
Wx::Event::EVT_LEFT_DCLICK(
105
105
my ( $this, $event ) = @_;
107
107
my $code = $event->GetKeyCode;
108
if ( $code == Wx::WXK_RETURN ) {
108
if ( $code == Wx::K_RETURN ) {
109
109
$self->on_list_item_activated($event);
110
} elsif ( $code == Wx::WXK_ESCAPE ) {
110
} elsif ( $code == Wx::K_ESCAPE ) {
112
112
# Escape key clears search and returns focus
128
128
my ( $this, $event ) = @_;
130
130
my $code = $event->GetKeyCode;
131
if ( $code == Wx::WXK_DOWN || $code == Wx::WXK_UP || $code == Wx::WXK_RETURN ) {
131
if ( $code == Wx::K_DOWN || $code == Wx::K_UP || $code == Wx::K_RETURN ) {
133
133
# Up/Down and return keys focus on the functions lists
134
134
$self->{list}->SetFocus;
227
227
Wx::gettext('Functions');
230
# Pick up colouring from the current editor style
233
my $config = $self->config;
235
# Load the editor style
236
require Padre::Wx::Editor;
237
my $data = Padre::Wx::Editor::data( $config->editor_style ) or return;
239
# Find the colours we need
240
my $foreground = $data->{padre}->{colors}->{PADRE_BLACK}->{foreground};
241
my $background = $data->{padre}->{background};
243
# Apply them to the widgets
244
if ( defined $foreground and defined $background ) {
245
$foreground = Padre::Wx::color($foreground);
246
$background = Padre::Wx::color($background);
248
$self->{list}->SetForegroundColour($foreground);
249
$self->{list}->SetBackgroundColour($background);
251
# $self->{search}->SetForegroundColour($foreground);
252
# $self->{search}->SetBackgroundColour($background);
259
231
my $self = shift;
260
232
my $current = shift or return;
261
233
my $document = $current->document;
262
my $search = $self->{search};
263
my $list = $self->{list};
264
my $lock = $self->main->lock('UPDATE');
235
# Abort any in-flight checks
266
238
# Hide the widgets when no files are open
267
239
unless ($document) {
272
240
$self->{document} = '';
276
# Ensure the widget is visible
280
245
# Clear search when it is a different document
281
246
my $id = Scalar::Util::refaddr($document);
282
247
if ( $id ne $self->{document} ) {
283
$search->ChangeValue('');
248
$self->{search}->ChangeValue('');
284
249
$self->{document} = $id;
287
252
# Nothing to do if there is no content
288
253
my $task = $document->task_functions;
289
if ( $document->is_unused or not $task ) {
259
# Ensure the widget is visible
262
# Shortcut if there is nothing to search for
263
if ( $document->is_unused ) {
297
270
text => $document->text_get,
298
271
order => $current->config->main_functions_order,
278
my $lock = $self->lock_update;
279
$self->{search}->Show(1);
280
$self->{list}->Show(1);
282
# Rerun our layout in case the size of the function list
283
# geometry changed while we were hidden.
289
my $lock = $self->lock_update;
290
$self->{search}->Hide;
292
$self->{list}->Clear;
302
296
# Set an updated method list from the task