Iwbnwif Yiw
2014-04-23 09:57:43 UTC
I have a wxGrid and in some cells I would like to display rich text.
To be precise I would like to have the ability to display text which has
different font attributes (bold, italic etc.), bulleted lists, numbered
lists (including hierarchical lists), hyperlinks and images within a cell.
So 'rich text' could also be (for example) HTML.
Probably the total number of cells could reach 10,000 but only 20 or so
would be visible at any one time.
I need to be able to edit the text, but I don't propose to have in-cell
editing.
My initial thoughts are as follows:
- Use wxRichTextCtrl as an editor and save the contents (XML) of each
cell to a std::vector<wxString>
- Write a custom wxGridCellRenderer that instantiates a
wxRichTextBuffer, loads the text from the XML string and uses
wxRichTextBuffer::Draw to draw the contents within the cell's rect
I have taken cues from src/richtextprint.cpp for this.
However if I understand correctly, although the wxGridCellRender would be
reference counted, for each cell a new instance of wxRichTextBuffer would
be created (potentially 10,000) which seems a bit inefficient.
Alternatively I could create a pool of wxRichTextBuffers and load the XML
for the visible cells on-the-fly, but this might make scrolling slow.
I do plan to do some experimentation and see how it goes, but first wanted
to ask the list if there is a better way of doing this :)
Thanks in advance!
To be precise I would like to have the ability to display text which has
different font attributes (bold, italic etc.), bulleted lists, numbered
lists (including hierarchical lists), hyperlinks and images within a cell.
So 'rich text' could also be (for example) HTML.
Probably the total number of cells could reach 10,000 but only 20 or so
would be visible at any one time.
I need to be able to edit the text, but I don't propose to have in-cell
editing.
My initial thoughts are as follows:
- Use wxRichTextCtrl as an editor and save the contents (XML) of each
cell to a std::vector<wxString>
- Write a custom wxGridCellRenderer that instantiates a
wxRichTextBuffer, loads the text from the XML string and uses
wxRichTextBuffer::Draw to draw the contents within the cell's rect
I have taken cues from src/richtextprint.cpp for this.
However if I understand correctly, although the wxGridCellRender would be
reference counted, for each cell a new instance of wxRichTextBuffer would
be created (potentially 10,000) which seems a bit inefficient.
Alternatively I could create a pool of wxRichTextBuffers and load the XML
for the visible cells on-the-fly, but this might make scrolling slow.
I do plan to do some experimentation and see how it goes, but first wanted
to ask the list if there is a better way of doing this :)
Thanks in advance!
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users