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

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

Fix global_settings sizing issues.

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