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

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
aalsubhi
In need of some credit
In need of some credit
Posts: 5
Joined: Sun Dec 13, 2015 9:37 pm

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

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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
Use the source, Luke!
aalsubhi
In need of some credit
In need of some credit
Posts: 5
Joined: Sun Dec 13, 2015 9:37 pm

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

Post by aalsubhi »

Is it possible to use the underline feature in richtextctrl and customize it with different style and color.
aalsubhi
In need of some credit
In need of some credit
Posts: 5
Joined: Sun Dec 13, 2015 9:37 pm

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

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax »

Sorry, i don't see a solution for this unless you modify wxRichTextCtrl itself.
Use the source, Luke!
aalsubhi
In need of some credit
In need of some credit
Posts: 5
Joined: Sun Dec 13, 2015 9:37 pm

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

Post 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.
aalsubhi
In need of some credit
In need of some credit
Posts: 5
Joined: Sun Dec 13, 2015 9:37 pm

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

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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.
Use the source, Luke!
Post Reply