#include Once "window9.bi"

Function Imagegadget( iGadget As Long , x As Long , y As Long , width_ As Long , height As Long  , pImage As hbitmap = 0 , style1 As Long = 0, style2 As Long = 0) As hwnd Export
	
	Dim As HWND 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)
	
	eventbox = gtk_event_box_new ()	
	
	pGlobalTypeWindow9->ListGadgets->addNodeSub(iGadget , Cint(eventbox) ,  4)
	
	gtk_fixed_put(GTK_FIXED(vbox), eventbox, x , y)  
	
	If pImage <> 0 Then
	
		Dim As Hbitmap  pix2
		
		Dim As gint wIm ,hIm 
		
		pix2 = gdk_pixbuf_copy (pImage)
		
		wIm  = gdk_pixbuf_get_width(pix2)
		
		hIm  = gdk_pixbuf_get_height(pix2)
		
		Dim As Any Ptr imTemp  = gtk_image_new_from_pixbuf(pix2)

		gtk_widget_set_size_request(eventbox, wIm , hIm)
		
		gtk_container_add (GTK_CONTAINER (eventbox), imTemp)	
		
		pGlobalTypeWindow9->ListWinAndContainers->addNodeSub( Cint(eventbox) , Cint(imTemp) , 1)
		
		g_object_set_data (Cast(Any Ptr, eventbox), "W_SIZE" , Cast(Any Ptr,Cint(wIm)))
		
		g_object_set_data (Cast(Any Ptr, eventbox), "H_SIZE" , Cast(Any Ptr,Cint(hIm)))	
		
		g_object_set_data (Cast(Any Ptr, eventbox), "BITMAP" , Cast(Any Ptr,pImage))
		
		gtk_widget_show(imTemp)	
		
	Else
	
		pGlobalTypeWindow9->ListWinAndContainers->addNodeSub( Cint(eventbox) , Cint(0)  , 1)
		
		gtk_widget_set_size_request(eventbox, width_, height)
		
		g_object_set_data (Cast(Any Ptr, eventbox), "W_SIZE" , Cast(Any Ptr,Cint(width_)))
		
		g_object_set_data (Cast(Any Ptr, eventbox), "H_SIZE" , Cast(Any Ptr,Cint(height)))		

	Endif
	
	g_object_set_data (Cast(Any Ptr, eventbox), "X_SIZE" , Cast(Any Ptr,Cint(x)))
	
	g_object_set_data (Cast(Any Ptr, eventbox), "Y_SIZE" , Cast(Any Ptr,Cint(y)))	
	
	tree_add_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	Dim As Node Ptr fNode = tree_find_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	g_signal_connect(G_OBJECT(eventbox), "event", G_CALLBACK (@EventsImageGadgetAllFunc), @(fNode->x))
	
	g_signal_connect(G_OBJECT(eventbox), "size-allocate", G_CALLBACK (@size_allocate_signals), @(fNode->x))
	
	gtk_widget_show(vBox)

	gtk_widget_show(eventbox)
	
	Return eventbox

End Function