[ruby-gnome2-doc-cvs] [Hiki] update - Gtk::Container

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2004年 8月 7日 (土) 17:18:59 JST


-------------------------
REMOTE_ADDR = 218.45.66.220
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp//?Gtk%3A%3AContainer
-------------------------
  = class Gtk::Container
  Gtk::Container is a abstract base class for widgets which contain other widgets.
  
  A GTK+ user interface is constructed by nesting widgets inside widgets. Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a Gtk::Window containing a Gtk::Frame containing a Gtk::Label. If you wanted an image instead of a textual label inside the frame, you might replace the Gtk::Label widget with a Gtk::Image widget. 
  
  There are two major kinds of container widgets in GTK+. Both are subclasses of the abstract Gtk::Container base class. 
  
  The first type of container widget has a single child widget and derives from Gtk::Bin. These containers are decorators, which add some kind of functionality to the child. For example, a Gtk::Button makes its child into a clickable button; a Gtk::Frame draws a frame around its child and a Gtk::Window places its child widget inside a top-level window. 
  
  The second type of container can have more than one child; its purpose is to manage layout. This means that these containers assign sizes and positions to their children. For example, a Gtk::HBox arranges its children in a horizontal row, and a Gtk::Table arranges the widgets it contains in a two-dimensional grid. 
  
  To fulfill its task, a layout container must negotiate the size requirements with its parent and its children. This negotiation is carried out in two phases, size requisition and size allocation. 
  
  === Size Requisition
  The size requisition of a widget is it's desired width and height. 
  
  How a widget determines its desired size depends on the widget. A Gtk::Label, for example, requests enough space to display all its text. Container widgets generally base their size request on the requisitions of their children. 
  
  The size requisition phase of the widget layout process operates top-down. It starts at a top-level widget, typically a Gtk::Window. The top-level widget asks its child for its size requisition by calling Gtk::Widget#size_request. To determine its requisition, the child asks its own children for their requisitions and so on. Finally, the top-level widget will get a requisition back from its child. 
  
  === Size Allocation
  When the top-level widget has determined how much space its child would like to have, the second phase of the size negotiation, size allocation, begins. Depending on its configuration (see Gtk::Window#resizable=), the top-level widget may be able to expand in order to satisfy the size request or it may have to ignore the size request and keep its fixed size. It then tells its child widget how much space it gets by calling Gtk::Widget#size_allocate. The child widget divides the space among its children and tells each child how much space it got, and so on. Under normal circumstances, a Gtk::Window will always give its child the amount of space the child requested. 
  
  A child's size allocation is represented by a Gtk::Allocation. This struct contains not only a width and height, but also a position (i.e. X and Y coordinates), so that containers can tell their children not only how much space they have gotten, but also where they are positioned inside the space available to the container. 
  
  Widgets are required to honor the size allocation they receive; a size request is only a request, and widgets must be able to cope with any size. 
  
  
  === Child properties
  Gtk::Container introduces child properties - these are object properties that are not specific to either the container or the contained widget, but rather to their relation. Typical examples of child properties are the position or pack-type of a widget which is contained in a Gtk::Box.
  
  Use Gtk::Container.install_child_property to install child properties for a container class and Gtk::Container.child_property or Gtk::Container.child_properties to get information about existing child properties. 
  
  To set the value of a child property, use Gtk::Container#child_set_property. To obtain the value of a child property, use Gtk::Container#child_get_property. To emit notification about child property changes, use Gtk::Widget#child_notify. 
  
  == Object Hierarchy
  * Object
    * GLib::Instantiatable
      * GLib::Object
        * Gtk::Object
          * Gtk::Widget
            * Gtk::Container
  
  == Class Methods
  --- Gtk::Container.child_properties(inherited_too)
      Returns all child properties of a container class.
      * Returns: a newly allocated Array of GLib::Param.
  --- Gtk::Container.child_property(property_name)
      Finds a child property of a container class by name.
      * property_name: the name of the child property to find  
      * Returns: the GLib::Param of the child property or nil if class has no child property with that name.  
  --- Gtk::Container.install_child_property(spec, property_id = 1)
      Installs a child property on a container class.
      * pspec: the GLib::Param for the property  
      * property_id: the id for the property
      * Returns: self
  
  == Instance Methods
  --- resize_container?
      return true If the resize_mode of the container is Gtk::RESIZE_PARENT
      * Returns: true or false
  
- --- add(widget, properties = nil)
+ --- add(widget, child_properties = nil)
      Adds widget to container. Typically used for simple containers such as Gtk::Window, Gtk::Frame, or Gtk::Button; for more complicated layout containers such as Gtk::Box or Gtk::Table, this method will pick default packing parameters that may not be correct. So consider methods such as Gtk::Box#pack_start and Gtk::Table#attach as an alternative to Gtk::Container#add in those cases. A widget may be added to only one container at a time; you can't place the same widget inside two different containers.
      * widget: a Gtk::Widget to be placed inside container
      * child_properties: a hash of child properties({type => value, type2 => value, ...})
      * Returns: self
  
  --- <<(widget)
      Same as add
      * widget: a Gtk::Widget to be placed inside container  
      * Returns: self
  
  --- remove(widget)
      Removes widget from container. widget must be inside container.
      * widget : a current child Gtk::Widget of the container
      * Returns: self
  
  --- resize_mode
      Returns the resize mode which specify how resize events are handled for the container. See Gtk::Container#resize_mode=.
      * Returns:  the current resize mode(((<GtkResizeMode|Gtk#GtkResizeMode>))). 
  --- resize_mode=(resize_mode)
      Sets the resize mode for the container. 
      The resize mode of a container determines whether a resize request will be passed to the container's parent, queued for later execution or executed immediately.
      * resize_mode: the new resize mode(((<GtkResizeMode|Gtk#GtkResizeMode>))). 
      * Returns: resize_mode
  
  --- set_resize_mode(resize_mode)
      Same as resize_mode=.
      * resize_mode: the new resize mode(((<GtkResizeMode|Gtk#GtkResizeMode>))). 
      * Returns: self
  
  --- check_resize
      Emits a "check_resize" signal.
      * Returns: self
  
  --- each {|widget| ... }
      Invokes block on each non-internal child of container. See Gtk::Container#each_forall for details on what constitutes an "internal" child. Most applications should use Gtk::Container#each, rather than Gtk::Container#each_forall.
      * {|widget| ... }: a block
         * widget: non-internal child Gtk::Widget of container
      * Returns: self
  
  --- children
      Returns the the container's non-internal children. See Gtk::Container#each_forall for details on what constitutes an "internal" child.
      * Returns : a newly-allocated list of the container's non-internal children.  
  
  --- reallocate_redraws=(needs_redraws)
      Sets the reallocate_redraws flag of the container to the given value. 
      Containers requesting reallocation redraws get automatically redrawn if any of their children changed allocation.
      * needs_redraws: the new value for the container's reallocate_redraws flag(true or false).  
      * Returns: needs_redraws
  --- set_reallocate_redraws(needs_redraws)
      Same as reallocate_redraws=.
      * needs_redraws: the new value for the container's reallocate_redraws flag(true or false).  
      * Returns: self
  
  --- focus_child=(focus_child)
      Emits a 'set-focus-child' signal and set focus to the focus_child widget.
      * focus_child: child Gtk::Widget to focus.
      * Returns: focus_child
  --- set_focus_child(focus_child)
      Same as focus_child=.
      * focus_child: child Gtk::Widget to focus.
      * Returns: self
  
  --- focus_vadjustment
      Retrieves the vertical focus adjustment for the container. See Gtk::Container#focus_vadjustment=.
      * Returns: the vertical focus adjustment(Gtk::Adjustment), or nil if none has been set.  
  --- focus_vadjustment=(adjustment)
      Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This method sets the vertical alignment. See Gtk::ScrolledWindow#vadjustment for a typical way of obtaining the adjustment and Gtk::Container#focus_hadjustment= for setting the horizontal adjustment. 
      The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
      * adjustment: a Gtk::Adjustment which should be adjusted when the focus is moved among the descendents of container
      * Returns: adjustment
  --- set_focus_vadjustment(adjustment)
      Same as focus_vadjustment=.
      * adjustment: a Gtk::Adjustment which should be adjusted when the focus is moved among the descendents of container
      * Returns: self
  
  --- focus_hadjustment
      Retrieves the horizontal focus adjustment for the container. See Gtk::Container#focus_hadjustment=.
      * Returns: the horizontal focus adjustment(Gtk::Adjustment), or nil if none has been set.  
  --- focus_hadjustment=(adjustment)
      Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This method sets the horizontal alignment. See Gtk::ScrolledWindow#hadjustment for a typical way of obtaining the adjustment and Gtk::Container#focus_vadjustment= for setting the vertical adjustment. 
      The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
      * adjustment: a Gtk::Adjustment which should be adjusted when the focus is moved among the descendents of container  
      * Returns: adjustment
  --- set_focus_hadjustment(adjustment)
      Same as focus_hadjustment=.
      * adjustment: a Gtk::Adjustment which should be adjusted when the focus is moved among the descendents of container 
      * Returns: self
  
  --- resize_children
      Resize children. This method is same as Gtk::Widget#size_alocate.
      * Returns: self
  
  --- child_type
      Returns the class of the children supported by the container. 
      Note that this may return nil to indicate that no more children can be added, e.g. for a Gtk::Paned which already has two children.
      * Returns : a Class
  
  --- child_get_property(child, property_name)
      Gets the value of a child property for child and container.
      * child: a Gtk::Widget which is a child of container  
      * property_name: the name of the property to get  
      * Returns: the value of the propery 
  --- child_set_property(child, property_name, value)
      Sets a child property for child and container.
      * child: a widget which is a child of container 
      * property_name: the name of the property to set
      * value: the value to set the property to
      * Returns: self
  
  --- each_forall {|widget| ... }
      Invokes block on each child of container, including children that are considered "internal" (implementation details of the container). "Internal" children generally weren't added by the user of the container, but were added by the container implementation itself. Most applications should use Gtk::Container#foreach, rather than Gtk::Container#each_forall.
      * {|widget| ... }: a block
         * widget: non-internal child Gtk::Widget of container
      * Returns: self
  
  --- border_width
      Retrieves the border width of the container.
      * Returns: the current border width
  --- border_width=(border_width)
      Sets the border width of the container. 
      The border width of a container is the amount of space to leave around the outside of the container. The only exception to this is Gtk::Window; because toplevel windows can't leave space outside, they leave the space inside. The border is added on all sides of the container. To add space to only one side, one approach is to create a Gtk::Alignment widget, call Gtk::Widget#set_size_request to give it a size, and place it on the side of the container as a spacer.
      * border_width: amount of blank space to leave outside the container. Valid values are in the range 0-65535 pixels.  
      * Returns: border_width
  --- set_border_width(border_width)
      Same as border_width=.
      * border_width: amount of blank space to leave outside the container. Valid values are in the range 0-65535 pixels.  
      * Returns: self
  
  --- propagate_expose(child, event)
      When a container receives an expose event, it must send synthetic expose events to all children that don't have their own Gdk::Window s. This method provides a convenient way of doing this. A container, when it receives an expose event, calls Gtk::Container#propagate_expose once for each child, passing in the event the container received. 
      this method takes care of deciding whether an expose event needs to be sent to the child, intersecting the event's area with the child area, and sending the event. 
      In most cases, a container can simply either simply inherit the ::expose implementation from Gtk::Container, or, do some drawing and then chain to the ::expose implementation from Gtk::Container.
      * child: a child of container  
      * event: a Gdk::EventExpose sent to container
      * Returns: self
  
  --- focus_chain
      Retrieves the focus chain of the container, if one has been set explicitly. If no focus chain has been explicitly set, GTK+ computes the focus chain based on the positions of the children. In that case, Ruby/GTK returns nil.
      * Returns: the focus chain of the container, or nil.
  
  --- focus_chain=(focusable_widgets)
      Sets a focus chain, overriding the one computed automatically by GTK+. 
      In principle each widget in the chain should be a descendant of the container, but this is not enforced by this method, since it's allowed to set the focus chain before you pack the widgets, or have a widget in the chain that isn't always packed. The necessary checks are done when the focus chain is actually traversed.
      * focusable_widgets: an Array of ((<Gtk::Widget>))s which is the new focus chain.  
      * Returns: focusable_widgets
  --- set_focus_chain(focusable_widgets)
      Same as focus_chain=.
      * focusable_widgets: an Array of ((<Gtk::Widget>))s which is the new focus chain.  
      * Returns: self
  --- unset_focus_chain
      Removes a focus chain explicitly set with Gtk::Container#focus_chain=.
      * Returns: self
  
  
  --- child=(child)
      Sets the Can be used to add a new child to the container.
      * child: Can be used to add a new child to the container
      * Returns: child
  --- set_child(child)
      Same as child=.
      * child: Can be used to add a new child to the container
      * Returns: self
  
  == Properties
  --- border-width: Integer (Read/Write)
      The width of the empty border outside the containers children
  
  --- child: Gtk::Widget (Write)
      Can be used to add a new child to the container
  
  --- resize-mode: ((<GtkResizeMode|Gtk#GtkResizeMode>)) (Read/Write)
      Specify how resize events are handled
  
  == Signals
  --- add: self, widget
       * self: Gtk::Container
       * widget: Gtk::Widget
  --- check-resize: self
       * self: Gtk::Container
  --- remove: self, widget
       * self: Gtk::Container
       * widget: Gtk::Widget
  --- set-focus-child: self, widget
       * self: Gtk::Container
       * widget: Gtk::Widget
  
  
  - ((<Masao>))





ruby-gnome2-cvs メーリングリストの案内
Zurück zum Archiv-Index