treeview - more then one icon and more text

BlitzMax Forums/BlitzMax GUI Programming/treeview - more then one icon and more text

hi,
i´m new to blitzmax and maxgui.
i want to create a treeview with more than one icon for each node. is this with maxgui possible?
something like


and another question is it possible to have an additional text to each node to the right? like


i want to create a treeview with more then one icon for each node. is this with maxgui possible?

and another question is it possible to have an additional text to each node to the right? like

Put simply, no, although you may get somewhere if you hack the MaxGUI modules apart and override the window drawing messages for the nodes.

I've never seen this idea before in any other application - I think the expected behaviour is to use tooltips to display additional relevant text for the node (ahem, I know there aren't any for treeviews at the moment) or a separate panel beside the treeview which displays any properties of the currently selected node.

thanks for the information

another question about Listboxes

is it possible to format Listboxes

1. some lines are bold, italic, different colour or differnt font?

2. to put some TABs between the text
example:

Line 1 Text ---------------TAB--->Text2
Line 2 longer Text---------TAB--->Text2

3. to make the icons longer. for example not 12*12 Pixels but 24*12 Pixel.

:-P

1. No
2. Just tried it now, and inserting a "~t" in between two strings doesn't make any differnce, so No.
3. No

You're not having much luck here are you... :-(

I think what you probably want is a multi-column listbox - one of the most frequently requested gadgets from MaxGUI users.

My only suggestion would be to perhaps look at some of the community contributed hacks (if you are only wanting to compile on Windows):

http://www.blitzbasic.com/Community/posts.php?topic=53343

SuperStrict

Import MaxGUI.Drivers

?Win32

AppTitle = "Multi-Column Listbox Example"

Global wndMain:TGadget = CreateWindow(AppTitle,100,100,400,300,Null,WINDOW_TITLEBAR)
	Global lstMultiColumn:TGadget = CreateListBox(0,0,ClientWidth(wndMain),ClientHeight(wndMain),wndMain,0)
	
	For Local r% = 1 To 10
		AddGadgetItem lstMultiColumn, ""
	Next
	
	For Local c% = 1 To 5
		AddListBoxColumn(lstMultiColumn, c-1, "Column " + c, 100)
		For Local r% = 1 To 10
			AddListBoxItem(Int(lstMultiColumn,Rnd()*1000),r-1,c-1)
		Next
	Next
	
Repeat
	Select WaitEvent()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE;End
	EndSelect
	Print CurrentEvent.ToString()
Forever

'MultiColumn List Box Code (created by Ziltch, adapted by Regular K)
'http://www.blitzbasic.com/Community/posts.php?topic=53343

Extern "win32"
	Function SetWindowLongA:Int(hWnd:Int,nIndex:Int,lNewLong:Int)
	Function GetModuleHandleA:Int(lMod:Long)
	Function GetWindowLongA:Int(hWnd:Int,nIndex:Int)
	Function MoveWindow(hWnd:Int,X:Int,Y:Int,nWidth:Int,nHeight:Int,bRepaint:Byte)
End Extern


Const LBS_DISABLENOSCROLL:Int = 4096
Const LBS_EXTENDEDSEL:Int = $800
Const LBS_HASSTRINGS:Int = 64
Const LBS_MULTICOLUMN:Int = 512
Const LBS_MULTIPLESEL:Int = 8
Const LBS_NODATA:Int	= $2000
Const LBS_NOINTEGRALHEIGHT:Int = 256
Const LBS_NOREDRAW :Int= 4
Const LBS_NOSEL:Int =  $4000
Const LBS_NOTIFY:Int  = 1
Const LBS_OWNERDRAWFIXED:Int = 16
Const LBS_OWNERDRAWVARIABLE:Int = 32
Const LBS_SORT:Int = 2
Const LBS_STANDARD:Int = $a00003
Const LBS_USETABSTOPS:Int = 128
Const LBS_WANTKEYBOARDINPUT:Int = $400


