I want to add alternating background colors in my styledtextctrl
(while still using foreground colors for syntax highlighting) but I'm
not having any luck. Is there a simple way to do this?
What I have so far is one style for even numbered lines and one for
odd. These styles only have their background set. I can use these
styles and my lines are all appropriately colored. However, when I
make a second pass over the data to assign styles to colorize the
foreground for specific words (read: syntax coloring), these new
styles override the line styles even though they don't explicitly set
the background.
Since what you are wanting to do is line-oriented then using markers is probably a better idea than styles. Markers are usually a little shape in the margin, but one of the marker styles sets the background color of the line instead. Try using wx.stc.STC_MARK_BACKGROUND. Keep in mind that as lines are inserted or deleted the the marks on existing lines are moved around with the lines, so you'll probably need to be able to reset the marks to maintain the zebra-stripe effect.
···
On 3/25/10 11:39 AM, Bryan Oakley wrote:
I want to add alternating background colors in my styledtextctrl
(while still using foreground colors for syntax highlighting) but I'm
not having any luck. Is there a simple way to do this?
What I have so far is one style for even numbered lines and one for
odd. These styles only have their background set. I can use these
styles and my lines are all appropriately colored. However, when I
make a second pass over the data to assign styles to colorize the
foreground for specific words (read: syntax coloring), these new
styles override the line styles even though they don't explicitly set
the background.
That is exactly what I needed. Thank you very much.
···
On Thu, Mar 25, 2010 at 4:46 PM, Robin Dunn <robin@alldunn.com> wrote:
On 3/25/10 11:39 AM, Bryan Oakley wrote:
I want to add alternating background colors in my styledtextctrl
(while still using foreground colors for syntax highlighting) but I'm
not having any luck. Is there a simple way to do this?
What I have so far is one style for even numbered lines and one for
odd. These styles only have their background set. I can use these
styles and my lines are all appropriately colored. However, when I
make a second pass over the data to assign styles to colorize the
foreground for specific words (read: syntax coloring), these new
styles override the line styles even though they don't explicitly set
the background.
Since what you are wanting to do is line-oriented then using markers is
probably a better idea than styles. Markers are usually a little shape in
the margin, but one of the marker styles sets the background color of the
line instead. Try using wx.stc.STC_MARK_BACKGROUND. Keep in mind that as
lines are inserted or deleted the the marks on existing lines are moved
around with the lines, so you'll probably need to be able to reset the marks
to maintain the zebra-stripe effect.