wxWidgets 2.8.12 FreeBASIC C wrapper

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

It's not good to break with old structures.

I think it's ok to make a OOP-wrap because it's on code-base in the header and don't affect the wrapper. Add new things to the wrapper will break the compatibility to the original wx-c and this may be a real problem for feature versions. A solution could be overloading the functions but with every new version of wx-c all the changes have to be done again.


For now I'll keep to the last version of the header. Thank you so far.
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

I don't understand you
why you will use the wrong version of wxEvtHandler ?

The addesss of the EventHandler callback was stored in the UserData property
and can be overwritten with your own UserData thats is an critical error:

and what are better ?

wxEvtHandler_proxy(MyButton, @MyEventListener)
wxEvtHandler_Connect(MyButton,EventType)

or the real wxWidget call

wxEvtHandler_Connect(MyButton,EventType,@MyEventHandler)

Again the wc-c project is dead you are talk about the wx.NET C wrapper
(and this wrapper is out of date wxWidget 2.6)

Joshy
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

wx-c is part of WX.Net and the latest version is 0.9.2, based on wxWidgets 2.8. The last release was at 2010-07-14. It's just one year and it's not dead.

I want to use the lib provided with this release (at least the code of the bundle). This is what FreeBASICs header did and should do as long as we can't use wxWidgets without any wrapper.

Maybe their eventcall isn't the best solution, but changing it will break with the original code and will break a lot of codes written.

You're doing a wx-c 'fork'...
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Post by Coolman »

MOD wrote:wx-c is part of WX.Net and the latest version is 0.9.2, based on wxWidgets 2.8. The last release was at 2010-07-14. It's just one year and it's not dead.

I want to use the lib provided with this release (at least the code of the bundle). This is what FreeBASICs header did and should do as long as we can't use wxWidgets without any wrapper.

Maybe their eventcall isn't the best solution, but changing it will break with the original code and will break a lot of codes written.

You're doing a wx-c 'fork'...
Or more logical to use the official wxwidgets to ensure future compatibility, well ok I get out ...
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

If i renember me right the first FreeBASIC wx-c headers was from wxc.sourceforge.net

Be open for new things in the world of IT things changing very often. :-)

I'm not a slave from any NET or MONO project we can have our own wxWidgets FB wrapper.

I added wxGLCanvas, wxTimer, wxSound and will add all the missing cool stuff TCPServer, TCPClient ... later.
I fixed some mistakes and made every class safer if(self!=NULL) and so one
i wrote a new 100% compatibe wxEvtHandler.

Now it's your turn would be cool if you support FreeBASIC with your wxDesigner.

Joshy
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

http://www.freebasic.net/index.php/deta ... =lib&id=35

It's WX.Nets wrapper not wxc.

It is easier to have the Net-people which update the wrapper and only translate the header than when 1-2 people update a special FB-version.

If you want to provide this new methods maybe it would be an idea to split it up in two libs. The first one just uses the original wx-c methods, the second one the new methods.
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

The wx-c lib is uptodate for Linux and Windows now.

buttonarray_object.bas
buttonarray_wx-c.bas
clientdc01_object.bas
clientdc01_wx-c.bas
demo01_wx-c.bas
glcanvas01_wx-c.bas
mdi01_wx-c.bas
menu01_wx-c.bas
sizer01_wc-c.bas
sound01_wc-c.bas
test01_object.bas
test01_wx-c.bas
test02_object.bas
test02_wx-c.bas
test03_wx-c.bas
timer01_wx-c.bas
wstring_2_fb.bas

please test it on your box

pease

Joshy
Last edited by D.J.Peters on Jul 12, 2011 16:38, edited 1 time in total.
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Now I'm back at home and made some tests on linux
all works fine except "mdi01_wx-c.bas".
I don't know why but the ChildFrames are not shown ?

with "upx -9 wx-c.dll" the dll are 1.75MB

Joshy
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

I saw that you asked what would be better (not really sure, I had no time to read it) and now it's edited. If it was about the lib: the best way to handle it would be, that the libs provided with wx.Net 0.9.2 would work with FB. This is not as easy because of the underscore in this version. Soon I'll have some sparetime and will look at this problem so that we get header for both windows and linux for this lib without having to compile it by yourself. Any further functions should be done with a second lib, a ext-wx-c-lib. I remember defines in your edited code (WX_CODE_ADVANCED). This could be added to the FB-header so that there will be no problems with the original version of the lib and just small fixes needed for new versions and provide additional functionality.
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

MOD you don't need to define anything
why you don't test the last version ?

