Changeset 2297


Ignore:
Timestamp:
12/30/08 18:57:16 (3 years ago)
Author:
adamk
Message:

Shifting over to the relocale method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Wx/MainWindow.pm

    r2287 r2297  
    6565    }; 
    6666 
     67# NOTE: Yes this method does get a little large, but that's fine. 
     68#       It's better to have one bigger method that is easily 
     69#       understandable rather than scattering tightly-related code 
     70#       all over the place in unrelated places. 
     71#       If you feel the need to make this smaller, try to make each 
     72#       individual step tighter and better abstracted. 
    6773sub new { 
    6874    my $class  = shift; 
     
    127133    $self->{marker} = {}; 
    128134 
     135    # Create the menu bar 
     136    $self->{menu} = Padre::Wx::Menu->new($self); 
     137    $self->SetMenuBar( $self->menu->wx ); 
     138 
     139    # Create the tool bar 
     140    $self->SetToolBar( 
     141        Padre::Wx::ToolBar->new($self) 
     142    ); 
     143    $self->GetToolBar->Realize; 
     144 
    129145    # Create the status bar 
    130146    $self->{gui}->{statusbar} = Padre::Wx::StatusBar->new($self); 
    131  
    132     # create basic window components 
    133     $self->create_main_components; 
    134147 
    135148    $self->create_editor_pane; 
     
    211224sub create_main_components { 
    212225    my $self = shift; 
    213  
    214     # Create the menu bar 
    215     delete $self->{menu} if defined $self->{menu}; 
    216     $self->{menu} = Padre::Wx::Menu->new($self); 
    217     $self->SetMenuBar( $self->menu->wx ); 
    218226 
    219227    # Create the tool bar 
     
    483491# Refresh Methods 
    484492 
     493# The term and method "refresh" is reserved for fast, blocking, 
     494# real-time updates to the GUI. Enabling and disabling menu entries, 
     495# updating dynamic titles and status bars, and other rapid changes. 
    485496sub refresh { 
    486497    my $self = shift; 
     
    516527} 
    517528 
    518 sub change_style { 
    519     my $self = shift; 
    520     my $name = shift; 
    521  
    522     warn "Style: $name\n"; 
    523     Padre::Wx::Editor::data($name); 
    524     foreach my $editor ( $self->pages ) { 
    525         $editor->padre_setup; 
    526     } 
    527      
    528     return; 
    529 } 
    530  
    531 sub change_locale { 
    532     my $self = shift; 
    533     my $name = shift; 
    534  
    535     # Save the locale to the config 
    536     Padre->ide->config->{host}->{locale} = $name; 
    537  
    538     # Reset the locale 
    539     delete $self->{locale}; 
    540     $self->{locale} = Padre::Locale::object(); 
    541  
    542     # Refresh the interface with the new labels 
    543     $self->create_main_components; 
    544     $self->refresh; 
    545  
    546     # Replace the AUI component captions 
    547     $self->manager->GetPane('sidepane')->Caption( Wx::gettext("Subs") ); 
    548     $self->manager->GetPane('bottompane')->Caption( Wx::gettext("Output") ); 
    549  
    550     return; 
    551 } 
    552  
    553529sub refresh_syntaxcheck { 
    554530    my $self = shift; 
    555531    return if $self->no_refresh; 
    556532    return if not $self->menu->view->{show_syntaxcheck}->IsChecked; 
    557  
    558533    Padre::Wx::SyntaxChecker::on_syntax_check_timer( $self, undef, 1 ); 
    559  
    560534    return; 
    561535} 
     
    581555# TODO now on every ui chnage (move of the mouse) 
    582556# we refresh this even though that should not be 
    583 # necessary  
    584 # can that be eliminated ? 
     557# necessary can that be eliminated ? 
    585558sub refresh_methods { 
    586559    my $self = shift; 
     
    630603 
    631604##################################################################### 
     605# Interface Rebuilding Methods 
     606 
     607sub change_style { 
     608    my $self = shift; 
     609    Padre::Wx::Editor::data($_[0]); 
     610    foreach my $editor ( $self->pages ) { 
     611        $editor->padre_setup; 
     612    } 
     613    return; 
     614} 
     615 
     616sub change_locale { 
     617    my $self = shift; 
     618    my $name = shift; 
     619 
     620    # Save the locale to the config 
     621    Padre->ide->config->{host}->{locale} = $name; 
     622 
     623    # Reset the locale 
     624    delete $self->{locale}; 
     625    $self->{locale} = Padre::Locale::object(); 
     626 
     627    # Run the "relocale" process to update the GUI 
     628    $self->relocale; 
     629 
     630    # With language stuff updated, do a full refresh 
     631    # sweep to clean everything up. 
     632    $self->refresh; 
     633 
     634    return; 
     635} 
     636 
     637# The term and method "relocale" is reserved for functionality 
     638# intended to run when the application wishes to change locale 
     639# (and wishes to do so without restarting). 
     640sub relocale { 
     641    my $self = shift; 
     642 
     643    # The menu doesn't support relocale, replace it 
     644    delete $self->{menu}; 
     645    $self->{menu} = Padre::Wx::Menu->new($self); 
     646    $self->SetMenuBar( $self->menu->wx ); 
     647 
     648    # The toolbar doesn't support relocale, replace it 
     649    $self->SetToolBar( 
     650        Padre::Wx::ToolBar->new($self) 
     651    ); 
     652    $self->GetToolBar->Realize; 
     653 
     654    # Update window manager captions 
     655    $self->manager->relocale; 
     656 
     657    return; 
     658} 
     659 
     660 
     661 
     662 
     663 
     664##################################################################### 
    632665# Introspection 
    633666 
     
    654687 $editor->BeginUndoAction; 
    655688 $editor->EndUndoAction; 
    656  
    657689 
    658690=cut 
Note: See TracChangeset for help on using the changeset viewer.