Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GUI: Proof of concept with wx-c.dll
#1
Hi all,
just wanted to inform you that, after messing around with GTK and GLADE (interesting approach btw...), now I tested the wx-c.dll.
This dll is a C wrapper for the wx (c++) functions, actually made for wx.net.
This way it's possible to use wx with non-oop languages like fb.

The downside is: wx-c.dll is big (1.5Mb UPX'ed) because allmost all wx commands (net,html etc.) are included.
On the other hand it's way smaller than GTK (with or without GLADE)

Almost forgot: another downside: there is no real doc for wx-c.dll but it's possible to use wx/wx.net docs...

BTW:
libwx-c.dll.a is pretty big, but it's only for developers anyhow Smile
wx-c.dll can be copied into the windows directory, it's only needed once...

Have fun

I've uploaded it to:
http://fbtk.qbtk.com/phpBB2/download.php?id=66
Reply
#2
Whoa, i didn't know a C wrapper for wx existed, really cool.

Just one DLL instead of the dozen needed by gtk, no unsafe XML scripts, etc, etc.

It seemed to load way faster than the glade test i wrote and used half the memory.

Any C headers that could be translated? We could team up to do that or something..

I wonder if it's portable too.. gonna check the wx.net..
Reply
#3
Because of wx's portable nature (there is also a dll for linux), I thought that it would be a good
complement to fb.

I don't have any wx experience at all, so for me it would be new territory.
But maybe there is somebody in fb-land that knows wx.

Another idea is to use the wx-c.dll and wx sources and make tons of static libs
(don't know if it's doable though...) this way, at least under windows,
the dll would not be needed, and the exe still not too big.
On the other hand, don't know if it's worth the hassle.

For now I think the wx-c.dll approach is not too bad, because the exe's are really small Big Grin

BTW: First I thought that wx is a bad idea, because with MinGWStudio a "HelloWorld" exe is 1.3Mb, but with this dll it's ok.
Reply
#4
Nah, it's really cool, unpacking the DLL and now the window+dlg test used only ~2mb (UPX will take twice the mem with DLL's, if i remember).

I checked the wxnet site, yeah, it runs in Linux and OS X, besides Windows -- the only worth OSes ;).

Seems like the C headers can be generated using that wx-c-gen perl script, but there will be quite alot of code, as there are loads of wx headers, only a team of experienced C and VB/FB/PB coders to do the translation.. maybe the perl script could be adapted too, dunno.

Wx seems more simple to use than Gtk, imo.. and with the wx-c wrappers returning only handles that can be "seen" as ordinary integers, nothing could be easier..
Reply
#5
download doesn't work. i got this ftp error. :x
Quote:Could not login to FTP Server. The Username 'u35831231qbtk' or the Password is wrong. Please check your FTP-Settings.
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#6
Downloaded it yesterday right after the upload, and it worked fine.

Downloaded it a few minutes ago and it worked fine too.

Don't know what was wrong, but hope you can download it now without problems.
Reply
#7
It cool. Now only to figure out how to work events. Maybe a team can start to port the C# code from the wx.NET library? I'm looking through it to find out how to use it.
Reply
#8
Example of a button event:
Code:
' proof of concept by fsw
' gui using the wx-c.dll found in wx.net
'
' wx-c is a c wrapper dll for the c++ wx functions.
'
' downside is: wx-c.dll is big (1.5Mb UPX'ed)
' because allmost all wx commands (net,html etc.) are
' included (look at wx-c.func.txt)
'
' on the other hand it's way smaller than GTK (with or without GLADE)
'
' almost forgot...
' another downside: there is no real doc for wx-c.dll
' but it's possible to use wx/wx.net docs...
'
' BTW:
' libwx-c.dll.a is pretty big, but it's only for developers anyhow :)
' wx-c.dll can be copied into the windows directory,
' so it's only needed once...

'$include: "wx-c\\libwx-c.bi"

dim shared wx_Frame as long

Sub ButtonClick ( byval event as long, byval iListener as long)

  wx_msgbox_size = wxSize_ctor (150, 50)
  wxMsgBox (wx_frame, "I'm going bye-bye!", "Bye!", 0, wx_msgbox_size)
  wxWindow_Close (wx_frame, 1)

End Sub

sub wxApp_OnInit ()

    wx_Frame = wxFrame_ctor ()

    wx_frame_pos  = wxSize_ctor ( 200, 200)
    wx_frame_size = wxSize_ctor ( 500, 300)

    wxFrame_Create (wx_Frame, 0, 1, "Welcome to WX-C", wx_frame_pos, wx_frame_size, wxDEFAULT_FRAME_STYLE, "frame" )

    wx_panel = wxPanel_ctor ()
    wxPanel_Create (wx_panel, wx_frame, 1, 0, 0, 0, 0)

    wx_button       = wxButton_ctor ()
    wx_button_pos   = wxSize_ctor (150, 100)
    wx_button_size  = wxSize_ctor (100, 30)

    wxButton_Create (wx_button, wx_panel, 2, "Exit!", wx_button_pos, wx_button_size , 0, 0, 0)

    wxEvtHandler_proxy (  wx_button, @ButtonClick)
    wxEvtHandler_Connect ( wx_button, wxEvent_EVT_COMMAND_BUTTON_CLICKED (), 2, -1, 0)

    wxWindow_Show ( wx_frame, 1)

