Customizable table for pureBasic

Programmation d'applications complexes
Avatar de l’utilisateur
microdevweb
Messages : 1800
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Customizable table for pureBasic

Message par microdevweb »

Dans ses temps troublé, on a le temps de coder. Voici un module table en version 1.1 beta 1

Image

Image

Image

Image

Comment l'installer
  • Installer git ICI
  • Faite un click droit sur une répertoire de votre choix et choisiser "Git Bash here"
  • Dans le terminal Git taper "git clone https://github.com/microdevweb/PB_TABLE"
  • Ouvrer le sous-répertoire "PB_TABLE" et exécuter "example1.pb "
Mise à jour de la version 1.1.b1
  • Faite un click droit sur le répertoire PB_TABLE et choisiser "Git Bash here"
  • taper la commande "git pull"
  • choisiser la dernière branche "git checkout version.1.1"
Image

Vers Github

Code de l'exemple

Code : Tout sélectionner

XIncludeFile "include/tb/tb.pbi"
UsePNGImageDecoder()
Enumeration 
  #FORM
  #CONTAINER
  #FIC
  #ST_FN
  #ST_SN
  #ST_AGE
  #ST_SIZE
  #ST_WEIGHT
EndEnumeration

Structure person
  firstName.s
  surname.s
  age.l
  size.f
  weight.d
  icon.l
  info.s
EndStructure

