2
$Id: tut6_1.pp,v 1.1 2000/07/13 06:34:01 michael Exp $
4
This file extracted from the GTK 1.2 tutorial.
7
Converted from C to Pascal by Thomas E. Payne
14
glib,gdk,gtk,sysutils;
16
//* Create a new hbox with an image and a label packed into it
17
//* and return the box. */
18
function xpm_label_box( parent: pGtkWidget;
20
label_text : pchar ): pGtkWidget; cdecl;
23
box1, label_,pixmapwid : pGtkWidget;
28
//* Create box for xpm and label */
29
box1 := gtk_hbox_new (FALSE, 0);
30
gtk_container_set_border_width (GTK_CONTAINER (box1), 2);
31
//* Get the style of the button to get the background color. */
32
style := gtk_widget_get_style(parent);
33
//* Now on to the xpm stuff */
34
//function gdk_pixmap_create_from_xpm(window:PGdkWindow;
36
// transparent_color:PGdkColor; filename:Pgchar):PGdkPixmap;
38
pixmap := gdk_pixmap_create_from_xpm (parent^.window, @mask,
39
@style^.bg[GTK_STATE_NORMAL],
41
pixmapwid := gtk_pixmap_new (pixmap, mask);
42
//* Create a label for the button */
43
label_ := gtk_label_new (label_text);
44
//* Pack the pixmap and label into the box */
45
gtk_box_pack_start (GTK_BOX (box1),
46
pixmapwid, FALSE, FALSE, 3);
47
gtk_box_pack_start (GTK_BOX (box1), label_, FALSE, FALSE, 3);
48
gtk_widget_show(pixmapwid);
49
gtk_widget_show(label_);
50
xpm_label_box := box1;
53
//* Our usual callback function */
54
procedure callback( widget : pGtkWidget; data : pgpointer );cdecl;
56
writeln ('Hello again - '+pchar(data)+' was pressed');
60
//* GtkWidget is the storage type for widgets */
61
window,button,box1 : pGtkWidget;
63
gtk_init (@argc, @argv);
64
//* Create a new window */
65
window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
66
gtk_window_set_title (GTK_WINDOW (window), 'Pixmap''d Buttons!');
67
//* It's a good idea to do this for all windows. */
68
gtk_signal_connect (GTK_OBJECT (window), 'destroy',
69
GTK_SIGNAL_FUNC (@gtk_exit), Nil);
70
gtk_signal_connect (GTK_OBJECT (window), 'delete_event',
71
GTK_SIGNAL_FUNC (@gtk_exit), Nil);
72
//* Sets the border width of the window. */
73
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
74
gtk_widget_realize(window);
75
//* Create a new button */
76
button := gtk_button_new ();
77
//* Connect the "clicked" signal of the button to our callback */
78
gtk_signal_connect (GTK_OBJECT (button), 'clicked',
79
GTK_SIGNAL_FUNC (@callback), pchar('cool button'));
80
//* This calls our box creating function */
81
box1 := xpm_label_box(window, 'info.xpm', 'cool button');
82
//* Pack and show all our widgets */
83
gtk_widget_show(box1);
84
gtk_container_add (GTK_CONTAINER (button), box1);
85
gtk_widget_show(button);
86
gtk_container_add (GTK_CONTAINER (window), button);
87
gtk_widget_show (window);
88
//* Rest in gtk_main and wait for the fun to begin! */
b'\\ No newline at end of file'