Const LVM_FIRST:Int = $1000
Const LVM_GETCOLUMNA:Int	=(LVM_FIRST+25)
Const LVM_GETCOLUMNW:Int	=(LVM_FIRST+95)
Const LVM_SETCOLUMNA:Int	=(LVM_FIRST+26)
Const LVM_SETCOLUMNW:Int	=(LVM_FIRST+96)
Const LVM_INSERTCOLUMNA:Int	=(LVM_FIRST+27)
Const LVM_INSERTCOLUMNW:Int	=(LVM_FIRST+97)
Const LVM_DELETECOLUMN:Int	=(LVM_FIRST+28)
Const LVM_GETCOLUMNWIDTH:Int	=(LVM_FIRST+29)
Const LVM_GETITEMA:Int	= (LVM_FIRST+5)
Const LVM_GETITEMW:Int	= (LVM_FIRST+75)
Const LVM_SETITEMA:Int	= (LVM_FIRST+6)
Const LVM_SETITEMW:Int	= (LVM_FIRST+76)
Const LVM_INSERTITEMA:Int	= (LVM_FIRST+7)
Const LVM_INSERTITEMW:Int	= (LVM_FIRST+77)
Const LVM_DELETEITEM:Int	= (LVM_FIRST+8)
Const LVM_DELETEALLITEMS:Int	= (LVM_FIRST+9)
Const LVM_GETCALLBACKMASK:Int	= (LVM_FIRST+10)
Const LVM_SETCALLBACKMASK:Int	=(LVM_FIRST+11)
Const LVM_SETCOLUMNWIDTH:Int	=(LVM_FIRST+30)
Const LVM_GETTEXTCOLOR:Int	=(LVM_FIRST+35)
Const LVM_SETTEXTCOLOR:Int	=(LVM_FIRST+36)
Const LVM_GETTEXTBKCOLOR:Int	=(LVM_FIRST+37)
Const LVM_SETTEXTBKCOLOR:Int	=	(LVM_FIRST+38)

Const LVCF_FMT:Int	=1
Const LVCF_WIDTH:Int	=2
Const LVCF_TEXT:Int	=4
Const LVCF_SUBITEM:Int	=8
Const LVCF_IMAGE:Int= 16
Const LVCF_ORDER:Int =32
Const LVIF_TEXT:Int = 1

Const LVS_ICON:Int             =0
Const LVS_REPORT:Int	        =1
Const LVS_SMALLICON:Int	        =2
Const LVS_LIST:Int	            =3
Const LVS_TYPEMASK:Int         =3
Const LVS_SINGLESEL:Int        =4
Const LVS_SHOWSELALWAYS:Int    =8
Const LVS_SORTASCENDING:Int    =16
Const LVS_SORTDESCENDING:Int   =32
Const LVS_SHAREIMAGELISTS:Int	=64
Const LVS_NOLABELWRAP:Int      =128
Const LVS_AUTOARRANGE:Int      =256
Const LVS_EDITLABELS:Int       =512
Const LVS_NOSCROLL:Int         =$2000
Const LVS_TYPESTYLEMASK:Int    =$fc00
Const LVS_ALIGNTOP:Int	        =0
Const LVS_ALIGNLEFT:Int	       =$800
Const LVS_ALIGNMASK:Int	       =$c00
Const LVS_OWNERDRAWFIXED:Int  =$400
Const LVS_NOCOLUMNHEADER:Int  =$4000
Const LVS_NOSORTHEADER:Int	   =$8000
Const GWL_STYLE:Int      = -16

Type  LVCOLUMN  
	Field mask:Int
	Field fmt:Int
	Field cx:Int
	Field pszText:Byte Ptr
	Field cchTextMax:Int
	Field iSubItem:Int
EndType

Type LVITEM 
	Field mask:Int
	Field iItem:Int
	Field iSubItem:Int
	Field iState:Int
	Field stateMask:Int
	Field pszText:Byte Ptr
	Field cchTextMax:Int
	Field iImage:Int
	Field lParam:Int
	Field iIndent:Int
	Field iGroupId:Int
	Field cColumns:Int
	Field puColumns:Int
EndType


