In a multi-line wxTextCtrl window, I would like to be able to paint the background of alternating lines a different color.
I can do this easily enough when I first fill the control, but I do have to allow for adding and deleting of lines. So if I paint the background when I add the text, things get out of step later on.
To avoid repainting the whole works over and over, I thought of doing it in the OnEraseBackground event handler and I have been able to hook into the event handler to intercept this event, but I'm quite clueless as to how to go about implementing my scheme, if it is even possible.
Any hints or pointers would be most welcome.
I have looked at wxScrolledWindow, but I don't see it fitting in as well as the text control - and besides, it would mean a good bit of rewrite
TIA
widgets
Painting wxtextCtrl background Topic is solved
Painting wxtextCtrl background
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
MSVC Express 2019/2022
wxWidgets 3.2.2
Hi!
Try the wxListCtrl. There you can change the color of each line (Item):
http://wiki.wxwidgets.org/WxListCtrl#Us ... _Each_Item
Try the wxListCtrl. There you can change the color of each line (Item):
http://wiki.wxwidgets.org/WxListCtrl#Us ... _Each_Item
-
- Earned some good credits
- Posts: 125
- Joined: Wed Mar 05, 2008 3:30 pm
I think you are looking for
Chris
Code: Select all
wxRichTextCtrl
It's not so much that I can't change or don't know how to change the background color of a line when I add it. I think I need to do it from the erase background event.Probot wrote:Hi!
Try the wxListCtrl. There you can change the color of each line (Item):
http://wiki.wxwidgets.org/WxListCtrl#Us ... _Each_Item
Aside from that, I would have to find out the maximum size of text the list control can handle.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
MSVC Express 2019/2022
wxWidgets 3.2.2
[quote="chris_bern"]I think you are looking for
I have looked at that control, but I think it would be overkill and besides, it does not really change my problem.
If I add background colors during the addition of the text, then I'm going to have to modify every line after the one modified whenever any one line is added or deleted - not a good solution.
To avoid that I want to paint the background separately.
Aug 2008
I have, meanwhile, changed the code to use the wxScrolledWindow
code - still working through the resulting changes.
Code: Select all
wxRichTextCtrl
If I add background colors during the addition of the text, then I'm going to have to modify every line after the one modified whenever any one line is added or deleted - not a good solution.
To avoid that I want to paint the background separately.
Aug 2008
I have, meanwhile, changed the code to use the wxScrolledWindow
code - still working through the resulting changes.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
MSVC Express 2019/2022
wxWidgets 3.2.2