wxStyledTextCtrl - text range background

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
chadman
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Mar 23, 2005 8:28 am

wxStyledTextCtrl - text range background

Post by chadman » Wed May 11, 2005 9:15 am

Is there a was to change the background of only a certain range of characters in a wxStyledTextCtrl? For instance, I have a paragraph and I want to highlight one or two separate sentences in yellow (not talking about a selection).

chadman
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Mar 23, 2005 8:28 am

Anybody know?

Post by chadman » Fri May 20, 2005 6:33 pm

Does anybody know any way to do this? My application's development is stalled because of this...

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Fri May 20, 2005 7:19 pm

Hi look at this;

http://scintilla.sourceforge.net/ScintillaDoc.html

Most of the calls map directly to the wxWidgets implementation..

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

chadman
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Mar 23, 2005 8:28 am

Post by chadman » Sun May 29, 2005 8:18 pm

In case anybody stumbles upon this in the future, I was able to figure it out (a while ago). Here's the code to do it:

Code: Select all

const int TEXT_STYLE_HIGHLIGHT = 1;

// set up the highlight style
StyleSetBackground(TEXT_STYLE_HIGHIGHT, wxColour(255, 255, 0));
StyleSetFont(TEXT_STYLE_HIGHIGHT, wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, false, "Arial"));

// apply the style
StartStyling(begPos, 31);
SetStyling(length, TEXT_STYLE_HIGHIGHT);
I think I was having trouble because I wasn't defining my own style.

Post Reply