Kirix Support Forums

XUL + WebConnect as GUI framework?

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

XUL + WebConnect as GUI framework?

Postby ildar on Fri Aug 07, 2009 3:36 am

hi guys,

I wonder if it is a good idea to use XUL + wxWebConnect as a GUI framework while keeping all business logic in wxWidgets. XULRunner includes a lot of features a modern application requires such as net connection features, built-in scripting, plugin support similar(or the same?) to firefox extensions and web like GUI. However, XULRunner is an external app, but wxWebConnect seems to solve this.

So the idea is to use wxWebConnect + XUL to render the GUI layout of wxWidgets applications.

Let's say I need an application that uses a database. I use wxWidgets C++ to implement database connection, data queries and processing and then I pass the data to Gecko engine via wxWebConnect to display and get user reaction.

How do you think is it going to work? And is it worth going that way?

And a question to Kirix if possible.
Does your Strata product use Gecko XUL engine in any way?
ildar
Registered User
 
Posts: 2
Joined: Fri Aug 07, 2009 3:11 am

Re: XUL + WebConnect as GUI framework?

Postby Aaron on Fri Aug 07, 2009 9:24 am

I definitely think this is an interesting concept.

In fact, we've used this concept to implement several extensions for Kirix Strata, which itself utilizes wxWebConnect to embed XUL/Gecko. For example, in the Benford's Law extension, we use a web control to display a graph, where the graph is based on data in a database table; in the Picture Puzzle extension, we use a web control for displaying and animating the game tiles and for creating a "cover-flow-like" interface for selecting the picture to use for the puzzle.

Although these extensions are implemented in Strata's scripting language, the scripting language binds to wxWebConnect, so the API calls for the web control in the scripting language are very similar to what you would use if you implemented it directly in wxWidgets. If you look at the code, you'll get a good idea of how to use a web control to render interface elements while implementing logic externally; simply download the extension, change the file extension to *.zip, then extract and view the code.

The basic idea is to "inject" rendering content into the web control, then "talk" to the content via the DOM as follows:

1) load the web-rendered content, 2) listen for events in the content, such as when a button is pressed, 3) get some value from the content when a particular event is triggered and invoke appropriate logic, 4) update the content based on the new state of the system.

1. To load the content into the browser control, create the interface in resource files and load them with wxWebControl::OpenURI(). For example, see MyFrame::OnGoAbout() in in the test application.

When loading content, make sure the content is loaded before interacting with the document via the DOM. This is because web content is loaded asynchronously, and just because a resource is opened doesn't mean that all the content is loaded. To make sure the content is loaded, wait for the wxEVT_WEB_DOMCONTENTLOADED event.

2. Once the content is loaded, listen for events in the DOM by getting the DOM document and adding an event listener for a particular event:

Code: Select all
// create a wxWebControl called m_browser; then:
wxDOMDocument doc = m_browser.GetDOMDocument();

// add an event listener to a particular element
wxDOMElement element = doc.GetElementById("ok");
element.AddEventListener("click", handler);


3. When the event handler is called, get a particular value using the DOM. Then, using this value, perform any necessary logic:

Code: Select all
// get the DOM document
wxDOMDocument doc = m_browser.GetDOMDocument();

// get the element containing the value in which we're interested;
// note: we need to call GetValue() on the element to get the value
wxDOMElement element = doc.GetElementById("input");
wxString value = element.GetValue();


4. Finally, update the content; if it's necessary to invoke a function in the web control, use wxWebControl::Execute()
Aaron Williams
Kirix Support Team
User avatar
Aaron
Kirix Support Team
 
Posts: 120
Joined: Fri Dec 16, 2005 3:01 pm

Re: XUL + WebConnect as GUI framework?

Postby ildar on Sat Aug 08, 2009 3:43 am

Thank you for the response.

Actually the main reason is the lack of database GUI components in wxWidgets. Whereas there is a vast of them in Javascript. So I was thinking of wxWebConnect + XUL + javasript as means to interact with C++ data management code. My only concern is the speed of javascript for displaying and navigating medium size datasets.

Any hints are welcome.
ildar
Registered User
 
Posts: 2
Joined: Fri Aug 07, 2009 3:11 am

Re: XUL + WebConnect as GUI framework?

Postby Aaron on Wed Aug 12, 2009 11:12 pm

Speed is a valid concern, although JavaScript implementations have been getting faster and faster. As we see these improvements make their way into XULRunner, you might be able to leverage JavaScript and still maintain adequate performance. However, at some point, the multiple layers of implementation may simply be too cumbersome to make it worth it. Have you created a test case to see how this might work?
Aaron Williams
Kirix Support Team
User avatar
Aaron
Kirix Support Team
 
Posts: 120
Joined: Fri Dec 16, 2005 3:01 pm

Return to wxWebConnect Questions, Thoughts & Feedback