Changeset 12427
- Timestamp:
- 09/02/10 06:00:44 (18 months ago)
- Location:
- trunk/Padre
- Files:
-
- 2 edited
-
Changes (modified) (1 diff)
-
lib/Padre/Wx/Dialog/Replace.pm (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/Changes
r12424 r12427 25 25 - Fix MIME type setting via menu (ZENOG) 26 26 - mark nl_be as not supported (ZENOG) 27 - partial fix for #452: 'focus order in Replace dialog' (ZENOG) 27 28 28 29 0.69 2010.08.17 -
trunk/Padre/lib/Padre/Wx/Dialog/Replace.pm
r12251 r12427 2 2 3 3 =pod 4 5 4 =head1 NAME 6 7 5 Padre::Wx::Dialog::Replace - Find and Replace Widget 8 9 6 =head1 DESCRIPTION 10 11 7 C<Padre::Wx:Main> implements Padre's Find and Replace dialog box. 12 13 8 =head1 METHODS 14 15 9 =cut 16 10 … … 24 18 use Padre::Wx::Role::Main (); 25 19 use Padre::Wx::History::ComboBox (); 26 27 20 our $VERSION = '0.69'; 28 21 our @ISA = qw{ … … 32 25 33 26 =pod 34 35 27 =head2 new 36 37 28 my $find = Padre::Wx::Dialog::Replace->new($main); 38 39 29 Create and return a C<Padre::Wx::Dialog::Replace> search and replace widget. 40 41 =cut 30 =cut 31 42 32 43 33 sub new { … … 149 139 $self, 150 140 Wx::wxID_FIND, 151 Wx::gettext( "&Find"),141 Wx::gettext('&Find'), 152 142 ); 153 143 Wx::Event::EVT_BUTTON( … … 158 148 } 159 149 ); 160 Wx::Event::EVT_ CHAR(150 Wx::Event::EVT_KEY_DOWN( 161 151 $self->{find_button}, 162 152 sub { 163 $self->hotkey( $_[1] ->GetKeyCode);153 $self->hotkey( $_[1], $self->{find_button} ); 164 154 } 165 155 ); 166 156 167 157 # The "Replace" button 168 $self->{replace } = Wx::Button->new(158 $self->{replace_button} = Wx::Button->new( 169 159 $self, 170 160 Wx::wxID_REPLACE, 171 Wx::gettext( "&Replace"),161 Wx::gettext('&Replace'), 172 162 ); 173 163 Wx::Event::EVT_BUTTON( 174 164 $self, 175 $self->{replace },165 $self->{replace_button}, 176 166 sub { 177 167 $_[0]->replace_button; 178 168 } 179 169 ); 180 Wx::Event::EVT_ CHAR(181 $self->{replace },182 sub { 183 $self->hotkey( $_[1] ->GetKeyCode);184 } 185 ); 186 $self->{replace }->SetDefault;170 Wx::Event::EVT_KEY_DOWN( 171 $self->{replace_button}, 172 sub { 173 $self->hotkey( $_[1], $self->{replace_button} ); 174 } 175 ); 176 $self->{replace_button}->SetDefault; 187 177 188 178 # The "Close" button 189 $self->{c ancel_button} = Wx::Button->new(179 $self->{close_button} = Wx::Button->new( 190 180 $self, 191 181 Wx::wxID_CANCEL, 192 Wx::gettext( "&Close"),182 Wx::gettext('&Close'), 193 183 ); 194 184 Wx::Event::EVT_BUTTON( 195 185 $self, 196 $self->{cancel_button}, 197 sub { 198 $_[0]->cancel_button; 199 } 200 ); 186 $self->{close_button}, 187 sub { 188 $_[0]->close_button; 189 } 190 ); 191 192 # Tab order 193 $self->{find_regex}->MoveAfterInTabOrder( $self->{find_text} ); 194 $self->{replace_text}->MoveAfterInTabOrder( $self->{find_regex} ); 195 $self->{find_case}->MoveAfterInTabOrder( $self->{replace_regex} ); 196 $self->{find_reverse}->MoveAfterInTabOrder( $self->{find_case} ); 197 $self->{find_first}->MoveAfterInTabOrder( $self->{find_reverse} ); 198 $self->{replace_all}->MoveAfterInTabOrder( $self->{find_first} ); 199 $self->{find_button}->MoveAfterInTabOrder( $self->{replace_all} ); 200 $self->{replace_button}->MoveAfterInTabOrder( $self->{find_button} ); 201 $self->{close_button}->MoveAfterInTabOrder( $self->{replace_button} ); 201 202 202 203 # Form Layout 203 204 204 # Find sizer begins here 205 205 my $find = Wx::StaticBoxSizer->new( … … 215 215 $self, 216 216 Wx::wxID_STATIC, 217 Wx::gettext( "Find Text:"),217 Wx::gettext('Find Text:'), 218 218 ), 219 219 0, … … 247 247 $self, 248 248 Wx::wxID_STATIC, 249 Wx::gettext( "Replace Text:"),249 Wx::gettext('Replace Text:'), 250 250 ), 251 251 0, … … 313 313 ); 314 314 $bottom->Add( 315 $self->{replace },315 $self->{replace_button}, 316 316 0, 317 317 Wx::wxGROW | Wx::wxLEFT | Wx::wxRIGHT, … … 319 319 ); 320 320 $bottom->Add( 321 $self->{c ancel_button},321 $self->{close_button}, 322 322 0, 323 323 Wx::wxGROW | Wx::wxLEFT, … … 363 363 $self->{find_first}->SetValue( $config->find_first ); 364 364 $self->{find_reverse}->SetValue( $config->find_reverse ); 365 366 365 return $self; 367 366 } 368 367 369 368 =pod 370 371 369 =head2 find 372 373 370 $self->find 374 375 371 Grab currently selected text, if any, and place it in find combo box. 376 372 Bring up the dialog or perform search for string's next occurrence 377 373 if dialog is already displayed. 378 379 374 TO DO: if selection is more than one line then consider it as the limit 380 375 of the search and not as the string to be used. 381 382 =cut 376 =cut 377 383 378 384 379 sub find { … … 396 391 $self->{find_text}->refresh; 397 392 $self->{replace_text}->refresh; 398 399 393 if ( $self->IsShown ) { 400 394 $self->find_button; … … 410 404 $self->Show(1); 411 405 } 412 413 406 return; 414 407 } 415 416 417 418 419 420 408 ###################################################################### 421 409 # Button Events 422 410 423 411 =pod 424 425 412 =head2 find_button 426 427 413 $self->find_button 428 429 414 Executed when Find button is clicked. 430 431 415 Performs search on the term specified in the dialog. 432 433 416 =cut 434 417 … … 441 424 my $search = $self->as_search; 442 425 unless ($search) { 443 $main->error( "Not a valid search");426 $main->error('Not a valid search'); 444 427 445 428 # Move the focus back to the search text … … 456 439 $self->Hide; 457 440 } 458 459 441 return; 460 442 } 461 443 462 444 =pod 463 464 =head2 cancel_button 465 466 $self->cancel_button 467 445 =head2 close_button 446 $self->close_button 468 447 Hide dialog when pressed cancel button. 469 470 =cut 471 472 sub c ancel_button {448 =cut 449 450 451 sub close_button { 473 452 my $self = shift; 474 453 $self->Hide; … … 483 462 $editor->SetFocus; 484 463 } 485 486 464 return; 487 465 } 488 466 489 467 =pod 490 491 468 =head2 replace_button 492 493 469 $self->replace_button; 494 495 470 Executed when the Replace button is clicked. 496 497 471 Replaces one appearance of the Find Text with the Replace Text. 498 499 472 If search window is still open, run C<search> on the whole text, 500 473 again. 501 502 =cut 474 =cut 475 503 476 504 477 # TO DO: The change to this function that turned it into a dual-purpose function … … 516 489 my $search = $self->as_search; 517 490 unless ($search) { 518 $main->error( "Not a valid search");491 $main->error('Not a valid search'); 519 492 520 493 # Move the focus back to the search text … … 541 514 # so they can change it if they want. 542 515 $self->{find_text}->SetFocus; 543 544 516 return; 545 517 } 546 518 547 519 =pod 548 549 520 =head2 replace_all 550 551 521 $self->replace_all; 552 553 522 Executed when Replace All button is clicked. 554 555 523 Replace all appearances of given string in the current document. 556 557 =cut 524 =cut 525 558 526 559 527 sub replace_all { … … 565 533 my $search = $self->as_search; 566 534 unless ($search) { 567 $main->error( "Not a valid search");535 $main->error('Not a valid search'); 568 536 return; 569 537 } … … 590 558 # so they can change it if they want. 591 559 $self->{find_text}->SetFocus; 592 593 560 return; 594 561 } 595 596 597 598 599 600 562 ##################################################################### 601 563 # Support Methods 602 564 603 565 =pod 604 605 566 =head2 as_search 606 607 567 Integration with L<Padre::Search>. Generates a search instance for the 608 568 currently configured information in the Find dialog. 609 610 569 Returns a L<Padre::Search> object, or C<undef> if current state of the 611 570 dialog does not result in a valid search. 612 613 571 =cut 614 572 … … 626 584 # Adds Ultraedit-like hotkeys for quick find/replace triggering 627 585 sub hotkey { 628 my $self = shift; 629 my $code = shift; 630 631 # Handle the 'f' hotkey 632 if ( $code == 102 ) { 586 my ( $self, $key_event, $sender ) = @_; 587 588 if ( $key_event->GetKeyCode == ord 'F' ) { 633 589 $self->find_button; 634 590 } 635 636 # Handle the 'r' hotkey 637 if ( $code == 114 ) { 591 if ( $key_event->GetKeyCode == ord 'R' ) { 638 592 $self->replace_button; 639 593 } 640 594 if ( $key_event->GetKeyCode == Wx::WXK_TAB ) { 595 596 #$sender->Navigate( $key_event->ShiftDown ? 0 : 1 ); 597 } 641 598 return; 642 599 } … … 648 605 my $config = $self->current->config; 649 606 my $changed = 0; 650 651 607 foreach my $name (qw{ find_case find_regex find_first find_reverse }) { 652 608 my $value = $self->{$name}->GetValue; … … 655 611 $changed = 1; 656 612 } 657 658 613 $config->write if $changed; 659 660 614 return $config; 661 615 } 662 663 616 1; 664 617 665 618 =pod 666 667 619 =head1 COPYRIGHT & LICENSE 668 669 620 Copyright 2008-2010 The Padre development team as listed in Padre.pm. 670 671 621 This program is free software; you can redistribute 672 622 it and/or modify it under the same terms as Perl itself. 673 674 623 The full text of the license can be found in the 675 624 LICENSE file included with this module. 676 677 =cut 625 =cut 626 678 627 679 628 # Copyright 2008-2010 The Padre development team as listed in Padre.pm.
Note: See TracChangeset
for help on using the changeset viewer.
