Module ListIconGadgetEx: RenderCell()

Share your advanced knowledge/code with the community.
User avatar
Peter
Posts: 888
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Module ListIconGadgetEx: RenderCell()

Post by Peter »

Howdy,

maybe you already know my module ListIconGadgetEx, which offers several functions that SpiderBasic does not support natively.

https://github.com/spiderbytes/ListIconGadgetEx

A new procedure called RenderCell() has been added, which allows to manipulate the data output. This allows you to influence the appearance of your data.

Example:

Code: Select all

EnableExplicit

XIncludeFile "ListIconGadgetEx.sbi"

Enumeration
  #Window
  #ListIconGadget
EndEnumeration

Procedure.s RenderCell(Row, Col, Text.s, TD, ListIconGadget)
  
  ; We want to set the text color depending on the amount:
  
  Protected TextColor.s
  
  If Val(Text) > 0
    
    ; incomming -> that's good! :-)
    TextColor = "green"
    
  ElseIf Val(Text) < 0
    
    ; outgoing  -> that's bad :-(
    TextColor = "red"
    
  ElseIf Val(Text) = 0 
    
    ; 0 -> neutral
    TextColor = "black"
    
  EndIf
  
  ! $(v_td).css("color", v_textcolor)
  
  ! $(v_td).css("text-align", "right"); // the column is right-aligned
  
  ; Now we change the output text:
  
  ; Please keep in mind that this only affects the *output*
  ; and GetGadget(Item)Text() still returns the Amount (without the '€'-sign)
  
  Text + " €"
  
  ! $(v_td).text(v_text);
  
EndProcedure

OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 250, 200, "RenderCell Demo 1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(#ListIconGadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), "Description", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)

AddGadgetColumn(#ListIconGadget, 1, "Amount", 100)

AddGadgetItem(#ListIconGadget, -1, "Salary"        + #LF$ + "2000")
AddGadgetItem(#ListIconGadget, -1, "Food & Drinks" + #LF$ + "-500")
AddGadgetItem(#ListIconGadget, -1, "Car Petrol"    + #LF$ + "-160")
AddGadgetItem(#ListIconGadget, -1, "Internet"      + #LF$ + "-50")

ListIconGadgetEx::RenderCell(#ListIconGadget, 1, @RenderCell()) ; we want to render the Amount-Column
Image

Greetings ... Peter
User avatar
Paul
Posts: 115
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Module ListIconGadgetEx: RenderCell()

Post by Paul »

Very nice Peter !!

Thanks.
User avatar
Paul
Posts: 115
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Module ListIconGadgetEx: RenderCell()

Post by Paul »

Hey Peter,
Has something changed? ListIconGadgetEx::BindCellClick no longer seems to work.

If you test your demo ListIconGadgetExDemo.sb there is no response from CellClick() procedure.
User avatar
Peter
Posts: 888
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Module ListIconGadgetEx: RenderCell()

Post by Peter »

Paul wrote:ListIconGadgetEx::BindCellClick no longer seems to work.
Fixed -> https://github.com/spiderbytes/ListIconGadgetEx

Thanks for the hint!

Greetings ... Peter
User avatar
Paul
Posts: 115
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Module ListIconGadgetEx: RenderCell()

Post by Paul »

Thanks again Peter,
Very nice work !!
Post Reply