新規作成  編集  Ruby-GNOME2 Project Website  ページ一覧  検索  更新履歴  編集履歴  RSS  ログイン

Gtk::Box

Gtk::Box クラス

Ruby/GTK2

Gtk::Box is an abstract widget which encapsulates functionallity for a particular kind of container, one that organizes a variable number of widgets into a rectangular area.

The rectangular area of a Gtk::Box is organized into either a single row or a single column of child widgets depending upon whether the box is of type Gtk::HBox or Gtk::VBox, respectively. Thus, all children of a Gtk::Box are allocated one dimension in common, which is the height of a row, or the width of a column.

Gtk::Box uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Gtk::Container. For a Gtk::Box, there are two reference positions: the start and the end of the box. For a Gtk::VBox, the start is defined as the top of the box and the end is defined as the bottom. For a Gtk::HBox the start is defined as the left side and the end is defined as the right side.

Use repeated calls to Gtk::Box#pack_start to pack widgets into a Gtk::Box from start to end. Use Gtk::Box#pack_end to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the same Gtk::Box.

Use Gtk::Box#pack_start_defaults or Gtk::Box#pack_end_defaults to pack widgets into a Gtk::Box if you do not need to specify the expand, fill, or padding attributes of the child to be added.

Because Gtk::Box is a Gtk::Container, you may also use Gtk::Container#add to insert widgets into the box, and they will be packed as if with Gtk::Box#pack_start_defaults. Use Gtk::Container#remove() to remove widgets from the Gtk::Box.

Use Gtk::Box#homogeneous= to specify whether or not all children of the Gtk::Box are forced to get the same amount of space.

Use Gtk::Box#spacing= to determine how much space will be minimally placed between all children in the Gtk::Box.

Use Gtk::Box#reorder_child to move a Gtk::Box child to a different place in the box.

Use Gtk::Box#set_child_packing to reset the expand, fill, and padding attributes of any Gtk::Box child. Use Gtk::Box#query_child_packing to query these fields.

Ruby/GTK3

要編集

インクルードされているモジュール

  • Gtk::Buildable?
  • Atk::Implementor
  • GLib::Interface?
  • Gtk::Orientable? Ruby/GTK3

クラスメソッド

Gtk::Box.new(orientation, spacing)

Ruby/GTK3 only

新しくGtk::Boxオブジェクトを作成します。

  • orientation: 子ウィジェットを並べる方向。Gtk::Orientation::HORIZONTAL?(:horizontal)もしくはGtk::Orientation::VERTICAL?(:vertical)を指定する。
  • spacing: 子ウィジェット同士のデフォルトの間隔(ピクセル)
  • 戻り値: Gtk::Boxオブジェクト

インスタンスメソッド

pack_start(child, expand = true, fill = true, padding = 0)
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.
  • child: the Gtk::Widget 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 Gtk::HBox and the full width of a Gtk::VBox. 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 in Gtk::Box. 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.
  • Returns: self
pack_end(child, expand = true, fill = true, padding = 0)
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.
  • child: the Gtk::Widget 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: fill 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 Gtk::HBox and the full width of a Gtk::VBox. 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 in Gtk::Box. 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.
  • Returns: self
pack_start_defaults(widget)
Adds widget 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. Parameters for how to pack the child widget, expand, fill, and padding, are given their default values, true, true, and 0, respectively.
  • widget: the Gtk::Widget to be added to box.
  • Returns: self
pack_end_defaults(widget)
Adds widget 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. Parameters for how to pack the child widget, expand, fill, and padding, are given their default values, true, true, and 0, respectively.
  • widget: the Gtk::Widget to be added to box.
  • Returns: self
homogeneous?
Returns whether the box is homogeneous (all children are the same size).
  • Returns: true to create equal allotments, false for variable allotments.
homogeneous=(homogeneous)
Sets the homogeneous field of Gtk::Box, controlling whether or not all children of box are given equal space in the box.
  • homogeneous: true to create equal allotments, false for variable allotments.
  • Returns: homogeneous
set_homogeneous(homogeneous)
Same as Gtk::Box#homogeneous=.
  • homogeneous: true to create equal allotments, false for variable allotments.
  • Returns: self.
spacing
Returns the spacing.
  • Returns: spacing between children
spacing=(spacing)
Sets the spacing field of Gtk::Box, which is the number of pixels to place between children of box.
  • spacing: the number of pixels to put between children.
  • Returns: spacing
set_spacing(spacing)
Same as Gtk::Box#spacing=.
  • spacing: the number of pixels to put between children.
  • Returns: self
reorder_child(child, position)
Moves child to a new position in the list of box children. The list is the children field of Gtk::Box, and contains both widgets packed Gtk::PACK_START as well as widgets packed Gtk::PACK_END, in the order that these widgets were added to box. A widget's position in the box children list determines where the widget is packed into box. A child widget at some position in the list will be packed just after all other widgets of the same packing type that appear earlier in the list.
  • child: the Gtk::Widget to move.
  • position: the new position for child in the children list of Gtk::Box, starting from 0. If negative, indicates the end of the list.
  • Returns: self
query_child_packing(child)
Returns information about how child is packed into box.
  • Returns: [expand, fill, padding, pack_type]
set_child_packing(child, expand, fill, padding, pack_type)
Sets the way child is packed into box.
  • child: the Gtk::Widget of the child to set.
  • expand: the new value of the expand field.
  • fill: the new value of the fill field.
  • padding: the new value of the padding field.
  • pack_type: the new value of the pack.
baseline_position()

Ruby/GTK3 only

要編集

baseline_position=()

Ruby/GTK3 only

要編集

set_baseline_position()

Ruby/GTK3 only

要編集

プロパティ

homogeneous: true or false (Read/Write)
Whether the children should all be the same size
spacing: Integer (Read/Write)
The amount of space between children
baseline-position:

Ruby/GTK3 only

要編集

関連ページ

更新履歴

  • 2014-09-08 Ruby/GTK3関連の情報を追加。 - きたがわ
  • 2014-06-15 インクルードされているモジュールの項目を追加。 - きたがわ
  • - Masao?