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
Earned some good credits
Earned some good credits
Posts: 122
Joined: Mon Jan 28, 2019 8:22 am

wxhtmlwindow alternative

Post by Wolfgang » Tue Jul 30, 2019 5:43 am

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: 307
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

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


Wolfgang
Earned some good credits
Earned some good credits
Posts: 122
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang » Thu Aug 01, 2019 11:08 am

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: 307
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

Post by New Pagodi » Fri Aug 02, 2019 1:46 am

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
Earned some good credits
Earned some good credits
Posts: 122
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang » Fri Aug 02, 2019 5:55 am

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: 307
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxhtmlwindow alternative

Post by New Pagodi » Fri Aug 02, 2019 6:29 am

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 114 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
Earned some good credits
Earned some good credits
Posts: 122
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang » Fri Aug 02, 2019 7:31 am

yes, the last one should work.

Wolfgang
Earned some good credits
Earned some good credits
Posts: 122
Joined: Mon Jan 28, 2019 8:22 am

Re: wxhtmlwindow alternative

Post by Wolfgang » Fri Aug 02, 2019 7:42 am

thanks

Post Reply