|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Aligning a fixed size panelHow do i create a frame 200x200 and make it stay centered in the app so even if the window is resized the frame stays 200x200 and stays in the center?? All the Vbox and Hbox stuff is confusing me
|
|
|
|
|
|
Re: Aligning a fixed size panelanother thing that just occured to me (i am not even suppose to be awake
at this hour) is a gtkalignment. $widget->set_size_request(200,200); $align = new GtkAlignment(0.5,0.5,0,0); $align->add($widget); somethingelse add or pack_start($align); - bob bob majdak jr wrote: > [forwarding it to the list this time. grr at incorrect reply-to headers.] > > you would probably want an hbox in a vbox in the window. off the top of > my head i think that would produce the requested result. > > $widget->set_size_request(200,200); > $hbox->pack_start($widget,true,false,0); > $vbox->pack_start($hbox,true,false,0); > $window->add($vbox); > > pack_start and pack_end work like so > > pack_start( > the widget to pack, > boolean of to take up all available area. "fill". > boolean of if to stretch contents to fill it. "expand". > number of pixels to padd between widgets. > ); > > - bob. > > > Adz07 wrote: >> How do i create a frame 200x200 and make it stay centered in the app >> so even >> if the window is resized the frame stays 200x200 and stays in the >> center?? >> All the Vbox and Hbox stuff is confusing me > -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Aligning a fixed size panelHere's the sample code: <?php $window = new GtkWindow(); $window->set_size_request(400, 300); $window->connect_simple('destroy', array('Gtk','main_quit')); $vbox2 = new GtkVBox(); // note 1 $vbox2->pack_start(new GtkLabel("This frame of size 200x200")); $vbox2->pack_start(new GtkLabel("will always stay stay centered")); $vbox2->pack_start(new GtkLabel("no matter how you resize the app")); $eventbox = new GtkEventBox(); // note 2 $eventbox->add($vbox2); $eventbox->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse("#CCFF99")); $frame_200_200 = new GtkFrame(); // note 3 $frame_200_200->set_size_request(200, 200); $frame_200_200->add($eventbox); $hbox = new GtkHBox(); // note 4 $hbox->pack_start(new GtkHBox()); $hbox->pack_start($frame_200_200, 0); $hbox->pack_start(new GtkHBox()); $vbox = new GtkVBox(); // note 5 $vbox->pack_start(new GtkHBox()); $vbox->pack_start($hbox, 0); $vbox->pack_start(new GtkHBox()); $window->add($vbox); // note 6 $window->show_all(); Gtk::main(); ?> Size and positioning in php-gtk2 is just like playing with lego building blocks. By combining various hboxes and vboxes, with appropriate use of the expand and fill parameters, you can achieve precise positioning and sizing of all widgets in PHP-GTK2. More explanations here: http://www.kksou.com/php-gtk2/articles/make-a-200x200-frame-always-centered-no-matter-how-you-resize-the-app-window.php Regards, /kksou p.s. There's another similar example at: http://www.kksou.com/php-gtk2/articles/change-tab-order---Example-4.php It also uses plain vbox's and hbox's to arrange the 12 buttons in a monopoly-like manner. |
| Free embeddable forum powered by Nabble | Forum Help |