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

Back to archive index

ruby-****@lists***** ruby-****@lists*****
2003年 4月 2日 (水) 11:10:10 JST


-------------------------
REMOTE_ADDR = 61.204.181.66
REMOTE_HOST = 
-------------------------
= class Gtk::Image
The GtkImage widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a Gdk::Pixbuf ("pixel buffer") from a file, and then display that. There's a convenience function to do this, Gtk::Image.new, used as follows: 

  image = Gtk::Image.new("myfile.png")

If the file isn't loaded successfully, the image will contain a "broken image" icon similar to that used in many web browsers. If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with Gdk::Pixbuf.new, then create the Gtk::Image with Gtk::Image.new(Gdk::Pixbuf). 

The image file may contain an animation, if so the Gtk::Image will display an animation (Gdk::PixbufAnimation) instead of a static image. 

Gtk::Image is a subclass of Gtk::Misc, which implies that you can align it (center, left, right) and add padding to it, using Gtk::Misc methods. 

Gtk::Image is a "no window" widget (has no Gdk::Window of its own), so by default does not receive events. If you want to receive events on the image, such as button clicks, place the image inside a Gtk::EventBox, then connect to the event signals on the event box. 

((*Example 2. Handling button press events on a Gtk::Image.*))

    image = Gtk::Image.new("myfile.png")
    event_box = Gtk::EventBox.new.add(image)
    event_box.signal_connect("button_press_event") do
      puts "Clicked."
    end

When handling events on the event box, keep in mind that coordinates in the image may be different from event box coordinates due to the alignment and padding settings on the image (see Gtk::Misc). The simplest way to solve this is to set the alignment to 0.0 (left/top), and set the padding to zero. Then the origin of the image will be the same as the origin of the event box. 

== super class
* Gtk::Misc

