Page 1 of 1

wxhtmlwindow alternative

Posted: Tue Jul 30, 2019 5:43 am
by Wolfgang
Hello

I have the problem that for one of my windows, the result by a query could reach even 6000 lines, and building this with wxhtmlwindow takes ages. Each entry is consisting of a reference name in the beginning, and a text with different length and with line breaks and different colours. The click reference for the whole entry the reference is called when clicked.
The whole html page is in one string.

To see how it should look like, here a screenshot.
screenshot.jpg
Is it somehow possible to make it scrollable, that only 10 have to be generated at once? however, is it then possible to scroll down the references, and see them during scrolling, like it is possible when the whole page is loaded into it?

Or what other possibilities are there to make it quicker?

Re: wxhtmlwindow alternative

Posted: Tue Jul 30, 2019 6:19 am
by New Pagodi

Re: wxhtmlwindow alternative

Posted: Thu Aug 01, 2019 11:08 am
by Wolfgang
Thank you wxhtmllistbox works fine, just a new problem arose.

If I change the selectionbackground with

Code: Select all

  SetSelectionBackground("LIGHT BLUE");
it also changes the colours of the foreground text. If it uses the standard colour for the selection background it does not change it, so what is going wrong?

Re: wxhtmlwindow alternative

Posted: Fri Aug 02, 2019 1:46 am
by New Pagodi
I'm not really familiar with that control, but it looks like your supposed to override the method

Code: Select all

virtual wxColour GetSelectedTextColour(const wxColour &colFg) const 
to return the color to be used when the item is selected. I think the way it works is your return the selected color you want for the given unselected color. For example, to convert text that is red when unselected to white, green when unselected to blue and all other colors to black, you would have the body of the method look like:

Code: Select all

if(colFg==*wxRED)
    return *wxWHITE;
else if(colFg==*wxGREEN)
    return *wxBLUE;
else
    return *wxBLACK;

Re: wxhtmlwindow alternative

Posted: Fri Aug 02, 2019 5:55 am
by Wolfgang
As my selection is multicolor this alone would not help.
But as said, if I leave the standard selection colour, it stays in the right colours only if I change the selectionbackgroundcolour it changes the colour of the text.
Or would it mean, write one for all the colours?

Re: wxhtmlwindow alternative

Posted: Fri Aug 02, 2019 6:29 am
by New Pagodi
This still works with multiple colors. Here's a really simple example where the box just keeps the colors the same in the selection.

Code: Select all

class MyListBox:public wxHtmlListBox
{
public:
    MyListBox(wxWindow*);

protected:
    virtual wxString OnGetItem (size_t n) const;
    virtual wxColour GetSelectedTextColour(const wxColour &colFg) const;
};

MyListBox::MyListBox(wxWindow* p):wxHtmlListBox(p)
{
    SetSelectionBackground("LIGHT BLUE");
}

wxColour MyListBox::GetSelectedTextColour(const wxColour &colFg) const
{
    if( colFg==wxColor(0x80,0x80,0x80) )
    {
        return wxColor(0x80,0x80,0x80);
    }
    else if( colFg==wxColor(0x80,0,0x80) )
    {
        return wxColor(0x80,0,0x80);
    }
    else if( colFg==wxColor(0,0x80,0x80) )
    {
        return wxColor(0,0x80,0x80);
    }
    else
    {
        return *wxBLACK;
    }
}

wxString MyListBox::OnGetItem (size_t n) const
{
    wxString s = "<font color=\"#808080\"><b>Item </b></font>";
    s << wxString::Format("%d ",static_cast<int>(n));
    s << "<font color=\"#800080\">More Text </font>";
    s << "<font color=\"#008080\">Other Text</font>";

    return s;
}
htmlbox.png
htmlbox.png (12.79 KiB) Viewed 103 times

Or if your 100% sure you don't need to change any of colors when selected, you could just do

Code: Select all

wxColour MyListBox::GetSelectedTextColour(const wxColour &colFg) const
{
    return colFg;
}

Re: wxhtmlwindow alternative

Posted: Fri Aug 02, 2019 7:31 am
by Wolfgang
yes, the last one should work.

Re: wxhtmlwindow alternative

Posted: Fri Aug 02, 2019 7:42 am
by Wolfgang
thanks