Another GUI alternative?

Nilo Nilo_member at pathlink.com
Mon Apr 17 13:08:58 PDT 2006


In article <e20qrb$h1c$1 at digitaldaemon.com>, clayasaurus says...
>
>Nilo wrote:
>> In article <e20mc9$bc5$1 at digitaldaemon.com>, clayasaurus says...
>>> Nilo wrote:
>>>> My question is: has someone tried to use fox from D? Would be possible for D
>>>> call a library written in C++? 
>>> Yes.
>>>
>>> If it is possible, what sould I do to port that
>>>> library in a D's usable manner?
>>> Create a C wrapper for it, then call the C wrapper from D.
>> 
>> What are the steps involved in creating a wrapper from C++? Is there a simple
>> tutorial or how-to? Or samples?
>> 
>> I've done a search but could not find...
>> 
>> I would like to start these port. Maybe I can do it... ;-)
>> 
>> TIA
>> 
>> Nilo
>> 
>
>#1) First compile a foktk.lib of this library with DMC.
>
>#2) The 'C' wrapper will be done in C++, but is called the C wrapper 
>because you wrap the classes into C functions. First you have to locate 
>the important classes in the library, and then you must create wrappers 
>for them. It may go something like...
>
>------------------------------------------------
>#include "foxtk.h"
>
>Window *window;
>
>void window_Start(char[] title, int x, int y)
>{
>    window = new Window("Title", x,y);
>}
>
>void window_Close()
>{
>    window.close();
>    delete window;
>}
>------------------------------------------------
>
>Compile this with DMC as well, we'll name it foxtkglue.lib.
>
>#3) The D interface. You can so something like...
>
>module window;
>
>// pretty it up
>void start() { window_Start() }
>void close() { window_Close() }
>
>// C-functions
>extern(C)
>{
>void window_Start(...);
>void window_Close(...);
>}
>
>#4) Using
>Compile your D code with your two .lib's, and do something like...
>
>import window;
>
>main()
>{
>   window.start(..,..,..);
>   window.close(..,..,..);
>}
>
>----------------------------
>Here's a C interface example I created with RakNet. 
>http://www.dsource.org/projects/bindings/browser/trunk/raknet/rakglue
>
>Goodluck.
>~ Clay
>
>
>

Thanks a lot, Clay, for your prompt responses. I'll study your suggestions and
code later.

Maybe I can do something about Fox...

Thanks. I'll keep you ( and the list ) informed about any progress. Obviously
I'll share any code that cames from these... ;-)

Nilo






More information about the Digitalmars-d mailing list