Ignore:
Timestamp:
Mar 11, 2010, 6:15:33 PM (14 years ago)
Author:
ronosman
Message:

Feature 1496 added : display a message in the photo selection when it is empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r5041 r5104  
    2323use Wx::DND;
    2424use POSIX qw(ceil floor);
     25use Wx::Locale qw/:default/;
    2526use Wx qw/
    2627             wxDefaultPosition
     
    4748             wxIMAGE_LIST_SMALL
    4849             wxTheApp
     50             wxVERTICAL
     51             wxALIGN_CENTER
     52             wxHORIZONTAL
     53             wxALIGN_CENTER_VERTICAL
     54             wxALIGN_CENTER_HORIZONTAL
     55             wxALL
     56             wxGROW
     57             wxWHITE
     58             wxSWISS
     59             wxNORMAL
     60             wxBOLD
     61             wxBITMAP_TYPE_PNG
    4962         /;
    5063use Wx::Event qw/
     
    8396        -1,
    8497        wxDefaultPosition,
    85         [ 180, -1],
     98        [ -1, -1],
    8699    );
    87100   
     
    110123
    111124    $self->prevItemCount(-1);
     125
    112126
    113127    EVT_LIST_BEGIN_DRAG( $self, $self, \&OnBeginDrag);
     
    135149                $self->Refresh;
    136150                $self->change_display_mode(0);
    137         }
    138         $event->Skip;
    139         }
    140     );
     151            }
     152            $event->Skip;
     153        }
     154    );
     155
     156    # manages empty panel position
     157    Wx::Event::EVT_PAINT( $self, sub {
     158            my ( $self, $event ) = @_;
     159            if(exists $self->{_empty_panel}){
     160                my ($w, $h) = $self->GetSizeWH;
     161                my ($x, $y) = $self->GetPositionXY;
     162                my ($wp, $hp) = $self->{_empty_panel}->GetSizeWH;
     163                my $x_off = ($w-$wp)/3 > 0 ? ($w-$wp)/3 : 0;
     164                my $y_off = ($h-$hp)/3 > 0 ? ($h-$hp)/3 : 0;
     165                $self->{_empty_panel}->Move(
     166                    [ $x+$x_off, $y+$y_off ]
     167                );
     168            }
     169            $event->Skip;
     170        }
     171    );
     172
    141173   
    142174    $self->initialize(
     
    353385}
    354386
     387sub OnEmpty {
     388    my ( $self ) = @_;
     389
     390    $self->_OnEmptyLayout;
     391
     392}
     393
     394sub OnNotEmpty {
     395    my ( $self ) = @_;
     396
     397    $self->{_empty_panel}->Show(0) if exists $self->{_empty_panel};
     398}
     399
     400sub _OnEmptyLayout {
     401
     402    my( $self ) = @_;
     403    $self->{_empty_panel}->Show(1);
     404
     405}
     406
     407sub add_button {
     408    my ( $self ) = @_;
     409
     410    $self->{_add_bt};
     411}
     412
     413sub InitEmptyMsg {
     414
     415    my ( $self ) = @_;
     416    # add a panel
     417    my $empty_panel = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize);
     418    my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     419   
     420    my $fb = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxBOLD );
     421    my $fn = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxNORMAL );
     422
     423    my( $item1 ) = Wx::StaticText->new( $empty_panel, -1, gettext("Drag photos here to get started"), wxDefaultPosition, wxDefaultSize, 0 );
     424    $item1->SetFont($fb);
     425    $item0->AddWindow( $item1, 0, wxALIGN_CENTER|wxALL, 5 );
     426
     427    my( $item2 ) = Wx::BoxSizer->new( wxHORIZONTAL );
     428   
     429    my( $item3 ) = Wx::StaticText->new( $empty_panel, -1, gettext("Or click"), wxDefaultPosition, wxDefaultSize, 0 );
     430    $item3->SetFont($fn);
     431    $item2->AddWindow( $item3, 0, wxALIGN_CENTER|wxALL, 5 );
     432
     433    my $icon1 = Wx::Icon->new();
     434    eval {
     435        $icon1->LoadFile(
     436            wxTheApp->resource_path('tb_add.png'),
     437            wxBITMAP_TYPE_PNG
     438        );
     439    };
     440    my $bmp = Wx::Bitmap->new( $icon1 );
     441
     442    my( $item4 ) = Wx::BitmapButton->new( $empty_panel, -1, $bmp, wxDefaultPosition, wxDefaultSize );
     443    $item2->AddWindow( $item4, 0, wxALIGN_CENTER|wxALL, 5 );
     444
     445    my( $item5 ) = Wx::StaticText->new( $empty_panel, -1, gettext("to choose files on your computer"), wxDefaultPosition, wxDefaultSize, 0 );
     446    $item5->SetFont($fn);
     447    $item2->AddWindow( $item5, 0, wxALIGN_CENTER|wxALL, 5 );
     448
     449    $item0->Add( $item2, 0, wxALIGN_CENTER|wxALL, 0 );
     450
     451    $empty_panel->SetSizer( $item0 );
     452    $item0->SetSizeHints( $empty_panel );
     453
     454    $self->{_empty_panel} = $empty_panel;
     455    $self->{_add_bt} = $item4;
     456    $self->{_empty_panel}->SetBackgroundColour(wxWHITE);
     457
     458    my ($wp, $hp) = $self->{_empty_panel}->GetSizeWH;
     459
     460    $self->SetMinSize( [20+$wp, -1 ]);
     461
     462}
     463
     464
     465
    3554661;
    356467
Note: See TracChangeset for help on using the changeset viewer.