wxMozilla

BlitzMax Forums/Brucey's Modules/wxMozilla

plash(Posted 2008) [#1]
Any chance you'll (Brucey) port over wxMozilla anytime soon?


Brucey(Posted 2008) [#2]
Had a look, and it doesn't appear to have much in the way of any development going on. Which is a shame really.

So, not likely.

I've read that the wxWidgets team are considering having a proper browser widget at some point (say, IE on win32, webkit on Mac, etc), but whether it'll ever get done...


plash(Posted 2008) [#3]
I've read that the wxWidgets team are considering having a proper browser widget at some point

Currently there is no way in wxWidgets to display html pages?


DavidDC(Posted 2008) [#4]
I haven't tried it yet, but there's wxHtmlWindow. I think there's also wxWebKitCtrl (unwrapped) which is more osx friendly apparently.

wxHtmlWindow does have its limitations:

"wxHtmlWindow is used by wxWidgets’ built-in help system, and it is also a great control to use in your applications whenever you need to display formatted text and graphics, such as reports. It can display a useful subset of HTML, including tables, but not frames. Features include animated GIFs, high-lighted links,fonts,background color,nested lists,centering, right-alignment, horizontal rules, character encoding support, and more. It doesn’t support style sheets,but you can normally achieve the effects you want by writing or generating the appropriate tags. HTML text is selectable and can be copied to the clipboard or returned to the application as plain text." (from the wxWidgets Programming pdf)


plash(Posted 2008) [#5]
wxHtmlWindow will be fine for what I'm going to do, thanks again!


Blueapples(Posted 2008) [#6]
Brucey,

I specifically will need Mozilla support for a project that I'm working on - currently I use Firefox launched externally but I would like to integrate the content viewing aspect into the actual application. What would go into wrapping this project?

I just looked at the CVS activity for wxMozilla and there has been some developer activity up until the end of 2007. The control looks like it works, so I believe it would be a good addition to the wxMax project.


Brucey(Posted 2008) [#7]
According to the FAQ at the wxWebKit project, the Mac version of mozilla doesn't allow embedding in Carbon, which kind of rules out getting that working very well on the Mac-side.

On another note... these are absolute beasts source-code wise, aren't they?


Blueapples(Posted 2008) [#8]
I hadn't seen that bit about no embedding for wxWebkit in Carbon... I guess that sort of fits into my own preference for getting wxMozilla support instead, provided it doesn't have any problems with carbon.

Oh don't even get me started on these things, just to copy a customized version of FireFox/Mozilla to my thumb drive takes like 10 minutes. And that's with a lot of it converted to binary (still tons of XUL files, etc.) Uncompiled, yeah, they're monsters. I wish there was some option that was smaller that provided the same kind of functionality, but what're you going to do?


Blueapples(Posted 2008) [#9]
I've got the wxMozilla source and I'm going to try to wrap it the same what you've done Brucey. Hopefully this works, I really need it .... ;)


Blueapples(Posted 2008) [#10]
Brucey, I'm working on getting a really simple wrapper to compile wxMozilla, and getting this error when trying to build:


In file included from /Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.cpp:23:
/Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.h:23:20: error: wxglue.h: No such file or directory
/Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.cpp: In constructor ‘MaxMozillaBrowser::MaxMozillaBrowser(BBObject*, wxWindow*, wxWindowID, int, int, int, int, long int)’:
/Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.cpp:31: error: ‘wxbind’ was not declared in this scope
/Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.cpp: In destructor ‘virtual MaxMozillaBrowser::~MaxMozillaBrowser()’:
/Applications/BlitzMax/mod/wx.mod/wxmozilla.mod/glue.cpp:35: error: ‘wxunbind’ was not declared in this scope


I have basically copied wxHtmlWindow to a new wzmozilla.mod folder and put the src folder of wxMozilla into that folder, with a very simple wrapper class (just creates the control for now). The source I have got so far is here: http://blueapples.org/files/wxmozilla.mod.zip

This source doesn't include Mozilla itself, as I haven't folded that into this yet. I expect more build errors and will at that point include Mozilla in the module or figure out how to statically or dynamically link with it. For now I just want to get the wrapper to build.

What I'm confused about is how #include "wxglue.h" can work (included from glue.h) since wxglue.h is in the directory above the module itself. I'm building (on OS 10.5) by going to /Applications/BlitzMax/bin in Terminal and running ./bmk makemods wx.wxmozilla Does this somehow not establish the correct environment for the compiler to find the core files in wx.mod?


Brucey(Posted 2008) [#11]
common.bmx imports wx.wx, which should establish the include for yours.

Ensure that the imports are in the right order.


Blueapples(Posted 2008) [#12]
common.bmx is almost exactly as it is in the other modules. I added one function at the top of the Extern block:

common.bmx
.
.
.
Import "glue.cpp"

Extern
	Function bmx_wxmozillabrowser_create:Byte Ptr(handle:Object, parent:Byte Ptr, id:Int, x:Int, y:Int, w:Int, h:Int, style:Int)
.
.
.


I've included it in the same way that they do:

wxmozilla.bmx
SuperStrict

Rem
bbdoc: wxMozilla
End Rem
Module wx.wxMozilla

ModuleInfo "Version: 1.00"
ModuleInfo "License: MIT"
ModuleInfo "Author: Isaac Raway, based on MIT code by Bruce A Henderson"
ModuleInfo "Copyright: (c) 2008 Isaac Raway, Bruce A Henderson"
ModuleInfo "Modserver: BRL"

?linux
ModuleInfo "CC_OPTS: -D__WXGTK__"
ModuleInfo "CC_OPTS: -D_FILE_OFFSET_BITS=64"
ModuleInfo "CC_OPTS: -D_LARGE_FILES"
ModuleInfo "CC_OPTS: -DWX_PRECOMP"
?win32
ModuleInfo "CC_OPTS: -DHAVE_W32API_H"
ModuleInfo "CC_OPTS: -D__WXMSW__"
ModuleInfo "CC_OPTS: -D_UNICODE"
ModuleInfo "CC_OPTS: -DUNICODE"
?macos
ModuleInfo "CC_OPTS: -D__WXMAC__"
ModuleInfo "CC_OPTS: -D_FILE_OFFSET_BITS=64"
ModuleInfo "CC_OPTS: -D_LARGE_FILES"
ModuleInfo "CC_OPTS: -DWX_PRECOMP"
?

Import "common.bmx"

Type wxMozillaBrowser Extends wxWindow

	Rem
	bbdoc: Constructor.
	End Rem
	Function CreateMozillaBrowser:wxMozillaBrowser(parent:wxWindow, id:Int, x:Int = -1, y:Int = -1, ..
			w:Int = -1, h:Int = -1, style:Int = wxHW_DEFAULT_STYLE)
			
		Return New wxMozillaBrowser.Create(parent, id, x, y, w, h, style)

	End Function
	
	Rem
	bbdoc: Creation method, for two-step construction. For details see CreateHtmlWindow.
	End Rem
	Method Create:wxMozillaBrowser(parent:wxWindow, id:Int, x:Int = -1, y:Int = -1, ..
			w:Int = -1, h:Int = -1, style:Int = wxHW_DEFAULT_STYLE)
			
		wxObjectPtr = bmx_wxmozillabrowser_create(Self, parent.wxObjectPtr, id, x, y, w, h, style)
		OnInit()
		Return Self
	End Method

	Rem
	bbdoc: Returns content of currently displayed page as plain text.
	End Rem
	Method ToText:String()
		Return "" 'bmx_wxmozillabrowser_totext(wxObjectPtr)
	End Method
End Type


I just tried to compile wxhtmlwindow, to test, using the same type command line (./bmk makemods wx.wxhtmlwindow), and this threw tons of similar errors. So, something doesn't work when compiled on the command line.


Blueapples(Posted 2008) [#13]
Hitting Cmd+D in the IDE appears to have built the module correctly. I'm sure it won't work (don't see how it could without the mozilla sources), but I can plug onwards now. Hopefully...


Blueapples(Posted 2008) [#14]
What does this error mean? It seems to be related to the event table for the class, maybe... I'm having a hard time parsing this. I think this would be a lot easier for you to do Brucey ;)



basic.bmx
SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxMozilla

Type MyApp Extends wxApp

        Field frame:wxFrame
	Field browser:wxMozillaBrowser

        Method OnInit:Int()

                frame = wxFrame.CreateFrame(Null, wxID_ANY, "Hello World", 100, 100)
		browser = wxMozillaBrowser.CreateMozillaBrowser(frame, wxID_ANY, 0, 0, 100, 100)
                frame.show()
        
                Return True

        End Method

End Type


New MyApp.run()



Brucey(Posted 2008) [#15]
You need to add, in your .cpp, something along the lines of :
BEGIN_EVENT_TABLE(MaxMozillaBrowser, wxMozillaBrowser)
END_EVENT_TABLE()

..or whatever the real class is called.

It's essentially a dummy event table, but the macros add all the bits of code that we need in order to use events properly - and as you saw, get it to compile properly :-)


Blueapples(Posted 2008) [#16]
Yep, got that in there. Here's my cpp and h files:

glue.cpp

#include "glue.h"


MaxMozillaBrowser::MaxMozillaBrowser(BBObject * handle, wxWindow * parent, wxWindowID id, int x, int y,
		int w, int h, long style)
	: maxHandle(handle), wxMozillaBrowser(parent, id, wxPoint(x, y), wxSize(w, h), style)
{
	wxbind(this, handle);
}

MaxMozillaBrowser::~MaxMozillaBrowser() {
	wxunbind(this);
}

BEGIN_EVENT_TABLE(MaxMozillaBrowser, wxMozillaBrowser)
END_EVENT_TABLE()


MaxMozillaBrowser * bmx_wxmozillabrowser_create(BBObject * maxHandle, wxWindow * parent, wxWindowID id, int x, int y,
		int w, int h, long style) {

	return new MaxMozillaBrowser(maxHandle, parent, id, x, y, w, h, style);
}


glue.h
#include "wxglue.h"
#include "wxMozillaBrowser.h"

class MaxMozillaBrowser;

extern "C" {

#include <blitz.h>

	MaxMozillaBrowser * bmx_wxmozillabrowser_create(BBObject * maxHandle, wxWindow * parent, wxWindowID id, int x, int y,
		int w, int h, long style);

}



class MaxMozillaBrowser : public wxMozillaBrowser
{
public:
	MaxMozillaBrowser(BBObject * handle, wxWindow * parent, wxWindowID id, int x, int y,
		int w, int h, long style);
	~MaxMozillaBrowser();
	
	
private:
	BBObject * maxHandle;
	
    // any class wishing to process wxWidgets events must use this macro
    DECLARE_EVENT_TABLE()
};



Brucey(Posted 2008) [#17]
Have you imported wxMozillaBrowser.cpp etc ?

It includes the implementation of the virtual method :

void wxMozillaBrowser::MacEnabledStateChanged( )
...


:-)


Blueapples(Posted 2008) [#18]
Doh! Of course.

Now I'm getting the tasty errors concerning Mozilla itself... have to get the code and try to integrate it. What a mess I'm making myself here...


Brucey(Posted 2008) [#19]
hehehe...

Well, it looks like you've taken care of the easy bit ;-)

Now, let the fun begin....


Brucey(Posted 2008) [#20]
I'm wondering if wxwebkit is mature enough to give a go too... big download but I have the connection which makes that part a non-issue.

However, I've read the instructions on building these things, and it seems like such a long, drawn out schlep - especially if you don't want to compile specifically a "browser".


Blueapples(Posted 2008) [#21]
Yeah no kidding, the prereqs alone are taking forever to install ("sudo port install mercurial libidl autoconf213")


Blueapples(Posted 2008) [#22]
The problem for me with wxwebkit, which is a beautiful looking package, is that I'm not sure I can control plugins the way I can with mozilla - I need to limit the Flash version, prevent using local plugins, etc. It might be possible but I just have no experience with it. I'm sure it must be possible - and any real cross platform browser control would put this miles ahead of any other GUI toolkit I know of.

And yeah, the install instructions are nuts. It looks like mozilla is actually pretty simple for the most part, but still a bit out of hand. The thing I'm worried about is getting the static files I need out of this build so I can link them to the BM application. I don't know if the suite building command ("$ make -f client.mk build") is going to give me something useful for that purpose, but one thing at a time I guess.

If I get wxMozilla working with BM I'll probably start maintaining it myself since it does look like the original project died.


Blueapples(Posted 2008) [#23]
By the way, this is what I'm looking using to build Mozilla - http://developer.mozilla.org/en/docs/Mac_OS_X_Build_Prerequisites


Brucey(Posted 2008) [#24]
If you are thinking of making this into a "proper" releasable module, then you'll be needing to build a set of shared objects if you can - I expect that to be no mean feat!!
Not sure you can get static libs out of if? (not sure if you'd want to!)

Are you going for a firefox build, or seamonkey?

Did you know, that inside the Firefox bundle, are all the .dylibs? (just thought I'd mention that, in case that was a possible route to take)

:-)