GtkPaned

only for RuBoard - do not distribute or recompile

GtkPaned

The GtkPaned widget allows the developer to split the desired space in two, either horizontally or vertically (see Figure 4.7). You split the space in half, but if you want thirds instead, you must then split one of the halves in half again (and again, and so on). The paned widget has a sizing handle that allows the user to grab and move the location of the pane, resizing the widgets in the two halves (if the options have been set correctly).

Figure 4.7. The GtkPaned widgets demo program running.
graphics/04fig07.gif

Finally, this chapter concludes with a demonstration of the Paned Widget demo ”in Listing 4.7 and Figure 4.7. In Figure 4.7, notice the different sizes of the resizing handles and that one is cut off in its display. Such things can be handled by setting the spacing of your child widgets. If you do this, however, you must allow enough of a buffer that your child widgets don t display over things like sizing handles.

Listing 4.7 GtkPaned Demo
 #include <gtk/gtk.h>  GtkWidget *frm_paned;  void destroy_main();  gint main(gint argc, gchar *argv[])  {    GtkWidget *lbl_hpaned1_left;     GtkWidget *lbl_vpaned1_top;     GtkWidget *lbl_hpaned2_left;     GtkWidget *lbl_vpaned2_top;     GtkWidget *lbl_vpaned2_bottom;     GtkWidget *hpaned1;     GtkWidget *vpaned1;     GtkWidget *hpaned2;     GtkWidget *vpaned2;     gtk_init(&argc, &argv);     frm_paned = gtk_window_new(GTK_WINDOW_TOPLEVEL);     gtk_window_set_title(GTK_WINDOW(frm_paned), "Paned Window Demo");     gtk_signal_connect(GTK_OBJECT(frm_paned),          "destroy",          GTK_SIGNAL_FUNC(destroy_main),          NULL);     hpaned1 = gtk_hpaned_new();     gtk_paned_gutter_size(GTK_PANED(hpaned1), 20);     gtk_paned_handle_size(GTK_PANED(hpaned1), 20);     lbl_hpaned1_left = gtk_label_new("hpaned1 left\nResize TRUE\nShrink TRUE");       gtk_paned_pack1(GTK_PANED(hpaned1), lbl_hpaned1_left, TRUE, TRUE);  /* The  gtk_paned_gutter_size()  call sets the width between   * the pane and the widgets next to it. As you can see,   * a little space improves the aesthetics of the UI considerably.   *   * The  gtk_paned_handle_size()  call sets the box that the user   * grabs with the mouse to resize the pane.   *   * The  gtk_paned_pack1()  call packs another widget into either the   * left side of a horizontal paned widget or the top side of   * a vertical pane. The  gtk_paned_pack2()  call (see the code below)   * is inserted to the right or bottom of an hpaned or vpaned,   * respectively.   *   * The parameters for  gtk_paned_pack*()  are listed here:   * ?  pane  the target pane of the call   * ?  child  the child widget to place left/right or top/bottom   * ?  resize  if true, the child widget will resize to fit its   *           new window proportionally when the window is resized   * ?  shrink  if false, will not allow the pane to be resized   *           smaller than the child widget   */  vpaned1 = gtk_vpaned_new();     gtk_paned_gutter_size(GTK_PANED(vpaned1), 20);     lbl_vpaned1_top = gtk_label_new("vpaned1 top\nResize TRUE\nShrink FALSE");     gtk_paned_pack2(GTK_PANED(hpaned1), vpaned1, TRUE, FALSE);     gtk_paned_pack1(GTK_PANED(vpaned1), lbl_vpaned1_top, TRUE, FALSE);     hpaned2 = gtk_hpaned_new();     gtk_paned_handle_size(GTK_PANED(hpaned2), 20);     lbl_hpaned2_left = gtk_label_new("hpaned2 left\nResize FALSE\nShrink TRUE");     gtk_paned_pack2(GTK_PANED(vpaned1), hpaned2, FALSE, TRUE);     gtk_paned_pack1(GTK_PANED(hpaned2), lbl_hpaned2_left, FALSE, TRUE);     vpaned2 = gtk_vpaned_new();     gtk_paned_gutter_size(GTK_PANED(vpaned2), 5);     gtk_paned_handle_size(GTK_PANED(vpaned2), 5);     lbl_vpaned2_top = gtk_label_new("vpaned2 top\nResize FALSE\nShrink FALSE");     lbl_vpaned2_bottom = gtk_label_new("vpaned2 bottom");     gtk_paned_pack2(GTK_PANED(hpaned2), vpaned2, FALSE, FALSE);     gtk_paned_pack1(GTK_PANED(vpaned2), lbl_vpaned2_top, FALSE, FALSE);     gtk_paned_pack2(GTK_PANED(vpaned2), lbl_vpaned2_bottom, FALSE, FALSE);     gtk_container_add(GTK_CONTAINER(frm_paned), hpaned1);     gtk_widget_show_all (frm_paned);     gtk_main ();     return 0;  }  void destroy_main()  {   gtk_main_quit();  } 
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