PureWindow

Share your advanced PureBasic knowledge/code with the community.
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

PureWindow

Post by microdevweb »

version beta 1

Make dialog use easier

Hello Guys,

A module for make dialog easier

How install it
  • Install git HERE
  • make a right click on a directory and choice "Git Bash here"
  • In the Git terminal paste this command "git clone https://github.com/microdevweb/PureWindow"
  • Open the subdirectory PureWindow" and run
    "exemple1.pb "
    "exemple2.pb "
    "exemple3.pb "
    "exemple4.pb "
Image

Code: Select all

; --------------------------------------------------------------
; PURE_WINDOW
; version 1.0
; EXAMPLE 1
; a simple vertical box 
; --------------------------------------------------------------
XIncludeFile "include/pw/pw.pbi"
Define flags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget
Global.PW::button bt1,bt2,bt3,bt4
Global mainForm.PW::Window = PW::newWindow(0,0,800,600,"Exemple 1",flags)
mainForm\setMinHeight(200)
mainForm\setMinWidth(200)
Global mainLayout.PW::VBox = mainForm\setLayout(PW::newVBox())
Global NewList text.s()




Procedure evButton(*bt.PW::button)
  ChangeCurrentElement(text(),*bt\getData())
  Debug text()
EndProcedure

bt1 = mainLayout\addChild(PW::newButton("Button 1"))
AddElement(text()):text()="I'm the button 1"
bt1\setData(@text())
bt1\bind(@evButton())
bt2 = mainLayout\addChild(PW::newButton("Button 2"))
AddElement(text()):text()="I'm the button 2"
bt2\setData(@text())
bt2\bind(@evButton())
bt3 = mainLayout\addChild(PW::newButton("Button 3"))
AddElement(text()):text()="I'm the button 3"
bt3\setData(@text())
bt3\bind(@evButton())
bt4 = mainLayout\addChild(PW::newButton("Button 4"))
AddElement(text()):text()="I'm the button 4"
bt4\setData(@text())
bt4\bind(@evButton())


PW::Application\run(mainForm)
Image

Code: Select all

; --------------------------------------------------------------
; PURE_WINDOW
; version 1.0
; EXAMPLE 2
; a simple horizontal box 
; --------------------------------------------------------------
XIncludeFile "include/pw/pw.pbi"
Define flags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget
Global.PW::button bt1,bt2,bt3,bt4
Global mainForm.PW::Window = PW::newWindow(0,0,800,600,"Exemple 2",flags)
mainForm\setMinHeight(200)
mainForm\setMinWidth(200)
Global mainLayout.PW::HBox = mainForm\setLayout(PW::newHBox())
Global NewList text.s()




Procedure evButton(*bt.PW::button)
  ChangeCurrentElement(text(),*bt\getData())
  Debug text()
EndProcedure

bt1 = mainLayout\addChild(PW::newButton("Button 1"))
AddElement(text()):text()="I'm the button 1"
bt1\setData(@text())
bt1\bind(@evButton())
bt2 = mainLayout\addChild(PW::newButton("Button 2"))
AddElement(text()):text()="I'm the button 2"
bt2\setData(@text())
bt2\bind(@evButton())
bt3 = mainLayout\addChild(PW::newButton("Button 3"))
AddElement(text()):text()="I'm the button 3"
bt3\setData(@text())
bt3\bind(@evButton())
bt4 = mainLayout\addChild(PW::newButton("Button 4"))
AddElement(text()):text()="I'm the button 4"
bt4\setData(@text())
bt4\bind(@evButton())


PW::Application\run(mainForm)
Image

Code: Select all

; --------------------------------------------------------------
; PURE_WINDOW
; version 1.0
; EXAMPLE 3 
; a fic customer 
; --------------------------------------------------------------
XIncludeFile "include/pw/pw.pbi"
Define flags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget
Global.PW::button btValide,btCancel
Global.PW::HBox btLayout
Global.PW::VBox fielLayout,mainLayout
Global.PW::stringGadget stFName,stSName,stAddress
Global mainForm.PW::Window = PW::newWindow(0,0,320,20,"Exemple 3",flags)
LoadFont(0,"Arial",11,#PB_Font_HighQuality)

Procedure init()
  SetActiveGadget(stFName\getId())
EndProcedure

SetGadgetFont(#PB_Default,FontID(0))
mainLayout = mainForm\setLayout(PW::newVBox())
mainLayout\setExpand(1) ; expand field layout
fielLayout = mainLayout\addChild(PW::newVBox())
btLayout = mainLayout\addChild(PW::newHBox())
btLayout\setExpand(PW::#EXPAND_NO)
btLayout\setAlign(PW::#ALIGN_RIGHT)
stFName = fielLayout\addChild(PW::newStringGadget())
stFName\setHeight(30)
stFName\setLabel("First name")
stSName = fielLayout\addChild(PW::newStringGadget())
stSName\setHeight(30)
stSName\setLabel("Last name")

stAddress = fielLayout\addChild(PW::newStringGadget())
stAddress\setHeight(30)
stAddress\setLabel("Address")
btValide = btLayout\addChild(PW::newButton("Validate"))
btValide\setWidth(90)
btValide\setHeight(25)
btCancel = btLayout\addChild(PW::newButton("Cancel"))
btCancel\setWidth(90)
btCancel\setHeight(25)

PW::Application\setInitiation(@init())
PW::Application\run(mainForm)
Image

Code: Select all

; --------------------------------------------------------------
; PURE_WINDOW
; version 1.0
; EXAMPLE 4 
; a fic customer 
; --------------------------------------------------------------
XIncludeFile "include/pw/pw.pbi"
Define flags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget
Global Dim bt.PW::button(12)
Global.PW::GridBox grid
Global mainForm.PW::Window = PW::newWindow(0,0,320,20,"Exemple 4",flags)
grid = mainForm\setLayout(PW::newGridBox(6))
For i = 0 To 11
  bt(i) = grid\addChild(PW::newButton("Button "+Str(i+1)))
  If i = 2
    grid\spanColums(bt(i),3)
  EndIf
  If i = 4
    grid\spanRows(bt(i),2)
  EndIf
Next
PW::Application\run(mainForm)
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.