Global NewList myPeople.person(),
               img_warning = CatchImage(#PB_Any,?war),
               img_phone = CatchImage(#PB_Any,?phone),  
               img_busnes = CatchImage(#PB_Any,?bus)


Procedure.s getFirstName(*this.person)
  With *this
    ProcedureReturn \firstName
  EndWith
EndProcedure

Procedure.s getSurName(*this.person)
  With *this
    ProcedureReturn \surname
  EndWith
EndProcedure

Procedure getAge(*this.person)
  With *this
    ProcedureReturn \age
  EndWith
EndProcedure

Procedure.f getSize(*this.person)
  With *this
    ProcedureReturn \size
  EndWith
EndProcedure

Procedure.d getWeight(*this.person)
  With *this
    ProcedureReturn \weight
  EndWith
EndProcedure

Procedure setName(*this.person,value.s)
  With *this
    \firstName = value
    SetGadgetText(#ST_FN,\firstName)
  EndWith
EndProcedure

Procedure setSurname(*this.person,value.s)
  With *this
    \surname = value
    SetGadgetText(#ST_SN,\surname)
  EndWith
EndProcedure

Procedure setAge(*this.person,value)
  With *this
    \age = value
    SetGadgetText(#ST_AGE,Str(value))
  EndWith
EndProcedure

Procedure setSize(*this.person,value.f)
  With *this
    \size = value
    SetGadgetText(#ST_SIZE,StrF(value))
  EndWith
EndProcedure

Procedure setWeight(*this.person,value.d)
  With *this
    \weight = value
    SetGadgetText(#ST_WEIGHT,StrD(value))
  EndWith
EndProcedure

Procedure getIcon(*this.person)
  With *this
    ProcedureReturn \icon
  EndWith
EndProcedure

Procedure.s getInfo(*this.person) 
  With *this
    ProcedureReturn \info
  EndWith
EndProcedure

Procedure exit()
  End
EndProcedure

Procedure makeData(table.TB::table)
  With myPeople()
    AddElement(myPeople())
    \firstName = "Pierre"
    \surname = "Bielen"
    \age = 55
    \size = 175.10
    \weight = 80.623
    \icon = img_busnes
    \info = "New Customer"
    table\addLine(@myPeople())
    AddElement(myPeople())
    \firstName = "André"
    \surname = "Dupond"
    \age = 48
    \size = 165.25
    \weight = 70.428
    \icon = img_warning
    \info = "This customer has"+Chr(10)+"order out"
    table\addLine(@myPeople())
    AddElement(myPeople())
    \firstName = "Paul"
    \surname = "Godelaine"
    \age = 49
    \size = 170.388
    \weight = 90.758
    \icon = img_phone
    \info = "Call him"+Chr(10)+"next week"+Chr(10)+"On his office phone"
    table\addLine(@myPeople())
    AddElement(myPeople())
    \firstName = "Eric"
    \surname = "Bosly"
    \age = 50
    \size = 164.189
    \weight = 110.25
    table\addLine(@myPeople())
    For i = 1 To 100
      AddElement(myPeople())
      \firstName = "name "+Str(i)
      \surname = "surname"+Str(i)
      \age = Random(65,20)
      \size = 180.23
      \weight = 70.999
      table\addLine(@myPeople())
    Next
  EndWith
EndProcedure

Procedure fillFic(*this.person)
  With *this
    SetGadgetText(#ST_FN,\firstName)
    SetGadgetText(#ST_SN,\surname)
    SetGadgetText(#ST_AGE,Str(\age))
    SetGadgetText(#ST_SIZE,StrF(\size))
    SetGadgetText(#ST_WEIGHT,StrD(\weight))
  EndWith
EndProcedure

Procedure start()
  Protected table.TB::table,y = 10
  Protected *cs.TB::stringColumn,*ci.TB::integerColumn,*cf.TB::floatColumn,*cd.TB::doubleColumn,
            *cc.TB::imageColumn
  OpenWindow(#FORM,0,0,800,600,"Example version 1.0.b6",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  ContainerGadget(#CONTAINER,10,10,400,580)
  table = TB::newTable(#CONTAINER)
  table\setTitle("List of customer")
  *cs = table\addColumn(TB::newStringColumn("Firstname",0.30,@getFirstName()))
  *cs\setEditable(@setName())
  *cs = table\addColumn(TB::newStringColumn("Surname",0.30,@getSurName()))
  *cs\setEditable(@setSurname())
  *ci = table\addColumn(TB::newIntegerColumn("Age",0.2,@getAge()))
  *ci\setEditable(@setAge())
  *cf = table\addColumn(TB::newFloatColumn("Size",0.2,@getSize()))
  *cf\setEditable(@setSize())
  *cd = table\addColumn(TB::newDoubleColumn("Weight",0.2,@getWeight()))
  *cd\setEditable(@setWeight())
  *cc = table\addColumn(TB::newImageColumn("Status",0.2,@getIcon()))
  *cc\setSize(0.6)
  *cc\enableTooltip(@getInfo())
  makeData(table)
  table\setSelectCallback(@fillFic())
  table\show()
  CloseGadgetList()
  ContainerGadget(#FIC,GadgetWidth(#CONTAINER)+20,10,WindowWidth(#FORM)- GadgetWidth(#CONTAINER) - 30,580)
  TextGadget(#PB_Any,10,y,GadgetWidth(#FIC) - 20,30,"Firstname")
  y + 30
  StringGadget(#ST_FN,10,y,GadgetWidth(#FIC) - 20,30,"")
  y + 40
  TextGadget(#PB_Any,10,y,GadgetWidth(#FIC) - 20,30,"Surname")
  y + 30
  StringGadget(#ST_SN,10,y,GadgetWidth(#FIC) - 20,30,"")
  y + 40
  TextGadget(#PB_Any,10,y,GadgetWidth(#FIC) - 20,30,"Age")
  y + 30
  StringGadget(#ST_AGE,10,y,GadgetWidth(#FIC) - 20,30,"")
  y + 40
  TextGadget(#PB_Any,10,y,GadgetWidth(#FIC) - 20,30,"Size")
  y + 30
  StringGadget(#ST_SIZE,10,y,GadgetWidth(#FIC) - 20,30,"")
  y + 40
  TextGadget(#PB_Any,10,y,GadgetWidth(#FIC) - 20,30,"Weight")
  y + 30
  StringGadget(#ST_WEIGHT,10,y,GadgetWidth(#FIC) - 20,30,"")
  CloseGadgetList()
  BindEvent(#PB_Event_CloseWindow,@exit(),#FORM)
EndProcedure

start()

Repeat :WaitWindowEvent():ForEver

DataSection
  war:
  IncludeBinary "images/warning.png"
  phone:
  IncludeBinary "images/phone.png"
  bus:
  IncludeBinary "images/busnes.png"
EndDataSection


La table peut se personnalisée
avec

Code : Tout sélectionner

TB::defaultColors\...
TB::defaultFont\...
TB::defaultSize\...
Dernière modification par microdevweb le sam. 21/mars/2020 0:53, modifié 4 fois.
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Shadow
Messages : 1373
Inscription : mer. 04/nov./2015 17:39

Re: Customizable table for pureBasic

Message par Shadow »

Cool ça merci :)
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
microdevweb
Messages : 1800
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Customizable table for pureBasic

Message par microdevweb »

new version 1.0.b2
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
microdevweb
Messages : 1800
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Customizable table for pureBasic

Message par microdevweb »

Version 1.0 beta 3 is out
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Répondre