ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Originally posted by joesbox sorry i haven't seen pascal since jr. high
If you have nothing to contribute to a thread please don't respond, many people go though the forums first and look for posts that have not yet had any repilies.
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/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.