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

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

Feature 1389 added : remove AUI docking manager

File size: 6.5 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            wxCLIP_CHILDREN
33            wxDEFAULT_DIALOG_STYLE
34            wxCAPTION
35            wxCLOSE_BOX
36            wxMAXIMIZE_BOX
37            wxMINIMIZE_BOX
38            wxRESIZE_BORDER
39            wxSTAY_ON_TOP
40        /;
41use base qw/Wx::Dialog Uploader::GUI::DlgCommon/;
42use Wx::Event qw/
43            EVT_CLOSE
44        /;
45
46use Carp;
47use Data::Dumper;
48
49sub new {
50    my ($this, $params) = @_;
51
52    my $class = ref($this) || $this;
53
54
55    my $self = $class->SUPER::new(
56        undef,
57        -1,
58        $params->{caption},
59        wxDefaultPosition,
60        wxDefaultSize,
61            wxCAPTION|
62            wxCLOSE_BOX|
63            wxMAXIMIZE_BOX|
64            wxMINIMIZE_BOX|
65            wxRESIZE_BORDER|
66            wxDEFAULT_DIALOG_STYLE|
67            wxSTAY_ON_TOP
68    );
69
70
71
72
73    $self->{tags} = $params->{tags};
74    $self->{orientation} = $params->{orientation}||wxVERTICAL;
75
76    # load controls
77    &main::GlobalSettings($self);
78
79    $self->properties(
80        $params->{properties}
81    );
82
83    $self->frame_callback(
84        $params->{frame_callback}
85    );
86
87    $self->{cpane_thumbnail} = $self->FindWindow($main::CPANE_THUMBNAIL);
88    $self->{cpane_resize} = $self->FindWindow($main::CPANE_RESIZE);
89    $self->{cpane_resize_advanced} = $self->FindWindow($main::CPANE_RESIZE_ADVANCED);
90    $self->{cpane_hd} = $self->FindWindow($main::CPANE_HD);
91    $self->{cpane_hd_advanced} = $self->FindWindow($main::CPANE_HD_ADVANCED);
92    $self->{cpane_watermark} = $self->FindWindow($main::CPANE_WATERMARK);
93    $self->{cpane_transfert_advanced} = $self->FindWindow($main::CPANE_TRANSFERT_ADVANCED);
94
95    $self->{gs_close} = $self->FindWindow($main::GS_CLOSE);
96
97    $self->InitLabels();
98    $self->InitChoices();
99    $self->SetProperties();
100    $self->InitHandler();
101    $self->_initEventHandlers();
102
103    $self->_DefautPhotoCaption(
104        $main::GS_DEFAULT_PHOTO_CAPTION
105    );
106
107    if($@){
108        Wx::LogMessage("Error during dialogbox initialization");
109    }
110
111    $self;   
112}
113
114
115
116sub _initEventHandlers {
117    my ( $self ) = @_;
118   
119    Wx::Event::EVT_BUTTON( $self, $self->{gs_close}, \&OnClose );
120    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_thumbnail}, \&OnPaneChanged );
121    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize}, \&OnPaneChanged );
122    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize_advanced}, \&OnPaneChanged );
123    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd}, \&OnPaneChanged );
124    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd_advanced}, \&OnPaneChanged );
125    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_watermark}, \&OnPaneChanged );
126    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_transfert_advanced}, \&OnPaneChanged );
127
128}
129
130
131sub OnClose {
132    my ( $self, $event ) = @_;
133   
134    $self->_close;
135}
136
137sub _close {
138    my ( $self ) = @_;
139
140
141    $self->Hide;
142}
143
144sub OnPaneChanged {
145    my( $self, $event ) = @_;
146
147    #$self->_layout;
148    $event->Skip;
149}
150
151sub _layout {
152    my( $self ) = @_;
153
154    $self->Layout; 
155    $self->GetSizer->Fit($self);
156    my $size = $self->GetSize;
157    $self->frame_callback->($size);
158
159}
160
161
162sub OnDefaultPhotoCaption {
163    my ( $self, $event ) = @_;
164   
165    $self->_DefautPhotoCaption(
166        $event->GetId
167    );
168
169    $event->Skip;
170}
171
172
173sub _DefautPhotoCaption {
174    my ( $self, $id ) = @_;
175
176    my $b=0;
177    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
178        if ( $self->properties->{$id}
179            ->{string_selection}->() =~ /refix/ ){
180            $b=1;
181        }
182    }
183
184    map {
185        $self->FindWindow($_)->Show($b)
186    }(
187        $main::PHOTO_CAPTION_PREFIX,
188        $main::GS_PHOTO_CAPTION_PREFIX
189    );
190}
191
192sub OnCreateResized {
193    my ( $self, $event ) = @_;
194   
195    my $id = $event->GetId;
196    my $b = 1;
197    if('CODE' eq ref $self->properties->{$id}->{selection}){
198        $b = !$self->properties->{$id}->{selection}->()
199    }
200
201    $self->{cpane_resize}->Collapse($b);
202    #$self->_layout;
203    $event->Skip;
204
205}
206
207
208sub OnHDUpload {
209    my ( $self, $event ) = @_;
210   
211
212    my $id = $event->GetId;
213    my $b = 1;
214    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
215        if ( $self->properties->{$id}
216            ->{string_selection}->() =~ /resized/){
217            $b = 0;
218        }
219    }
220    $self->{cpane_hd}->Collapse($b);
221    #$self->_layout;
222    $event->Skip;
223}
224
225sub OnWatermark {
226    my ( $self, $event ) = @_;
227   
228    my $id = $event->GetId;
229    my $b = 1;
230    if('CODE' eq ref $self->properties->{$id}->{value}){
231        $b = !$self->properties->{$id}->{value}->()
232    }
233
234    $self->{cpane_watermark}->Collapse($b);
235    #$self->_layout;
236    $event->Skip;
237}
238
239
2401;
Note: See TracBrowser for help on using the repository browser.