Changeset 860
- Timestamp:
- 11/09/08 14:49:52 (3 years ago)
- Location:
- trunk/lib/Padre/Wx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Padre/Wx/Editor.pm
r858 r860 172 172 173 173 $self->SetMarginWidth(1, 0); 174 $self->SetMarginWidth(2, 0);174 #$self->SetMarginWidth(2, 0); 175 175 176 176 # premature optimization, caching the with that was on the 3rd place at load time … … 190 190 } 191 191 192 # Just a placeholder 193 sub show_symbols { 194 my ( $self, $on ) = @_; 195 196 $self->SetMarginWidth(1, 0); 197 198 # $self->SetMarginWidth(1, 16); #margin 1 for symbols, 16 px wide 199 # $self->SetMarginType(1, Wx::wxSTC_MARGIN_SYMBOL); 200 201 return; 202 } 203 204 sub show_folding { 205 my ( $self, $on ) = @_; 206 207 if ( $on ) { 208 # Setup a margin to hold fold markers 209 $self->SetMarginType(2, Wx::wxSTC_MARGIN_SYMBOL); # margin number 2 for symbols 210 $self->SetMarginMask(2, Wx::wxSTC_MASK_FOLDERS); # set up mask for folding symbols 211 $self->SetMarginSensitive(2, 1); # this one needs to be mouse-aware 212 $self->SetMarginWidth(2, 16); # set margin 2 16 px wide 213 214 # define folding markers 215 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDEREND, Wx::wxSTC_MARK_BOXPLUSCONNECTED, Wx::Colour->new("white"), Wx::Colour->new("black")); 216 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDEROPENMID, Wx::wxSTC_MARK_BOXMINUSCONNECTED, Wx::Colour->new("white"), Wx::Colour->new("black")); 217 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDERMIDTAIL, Wx::wxSTC_MARK_TCORNER, Wx::Colour->new("white"), Wx::Colour->new("black")); 218 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDERTAIL, Wx::wxSTC_MARK_LCORNER, Wx::Colour->new("white"), Wx::Colour->new("black")); 219 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDERSUB, Wx::wxSTC_MARK_VLINE, Wx::Colour->new("white"), Wx::Colour->new("black")); 220 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDER, Wx::wxSTC_MARK_BOXPLUS, Wx::Colour->new("white"), Wx::Colour->new("black")); 221 $self->MarkerDefine(Wx::wxSTC_MARKNUM_FOLDEROPEN, Wx::wxSTC_MARK_BOXMINUS, Wx::Colour->new("white"), Wx::Colour->new("black")); 222 223 # activate 224 $self->SetProperty('fold' => 1); 225 226 Wx::Event::EVT_STC_MARGINCLICK( 227 $self, 228 Wx::wxID_ANY, 229 sub { 230 my ( $editor, $event ) = @_; 231 if ( $event->GetMargin() == 2 ) { 232 my $line_clicked = $editor->LineFromPosition( $event->GetPosition() ); 233 my $level_clicked = $editor->GetFoldLevel($line_clicked); 234 # TODO check this (cf. ~/contrib/samples/stc/edit.cpp from wxWidgets) 235 #if ( $level_clicked && wxSTC_FOLDLEVELHEADERFLAG) > 0) { 236 $editor->ToggleFold($line_clicked); 237 #} 238 } 239 } 240 ); 241 } 242 else { 243 $self->SetMarginSensitive(2, 0); 244 $self->SetMarginWidth(2, 0); 245 # deactivate 246 $self->SetProperty('fold' => 1); 247 } 248 249 return; 250 } 251 192 252 sub set_preferences { 193 253 my ($self) = @_; … … 196 256 197 257 $self->show_line_numbers( $config->{editor_linenumbers} ); 258 $self->show_folding( $config->{editor_codefolding} ); 198 259 $self->SetIndentationGuides( $config->{editor_indentationguides} ); 199 260 $self->SetViewEOL( $config->{editor_eol} ); -
trunk/lib/Padre/Wx/MainWindow.pm
r858 r860 1312 1312 } 1313 1313 1314 sub on_toggle_code_folding { 1315 my ($self, $event) = @_; 1316 1317 my $config = Padre->ide->config; 1318 $config->{editor_codefolding} = $event->IsChecked ? 1 : 0; 1319 1320 foreach my $editor ( $self->pages ) { 1321 $editor->show_folding( $config->{editor_codefolding} ); 1322 } 1323 1324 return; 1325 } 1326 1314 1327 sub on_toggle_indentation_guide { 1315 1328 my $self = shift; -
trunk/lib/Padre/Wx/Menu.pm
r858 r860 298 298 $menu->{view_lines}, 299 299 \&Padre::Wx::MainWindow::on_toggle_line_numbers, 300 ); 301 $menu->{view_folding} = $menu->{view}->AppendCheckItem( -1, gettext("Show code folding") ); 302 Wx::Event::EVT_MENU( $win, 303 $menu->{view_folding}, 304 \&Padre::Wx::MainWindow::on_toggle_code_folding, 300 305 ); 301 306 $menu->{view_eol} = $menu->{view}->AppendCheckItem( -1, gettext("Show Newlines") ); … … 578 583 # Setup menu state from configuration 579 584 $menu->{view_lines}->Check( $config->{editor_linenumbers} ? 1 : 0 ); 585 $menu->{view_folding}->Check( $config->{editor_codefolding} ? 1 : 0 ); 580 586 $menu->{view_eol}->Check( $config->{editor_eol} ? 1 : 0 ); 581 587 unless ( Padre::Util::WIN32 ) {
Note: See TracChangeset
for help on using the changeset viewer.
