#include Once "window9.bi"

Function Buttongadget(iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = 0) As HWND Export
	
	Dim As HWND button , vBox , mainBox
	
	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)
	
	If style = FB_BS_PUSHLIKE Then
		
		button = gtk_toggle_button_new_with_label(g_locale_to_utf8(sText,Len(sText),0,0,0))
		
	Else
		
		button = gtk_button_new_with_label(g_locale_to_utf8(sText,Len(sText),0,0,0))	
		
	Endif
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(button) ,  1)
	
	gtk_widget_set_size_request(button, width_, height_)
	
	gtk_fixed_put(GTK_FIXED(vbox), button, x , y)
	
	g_object_set_data (Cast(Any Ptr, button), "X_SIZE" , Cast(Any Ptr,Cint(x)))
	
	g_object_set_data (Cast(Any Ptr, button), "Y_SIZE" , Cast(Any Ptr,Cint(y)))
	
	g_object_set_data (Cast(Any Ptr, button), "W_SIZE" , Cast(Any Ptr,Cint(width_)))
	
	g_object_set_data (Cast(Any Ptr, button), "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(button), "clicked", G_CALLBACK (@EventsButtonClickSub), @(fNode->x))
	
	g_signal_connect(G_OBJECT(button), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
	
	gtk_widget_show(vbox)
	
	gtk_widget_show(button)
	
	Dim As Any Ptr wChild = gtk_bin_get_child(GTK_BIN(button))
	
	If wChild Then
		
		gtk_widget_modify_font( wChild , pGlobalTypeWindow9->fontCurent)
		
		g_object_set_data (Cast(Any Ptr, button), "FONT" , Cast(Any Ptr,pGlobalTypeWindow9->fontCurent))
		
	Endif
	
	Return button
	
End Function
