Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

Scroll Region

The canvas is practically infinite from a programmer's standpoint; however, in reality your application probably uses only a small area. When using the canvas you must specify which region is interesting to the user with gnome_canvas_set_scroll_region() (Figure 6). The scroll region is given in world coordinates. You can query the scroll region with gnome_canvas_get_scroll_region().

To add scroll bars to the canvas, simply create a GtkScrolledWindow and add the canvas to it:


  GtkWidget* sw;
  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(sw), canvas);

    

If you want to implement scrolling via some mechanism other than the scroll bars, you can get and set the "scroll offsets." The scroll offsets are in canvas pixel coordinates; they specify the top left visible pixel. Remember that canvas pixel coordinates are relative to the scroll region.

         #include <libgnomeui/gnome-canvas.h>
        

void gnome_canvas_set_scroll_region(GnomeCanvas* canvas, double x1, double y1, double x2, double y2);

void gnome_canvas_get_scroll_region(GnomeCanvas* canvas, double* x1, double* y1, double* x2, double* y2);

void gnome_canvas_scroll_to(GnomeCanvas* canvas, gint cx, gint cy);

void gnome_canvas_get_scroll_offsets(GnomeCanvas* canvas, gint* cx, gint* cy);

Figure 6. Canvas Scrolling

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire