GtkScrolledWindow

only for RuBoard - do not distribute or recompile

GtkScrolledWindow

The GtkScrolledWindow widget is a container widget that allows you to implement scroll bars on widgets that don t have them already integrated. This of course allows you to have multiple windows in your application and have the user scroll within each of those windows to view the widgets as needed. If you haven t guessed by now, Figure 4.5 is a screen shot of Listing 4.5

Figure 4.5. The GtkScrolledWindow demo program running.
graphics/04fig05.gif

The scrolled window demo (Listing 4.5 and Figure 4.5) is a variation on the theme used in Listing 4.3 and 4.4. In this case, there are two command buttons for setting the relevant properties. Note that the policies do not always have to be the same for the horizontal and vertical scroll bars; you can mix the always setting with the automatic setting. In Listing, 4.5, however, I have set both to the same setting instead of mixing them.

Listing 4.5 GtkScrolledWindow Demo
 #include <gtk/gtk.h>  GtkWidget *frm_scrolled;  GtkWidget *scrolled_main;  GtkWidget *fixed_main;  GtkWidget *cmd_set_policy_auto, *cmd_set_policy_always;  void destroy_main();  void cmd_set_policy_auto_clicked();  void cmd_set_policy_always_clicked();  gint main(gint argc, gchar *argv[])  {    gtk_init(&argc, &argv);     frm_scrolled = gtk_window_new(GTK_WINDOW_TOPLEVEL);     gtk_window_set_title(GTK_WINDOW(frm_scrolled), "Scrolled Window Demo");  /* Notice that because you are not giving the window any   * default sizing information, it will come up very small.   * You will need to resize it to show the two command   * buttons below and demonstrate the scroll button   * policies they demonstrate.   */  gtk_signal_connect(GTK_OBJECT(frm_scrolled),          "destroy",          GTK_SIGNAL_FUNC(destroy_main),          NULL);     scrolled_main = gtk_scrolled_window_new(NULL, NULL);     fixed_main = gtk_fixed_new();     cmd_set_policy_auto = gtk_button_new_with_label("Set Policy Auto");     gtk_signal_connect(GTK_OBJECT(cmd_set_policy_auto),          "clicked",          GTK_SIGNAL_FUNC(cmd_set_policy_auto_clicked),          NULL);     cmd_set_policy_always = gtk_button_new_with_label("Set Policy Always");     gtk_signal_connect(GTK_OBJECT(cmd_set_policy_always),            "clicked",          GTK_SIGNAL_FUNC(cmd_set_policy_always_clicked),          NULL);     gtk_fixed_put(GTK_FIXED(fixed_main), cmd_set_policy_auto, 200, 200);     gtk_fixed_put(GTK_FIXED(fixed_main), cmd_set_policy_always, 50, 75);     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_main),  fixed_main);     gtk_container_add(GTK_CONTAINER(frm_scrolled), scrolled_main);     gtk_widget_show_all (frm_scrolled);     gtk_main ();     return 0;  }  void destroy_main()  {    gtk_main_quit();  }  void cmd_set_policy_auto_clicked()  {     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_main),                                     GTK_POLICY_AUTOMATIC,                                     GTK_POLICY_AUTOMATIC);  }  void cmd_set_policy_always_clicked()  {  /* This is the default behavior for the widget.   */  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_main),                                     GTK_POLICY_ALWAYS,                                     GTK_POLICY_ALWAYS);  } 
only for RuBoard - do not distribute or recompile


MySQL Building User Interfaces
MySQL: Building User Interfaces (Landmark)
ISBN: 073571049X
EAN: 2147483647
Year: 2001
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net