GtkBox::pack_start GtkBox::pack_start
void pack_start(GtkWidget child [, bool expand = true [, bool fill = true [, int padding = 0]]]);Adiciona child na caixa começando a partir do início. Se a caixa for um GtkVBox, o child será adicionado a apartir do topo. Se a caixa for um GtkHBox o child será adicionado a partir da esquerda.
O argumento opcional expand, controla quando o widget deverá ou não consumir todo o espaço disponível quando o container e o child forem exibidos. Consumir todo o espaço disponível não quer dizer que child será redimencionado para ocupar o container.
Veja também: pack_end()
Exemplo 16. Os parâmetros expand e fill do GtkBox em ação
Este exemplo demostra os parâmetros expand e fill.
No começo dois GtkLabel são criados e pack_start() em uma caixa, o primeiro espandido e o segundo não expandido.
O lado direito da janela mostra o parâmetro fill: Dois botões são adicionados na caixa, ambos expandidos, mas apenas o primeiro com fill, o segundo ocupa a metade do espaço, mas mantém o tamanho ideal para mostrar todo o texto, enquanto o primeiro ocupa todo o espaço para motrar
<?php //GtkBox expand and fill parameter example /** * Example 1: The "expand" parameter */ $boxExpand = new GtkVBox(); $lblExpand = new GtkLabel('Expand'); $lblNoExpand = new GtkLabel('No expand'); //Add the expanded Label with the //expand parameter set to true $boxExpand->pack_start($lblExpand, true); //to see the difference better $boxExpand->pack_start(new GtkHSeparator(), false, false, 3); //Add the unexpanded label with the //expand parameter set to false $boxExpand->pack_start($lblNoExpand, false); /** * Example 2: The "fill" parameter */ $boxFill = new GtkVBox(); $btnFill = new GtkButton('Fill'); $btnNoFill = new GtkButton('No fill'); //Add the filled button to the box //with the fill parameter set to true $boxFill->pack_start($btnFill, true, true); //to see the difference better $boxFill->pack_start(new GtkHSeparator(), false, false, 3); //Add the unfilled button to the box, //with the filled parameter set to false $boxFill->pack_start($btnNoFill, true, false); /** * Add both of the example boxes to the window */ $wnd = new GtkWindow(); $wnd->set_title('Pack test'); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $wnd->set_size_request(300, 200); //Set the box homogenous, so that left and right //example get the same space $hbox = new GtkHBox(true); //Add the expand example box $hbox->pack_start($boxExpand, true); //Add the fill example box $hbox->pack_start($boxFill, true); //Add the main box to the window $wnd->add($hbox); $wnd->show_all(); Gtk::main(); ?>





