Just starting out? Need help? Post your questions and find answers here.
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

ListIconGadget - right align a column's content

by the.weavster Mon Dec 04, 2017 11:00 am

Is it possible to right align the contents of a particular column of a ListIconGadget?

Thanks
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

Re: ListIconGadget - right align a column's content

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

Bump.

I have the potential of a large project looming and this is going to be important for me.
User avatar
Peter
 
Posts: 479
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: ListIconGadget - right align a column's content

by Peter Mon Dec 18, 2017 6:11 pm

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
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

Re: ListIconGadget - right align a column's content

by the.weavster Mon Dec 18, 2017 9:58 pm

Thank you very much, Peter :D
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

Re: ListIconGadget - right align a column's content

by the.weavster Tue Dec 19, 2017 8:34 am

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.
User avatar
Peter
 
Posts: 479
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: ListIconGadget - right align a column's content

by Peter Tue Dec 19, 2017 9:29 am

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
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

Re: ListIconGadget - right align a column's content

by the.weavster Fri Dec 22, 2017 9:33 am

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.
User avatar
Peter
 
Posts: 479
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: ListIconGadget - right align a column's content

by Peter Sat Dec 23, 2017 8:35 am

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
the.weavster
 
Posts: 130
Joined: Sat Mar 01, 2014 3:02 pm

Re: ListIconGadget - right align a column's content

by the.weavster Sat Dec 23, 2017 1:48 pm

Thank you, Peter :D
Dirk Geppert
 
Posts: 58
Joined: Fri Sep 22, 2017 7:02 am

Re: ListIconGadget - right align a column's content

by Dirk Geppert Wed Dec 27, 2017 8:41 am

Thank you Peter. Would it be possible to extend the ListiconGadget() that you can sort with it?
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 1 guest