Alternative to the missing #PB_ListIcon_GridLines

Mac OSX specific forum
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Alternative to the missing #PB_ListIcon_GridLines

Post by Shardik »

The PureBasic help for the ListIconGadget states that the flag #PB_ListIcon_GridLines
is not supported in MacOS. But the underlying DataBrowser API of MacOS has two
features which do something similar:
- one feature enables alternating row colors to optically separate the single rows
- another feature draws column dividers

This code example demonstrates their use to "simulate" grid lines:

Code: Select all

ImportC ""
  DataBrowserChangeAttributes(ControlRef.L, AttributesToSet.L, AttributesToClear.L)
EndImport

#kDataBrowserAttributeListViewAlternatingRowColors = (1 << 1)
#kDataBrowserAttributeListViewDrawColumnDividers = (1 << 2)

OpenWindow(0, 0, 0, 430, 105, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 420, 95, "Name", 110)

DataBrowserChangeAttributes(GadgetID(0), #kDataBrowserAttributeListViewAlternatingRowColors | #kDataBrowserAttributeListViewDrawColumnDividers, 0)

AddGadgetColumn(0, 1, "Address", 289)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit"+ #LF$ + "321 Logo Drive, Mouse House, Downtown")

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Vitor_Boss®
User
User
Posts: 81
Joined: Thu Sep 23, 2010 4:22 am

Re: Alternative to the missing #PB_ListIcon_GridLines

Post by Vitor_Boss® »

This is a VB6 version:

Code: Select all

Public Const LVM_FIRST As Long = &H1000
Public Const LVS_EX_FULLROWSELECT As Long = &H20
Public Const LVS_EX_GRIDLINES As Long = &H1
Public Const LVM_GETEXTENDEDLISTVIEWSTYLE As Long = LVM_FIRST + &H37
Public Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = LVM_FIRST + &H36

Public Sub LVstyles(Lv As Object)
    Dim lstyle As Long
    lstyle = SendMessage(Lv.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
    lstyle = lstyle Or LVS_EX_FULLROWSELECT Or LVS_EX_GRIDLINES
    Call SendMessage(Lv.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal lstyle)
End Sub
Hope helpful.
Sorry by bad English.
HP Pavilion DV6-2155DX: Intel i3-330m 2.13 / 4GB DDR3 / 500GB Sata2 HD / Display 15.6" LED / Win7 Ultimate x64 / PB 4.50 x86 demo.
Post Reply