ListIconGadget - Column alignment

Linux specific forum
lnxque
User
User
Posts: 30
Joined: Tue Jan 26, 2010 4:06 pm

ListIconGadget - Column alignment

Post by lnxque »

Is an example for the column alignment in ListIconGadget available?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: ListIconGadget - Column alignment

Post by Rook Zimbabwe »

I am confused by the term... do you mean a way to automatically expand the column to the length of the largest entry?

Or how ot CENTER text in each column header?

:D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
lnxque
User
User
Posts: 30
Joined: Tue Jan 26, 2010 4:06 pm

Re: ListIconGadget - Column alignment

Post by lnxque »

The last one.

How can i align the text in columns in a ListIconGadget in the middle (center) and right (under Linux)?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: ListIconGadget - Column alignment

Post by freak »

The underlying GtkTreeView is quite a beast, so these things are not as simple as in Windows.

Here it is though:

Code: Select all

ImportC ""
  g_object_set_double(*Object, Property.p-ascii, Value.d, NULL) As "g_object_set"
EndImport

; Set Column alignment for given #Gadget and Column
; Alignment should be between 0 and 1
;
Procedure SetColumnAlign(Gadget, Column, Alignment.d)
  Protected *Column, *CellRenderers, Count, Index
 
  *Column = gtk_tree_view_get_column_(GadgetID(Gadget), Column)  
  If *Column
    ; This only aligns the title text
    gtk_tree_view_column_set_alignment_(*Column, Alignment)
 
    ; Align the text renderers as well
    *CellRenderers = gtk_tree_view_column_get_cell_renderers_(*Column)
    If *CellRenderers
      Count = g_list_length_(*CellRenderers)
      For Index = 0 To Count-1
        g_object_set_double(g_list_nth_data_(*CellRenderers, Index), "xalign", Alignment, #Null)
      Next Index         
      g_list_free_(*CellRenderers)
    EndIf
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 500, 300, "ListIcon Columns", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListIconGadget(0, 10, 10, 480, 280, "Left", 150)
  AddGadgetColumn(0, 1, "Center", 150)
  AddGadgetColumn(0, 2, "Right", 150)
  
  SetColumnAlign(0, 0, 0.0)
  SetColumnAlign(0, 1, 0.5)
  SetColumnAlign(0, 2, 1.0)
  
  For i = 1 To 10
    AddGadgetItem(0, -1, RSet("", i, "A")+Chr(10)+RSet("", i, "A")+Chr(10)+RSet("", i, "A"))
  Next i

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
quidquid Latine dictum sit altum videtur
lnxque
User
User
Posts: 30
Joined: Tue Jan 26, 2010 4:06 pm

Re: ListIconGadget - Column alignment

Post by lnxque »

This was, what i am looking for. Thank you (für Tannenbäumchen ;-)
Post Reply