3
This file extracted from the GTK tutorial.
6
Converted from C to Pascal by Frank Loemker
7
<floemker@techfak.uni-bielefeld.de>
13
{ XPM data of Open-File icon }
16
xpm_data:array[0..19] of pchar =
37
{ when invoked (via signal delete_event), terminates the application. }
38
procedure close_application(widget : pGtkWidget ; event: pGdkEvent ; data: pgpointer); cdecl;
43
{ is invoked when the button is clicked. It just prints a message. }
44
procedure button_clicked(widget : pGtkWidget ; data: pgpointer); cdecl;
46
writeln ('button clicked');
49
{ GtkWidget is the storage type for widgets }
50
var window, pixmapwid, button : pGtkWidget;
51
thepixmap : pGdkPixmap;
55
{ create the main window, and attach delete_event signal to terminating
57
gtk_init( @argc, @argv );
60
window := gtk_window_new( GTK_WINDOW_TOPLEVEL );
61
gtk_signal_connect (pGTKOBJECT (window), 'delete_event',
62
GTK_SIGNAL_FUNC (@close_application), NIL );
63
gtk_container_set_border_width( pGTKCONTAINER (window), 10 );
64
gtk_widget_show( window );
66
{ now for the pixmap from gdk }
67
style := gtk_widget_get_style( window );
68
thepixmap := gdk_pixmap_create_from_xpm_d( window^.window, @mask,
69
@style^.bg[GTK_STATE_NORMAL],
72
{ a pixmap widget to contain the pixmap }
73
pixmapwid := gtk_pixmap_new( thepixmap, mask );
74
gtk_widget_show( pixmapwid );
76
{ a button to contain the pixmap widget }
77
button := gtk_button_new();
78
gtk_container_add( pGTKCONTAINER(button), pixmapwid );
79
gtk_container_add( pGTKCONTAINER(window), button );
80
gtk_widget_show( button );
82
gtk_signal_connect (pGTKOBJECT(button), 'clicked',
83
GTK_SIGNAL_FUNC(@button_clicked), NIL );