#include Once "window9.bi"

Function Textgadget(iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = SS_NOTIFY) As HWND Export
	
	Dim As HWND text , vBox , mainBox , eventbox 
	
	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)	
	
	text = gtk_label_new (sText)
	
	tree_add_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	Dim As Node Ptr fNode = tree_find_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)	
	
	If style And SS_NOTIFY Then
		
		eventbox = gtk_event_box_new ()
		
		gtk_container_add (GTK_CONTAINER (eventbox), text)
		
		gtk_widget_set_size_request(eventbox, width_, height_)
		
		gtk_fixed_put(GTK_FIXED(vbox), eventbox, x , y)	
		
		g_signal_connect(G_OBJECT(eventbox), "event", G_CALLBACK (@EventsTextGadgetAllFunc), @(fNode->x))
		
		g_object_set_data(G_OBJECT(text), "notify", Cast(Any Ptr,1))
		
		g_signal_connect(G_OBJECT(eventbox), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
		
		gtk_widget_show(eventbox)
		
	Else
		
		gtk_widget_set_size_request(text, width_, height_)
		
		gtk_fixed_put(GTK_FIXED(vbox), text , x , y)
		
		g_signal_connect(G_OBJECT(text), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))			
		
	Endif
	
	g_object_set_data (Cast(Any Ptr, text), "X_SIZE" , Cast(Any Ptr,Cint(x)))
	
	g_object_set_data (Cast(Any Ptr, text), "Y_SIZE" , Cast(Any Ptr,Cint(y)))
	
	g_object_set_data (Cast(Any Ptr, text), "W_SIZE" , Cast(Any Ptr,Cint(width_)))
	
	g_object_set_data (Cast(Any Ptr, text), "H_SIZE" , Cast(Any Ptr,Cint(height_)))	
	
	If style And SS_RIGHT Then
		
		gtk_misc_set_alignment(Cast(Any Ptr,text) , 1 , 0.5)
		
	Elseif style And SS_CENTER Then
		
		gtk_misc_set_alignment(Cast(Any Ptr,text) , 0.5 , 0.5)	
		
	Else
		
		gtk_misc_set_alignment(Cast(Any Ptr,text) , 0 , 0.5)
		
	Endif			
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(text) ,  5)

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


