Re: Urgent regarding resizing of boxs



Hi Nisha,

attached is a small sample program that essentially reproduces the problem. I marked the line which you need to change.

Hope this helps.

And please, for further questions of this kind, reduce the problematic code to the bare minimum and/or send something that compiles!

Here are some guidelines from the top of my head that would help reviewing your code:

a) Unless your problem can be described by less than say 10 lines of code, send something that can be compiled and linked.

b) Remove ALL unnecessary complexity.
For instance in the code you sent, there is a loop for 6 databoxes and 6 seperators. One box would have been enough. Since you sent the mail to non-gtkdatabox-users, too, you should have considered replacing the gtkdatabox widget by a standard widget. You also call factory functions, make_box, labelBoxFunc, and gtk_databox_create_box_with_scrollbars_and_rulers. Users of GtkDatabox don't know two of those, others don't know all three.

d) Use variables with intuitive names.
You are using box_main, HBox_main, hbox1, hbox2, hbox3, vbox1, vbox2, vbox3 as containers which are used in a counterintuitive order (for my brain). Its too many of them and their names do not tell enough of their purpose. Before sending code for inspection by others, review it for ease of understanding.


These guidelines are certainly neither perfect nor complete, but please try to stick to them!

If you do,

*) many of your problems will be solved by yourself during the preparation of the question

*) questions are more likely to be answered quickly

*) the quality of your code will increase


Since this is the 10th or so question about packing widgets, you might also want to take a look at a tutorial for this topic, e.g.
http://library.gnome.org/devel/gtk-tutorial/stable/c355.html

Regards,

Roland


nisha jain wrote:
Hi All,
I am facing a problem in gtk hbox and vbox widgets and i have to resolve this issue as soon as possible.
Please let me know if any one has some inputs--
I am having following code to make a GUI for my application and I need to resize my windows to utilize all space i don't want any gaps inbetween the hboxs and vboxs but these is lots of space wasting.
--
I am using following code.. I attached the figure where i am getting lot of space between databoxs which are
packed into a hboxwidget
so basically i did following vbox
___________________
|      hbox            hbox|
|                                |
|        hbox                 |
|__________________ |
and inside each hbox couple of vboxes are combined.....

#include <gtk/gtk.h>
#include <gtkdatabox.h>

static void
create (void)
{
   GtkWidget *window;
   GtkWidget *vBoxRoot;
   GtkWidget *hBoxTop;
   GtkWidget *hBoxTopLeft;
   GtkWidget *hBoxTopRight;
   GtkWidget *hBoxBottom;
   GtkWidget *databox;
   GtkWidget *labelButton;
   GtkWidget *button;
   GdkColor color;

   /* The window */
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_size_request (window, 500, 500);
   g_signal_connect (GTK_OBJECT (window), "destroy",
		     G_CALLBACK (gtk_main_quit), NULL);
   gtk_container_set_border_width (GTK_CONTAINER (window), 0);

   /* The boxes */
   vBoxRoot = gtk_vbox_new (FALSE, 0);
   hBoxTop = gtk_hbox_new (FALSE, 0);
   hBoxBottom = gtk_hbox_new (FALSE, 0);
   hBoxTopLeft = gtk_hbox_new (FALSE, 0);
   hBoxTopRight = gtk_hbox_new (FALSE, 0);

   /* Packing the boxes */
   gtk_container_add (GTK_CONTAINER (window), vBoxRoot);

   gtk_box_pack_start (GTK_BOX(vBoxRoot), hBoxTop, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX(vBoxRoot), hBoxBottom, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(hBoxTop), hBoxTopLeft, TRUE, TRUE, 0);
   /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
   /* Change to FALSE, FALSE in the next line */
   /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
   gtk_box_pack_start (GTK_BOX(hBoxTop), hBoxTopRight, TRUE, TRUE, 0);

   /* Adding databox widget in top left position */
   databox = gtk_databox_new(); /* If you don't want scrollbars or rulers, you can use the normal constructor */
   color.red = 16383;
   color.green = 16383;
   color.blue = 16383;
   gtk_widget_modify_bg (databox, GTK_STATE_NORMAL, &color);
   gtk_box_pack_start (GTK_BOX (hBoxTopLeft), databox, TRUE, TRUE, 0);

   /* Adding a label to top right position */
   labelButton = gtk_button_new_with_label ("Some text");
   gtk_box_pack_end (GTK_BOX (hBoxTopRight), labelButton, FALSE, FALSE, 0);

   /* Adding friendly Quit-Button to bottom position */
   button = gtk_button_new_with_label ("Quit");
   gtk_box_pack_start (GTK_BOX (hBoxBottom), button, TRUE, TRUE, 0);
   g_signal_connect (GTK_OBJECT (button), "clicked",
                     G_CALLBACK (gtk_main_quit), GTK_OBJECT (window));

   gtk_widget_show_all (window);
}

gint
main (gint argc, char *argv[])
{
   gtk_init (&argc, &argv);

   create ();
   gtk_main ();

   return 0;
}


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