Changeset 5184 for extensions/pLoader/trunk/src
- Timestamp:
- Mar 19, 2010, 6:50:48 AM (15 years ago)
- Location:
- extensions/pLoader/trunk/src/Uploader
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm
r5041 r5184 46 46 'Wx::CheckBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHECKBOX( $ctrl, $ctrl, sub { $self->OnCheckBox(@_) } ); }, 47 47 'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); }, 48 'Wx::ComboBox' => sub { my ( $ctrl ) = @_; 49 Wx::Event::EVT_COMBOBOX( $ctrl, $ctrl, sub { $self->OnComboBox(@_) } ); 50 Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } ); 51 }, 48 52 }; 49 53 … … 83 87 84 88 89 sub OnComboBoxText { 90 my ( $self, $ctrl, $event ) = @_; 91 92 if( exists $ctrl->{_value}){ 93 $event->Skip(1); 94 } 95 else{ 96 my $id = $ctrl->GetId; 97 # change the property value 98 $self->properties->{$id}->{value}->( 99 $event->GetString 100 ) if exists $self->properties->{$id}->{value}; 101 102 # exec the callback 103 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 104 $self->properties->{$id}->{frame_callback}; 105 } 106 107 } 108 109 85 110 # what does happen when the text changes 86 111 sub OnTextCtrl { … … 97 122 $self->properties->{$id}->{frame_callback}; 98 123 99 $event->Skip;100 124 } 101 125 … … 163 187 $event->Skip; 164 188 } 189 190 191 sub OnComboBox { 192 my ( $self, $ctrl, $event ) = @_; 193 194 my $id = $ctrl->GetId; 195 196 $ctrl->{_multi_selection_mode} = $self->properties->{$id}->{multi_selection_mode}->() 197 if exists $self->properties->{$id}->{multi_selection_mode}; 198 199 my $selection = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection; 200 201 my $value = $self->properties->{$id}->{pre_process}->( $selection ) if exists 202 $self->properties->{$id}->{pre_process}; 203 204 if( exists $self->properties->{$id}->{value} ){ 205 $value = $self->properties->{$id}->{value}->( 206 $value, 207 $selection, 208 ); 209 # the item selected in the list is not the real value 210 # we place here the actual value 211 # to use in EVT_IDLE event, and overwrite the text field with it 212 $ctrl->{_value} = $value; 213 } 214 215 # exec the callback 216 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 217 $self->properties->{$id}->{frame_callback}; 218 } 219 165 220 166 221 sub OnDatePicker { … … 196 251 $ctrl->SetValue($date); 197 252 }, 253 'Wx::ComboBox' => sub { 254 my ($ctrl, $value ) = @_; 255 $ctrl->SetValue($value) ; 256 }, 198 257 }; 199 258 … … 210 269 my $ctrl =$self->FindWindow($_); 211 270 if(defined $ctrl){ 271 #printf("%s\n", $ctrl); 212 272 # checkbox, static text 213 273 $change_value->{ref $ctrl}->( … … 269 329 my ( $self ) = @_; 270 330 271 331 map { 272 332 my $ctrl =$self->FindWindow($_); 273 333 #printf("ctrl %s : %s\n", $_, $ctrl); -
extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm
r5155 r5184 309 309 { 310 310 $main::CAPTION => { label=>gettext("Caption")}, 311 $main::PHOTO_PROPERTIES_CAPTION => { 311 $main::PHOTO_PROPERTIES_CAPTION => { 312 multi_selection_mode => sub { $self->multi_selection_mode }, 313 string_selection => sub { return 1; }, 312 314 value => sub { 315 $self->imagelist->SetImageSelectionName(@_); 313 316 $self->multi_selection_mode ? 314 $self->imagelist-> SetImageSelectionName(@_):315 $self->imagelist->current_image->site_name (@_)317 $self->imagelist->image_selection_name : 318 $self->imagelist->current_image->site_name; 316 319 }, 320 pre_process => sub { sub { $self->imagelist->GetCurrentImageDefaultName(@_); } }, 321 choices => 322 [ 323 map { gettext $_ } @{wxTheApp->default_photo_names} 324 ], 317 325 frame_callback => sub { $self->imageviewer_item_refresh(1); }, 318 326 }, -
extensions/pLoader/trunk/src/Uploader/GUI/Layout/PhotoPropertiesCategoriesTags.pm
r5122 r5184 12 12 use Wx qw( wxALIGN_RIGHT wxALIGN_BOTTOM wxALIGN_CENTER wxALIGN_CENTER_VERTICAL wxALIGN_CENTER_HORIZONTAL ); 13 13 use Wx qw( wxTR_HAS_BUTTONS wxTR_LINES_AT_ROOT wxSUNKEN_BORDER wxLI_HORIZONTAL wxTE_MULTILINE ); 14 use Wx qw( wxDP_DROPDOWN );14 use Wx qw( wxDP_DROPDOWN wxCB_READONLY); 15 15 16 16 # Bitmap functions … … 117 117 my $topsizer = Wx::BoxSizer->new( wxVERTICAL ); 118 118 119 $topsizer->Add( 120 TextField(119 $topsizer->Add( 120 ComboField( 121 121 $parent, 122 122 $main::CAPTION, … … 314 314 } 315 315 316 317 sub ComboField { 318 my ( $parent, $id_label, $id_ctrl, $expand ) = @_; 319 320 $expand ||=0; 321 322 my( $sizer ) = Wx::BoxSizer->new( wxVERTICAL ); 323 324 $expand||=0; 325 326 $sizer->Add( 327 Wx::StaticText->new( 328 $parent, 329 $id_label, 330 "text", 331 wxDefaultPosition, 332 wxDefaultSize, 333 0 334 ), 335 0, 336 wxALL, 337 1 338 ); 339 340 my $ctrl = Wx::ComboBox->new( 341 $parent, 342 $id_ctrl, 343 "", 344 wxDefaultPosition, 345 [-1,-1], 346 [], 347 348 ); 349 350 # the EVT_COMBOBOX has set _value if we need to overwrite the default 351 # text. The list contains function names. We want to have the value returned by the function 352 # in the text field 353 Wx::Event::EVT_IDLE( 354 $ctrl, 355 sub { 356 my ( $ctrl, $event ) = @_; 357 if(exists $ctrl->{_value}){ 358 $ctrl->SetValue($ctrl->{_value}) if !$ctrl->{_multi_selection_mode}; 359 delete $ctrl->{_value}; 360 delete $ctrl->{_multi_selection_mode}; 361 } 362 } 363 ); 364 365 366 $sizer->Add( 367 $ctrl, 368 $expand, 369 wxEXPAND|wxALL, 370 1 371 ); 372 373 374 375 $sizer; 376 } 377 378 316 379 sub _multi_selection_mode_panel_layout{ 317 380 my ( $panel ) = @_; … … 335 398 336 399 } 400 401 1; 402 -
extensions/pLoader/trunk/src/Uploader/ImageList.pm
r5155 r5184 30 30 use Digest::MD5::File qw/file_md5_hex md5_hex/; 31 31 use Wx::Locale qw/:default/; 32 use Wx ;32 use Wx qw/wxTheApp/; 33 33 34 34 # this class implements a collection of image files with associated data … … 342 342 } 343 343 344 sub GetCurrentImageDefaultName { 345 my ( $self, $index, $pattern ) = @_; 346 347 $pattern = wxTheApp->eng_default_photo_names->{$pattern}; 348 349 $self->SetCurrentImage($index); 350 351 my $img = $self->current_image; 352 353 $self->_photo_name_from_pattern( 354 $img->file, 355 $img->create_date, 356 $index, 357 $pattern 358 ); 359 } 344 360 345 361 sub _default_photo_name { 346 362 my ( $self, $file, $info, $i ) = @_; 347 348 363 364 my $create_date = $info->{CreateDate}; 365 366 367 $self->_photo_name_from_pattern($file, $create_date, $i, $self->default_photo_name); 368 } 369 370 371 sub _photo_name_from_pattern { 372 my ( $self, $file, $create_date, $i, $pattern ) = @_; 373 374 my ( $yyyy, $mm, $dd, $hh, $mi, $ss ) = split /[:\s]/, $create_date ; 375 376 my $chrono = join('', $yyyy, $mm, $dd); 377 349 378 my $name; 350 my $create_date = $info->{CreateDate};351 379 my $ext; 352 380 my ( $vol, $path, $filename ) = File::Spec->splitpath($file); 353 381 ( $filename, $ext ) = split /\.\w+$/, $filename; 354 382 355 my ( $yyyy, $mm, $dd, $hh, $mi, $ss ) = split /[:\s]/, $create_date ; 356 357 my $chrono = join('', $yyyy, $mm, $dd); 358 if('Prefix' eq $self->default_photo_name){ 383 384 if('Prefix' eq $pattern){ 359 385 $name = $self->default_name_prefix 360 386 } 361 elsif('File name' eq $ self->default_photo_name){387 elsif('File name' eq $pattern){ 362 388 $name = $filename 363 389 } 364 elsif('File path and name' eq $ self->default_photo_name){390 elsif('File path and name' eq $pattern){ 365 391 $name = sprintf( 366 392 "%s", … … 368 394 ) 369 395 } 370 elsif('Prefix + rank number' eq $ self->default_photo_name){396 elsif('Prefix + rank number' eq $pattern){ 371 397 $name = sprintf( 372 398 "%s%s", … … 375 401 ) 376 402 } 377 elsif('Rank number + prefix' eq $ self->default_photo_name){403 elsif('Rank number + prefix' eq $pattern){ 378 404 $name = sprintf( 379 405 "%s%s", … … 382 408 ) 383 409 } 384 elsif('Prefix + create date chrono' eq $ self->default_photo_name){410 elsif('Prefix + create date chrono' eq $pattern){ 385 411 $name = sprintf( 386 412 "%s%s", … … 389 415 ) 390 416 } 391 elsif('Create date chrono + prefix' eq $ self->default_photo_name){417 elsif('Create date chrono + prefix' eq $pattern){ 392 418 $name = sprintf( 393 419 "%s%s", … … 1422 1448 $self->image_selection_tags($tags) if 'ARRAY' eq ref $tags; 1423 1449 1424 #print Dumper $self->image_selection_tags;1425 1450 # append to each image 1426 1451 # if multiple selection … … 1466 1491 } 1467 1492 1493 1468 1494 sub SetImageSelectionName { 1469 my ( $self, $name ) = @_; 1470 1471 # append to each image 1472 # if multiple selection 1473 if($self->multi_selection_mode){ 1474 if(defined $name){ 1475 $self->image_selection_name($name); 1476 map { 1477 $self->GetImage($_)->site_name( 1478 $name 1479 ) ; 1480 }@{$self->image_selection} 1481 }; 1482 } 1483 1484 $self->image_selection_name; 1495 my ( $self, $name, $param ) = @_; 1496 1497 # works in single and multi selection mode 1498 if(defined $name){ 1499 map { 1500 my $_name = 'CODE' eq ref $name ? 1501 $name->($_, $param) : 1502 $name; 1503 $self->image_selection_name($_name); 1504 1505 $self->GetImage($_)->site_name( 1506 $_name 1507 ) ; 1508 }@{$self->image_selection} 1509 } 1485 1510 } 1486 1511
Note: See TracChangeset
for help on using the changeset viewer.