Wx-Demo

 view release on metacpan or  search on metacpan

lib/Wx/DemoModules/wxToolBar.pm  view on Meta::CPAN

        return;
    }
    $t->EnableTool( wxID_OPEN, !$t->GetToolEnabled( wxID_OPEN ) );
}

sub DoDeleteOpen {
    my( $this ) = @_;
    my $t = $this->GetToolBar;
    unless( $t->FindById( wxID_OPEN ) ) {
        $this->textctrl->WriteText( "No tool\n" );
        return;
    }
    $t->DeleteTool( wxID_OPEN );
}

sub DoToggleQuotes {
    my( $this ) = @_;
    my $t = $this->GetToolBar;

    $t->ToggleTool( $ID_QUOTES, !$t->GetToolState( $ID_QUOTES ) );
}

sub OnInsertOpen {
    my( $this, $event ) = @_;
    my $t = $this->GetToolBar;
    my $bmp = BITMAP( 'fileopen' );
    $t->InsertTool( 0, wxID_OPEN, $bmp, wxNullBitmap,
                    0, undef, 'Delete this tool',
                    'This button was inserted into the toolbar'
                    );
    $t->Realize;
}

sub RecreateToolbar {
    my( $this ) = @_;
    my $t = $this->GetToolBar;
    $t->Destroy if $t;
    $this->SetToolBar( undef );

    my( $style ) =
      ( $this->horizontal_toolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL ) |
        wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE;
    $t = $this->CreateToolBar( $style, $ID_TOOLBAR );
    $t->SetMargins( 4, 4 );

    my( @bitmaps ) = map { BITMAP( $_ ) } qw(fileopen filesave fuzzy quotes);
    if( !$this->small_toolbar ) {
        my( $w, $h ) = ( $bitmaps[0]->GetWidth * 2,
                         $bitmaps[0]->GetHeight * 2 );
        @bitmaps =
            map { Wx::Bitmap->new( Wx::Image->new( $_ )->Scale( $w, $h ) ) }
                @bitmaps;
        $t->SetToolBitmapSize( [ $w, $h ] );
    }

    my $width = ( Wx::wxMSW() ) ? 24 : 16;
    $t->AddTool( wxID_SAVE, $bitmaps[1], wxNullBitmap, 0, undef, 'Open File' );
    if( $this->horizontal_toolbar ) {
        my $c = Wx::ComboBox->new
            ( $t, $ID_COMBO, '', wxDefaultPosition, wxDefaultSize,
              [ 'This', 'is a', 'combobox', 'in a', 'toolbar' ] );
        $t->AddControl( $c );
    }
    $t->AddTool( -1, $bitmaps[2], wxNullBitmap, 1, undef,
                     'Toggle button 1' );
    $t->AddSeparator;
    $t->AddTool( $ID_QUOTES, $bitmaps[3], wxNullBitmap, 1, undef,
                 'Toggle button 1' );

    $t->Realize;
}

sub OnCombo {
    my( $this, $event ) = @_;

    Wx::LogStatus( "ComboBox string '%s' selected", $event->GetString );
}

sub OnToolEnter {
    my( $this, $event ) = @_;

    if( $event->GetSelection > -1 ) {
        $this->SetStatusText( sprintf 'This is tool number %d',
                              $event->GetSelection );
    } else {
        $this->SetStatusText( '' );
    }
}

sub add_to_tags { qw(controls) }
sub title { 'wxToolBar' }

1;



( run in 0.514 second using v1.01-cache-2.11-cpan-2398b32b56e )