Page 1 of 1

How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Sun Dec 13, 2015 9:49 pm
by aalsubhi
Hello there,
I'm using wxwidgets with python. I have been tried to draw dashed red line under some words in richtextctrl using wx.dc, but I have a problem to get the correct position of the words especially when the vertical scrollbar is enabled. Any idea to make the dashed underline possible will be appreciated.
Thanks in advanced.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Sun Dec 13, 2015 10:12 pm
by doublemax
Unfortunately there is no easy solution for this. There was a similar question recently on the wx-users mailing list:
https://groups.google.com/d/msg/wx-user ... AdvgStCQAJ

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Mon Dec 14, 2015 4:02 pm
by aalsubhi
Is it possible to use the underline feature in richtextctrl and customize it with different style and color.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Tue Dec 15, 2015 6:25 pm
by aalsubhi
can I access the underline feature in python and change the color and style of the underline?

I'm stuck in this point in my application.

Thanks in advance.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Tue Dec 15, 2015 7:34 pm
by doublemax
Sorry, i don't see a solution for this unless you modify wxRichTextCtrl itself.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Tue Dec 15, 2015 10:34 pm
by aalsubhi
That seems more complicated. I'm not good at C++.
Is there anyway to convert the text index position to screen coordinates. I'm able to store the index of each word.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Wed Dec 16, 2015 8:48 pm
by aalsubhi
In WxPython documentation , I found this function :PositionToCoords(self, pos) which is used to converts given text position to client coordinates in pixels. I used it ,but it returned -1 that's mean the function does not success.

Any idea to use this function correctly , it will help me to draw the line in the right position.

Any help would be appreciated.

Re: How I can draw dashed line under some words in multi-lines richtextctrl ?

Posted: Wed Dec 16, 2015 9:49 pm
by doublemax
A PositionToCoords method does not exist in the C++ part, only PositionToXY. But that returns coordinates as line and column number, not in pixel coordinates.

Try studying the code in wxRichTextCtrl::OnLeftClick in wx/src/richtext/richtextctrl.cpp. Maybe it gives you a hint about which classes / methods you can use.

But i haven't seen anything that would do what you need.