Multi-Line Listbox Item

BlitzMax Forums/BlitzMax Beginners Area/Multi-Line Listbox Item

CASO(Posted 2010) [#1]
I need each item in the listbox to have 2-4 lines. I there a way in MaxGUI, or wxWidgets to create a listbox so that items are not limited to one line.

Example:

Item1-Line1 <--Highlighted from here...
Item1-Line2
Item1-Line3 <--...to here
Item2-Line1
Item2-Line2
Item3-Line1
Item4-Line1
Item4-Line2


Ghost Dancer(Posted 2010) [#2]
You can simply add separate items to the gadget, and use the Extra field to store the actual item number, so something like:

AddGadgetItem(myGadget, "Item 1, Line 1", 0, -1, "", "1")
AddGadgetItem(myGadget, "Item 1, Line 2", 0, -1, "", "1")
AddGadgetItem(myGadget, "Item 2, Line 1", 0, -1, "", "2")
AddGadgetItem(myGadget, "Item 2, Line 2", 0, -1, "", "2")


You then use GadgetItemExtra() to get the data from the extra field, e.g.

selectedLine$ = GadgetItemExtra(myGadget, SelectedGadgetItem(myGadget)) 


Note that the extra field requies an object so you can't stick Integers in there directly, which is why I used strings in the example. If you need to get numerical values, you can simply Int() the returned string from GadgetItemExtra.

selectedLine = Int( GadgetItemExtra(myGadget, SelectedGadgetItem(myGadget)) )


To select all related lines at once, you will need to code your own function to select the lines with the same value in the extra field.


CASO(Posted 2010) [#3]
It is the highlighting that is important though. I need all the lines of an item to be highlighted.


Ghost Dancer(Posted 2010) [#4]
The function will be something like the following. I've not tested it so may need some tweaking but you get the idea.

Function selectItems(gadg:TGadget)
	selectedLine = Int( GadgetItemExtra(myGadget, SelectedGadgetItem(myGadget)) )
	
	For i = 0 To CountGadgetItems(gadg)
		If Int( GadgetItemExtra(myGadget, i) ) = selectedLine Then
			SelectGadgetItem(gadg, i)
		Else
			DeselectGadgetItem(gadg, i)
		End If
	Next
End Function


You then need to call this function when an item is selected. Depending on how you have done your main loop, it will look something like this:

Repeat
	WaitEvent()
	
	Select EventID()
	Case EVENT_WINDOWCLOSE
		Exit

	Case EVENT_GADGETSELECT
		Select EventSource()
			Case myListBox selectItems myListBox
		End Select

	End Select
Forever


Oh, and don't forget you will need to make the listbox multi-select.

Hope this helps :)


CASO(Posted 2010) [#5]
From what I have tested. MaxGUI for Mac does not seem to support the LISTBOX_MULTISELECT property.


JoshK(Posted 2012) [#6]
From what I have tested. MaxGUI for Mac does not seem to support the LISTBOX_MULTISELECT property.

I think this is something totally unsupported by the platform.