wxWidgets and PureBasic

Everything else that doesn't fall into one of the other PB categories.
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

wxWidgets and PureBasic

Post by FloHimself »

hi,

after reading at http://briancbecker.com/site/index.php?id=0 that on http://sourceforge.net/project/showfile ... _id=290546 is a dll containing wxWidgets with C API, i converted an example:

Code: Select all

#wxBOTH                  = $0004 | $0008
#wxDEFAULT_FRAME_STYLE   = 541068864

#wxWIDGETS_LIB = 0

Global wx_app
Global wx_frame
Global wx_panel
Global wx_button

Procedure ButtonClick(*event.l, iListener.l)
  wx_msgbox_size = CallCFunction(#wxWIDGETS_LIB, "wxSize_ctor", 150, 50)
  CallCFunction(#wxWIDGETS_LIB, "wxMsgBox", wx_frame, "I'm going bye-bye!", "Bye!", 0, wx_msgbox_size);
  CallCFunction(#wxWIDGETS_LIB, "wxWindow_Close", wx_frame, #True)
  ProcedureReturn 0
EndProcedure

Procedure wxApp_OnInit(*self.l)
  wx_frame = CallCFunction(#wxWIDGETS_LIB, "wxFrame_ctor")
  If wx_frame
    wx_frame_pos  = CallCFunction(#wxWIDGETS_LIB, "wxSize_ctor", 200, 200)
    wx_frame_size = CallCFunction(#wxWIDGETS_LIB, "wxSize_ctor", 500, 300)
    If CallCFunction(#wxWIDGETS_LIB, "wxFrame_Create", wx_frame, 0, -1, "Welcome To WX-C", wx_frame_pos, wx_frame_size, #wxDEFAULT_FRAME_STYLE, "frame")
      
      wx_panel = CallCFunction(#wxWIDGETS_LIB, "wxPanel_ctor")
      CallCFunction(#wxWIDGETS_LIB, "wxPanel_Create", wx_panel, wx_frame, 1, 0, 0, 0, 0)
     
      wx_button       = CallCFunction(#wxWIDGETS_LIB, "wxButton_ctor")
      wx_button_pos   = CallCFunction(#wxWIDGETS_LIB, "wxSize_ctor", 150, 100)
      wx_button_size  = CallCFunction(#wxWIDGETS_LIB, "wxSize_ctor", 100, 30)
  
      CallCFunction(#wxWIDGETS_LIB, "wxButton_Create", wx_button, wx_panel, 2, "Exit!", wx_button_pos, wx_button_size , 0, 0, 0);
 
      CallCFunction(#wxWIDGETS_LIB, "wxEvtHandler_proxy", wx_frame, @ButtonClick())
      wxEvent_EVT_COMMAND_BUTTON_CLICKED = CallCFunction(#wxWIDGETS_LIB, "wxEvent_EVT_COMMAND_BUTTON_CLICKED")
      Debug wxEvent_EVT_COMMAND_BUTTON_CLICKED
      CallCFunction(#wxWIDGETS_LIB, "wxEvtHandler_Connect", wx_frame, wxEvent_EVT_COMMAND_BUTTON_CLICKED, 2, -1, 0)
      CallCFunction(#wxWIDGETS_LIB, "wxWindow_CenterOnScreen", wx_frame, #wxBOTH)
      CallCFunction(#wxWIDGETS_LIB, "wxWindow_Show", wx_frame, #True)
    EndIf
  EndIf
  ProcedureReturn CallCFunction(#wxWIDGETS_LIB, "wxApp_OnInit", wx_app)
EndProcedure

Procedure wxApp_OnExit(*self.l)
  ProcedureReturn CallCFunction(#wxWIDGETS_LIB, "wxApp_OnExit", wx_app)
EndProcedure

If OpenLibrary(#wxWIDGETS_LIB,"wx-c.dll")
  wx_app = CallCFunction(#wxWIDGETS_LIB, "wxApp_ctor")
  If CallCFunction(#wxWIDGETS_LIB, "wxApp_RegisterVirtual", wx_app, @wxApp_OnInit(),  @wxApp_OnExit())
    CallCFunction(#wxWIDGETS_LIB, "wxApp_Run", 1, "")
  EndIf
EndIf
you will need the wx-c.dll from this http://alphafern.com/BrianCBecker/Downl ... c/wx_c.zip archive to test it. there is a linux lib called libwx-c.so also. maybe someone can test this on a linux box??

best regards,
flo
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Heya FloHimself,

Thanks for this!
@}--`--,-- A rose by any other name ..
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Woah!

Cool!

ImageImageImageImageImage
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Post a screenshot so I can see! (I don't want to install the widgets yet).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Very nice ; waiting for userLib :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

PB wrote:Post a screenshot so I can see! (I don't want to install the widgets yet).
No need, just download that zip file that contains the dll and save the pb source in the same dir!
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

ho yes very good topic...

In the past, 2 years ago, i made a Tetris game in Python and wxPython.
It was very nice and smooth with transparency effect and joystick support.
Almost finished until i crash accidently my harddrive :cry:
I recognize all those functions. And i remember how interessant it was to
create GUI thanx wx stuff. Very powerfull and efficient API.
A wxPB userlib would be very welcome :P But i know it's a huge work.
Only a well organized PB-team can make it :twisted:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

i would go with a include file for the dll for varius reasons.. but is someone able to test this on a linux box???
NetSlayer
New User
New User
Posts: 4
Joined: Mon Nov 15, 2004 4:25 pm
Location: Germany
Contact:

Post by NetSlayer »

On Linux it does absolutely nothing. I replaced CallCFunction() with CallFunction() (CallCFunction() is not available on Linux) and removed the "Debug" line. I compiled and executed it but nothing really happens.

Edit: It sucks on opening the library, that doesn't work.
Regards, NetSlayer
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

widget ? What's that ? a better GUI system
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

NetSlayer wrote:On Linux it does absolutely nothing. I replaced CallCFunction() with CallFunction() (CallCFunction() is not available on Linux) and removed the "Debug" line. I compiled and executed it but nothing really happens.

Edit: It sucks on opening the library, that doesn't work.
you used linux lib libwx-c.so from http://prdownloads.sourceforge.net/wxne ... z?download ??
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

NetSlayer wrote:On Linux it does absolutely nothing. I replaced CallCFunction() with CallFunction() (CallCFunction() is not available on Linux) and removed the "Debug" line. I compiled and executed it but nothing really happens.

Edit: It sucks on opening the library, that doesn't work.
That's weird...

I had the same problem with FMOD.so !!!

I can get OpenLibrary to open the damn thing!

Can this be a linux bug !?
NetSlayer
New User
New User
Posts: 4
Joined: Mon Nov 15, 2004 4:25 pm
Location: Germany
Contact:

Post by NetSlayer »

FloHimself wrote:
NetSlayer wrote:On Linux it does absolutely nothing. I replaced CallCFunction() with CallFunction() (CallCFunction() is not available on Linux) and removed the "Debug" line. I compiled and executed it but nothing really happens.

Edit: It sucks on opening the library, that doesn't work.
you used linux lib libwx-c.so from http://prdownloads.sourceforge.net/wxne ... z?download ??
Yes, I did.

@Num3:
Really seems to be a bug. We should tell Fred.
Regards, NetSlayer
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I've posted the OpenLibrary possible bug on the Bug Reports thread...
Post Reply