Re: [gtk-list] scrollbars
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] scrollbars
- Date: Wed, 27 Jan 99 10:28:32 +0100
On Tue, 26 Jan 1999 23:46:11 +0300 (MSK), gtk-list@redhat.com (Alexander Kotelnikov) wrote:
> Hello,
> I think many people have this problem, so I'd like to know, how to solve
> it the best way:
> I have a large pixmap and drawing_area, and I want to show whole pixmap
> using scrolling.
> I somebody can refer me to simple examples, I'll be very much obliged,
This is some example code I wrote for a movie browser. It uses GTK+ and
GdkImlib, but you can put whatever you want within the scrolled window.
Hope this helps,
Erik
#include <gtk/gtk.h>
#include <gdk_imlib.h>
/* just a pixmap with a logo in an XPM file */
extern char *logo_xpm[];
GtkWidget *toplevel;
GtkWidget *vbox;
GdkPixmap *pmap;
GdkBitmap *mask;
GtkWidget *scrolledwindow;
GtkWidget *browserSelectPixmap;
/* create toplevel window */
toplevel = gtk_window_new(GTK_WINDOW_DIALOG);
gtk_window_set_title(GTK_WINDOW(toplevel), "Image browser");
gtk_window_set_wmclass(GTK_WINDOW(toplevel), "browser", "Image browser");
gtk_widget_set_usize(GTK_WIDGET(toplevel), 800, 600);
/* realize this widget so pixmaps can be created using this
* toplevel window
*/
gtk_widget_realize(toplevel);
/* listen to WM_QUIT event */
gtk_signal_connect(GTK_OBJECT(toplevel), "delete_event",
GTK_SIGNAL_FUNC(browser_quit_callback), NULL);
/* create a vbox to put the stuff in */
vbox = gtk_vbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(vbox), 1);
gtk_container_add(GTK_CONTAINER(toplevel), vbox);
gtk_widget_show(vbox);
/* create a scrolled window for viewing files */
scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_show(scrolledwindow);
gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 1);
gdk_imlib_data_to_pixmap(logo_xpm, &pmap, &mask);
browserSelectPixmap = gtk_pixmap_new(pmap, mask);
gdk_imlib_free_pixmap(pmap);
gdk_imlib_free_bitmap(mask);
gtk_widget_show(browserSelectPixmap);
gtk_container_add(GTK_CONTAINER(scrolledwindow), browserSelectPixmap);
/* your code goes here */
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]