#include ONCE "window9.bi"

type TStatusField
	
	label as Hwnd
	
	sep as hwnd
	
	width as long
	
	iAllWidth as Long
	
	x_Label as Long
	
	iFEnd as Byte
	
End Type

Sub SetGadgetFont(iGadget as Long = 0 , iFont as Integer = 0) export
	
	if iGadget = 0 andalso iFont = 0 then
		
		pGlobalTypeWindow9->fontCurent = pGlobalTypeWindow9->fontDefault
		
	elseif iGadget = 0 then
		
		pGlobalTypeWindow9->fontCurent = cast(any ptr, iFont)
		
	else
		
		dim as any ptr pWidget 
		
		dim as long classWidget
		
		dim as PangoFontDescription Ptr f = cast(PangoFontDescription Ptr , iFont)
		
		dim as ListT ptr pTemp = pGlobalTypeWindow9->ListGadgets->findNodeFunc(iGadget)
		
		if pTemp <> 0 then
			
			pWidget = cast(any ptr,pTemp->anyTwoData)
			
			classWidget = pTemp->anyThreeData
			
		else
			
			exit sub
			
		endif		
		
		select case classWidget	
				
			Case 1 , 9 , 10 
				
				gtk_widget_modify_font(gtk_bin_get_child(GTK_BIN(pWidget)) , f)
				
				g_object_set_data (cast(any ptr, pWidget), "FONT" , CAST(ANY PTR,f))
				
			Case 2 ,  5 , 6 , 7 , 15 , 19 , 20 , 8 , 11 
				
				gtk_widget_modify_font(pWidget , f)	
				
			case 16
				
				dim as GList ptr children = gtk_container_get_children(pWidget)
				
				pWidget = children->data
				
				gtk_widget_modify_font(pWidget , f)
				
			case 22	
				
				dim as Long iNpages = gtk_notebook_get_n_pages (pWidget)
				
				for i as Long = 0 to iNpages - 1
					
					dim as any ptr w = gtk_notebook_get_nth_page( pWidget , i)
					
					w = gtk_notebook_get_tab_label(pWidget , w)
					
					dim as GList ptr children = gtk_container_get_children(w)
					
					gtk_widget_modify_font ( children->data , f)
					
				Next
				
			case 27
				
				dim as any ptr mFirstItemStatus = g_object_get_data (cast(any ptr,pWidget), "statusbarchild")
				
				if mFirstItemStatus then gtk_widget_modify_font ( mFirstItemStatus , f)
				
				dim as GSList ptr pTemp = g_object_get_data (cast(any ptr,pWidget), "statusbarlist")
				
				if pTemp then
					
					while pTemp
						
						dim as TStatusField ptr Tsf =  cast(TStatusField ptr,pTemp->data)
						
						gtk_widget_modify_font ( tsf->label , f)
						
						pTemp = g_slist_next(pTemp)
						
					Wend						
					
				EndIf	
				
		End Select	
		
	EndIf
	
End Sub