End Sub

sub wxApp_OnExit()

    ' here your code executed on exit
    wx_msgbox_size = wxSize_ctor ( 150, 50)
    wxMsgBox ( wx_frame, "Bye Bye...", "Window Closed!", 0, wx_msgbox_size)

End Sub


' main code...

  wx_app = wxApp_ctor()
  wxApp_RegisterVirtual ( wx_app, @wxApp_OnInit,  @wxApp_OnExit)

  wxApp_Run()

end
Reply
#9
Well the runtime is a bit big but 1.5Mb is only like 150K now days on most peoples systems. It seem like a good library for a crossplatform gui. Maybe the other gui libraries/compilers some others are making on here can adapt it if they don't mind the overhead? It will be really cool to use if classes ever get implemented.
Reply
#10
To make things even easier:
Code:
' proof of concept by fsw
' gui using the wx-c.dll found in wx.net
'
' wx-c is a c wrapper dll for the c++ wx functions.
'
' downside is: wx-c.dll is big (1.5Mb UPX'ed)
' because allmost all wx commands (net,html etc.) are
' included (look at wx-c.func.txt)
'
' on the other hand it's way smaller than GTK (with or without GLADE)
'
' almost forgot...
' another downside: there is no real doc for wx-c.dll
' but it's possible to use wx/wx.net docs...
'
' BTW:
' libwx-c.dll.a is pretty big, but it's only for developers anyhow :)
' wx-c.dll can be copied into the windows directory,
' so it's only needed once...

'$include: "wx-c\\libwx-c.bi"

dim shared wx_Frame as long
dim shared wx_Panel as long
dim shared wx_button1 as long
dim shared wx_button2 as long
dim shared wx_id as long
wx_id = 100

Sub ButtonClick1 ( byval event as long, byval iListener as long)

  wx_msgbox_size = wxSize_ctor (150, 50)
  wxMsgBox (wx_frame, "Hello!", "Hi!", 0, wx_msgbox_size)

End Sub

Sub ButtonClick2 ( byval event as long, byval iListener as long)

  wx_msgbox_size = wxSize_ctor (150, 50)
  wxMsgBox (wx_frame, "I'm going bye-bye!", "Bye!", 0, wx_msgbox_size)
  wxWindow_Close (wx_frame, 1)

End Sub

Function New_wx_Frame (parent, x, y, w, h, style, title as string) as integer

    wx_Frame = wxFrame_ctor ()

    wx_frame_pos  = wxSize_ctor ( x, y)
    wx_frame_size = wxSize_ctor ( w, h)

    wxFrame_Create (wx_Frame, parent, 1, title, wx_frame_pos, wx_frame_size, style, "frame" )
    New_wx_Frame = wx_Frame

End Function

Function New_wx_Panel (parent) as integer

    wx_panel = wxPanel_ctor ()
    wxPanel_Create (wx_panel, parent, 1, 0, 0, 0, 0)
    New_wx_Panel = wx_panel
End Function

Function New_wx_Button (parent, x, y, w, h, text as string, connect_function) as integer
    
    wx_id = wx_id + 1
    wx_button       = wxButton_ctor ()
    wx_button_pos   = wxSize_ctor (x, y)
    wx_button_size  = wxSize_ctor (w, h)

    wxButton_Create (wx_button, parent, wx_id, text, wx_button_pos, wx_button_size , 0, 0, 0)

    wxEvtHandler_proxy ( wx_button, connect_function)
    wxEvtHandler_Connect ( wx_button, wxEvent_EVT_COMMAND_BUTTON_CLICKED (), wx_id, -1, 0)

    New_wx_Button = wx_button

End Function

sub wxApp_OnInit ()

    wx_Frame = New_wx_Frame (0,200, 200,500, 300, wxDEFAULT_FRAME_STYLE, "Welcome to WX-C")
    wx_panel = New_wx_Panel (wx_frame)

    wx_button1 = New_wx_Button (wx_panel, 150, 100, 100, 30, "Hello", @ButtonClick1)
    wx_button2 = New_wx_Button (wx_panel, 300, 100, 100, 30, "Exit!", @ButtonClick2)

    wxWindow_Show ( wx_frame, 1)

End Sub

sub wxApp_OnExit()

    ' here your code executed on exit
    wx_msgbox_size = wxSize_ctor ( 150, 50)
    wxMsgBox ( wx_frame, "Bye Bye...", "Window Closed!", 0, wx_msgbox_size)

End Sub


' main code...

  wx_app = wxApp_ctor()
  wxApp_RegisterVirtual ( wx_app, @wxApp_OnInit,  @wxApp_OnExit)

  wxApp_Run()

end
8)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)