Purebasic VS Blitz+ / 3D

Miscellaneous Forums/General Discussion/Purebasic VS Blitz+ / 3D

I have done a little work in PB and B3D and B+ which for the purposes of this exercise are the same for producing an APPLICATION.

I created a little security pin pad example in both languages using the tools in each for creation of the window.

Not considering program size the form designer in PB was easier to use than in Blitz's BlitzUI... But BlitzUI gives me a unique look which can be color customized. I have not tried this in the other libs as I don't think they have form designers included. I hope one day they will if not.

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)

IncludeFile "GeneratedIncludeFile.pb"

Open_Window_0()

Repeat ; Start of the event loop
  
  Event = WaitWindowEvent() ; This line waits until an event is received from Windows
  
  WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
  
  GadgetID = EventGadget() ; Is it a gadget event?
  
  EventType = EventType() ; The event type
  
  ;You can place code here, and use the result as parameters for the procedures
  
  If Event = #PB_Event_Gadget
    
    If GadgetID = #String_0
      
    ElseIf GadgetID = #Button_1
     String$ = GetGadgetText(#String_0)
     String$ = string$+"1"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_2
     String$ = GetGadgetText(#String_0)
     String$ = string$+"2"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_3
     String$ = GetGadgetText(#String_0)
     String$ = string$+"3"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_4
     String$ = GetGadgetText(#String_0)
     String$ = string$+"4"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_5
     String$ = GetGadgetText(#String_0)
     String$ = string$+"5"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_6
     String$ = GetGadgetText(#String_0)
     String$ = string$+"6"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_7
     String$ = GetGadgetText(#String_0)
     String$ = string$+"7"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_8
     String$ = GetGadgetText(#String_0)
     String$ = string$+"8"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_9
     String$ = GetGadgetText(#String_0)
     String$ = string$+"9"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_0
     String$ = GetGadgetText(#String_0)
     String$ = string$+"0"
      SetGadgetText(#String_0,String$)
    ElseIf GadgetID = #Button_ENTER
      User$ = String$ ; LOOKUP TABLE IN DB FOR USER ID
                ; CLOSE WINDOW
    ElseIf GadgetID = #Button_CANCEL
     String$ = GetGadgetText(#String_0)
     String$ =""
      SetGadgetText(#String_0,String$)
    EndIf
    
  EndIf
  
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
;


And it Geneated a Include file (though why you can just hit this in the main program I don't know... it may be a style thing...

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #String_0
  #Button_1
  #Button_2
  #Button_3
  #Button_4
  #Button_5
  #Button_6
  #Button_7
  #Button_8
  #Button_9
  #Button_0
  #Button_ENTER
  #Button_CANCEL
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 620, 412, 244, 300, "ENTER USER ID",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
    If CreateGadgetList(WindowID(#Window_0))
      StringGadget(#String_0, 20, 10, 200, 30, "", #PB_String_Numeric)
      ButtonGadget(#Button_1, 20, 50, 60, 50, "1")
      ButtonGadget(#Button_2, 90, 50, 60, 50, "2")
      ButtonGadget(#Button_3, 160, 50, 60, 50, "3")
      ButtonGadget(#Button_4, 20, 110, 60, 50, "4")
      ButtonGadget(#Button_5, 90, 110, 60, 50, "5")
      ButtonGadget(#Button_6, 160, 110, 60, 50, "6")
      ButtonGadget(#Button_7, 20, 170, 60, 50, "7")
      ButtonGadget(#Button_8, 90, 170, 60, 50, "8")
      ButtonGadget(#Button_9, 160, 170, 60, 50, "9")
      ButtonGadget(#Button_0, 20, 230, 60, 50, "0")
      ButtonGadget(#Button_ENTER, 90, 230, 60, 50, "ENTER")
      ButtonGadget(#Button_CANCEL, 160, 230, 60, 50, "CANCEL")
      
    EndIf
  EndIf
EndProcedure


Mind you the forms designer was nice and reminiscent of the VB 3.0 thing I used to use...

Now in Blitz UI...

Graphics 800, 600, 16, 2
SetBuffer BackBuffer(  )
HidePointer

Include "blitzui.bb"

;Load fonts and mouse cursors
;and collect information
Initialise(  )

;Window
win003 = Window( 144, 46, 200, 305, "SECURITY PIN", "0", 1, 0, 0, 0 )
btn001 = Button( 14, 41, 50, 50, "1", "0", 1, 1, 0 )
btn002 = Button( 72, 41, 50, 50, "2", "0", 1, 0, 0 )
btn003 = Button( 130, 41, 50, 50, "3", "0", 1, 0, 0 )
btn004 = Button( 14, 100, 50, 50, "4", "0", 1, 0, 0 )
btn005 = Button( 72, 100, 50, 50, "5", "0", 1, 0, 0 )
btn006 = Button( 130, 100, 50, 50, "6", "0", 1, 1, 0 )
btn007 = Button( 15, 159, 50, 50, "7", "0", 1, 1, 0 )
btn008 = Button( 72, 158, 50, 50, "8", "0", 1, 1, 0 )
btn009 = Button( 130, 159, 50, 50, "9", "0", 1, 0, 0 )
btn000 = Button( 15, 216, 50, 50, "0", "0", 1, 0, 0 )
btn0CLEAR = Button( 72, 216, 50, 50, "CLEAR", "0", 1, 0, 0 )
btn0ENTER = Button( 130, 216, 50, 50, "ENTER", "0", 1, 0, 0 )
txt001 = TextBox( 13, 14, 169, 21, 0, 0, 18, 10, 1 )
SendMessage( txt002, "TM_SETTEXT", 0, "ENTER ID" )

Repeat

	;Draw the GUI and update the mouse
	UpdateGUI(  )
	
	;Event Handling
	Select app\Event
		Case EVENT_WINDOW
			Select app\WindowEvent
			End Select
		Case EVENT_MENU
			Select app\MenuEvent
			End Select
		Case EVENT_GADGET
			Select app\GadgetEvent
				Case btn001
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"1"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )				
				Case btn002
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"2"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )					
				Case btn003
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"3"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn004
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"4"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )	
				Case btn005
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"5"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )	
				Case btn006
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"6"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )			
				Case btn007
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"7"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn008
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"8"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn009
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"9"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn000
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=strub$+"0"
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn0CLEAR
					SendMessage( txt001, "TM_GETTEXT",0, strub$ )
					strub$=""
					SendMessage( txt001, "TM_SETTEXT",0, strub$ )
				Case btn0ENTER
					User$=strub$
						; lookup user in table
						;close window and enter program main window
					
			
					
			End Select
	End Select
	
	;Draw the mouse
	DrawMouse(  )
	
	;Reset all GUI events
	ResetEvents(  )

	Flip
	Cls

Until KeyHit( 1 ) Or app\Quit = True
;Free all images and controls created by BlitzUI
Destroy(  )
End


The key thing with BlitzUI is that the brilliance of the system was never well documented. The SendMessage was the heart of the system and without it you had nothing happening...

BlitzUI seemed just a slight bit slower on the mouse or touchscreen. That may have been the CPU I was running on.

The key with PB is the windows API calls but you cannot really customize the look of the system you write it will always look like windows (as far as I know!)

I am going to take my coordinates (generated by BlitzUI) and try this with NGui etc. and see what it looks like.

PB code is very fast - and small. Unfortunately, updates are being released very slowly (especially for the Mac). The 3D part is (very) limited.

Any idea on being able to "skin" the application?

It is possible.. check the code archives on purearea or something along those lines... I'm sure there's a link on the forum..
It's been such a long time since I used PB, so I don't remember quite what it was called..