#include Once "window9.bi"

Function Listviewgadget(iGadget As Long , iX As Long, iY As Long, iWidth As Long, iHeight As Long  , iExStyle As Long = 0  , iStyle As Long = 0 , iStyle2 As Long  = 0, iSizeIcon As Long  = 0, iStyleIcon As Long = 0) As Hwnd Export
	
	Dim As HWND listview , vBox , mainBox , scroll
	
	Dim As GtkListStore Ptr liststore
	
	Dim As ListT Ptr pListTemp
	
	Dim As GtkTreeSelection Ptr selection
	
	Freegadget(iGadget)
	
	pGlobalTypeWindow9->OptGroup = 0 ' reset Group OptionGadget
	
	pListTemp = Cast(ListT Ptr,pGlobalTypeWindow9->ListWinAndContainers->findNodeFunc(Cint(pGlobalTypeWindow9->CurentHwnd)))
	
	mainBox = Cast(hwnd , pListTemp->anyTwoData)	
	
	vbox = gtk_fixed_new()
	
	gtk_container_add (GTK_CONTAINER(mainBox), vbox)	
	
	scroll = gtk_scrolled_window_new (NULL, NULL)
	
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC)	
	
	Dim As Gtype dd(1000) 
	
	For i As Long = 0 To 999
		
		If i And 1 Then
			
			dd(i) = G_TYPE_STRING
			
		Else
			
			dd(i) = GDK_TYPE_PIXBUF
			
		Endif
		
	Next
	
	liststore = gtk_list_store_newv(999, @dd(0))
	
	listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(liststore))
	
	selection = gtk_tree_view_get_selection (Cast(Any Ptr,listview))
	
	If iStyle And LVS_SINGLESEL Then	
		
		gtk_tree_selection_set_mode (Cast(Any Ptr,selection), GTK_SELECTION_BROWSE)
		
	Else
		
		gtk_tree_selection_set_mode (Cast(Any Ptr,selection), GTK_SELECTION_MULTIPLE)
		
	Endif
	
	If iStyle And 	LVS_NOCOLUMNHEADER Then
		
		gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (listview), False)
		
	Endif
	
	If iExStyle And LVS_EX_GRIDLINES Then
		
		gtk_tree_view_set_grid_lines(GTK_TREE_VIEW (listview) , GTK_TREE_VIEW_GRID_LINES_HORIZONTAL)
		
	Endif		
	
	g_object_unref(liststore)
	
	gtk_container_add (GTK_CONTAINER (scroll), listview)		
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(listview) ,  19)
	
	gtk_widget_set_size_request(scroll, iWidth, iHeight)
	
	gtk_fixed_put(GTK_FIXED(vbox), scroll, iX , iY)
	
	g_object_set_data (Cast(Any Ptr, listview), "X_SIZE" , Cast(Any Ptr,Cint(iX)))
	
	g_object_set_data (Cast(Any Ptr, listview), "Y_SIZE" , Cast(Any Ptr,Cint(iY)))
	
	g_object_set_data (Cast(Any Ptr, listview), "W_SIZE" , Cast(Any Ptr,Cint(iWidth)))
	
	g_object_set_data (Cast(Any Ptr, listview), "H_SIZE" , Cast(Any Ptr,Cint(iHeight)))	
	
	tree_add_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	Dim As Node Ptr fNode = tree_find_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)	
	
	g_signal_connect(G_OBJECT(listview), "cursor-changed", G_CALLBACK (@EventCursorChangesListViewGadgetSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(listview), "button-press-event", G_CALLBACK (@MousePressListViewSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(listview), "button-release-event", G_CALLBACK (@MousePressListViewSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(scroll), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
	
	gtk_widget_show(vBox)

	gtk_widget_show(scroll)

	gtk_widget_show(listview)
	
	gtk_widget_modify_font(listview, pGlobalTypeWindow9->fontCurent)
	
	Return listview
	
End Function