~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/FunctionList.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
use Padre::Wx::Role::Main ();
13
13
use Padre::Wx             ();
14
14
 
15
 
our $VERSION = '0.90';
 
15
our $VERSION = '0.92';
16
16
our @ISA     = qw{
17
17
        Padre::Role::Task
18
18
        Padre::Wx::Role::View
36
36
        my $self = $class->SUPER::new(
37
37
                $panel,
38
38
                -1,
39
 
                Wx::wxDefaultPosition,
40
 
                Wx::wxDefaultSize,
 
39
                Wx::DefaultPosition,
 
40
                Wx::DefaultSize,
41
41
        );
42
42
 
43
43
        # Temporary store for the function list.
49
49
        # Create the search control
50
50
        $self->{search} = Wx::TextCtrl->new(
51
51
                $self, -1, '',
52
 
                Wx::wxDefaultPosition,
53
 
                Wx::wxDefaultSize,
54
 
                Wx::wxTE_PROCESS_ENTER | Wx::wxSIMPLE_BORDER,
 
52
                Wx::DefaultPosition,
 
53
                Wx::DefaultSize,
 
54
                Wx::TE_PROCESS_ENTER | Wx::SIMPLE_BORDER,
55
55
        );
56
56
 
57
57
        # Create the functions list
58
58
        $self->{list} = Wx::ListBox->new(
59
59
                $self,
60
60
                -1,
61
 
                Wx::wxDefaultPosition,
62
 
                Wx::wxDefaultSize,
 
61
                Wx::DefaultPosition,
 
62
                Wx::DefaultSize,
63
63
                [],
64
 
                Wx::wxLB_SINGLE | Wx::wxBORDER_NONE
 
64
                Wx::LB_SINGLE | Wx::BORDER_NONE
65
65
        );
66
66
 
67
67
        # Create a sizer
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 );
73
73
 
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(
94
94
                        $self->{list},
95
95
                        sub {
105
105
                        my ( $this, $event ) = @_;
106
106
 
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 ) {
111
111
 
112
112
                                # Escape key clears search and returns focus
113
113
                                # to the editor
128
128
                        my ( $this, $event ) = @_;
129
129
 
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 ) {
132
132
 
133
133
                                # Up/Down and return keys focus on the functions lists
134
134
                                $self->{list}->SetFocus;
137
137
                                        $selection = 0;
138
138
                                }
139
139
                                $self->{list}->Select($selection);
140
 
                        } elsif ( $code == Wx::WXK_ESCAPE ) {
 
140
                        } elsif ( $code == Wx::K_ESCAPE ) {
141
141
 
142
142
                                # Escape key clears search and returns focus
143
143
                                # to the editor
161
161
        );
162
162
 
163
163
        if (Padre::Feature::STYLE_GUI) {
164
 
                $self->recolour;
 
164
                $self->main->theme->apply( $self->{list} );
165
165
        }
166
166
 
167
167
        return $self;
227
227
        Wx::gettext('Functions');
228
228
}
229
229
 
230
 
# Pick up colouring from the current editor style
231
 
sub recolour {
232
 
        my $self   = shift;
233
 
        my $config = $self->config;
234
 
 
235
 
        # Load the editor style
236
 
        require Padre::Wx::Editor;
237
 
        my $data = Padre::Wx::Editor::data( $config->editor_style ) or return;
238
 
 
239
 
        # Find the colours we need
240
 
        my $foreground = $data->{padre}->{colors}->{PADRE_BLACK}->{foreground};
241
 
        my $background = $data->{padre}->{background};
242
 
 
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);
247
 
 
248
 
                $self->{list}->SetForegroundColour($foreground);
249
 
                $self->{list}->SetBackgroundColour($background);
250
 
 
251
 
                # $self->{search}->SetForegroundColour($foreground);
252
 
                # $self->{search}->SetBackgroundColour($background);
253
 
        }
254
 
 
255
 
        return 1;
256
 
}
257
 
 
258
230
sub refresh {
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');
 
234
 
 
235
        # Abort any in-flight checks
 
236
        $self->task_reset;
265
237
 
266
238
        # Hide the widgets when no files are open
267
239
        unless ($document) {
268
 
                $search->Hide;
269
 
                $list->Hide;
270
 
                $list->Clear;
271
 
                $self->{model}    = [];
272
240
                $self->{document} = '';
 
241
                $self->disable;
273
242
                return;
274
243
        }
275
244
 
276
 
        # Ensure the widget is visible
277
 
        $search->Show(1);
278
 
        $list->Show(1);
279
 
 
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;
285
250
        }
286
251
 
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 ) {
290
 
                $list->Clear;
 
254
        unless ($task) {
 
255
                $self->disable;
 
256
                return;
 
257
        }
 
258
 
 
259
        # Ensure the widget is visible
 
260
        $self->enable;
 
261
 
 
262
        # Shortcut if there is nothing to search for
 
263
        if ( $document->is_unused ) {
291
264
                return;
292
265
        }
293
266
 
297
270
                text  => $document->text_get,
298
271
                order => $current->config->main_functions_order,
299
272
        );
 
273
 
 
274
}
 
275
 
 
276
sub enable {
 
277
        my $self = shift;
 
278
        my $lock = $self->lock_update;
 
279
        $self->{search}->Show(1);
 
280
        $self->{list}->Show(1);
 
281
 
 
282
        # Rerun our layout in case the size of the function list
 
283
        # geometry changed while we were hidden.
 
284
        $self->Layout;
 
285
}
 
286
 
 
287
sub disable {
 
288
        my $self = shift;
 
289
        my $lock = $self->lock_update;
 
290
        $self->{search}->Hide;
 
291
        $self->{list}->Hide;
 
292
        $self->{list}->Clear;
 
293
        $self->{model} = [];
300
294
}
301
295
 
302
296
# Set an updated method list from the task
325
319
 
326
320
        # Show the components and populate the function list
327
321
        SCOPE: {
328
 
                my $lock = $self->main->lock('UPDATE');
 
322
                my $lock = $self->lock_update;
329
323
                $search->Show(1);
330
324
                $list->Show(1);
331
325
                $list->Clear;