Page 2 of 2

Re: OPB v0.51 (objective PB)

Posted: Tue Nov 08, 2011 8:12 pm
by X
fsw wrote:Surely interesting stuff.
Because it's low level asm it's tight to 32bit OS.
Had to install PB32 in order to try it out...

Still very nice.
Wait ... this is limited to 32bit PB?

Re: OPB v0.53 (objective PB)

Posted: Tue Nov 08, 2011 8:21 pm
by idle
It was but it's fixed now, should be fine for 64bit but I can't test it

Re: OPB v0.53 (objective PB)

Posted: Thu Nov 10, 2011 12:31 am
by fsw
Yes it works on Win7-64 (not tested on Linux-64...)

Re: OPB v0.53 (objective PB)

Posted: Tue Nov 29, 2011 8:33 pm
by fsw
Hello,
just wanted to mention that I had time over the weekend and looked at the misbehaving event loop.

Here the fix:

Code: Select all

; this is inside the event loop...
; some code and then:
;...
        If EventGadget  
          
          ForEach *win\gadget()  
            *gad = *win\gadget() 
          
            If *gad\gadget = EventGadget 
              GadgetFound = #True                                          <- added this
              Break 
            EndIf  
            
          Next 
          
          If GadgetFound                                                       <- added this
            
            Select EventType
                
              Case #PB_EventType_LeftClick

; and then do:

          ; reset GadgetFound = prep for new event...
          GadgetFound = #False                                           <- added this
          
        Else 
          ClassWindowCheckHits(*win) 
        EndIf

; and so on...

that's all.

Even created a small SQLite app with an extended cWindow (changed some stuff for less typing) - it was a breeze.

What I like about this approach is that it can live alongside "normal" PB commands/syntax.

Will soon post my cWindow extensions when I'm done.

Thanks
fsw

Re: OPB v0.53 (objective PB)

Posted: Tue Nov 29, 2011 9:43 pm
by idle
Thanks I'll fix up the example.

Re: OPB v0.54 (objective PB)

Posted: Sun Dec 11, 2011 10:58 pm
by idle
updated it

changed it so OPB can also be used as a shared object or statically compiled with a class
and extended the window manager example so it can be used as a shared object also to test modularity

see the Readme in the zip

Re: OPB v0.54 (objective PB)

Posted: Fri Dec 16, 2011 2:14 am
by idle
Extended the event driven window manager to handle a windowed screen with multiple control windows
isn't complete yet or extensively debugged and not sure if #PB_Event_DeactivateWindow is present on windows

Events are registered with a precedence
1 a specific gadget and event "OnClick" ...
2 a specific gadget or any gadget and all its events via "Onevent"
1 a specific window and event "OnWindowMaximize"
2 a specific window or any window and all its gadgets events via "OnEvent"
1 a WindowScreen callback for rendering

