wxhtmlwindow alternative Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 180
Joined: Mon Jan 28, 2019 8:22 am

wxhtmlwindow alternative

Post 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?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

Post by New Pagodi »

Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 180
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post 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?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

Post 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;
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 180
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post 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?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

Post 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 1307 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;
}
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 180
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang »

yes, the last one should work.
Wolfgang
I live to help wx-kind
I live to help wx-kind
Posts: 180
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang »

thanks
Post Reply