== class methods
--- Gtk::Image.new(value = nil)
    Creates a new Gtk::Image.
    * value
       * nil - Create a new empty Gtk::Image.
       * filename(String) - Creates a new Gtk::Image displaying the file filename. If the file isn't found or can't be loaded, the resulting Gtk::Image will display a "broken image" icon. This function never returns nil, it always returns a valid Gtk::Image widget. If the file contains an animation, the image will contain an animation. If you need to detect failures to load the file, use Gdk::Pixbuf.new(filename) to load the file yourself, then create the Gtk::Image from the pixbuf. (Or for animations, use Gdk::PixbufAnimation.new(filenam. The storage type (Gtk::Image#storage_type) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
       * Gdk::Pixbuf - Create a new Gtk::Image from Gdk::Pixbuf. This function just creates an Gtk::Image. The Gtk::Image created will not react to state changes. Should you want that, you should use Gtk::IconSet.
       * Gdk::PixbufAnimation - Creates a Gtk::Image displaying the given animation. The Gtk::Image does not assume a reference to the animation; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.

--- Gtk::Image.new(stock_id, size)
    Creates a Gtk::Image displaying a stock icon. Sample stock icon names are Gtk::Stock::OPEN, Gtk::Stock::EXIT. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. If the stock icon name isn't known, a "broken image" icon will be displayed instead. You can register your own stock icon names, see Gtk::IconFactory#add_default and Gtk::IconFactory#add.
    * stock_id: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    
--- Gtk::Image.new(image, mask)
    Creates a Gtk::Image widget displaying a image with a mask. A Gdk::Image is a client-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the image or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * image: image (Gdk::Image).
    * mask: mask (Gdk::Pixmap(depth = 1)

--- Gtk::Image.new(pixmap, mask)
    Creates a Gtk::Image widget displaying pixmap with a mask. A Gdk::Image is a server-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the pixmap or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * pixmap: pixmap (Gdk::Pixmap).
    * mask: mask (Gdk::Pixmap(depth = 1)

--- Gtk::Image.new(iconset, size)
    Creates a Gtk::Image displaying an icon set. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. Instead of using this method, usually it's better to create a Gtk::IconFactory, put your icon sets in the icon factory, add the icon factory to the list of default factories with Gtk::IconFactory#add_default, and then use Gtk::Image.new(stock_id, size). This will allow themes to override the icon you ship with your application. 
    The Gtk::Image does not assume a reference to the icon set; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * iconset: stock icon (constants of Gtk::Stock)
    * size: size (GtkIconSize - the constants of Gtk::IconSize)

== public instance methods
--- icon_set
    Gets the icon set being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ICON_SET (see Gtk::Image#storage_type).
    * Returns: the icon set (Gtk::IconSet).
    
--- icon_set=(iconset)
    Sets the icon set.
    * iconset: a new icon set Gtk::IconSet
    * Returns: iconset (Gtk::IconSet)

--- set_icon_set(iconset)
    Same as icon_set=
    * iconset: a new icon set Gtk::IconSet
    * Returns: self

--- icon_size
    Gets the icon size being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ICON_SET (see Gtk::Image#storage_type).
    * Returns: icon size (GtkIconSize - the constants of Gtk::IconSize)

--- icon_size=(size)
    Sets the icon size.
    * size: a new icon size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: icon size
    
--- set_icon_size(size)
    Same as icon_size=.
    * size: a new icon size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: self

--- image
    Gets the Gdk::Image being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::IMAGE (see Gtk::Image::storage_type). The caller of this function does not own a reference to the returned image and mask.
    * Returns: image (Gdk::Image)

--- image=(image)
    Sets the image.
    * image: the new image (Gdk::Image).
    * Returns: image

--- set_image(image)
    Same as image=.
    * image: the new image (Gdk::Image).
    * Returns: self

--- pixbuf
    Gets the Gdk::Pixbuf being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXBUF (see Gtk::Image#storage_type). The caller of this function does not own a reference to the returned pixbuf.
    * Returns: pixbuf (Gdk::Pixbuf)

--- pixbuf=(pixbuf)
    Sets the pixbuf.
    * pixbuf: the new pixbuf (Gdk::Pixbuf).
    * Returns: pixbuf

--- set_pixbuf(pixbuf)
    Same as pixbuf=.
    * pixbuf: the new pixbuf (Gdk::Pixbuf).
    * Returns: self

--- pixbuf_animation
    Gets the Gdk::PixbufAnimation being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ANIMATION (see Gtk::Image::storage_type).
    * Returns: animation (Gdk::PixbufAnimation)

--- pixbuf_animation=(animation)
    Sets the animation.
    * animation: the new animation (Gdk::PixbufAnimation).
    * Returns: animation

--- set_pixbuf_animation(animation)
    Same as animation=.
    * animation: the new animation (Gdk::PixbufAnimation).
    * Returns: self

--- pixmap
    Gets the Gdk::Pixmap being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXMAP (see Gtk::Image::storage_type).
    * Returns: pixmap (Gdk::Pixmap)

--- pixmap=(pixmap)
    Sets the pixmap.
    * pixmap: the new pixmap (Gdk::Pixmap).
    * Returns: pixmap

--- set_pixmap(pixmap)
    Same as pixmap=.
    * pixmap: the new pixmap (Gdk::Pixmap).
    * Returns: self

--- mask
    Gets the Gdk::Pixmap being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXMAP (see Gtk::Image::storage_type).
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: mask

--- mask=(mask)
    Sets the mask.
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: mask

--- set_mask(mask)
    Same as mask=.
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: self

--- stock
    Gets the stock item being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::STOCK (see Gtk::Image::storage_type).
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: stock

--- stock=(stock)
    Sets the stock item.
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: stock

--- set_stock(stock)
    Same as stock=.
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: self

--- file=(filename)
    Sets the filename.
    * filename: the new filename(String).
    * Returns: filename

--- set_file(filename)
    Same as file=.
    * filename: the new filename(String).
    * Returns: self

--- set(value)
    Sets a new value. 
    * value
       * filename(String) - Creates a new Gtk::Image displaying the file filename. If the file isn't found or can't be loaded, the resulting Gtk::Image will display a "broken image" icon. This function never returns nil, it always returns a valid Gtk::Image widget. If the file contains an animation, the image will contain an animation. If you need to detect failures to load the file, use Gdk::Pixbuf.new(filename) to load the file yourself, then create the Gtk::Image from the pixbuf. (Or for animations, use Gdk::PixbufAnimation.new(filenam. The storage type (Gtk::Image#storage_type) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
       * Gdk::Pixbuf - Create a new Gtk::Image from Gdk::Pixbuf. This function just creates an Gtk::Image. The Gtk::Image created will not react to state changes. Should you want that, you should use Gtk::IconSet.
       * Gdk::PixbufAnimation - Creates a Gtk::Image displaying the given animation. The Gtk::Image does not assume a reference to the animation; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * Returns: self

--- set(stock_id, size)
    Sets a Gtk::Image displaying a stock icon. Sample stock icon names are Gtk::Stock::OPEN, Gtk::Stock::EXIT. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. If the stock icon name isn't known, a "broken image" icon will be displayed instead. You can register your own stock icon names, see Gtk::IconFactory#add_default and Gtk::IconFactory#add.
    * stock_id: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: self
    
--- set(image, mask)
    Sets a Gtk::Image widget displaying a image with a mask. A Gdk::Image is a client-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the image or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * image: image (Gdk::Image).
    * mask: mask (Gdk::Pixmap(depth = 1))
    * Returns: self

--- set(pixmap, mask)
    Sets a Gtk::Image widget displaying pixmap with a mask. A Gdk::Image is a server-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the pixmap or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * pixmap: pixmap (Gdk::Pixmap).
    * mask: mask (Gdk::Pixmap(depth = 1))
    * Returns: self

--- set(iconset, size)
    Sets a Gtk::Image displaying an icon set. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. Instead of using this method, usually it's better to create a Gtk::IconFactory, put your icon sets in the icon factory, add the icon factory to the list of default factories with Gtk::IconFactory#add_default, and then use Gtk::Image.new(stock_id, size). This will allow themes to override the icon you ship with your application. 
    The Gtk::Image does not assume a reference to the icon set; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * iconset: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)

--- storage_type
    Gets the type(((<GtkImageType|Gtk::Image#GtkImageType>))) of representation being used by the Gtk::Image to store image data. If the Gtk::Image has no image data, the return value will be Gtk::Image::EMPTY.
    * Returns: storage_type(((<GtkImageType|Gtk::Image#GtkImageType>))).

== constants
=== GtkImageType
Describes the image data representation used by a Gtk::Image. If you want to get the image from the widget, you can only get the currently-stored representation. e.g. if the Gtk::Image#storage_type returns Gtk::Image::PIXBUF, then you can call Gtk::Image#pixbuf but not Gtk::Image#stock. For empty images, you can request any storage type (call any of the "get" functions), but they will all return nil values. 

--- EMPTY
    there is no image displayed by the widget. 
--- PIXMAP
    the widget contains a Gdk::Pixmap. 
--- IMAGE
    the widget contains a Gdk::Image. 
--- PIXBUF
    the widget contains a Gdk::Pixbuf. 
--- STOCK
    the widget contains a stock icon (Gtk::Stock constant value). 
--- ICON_SET
    the widget contains a Gtk::IconSet.
--- ANIMATION
    the widget contains a Gdk::PixbufAnimation.

== See Also
Gdk::Pixbuf

- ((<Masao>))

-------------------------
= class Gtk::Image
The Gtk::Image widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a Gdk::Pixbuf ("pixel buffer") from a file, and then display that. There's a convenience function to do this, Gtk::Image.new, used as follows: 

  image = Gtk::Image.new("myfile.png")

If the file isn't loaded successfully, the image will contain a "broken image" icon similar to that used in many web browsers. If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with Gdk::Pixbuf.new, then create the Gtk::Image with Gtk::Image.new(Gdk::Pixbuf). 

The image file may contain an animation, if so the Gtk::Image will display an animation (Gdk::PixbufAnimation) instead of a static image. 

Gtk::Image is a subclass of Gtk::Misc, which implies that you can align it (center, left, right) and add padding to it, using Gtk::Misc methods. 

Gtk::Image is a "no window" widget (has no Gdk::Window of its own), so by default does not receive events. If you want to receive events on the image, such as button clicks, place the image inside a Gtk::EventBox, then connect to the event signals on the event box. 

((*Example 2. Handling button press events on a Gtk::Image.*))

    image = Gtk::Image.new("myfile.png")
    event_box = Gtk::EventBox.new.add(image)
    event_box.signal_connect("button_press_event") do
      puts "Clicked."
    end

When handling events on the event box, keep in mind that coordinates in the image may be different from event box coordinates due to the alignment and padding settings on the image (see Gtk::Misc). The simplest way to solve this is to set the alignment to 0.0 (left/top), and set the padding to zero. Then the origin of the image will be the same as the origin of the event box. 

== super class
* Gtk::Misc

== class methods
--- Gtk::Image.new(value = nil)
    Creates a new Gtk::Image.
    * value
       * nil - Create a new empty Gtk::Image.
       * filename(String) - Creates a new Gtk::Image displaying the file filename. If the file isn't found or can't be loaded, the resulting Gtk::Image will display a "broken image" icon. This function never returns nil, it always returns a valid Gtk::Image widget. If the file contains an animation, the image will contain an animation. If you need to detect failures to load the file, use Gdk::Pixbuf.new(filename) to load the file yourself, then create the Gtk::Image from the pixbuf. (Or for animations, use Gdk::PixbufAnimation.new(filenam. The storage type (Gtk::Image#storage_type) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
       * Gdk::Pixbuf - Create a new Gtk::Image from Gdk::Pixbuf. This function just creates an Gtk::Image. The Gtk::Image created will not react to state changes. Should you want that, you should use Gtk::IconSet.
       * Gdk::PixbufAnimation - Creates a Gtk::Image displaying the given animation. The Gtk::Image does not assume a reference to the animation; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.

--- Gtk::Image.new(stock_id, size)
    Creates a Gtk::Image displaying a stock icon. Sample stock icon names are Gtk::Stock::OPEN, Gtk::Stock::EXIT. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. If the stock icon name isn't known, a "broken image" icon will be displayed instead. You can register your own stock icon names, see Gtk::IconFactory#add_default and Gtk::IconFactory#add.
    * stock_id: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    
--- Gtk::Image.new(image, mask)
    Creates a Gtk::Image widget displaying a image with a mask. A Gdk::Image is a client-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the image or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * image: image (Gdk::Image).
    * mask: mask (Gdk::Pixmap(depth = 1)

--- Gtk::Image.new(pixmap, mask)
    Creates a Gtk::Image widget displaying pixmap with a mask. A Gdk::Image is a server-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the pixmap or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * pixmap: pixmap (Gdk::Pixmap).
    * mask: mask (Gdk::Pixmap(depth = 1)

--- Gtk::Image.new(iconset, size)
    Creates a Gtk::Image displaying an icon set. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. Instead of using this method, usually it's better to create a Gtk::IconFactory, put your icon sets in the icon factory, add the icon factory to the list of default factories with Gtk::IconFactory#add_default, and then use Gtk::Image.new(stock_id, size). This will allow themes to override the icon you ship with your application. 
    The Gtk::Image does not assume a reference to the icon set; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * iconset: stock icon (constants of Gtk::Stock)
    * size: size (GtkIconSize - the constants of Gtk::IconSize)

== public instance methods
--- icon_set
    Gets the icon set being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ICON_SET (see Gtk::Image#storage_type).
    * Returns: the icon set (Gtk::IconSet).
    
--- icon_set=(iconset)
    Sets the icon set.
    * iconset: a new icon set Gtk::IconSet
    * Returns: iconset (Gtk::IconSet)

--- set_icon_set(iconset)
    Same as icon_set=
    * iconset: a new icon set Gtk::IconSet
    * Returns: self

--- icon_size
    Gets the icon size being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ICON_SET (see Gtk::Image#storage_type).
    * Returns: icon size (GtkIconSize - the constants of Gtk::IconSize)

--- icon_size=(size)
    Sets the icon size.
    * size: a new icon size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: icon size
    
--- set_icon_size(size)
    Same as icon_size=.
    * size: a new icon size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: self

--- image
    Gets the Gdk::Image being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::IMAGE (see Gtk::Image::storage_type). The caller of this function does not own a reference to the returned image and mask.
    * Returns: image (Gdk::Image)

--- image=(image)
    Sets the image.
    * image: the new image (Gdk::Image).
    * Returns: image

--- set_image(image)
    Same as image=.
    * image: the new image (Gdk::Image).
    * Returns: self

--- pixbuf
    Gets the Gdk::Pixbuf being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXBUF (see Gtk::Image#storage_type). The caller of this function does not own a reference to the returned pixbuf.
    * Returns: pixbuf (Gdk::Pixbuf)

--- pixbuf=(pixbuf)
    Sets the pixbuf.
    * pixbuf: the new pixbuf (Gdk::Pixbuf).
    * Returns: pixbuf

--- set_pixbuf(pixbuf)
    Same as pixbuf=.
    * pixbuf: the new pixbuf (Gdk::Pixbuf).
    * Returns: self

--- pixbuf_animation
    Gets the Gdk::PixbufAnimation being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::ANIMATION (see Gtk::Image::storage_type).
    * Returns: animation (Gdk::PixbufAnimation)

--- pixbuf_animation=(animation)
    Sets the animation.
    * animation: the new animation (Gdk::PixbufAnimation).
    * Returns: animation

--- set_pixbuf_animation(animation)
    Same as animation=.
    * animation: the new animation (Gdk::PixbufAnimation).
    * Returns: self

--- pixmap
    Gets the Gdk::Pixmap being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXMAP (see Gtk::Image::storage_type).
    * Returns: pixmap (Gdk::Pixmap)

--- pixmap=(pixmap)
    Sets the pixmap.
    * pixmap: the new pixmap (Gdk::Pixmap).
    * Returns: pixmap

--- set_pixmap(pixmap)
    Same as pixmap=.
    * pixmap: the new pixmap (Gdk::Pixmap).
    * Returns: self

--- mask
    Gets the Gdk::Pixmap being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::PIXMAP (see Gtk::Image::storage_type).
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: mask

--- mask=(mask)
    Sets the mask.
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: mask

--- set_mask(mask)
    Same as mask=.
    * mask: the new mask (Gdk::Pixmap(depth = 1).
    * Returns: self

--- stock
    Gets the stock item being displayed by the Gtk::Image. The storage type of the image must be Gtk::Image::EMPTY or Gtk::Image::STOCK (see Gtk::Image::storage_type).
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: stock

--- stock=(stock)
    Sets the stock item.
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: stock

--- set_stock(stock)
    Same as stock=.
    * stock: the new stock item (Gtk::Stock constant value).
    * Returns: self

--- file=(filename)
    Sets the filename.
    * filename: the new filename(String).
    * Returns: filename

--- set_file(filename)
    Same as file=.
    * filename: the new filename(String).
    * Returns: self

--- set(value)
    Sets a new value. 
    * value
       * filename(String) - Creates a new Gtk::Image displaying the file filename. If the file isn't found or can't be loaded, the resulting Gtk::Image will display a "broken image" icon. This function never returns nil, it always returns a valid Gtk::Image widget. If the file contains an animation, the image will contain an animation. If you need to detect failures to load the file, use Gdk::Pixbuf.new(filename) to load the file yourself, then create the Gtk::Image from the pixbuf. (Or for animations, use Gdk::PixbufAnimation.new(filenam. The storage type (Gtk::Image#storage_type) of the returned image is not defined, it will be whatever is appropriate for displaying the file.
       * Gdk::Pixbuf - Create a new Gtk::Image from Gdk::Pixbuf. This function just creates an Gtk::Image. The Gtk::Image created will not react to state changes. Should you want that, you should use Gtk::IconSet.
       * Gdk::PixbufAnimation - Creates a Gtk::Image displaying the given animation. The Gtk::Image does not assume a reference to the animation; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * Returns: self

--- set(stock_id, size)
    Sets a Gtk::Image displaying a stock icon. Sample stock icon names are Gtk::Stock::OPEN, Gtk::Stock::EXIT. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. If the stock icon name isn't known, a "broken image" icon will be displayed instead. You can register your own stock icon names, see Gtk::IconFactory#add_default and Gtk::IconFactory#add.
    * stock_id: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)
    * Returns: self
    
--- set(image, mask)
    Sets a Gtk::Image widget displaying a image with a mask. A Gdk::Image is a client-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the image or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * image: image (Gdk::Image).
    * mask: mask (Gdk::Pixmap(depth = 1))
    * Returns: self

--- set(pixmap, mask)
    Sets a Gtk::Image widget displaying pixmap with a mask. A Gdk::Image is a server-side image buffer in the pixel format of the current display. The Gtk::Image does not assume a reference to the pixmap or mask; you still need to unref them if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * pixmap: pixmap (Gdk::Pixmap).
    * mask: mask (Gdk::Pixmap(depth = 1))
    * Returns: self

--- set(iconset, size)
    Sets a Gtk::Image displaying an icon set. Sample stock sizes are Gtk::IconSize::MENU, Gtk::IconSize::SMALL_TOOLBAR. Instead of using this method, usually it's better to create a Gtk::IconFactory, put your icon sets in the icon factory, add the icon factory to the list of default factories with Gtk::IconFactory#add_default, and then use Gtk::Image.new(stock_id, size). This will allow themes to override the icon you ship with your application. 
    The Gtk::Image does not assume a reference to the icon set; you still need to unref it if you own references. Gtk::Image will add its own reference rather than adopting yours.
    * iconset: stock icon (constants of Gtk::Stock)
    * size: size (((<GtkIconSize|Gtk::IconSIze#GtkIconSize>)) - the constants of Gtk::IconSize)

--- storage_type
    Gets the type(((<GtkImageType|Gtk::Image#GtkImageType>))) of representation being used by the Gtk::Image to store image data. If the Gtk::Image has no image data, the return value will be Gtk::Image::EMPTY.
    * Returns: storage_type(((<GtkImageType|Gtk::Image#GtkImageType>))).

== constants
=== GtkImageType
Describes the image data representation used by a Gtk::Image. If you want to get the image from the widget, you can only get the currently-stored representation. e.g. if the Gtk::Image#storage_type returns Gtk::Image::PIXBUF, then you can call Gtk::Image#pixbuf but not Gtk::Image#stock. For empty images, you can request any storage type (call any of the "get" functions), but they will all return nil values. 

--- EMPTY
    there is no image displayed by the widget. 
--- PIXMAP
    the widget contains a Gdk::Pixmap. 
--- IMAGE
    the widget contains a Gdk::Image. 
--- PIXBUF
    the widget contains a Gdk::Pixbuf. 
--- STOCK
    the widget contains a stock icon (Gtk::Stock constant value). 
--- ICON_SET
    the widget contains a Gtk::IconSet.
--- ANIMATION
    the widget contains a Gdk::PixbufAnimation.

== See Also
Gdk::Pixbuf

- ((<Masao>))




ruby-gnome2-cvs メーリングリストの案内
Back to archive index