#include "window9.bi"

Type TStatusFieldForResize
	
	label As Hwnd
	
	sep As hwnd
	
	Width As Long
	
	iAllWidth As Long
	
	x_Label As Long
	
	iFEnd As Byte
	
End Type

Sub Resizegadget(iGadget As Long ,  x As Long  = FB_IGNORE, y As Long = FB_IGNORE, width_ As Long  = FB_IGNORE, height As Long = FB_IGNORE) Export
	
	Dim As Hwnd win = Cast(HWND, Gadgetid(iGadget))
	
	Dim As Long iClass = Getclassgadget ( iGadget )
	
	Dim As Hwnd w2,w3
	
	Select Case iClass
	
		Case 1 , 3 , 4 , 6 , 7 , 8 , 9 , 10 , 12 , 13 , 14 , 16 , 18 , 21 , 22 , 23 , 26 , 27 , 28
		
			w2 = win
			
			w3 = gtk_widget_get_parent(w2)
			
		Case 2 , 11 , 15 , 19 , 20
		
			w2 = gtk_widget_get_parent(win)
			
			w3 = gtk_widget_get_parent(w2)
			
		Case 5
		
			If g_object_get_data(G_OBJECT(win), "notify") Then
	
				w2 = gtk_widget_get_parent(win)
				
			Else
			
				w2 = win

			Endif
			
			w3 = gtk_widget_get_parent(w2)	
			
		Case 17
		
			#ifdef __USE_GTK3__
			
				w2 = win
				
				w3 = gtk_widget_get_parent(w2)				
			
			#else
			
				w2 = gtk_widget_get_parent(win)
				
				w3 = gtk_widget_get_parent(w2)				
			
			#endif

	End Select
	
	If (x = FB_IGNORE Andalso y = FB_IGNORE) Then
	Else
		If x = FB_IGNORE Then x = Cint(g_object_get_data (Cast(Any Ptr, win), "X_SIZE"))
		
		If y = FB_IGNORE Then y = Cint(g_object_get_data (Cast(Any Ptr, win), "Y_SIZE"))
		
		gtk_fixed_move(GTK_FIXED(w3), w2, x , y)
		
	Endif

	If width_ = FB_IGNORE Then width_ = Cint(g_object_get_data (Cast(Any Ptr, win), "W_SIZE"))
	
	If height = FB_IGNORE Then height = Cint(g_object_get_data (Cast(Any Ptr, win), "H_SIZE"))	

	gtk_widget_set_size_request(w2 , width_ ,	height)
	
	g_object_set_data (Cast(Any Ptr, win), "X_SIZE" , Cast(Any Ptr,Cint(x)))
	
	g_object_set_data (Cast(Any Ptr, win), "Y_SIZE" , Cast(Any Ptr,Cint(y)))
	
	g_object_set_data (Cast(Any Ptr, win), "W_SIZE" , Cast(Any Ptr,Cint(width_)))
	
	g_object_set_data (Cast(Any Ptr, win), "H_SIZE" , Cast(Any Ptr,Cint(height)))
	
	If iClass = 3 Then
	
		Setimagegadget(iGadget, Cast(Any Ptr, g_object_get_data (Cast(Any Ptr, win), "BITMAP")))
		
	Elseif iClass = 27 Then
		
		Dim As GSList Ptr pStoreField = g_object_get_data (Cast(Any Ptr,win), "statusbarlist")
		
		If pStoreField Then
			
			Dim As Long iCountElement = g_slist_length(pStoreField)
			
			Dim As Long iHeightStatusbar = Cint(g_object_get_data (Cast(Any Ptr, win), "H_SIZE"))
			
			For i As Long = 0 To iCountElement-1
				
				Dim As GSList Ptr pTemp = g_slist_nth(pStoreField , i)
				
				Dim As TStatusFieldForResize Ptr pData = pTemp->Data
				
				gtk_widget_set_size_request(pData->label , pData->Width-2  , iHeightStatusbar)
				
				gtk_widget_set_size_request(pData->sep , 2  , iHeightStatusbar)
				
			Next
			
		Endif
		
	Endif	
	
End Sub