|
Post by Adam on Jan 14, 2009 17:13:14 GMT -5
i thought i would use callbacks like you did with your newton plugin so when some kind of action is called it will send it to the dll and the dll will call the function you set for it
i got a warning from doing that, but thanks IT COMPILED! YAY
now for sending the int back into the plugin would i have to set a pointer to it to be able to use it?
|
|
|
Post by Adam on Jan 14, 2009 17:40:49 GMT -5
it compiled but when i try to run it i get an exception =[
|
|
|
Post by DJLinux on Jan 14, 2009 20:02:21 GMT -5
it compiled but when i try to run it i get an exception =[ post your code complete
|
|
|
Post by DJLinux on Jan 14, 2009 21:47:09 GMT -5
here are the startingpoint for your Gtk plug-in Download: GtkPlugin.zipi included my current "Basic4GLMacros.bi" file see the code how simple it can be ' runtime ' [d]eclare lugin [f]unction DPF(same_name_as_in_the_GTK_lib) ' call the gtk function same_name_as_in_the_GTK_lib() END SUB
' plugin ' [r]egister [v]oid [f]unction RVF(same_name_as_in_the_GTK_lib) "test01.gb" will open an GTK window gtk_init() dim hWin=gtk_Window_New(GTK_WINDOW_TOPLEVEL) gtk_window_set_title(hWin,"GTK Plug -In for B4GL!") gtk_widget_show_all(hWin)
while TRUE gtk_main_iteration() sleep(100) wend let me know if you need help Joshy #include "gtk/gtk.bi" #include "Basic4GLMacros.bi"
dim shared as IDLL_Basic4GL_Plugin ptr Plugin dim shared as string gLastError
extern "C"
DPF(gtk_init) gtk_init(0,0) end sub DPF(gtk_exit) gtk_exit(GIP(1)) end sub
DPF(Gtk_Window_New) SIR( cast( integer,Gtk_Window_New(GIP(1)) ) ) end sub DPF(gtk_window_set_title) gtk_window_set_title( GTK_WINDOW( GIP(2) ),GSP(1)) end sub DPF(gtk_widget_show_all) gtk_widget_show_all(GTK_WIDGET( GIP(1) )) end sub DPF(gtk_events_pending) SIR(gtk_events_pending) end sub DPF(gtk_main_iteration) SIR(gtk_main_iteration()) end sub
' ########## ' # Plugin # ' ########## function Load(THIS_PLUGIN , _ THIS_REGISTRY, _ blnIsExe as byte) as byte ' register const's by name and value RIC(GTK_WINDOW_TOPLEVEL,GTK_WINDOW_TOPLEVEL)
' gegister runtime functions RVF(Gtk_Init) RVF(gtk_exit):AIP RIF(Gtk_Window_New):AIP RVF(Gtk_Window_Set_Title):AIP:ASP RVF(Gtk_Widget_Show_All):AIP RIF(gtk_events_pending) RIF(gtk_main_iteration) return 1 end function
end extern
|
|
|
Post by Adam on Jan 16, 2009 2:22:36 GMT -5
thank you for all the help but it turns out i just forgot to add a gtkinit call... my code works now lol i do have a question though, how would i set the callback for this where @destroy is a function in b4gl code? g_signal_connect (G_OBJECT (win), "destroy", G_CALLBACK (@destroy), NULL) gtk_main_iteration? hmm good idea 
|
|
|
Post by Adam on Jan 16, 2009 4:57:06 GMT -5
i have buttons showing up now and will post the first dll when i figure out g_signal_connect so i can get the program to close properly without using task manager  EDIT: djlinux, what exactly is this line doing in your newton dll? gpBodyUserData->ForceAndTorqueCallback=gpCompiler->Compile(GS(1)); is it just compiling the string? and if so, i can't find a compile or similiar function in freebasic =[
|
|
|
Post by DJLinux on Jan 21, 2009 3:47:11 GMT -5
i have buttons showing up now and will post the first dll when i figure out g_signal_connect so i can get the program to close properly without using task manager  EDIT: djlinux, what exactly is this line doing in your newton dll? gpBodyUserData->ForceAndTorqueCallback=gpCompiler->Compile(GS(1)); is it just compiling the string? and if so, i can't find a compile or similiar function in freebasic =[ yes it used the B4GL compiler interface to compile the string param
|
|
|
Post by Adam on Jan 21, 2009 6:49:38 GMT -5
so would i set the parameter to "THIS_COMPILER" as the pointer?
|
|
|
Post by DJLinux on Jan 21, 2009 15:34:23 GMT -5
gCompi and gCode are gloabal vars: dim shared as IB4GLCompiler ptr gCompi dim shared as Integer gCode inside of Load fetch the interface: function Load (THIS_PLUGIN , _ THIS_REGISTRY, _ blnIsExe as integer) as integer dim as IB4GLCompiler ptr ptr lpCompi lpCompi=_registry->FetchInterface(_registry,"IB4GLCompiler", IB4GLCOMPILER_MAJOR, IB4GLCOMPILER_MINOR) gCompi=cptr(IB4GLCompiler ptr,lpCompi[0]) ...
compile a string with b4gl code: gCode = gCompi->Compile(gCompi,codetext) now if GTK call's a callback inside your plugin and gCode are <>0 then you can execute the precompiled B4GL code: gCompi->Execute(gCompi,gCode)
|
|
|
Post by Adam on Jan 21, 2009 20:59:20 GMT -5
thank you so much! i would never be able to figure out all the registry stuff.. hopefully i will be posting it soon =]
|
|
|
Post by DJLinux on Jan 21, 2009 23:03:46 GMT -5
thank you so much! i would never be able to figure out all the registry stuff.. hopefully i will be posting it soon =] i hope you can save any user data with every created GTK GUI element! if not, you will run in to a big problem think about a user have one ore more open windows and a number of GUI elements per window (buttons, list/combo boxes, menus, ...) now how you would save all possible handles for the pre compiled callbacks? you know what i mean? Joshy
|
|
|
Post by Adam on Jan 22, 2009 8:11:55 GMT -5
well.. I figured that i would be able to just pass all of that to the gtk+ library but if not i am thinking of making a dynamic array of pointers which shouldn't be too hard
|
|
|
Post by Adam on Feb 11, 2009 18:30:45 GMT -5
I was working on gtk+ when i realized how much i abhorred its packing methods, so i figured i would take Empyrion Martyr's button include port it then form it into a complete gui dll. I am currently having a problem with it though... i can not get the button state to return released... here is the code for it, well the button part at least.. help would be greatly apreciated
If Temp->_Type = 1 Then If Temp->Visible = 0 Then Temp->State = _Invisible ElseIf Temp->Visible <> 0 And Temp->State = _Invisible Then Temp->State = _Released EndIf Sx = Temp->_Pos(0) Sy = Temp->_Pos(1) Ex = Sx + Temp->_Size(0) Ey = Sy + Temp->_Size(1) in = 0 If tx>sx and tx<ex and ty>sy and ty<ey then in = 1 EndIf If Not Temp->State = _Invisible And Not Temp->State = _Greyed_Out Then If Not In Then Temp->State = _Free EndIf If Temp->State = _Released Then Temp->State = _Free EndIf If (Temp->State = _Pressed) And (Mouse.Down(0) = 0) Then Temp->State = _Released return EndIf If in And Not Mouse.Down(0) Then Temp->State = _Hover EndIf If in And (Mouse.Down(0) = -1) Then Temp->State = _Pressed EndIf EndIf If Temp->State < 3 Then Temp->CurTex = Temp->State ElseIf Temp->State = _Released Then Temp->CurTex = 0 ElseIf Temp->State = _Greyed_Out Then Temp->CurTex = 3 EndIf EndIf
|
|
|
Post by Adam on Feb 22, 2009 5:04:34 GMT -5
havn't even messed with this since my last post but i figure someone will enjoy it. After i finish figuring out how to generate textures at runtime i am going to write the texturing routines so you have actual on button text  , then i will continue on with sliders, progress bars, ect.. it willl probably be a while though because i have been busy Here's a simple example program i wrote for it b4_init(640, 480) Dim A = b4_new(b4_Button,LoadTex("Ide/splash.png")) b4_setpos(320,240) b4_setSize(310,230) Dim B = b4_new(b4_button) b4_SetPos(10,10) b4_SetAmplitude(5) textmode(text_overlaid) Dim AB Do GLClear(GL_COLOR_BUFFER_BIT) b4_Main() Locate 1,1 print b4_getstate(a) Locate 1,2 print b4_getstate(b) drawtext() SwapBuffers() Sleep(20) Loop
|
|