8
procedure hello(widget : pGtkWidget ; data: pgpointer ); cdecl;
10
writeln('Hello World');
13
function delete_event (widget : pGtkWidget ; event: pGdkEvent; data: pgpointer ): integer; cdecl;
15
writeln('Delete Event Occurred');
16
delete_event := ord(true);
19
procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
25
window, button : pGtkWidget;//GtkWidget is the storage type for widgets
29
// This is called in all GTK applications. Arguments are parsed
30
// from the command line and are returned to the application.
31
gtk_init (@argc, @argv);
33
// create a new window
34
window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
36
// When the window is given the "delete_event" signal (this is given
37
// by the window manager, usually by the 'close' option, or on the
38
// titlebar), we ask it to call the delete_event () function
39
// as defined above. The data passed to the callback
40
// function is NULL and is ignored in the callback function.
41
gtk_signal_connect (pGTKOBJECT (window), 'delete_event',
42
GTK_SIGNAL_FUNC (@delete_event), NIL);
45
// Here we connect the "destroy" event to a signal handler.
46
// This event occurs when we call gtk_widget_destroy() on the window,
47
// or if we return 'FALSE' in the "delete_event" callback.
48
gtk_signal_connect (pGTKOBJECT (window), 'destroy',
49
GTK_SIGNAL_FUNC (@destroy), NULL);
51
// Sets the border width of the window.
52
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
54
// Creates a new button with the label "Hello World".
55
button := gtk_button_new_with_label ('Hello_World');
57
// When the button receives the "clicked" signal, it will call the
58
// function hello() passing it NULL as its argument. The hello()
59
// function is defined above. */
60
gtk_signal_connect (pGTKOBJECT (button), 'clicked',
61
GTK_SIGNAL_FUNC (@hello), NULL);
63
// This will cause the window to be destroyed by calling
64
// gtk_widget_destroy(window) when "clicked". Again, the destroy
65
// signal could come from here, or the window manager
66
gtk_signal_connect_object (pGTKOBJECT (button), 'clicked',
67
GTK_SIGNAL_FUNC (@gtk_widget_destroy),
70
// This packs the button into the window (a gtk container).
71
gtk_container_add (GTK_CONTAINER (window), button);
73
// The final step is to display this newly created widget.
74
gtk_widget_show (button);
77
gtk_widget_show (window);
79
// All GTK applications must have a gtk_main(). Control ends here
80
// and waits for an event to occur (like a key press or