source: extensions/pLoader/trunk/src/Uploader/GUI/wxGlobalSettings.pm @ 4571

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

This one is also important for feature 1346 !

File size: 6.1 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::GUI::wxGlobalSettings;
21use strict;
22use Wx qw/
23            wxDefaultSize
24            wxDefaultPosition
25            wxTAB_TRAVERSAL
26            wxID_CANCEL
27            wxID_OK
28            wxGREEN
29            wxHORIZONTAL
30            wxVERTICAL
31            wxFULL_REPAINT_ON_RESIZE
32        /;
33use base qw/Wx::Panel Uploader::GUI::DlgCommon/;
34use Wx::Event qw/
35            EVT_CLOSE
36        /;
37
38use Carp;
39use Data::Dumper;
40
41sub new {
42    my ($this, $params) = @_;
43
44    my $class = ref($this) || $this;
45
46
47    my $self = $class->SUPER::new( $params->{parentwnd}, -1, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE );
48    $self->{tags} = $params->{tags};
49    $self->{orientation} = $params->{orientation}||wxVERTICAL;
50
51    # load controls
52    &main::GlobalSettings($self);
53
54    $self->properties(
55        $params->{properties}
56    );
57    $self->{cpane_resize} = $self->FindWindow($main::CPANE_RESIZE);
58    $self->{cpane_resize_advanced} = $self->FindWindow($main::CPANE_RESIZE_ADVANCED);
59    $self->{cpane_hd} = $self->FindWindow($main::CPANE_HD);
60    $self->{cpane_hd_advanced} = $self->FindWindow($main::CPANE_HD_ADVANCED);
61    $self->{cpane_watermark} = $self->FindWindow($main::CPANE_WATERMARK);
62    $self->{cpane_transfert_advanced} = $self->FindWindow($main::CPANE_TRANSFERT_ADVANCED);
63
64    $self->InitLabels();
65    $self->InitChoices();
66    $self->SetProperties();
67    $self->InitHandler();
68    $self->_initEventHandlers();
69
70    $self->_DefautPhotoCaption(
71        $main::GS_DEFAULT_PHOTO_CAPTION
72    );
73
74    if($@){
75        Wx::LogMessage("Error during dialogbox initialization");
76    }
77
78    $self;   
79}
80
81
82
83sub _initEventHandlers {
84    my ( $self ) = @_;
85   
86    EVT_CLOSE( $self, \&OnClose );
87    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize}, \&OnPaneChanged );
88    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize_advanced}, \&OnAdvancedPaneChanged );
89    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd}, \&OnPaneChanged );
90    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd_advanced}, \&OnAdvancedPaneChanged );
91    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_watermark}, \&OnPaneChanged );
92    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_transfert_advanced}, \&OnAdvancedPaneChanged );
93
94}
95
96
97sub OnClose {
98    my ( $self, $event ) = @_;
99   
100    $self->_close;
101}
102
103sub _close {
104    my ( $self ) = @_;
105
106
107    $self->Destroy;
108}
109
110sub OnPaneChanged {
111    my( $self, $event ) = @_;
112
113#    $self->_set_size(
114#        $event->GetCollapsed
115#    );
116    $self->Layout;
117    $event->Skip;
118}
119
120sub OnAdvancedPaneChanged {
121    my( $self, $event ) = @_;
122
123    $self->Layout;
124    $event->Skip;
125
126}
127
128sub OnDefaultPhotoCaption {
129    my ( $self, $event ) = @_;
130   
131    $self->_DefautPhotoCaption(
132        $event->GetId
133    );
134
135    $event->Skip;
136}
137
138
139sub _DefautPhotoCaption {
140    my ( $self, $id ) = @_;
141
142    my $b=0;
143    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
144        if ( $self->properties->{$id}
145            ->{string_selection}->() =~ /refix/ ){
146            $b=1;
147        }
148    }
149
150    map {
151        $self->FindWindow($_)->Show($b)
152    }(
153        $main::PHOTO_CAPTION_PREFIX,
154        $main::GS_PHOTO_CAPTION_PREFIX
155    );
156}
157
158sub OnCreateResized {
159    my ( $self, $event ) = @_;
160   
161    my $id = $event->GetId;
162    my $b = 1;
163    if('CODE' eq ref $self->properties->{$id}->{selection}){
164        $b = $self->properties->{$id}->{selection}->()
165    }
166
167    $self->{cpane_resize}->Collapse($b);
168    $self->Layout;
169    $event->Skip;
170
171}
172
173
174sub _set_size {
175    my ( $self, $collapsed ) = @_;
176
177    printf("collapsed %s\n", $collapsed);
178    my $new_size = $collapsed ? Wx::Size->new(200, 200) : Wx::Size->new(800, 800);
179    printf("collapsed %s, %s\n", $new_size->GetWidth, $new_size->GetHeight);
180
181    $self->SetMinSize($new_size);
182    $self->Layout;
183}
184
185sub OnHDUpload {
186    my ( $self, $event ) = @_;
187   
188
189    my $id = $event->GetId;
190    my $b = 1;
191    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
192        if ( $self->properties->{$id}
193            ->{string_selection}->() =~ /resized/){
194            $b = 0;
195        }
196    }
197    $self->{cpane_hd}->Collapse($b);
198    $self->Layout;
199    $event->Skip;
200}
201
202sub OnWatermark {
203    my ( $self, $event ) = @_;
204   
205    my $id = $event->GetId;
206    my $b = 1;
207    if('CODE' eq ref $self->properties->{$id}->{value}){
208        $b = !$self->properties->{$id}->{value}->()
209    }
210
211    $self->{cpane_watermark}->Collapse($b);
212    $self->Layout;
213    $event->Skip;
214}
215
216
2171;
Note: See TracBrowser for help on using the repository browser.