source: extras/pLoader/trunk/src/Uploader/Object2.pm @ 3284

Last change on this file since 3284 was 2696, checked in by ronosman, 16 years ago

Features added:

  • Cancel during upload or file processing
  • Auto rotate
  • Upload high resolution
  • Property svn:eol-style set to LF
File size: 3.8 KB
Line 
1# +-----------------------------------------------------------------------+
2# | pLoader - a Perl photo uploader for Piwigo                            |
3# +-----------------------------------------------------------------------+
4# | Copyright(C) 2008      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::Object2;
21use strict;
22
23use Data::Dumper;
24use base qw/
25               Class::Accessor::Fast
26           /; 
27
28__PACKAGE__->mk_accessors(     
29    qw/
30        accessors
31        frame_callbacks
32      /
33);
34
35
36
37
38
39
40# Set control values with accessor
41sub SetControlValues {
42    my ( $self ) = @_;
43   
44    my $accessors = $self->accessors;
45   
46    # accessor_name => [ sub {}, control_id ]
47    map {
48        my $control_id = $_;
49        $self->SetControlValue($control_id);
50   }
51    keys %$accessors;
52}
53
54
55
56sub GetControlValue {
57    my( $self, $control_id ) = @_;
58
59    my $ctrl = $self->FindWindow($control_id) ;
60    my $accessor = $self->accessors->{$control_id};
61
62    # to execute the right method
63    my $method = {
64        'Wx::TextCtrl' => sub { 
65                              $accessor->(
66                                  $ctrl->GetValue()
67                              );
68                          },   
69        'Wx::StaticText' => sub { 
70                              $accessor->(
71                                  $ctrl->GetLabel()
72                              );
73                          },   
74        'Wx::StaticBitmap' => sub { 
75                              $accessor->(
76                                  $ctrl->GetBitmap()
77                              );
78                          },   
79        'Wx::RadioBox' => sub { 
80                              $accessor->(
81                                  $ctrl->GetSelection()
82                              );
83                          },   
84    };
85
86
87    eval {
88        $method->{ref $ctrl }->();
89    };
90}
91
92
93
94sub SetControlValue {
95    my( $self, $control_id ) = @_;
96
97    my $ctrl = $self->FindWindow($control_id) ;
98    my $accessor = $self->accessors->{$control_id};
99
100
101    # to execute the right method
102    my $method = {
103        'Wx::TextCtrl' => sub { 
104                              $ctrl->ChangeValue(
105                                  $accessor->()
106                              );
107                          },   
108        'Wx::StaticText' => sub { 
109                              $ctrl->SetLabel(
110                                  $accessor->()
111                              );
112                          },   
113        'Wx::StaticBitmap' => sub { 
114                              $ctrl->SetBitmap(
115                                  $accessor->()
116                              );
117                          },   
118        'Wx::RadioBox' => sub { 
119                              $ctrl->SetSelection(
120                                  $accessor->()
121                              );
122                          },   
123    };
124    eval {
125        $method->{ref $ctrl }->();
126    };
127}
1281;
Note: See TracBrowser for help on using the repository browser.