Changeset 4800 for extensions/pLoader


Ignore:
Timestamp:
Jan 30, 2010, 5:13:16 AM (14 years ago)
Author:
ronosman
Message:

Photo properties layout management. Use adaptive sizes with stretch factors.

Location:
extensions/pLoader/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/res/photo_properties_with_categories_tags_wdr.pl

    r4793 r4800  
    1 #-----------------------------------------------------------------------------
    2 # Perl source generated by wxDesigner from file: photo_properties_with_categories_tags.wdr
    3 # Do not modify this file, all changes will be lost!
    4 #-----------------------------------------------------------------------------
    5 
    61use Wx;
    72use Wx::Calendar;
    83use Wx::DateTime;
    9 use Wx::Grid;
    104use strict;
    115
     
    159use Wx qw( wxDefaultSize wxDefaultPosition wxNullAnimation wxNullFont wxBLACK );
    1610use Wx qw( wxID_OK wxID_APPLY wxID_SAVE wxID_SAVEAS wxID_CANCEL wxID_YES wxID_NO wxID_EXIT wxID_ABOUT wxID_HELP );
    17 use Wx qw( wxVERTICAL wxHORIZONTAL wxALL wxLEFT wxRIGHT wxTOP wxBOTTOM wxCENTRE wxGROW );
     11use Wx qw( wxVERTICAL wxHORIZONTAL wxALL wxLEFT wxRIGHT wxTOP wxBOTTOM wxCENTRE wxGROW wxEXPAND);
    1812use Wx qw( wxALIGN_RIGHT wxALIGN_BOTTOM wxALIGN_CENTER wxALIGN_CENTER_VERTICAL wxALIGN_CENTER_HORIZONTAL );
    1913use Wx qw( wxTR_HAS_BUTTONS wxTR_LINES_AT_ROOT wxSUNKEN_BORDER wxLI_HORIZONTAL wxTE_MULTILINE );
     
    3226
    3327sub PhotoPropertiesCategoriesTags {
    34     my( $parent ) = $_[0];
    35     my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     28    my( $parent ) = @_;
     29    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
    3630   
    3731    my( $item2 ) = Wx::Notebook->new( $parent, $main::PHOTO_PROPERTIES_NB, wxDefaultPosition, [400,160], 0 );
     
    4135    }
    4236   
    43     $item0->Add( $item1, 2, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     37    # the notebook has adaptive size : stretch factor 2, wxEXPAND
     38    $topsizer->Add( $item1, 2, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    4439
    4540    my( $item3 ) = Wx::TreeCtrl->new( $parent, $main::PHOTO_PROPERTIES_CATEGORIES, wxDefaultPosition, [120,160], wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT|wxSUNKEN_BORDER );
    46     $item0->AddWindow( $item3, 1, wxGROW|wxALL, 5 );
     41    # the notebook has adaptive size : stretch factor 1, wxEXPAND
     42    $topsizer->AddWindow( $item3, 1, wxGROW|wxALL, 5 );
    4743
    4844    my( $item4 ) = Wx::StaticLine->new( $parent, $main::ID_LINE, wxDefaultPosition, [20,-1], wxLI_HORIZONTAL );
    49     $item0->AddWindow( $item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     45    $topsizer->AddWindow( $item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    5046
    5147    my( $item5 ) = Wx::Button->new( $parent, $main::PHOTO_PROPERTIES_UPLOAD, "", wxDefaultPosition, [-1,40], 0 );
    52     $item0->AddWindow( $item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     48    $topsizer->AddWindow( $item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    5349
    54     my( $set_size ) = @_ >= 3 ? $_[2] : 1;
    55     my( $call_fit ) = @_ >= 2 ? $_[1] : 1;
    56     if( $set_size == 1 ) {
    57          $_[0]->SetSizer( $item0 );
    58          
    59          if( $call_fit == 1 ) {
    60              $item0->SetSizeHints( $_[0] );
    61          }
    62     }
    63    
    64     $item0;
     50    $parent->SetSizer( $topsizer );
     51    $topsizer->SetSizeHints( $parent );
     52
     53    $topsizer;
    6554}
    6655
     
    6958
    7059sub photo_properties_tags {
    71     my( $parent ) = $_[0];
    72     my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     60    my( $parent, $tags ) = @_;
     61    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
    7362   
    7463    my( $item1 ) = Wx::StaticText->new( $parent, $main::TAGS, "text", wxDefaultPosition, wxDefaultSize, 0 );
    75     $item0->AddWindow( $item1, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
     64    $topsizer->AddWindow( $item1, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
    7665
    77     my $tags = $_[1];
    78 $tags->{parentwnd}=$parent;
    79 my( $item2 ) = Uploader::GUI::wxChoiceFilteredPanel->new($tags);
    80     $item0->AddWindow( $item2, 0, wxALIGN_CENTER_VERTICAL, 5 );
     66    $tags->{parentwnd}=$parent;
     67    my( $panel ) = Uploader::GUI::wxChoiceFilteredPanel->new($tags);
     68    # the panel has adaptive size : stretch factor 1, wxEXPAND
     69    $topsizer->AddWindow( $panel, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    8170
    82     my( $set_size ) = @_ >= 3 ? $_[2] : 1;
    83     my( $call_fit ) = @_ >= 2 ? $_[1] : 1;
    84     if( $set_size == 1 ) {
    85          $_[0]->SetSizer( $item0 );
    86          
    87          if( $call_fit == 1 ) {
    88              $item0->SetSizeHints( $_[0] );
    89          }
    90     }
     71    $parent->SetSizer( $topsizer );
     72    $topsizer->SetSizeHints( $parent );
    9173   
    92     $item0;
     74    $topsizer;
    9375}
    9476
     
    10587
    10688sub photo_properties_caption_comments {
    107     my( $parent ) = $_[0];
    108     my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     89    my( $parent ) = @_;
     90    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
    10991   
    11092    my( $item1 ) = Wx::BoxSizer->new( wxVERTICAL );
     
    11395    $item1->AddWindow( $item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    11496
    115     my( $item3 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CAPTION, "", wxDefaultPosition, [300,-1], 0 );
    116     $item1->AddWindow( $item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     97    my( $item3 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CAPTION, "", wxDefaultPosition, [-1,-1], 0 );
     98    $item1->AddWindow( $item3, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    11799
    118     $item0->Add( $item1, 0, 0, 5 );
     100    $topsizer->Add( $item1, 0, wxEXPAND, 5 );
    119101
    120102    my( $item4 ) = Wx::BoxSizer->new( wxVERTICAL );
     
    123105    $item4->AddWindow( $item5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    124106
    125     my( $item6 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_AUTHOR, "", wxDefaultPosition, [300,-1], 0 );
    126     $item4->AddWindow( $item6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     107    my( $item6 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_AUTHOR, "", wxDefaultPosition, [-1,-1], 0 );
     108    $item4->AddWindow( $item6, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    127109
    128110    my( $item7 ) = Wx::StaticText->new( $parent, $main::COMMENT, "text", wxDefaultPosition, wxDefaultSize, 0 );
    129111    $item4->AddWindow( $item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    130112
    131     my( $item8 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_COMMENT, "", wxDefaultPosition, [300,50], wxTE_MULTILINE );
    132     $item4->AddWindow( $item8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     113    # adaptive size : stretch factor 1
     114    # the textctrl has a variable line number
     115    my( $item8 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_COMMENT, "", wxDefaultPosition, [-1,-1], wxTE_MULTILINE );
     116    $item4->AddWindow( $item8, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    133117
    134118    my( $item9 ) = Wx::StaticText->new( $parent, $main::CREATE_DATE, "text", wxDefaultPosition, wxDefaultSize, 0 );
     
    137121    my( $item10 ) = Wx::DatePickerCtrl->new( $parent, $main::PHOTO_PROPERTIES_CREATE_DATE, Wx::DateTime->new(), wxDefaultPosition, [200,-1], wxDP_DROPDOWN );
    138122    $item4->AddWindow( $item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    139 
    140     $item0->Add( $item4, 0, 0, 0 );
     123    # adaptive size : stretch factor 3
     124    $topsizer->Add( $item4, 3, wxEXPAND, 5 );
    141125
    142126    my( $item11 ) = Wx::BoxSizer->new( wxVERTICAL );
     
    145129    $item11->AddWindow( $item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    146130
    147     my( $item13 ) = Wx::Choice->new( $parent, $main::PHOTO_PROPERTIES_PRIVACY_LEVEL, wxDefaultPosition, [300,-1], [], 0 );
    148     $item11->AddWindow( $item13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     131    my( $item13 ) = Wx::Choice->new( $parent, $main::PHOTO_PROPERTIES_PRIVACY_LEVEL, wxDefaultPosition, [-1,-1], [], 0 );
     132    $item11->AddWindow( $item13, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    149133
    150     $item0->Add( $item11, 1, Wx::wxALIGN_TOP, 5 );
     134    # adaptive size : stretch factor 1
     135    $topsizer->Add( $item11, 1, wxEXPAND, 5 );
    151136
    152     my( $set_size ) = @_ >= 3 ? $_[2] : 1;
    153     my( $call_fit ) = @_ >= 2 ? $_[1] : 1;
    154     if( $set_size == 1 ) {
    155          $_[0]->SetSizer( $item0 );
    156          
    157          if( $call_fit == 1 ) {
    158              $item0->SetSizeHints( $_[0] );
    159          }
    160     }
     137    $parent->SetSizer( $topsizer );
     138    $topsizer->SetSizeHints( $parent );
    161139   
    162     $item0;
     140    $topsizer;
    163141}
    164 
    165 # Menu bar functions
    166 
    167 
    168 # Toolbar functions
    169142
    170143use Wx qw( wxITEM_NORMAL wxITEM_RADIO wxITEM_CHECK );
    171144
    172 
    173 # End of generated file
  • extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm

    r4779 r4800  
    3030             wxTE_PROCESS_ENTER
    3131             wxRA_SPECIFY_ROWS
     32             wxGROW
     33             wxEXPAND
    3234         /;
    3335
     
    5254        search_result
    5355        previous_autocompleted
    54                 autocomplete_from
    55                 autocomplete_to
    56                 autocomplete_set_selection
     56        autocomplete_from
     57        autocomplete_to
     58        autocomplete_set_selection
    5759      /
    5860);
    59 
    60 use Wx::Event qw(EVT_CHECKLISTBOX EVT_LISTBOX EVT_SEARCHCTRL_SEARCH_BTN EVT_SEARCHCTRL_CANCEL_BTN
    61                  EVT_TEXT EVT_TEXT_ENTER EVT_IDLE EVT_RADIOBOX);
    6261
    6362
     
    7473    $self->Refresh;
    7574
    76     EVT_CHECKLISTBOX( $self, $self->listchoices, \&OnCheck );
    77     EVT_LISTBOX( $self, $self->listchoices, \&OnSelected );
    78     EVT_SEARCHCTRL_SEARCH_BTN( $self, $self->search, \&OnSearch );
    79     EVT_SEARCHCTRL_CANCEL_BTN( $self, $self->search, \&OnCancel );
    80     EVT_TEXT( $self, $self->search, \&OnSearch );
    81     EVT_TEXT_ENTER( $self, $self->search, \&OnSearchEnter );
    82     EVT_RADIOBOX( $self, $self->btn_show, \&OnShow );
    83         # fix for linux : can not call SetSelection before the current event is processed.
    84         # call when idle
    85         EVT_IDLE(
    86             $self,
    87                 sub {
    88                     my ($self, $event)=@_;
    89                         $self->search->SetSelection(
    90                             $self->autocomplete_from,
    91                             $self->autocomplete_to
    92                         ) if $self->autocomplete_set_selection;
    93                         $self->autocomplete_set_selection(0);
    94                 }
    95         );
     75    Wx::Event::EVT_CHECKLISTBOX( $self, $self->listchoices, \&OnCheck );
     76    Wx::Event::EVT_LISTBOX( $self, $self->listchoices, \&OnSelected );
     77    Wx::Event::EVT_SEARCHCTRL_SEARCH_BTN( $self, $self->search, \&OnSearch );
     78    Wx::Event::EVT_SEARCHCTRL_CANCEL_BTN( $self, $self->search, \&OnCancel );
     79    Wx::Event::EVT_TEXT( $self, $self->search, \&OnSearch );
     80    Wx::Event::EVT_TEXT_ENTER( $self, $self->search, \&OnSearchEnter );
     81    Wx::Event::EVT_RADIOBOX( $self, $self->btn_show, \&OnShow );
     82    # fix for linux : can not call SetSelection before the current event is processed.
     83    # call when idle
     84    Wx::Event::EVT_IDLE(
     85        $self,
     86        sub {
     87            my ($self, $event)=@_;
     88            $self->search->SetSelection(
     89                $self->autocomplete_from,
     90                $self->autocomplete_to
     91            ) if $self->autocomplete_set_selection;
     92            $self->autocomplete_set_selection(0);
     93        }
     94    );
    9695
    9796    $self;
     
    9998
    10099sub _init_properties {
    101     my ( $self, $params ) = @_; 
    102        
     100    my ( $self, $params ) = @_;   
     101   
    103102    $self->choices(
    104103        $params->{choices}|| sub { [] }
     
    132131
    133132sub _init_panel {
    134     my ( $self ) = @_; 
     133    my ( $self ) = @_;   
    135134
    136135    my( $vsizer ) = Wx::BoxSizer->new( wxVERTICAL );
    137136   
    138137    $self->search(
    139         Wx::SearchCtrl->new( $self, -1, "", wxDefaultPosition, [320,-1],wxTE_PROCESS_ENTER )
     138        Wx::SearchCtrl->new( $self, -1, "", wxDefaultPosition, [-1,-1],wxTE_PROCESS_ENTER )
    140139    );
    141140
    142141    $self->search->ShowCancelButton( 1 );
    143142
    144     $vsizer->AddWindow( $self->search, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
     143    $vsizer->AddWindow( $self->search, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
    145144
    146145    $self->btn_show(
    147         Wx::RadioBox->new( $self, -1, sprintf("%s :", gettext("Show")), wxDefaultPosition, [320, -1],
     146        Wx::RadioBox->new( $self, -1, sprintf("%s :", gettext("Show")), wxDefaultPosition, [-1, -1],
    148147            [gettext("All"),gettext("Selected"),gettext("Not selected")] , 1, wxRA_SPECIFY_ROWS )
    149148    );
    150     $vsizer->AddWindow( $self->btn_show, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
     149    $vsizer->AddWindow( $self->btn_show, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
    151150
    152151
    153152    $self->listchoices(
    154         Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [320,200], [], 0 )
    155     );
    156     $vsizer->AddWindow( $self->listchoices, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
     153        Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [-1,-1], [], 0 )
     154    );
     155    $vsizer->AddWindow( $self->listchoices, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
    157156
    158157    $self->SetSizer( $vsizer );
     158    $vsizer->SetSizeHints( $self );
    159159         
    160     $vsizer->SetSizeHints( $self );
    161160}
    162161
     
    164163    my ( $self, $choices ) = @_;
    165164
    166         $self->listchoices->Freeze;
     165    $self->listchoices->Freeze;
    167166    $self->listchoices->Clear;
    168167    $self->id_lookup({});
     
    174173    #print Dumper $self->properties;
    175174    map {
    176         $self->listchoices->Append(
    177             $_->{name},
    178         );
     175        $self->listchoices->Append(
     176            $_->{name},
     177        );
    179178        $self->id_lookup->{$row} = $_->{id};
    180179        $self->row_lookup->{$_->{id}} = $row;
    181180        $self->id_from_name->{$_->{name}} = $_->{id};
    182         $row++;
     181        $row++;   
    183182    }@{$choices};
    184         $self->listchoices->Thaw;
     183    $self->listchoices->Thaw;
    185184
    186185}
     
    198197    $self->_init_choices($choices);
    199198    $self->SetSelection($selected);
    200        
     199   
    201200}
    202201
     
    209208    $self->listchoices->Freeze;
    210209    map {
    211         $self->listchoices->Check($row, 0) ;   
    212         $row++;
     210        $self->listchoices->Check($row, 0) ;   
     211        $row++;
    213212    }@$choices;
    214213    $self->listchoices->Thaw;
     
    224223    $self->listchoices->Freeze;
    225224    map {
    226         $self->listchoices->Check(
    227             $self->row_lookup->{$_},
    228             exists $self->row_lookup->{$_},
    229         ) if defined $self->row_lookup->{$_};
    230         $self->is_selected->{$_} = 1;   
    231     }
    232     @{$selection};     
     225        $self->listchoices->Check(
     226            $self->row_lookup->{$_},
     227            exists $self->row_lookup->{$_},
     228        ) if defined $self->row_lookup->{$_};
     229        $self->is_selected->{$_} = 1;   
     230    }
     231    @{$selection};   
    233232    $self->listchoices->Thaw;
    234233}
     
    244243           
    245244        my $id = $self->id_lookup->{$row};
    246         $self->is_selected->{$id} = $self->listchoices->IsChecked($row) ;       
    247         $row++;
     245        $self->is_selected->{$id} = $self->listchoices->IsChecked($row) ;   
     246        $row++;
    248247    }@$choices;
    249248
    250249    [
    251250        grep { $self->is_selected->{$_} } keys %{$self->is_selected}
    252     ]; 
     251    ];   
    253252}
    254253
     
    258257    $self->selection->(
    259258        $self->GetSelection
    260     ); 
     259    );   
    261260}
    262261
     
    321320
    322321sub _refresh_selected_searched {
    323     my ( $self, $searched ) = @_;       
     322    my ( $self, $searched ) = @_;       
    324323
    325324    $self->Refresh;
     
    348347    # autocompletion
    349348    if(1== scalar @{$self->search_result}){
    350         my $value = $self->search_result->[0]->{name};
    351         unless(  $value eq $self->previous_autocompleted ){
    352             $self->autocomplete_from(
    353                             $self->search->GetLastPosition
    354                     );
    355             $self->search->ChangeValue($value);
    356             $self->autocomplete_to(
    357                             $self->search->GetLastPosition
    358                     );
    359             $self->autocomplete_set_selection(1);
    360             $self->previous_autocompleted($value);
    361         }       
     349        my $value = $self->search_result->[0]->{name};
     350        unless(  $value eq $self->previous_autocompleted ){
     351            $self->autocomplete_from(
     352                $self->search->GetLastPosition
     353            );
     354            $self->search->ChangeValue($value);
     355            $self->autocomplete_to(
     356                $self->search->GetLastPosition
     357            );
     358            $self->autocomplete_set_selection(1);
     359            $self->previous_autocompleted($value);
     360        }   
    362361    }
    363362    else{
    364         $self->previous_autocompleted(undef);
    365     }
    366        
    367         $event->Skip;
     363        $self->previous_autocompleted(undef);
     364    }
     365   
     366    $event->Skip;
    368367}
    369368
     
    389388
    390389sub _show_notselected {
    391     my ( $self ) = @_; 
     390    my ( $self ) = @_;   
    392391
    393392    $self->Refresh(
     
    397396
    398397sub _show_selected {
    399     my ( $self ) = @_; 
     398    my ( $self ) = @_;   
    400399
    401400    $self->Refresh(
     
    405404
    406405sub _show_all {
    407     my ( $self ) = @_; 
     406    my ( $self ) = @_;   
    408407
    409408    $self->Refresh(
     
    418417    [
    419418        grep { $self->is_selected->{$_->{id}} } @$choices
    420     ]   
     419    ]   
    421420}
    422421
     
    427426    [
    428427        grep { !$self->is_selected->{$_->{id}} } @$choices
    429     ]   
     428    ]   
    430429}
    431430
Note: See TracChangeset for help on using the changeset viewer.