Customizable table for PureBasic

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

Customizable table for PureBasic

Post by microdevweb »

In this hard time, we have some of time for coding. Found here a module for make a customizable table with purebasic.

Version 1.1 beta 1

Image

Image

Image

Image

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/PB_TABLE"
  • Open the subdirectory "PB_TABLE" and run "example1.pb "
Update to version 1.1.b1
  • Make a right click on the directory PB_TABLE and choice "Git Bash here"
  • Use the command "git pull"
  • And choise the last branch with "git checkout version.1.1"
Image

Towards Github

Code of the example

Code: Select all

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


You can customize the table like this

Code: Select all

TB::defaultColors\...
TB::defaultFont\...
TB::defaultSize\...
Last edited by microdevweb on Sat Mar 21, 2020 12:47 am, edited 5 times in total.
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Customizable table for PureBasic

Post by IdeasVacuum »

Looks very neat microdevweb, thanks for sharing.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

Re: Customizable table for PureBasic

Post by microdevweb »

new version 1.0.b2
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

Re: Customizable table for PureBasic

Post by microdevweb »

Version 1.0 beta 3 is out
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Customizable table for PureBasic

Post by Cyllceaux »

Nice... but don't forget the dpi

Image
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

Re: Customizable table for PureBasic

Post by microdevweb »

Thanks Cyllceaux,

I need look for that
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

Re: Customizable table for PureBasic

Post by microdevweb »

@Cyllceaux,

Can you tell me more about your screen configuration. I don't have any success for make like this error with my computer.
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Customizable table for PureBasic

Post by Cyllceaux »

It's not an error.

My dpi is on 200%.

viewtopic.php?f=27&t=73051

Code: Select all

 Procedure.f dpiX(Num.i)
	  If Num > 0  
	    ProcedureReturn DesktopScaledX(Num)
	  EndIf   
	EndProcedure

	Procedure.f dpiY(Num.i)
	  If Num > 0  
	    ProcedureReturn DesktopScaledY(Num)
	  EndIf  
	EndProcedure
User avatar
microdevweb
Enthusiast
Enthusiast
Posts: 179
Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique

Re: Customizable table for PureBasic

Post by microdevweb »

Hi Cyllceaux,

I can't seem to have the same thing, but i had changed some things in my code with your example. Can you try the new version 1.0.b5
Use Pb 5.73 lst and Windows 10

my mother-language isn't english, in advance excuse my mistakes.
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Customizable table for PureBasic

Post by Cyllceaux »

Image

Looks better, but now there are no scrollbars anymore :)
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Customizable table for PureBasic

Post by Andre »

Interesting project, thanks for sharing! :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply