wxwidgets

Which control to display a text with background-marked parts?


I need to display the content of a plain-text file, and to mark different parts of the text by different background colors. The marking is only visual, for the user. The information about the region and the background color is not and will never be a part of the text file (no markup).

One can select the part of text in wxTextCtrl by mouse (say to use Ctrl+C as the next step). Is it more OS-native control feature? Or can a multiple selection like that with different colors be done?

Or should the wxRichTextCtrl be used for the purpose? Or is there any other, more suitable widget for the task?

The parts are or recognized or by the algorithm, or marked manually (selected by mouse) -- but that is not the core of the question.


Solution

  • You can indeed use visual styles support in wxTextCtrl to do this, see " wxTextCtrl Styles" section in wxTextCtrl documentation.

    Or you could use Scintilla-based wxStyledTextCtrl which is specifically designed for syntax highlighting code.

    wxRichTextCtrl would be a bad choice for plain text however.