Hi Konstantin,
 
I have started looking at using wxDirect to wrap other wxWidgets components. Bottom line is that you can't really do it with the version we have available today. I'm working on the changes needed (they are not extensive), but since I will be on vacation starting tomorrow, please don't expect any reply for at least 2-3 weeks.
 
Regards
Jeremy
 
On Wed, 07 Apr 2010 10:47 +0100, "Jeremy O'Donoghue" <jeremy.odonoghue@gmail.com> wrote:
Hi Konstantin,
 
To answer your first question, frame returns a Frame (), which, under the hood is an Object  - that's another way of saying that I think your code is at least correctly typed.
 
I think you would need to use wxDirect to integrate properly with wxHaskell. It's a bit tedious, but not especially hard. I'll probably write a blog posting about this soon, but the basics of what you need to do are as follows:
 
Create an Eiffel(!) file containing all of the constant definitions exported by wxWebConnect (or at least the ones you want...). The reason for the Eiffel is historical: wxHaskell was originally built on top of a (long-obsolete) binding of wxWidgets to Eiffel. This requires no real knowledge of Eiffel: it's simply a file containing lines such as:
 
wxMY_CONTROL_SOME_VALUE : INTEGER is 23
 
Create a C header file describing the API you want to wrap - this is somewhat stylized, using macros to describe inheritance.
 
Run wxDirect over the newly created files - this autogenerates C wrappers over the C++ classes/functions with appropriate Haskell to use them.
 
I realize that this is a bit 'handwaving', but a full description really requires quite a lot more than I can manage in a single e-mail.
 
As a little more help, if you download wxCore source code (cabal fetch wxcore), you can look at the following files for inspiration:
 
wxcore/src/include/wxc_glue.h and wxc.h - these show the 'wrapping' style needed.
wxcore/src/eiffel/stc.e - this shows how to define constants in the Eiffel format
 
WxDirect accepts the following options:
 
-d : create constant definitions from .e files
-c : create class definitions from .h files
-t : create class type definitions from .h files
-i : create class info definitions
-o : set the output directory
 
I suspect that you will have a bit of trouble with getting all of this to work, so if you can wait (it may be a couple of weeks), there may be a blog posting to help you.
 
Regards
Jeremy
 
 
On Mon, 05 Apr 2010 18:47 +0400, "Konstantin Chugalinskiy" <kchugalinskiy@gmail.com> wrote:
Hello, wxHaskell community!
 
I need to embed web control into my application under Windows 7. I am trying to use wxWebconnect ( http://www.kirix.com/labs/wxwebconnect/documentation/getting-started.html ) library with Gecko engine for this.
Haskell code:
foreign import stdcall unsafe "_browserFrame"
    c_browserFrame :: Ptr a -> IO(Ptr ())
 
main :: IO ()
main
  = start gui
 
gui :: IO ()
gui = do
    f <- frame [text := "Hello world!", size := (sz 600 600) ]
    withObjectPtr f c_browserFrame
    return ()
 
where browser frame looks like
C++ code:
void* __stdcall browserFrame (wxFrame* ptrWxWindow)
{
    wxString xulrunner_path = FindXulRunner(wxT("xr"));
    wxString dir(wxT("\\plugins"));
    wxWebControl::InitEngine(xulrunner_path);
    wxWebControl::AddPluginPath(dir);
    wxWebControl* ptrBrowser = new wxWebControl(ptrWxWindow, wxID_WEB, wxPoint(0,0), wxSize(600,600)); //Here error comes from
    return ptrWxWindow;
}
it is compiled as dll by MS Visual 2008 and linked to Haskell program.
 
Also it looks like CreateControl execution fails.
It should be mentioned that ptrWxWindow can be operated with no errors (I mean hiding, resizing etc) and no any other kind of control can be created (wxButton, wxLabel).
If first parameter to c_browserFrame (parent window) is objectNull then everything is ok with no changes to gui. I can't understand what is wrong with ptrWxWindow param when passed from Haskell.
typeid(ptrWxWindow).name() shows expected type of ptrWxWindow - wxFrame.
 
What am I doing wrong? Please help me. Or maybe can you help me using your wxdirect subsystem to add this control to wxHaskell?

with best regards,
Chugalinskiy Konstantin
kchugalinskiy@gmail.com
Jabber: koschugalinskiy@jabber.ru
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

-- 
  Jeremy O'Donoghue
  jeremy.odonoghue@gmail.com
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

-- 
  Jeremy O'Donoghue
  jeremy.odonoghue@gmail.com