Developing a Web Browser with Haskell

April 5, 2010

Using wxHtmlWindow with wxHaskell

Filed under: hsbrowser — Tags: , — gcarlos @ 5:59 pm

Hello, today I will show you how to use the wxHtmlWindow of wxWidgets. You would notice that it’s easy to do!!!

WxWidgets has the option to use a render engine for html in his applications, it has a lot of functions to use, like any other html browser, not so rich, but it’s ok. See this documentation.

wxHtmlWindow is not available on Graphics.UI.WX of wxHaskell, it is available  on WXCore, and we can use them only importing Graphics.UI.WXCore. We can use it directly but it depent of you. I will use a function that create the object:

htmlWindow parent props = do
phtml <- htmlWindowCreate parent idAny rectNull 0 “”
set phtml props
return phtml
Until now, we can use all the functions that provides WXCore for this object, we will use an special function htmlWindowLoadPage phtmlwin url, this function permit us to load a web page as his name indicate.
So that’s all, now we will make an graphic interface to use this panel htmlWindows, something easy to demostrate his utility.
Basically we need an entry text and a button to load the web page that is written in the text entry.
inp <- entry  f   [text := "http://www.joes-hardware.com"]
go   <- button f [text := "Get", on command := showPage phtml inp]
I put a default page; the showPage function does what we were talking before.
showPage html inp = do
url  <- get inp text
htmlWindowLoadPage html url
return ()
And finally we I make a layout for this browser:
set f [layout := column 5 [ hfill $ row 5 [hfill $ widget inp , widget go ]
, fill  $ margin 5 $ widget phtml
]
]
That’s all for the interface, you can compile and use it. You can download the source code from here.
About these ads

1 Comment »

  1. Just want to say what a great blog you got here!
    I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!

    Thumbs up, and keep it going!

    Cheers
    Christian, iwspo.net

    Comment by AnonelulptomA — May 24, 2010 @ 5:48 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: