#include Once "window9.bi"

Function Spingadget(iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long, maxvalue As Long, minvalue As Long, curvalue As Long, style1 As Long = 0 , style2 As Long = 0 ) As Hwnd Export
	
	Dim As HWND spin , 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(curvalue , minvalue , maxvalue,1, 10, 0))
	
	spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0)
	
	If style1 And UDS_WRAP Then
	
		gtk_spin_button_set_wrap (Cast(Any Ptr,spin),True)

	Endif
	
	If style2 And ES_NUMBER Then
	
		gtk_spin_button_set_numeric(Cast(Any Ptr,spin),True)

	Endif	
	
	If pGlobalTypeWindow9->ListRangeForSliders = 0 Then
	
		pGlobalTypeWindow9->ListRangeForSliders = New LinList

	Endif	
	
	pGlobalTypeWindow9->ListRangeForSliders->addNodeSub(iGadget , minvalue ,  maxvalue)
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(spin) ,  7)

	gtk_widget_set_size_request(spin, width_, height_)
	
	gtk_fixed_put(GTK_FIXED(vbox), spin, x , y)
	
	g_object_set_data (Cast(Any Ptr, spin), "X_SIZE" , Cast(Any Ptr,Cint(x)))
	
	g_object_set_data (Cast(Any Ptr, spin), "Y_SIZE" , Cast(Any Ptr,Cint(y)))
	
	g_object_set_data (Cast(Any Ptr, spin), "W_SIZE" , Cast(Any Ptr,Cint(width_)))
	
	g_object_set_data (Cast(Any Ptr, spin), "H_SIZE" , Cast(Any Ptr,Cint(height_)))	
	
	tree_add_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	Dim As Node Ptr fNode = tree_find_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)	
	
	g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK (@EventsSpinGadgetSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(spin), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
	
	gtk_widget_show(vbox)
	
	gtk_widget_show(spin)
	
	gtk_widget_modify_font(spin , pGlobalTypeWindow9->fontCurent)
	
	Return spin		

End Function