after #include "inc/wx.bi" it's pure wx-c

all examples you posted works without any changes

Joshy
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

You maybe changed the eventhandling but it's not 'pure' wx-c. It's compiled by you (btw I'm not sure if you're allowed to add your name as an autor) with lots of functions, which are not included in the original version.

It's maybe nice to have this but what will happen if the wx.Net people change lot of things in the code? You'll have to do it all again.

(demo01_wx-c.bas isn't compiling properly and why this wxSound-info, this warnings are annoying.)
D.J.Peters
Posts: 8588
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Only in this one example the old wxEvtHandler_proxy() was missed.

I hope do you have fun with your destructive comments.

demo01-wx-c.bas

Code: Select all

''
'' wxWindows-c example, by dumbledore
''

#define DEBUG
#Include Once "inc/wx.bi"

Const FRAME_W = 500
Const FRAME_H = 400

''
'' ids
''
Enum
  ID_FRAME=1
  ID_PANEL
  ID_CLICKMEBUTTON
  ID_EXITBUTTON
  ID_DIAG_EXITBUTTON
End Enum

Declare Function app_oninit_cb APICALL () As wxBool
Declare Function app_onexit_cb APICALL () As wxInt

''
'' globals
''
Dim Shared As _wxApp Ptr app
Dim Shared As _wxFrame Ptr frame
Dim Shared As _wxDialog Ptr dialog

'':::::
''
'' main 
''
app = wxApp_ctor()
wxApp_RegisterVirtual(app, @app_oninit_cb, @app_onexit_cb)
wxApp_Run

'':::::
''
'' dialog's exit button callback
''
Sub diag_exitbutton_cb APICALL (ByVal event As _wxEvent Ptr,iListener as wxInt)
  dprint("diag_exitbutton_cb")
  wxDialog_EndModal( dialog, 0 )
End Sub

'':::::
''
'' panel's click-me button callback
''
Sub panel_clickmebutton_cb APICALL (ByVal event As _wxEvent Ptr,iListener as wxInt)
  dprint("panel_clickmebutton_cb")
  wxDialog_ShowModal( dialog )
end Sub

'':::::
''
'' panel's exit button callback
''
Sub panel_exitbutton_cb APICALL (ByVal event As _wxEvent Ptr,iListener as wxInt)
  dprint("panel_exitbutton_cb")
  wxWindow_Close( frame, 0 )
End Sub

'':::::
''
'' on init callback
''
Function app_oninit_cb APICALL () As wxBool
  dprint("app_oninit_cb")
  Dim As Integer ypos, size
   
  '' create the main window
  frame = wxFrame_ctor( )
  wxFrame_Create(frame,,ID_FRAME, wxString("Welcome to WX-C"), _
       200, 200, FRAME_W, FRAME_H, _
       wxFRAME_DEFAULT_STYLE, WX_NULL )
   
  '' make a dialog
  dialog = wxDialog_ctor( )
  wxDialog_Create(dialog, frame, -1, wxString("Press Exit"),_
       10, 10, 500, 400, _
    wxFRAME_DEFAULT_STYLE, 0 )
   
  '' add widgets to the dialog
  size = 27
  ypos=1

  wxButton_Create(wxButton_ctor(),dialog,,wxString("&Goto")  ,405,ypos,85)
  ypos += size
   
  wxButton_Create(wxButton_ctor(),dialog,,wxString("&Select"),405,ypos,85)
  ypos += size
   
  wxButton_Create(wxButton_ctor(),dialog,,wxString("E&dit")  ,405,ypos,85)
  ypos += size
   
  wxButton_Create(wxButton_ctor(),dialog,,wxString("&Add")   ,405,ypos,85)
  ypos += size
   
  Dim As _wxButton Ptr diag_exitbutton = wxButton_ctor( )
  wxButton_Create(diag_exitbutton, dialog, ID_DIAG_EXITBUTTON, _
                  wxString("&Exit"), 405, ypos, 85)
  wxEvtHandler_proxy(diag_exitbutton,@diag_exitbutton_cb)
  wxEvtHandler_Connect(diag_exitbutton,wxEvent_EVT_COMMAND_BUTTON_CLICKED( ))

  
  Dim As _wxListBox Ptr selector = wxListBox_ctor( )
  wxListBox_Create( selector, dialog,,,,400,350,0, LB_SINGLE Or LB_NEED_SB Or LB_HSCROLL)
    
  Dim As _wxFont Ptr font = wxFont_ctor( 10, wxMODERN, wxNORMAL, wxNORMAL, 0, 0, 0 )
  wxWindow_SetFont( selector, font )
    
  Dim As Integer i
  Dim As _wxArrayString Ptr tempString = wxArrayString_ctor( )
  For i = 0 To 15
    wxArrayString_Add( tempString, wxString("list item " + Str( i+1 )) )
    wxListBox_InsertItems( selector, tempString, i )
    wxArrayString_Clear( tempString )
  Next i
   
  '' create the main panel
  Dim As _wxPanel Ptr panel = wxPanel_ctor( )
  wxPanel_Create( panel, frame, ID_PANEL, 0, 0, 0, 0 )
   
  '' create a text widget
  '' we're not using this thing for any events so it gets an id of -1
  Dim As _wxTextCtrl Ptr text = wxTextCtrl_ctor( )
  wxTextCtrl_Create(text, panel,, wxString("Hello from wx-c in fb!"), _
                    8,8,FRAME_W-24,FRAME_H-200, wxVSCROLL)
       
  wxTextCtrl_SetFont( text, font )
   
  '' make a button (sending a wxsize(-1,-1) means take the default size -
  '' you can specify just x or y as -1 if you want the other one to be a fixed size
  Dim As _wxButton Ptr panel_clickmebutton = wxButton_ctor( )
  wxButton_Create(panel_clickmebutton, panel, ID_CLICKMEBUTTON, _
                  wxString("show dialog"), FRAME_W\2 - 100, FRAME_H - 60)
   
  '' connect the button to the button event handler sub
  wxEvtHandler_proxy(panel_clickmebutton,@panel_clickmebutton_cb)
  wxEvtHandler_Connect(panel_clickmebutton,wxEvent_EVT_COMMAND_BUTTON_CLICKED( ))
  
  
  ''
  Dim As _wxButton Ptr panel_exitbutton = wxButton_ctor( )
  wxButton_Create(panel_exitbutton, panel, ID_EXITBUTTON, _
                  wxString("Exit"), FRAME_W\2 + 40, FRAME_H - 60)
   
  '' connect the button to the button event handler sub
  wxEvtHandler_proxy(panel_exitbutton,@panel_exitbutton_cb)
  wxEvtHandler_Connect(panel_exitbutton,wxEvent_EVT_COMMAND_BUTTON_CLICKED( ))

   
  '' center it
  wxWindow_CenterOnScreen(frame, wxBOTH )
    
  '' show window
  wxWindow_Show(frame)

  Function = wxApp_OnInit(app)
    
End Function

'':::::
''
'' on exit callback
''
Function app_onexit_cb APICALL () As wxInt
  dprint("app_onexit_cb")
  wxMsgBox(,wxString("Bye Bye..."), wxString("Window Closed!"))

  Function = wxApp_OnExit( app )
    
End Function
 
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Post by MOD »

No, I think you missunderstood what I'm trying to say. I really appreciate what you've done, it's the first step to get the latest wx-c working with FB. But, everthing you're doing beyond the wx.Net version of wx-c, it's not wx-c anymore. It's a new wrapper for wxWidgets, call it wxFB or what you want, but it's not wx-c anymore.

I also really like your implementations for new widgets but my plan is to have compatible header and a compatible designer for the wx-c version included with wx.Net 0.9.2. This is my first aim, nothing more nothing less. When I'm at this point that their lib works with the designer I'll consider making a extended designer for your new wrapper. This will sure take some time but I think it's exactly what FB needs.

My suggestions:
- first rename the lib so it's clear that it's not wx-c from the wx.Net project
- implement all functions and everything what you thing it's a good idea
- make examples for everything what's beyond the original wx-c functionality

Then we can easily change the designers output and it will support your new lib.
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

can you one "Screenres 300,300,32" in the canvas 800x600 ?

gruss
mayankjohri
Posts: 7
Joined: Jun 04, 2010 12:22

Post by mayankjohri »

I am trying to xrc for gui design and is at a loss how to get the update the controls such as checklistctrl.

In the below example when i use wxwindow functions to update the controls then they work. but if i try to use the control specific functions they fail.

In python I used to use "xrc.XRCCTRL" but i am not able to find any equivalent to that.

Any help will be great.

Code: Select all

#Define DEBUG
#Include Once "wx-c/wx.bi"
#Include Once "wx-c/arraystring.bi"
#include Once "wx-c/common.bi"
#Include Once "wx-c/listbox.bi"
#include once "wx-c/window.bi"

Const FRAME_W = 500
Const FRAME_H = 400

''
'' ids
''
Enum
  ID_FRAME=1
  ID_PANEL
  ID_CLICKMEBUTTON
  ID_EXITBUTTON
  ID_DIAG_EXITBUTTON
End Enum

Declare Function app_oninit_cb APICALL () As wxBool
Declare Function app_onexit_cb APICALL () As wxInt

''
'' globals
''
Dim Shared As _wxApp Ptr app
Dim Shared As _wxDialog Ptr dialog

'':::::
'''
'' main 
''
'Dim apps As _wxApp Ptr
app = wxApp_ctor()
wxApp_RegisterVirtual(app, @app_oninit_cb, @app_onexit_cb)
wxApp_Run

'':::::
''
'' dialog's exit button callback
''
Sub diag_exitbutton_cb APICALL (ByVal event As _wxEvent Ptr,iListener as wxInt)
	'wxMsgBox(,wxString("Bye Bye...1"), wxString("Window Closed!")) 
  	dprint("diag_exitbutton_cb")
  	wxWindow_Destroy( dialog)
  	app_onexit_cb(  )
End Sub

'':::::
''
'' on init callback
''
Function app_oninit_cb APICALL () As wxBool
  dprint("app_oninit_cb")
  Dim As Integer ypos, size
  Dim xrc As _wxXmlResource Ptr
  '' create the main window

  xrc = wxXmlResource_ctorByFilemask(wxString("frmMayaMyAppsClient.xrc"), XRC_USE_LOCALE)
  wxXmlResource_InitAllHandlers(xrc)
  dialog = wxDialog_ctor( )
  
  wxDialog_Create(dialog,WX_NULL,-1, wxString("Press Exit"),_
      10, 10, 500, 400, _
    	wxDIALOG_DEFAULT_STYLE, 0 ) ' Does not make any difference what type you set as they are overwritten by XRC
  wxXmlResource_LoadDialogDlg(xrc, dialog, 0, wxString("frmMain"))
  wxWindow_CenterOnScreen(dialog, wxBOTH )
  
  wxEvtHandler_proxy(dialog,@diag_exitbutton_cb)
  wxEvtHandler_Connect(dialog,wxEvent_EVT_CLOSE_WINDOW( ))

  Dim m_notebook1 As _wxNotebook Ptr
  Dim m_clInstalled As _wxCheckListBox Ptr
  Dim m_staticText2 As _wxTextCtrl Ptr

  	m_clInstalled = wxWindow_FindWindowByName(wxString("m_hyperlink1"), dialog)
  	m_staticText2 =  wxWindow_FindWindowByName(wxString("m_staticText2"), dialog)
	
[b]	' These do not work and result in program crash
	'wxTextCtrl_SetValue(m_staticText2, wxString("testing"))
	'm_staticText2->SetValue(wxString("test"))
	
	' These works just fine
	wxWindow_SetLabel(m_staticText2,  wxString("tesT"))
	wxWindow_Hide(m_clInstalled)
[/b]		
	
  wxWindow_Show(dialog)
  
  Function = wxApp_OnInit(app)
End Function

Function app_onexit_cb APICALL () As wxInt
  dprint("app_onexit_cb")
  Function = wxApp_OnExit( app )
  End
End Function
xrc file

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
	<object class="wxDialog" name="frmMain">
		<style>wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</style>
		<size>600,300</size>
		<title>maya Apps Manager Client, Ver: 0.0.1</title>
		<centered>1</centered>
		<object class="wxBoxSizer">
			<orient>wxVERTICAL</orient>
			<object class="sizeritem">
				<option>1</option>
				<flag>wxEXPAND | wxALL</flag>
				<border>5</border>
				<object class="wxNotebook" name="m_notebook1">
					<object class="notebookpage">
						<label>Installed Applications</label>
						<selected>1</selected>
						<object class="wxPanel" name="m_panel1">
							<style>wxTAB_TRAVERSAL</style>
							<object class="wxBoxSizer">
								<orient>wxVERTICAL</orient>
								<object class="sizeritem">
									<option>1</option>
									<flag>wxEXPAND</flag>
									<border>5</border>
									<object class="wxBoxSizer">
										<orient>wxVERTICAL</orient>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL|wxEXPAND</flag>
											<border>5</border>
											<object class="wxCheckListBox" name="m_clInstalled">
												<style>wxLB_EXTENDED|wxLB_MULTIPLE|wxLB_NEEDED_SB|wxLB_SORT|wxSTATIC_BORDER</style>
												<content>
													<item>dummy1</item>
													<item>dummy2</item>
												</content>
											</object>
										</object>
									</object>
								</object>
								<object class="sizeritem">
									<option>0</option>
									<flag>wxEXPAND</flag>
									<border>5</border>
									<object class="wxBoxSizer">
										<orient>wxHORIZONTAL</orient>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL</flag>
											<border>5</border>
											<object class="wxButton" name="m_bUninstallPhysicalApp">
												<style>wxNO_BORDER</style>
												<label>Uninstall</label>
												<default>0</default>
											</object>
										</object>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL</flag>
											<border>5</border>
											<object class="wxButton" name="m_bRepairPhysicalApp">
												<style>wxNO_BORDER</style>
												<label>Repair</label>
												<default>0</default>
											</object>
										</object>
									</object>
								</object>
								<object class="sizeritem">
									<option>0</option>
									<flag>wxALL</flag>
									<border>5</border>
									<object class="wxStaticText" name="m_staticText2">
										<label>MyLabel</label>
										<wrap>-1</wrap>
									</object>
								</object>
							</object>
						</object>
					</object>
					<object class="notebookpage">
						<label>Available Applications</label>
						<selected>0</selected>
						<object class="wxPanel" name="m_panel2">
							<style>wxTAB_TRAVERSAL</style>
							<object class="wxBoxSizer">
								<orient>wxVERTICAL</orient>
								<object class="sizeritem">
									<option>1</option>
									<flag>wxEXPAND</flag>
									<border>5</border>
									<object class="wxBoxSizer">
										<orient>wxVERTICAL</orient>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL|wxEXPAND</flag>
											<border>5</border>
											<object class="wxCheckListBox" name="m_clAvailableApps">
												<style>wxSTATIC_BORDER</style>
												<content />
											</object>
										</object>
									</object>
								</object>
								<object class="sizeritem">
									<option>0</option>
									<flag>wxEXPAND</flag>
									<border>5</border>
									<object class="wxBoxSizer">
										<orient>wxHORIZONTAL</orient>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL</flag>
											<border>5</border>
											<object class="wxButton" name="m_bInstallApps">
												<style>wxNO_BORDER</style>
												<label>Install selected Apps</label>
												<default>0</default>
											</object>
										</object>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL</flag>
											<border>5</border>
											<object class="wxButton" name="m_bReRefreshAvailableAppsList">
												<style>wxNO_BORDER</style>
												<label>Refresh List</label>
												<default>0</default>
											</object>
										</object>
									</object>
								</object>
							</object>
						</object>
					</object>
					<object class="notebookpage">
						<label>Configuration Panel</label>
						<selected>0</selected>
						<object class="wxPanel" name="m_panel3">
							<style>wxTAB_TRAVERSAL</style>
							<object class="wxBoxSizer">
								<orient>wxVERTICAL</orient>
								<object class="sizeritem">
									<option>0</option>
									<flag>wxEXPAND</flag>
									<border>5</border>
									<object class="wxBoxSizer">
										<orient>wxHORIZONTAL</orient>
										<object class="sizeritem">
											<option>0</option>
											<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
											<border>5</border>
											<object class="wxStaticText" name="m_staticText1">
												<label>Packages DB Location:</label>
												<wrap>-1</wrap>
											</object>
										</object>
										<object class="sizeritem">
											<option>1</option>
											<flag>wxALL</flag>
											<border>5</border>
											<object class="wxFilePickerCtrl" name="m_sqliteDBPicker">
												<value></value>
												<message>Select the SQLite DB File</message>
												<wildcard>*.*</wildcard>
												<style>wxFLP_CHANGE_DIR|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL|wxSIMPLE_BORDER</style>
											</object>
										</object>
										<object class="sizeritem">
											<option>0</option>
											<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
											<border>5</border>
											<object class="wxButton" name="m_bUpdateConfiguration">
												<style>wxNO_BORDER</style>
												<label>Update</label>
												<default>0</default>
											</object>
										</object>
									</object>
								</object>
							</object>
						</object>
					</object>
				</object>
			</object>
			<object class="sizeritem">
				<option>0</option>
				<flag>wxALL|wxALIGN_CENTER_HORIZONTAL</flag>
				<border>5</border>
				<object class="wxHyperlinkCtrl" name="m_hyperlink1">
					<label>Mayank&apos;s Home</label>
					<url>mayankjohri.wordpress.com</url>
					<style>wxHL_DEFAULT_STYLE</style>
				</object>
			</object>
		</object>
	</object>
</resource>
Post Reply