wxHtmlHelpHtmlWindow using wxWebview

110 views
Skip to first unread message

Stefano Mtangoo

unread,
Jun 17, 2013, 6:03:03 AM6/17/13
to wx-...@googlegroups.com
wxHtmlHelpHtmlWindow display menus ugly and I wanted to check how much effort is needed to change it to wxWebview and if I can do it myself.
Looking at wxHtmlHelpHtmlWindow class it inherits wxHtmlWindow and have few methods that can be somehow changed to use wxWebView.
Is that all that I need to do? I can't believe its that simple. The file I was looking at is wx/src/html/helpwind.cpp

If I'm missing anything, what is it?
TIA,
Stefano

Steven Lamerton

unread,
Jun 17, 2013, 6:10:34 AM6/17/13
to wx-...@googlegroups.com
Hi Stefano,

This has come up a few times on the list, take a look at [1] where there is a list of steps that need to be undertaken. I am sure there were some other threads as well but I can't find them at the moment. Once there is a new base class that you can derive the existing wxHtmlHelpWindow and the new wxWebViewHelpWindow from it should be reasonably straightforward.

Hope that helps, please let me know if you have any questions,

Steven

[1] https://groups.google.com/forum/?hl=en&fromgroups#!searchin/wx-dev/wxwebview$20help/wx-dev/jZh4qU-tZls/_oNfwJMWINoJ


--
To unsubscribe, send email to wx-dev+un...@googlegroups.com
or visit http://groups.google.com/group/wx-dev
 
 
 

Stefano Mtangoo

unread,
Jun 17, 2013, 4:43:13 PM6/17/13
to wx-...@googlegroups.com


On Monday, June 17, 2013 1:10:34 PM UTC+3, Steve Lamerton wrote:
Hi Stefano,

This has come up a few times on the list, take a look at [1] where there is a list of steps that need to be undertaken. I am sure there were some other threads as well but I can't find them at the moment. Once there is a new base class that you can derive the existing wxHtmlHelpWindow and the new wxWebViewHelpWindow from it should be reasonably straightforward.

Hope that helps, please let me know if you have any questions,
Great. Let me familiarize with the discussion that went on and I will definitely ask any question.
I will want to do it if my little time I have will be enough!
 

Stefano Mtangoo

unread,
Jun 17, 2013, 5:11:44 PM6/17/13
to wx-...@googlegroups.com
I checked the Vadim's solution and I cannot say how difficult it is.
With this little time in my hand and desire to get rid of ugly help display I will try, where I end others will take over.
So I decided to make something like this

/*!
 * Help Window base class that will be inherited to add new backend
 * Expect to be base to at least wxHtmlWindow and wxWebView based backends
 * Jun 18 2013 - Stefano D. Mtangoo
 */
 
 class WXDLLIMPEXP_HTML wxHtmlHelpView : public wxWindow
 {
     
 };


/*!
 * Help window - wxWebview

class WXDLLIMPEXP_HTML wxWebViewHelpWindow : public wxHtmlHelpView
{
   
};


/*!
 * Help window - wxHtmlWindow
 */

class WXDLLIMPEXP_HTML wxHtmlHelpWindow : public wxHtmlHelpView
{
   
};

I will now shift all methods that are public to base class and implement what is common.
Also as for those that are not common (talking of methods), I will make them pure abstract in base class.
Is there anything that I do amiss or needed as essential work to make it happen?

Best regards,
Stefano

Stefano Mtangoo

unread,
Jun 18, 2013, 6:10:03 AM6/18/13
to wx-...@googlegroups.com
I would like to hear comments if I'm on right track!
Best regards,
Stefano

Steven Lamerton

unread,
Jun 18, 2013, 6:16:44 AM6/18/13
to wx-...@googlegroups.com
At a glance that looks fine, I think wxHelpWindow would make more sense as the base class name. You may also need to make a couple of minor changes to wxHtmlHelpControllerso it takes a pointer to the base class.

Steven

Stefano Mtangoo

unread,
Jun 18, 2013, 6:39:31 AM6/18/13
to wx-...@googlegroups.com
I have seen that and will change them. I have changed the class as it makes more sense.
Let me work a bit and I'll be back!

Steven

Stefano Mtangoo

unread,
Jun 22, 2013, 12:01:55 PM6/22/13
to wx-...@googlegroups.com
Hi Steven and wxDev,


On Monday, June 17, 2013 1:03:03 PM UTC+3, Stefano Mtangoo wrote:
wxHtmlHelpHtmlWindow display menus ugly and I wanted to check how much effort is needed to change it to wxWebview and if I can do it myself.
Looking at wxHtmlHelpHtmlWindow class it inherits wxHtmlWindow and have few methods that can be somehow changed to use wxWebView.
Is that all that I need to do? I can't believe its that simple. The file I was looking at is wx/src/html/helpwind.cpp

I found this line problematic since it cannot remain the same in base class.
Should I declare it a pointer to void and do type casting in respective imprementation or is ther better alternative?
The Line is:

protected:
    wxHtmlWindow *m_HtmlWin; 
I want to change it to

protected:
    void *m_HtmlWin; 

Steven Lamerton

unread,
Jun 22, 2013, 3:18:25 PM6/22/13
to wx-...@googlegroups.com

On 22 Jun 2013 17:01, "Stefano Mtangoo" <mwinj...@gmail.com> wrote:
> I found this line problematic since it cannot remain the same in base class.
> Should I declare it a pointer to void and do type casting in respective imprementation or is ther better alternative?
> The Line is:
>
> protected:
>     wxHtmlWindow *m_HtmlWin; 
> I want to change it to
>
> protected:
>     void *m_HtmlWin; 
>>
>>
>> If I'm missing anything, what is it?

