' Pixmap.bas
' Translated from C to FB by TinyCla, 2006
'
' Reviewed by TJF (2011-2014)
' Details: http://developer.gnome.org/gtk/

#INCLUDE ONCE "Gir/Gtk-2.0.bi" ' Gtk+-2 only!!!
#INCLUDE ONCE "Gir/_GObjectMacros-2.0.bi"


' is invoked when the button is clicked.  It just prints a message.
SUB button_clicked CDECL ( BYVAL widget AS GtkWidget PTR, BYVAL user_data AS gpointer )

	PRINT "button clicked"

END SUB



' ==============================================
' Main
' ==============================================

' XPM data of Open-File icon
DIM AS gchar PTR xpm_data(...) => { _
  @"16 16 3 1", _
  @"       c None", _
  @".      c #000000000000", _
  @"X      c #FFFFFFFFFFFF", _
  @"                ", _
  @"   ......       ", _
  @"   .XXX.X.      ", _
  @"   .XXX.XX.     ", _
  @"   .XXX.XXX.    ", _
  @"   .XXX.....    ", _
  @"   .XXXXXXX.    ", _
  @"   .X.XXX.X.    ", _
  @"   .XX.X.XX.    ", _
  @"   .XXX.XXX.    ", _
  @"   .XX.X.XX.    ", _
  @"   .X.XXX.X.    ", _
  @"   .XXXXXXX.    ", _
  @"   .........    ", _
  @"                ", _
  @"                "}


' create the main window, and attach delete_event signal to terminating the application
gtk_init(@__FB_ARGC__, @__FB_ARGV__)
VAR win = gtk_window_new (GTK_WINDOW_TOPLEVEL)
g_signal_connect (G_OBJECT (win), "delete_event", G_CALLBACK (@gtk_main_quit), NULL)
gtk_container_set_border_width (GTK_CONTAINER (win), 10)
gtk_widget_show (win)

' now for the pixmap from gdk
VAR style = gtk_widget_get_style (win)

DIM AS GdkBitmap PTR mask
VAR pixmap = gdk_pixmap_create_from_xpm_d (GDK_DRAWABLE(win->Window),  @mask, @style->bg(GTK_STATE_NORMAL), @xpm_data(0))

' a pixmap widget to contain the pixmap
VAR pixmapwid = gtk_pixmap_new (pixmap, mask)
gtk_widget_show (pixmapwid)

' a button to contain the pixmap widget
VAR button = gtk_button_new ()
gtk_container_add (GTK_CONTAINER (button), pixmapwid)
gtk_container_add (GTK_CONTAINER (win), button)
gtk_widget_show (button)

g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (@button_clicked), NULL)

' show the window
gtk_main ()
