Page 1 of 2

ListIconGadget - right align a column's content

Posted: Mon Dec 04, 2017 11:00 am
by the.weavster
Is it possible to right align the contents of a particular column of a ListIconGadget?

Thanks

Re: ListIconGadget - right align a column's content

Posted: Fri Dec 15, 2017 8:57 am
by the.weavster
Bump.

I have the potential of a large project looming and this is going to be important for me.

Re: ListIconGadget - right align a column's content

Posted: Mon Dec 18, 2017 6:11 pm
by Peter
Hi,

here are two procedures (SetColumnHeaderAlignment() and SetColumnAlignment()) that should solve your problem:

Code: Select all

Enumeration
  #Window
  #ListIconGadget
EndEnumeration

Procedure SetColumnHeaderAlignment(Column, Alignment.s)
  ! $("<style/>", {text: ".dgrid-cell.dgrid-column-" + v_column + "[role='columnheader'] {text-align: " + v_alignment + ";}"}).appendTo('head');    
EndProcedure

Procedure SetColumnAlignment(Column, Alignment.s)
  ! $("<style/>", {text: ".dgrid-cell.dgrid-column-" + v_column + "[role='gridcell'] {text-align: " + v_alignment + ";}"}).appendTo('head');    
EndProcedure

OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 800, 400, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#ListIconGadget, 0, 0, 800, 400, "Column 0", 300, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)

AddGadgetColumn(#ListIconGadget, 1, "Column 1", 400)

SetColumnHeaderAlignment(0, "center")
SetColumnAlignment(0, "right")

SetColumnHeaderAlignment(1, "right")
SetColumnAlignment(1, "center")

Define Counter

For Counter = 0 To 9
  AddGadgetItem(#ListIconGadget, -1, "Column 0 / Row " + Counter + #LF$ + "Column 1 / Row " + Counter)
Next

Greetings ... Peter

Re: ListIconGadget - right align a column's content

Posted: Mon Dec 18, 2017 9:58 pm
by the.weavster
Thank you very much, Peter :D

Re: ListIconGadget - right align a column's content

Posted: Tue Dec 19, 2017 8:34 am
by the.weavster
Peter, may I ask where you found the reference documents that enable you to figure this out? I'd really like to see what enhancements are possible for the ListIconGadget.

Is it possible to refine your function from this:
SetColumnAlignment(Column, Alignment.s)

to this:
SetColumnAlignment(GadgetID,Column, Alignment.s)

I also like to put a window's event handlers in its own code file, so for example I handle gadget events like this:

Code: Select all

Procedure HandleGadgetEvents()
  evWindow = EventWindow() 
  evGadget = EventGadget()
  evType   = EventType()
  evX      = 0 : evY = 0
  If GadgetType(evGadget) = #PB_GadgetType_Canvas
    evX = GetGadgetAttribute(evGadget,#PB_Canvas_MouseX)
    evY = GetGadgetAttribute(evGadget,#PB_Canvas_MouseY)
  ElseIf GadgetType(evGadget) = #PB_GadgetType_ListIcon
    ; how to set evX and evY to the cell clicked by the user?
  EndIf
  Select evWindow
    Case #frmHeadings
      frmHeadings_GadgetEvents(evGadget,evType,evX,evY)
   ; etc...   
  EndSelect  
EndProcedure

BindEvent(#PB_Event_Gadget,@HandleGadgetEvents())
So I need to figure out how to get the row and column of the cell the user clicked in the ListIconGadget.

Thanks.

Re: ListIconGadget - right align a column's content

Posted: Tue Dec 19, 2017 9:29 am
by Peter
the.weavster wrote:Is it possible to refine your function from this: [...] to this:
SetColumnAlignment(GadgetID,Column, Alignment.s)
[X] Done. It's now integrated in my ListIconGadgetEx-Module (see below).
the.weavster wrote:So I need to figure out how to get the row and column of the cell the user clicked in the ListIconGadget.
please take a look at this repository: https://github.com/spiderbytes/ListIconGadgetEx (BindCellClick)

Greetings ... Peter

Re: ListIconGadget - right align a column's content

Posted: Fri Dec 22, 2017 9:33 am
by the.weavster
Thanks again, Peter.

Sorry to be a pain in the neck but would it be possible to to enhance the row color commands so the colors can be set on a gadget by gadget basis?

i.e.

Code: Select all

SetEvenRowColor(RowColor.s, SelectedRowColor.s, TextColor.s, SelectedTextColor.s)
becomes:

Code: Select all

SetEvenRowColor(Gadget, RowColor.s, SelectedRowColor.s, TextColor.s, SelectedTextColor.s)
Thanks.

Re: ListIconGadget - right align a column's content

Posted: Sat Dec 23, 2017 8:35 am
by Peter
the.weavster wrote:would it be possible to to enhance the row color commands so the colors can be set on a gadget by gadget basis?
[X] Done: https://github.com/spiderbytes/ListIconGadgetEx

Greetings ... Peter

Re: ListIconGadget - right align a column's content

Posted: Sat Dec 23, 2017 1:48 pm
by the.weavster
Thank you, Peter :D

Re: ListIconGadget - right align a column's content

Posted: Wed Dec 27, 2017 8:41 am
by Dirk Geppert
Thank you Peter. Would it be possible to extend the ListiconGadget() that you can sort with it?