Changeset 10473


Ignore:
Timestamp:
02/02/10 23:33:50 (2 years ago)
Author:
azawawi
Message:

More refactoring to the Regex Editor dialog UI & code. You can now see four non-functioning regex snippet buttons alongside the regex text control.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Wx/Dialog/RegexEditor.pm

    r10471 r10473  
    5656 
    5757 
    58 sub _regex_syntax { 
     58# 
     59# A private method that returns a hash of regex groups along with their meaning 
     60#  
     61sub _regex_groups { 
    5962    my $self = shift; 
    6063 
     
    147150 
    148151    $self->{menu} = Wx::Menu->new; 
    149 #   my %regex_syntax = $self->_regex_syntax; 
    150 #   foreach my $name (keys %regex_syntax) { 
    151 #       my %subgroup = $regex_syntax{$name}; 
     152    my %regex_groups = $self->_regex_groups; 
     153 
     154    foreach my $code (keys %regex_groups) { 
     155        my %sub_group = %{$regex_groups{$code}}; 
     156        $self->{$code} = Wx::Button->new( 
     157            $self, -1, $sub_group{label}, 
     158        ); 
    152159#       $self->{menu}->Append( -1, $subgroup{label} ); 
    153160#       $self->{menu}->AppendSeparator(); 
     
    157164#           $self->{menu}->AppendSeparator(); 
    158165#       } 
    159 #   } 
     166    } 
    160167#   Wx::Event::EVT_MENU( 
    161168#       $self, 
     
    165172#   ); 
    166173 
    167  
     174    # Matching radio button 
    168175    $self->{matching} = Wx::RadioButton->new( 
    169         $self, 
    170         -1, 
    171         'Matching', 
    172     ); 
     176        $self, -1, Wx::gettext('Matching'), 
     177    ); 
     178     
     179    # Substitution radio button 
    173180    $self->{substituting} = Wx::RadioButton->new( 
    174         $self, 
    175         -1, 
    176         'Substituting', 
    177     ); 
    178  
    179     $self->{button_menu} = Wx::Button->new( 
    180         $self, 
    181         -1, 
    182         Wx::gettext('&Insert'), 
    183     ); 
    184  
    185     # Close Button 
    186     $self->{button_close} = Wx::Button->new( 
    187         $self, 
    188         Wx::wxID_CANCEL, 
    189         Wx::gettext('&Close'), 
    190     ); 
    191  
     181        $self, -1, Wx::gettext('Substituting'), 
     182    ); 
     183 
     184    # Close button 
     185    $self->{close_button} = Wx::Button->new( 
     186        $self, Wx::wxID_CANCEL, Wx::gettext('&Close'), 
     187    ); 
    192188 
    193189    # Dialog Layout 
     
    204200    $operation->Add( $self->{matching},     0, Wx::wxALL, 1 ); 
    205201    $operation->Add( $self->{substituting}, 0, Wx::wxALL, 1 ); 
     202    $operation->AddStretchSpacer; 
     203 
     204    my $regex = Wx::BoxSizer->new(Wx::wxVERTICAL); 
     205    $regex->Add( 
     206        $self->{regex},  
     207        1,  
     208        Wx::wxALL | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND,  
     209        1 
     210    ); 
     211 
     212    my $regex_groups = Wx::BoxSizer->new(Wx::wxVERTICAL); 
     213    foreach my $code (keys %regex_groups) { 
     214        $regex_groups->Add( $self->{$code}, 0, Wx::wxEXPAND | Wx::wxALIGN_CENTER_HORIZONTAL, 1 ); 
     215    } 
     216     
     217    my $combined = Wx::BoxSizer->new(Wx::wxHORIZONTAL); 
     218    $combined->Add( $regex, 2, Wx::wxALL | Wx::wxEXPAND, 0 ); 
     219    $combined->Add( $regex_groups, 0, Wx::wxALL | Wx::wxEXPAND, 0 ); 
    206220 
    207221    # Vertical layout of the left hand side 
    208222    my $left = Wx::BoxSizer->new(Wx::wxVERTICAL); 
    209     $left->AddSpacer(3); 
    210     $left->Add( $modifiers,   0, Wx::wxALL | Wx::wxEXPAND, 1 ); 
    211     $left->Add( $operation,   0, Wx::wxALL | Wx::wxEXPAND, 1 ); 
    212     $left->Add( $self->{button_menu}, 0, Wx::wxALIGN_CENTER_HORIZONTAL, 1 ); 
    213     $left->Add( $regex_label, 0, Wx::wxALL | Wx::wxEXPAND, 1 ); 
    214     $left->Add( 
    215         $self->{regex}, 
    216         1, 
    217         Wx::wxALL | Wx::wxALIGN_TOP | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
    218         1 
    219     ); 
     223    $left->Add( $operation,   0, Wx::wxALL | Wx::wxEXPAND, 2 ); 
     224    $left->Add( $modifiers,   0, Wx::wxALL | Wx::wxEXPAND, 2 ); 
     225    $left->AddSpacer(5); 
     226    $left->Add( $regex_label, 0, Wx::wxALL | Wx::wxEXPAND, 1 );  
     227    $left->Add( $combined,   0, Wx::wxALL | Wx::wxEXPAND, 2 ); 
     228     
    220229    $left->Add( $substitute_label, 0, Wx::wxALL | Wx::wxEXPAND, 1 ); 
    221230    $left->Add( 
    222231        $self->{substitute}, 
    223232        1, 
    224         Wx::wxALL | Wx::wxALIGN_TOP | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
     233        Wx::wxALL | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
    225234        1 
    226235    ); 
     
    231240        $self->{original_text}, 
    232241        1, 
    233         Wx::wxALL | Wx::wxALIGN_TOP | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
     242        Wx::wxALL | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
    234243        1 
    235244    ); 
     
    238247        $self->{matched_text}, 
    239248        1, 
    240         Wx::wxALL | Wx::wxALIGN_TOP | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
     249        Wx::wxALL | Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxEXPAND, 
    241250        1 
    242251    ); 
    243252    $left->AddSpacer(5); 
    244     $left->Add( $self->{button_close}, 0, Wx::wxALIGN_CENTER_HORIZONTAL, 1 ); 
     253    $left->Add( $self->{close_button}, 0, Wx::wxALIGN_CENTER_HORIZONTAL, 1 ); 
    245254 
    246255    # Main sizer 
     
    251260    my $self = shift; 
    252261 
    253     Wx::Event::EVT_BUTTON( 
    254         $self, 
    255         $self->{button_menu}, 
    256         sub { 
    257             my ($self, $event) = @_; 
    258             $self->PopupMenu( $self->{menu}, 0, 0 ); 
    259         } 
    260     ); 
    261262    Wx::Event::EVT_TEXT( 
    262263        $self, 
     
    300301 
    301302 
     303# 
     304# A private method that returns a hash of regex modifiers 
     305# 
    302306sub _modifiers { 
    303307    my $self = shift; 
Note: See TracChangeset for help on using the changeset viewer.