#include ONCE "window9.bi"

function GetGadgetText(iGadget as Long ) as string export
	
	dim as hwnd pWidget 
	
	dim as long classWidget
	
	dim as ListT ptr pTemp = pGlobalTypeWindow9->ListGadgets->findNodeFunc(iGadget)
	
	if pTemp <> 0 then
	
		pWidget = cast(hwnd,pTemp->anyTwoData)
		
		classWidget = pTemp->anyThreeData
		
	else
	
		return ""
	
	endif
	
	select case classWidget
	
		Case 1 , 9 , 10
		
			return *gtk_button_get_label(cast(any ptr,pWidget))
			
		case 2
		
			dim as  GtkTextBuffer ptr buffer = gtk_text_view_get_buffer(cast(any ptr,pWidget))

			dim as GtkTextIter iterstart , iterend
			
			dim as gint char_offset1 = 0 , char_offset2 = -1
	
			gtk_text_buffer_get_iter_at_offset (buffer, @iterstart, char_offset1)
			
			gtk_text_buffer_get_iter_at_offset (buffer, @iterend, char_offset2)
			
			return *gtk_text_buffer_get_text(buffer , @iterstart , @iterend , 0)
			
		case 5
		
			return *gtk_label_get_text(cast(any ptr,pWidget))
			
		Case 6 , 7
		
			return *gtk_entry_get_text(cast(any ptr,pWidget))
			
		case 11
		
			return *gtk_label_get_text(cast(any ptr,pWidget))
			
		case 16
		
			dim as any ptr label = gtk_frame_get_label_widget(cast(any ptr,pWidget))
			
			return *gtk_label_get_text(label)
			
		case 27
		
			dim as any ptr label = g_object_get_data (cast(any ptr,pWidget), "statusbarchild")
			
			return *gtk_label_get_text(label)

	End Select			

End function