Помогите с gtk2 (pack_start)

Модератор: Модераторы разделов

apl
Сообщения: 1

Помогите с gtk2 (pack_start)

Сообщение apl »

Я только начинаю изучать Gtk2... пока пишу на перле, т.к. сейчас знаю неплохо его, а на остальных давно не писал...

Подскажите плиз...

1. Что делает ф-ция pack_start. Пакует объекты в контейнер? А чем она от pack_end отличается?
2. Какие параметры у нее? Как ее использовать

Гуглил, но описание не нашел... в лучшем случае примеры без каментов
Спасибо сказали:
mrcashe
Сообщения: 18

Re: Помогите с gtk2 (pack_start)

Сообщение mrcashe »

apl писал(а):
19.02.2010 16:26
1. Что делает ф-ция pack_start. Пакует объекты в контейнер? А чем она от pack_end отличается?
2. Какие параметры у нее? Как ее использовать

Не владею Перлом, но, в целом, Вы правы: они пакуют виджеты в контейнер. Поэтому первым аргументом должен быть виджет. Далее идут опции упаковки. Это важные опции, так как от них зависит, какой будет внешний вид у упакованных виджетов.

Для C прототип такой:

Код: Выделить всё

void gtk_box_pack_start(GtkBox *box, GtkWidget *child,
                                   gboolean expand, gboolean fill, guint padding);
 Adds child to box, packed with reference to the start of box. The child is packed after any other child packed with reference to the start of box.
box :
   a GtkBox
  child :
   the GtkWidget to be added to box
  expand :
  TRUE if the new child is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option
  fill :
  TRUE if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set to FALSE. A child is always allocated the full height of a GtkHBox and the full width of a GtkVBox. This option affects the other dimension
  padding :
   extra space in pixels to put between this child and its neighbors, over and above the global amount specified by "spacing" property. If child is a widget at one of the reference ends of box, then padding pixels are also put between child and the reference edge of box


Код: Выделить всё

void gtk_box_pack_end(GtkBox *box,
                                 GtkWidget *child,
                                 gboolean expand,
                                 gboolean fill,
                                 guint padding);
 Adds child to box, packed with reference to the end of box. The child is packed after (away from end of) any other child packed with reference to the end of box.
box :
   a GtkBox
  child :
   the GtkWidget to be added to box
  expand :
  TRUE if the new child is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option
  fill :
  TRUE if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set to FALSE. A child is always allocated the full height of a GtkHBox and the full width of a GtkVBox. This option affects the other dimension
  padding :
   extra space in pixels to put between this child and its neighbors, over and above the global amount specified by "spacing" property. If child is a widget at one of the reference ends of box, then padding pixels are also put between child and the reference edge of box


Для C++

Код: Выделить всё

void   pack_start (Widget& child, PackOptions options=PACK_EXPAND_WIDGET, guint padding=0)
     Left side insert a widget to a box.


Код: Выделить всё

void   pack_start (Widget& child, bool expand, bool fill, guint padding=0)
     Left side insert a widget to a box.


Код: Выделить всё

void   pack_end (Widget& child, PackOptions options=PACK_EXPAND_WIDGET, guint padding=0)
     Right side insert a widget to a box.


Код: Выделить всё

void   pack_end (Widget& child, bool expand, bool fill, guint padding=0)
     Adds child to box , packed with reference to the end of box .


В общем, pack_start() пакует слева или сверху, а pack_end() - справа или снизу, в зависимости от того, в какой контейнер его вставляют: в горизонтальный (GtkHBox) или в вертикальный (GtkVBox). Какой прототип использован в Perl, ХЗ, но лучшим подспорьем может послужить описание gtk+ на gnome.org, пусть даже для языка C. К сожалению, степень документированности этой библиотеки не столь высока, как хотелось бы.
Спасибо сказали: