source: extensions/pLoader/trunk/src/Uploader/GUI/ImageProgressDlg.pm @ 6494

Last change on this file since 6494 was 6494, checked in by ronosman, 14 years ago

New progress dialog implementation using virtual listctrl. Fix scrolling issues with Wx::Gauge.

File size: 3.7 KB
Line 
1# +-----------------------------------------------------------------------+
2# | pLoader - a Perl photo uploader for Piwigo                            |
3# +-----------------------------------------------------------------------+
4# | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
5# +-----------------------------------------------------------------------+
6# | This program is free software; you can redistribute it and/or modify  |
7# | it under the terms of the GNU General Public License as published by  |
8# | the Free Software Foundation                                          |
9# |                                                                       |
10# | This program is distributed in the hope that it will be useful, but   |
11# | WITHOUT ANY WARRANTY; without even the implied warranty of            |
12# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
13# | General Public License for more details.                              |
14# |                                                                       |
15# | You should have received a copy of the GNU General Public License     |
16# | along with this program; if not, write to the Free Software           |
17# | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18# | USA.                                                                  |
19# +-----------------------------------------------------------------------+
20package Uploader::GUI::ImageProgressDlg;
21use strict;
22use Wx qw/
23    wxDefaultSize
24    wxDefaultPosition
25    wxID_CANCEL
26    wxID_OK
27    wxGREEN
28    wxDIALOG_NO_PARENT
29    wxDEFAULT_DIALOG_STYLE
30    wxMAXIMIZE_BOX
31    wxMINIMIZE_BOX
32/;
33use base qw/Wx::Dialog Class::Accessor::Fast/;
34use Wx::Event qw/
35    EVT_BUTTON
36/;
37
38__PACKAGE__->mk_accessors( qw/
39    cancel_cbk
40    listctrl
41    columns
42    progress_column
43/);
44use Carp;
45use Uploader::GUI::Layout::ImageProgress;
46
47sub new {
48    my ($this, $params) = @_;
49    #on recupere le nom de la classe en fonction du type d'appel de la méthode.
50    my $class = ref($this) || $this;
51
52
53    my $self = $class->SUPER::new(
54        undef, 
55        -1,
56        $params->{title},
57        wxDefaultPosition,
58        wxDefaultSize,
59             wxDIALOG_NO_PARENT|
60             wxDEFAULT_DIALOG_STYLE|
61             wxMAXIMIZE_BOX|
62             wxMINIMIZE_BOX
63
64    );
65
66    $self->columns(
67        ['Name', 'Rank', '%', 'Status', 'File']
68    );
69
70    $self->progress_column(
71        $params->{progress_column}||2
72    );
73
74    $self->cancel_cbk(
75        $params->{cancel_cbk}
76    );
77
78    Uploader::GUI::Layout::ImageProgress::Init($self);
79
80    $self->init_columns;
81
82    # which column displays progress bar
83    $self->listctrl->progress_column(
84        $self->progress_column
85    );
86
87    $self->listctrl->column_item_data(
88        $params->{column_item_data}
89    );
90
91    Wx::Event::EVT_BUTTON( $self, $main::ID_UPLOAD_CANCEL, \&on_cancel );
92    Wx::Event::EVT_CLOSE( $self, \&on_close );
93
94    $self;
95}
96
97
98sub init_columns {
99    my ( $self ) = @_;
100
101    map {
102        my $col = $self->listctrl->InsertColumn(
103            $self->listctrl->GetColumnCount,
104            $_
105        );
106    }
107    @{$self->columns}
108}
109
110
111sub add_images {
112    my ( $self, $images ) = @_;
113
114    $self->listctrl->add_progress_items($images);
115}
116
117
118sub update_image_item {
119    my ( $self, $image ) = @_;
120
121    my $item = $image->{add_rank};
122    $self->listctrl->replace_item_data($item, $image);
123}
124
125
126sub auto_size_columns {
127    my ( $self ) = @_;
128
129    map{
130       $self->listctrl->SetColumnWidth($_, -1);
131    }(0..$self->listctrl->GetColumnCount);
132
133}
134
135
136sub on_cancel {
137    my( $self, $event ) = @_;
138
139    $self->cancel_cbk->();
140    $event->Skip;
141}
142 
143
144sub on_close {
145    my( $self, $event ) = @_;
146
147    $self->Hide;
148    $event->Skip;
149}
150
151
1521;
Note: See TracBrowser for help on using the repository browser.