Changeset 10476

Show
Ignore:
Timestamp:
02/03/10 00:01:33 (6 months ago)
Author:
azawawi
Message:

regex-helper-menu buttons are now working. Only need now to activate their action.

Files:
1 modified

Legend:

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

    r10475 r10476  
    6363 
    6464        return ( 
    65                 '01' => { 
     65                '00' => { 
    6666                        label => Wx::gettext('Character Classes'), 
    6767                        value => { 
    68                                 '.'  => Wx::gettext('Any character except a newline'), 
    69                                 '\d' => Wx::gettext('Any decimal digit'), 
    70                                 '\D' => Wx::gettext('Any non-digit'), 
    71                                 '\s' => Wx::gettext('Any whitespace character'), 
    72                                 '\S' => Wx::gettext('Any non-whitespace character'), 
    73                                 '\w' => Wx::gettext('Any word character'), 
    74                                 '\W' => Wx::gettext('Any non-word character'), 
     68                                '00.'  => Wx::gettext('Any character except a newline'), 
     69                                '01\d' => Wx::gettext('Any decimal digit'), 
     70                                '02\D' => Wx::gettext('Any non-digit'), 
     71                                '03\s' => Wx::gettext('Any whitespace character'), 
     72                                '04\S' => Wx::gettext('Any non-whitespace character'), 
     73                                '05\w' => Wx::gettext('Any word character'), 
     74                                '06\W' => Wx::gettext('Any non-word character'), 
     75                        } 
     76                }, 
     77                '01' => { 
     78                        label => Wx::gettext('Quantifiers'), 
     79                        value => { 
     80                                '00*'     => Wx::gettext('Zero or more of the preceding block'), 
     81                                '01+'     => Wx::gettext('One or more of the preceding block'), 
     82                                '02?'     => Wx::gettext('Zero or one of the preceding block'), 
     83                                '03{m}'   => Wx::gettext('Exactly m of the preceding block'), 
     84                                '04{m,n}' => Wx::gettext('m to n of the preceding block'), 
    7585                        } 
    7686                }, 
    7787                '02' => { 
    78                         label => Wx::gettext('Quantifiers'), 
     88                        label => Wx::gettext('Miscellaneous'), 
    7989                        value => { 
    80                                 '*'     => Wx::gettext('Zero or more of the preceding block'), 
    81                                 '+'     => Wx::gettext('One or more of the preceding block'), 
    82                                 '?'     => Wx::gettext('Zero or one of the preceding block'), 
    83                                 '{m}'   => Wx::gettext('Exactly m of the preceding block'), 
    84                                 '{m,n}' => Wx::gettext('m to n of the preceding block'), 
     90                                '00|'   => Wx::gettext('Alternation'), 
     91                                '01[ ]' => Wx::gettext('Character set'), 
     92                                '02^'   => Wx::gettext('Beginning of line'), 
     93                                '03$'   => Wx::gettext('End of line'), 
     94                                '04\b'  => Wx::gettext('A word boundary'), 
     95                                '05\B'  => Wx::gettext('Not a word boundary'), 
    8596                        } 
    8697                }, 
    8798                '03' => { 
    88                         label => Wx::gettext('Miscellaneous'), 
    89                         value => { 
    90                                 '|'   => Wx::gettext('Alternation'), 
    91                                 '[ ]' => Wx::gettext('Character set'), 
    92                                 '^'   => Wx::gettext('Beginning of line'), 
    93                                 '$'   => Wx::gettext('End of line'), 
    94                                 '\b'  => Wx::gettext('A word boundary'), 
    95                                 '\B'  => Wx::gettext('Not a word boundary'), 
    96                         } 
    97                 }, 
    98                 '04' => { 
    9999                        label => Wx::gettext('Grouping constructs'), 
    100100                        value => { 
    101                                 '( )'   => Wx::gettext('A group'), 
    102                                 '(?: )' => Wx::gettext('Non-capturing group'), 
    103                                 '(?= )' => Wx::gettext('Positive lookahead assertion'), 
    104                                 '(?! )' => Wx::gettext('Negative lookahead assertion'), 
    105                                 '\n'    => Wx::gettext('Backreference to the nth group'), 
     101                                '00( )'   => Wx::gettext('A group'), 
     102                                '01(?: )' => Wx::gettext('Non-capturing group'), 
     103                                '02(?= )' => Wx::gettext('Positive lookahead assertion'), 
     104                                '03(?! )' => Wx::gettext('Negative lookahead assertion'), 
     105                                '04\n'    => Wx::gettext('Backreference to the nth group'), 
    106106                        } 
    107107                } 
     
    149149        } 
    150150 
    151         $self->{menu} = Wx::Menu->new; 
    152151        my %regex_groups = $self->_regex_groups; 
    153  
    154         foreach my $code ( keys %regex_groups ) { 
     152        foreach my $code ( sort keys %regex_groups ) { 
    155153                my %sub_group = %{ $regex_groups{$code} }; 
    156                 $self->{$code} = Wx::Button->new( 
     154                my $button_name = $code . '_button'; 
     155                $self->{$button_name} = Wx::Button->new( 
    157156                        $self, -1, $sub_group{label}, 
    158157                ); 
    159158 
    160                 #               $self->{menu}->Append( -1, $subgroup{label} ); 
    161                 #               $self->{menu}->AppendSeparator(); 
    162                 #               my $subgroup_value = $subgroup{value}; 
    163                 #               foreach my $name (keys %subgroup_value) { 
    164                 #                       my $menu_item = $self->{menu}->Append( -1, $subgroup_value{$name} ); 
    165                 #                       $self->{menu}->AppendSeparator(); 
    166                 #               } 
    167         } 
    168  
    169         #       Wx::Event::EVT_MENU( 
    170         #               $self, 
    171         #               $self->{menu}, 
    172         #               sub { 
    173         #               }, 
    174         #       ); 
     159                my $menu_name = $code . '_menu'; 
     160                $self->{$menu_name} = Wx::Menu->new; 
     161                my %sub_group_value = %{$sub_group{value}}; 
     162                foreach my $element (sort keys %sub_group_value) { 
     163                        my $label = $element; 
     164                        $label =~ s/^\d{2}//; 
     165                        $self->{$menu_name}->Append(  
     166                                -1, $label . "\t" . $sub_group_value{$element} ); 
     167                } 
     168        } 
    175169 
    176170        # Matching radio button 
     
    208202 
    209203        my $regex_groups = Wx::BoxSizer->new(Wx::wxVERTICAL); 
    210         foreach my $code ( keys %regex_groups ) { 
    211                 $regex_groups->Add( $self->{$code}, 0, Wx::wxEXPAND, 1 ); 
     204        foreach my $code ( sort keys %regex_groups ) { 
     205                my $button_name = $code . '_button'; 
     206                $regex_groups->Add( $self->{$button_name}, 0, Wx::wxEXPAND, 1 ); 
    212207        } 
    213208 
     
    240235sub _bind_events { 
    241236        my $self = shift; 
     237 
     238        my %regex_groups = $self->_regex_groups; 
     239        foreach my $code ( keys %regex_groups ) { 
     240                my %sub_group = %{ $regex_groups{$code} }; 
     241                my $button_name = $code . '_button'; 
     242                my $menu_name = $code . '_menu'; 
     243                Wx::Event::EVT_BUTTON( 
     244                        $self, 
     245                        $self->{$button_name}, 
     246                        sub { 
     247                                my @pos = $self->{$button_name}->GetPositionXY; 
     248                                my @size = $self->{$button_name}->GetSizeWH; 
     249                                $self->PopupMenu($self->{$menu_name}, $pos[0], $pos[1] + $size[1]); 
     250                        }, 
     251                ); 
     252        } 
     253 
     254        #       Wx::Event::EVT_MENU( 
     255        #               $self, 
     256        #               $self->{menu}, 
     257        #               sub { 
     258        #               }, 
     259        #       ); 
    242260 
    243261        Wx::Event::EVT_TEXT(