#include Once "window9.bi"

Function Createtoolbar(iStyle1 As Long = IDB_STD_SMALL_COLOR , iStyle2 As Long  = 0 , iStyle3 As Long = 0 ) As Integer Export  
	
	If pGlobalTypeWindow9->ListToolBar = 0 Then
		
		pGlobalTypeWindow9->ListToolBar = New LinList
		
		if pGlobalTypeWindow9->ListToolBar = 0 then
			
			print "Allocated memory error in Createtoolbar!"
			
			return 0
			
		EndIf
		
	Endif
	
	Dim As Long yPos
	
	Dim As Any Ptr pMenu = g_object_get_data(Cast(Any Ptr, pGlobalTypeWindow9->CurentHwnd) , "main_menu")
	
	If pMenu Then
		
		For i As Integer = 0 To 1000 ' wait set setting x-server
			
			Sendnullevent
			
			Windowevent
			
		Next		
		
		Dim As GdkRectangle rect
		
		gtk_widget_get_allocation(pMenu , @rect)
		
		yPos = rect.height		
		
	Endif
	
	Dim As ListT Ptr pListTemp
	
	Dim As Any Ptr mainBox , vBox
	
	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)
	
	Dim As HWND toolbar = gtk_toolbar_new()
	
	gtk_fixed_put(GTK_FIXED(vbox), toolbar , 0 , yPos)
	
	gtk_toolbar_set_show_arrow(Cast(Any Ptr, toolbar) , False)
	
	If iStyle2 And TBSTYLE_TOOLTIPS Then
		
		g_object_set_data(Cast(Any Ptr, toolbar) , "tooltip" , Cast(Any Ptr,1))
		
	Endif
	
	gtk_toolbar_set_icon_size ( Cast(Any Ptr ,toolbar) ,  iStyle1)
	
	gtk_widget_show(vbox)
	
	gtk_widget_show(toolbar)
	
	Return Cint(toolbar)
	
End Function