Changeset 2257


Ignore:
Timestamp:
12/29/08 21:18:05 (3 years ago)
Author:
adamk
Message:

Move the status bar out into it's own encapsulated class

Location:
trunk/Padre/lib/Padre/Wx
Files:
1 added
1 edited

Legend:

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

    r2256 r2257  
    3333use Padre::Wx                 (); 
    3434use Padre::Wx::Editor         (); 
     35use Padre::Wx::Output         (); 
    3536use Padre::Wx::ToolBar        (); 
    36 use Padre::Wx::Output         (); 
     37use Padre::Wx::StatusBar      (); 
    3738use Padre::Wx::ErrorList      (); 
    3839use Padre::wx::AuiManager     (); 
     
    106107    $self->{locale} = Padre::Locale::object(); 
    107108 
     109    # Drag and drop support 
    108110    $self->SetDropTarget( 
    109111        Padre::Wx::FileDropTarget->new($self) 
     
    114116    $self->{_methods} = []; 
    115117 
     118    # Temporary store for the notebook tab history 
     119    # TODO: Storing this here (might) violate encapsulation. 
     120    #       It should probably be in the notebook object. 
     121    $self->{page_history} = []; 
     122 
    116123    # Set the window manager 
    117124    $self->{manager} = Padre::Wx::AuiManager->new($self); 
     
    120127    $self->{marker} = {}; 
    121128 
    122     $self->{page_history} = []; 
     129    # Create the status bar 
     130    $self->{gui}->{statusbar} = Padre::Wx::StatusBar->new($self); 
    123131 
    124132    # create basic window components 
     
    153161        my $mod  = $event->GetModifiers || 0; 
    154162        my $code = $event->GetKeyCode; 
    155          
     163 
    156164        # remove the bit ( Wx::wxMOD_META) set by Num Lock being pressed on Linux 
    157165        $mod = $mod & (Wx::wxMOD_ALT() + Wx::wxMOD_CMD() + Wx::wxMOD_SHIFT()); 
     
    215223    $self->GetToolBar->Realize; 
    216224 
    217     # Create the status bar 
    218     unless ( defined $self->{gui}->{statusbar} ) { 
    219         $self->{gui}->{statusbar} = $self->CreateStatusBar( 1, Wx::wxST_SIZEGRIP|Wx::wxFULL_REPAINT_ON_RESIZE ); 
    220         $self->{gui}->{statusbar}->SetFieldsCount(4); 
    221         $self->{gui}->{statusbar}->SetStatusWidths(-1, 100, 50, 100); 
    222     } 
    223  
    224     return; 
    225 } 
    226  
     225    return; 
     226} 
    227227 
    228228sub create_editor_pane { 
     
    562562 
    563563sub refresh_status { 
    564     my ($self) = @_; 
     564    my $self = shift; 
    565565    return if $self->no_refresh; 
    566  
    567     my $pageid = $self->nb->GetSelection(); 
    568     if (not defined $pageid or $pageid == -1) { 
    569         $self->SetStatusText("", $_) for (0..3); 
    570         return; 
    571     } 
    572     my $editor       = $self->nb->GetPage($pageid); 
    573     my $doc          = Padre::Documents->current or return; 
    574     my $line         = $editor->GetCurrentLine; 
    575     my $filename     = $doc->filename || ''; 
    576     my $newline_type = $doc->get_newline_type || Padre::Util::NEWLINE; 
    577     my $modified     = $editor->GetModify ? '*' : ' '; 
    578  
    579     if ($filename) { 
    580         $self->nb->SetPageText($pageid, $modified . File::Basename::basename $filename); 
    581     } else { 
    582         my $text = substr($self->nb->GetPageText($pageid), 1); 
    583         $self->nb->SetPageText($pageid, $modified . $text); 
    584     } 
    585  
    586     my $pos   = $editor->GetCurrentPos; 
    587     my $start = $editor->PositionFromLine($line); 
    588     my $char  = $pos-$start; 
    589  
    590     $self->SetStatusText("$modified $filename",             0); 
    591  
    592     my $charWidth = $self->{gui}->{statusbar}->GetCharWidth; 
    593     my $mt = $doc->get_mimetype; 
    594     my $curPos = Wx::gettext('L:') . ($line + 1) . ' ' . Wx::gettext('Ch:') . $char; 
    595  
    596     $self->SetStatusText($mt,           1); 
    597     $self->SetStatusText($newline_type, 2); 
    598     $self->SetStatusText($curPos,       3); 
    599  
    600     # since charWidth is an average we adjust the values a little 
    601     $self->{gui}->{statusbar}->SetStatusWidths( 
    602         -1, 
    603         (length($mt)           - 1) * $charWidth, 
    604         (length($newline_type) + 2) * $charWidth, 
    605         (length($curPos)       + 1) * $charWidth 
    606     );  
    607  
    608     return; 
     566    $self->GetStatusBar->refresh; 
    609567} 
    610568 
     
    19831941 
    19841942    my $editor = $self->selected_editor; 
    1985     #$editor->SetEOLMode( $mode{$newline_type} ); 
    19861943    $editor->ConvertEOLs( $Padre::Wx::Editor::mode{$newline_type} ); 
    19871944 
Note: See TracChangeset for help on using the changeset viewer.