#include Once "window9.bi"

Function Scrollbargadget(iGadget As Long , iX As Long, iY As Long, iWidth As Long, iHeight As Long, iMinValue As Long, iMaxValue As Long, iStyle As Long = SBS_HORZ , iLenStep As Long = 10 ) As Hwnd Export
	
	Dim As HWND ScrollBar , vBox , mainBox 
	
	Dim As GtkAdjustment Ptr adjustment 
	
	Dim As ListT Ptr pListTemp
	
	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)	
	
	adjustment = Cast(Any Ptr,gtk_adjustment_new(0 , iMinValue , iMaxValue, 1, iLenStep, 0))
	
	If iStyle = sbs_horz Then
		
		ScrollBar = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustment))
		
	Else 
		
		ScrollBar = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustment))
		
	Endif
	
	g_object_set_data(Cast(Any Ptr , ScrollBar) , "ScrollADJ" , adjustment)
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(ScrollBar) ,  23)
	
	gtk_widget_set_size_request(ScrollBar, iWidth, iHeight)
	
	gtk_fixed_put(GTK_FIXED(vbox), ScrollBar, iX , iY)
	
	g_object_set_data (Cast(Any Ptr, ScrollBar), "X_SIZE" , Cast(Any Ptr,Cint(iX)))
	
	g_object_set_data (Cast(Any Ptr, ScrollBar), "Y_SIZE" , Cast(Any Ptr,Cint(iY)))
	
	g_object_set_data (Cast(Any Ptr, ScrollBar), "W_SIZE" , Cast(Any Ptr,Cint(iWidth)))
	
	g_object_set_data (Cast(Any Ptr, ScrollBar), "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(ScrollBar), "value-changed", G_CALLBACK (@EventsScrollBarGadgetSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(ScrollBar), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
	
	gtk_widget_show(vbox)
	
	gtk_widget_show(ScrollBar)
	
	Return ScrollBar		
	
End Function