Page 2 of 2

Posted: Thu Jun 19, 2003 12:10 am
by fsw
BTW: Fred,
PureGUI is dead, long live Connect.DLL 8O

Fred, you have done a good job with the Event Stuff in PureBasic that PureGUI is no longer needed.
I can have all special gadget events I need with PureBasic 3.7 - sweet!
( seems to work fine now - not all Gadgets tested though... )

The only thing remaining is the automatic calling of events for Gadgets.
(...and #PB_ANY for Memory, Directories and files etc. :wink: )
I've put the remaining functions in a DLL with 3 Functions in it:
InitConnect(), Connect() and GetConnection().

My PureBasic code now looks like this: (example)

Code: Select all

OpenWindow(1,100,200,320,240,#PB_Window_SystemMenu | #PB_Window_SizeGadget,"Test")
CreateGadgetList(WindowID(1))
AdvancedGadgetEvents(#TRUE)
InitConnect()

CreateMenu(1,WindowID(1))
  MenuTitle("File")
  MenuItem(Connect(#PB_Event_Menu, ?MenuNew),"New")
  MenuItem(Connect(#PB_Event_Menu, ?MenuOpen),"Open")
  MenuItem(Connect(#PB_Event_Menu, ?MenuSave),"Save")
  
CreateToolBar(1,WindowID(1))
  ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuNew),#PB_ToolBarIcon_New)
  ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuOpen),#PB_ToolBarIcon_Open)
  ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuSave),#PB_ToolBarIcon_Save)
      
ButtonGadget(Connect(#PB_Event_Gadget, ?Button1),10,30,100,25,"Button 1")
ButtonGadget(Connect(#PB_Event_Gadget, ?Button2),10,80,100,25,"Button 2")
ButtonGadget(Connect(#PB_Event_Gadget, ?Button3),10,130,100,25,"Button 3")


Repeat
  Event.l = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Menu
      CallFunctionFast(GetConnection(#PB_Event_Menu, EventMenuID()))

    Case #PB_Event_Gadget
      CallFunctionFast(GetConnection(#PB_Event_Gadget, EventGadgetID()))
      
  EndSelect
Until Event = #PB_Event_CloseWindow

End
and what remains is building the 'sub routines' for each Event.
Something like this: (example - only menues are shown...)

Code: Select all

;- User Functions
MenuNew:
  Debug "SubDir MenuNew"
  Debug GetConnection(#PB_Event_Menu, ?MenuNew)
Return

MenuOpen:
  Debug "SubDir MenuOpen"
  Debug GetConnection(#PB_Event_Menu, ?MenuOpen)
  DisableMenuItem(GetConnection(#PB_Event_Menu, ?MenuOpen),1)
Return

MenuSave:
  Debug "SubDir MenuSave"
  Debug GetConnection(#PB_Event_Menu, ?MenuSave)
  If GetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave)) = 1
    SetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave),0)      
  Else
    SetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave),1)      
  EndIf 
Return

InitConnect() = is needed beause it's a DLL not a OBJ.
Connect(ChildType, EventFunctionSubroutine) = gives a number to a gadget and connects it to a sub routine.
GetConnection(ChildType, EventID) = returns the address of the EventFunctionSubroutine
or
GetConnection(ChildType, EventFunctionSubroutine) = returns the GadgetNumber connected to the EventFunctionSubroutine

Now GUI coding is a breeze - for lazy coders like me :wink:

Posted: Thu Jun 19, 2003 12:21 am
by tinman
fsw wrote:for lazy coders like me :wink:
Not too lazy to upload it somewhere surely ;)
I always liked the look of PureGUI for an event based approach.

Posted: Thu Jun 19, 2003 12:37 am
by fsw
And I thought I'm alone...

Thanks Tinman for the flowers :wink:

Upload....yeah sure - but first I have to clean it up, for the public :roll:

BTW:
It would be nicer if it wasn't a 6KB DLL but a 2KB OBJ (compressed 1KB).
Tried to tweak purebasic's asm code of it (13KB) and made a OBJ - but there is some memory mismach (it's not working right as OBJ...).
I'm not that familiar with asm... (this said, I could never ever optimize asm code :oops: )

Posted: Sun Jun 22, 2003 7:40 pm
by Psychophanta
Agree with Fred.

PB is characterized specially by small and powerful executables generated by the PB compilation.

For sure Fred doesn't want never to loose this characteristic which makes PB to be distinguished from the most of the rest of compilers (included some C++ ones i've compared).

If Fred loose this policy, PB could loose its position.