Control for text display, highlight and scroll
Control for text display, highlight and scroll
I am looking for a control that will be able to load large scrollable text (e.g. say, 25 MB).
The text doesn't have to be editable, but just viewable.
I also need to highlight the lines in text on mouse clicks.
Which control will be a suitable choice?
The text doesn't have to be editable, but just viewable.
I also need to highlight the lines in text on mouse clicks.
Which control will be a suitable choice?
Re: Control for text display, highlight and scroll
I would try wxStyledTextCtrl or wxWebView.
Use the source, Luke!
Re: Control for text display, highlight and scroll
If the text is line-oriented (e.g., a CSV file) instead of being paragraph-oriented (text can be wrapped), I would try using wxListCtrl in virtual mode.
Re: Control for text display, highlight and scroll
Thanks. I am looking at wxWebView. It seems like a complete web browser. I am not using wxListCtrl because its a paragraph oriented text, yes.
Any hints on which functions I will need to paste text into wxWebView and highlight particular lines with mouse clicks? For starters, I need just basic functionality.
After creating it I get this:
It seems like a web browser.
Any hints on which functions I will need to paste text into wxWebView and highlight particular lines with mouse clicks? For starters, I need just basic functionality.
After creating it I get this:
It seems like a web browser.
Re: Control for text display, highlight and scroll
Yes, it is a webbrowser. And as such much better optimized to display large amounts of text than any other control. That's why i suggested it.
In the most simple form, you just call wxWebView::SetPage() with a basic html page.
If you need more fancy stuff, you might need to know at least basic things about HTML (eventually CSS) and JavaScript.
In the most simple form, you just call wxWebView::SetPage() with a basic html page.
Code: Select all
<html><body><pre>
your text here
</pre></body></html>
What exactly do you need? When i read your first post i thought you meant simple text selection for copy and paste. That should work out of the box.ny hints on which functions I will need to paste text into wxWebView and highlight particular lines with mouse clicks?
If you need more fancy stuff, you might need to know at least basic things about HTML (eventually CSS) and JavaScript.
Use the source, Luke!
Re: Control for text display, highlight and scroll
I want to just display a large .txt file.
So for example, here's how a "sample text" should appear:
That's a photoshopped image just for example.
I should be able to mouse hover lines and highlight text on mouse clicks.
Do I need to add html tags to display text and highlight?
Here's what I tried:
The output was:
So for example, here's how a "sample text" should appear:
That's a photoshopped image just for example.
I should be able to mouse hover lines and highlight text on mouse clicks.
Do I need to add html tags to display text and highlight?
Here's what I tried:
Code: Select all
wxString str = "<html><body><pre>your text here</pre></body></html>";
TextViewer->SetPage(str, "");
Re: Control for text display, highlight and scroll
Hi,
Are you trying to run it underWindows 10?
It is possible you default browser is set to M$ Edge and not IE....
Thank you.
Are you trying to run it underWindows 10?
It is possible you default browser is set to M$ Edge and not IE....
Thank you.
Re: Control for text display, highlight and scroll
Hi, It is Windows 8.1 OS and wxWidgets-3.1.2 setup environment under MSVS 2019. I am not exactly going to use the control to load internet web pages, but just local text (.txt/ .html) files.
Re: Control for text display, highlight and scroll
Can you show the code where you create the webview control?
E.g. you should not pass "" as url when creating it. The default is "about:blank".
It's also possible that you need to wait for the wxEVT_WEBVIEW_LOADED event and set the new page from there.
E.g. you should not pass "" as url when creating it. The default is "about:blank".
It's also possible that you need to wait for the wxEVT_WEBVIEW_LOADED event and set the new page from there.
Use the source, Luke!
Re: Control for text display, highlight and scroll
Okay, I see.
I changed this:
to:
Now, it appears to work.
It seems I will need to convert the text files into html to display the data and highlight it.
I am not much aware of web development languages.. So to get started,
I changed this:
Code: Select all
TextViewer = wxWebView::New(m_panel, wxID_ANY, "");
Code: Select all
TextViewer = wxWebView::New(m_panel, wxID_ANY, "about:blank");
It seems I will need to convert the text files into html to display the data and highlight it.
I am not much aware of web development languages.. So to get started,
- Do I need to use JavaScript here for mouse hover actions on text and highlight?
- Can I disable horizontal scroll and do word wrap of text?
Re: Control for text display, highlight and scroll
Text selection and copy/paste should work out of the box. For hover action you'll need either CSS or JS, depending on what you need. Can you explain?Do I need to use JavaScript here for mouse hover actions on text and highlight?
Remove the <pre></pre> tags.Can I disable horizontal scroll and do word wrap of text?
Use the source, Luke!
Re: Control for text display, highlight and scroll
@doublemax: I have a 20 secs photoshopped clip in which I tried to explain exactly what I am tying to do. I want to hover the mouse over text and it should highlight the line. When I mouseclick over it then it changes highlight.
Okay, to achieve this. I know where the lines start and end. So, basically, do I need to add some JavaScript here for mouse events and dynamic highlights?
Okay, to achieve this. I know where the lines start and end. So, basically, do I need to add some JavaScript here for mouse events and dynamic highlights?
Re: Control for text display, highlight and scroll
The hover effect could be done with CSS alone. For the click handling you need JS. As this code has to be added to every single line of text, this might at least double the length of the text.
Did you already make a test how the control behaves with 25mb of text?
Did you already make a test how the control behaves with 25mb of text?
Use the source, Luke!
Re: Control for text display, highlight and scroll
I'd be happy if it works with at least 2 MB of text for now. Yes, I tried it with ~25 MB file and it appears to load it fine as well but because there's too much to scroll, it can get slow and unresponsive.
Currently, I'd just focus on highlighting and seems like I'd need to learn some CSS / Javascript stuff.
Currently, I'd just focus on highlighting and seems like I'd need to learn some CSS / Javascript stuff.
Re: Control for text display, highlight and scroll
So, is it really not possible to edit and save text as html within this control? Maybe via. Javascript again?