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
RevLine 
[4571]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
[4718]26            wxDEFAULT_DIALOG_STYLE
27            wxCAPTION
28            wxCLOSE_BOX
29            wxMAXIMIZE_BOX
30            wxMINIMIZE_BOX
31            wxRESIZE_BORDER
32            wxSTAY_ON_TOP
[4727]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
[4738]44            wxBK_LEFT
45            wxHORIZONTAL
[4571]46        /;
[4718]47use base qw/Wx::Dialog Uploader::GUI::DlgCommon/;
[4727]48use Wx::Locale qw/:default/;
[4571]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
[4718]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
[4571]80    $self->{tags} = $params->{tags};
81    $self->{orientation} = $params->{orientation}||wxVERTICAL;
82
83    # load controls
[4732]84    GlobalSetting_ToolBook($self, 1);
[4571]85
86    $self->properties(
87        $params->{properties}
88    );
[4589]89
90
[4732]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);
[4718]98    $self->{gs_close} = $self->FindWindow($main::GS_CLOSE);
99
[4571]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
[4738]114    # Force layout an paint : awful but works
115    $self->{cpane_hd}->Collapse(0);
116    $self->{cpane_hd}->Collapse(1);
117
[4571]118    $self;   
119}
120
121
122
123sub _initEventHandlers {
124    my ( $self ) = @_;
125   
[4718]126    Wx::Event::EVT_BUTTON( $self, $self->{gs_close}, \&OnClose );
[4571]127
[4738]128
[4571]129}
130
131
132sub OnClose {
133    my ( $self, $event ) = @_;
134   
135    $self->_close;
136}
137
138sub _close {
139    my ( $self ) = @_;
140
141
[4718]142    $self->Hide;
[4571]143}
144
145
146sub OnDefaultPhotoCaption {
147    my ( $self, $event ) = @_;
148   
149    $self->_DefautPhotoCaption(
150        $event->GetId
151    );
152
153    $event->Skip;
154}
155
[4727]156# Display prefix textfield when needed
[4571]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}){
[4589]182        $b = !$self->properties->{$id}->{selection}->()
[4571]183    }
184
185    $self->{cpane_resize}->Collapse($b);
[4727]186
[4571]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);
[4727]205
[4571]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);
[4727]219
[4571]220    $event->Skip;
221}
222
223
[4727]224sub GlobalSetting_ToolBook {
225    my( $parent ) = $_[0];
[4738]226    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
[4727]227   
[4738]228    my( $tbook ) = Wx::Toolbook->new( $parent, $main::ID_NOTEBOOK, wxDefaultPosition, [-1,-1], wxBK_LEFT  );
[4727]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
[4738]238    $tbook->AssignImageList($imgl);
[4727]239
[4738]240    my( $item3 ) = Wx::Panel->new( $tbook, -1 );
[4727]241    &main::GS_photo_properties( $item3, 0 );
[4738]242    $tbook->AddPage( $item3, gettext("Photo properties"), 0, 0 );
[4727]243
[4738]244    my( $item4 ) = Wx::Panel->new( $tbook, -1 );
[4727]245    &main::GS_photo_preparation( $item4, 0 );
[4738]246    $tbook->AddPage( $item4, gettext("Photo size"), 0, 1 );
[4727]247
[4738]248    my( $item5 ) = Wx::Panel->new( $tbook, -1 );
[4727]249    &main::GS_photo_watermark( $item5, 0 );
[4738]250    $tbook->AddPage( $item5, gettext("Watermark"), 0, 2 );
[4727]251
[4738]252    my( $item6 ) = Wx::Panel->new( $tbook, -1 );
[4727]253    &main::GS_photo_transfer( $item6, 0 );
[4738]254    $tbook->AddPage( $item6, gettext("Transfer"), 0, 3 );
[4727]255
256
[4738]257    $topsizer->Add( $tbook, 0, wxALIGN_CENTER|wxALL, 5 );
258
259
[4727]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
[4738]268    $topsizer->Add( $item87, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
[4727]269
270
[4738]271    $_[0]->SetSizerAndFit( $topsizer );
272
273
274
275    $topsizer;
[4727]276}
277
278
[4571]2791;
Note: See TracBrowser for help on using the repository browser.