Re: Pascal code
First note: I'm using GTK in C, but it looks for me that the functions you have in the code are exactly the same and have the same arguments as C ones.
Code:
procedure change_xpm(sbutton:pgtkwidget; smile:ppgchar);
begin;
gtk_container_remove( pGTKCONTAINER(sbutton), pixmapwid );
widget 'pixmapwid' is removed from container sbutton
style := gtk_widget_get_style( window );
thepixmap := gdk_pixmap_create_from_xpm_d( window^.window, @mask,
@style^.bg[GTK_STATE_NORMAL],
ppgchar (smile ));
gdk_pixmap_create_from_xpm_ prototype (in C) is:
GdkPixmap* gdk_pixmap_create_from_xpm_d
(GdkDrawable *drawable,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data);
It simply creates a pixmap from data in XPM format. In this case,
the data (smile) was one of the procedure's arguments.
pixmapwid := gtk_pixmap_new( thepixmap, mask );
gtk_widget_show( pixmapwid );
gtk_container_add( pGTKCONTAINER(sbutton), pixmapwid );pixmapwid (new) is added to container sbutton
GTK_Widget_Show(sbutton); showing the button
end;
The procedure simply changes pixmap of 'sbutton' from the current one to data passed in 'smile'
PROCEDURE Button_Label(widget:pGtkWidget; var blabel:pGtkWidget; num:integer);
begin
gtk_container_remove(GTK_CONTAINER(widget), blabel);
Removing widget from container.
case num of
0:blabel:=gtk_label_new(pchar(''));
1:blabel:=gtk_pixmap_new( xpm1, mask1 );
2:blabel:=gtk_pixmap_new( xpm2, mask2 );
3:blabel:=gtk_pixmap_new( xpm3, mask3 );
4:blabel:=gtk_pixmap_new( xpm4, mask4 );
5:blabel:=gtk_pixmap_new( xpm5, mask5 );
6:blabel:=gtk_pixmap_new( xpm6, mask6 );
7:blabel:=gtk_pixmap_new( xpm7, mask7 );
8:blabel:=gtk_pixmap_new( xpm8, mask8 );
10:blabel:=gtk_pixmap_new( xpm10, mask10 );
11:blabel:=gtk_pixmap_new( xpm11, mask11 );
13:blabel:=gtk_pixmap_new( xpm13, mask13 );
end;
Depending on the number 'num' passed as
third argument, the right XPM is loaded, with right mask
(you have them defined somewhere in the code, I guess.
gtk_container_add(GTK_CONTAINER(widget), blabel);
Newly loaded data is added to the container.
gtk_widget_show(blabel);
gtk_widget_show (widget);
And the widgets are shown.
end;
Hope that helps. As I wrote before, you can use manual for C, so when you want to check what a certainfunction does, you can find the info in GTK/GDK manual here: http://gtk.org/api/
|