wxStyledTextCtrl Flags and other goodies:
Here's a quick example of how to specify where the wxStyledTextCtrl draws the 'collapsed' line, above or below the fold point. Also, how to get all the fold points to show in the margin.
class Editor(wxStyledTextCtrl): def __init__(self, parent, ID): wxStyledTextCtrl.__init__(self, parent, ID) # # Other initialization code goes here, but we'll skip to the interesting part # # Shows the line under folded text EXPANDED_LINE_ABOVE = 2 EXPANDED_LINE_BELOW = 8 COLLAPSED_LINE_ABOVE = 4 COLLAPSED_LINE_BELOW = 16 LINE_DEBUGGING = 64 self.SetFoldFlags( COLLAPSED_LINE_BELOW ) # If you want to see the fold markers for more than # the first level, you can some or all of the following flags: self.SetMarginMask(2, ( 1 << wxSTC_MARKNUM_FOLDER ) | \ ( 1 << wxSTC_MARKNUM_FOLDEROPEN ) | \ ( 1 << wxSTC_MARKNUM_FOLDEREND ) | \ ( 1 << wxSTC_MARKNUM_FOLDEROPENMID ) | \ ( 1 << wxSTC_MARKNUM_FOLDERMIDTAIL ) | \ ( 1 << wxSTC_MARKNUM_FOLDERTAIL ) | \ ( 1 << wxSTC_MARKNUM_FOLDERSUB ) ) # Now you can define the Folder mark styles... foldIconsFG = '#909090' foldIconsBG = '#FFFFFF' # Top Level Folders... self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_CIRCLEPLUS, foldIconsBG , foldIconsFG) # Collapsed self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_CIRCLEMINUS, foldIconsBG, foldIconsFG) # Expanded self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNERCURVE, foldIconsBG, foldIconsFG) # End of Top Level Folder # Nested Folders.... self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, foldIconsBG, foldIconsFG) # Collapsed self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, foldIconsBG, foldIconsFG) # Expanded self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNERCURVE, foldIconsBG, foldIconsFG) # End of Nested Folder # Inside of Folder Marker self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, foldIconsBG, foldIconsFG) # here are the different styles available: ## wxSTC_MARK_VLINE ## wxSTC_MARK_BOXPLUS ## wxSTC_MARK_BOXMINUS ## wxSTC_MARK_BOXPLUSCONNECTED ## wxSTC_MARK_BOXMINUSCONNECTED ## wxSTC_MARK_TCORNER ## wxSTC_MARK_LCORNER ## wxSTC_MARK_CIRCLEPLUS ## wxSTC_MARK_CIRCLEMINUS ## wxSTC_MARK_CIRCLEPLUSCONNECTED ## wxSTC_MARK_CIRCLEMINUSCONNECTED ## wxSTC_MARK_TCORNERCURVE ## wxSTC_MARK_LCORNERCURVE
- There is one little part of this little puzzle I can't seem to work out. The *CONNECTED styles don't seem to render quite right. They seem to be the same as their non-CONNECTED counterparts. For example, wxSTC_MARK_CIRCLEPLUS renders the exact same way as wxSTC_MARK_CIRCLEPLUSCONNECTED. If you figure it out, or know offhand, please add a comment. That small complaint aside, it works quite nicely.
Cheers,
- M@ [aka Darth APO]