keyboard functions replace PB keyboard (*don't use pb InitKeyboard)
US english keyboard is currently text mapped scan includes lowercase keys

ClassWindowKeyboardPressed(windowObject,#OPBKey_UP) to test for multiple key presses
ClassWindowKeyboardReleased(windowObject,#OPBKey_DOWN)
key = ClassWindowGetKey(windowobject) ;gets the current key pressed down
keyString = ClassWindowGetKeyString(key) ;converts the key to it's string (needs to be language mapped)

[edit]
Added MouseScroll events
Fixed a few bugs

Code: Select all

Procedure Window2_OK_OnClick()
;...
Endprocedure

w2 = NewWindow("w2",0,0,300,200,"Window2",#PB_Window_ScreenCentered) 
wn2 = ClassWindowGetWindowNumber(w2)
 
If CreateMenu(0,ClassWindowGetWindowID(w2))
  MenuTitle("Project")
  MenuItem(1, "Open")
  MenuBar()                  
  MenuItem(4, "Close")
EndIf

;register menu callback
ClassWindowRegisterWindowEvent(w2,#OnMenu,@Window2_OnMenu())
;Add a gadget and register a event pass in the gadget ID   
b2 = ClassWindowAddGadget(w2,ButtonGadget(#PB_Any,235,5,60,20,"OK"), #OnClick,@Window2_OK_OnClick())
;add additional events for the gadget mouse enter / leave  
ClassWindowRegisterGadgetEvent(b2,#OnMouseEnter,@Window2_OK_OnMouseEnter())
ClassWindowRegisterGadgetEvent(b2,#OnMouseLeave,@Window2_OK_OnMouseLeave())
lv2 = ListViewGadget(#PB_Any,3,30,293,160)
;enter the main loop 
ClassWindowMain()
;program will end when all window are closed 

Re: OPB v0.54 (objective PB)

Posted: Sat Dec 24, 2011 2:00 am
by idle
Added Foreign Function Interface class based on code by Wilbert
so you can call functions in libs with varargs

Code: Select all

file.s = OpenFileRequester("FFI","","*.*",1)
;open a lib loads it's exported functions
Global mlib = FFI_OpenLibrary(file,@enumfuncs())

;make wrapper functions to call the library functions
Procedure.f Foof(a.f,b.f)
  Static fn
  If Not fn   ;get the named function and set the number of parameters 
    fn = FFI_GetFunction(mlib,"foof",2) 
  EndIf   
  FFI_PushF(fn,a) ;push the parameters by type 
  FFI_PushF(fn,b)
  ProcedureReturn FFI_CallF(fn)   ;call the function via the required return type 
EndProcedure 

Procedure.s Foos()
  Static fn 
  If Not fn 
    fn = FFI_GetFunction(mlib,"foos",0)
  EndIf 
  ProcedureReturn PeekS(FFI_CallL(fn))
EndProcedure 

;call the functions 
Debug StrF(Foof(5.5,4.3))
Debug foos()

;free the library
FFI_FreeLibrary(mlib)  

Re: OPB v0.54 (objective PB)

Posted: Wed Feb 15, 2012 7:01 pm
by fsw
@idle,
downloaded the v054 and wanted to add the GUI stuff I added to v53 a while ago but while doing it I realized that the NewWindow procedure should actually return the WindowNumber instead of the class instance.
This way it can be used as a "normal" PureBasic Window and the OPBWindowGetWindowNumber and OPBWindowGetWindowID procedures are not needed anymore.
In my version of v053 I also substituted OPBWindowAddGadget with NewButton, NewPanel etc. as OPBWindowAddGadget looked to cryptic.

All OPB procedures that need the class information could retrieve the class instance through the WindowNumber.

This approach would align OPB to PureBasic instead of doing his own thing.

What do you think?

Re: OPB v0.54 (objective PB)

Posted: Wed Feb 15, 2012 7:24 pm
by idle
Yes sounds like a better plan.

Re: OPB v0.54 (objective PB)

Posted: Sun Mar 11, 2012 3:31 am
by idle
updated v0.55

removed introspection
updated the event driven window class so it returns the PB object numbers
added the FFI into the runtime (FFI is 32bit only at the moment)

changed how to start and stop OPB by calling OPBStart() and OPBStop()
it returns a module instance, though you can still create additional modules
also if it's used from a Dll you will need to call OPBClose() to close the lib

Re: OPB v0.55 (objective PB)

Posted: Mon Mar 12, 2012 11:58 pm
by idle
quick update v0.55.1
Changed a classes user data store to a dynamic structure
so it's only instantiated if you call OPBClassSetData() when building a class or passing it through.

Re: OPB v0.56 (objective PB)

Posted: Fri Mar 16, 2012 5:56 am
by idle
update v.56
made it compatible with Interfaces

Re: OPB v0.56 (objective PB)

Posted: Sun Mar 18, 2012 6:59 am
by idle
Added in remaining PB types to FFI