Re: [gtk-list] scrollbars

On Tue, 26 Jan 1999 23:46:11 +0300 (MSK), (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,

#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 

  /* 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);

  /* create a scrolled window for viewing files */
  scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  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);
  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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]