It is currently Tue Jan 26, 2021 10:32 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Customizable table for PureBasic
PostPosted: Wed Mar 18, 2020 10:03 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
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:
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:
TB::defaultColors\...
TB::defaultFont\...
TB::defaultSize\...

_________________
Use Pb 5.72 (beta 1) lst and Windows 10

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


Last edited by microdevweb on Sat Mar 21, 2020 12:47 am, edited 5 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Thu Mar 19, 2020 1:33 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6282
Location: Wales, UK
Looks very neat microdevweb, thanks for sharing.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Thu Mar 19, 2020 9:46 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
new version 1.0.b2

_________________
Use Pb 5.72 (beta 1) lst and Windows 10

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Thu Mar 19, 2020 1:42 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
Version 1.0 beta 3 is out

_________________
Use Pb 5.72 (beta 1) lst and Windows 10

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Thu Mar 19, 2020 8:44 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 227
Nice... but don't forget the dpi

Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Fri Mar 20, 2020 5:39 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
Thanks Cyllceaux,

I need look for that

_________________
Use Pb 5.72 (beta 1) lst and Windows 10

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Fri Mar 20, 2020 9:19 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
@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.72 (beta 1) lst and Windows 10

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Fri Mar 20, 2020 10:07 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 227
It's not an error.

My dpi is on 200%.

https://www.purebasic.fr/english/viewtopic.php?f=27&t=73051

Code:
 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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Fri Mar 20, 2020 1:40 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 13, 2014 9:38 am
Posts: 177
Location: Belgique
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.72 (beta 1) lst and Windows 10

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Sat Mar 21, 2020 2:35 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 227
Image

Looks better, but now there are no scrollbars anymore :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Customizable table for PureBasic
PostPosted: Sun Mar 22, 2020 12:08 am 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1872
Location: Germany (Saxony, Deutscheinsiedel)
Interesting project, thanks for sharing! :D

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye