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

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

Feature 1562 : remove STAY_ON_TOP attribute.

File size: 8.2 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::wxGlobalSettings;
21use strict;
22use Wx qw/
23            wxDefaultSize
24            wxDefaultPosition
25            wxVERTICAL
26            wxDEFAULT_DIALOG_STYLE
27            wxCAPTION
28            wxCLOSE_BOX
29            wxMAXIMIZE_BOX
30            wxMINIMIZE_BOX
31            wxRESIZE_BORDER
32            wxALIGN_CENTER
33            wxALL
34            wxBK_DEFAULT
35            wxALIGN_CENTER_VERTICAL
36            wxGROW
37            wxALIGN_CENTER_VERTICAL
38            wxLI_HORIZONTAL
39            wxALIGN_BOTTOM
40            wxALIGN_CENTER_HORIZONTAL
41            wxBITMAP_TYPE_PNG
42            wxTheApp
43            wxBK_LEFT
44            wxHORIZONTAL
45        /;
46use base qw/Wx::Dialog Uploader::GUI::DlgCommon/;
47use Wx::Locale qw/:default/;
48use Wx::Event qw/
49            EVT_CLOSE
50        /;
51
52use Carp;
53use Data::Dumper;
54
55sub new {
56    my ($this, $params) = @_;
57
58    my $class = ref($this) || $this;
59
60
61    my $self = $class->SUPER::new(
62        undef,
63        -1,
64        $params->{caption},
65        wxDefaultPosition,
66        wxDefaultSize,
67            wxCAPTION|
68            wxCLOSE_BOX|
69            wxMAXIMIZE_BOX|
70            wxMINIMIZE_BOX|
71            wxRESIZE_BORDER|
72            wxDEFAULT_DIALOG_STYLE
73    );
74
75
76
77
78    $self->{tags} = $params->{tags};
79    $self->{orientation} = $params->{orientation}||wxVERTICAL;
80
81    # load controls
82    GlobalSetting_ToolBook($self, 1);
83
84    $self->properties(
85        $params->{properties}
86    );
87
88
89    $self->{cpane_thumbnail} = $self->FindWindow($main::CPANE_THUMBNAIL);
90    $self->{cpane_resize} = $self->FindWindow($main::CPANE_RESIZE);
91    $self->{cpane_resize_advanced} = $self->FindWindow($main::CPANE_RESIZE_ADVANCED);
92    $self->{cpane_hd} = $self->FindWindow($main::CPANE_HD);
93    $self->{cpane_hd_advanced} = $self->FindWindow($main::CPANE_HD_ADVANCED);
94    $self->{cpane_watermark} = $self->FindWindow($main::CPANE_WATERMARK);
95    $self->{cpane_transfert_advanced} = $self->FindWindow($main::CPANE_TRANSFERT_ADVANCED);
96    $self->{gs_close} = $self->FindWindow($main::GS_CLOSE);
97
98    $self->InitLabels();
99    $self->InitChoices();
100    $self->SetProperties();
101    $self->InitHandler();
102    $self->_initEventHandlers();
103
104    $self->_DefautPhotoCaption(
105        $main::GS_DEFAULT_PHOTO_CAPTION
106    );
107
108    if($@){
109        Wx::LogMessage("Error during dialogbox initialization");
110    }
111
112    # Force layout an paint : awful but works
113    $self->{cpane_hd}->Collapse(0);
114    $self->{cpane_hd}->Collapse(1);
115
116    $self;   
117}
118
119
120
121sub _initEventHandlers {
122    my ( $self ) = @_;
123   
124    Wx::Event::EVT_BUTTON( $self, $self->{gs_close}, \&OnClose );
125    # Required for GTK
126    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_thumbnail}, \&OnPaneChanged );
127    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize}, \&OnPaneChanged );
128    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_resize_advanced}, \&OnPaneChanged );
129    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd}, \&OnPaneChanged );
130    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_hd_advanced}, \&OnPaneChanged );
131    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_watermark}, \&OnPaneChanged );
132    Wx::Event::EVT_COLLAPSIBLEPANE_CHANGED( $self, $self->{cpane_transfert_advanced}, \&OnPaneChanged );
133
134
135}
136
137
138sub OnClose {
139    my ( $self, $event ) = @_;
140   
141    $self->_close;
142}
143
144sub _close {
145    my ( $self ) = @_;
146
147
148    $self->Hide;
149}
150
151
152sub OnDefaultPhotoCaption {
153    my ( $self, $event ) = @_;
154   
155    $self->_DefautPhotoCaption(
156        $event->GetId
157    );
158
159    $event->Skip(1);
160}
161
162# Display prefix textfield when needed
163sub _DefautPhotoCaption {
164    my ( $self, $id ) = @_;
165
166    my $b=0;
167    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
168        if ( $self->properties->{$id}
169            ->{string_selection}->() =~ /caption/i ){
170            $b=1;
171        }
172    }
173
174    map {
175        $self->FindWindow($_)->Show($b)
176    }(
177        $main::PHOTO_CAPTION_PREFIX,
178        $main::GS_PHOTO_CAPTION_PREFIX
179    );
180}
181
182sub OnCreateResized {
183    my ( $self, $event ) = @_;
184   
185    my $id = $event->GetId;
186    my $b = 1;
187    if('CODE' eq ref $self->properties->{$id}->{selection}){
188        $b = !$self->properties->{$id}->{selection}->()
189    }
190
191    $self->{cpane_resize}->Collapse($b);
192
193    $event->Skip(1);
194
195}
196
197
198sub OnHDUpload {
199    my ( $self, $event ) = @_;
200   
201
202    my $id = $event->GetId;
203    my $b = 1;
204    if('CODE' eq ref $self->properties->{$id}->{string_selection}){
205        if ( $self->properties->{$id}
206            ->{string_selection}->() =~ /resized/){
207            $b = 0;
208        }
209    }
210    $self->{cpane_hd}->Collapse($b);
211
212    $event->Skip(1);
213}
214
215sub OnWatermark {
216    my ( $self, $event ) = @_;
217   
218    my $id = $event->GetId;
219    my $b = 1;
220    if('CODE' eq ref $self->properties->{$id}->{value}){
221        $b = !$self->properties->{$id}->{value}->()
222    }
223
224    $self->{cpane_watermark}->Collapse($b);
225
226    $event->Skip(1);
227}
228
229sub OnPaneChanged {
230    my( $self, $event ) = @_;
231
232    $self->Layout;
233    $event->Skip(1);
234}
235
236
237sub GlobalSetting_ToolBook {
238    my( $parent ) = $_[0];
239    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
240   
241    my( $tbook ) = Wx::Toolbook->new( $parent, $main::ID_NOTEBOOK, wxDefaultPosition, [-1,-1], wxBK_LEFT  );
242
243    my $imgl = Wx::ImageList->new( 16, 16 );
244
245    map {
246        $imgl->Add(
247            Wx::Bitmap->new( wxTheApp->resource_path($_), wxBITMAP_TYPE_PNG )
248        )
249    } qw/picture_edit.png pictures.png picture_key.png picture_go.png world.png/;
250
251    $tbook->AssignImageList($imgl);
252
253    my( $item3 ) = Wx::Panel->new( $tbook, -1 );
254    &main::GS_photo_properties( $item3, 0 );
255    $tbook->AddPage( $item3, gettext("Photo properties"), 0, 0 );
256
257    my( $item4 ) = Wx::Panel->new( $tbook, -1 );
258    &main::GS_photo_preparation( $item4, 0 );
259    $tbook->AddPage( $item4, gettext("Photo size"), 0, 1 );
260
261    my( $item5 ) = Wx::Panel->new( $tbook, -1 );
262    &main::GS_photo_watermark( $item5, 0 );
263    $tbook->AddPage( $item5, gettext("Watermark"), 0, 2 );
264
265    my( $item6 ) = Wx::Panel->new( $tbook, -1 );
266    &main::GS_photo_transfer( $item6, 0 );
267    $tbook->AddPage( $item6, gettext("Transfer"), 0, 3 );
268
269    my( $item7 ) = Wx::Panel->new( $tbook, -1 );
270    &main::GS_language( $item7, 0 );
271    $tbook->AddPage( $item7, gettext("Language choice"), 0, 4 );
272
273
274    $topsizer->Add( $tbook, 0, wxALIGN_CENTER|wxALL, 5 );
275
276
277    my( $item87 ) = Wx::BoxSizer->new( wxVERTICAL );
278   
279    my( $item88 ) = Wx::StaticLine->new( $parent, -1, wxDefaultPosition, [20,-1], wxLI_HORIZONTAL );
280    $item87->AddWindow( $item88, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
281
282    my( $item89 ) = Wx::Button->new( $parent, $main::GS_CLOSE, gettext("Close"), wxDefaultPosition, wxDefaultSize, 0 );
283    $item87->AddWindow( $item89, 0, wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
284
285    $topsizer->Add( $item87, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
286
287
288    $_[0]->SetSizerAndFit( $topsizer );
289
290
291
292    $topsizer;
293}
294
295
2961;
Note: See TracBrowser for help on using the repository browser.