I think you should only have these details in the derived classes, then it wouldn't matter about the differences.

Steven

Julian Smart

unread,
Jun 22, 2013, 3:28:36 PM6/22/13
to wx-...@googlegroups.com
On 22/06/2013 20:18, Steven Lamerton wrote:
>
> On 22 Jun 2013 17:01, "Stefano Mtangoo" <mwinj...@gmail.com
Plus you could have a pure virtual function in the base class returning
a wxWindow pointer, in case you really need to access the window in a
generic way.

Julian

Stefano Mtangoo

unread,
Jun 22, 2013, 4:26:16 PM6/22/13
to wx-...@googlegroups.com
I will go with Julian's way if no objection. It makes code readable AFAICS!
Thanks all!

Stefano Mtangoo

unread,
Jul 3, 2013, 3:22:59 PM7/3/13
to wx-...@googlegroups.com
I have done major works changing internal classes and adding other classes.
Tested samples/help and works with wxHtmlWindow kind of help but I have few questions:
1. What are other classes need to change to make the change complete? All I have done is changes in helpwnd and helpctrl only (cpp/h)
2. I cannot load the URLs of zip file in wxWebview. I tried to add linese below but did not help


    wxFileSystem::AddHandler(new wxArchiveFSHandler);
    wxFileSystem::AddHandler(new wxMemoryFSHandler);

then
 m_htmlWindow->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("zip")));
 m_htmlWindow->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));

Best regards

Steven Lamerton

unread,
Jul 3, 2013, 3:50:28 PM7/3/13
to wx-...@googlegroups.com
On 3 July 2013 20:22, Stefano Mtangoo <mwinj...@gmail.com> wrote:
I have done major works changing internal classes and adding other classes.
Tested samples/help and works with wxHtmlWindow kind of help but I have few questions:

This is excellent news!
 
1. What are other classes need to change to make the change complete? All I have done is changes in helpwnd and helpctrl only (cpp/h)

I am not sure about this, someone more familiar with the help system probably needs to answer this.
 
2. I cannot load the URLs of zip file in wxWebview. I tried to add linese below but did not help


    wxFileSystem::AddHandler(new wxArchiveFSHandler);
    wxFileSystem::AddHandler(new wxMemoryFSHandler);

then
 m_htmlWindow->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("zip")));
 m_htmlWindow->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));

So you definitely should use wxWebViewArchiveHandler for this, I suspect the problem comes from the fact that is uses a different style of path to the other zip handling classes, an example of this is given in the docs.

Thanks again,

Steven

Stefano Mtangoo

unread,
Jul 3, 2013, 3:56:08 PM7/3/13
to wx-...@googlegroups.com
So you mean above code is correct?
Well If so I need only to know the formats of the two so that I can process url before I load on wxWeb view.
With current implementation its trivial job as long as I know both formats (help links and webview handler)

 

Thanks again,

Steven

Steven Lamerton

unread,
Jul 3, 2013, 4:01:53 PM7/3/13
to wx-...@googlegroups.com
The code is correct, but passing "zip" as an argument probably isn't a great idea. The argument becomes the name of the scheme that is handled, for example with your code it would be:

zip://path/to/help/file

Perhaps calling it "help" would make more sense, but it probably doesn't matter.

Steven

Stefano Mtangoo

unread,
Jul 3, 2013, 4:11:54 PM7/3/13
to wx-...@googlegroups.com

I agree but now that I have to make sure it works before I do cleaning work.
What is the format of wxWebview handling zipped files?
Is it this way?---> file:///C:/example/docs.zip;protocol=zip/directory/subdir/file.htm
Anyone who knows help file url format (looks like file:/home/stefano/zipfile.zip#zip:dir/subdir/file.html)

Is there a documentation of the two formats?

Steven Lamerton

unread,
Jul 3, 2013, 4:35:09 PM7/3/13
to wx-...@googlegroups.com
These looks correct to me.

Steven

Stefano Mtangoo

unread,
Jul 3, 2013, 4:57:32 PM7/3/13
to wx-...@googlegroups.com

Got this error. Do you see any problem in this url?
file:///home/stefano/wxwidgets2/samples/help/doc.zip;protocol=zip/res/introduction.html

Zip file is doc.zip/res/introduction.html
 

Steven

Stefano Mtangoo

unread,
Jul 4, 2013, 3:14:43 AM7/4/13
to wx-...@googlegroups.com
cannot get the files in zipped folder load. I all times get

Unable to load page

Problem occurred while loading the URL file:///home/stefano/wxwidgets2/samples/help/doc.zip;protocol=zip/thedir/introduction.html

Error opening file: No such file or directory


Any Idea?

Steven Lamerton

unread,
Jul 4, 2013, 4:35:02 AM7/4/13
to wx-...@googlegroups.com
I guess you aren't using the scheme that you registered with the archive handler? You need to, the handler doesn't apply to every possible url. The sample has a good example of this, it registers a wxWebViewArchiveHandler using the "wxfs" scheme, the actual file loading is done in OnLoadScheme.

Hope that helps,

Steven

Stefano Mtangoo

unread,
Jul 4, 2013, 5:00:45 AM7/4/13
to wx-...@googlegroups.com

You nailed it.

Now the class is working fine (see screenshot).
Now that I took all company work Yesterday to make sure that I finish basic dirty works, I have to finish ,y customers works.
I will do the cleaning and organizing codes later (after these activities). If anyone is interested to do finishing and reorganizing of working code I can upload that
(May be a pull request to Vadim's git?)



Best regards
Stefano

Steven
Reply all
Reply to author
Forward
0 new messages