Function AddListBoxColumn(ListBox:TGadget,Column:Int,HeadingText:String,Width:Int,Style:Int = 0)
	Local ListboxHwnd:Int=QueryGadget(ListBox,QUERY_HWND)
	Local col:LVCOLUMN = New LVCOLUMN	
	Col.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT
	Col.fmt = Style
	Col.cx = Width
	col.pszText = HeadingText$.ToCString()
	'	Col.cchTextMax = Text$.Length + 1
	Local ListBoxstyle:Int = GetWindowLongA(ListboxHwnd , GWL_STYLE)
	SetWindowLongA(ListboxHwnd , GWL_STYLE, ListBoxstyle ~ LVS_NOCOLUMNHEADER | LBS_MULTICOLUMN) 'change the style so that we have headings
	SendMessageA(ListboxHwnd,LVM_INSERTCOLUMNA,Column,Int(Byte Ptr Col))
End Function

Function ListBoxHeading(ListBox:TGadget,Column:Int,Text:String)
	Local ListboxHwnd:Int=QueryGadget(ListBox,QUERY_HWND)
	Local col:LVCOLUMN = New LVCOLUMN	
	Col.mask = LVCF_TEXT| LVCF_FMT 
	col.pszText = Text$.ToCString()
	'	Col.cchTextMax = Text$.Length + 1
	SendMessageA(ListboxHwnd,LVM_SETCOLUMNA,Column,Int(Byte Ptr Col))
End Function

Function ListBoxColumnWidth(ListBox:TGadget,Column:Int,width:Int)
	Local ListboxHwnd:Int=QueryGadget(ListBox,QUERY_HWND)
	Local col:LVCOLUMN = New LVCOLUMN	
	Col.mask = LVCF_WIDTH
	col.cx   = width
	SendMessageA(ListboxHwnd,LVM_SETCOLUMNA,Column,Int(Byte Ptr Col))
End Function

Function AddListBoxItem(ListBox:TGadget,Text:String,Row:Int,Column:Int)
	Local ListboxHwnd:Int=QueryGadget(ListBox,QUERY_HWND)
	Global ColItem:LVITEM  = New LVITEM
	ColItem.mask = LVIF_TEXT
	ColItem.iSubItem = Column
	ColItem.iItem = Row
	ColItem.pszText = Text$.ToCString()
	ColItem.cchTextMax =  Text$.Length + 1
	SendMessageA( ListboxHwnd,LVM_SETITEMA,0,Int(Byte Ptr ColItem))	
End Function


Otherwise, you might want to consider looking at Brucey's wxWidgets GUI library wrapper: wxMax.

If it interests you, wxWidgets can do some of what you mention (changing the colour of lines, for example), but it's a bit trickier to use than MaxGUI, and the BlitzMax port isn't finished at present.

Since wxWidgets can do some of this, I assume you would be able to do it with the Windows API. Perhaps taking a look at the source of the wxWidgets components might put you in the right direction?

You could fake tabs, couldn't you?

As you heard already it's not possible to do it like you wanted. The question may is, does it need to be like that? If not, you could may arrange it differently which could be still ok for you or the user.
When looking at both examples, the first idea which came up, is to create for the projects in the list a subnode. This subnode can have again an icon (your second one) and as text perhaps your numbers (those after the tabs) and it belongs directly to each project in the tree structure.
Those subnodes can be automatically expanded by your program, to stay always open. Or you can do so by a single click on a treeview item manually on demand.
Don't know how important the extra info is? Do you need it visible all the time, or is it just a minor thing? As the treeview can detect a right click on a node, you could popup a small menu with icon and text (it does not need to do anything when selected) like a context menu.
Just some ideas...

again thanks for your help.
i have a workaround for my problem.
i create two versions for each icon. primary usage of the icon is to tell the user the colour of drawn lines on a canvas. secondary usage is to tell the user that the lines are visible or not. so i create for each colour a visible and an invisible icon.

compared to my next problem this is trivial....

triangulating 2d-polygons.

it seems nobody has made this in blitzmax.
but this is the wrong thread to discuss this. i´m opening a new thread in "BlitzMax Programming"

thanks for your effort