Page 1 of 1
NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Wed May 26, 2010 3:40 pm
by sverson
How can I do this on Linux & Mac?
Code: Select all
If OpenWindow(0, 100, 100, 350, 100, "NoColumnHeader & AutoSize", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 340, 90, "", 0, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#LVS_NOCOLUMNHEADER)
AddGadgetColumn(0, 1, "", 0)
For X.l = 1 To 5
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
Next
For X.l = 0 To 1
SendMessage_(GadgetID(0),#LVM_SETCOLUMNWIDTH,X,#LVSCW_AUTOSIZE_USEHEADER)
Next
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 10:51 am
by Shardik
I have modified your code to run in Windows and Linux. In Linux you don't need to adjust the
column size. It's the default setting. To disable the column headers you can use
Code: Select all
gtk_tree_view_set_headers_visible_(GadgetID(#ListIconGadget), #False)
In order to run in Linux and in Windows I had to define a column width greater than 0 because
Linux displays an error for a column size of 0. But that doesn't matter because afterwards the
column size will be adjusted...
Code: Select all
OpenWindow(0, 100, 100, 450, 100, "NoColumnHeader & AutoSize", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 440, 90, "", 100, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "", 100)
For X.l = 1 To 5
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
Next
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_tree_view_set_headers_visible_(GadgetID(0), #False)
CompilerCase #PB_OS_Windows
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) | #LVS_NOCOLUMNHEADER)
For X.l = 0 To 1
SendMessage_(GadgetID(0),#LVM_SETCOLUMNWIDTH,X,#LVSCW_AUTOSIZE_USEHEADER)
Next
CompilerEndSelect
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 11:28 am
by sverson
Thanks Shardik.
This is exactly what I was looking for.

Now just the mac code is missing.
Shardik wrote:In order to run in Linux and in Windows I had to define a column width greater than 0 because Linux displays an error for a column size of 0.
Yes - sad thing in some cases - this is another one I need to solve. - Does anyone konw how to hide a column permamently on linux (& mac)

Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 2:16 pm
by Shardik
sverson wrote:Does anyone konw how to hide a column permamently on linux
That's very easy:
Code: Select all
OpenWindow(0, 100, 100, 410, 115, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 400, 75, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
ButtonGadget(1, 155, 85, 120, 25, "Hide Column 0")
*Column0.GtkTreeViewColumn = gtk_tree_view_get_column_(GadgetID(0), 0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
If EventGadget() = 1
Column0State = gtk_tree_view_column_get_visible_(*Column0)
gtk_tree_view_column_set_visible_(*Column0, Column0State ! 1)
If Column0State
SetGadgetText(1, "Display Column 0")
Else
SetGadgetText(1, "Hide Column 0")
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 3:21 pm
by sverson
Thanks again.
Works great!
Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 4:23 pm
by freak
Hide the header on the mac:
Code: Select all
ImportC ""
SetDataBrowserListViewHeaderBtnHeight(Control.i, Height.u)
GetDataBrowserListViewHeaderBtnHeight(Control.i, *Height.UNICODE)
EndImport
#noErr = 0
If OpenWindow(0, 100, 100, 350, 100, "NoColumnHeader & AutoSize", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 340, 90, "", 200, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "", 200)
For X.l = 1 To 5
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
Next
If GetDataBrowserListViewHeaderBtnHeight(GadgetID(0), @oldheight.u) = #noErr
; If you want the header back, call this again with 'oldheight' as last parameter
; (if you never want to get the header back, you don't need the GetDataBrowserListViewHeaderBtnHeight() call at all)
SetDataBrowserListViewHeaderBtnHeight(GadgetID(0), 0)
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
There is no way to autosize the columns by content (only by some predefined min/max values). I suggest to choose a fixed column with which you think makes sense for your data and then apply the autosize only for the OS that support it.
Re: NOCOLUMNHEADER & AUTOSIZE on Linux & Mac
Posted: Thu May 27, 2010 9:41 pm
by sverson
Thanks for your help, Freak.
Will test it asap.