gtk3-0.15.10: Binding to the Gtk+ 3 graphical user interface library

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell98

Graphics.UI.Gtk.Display.Image

Contents

- Detail
- Class Hierarchy
- Types
- Constructors
- Methods
- Icon Sizes
- Attributes

Description

A widget displaying an image

Synopsis

- data Image
- class MiscClass o => ImageClass o
- castToImage :: GObjectClass obj => obj -> Image
- gTypeImage :: GType
- toImage :: ImageClass o => o -> Image
- data ImageType
  - = ImageEmpty
  - | ImagePixbuf
  - | ImageStock
  - | ImageIconSet
  - | ImageAnimation
  - | ImageIconName
  - | ImageGicon
  - | ImageSurface
- imageNewFromFile :: GlibFilePath fp => fp -> IO Image
- imageNewFromPixbuf :: Pixbuf -> IO Image
- imageNewFromAnimation :: PixbufAnimationClass animation => animation -> IO Image
- imageNewFromStock :: StockId -> IconSize -> IO Image
- imageNew :: IO Image
- imageNewFromIconName :: GlibString string => string -> IconSize -> IO Image
- imageGetPixbuf :: Image -> IO Pixbuf
- imageSetFromPixbuf :: Image -> Pixbuf -> IO ()
- imageSetFromAnimation :: PixbufAnimationClass animation => Image -> animation -> IO ()
- imageSetFromFile :: GlibFilePath fp => Image -> fp -> IO ()
- imageSetFromStock :: Image -> StockId -> IconSize -> IO ()
- imageSetFromIconName :: GlibString string => Image -> string -> IconSize -> IO ()
- imageSetPixelSize :: Image -> Int -> IO ()
- imageGetPixelSize :: Image -> IO Int
- imageClear :: Image -> IO ()
- data IconSize
  - = IconSizeInvalid
  - | IconSizeMenu
  - | IconSizeSmallToolbar
  - | IconSizeLargeToolbar
  - | IconSizeButton
  - | IconSizeDnd
  - | IconSizeDialog
  - | IconSizeUser Int
- imagePixbuf :: PixbufClass pixbuf => ReadWriteAttr Image Pixbuf pixbuf
- imageAnimation :: (PixbufClass pixbuf, PixbufAnimationClass animation) => ReadWriteAttr Image animation pixbuf
- imageImage :: ImageClass image => ReadWriteAttr Image Image image
- imageFile :: GlibString string => Attr Image string
- imageStock :: GlibString string => Attr Image string
- imageIconSize :: Attr Image Int
- imagePixelSize :: Attr Image Int
- imageIconName :: GlibString string => Attr Image string
- imageStorageType :: ReadAttr Image ImageType

# Detail

The `Image` widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a `Pixbuf` ("pixel buffer") from a file, and then display that. There's a convenience function to do this, `imageNewFromFile`, used as follows: 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 `pixbufNewFromFile`, then create the `Image` with `imageNewFromPixbuf`.

    image <- imageNewFromFile "myfile.png"

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

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

`Image` is a "no window" widget (has no `DrawWindow` 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 `EventBox`, then connect to the event signals on the event box.

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 `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.

Sometimes an application will want to avoid depending on external data files, such as image files. Gtk+ comes with a program to avoid this, called gdk-pixbuf-csource. This program allows you to convert an image into a C variable declaration, which can then be loaded into a `Pixbuf` using `pixbufNewFromInline`.

# Class Hierarchy

    | GObject
    | +----Object
    | +----Widget
    | +----Misc
    | +----Image

# Types

data Image Source #

#### Instances

Instances details

Eq Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods (==) :: Image -> Image -> Bool Source # (/=) :: Image -> Image -> Bool Source #
Ord Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods compare :: Image -> Image -> Ordering Source # (<) :: Image -> Image -> Bool Source # (<=) :: Image -> Image -> Bool Source # (>) :: Image -> Image -> Bool Source # (>=) :: Image -> Image -> Bool Source # max :: Image -> Image -> Image Source # min :: Image -> Image -> Image Source #
GObjectClass Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods toGObject :: Image -> GObject Source # unsafeCastGObject :: GObject -> Image Source #
ImageClass Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types
MiscClass Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types
WidgetClass Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types

class MiscClass o => ImageClass o Source #

#### Instances

Instances details

ImageClass Image Source # |
Instance details Defined in Graphics.UI.Gtk.Types

castToImage :: GObjectClass obj => obj -> Image Source #

gTypeImage :: GType Source #

toImage :: ImageClass o => o -> Image Source #

data ImageType Source #

Describes the image data representation used by a `Image`. If you want to get the image from the widget, you can only get the currently-stored representation. e.g. if the `imageStorageType` is `ImagePixbuf`, then you can call `imageGetPixbuf` but not `imageGetStock`. For empty images, you can request any storage type (call any of the "get" functions), but they will all return `Nothing`.

Constructors

ImageEmpty |
ImagePixbuf |
ImageStock |
ImageIconSet |
ImageAnimation |
ImageIconName |
ImageGicon |
ImageSurface |

#### Instances

Instances details

Enum ImageType Source # |

Instance details

Defined in Graphics.UI.Gtk.Display.Image

Methods

succ :: ImageType -> ImageType Source #

pred :: ImageType -> ImageType Source #

toEnum :: Int -> ImageType Source #

fromEnum :: ImageType -> Int Source #

enumFrom :: ImageType -> [ImageType] Source #

enumFromThen :: ImageType -> ImageType -> [ImageType] Source #

enumFromTo :: ImageType -> ImageType -> [ImageType] Source #

enumFromThenTo :: ImageType -> ImageType -> ImageType -> [ImageType] Source #

Show ImageType Source # |
Instance details Defined in Graphics.UI.Gtk.Display.Image Methods showsPrec :: Int -> ImageType -> ShowS Source # show :: ImageType -> String Source # showList :: [ImageType] -> ShowS Source #
Eq ImageType Source # |
Instance details Defined in Graphics.UI.Gtk.Display.Image Methods (==) :: ImageType -> ImageType -> Bool Source # (/=) :: ImageType -> ImageType -> Bool Source #

# Constructors

imageNewFromFile :: GlibFilePath fp => fp -> IO Image Source #

Creates a new `Image` displaying the file `filename`. If the file isn't found or can't be loaded, the resulting `Image` will display a "broken image" icon.

If the file contains an animation, the image will contain an animation.

If you need to detect failures to load the file, use `pixbufNewFromFile` to load the file yourself, then create the `Image` from the pixbuf. (Or for animations, use `pixbufAnimationNewFromFile`).

The storage type (`imageGetStorageType`) of the returned image is not defined, it will be whatever is appropriate for displaying the file.

imageNewFromPixbuf :: Pixbuf -> IO Image Source #

Creates a new `Image` displaying a `Pixbuf`.

Note that this function just creates an `Image` from the pixbuf. The `Image` created will not react to state changes. Should you want that, you should use `imageNewFromIconSet`.

imageNewFromAnimation :: PixbufAnimationClass animation => animation -> IO Image Source #

imageNewFromStock Source #

Arguments

:: StockId | `stockId` - a stock icon name
-> IconSize | `size` - a stock icon size
-> IO Image |

Creates a `Image` displaying a stock icon. If the stock icon name isn't known, the image will be empty.

imageNew :: IO Image Source #

Creates a new empty `Image` widget.

imageNewFromIconName Source #

Arguments

:: GlibString string |
=> string | `iconName` - an icon name
-> IconSize | `size` - a stock icon size
-> IO Image |

Creates a `Image` displaying an icon from the current icon theme. If the icon name isn't known, a "broken image" icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

- Available since Gtk+ version 2.6

# Methods

imageGetPixbuf :: Image -> IO Pixbuf Source #

Gets the `Pixbuf` being displayed by the `Image`. The storage type of the image must be `ImageEmpty` or `ImagePixbuf` (see `imageGetStorageType`).

imageSetFromPixbuf :: Image -> Pixbuf -> IO () Source #

Overwrite the current content of the `Image` with a new `Pixbuf`.

imageSetFromAnimation :: PixbufAnimationClass animation => Image -> animation -> IO () Source #

imageSetFromFile :: GlibFilePath fp => Image -> fp -> IO () Source #

See `imageNewFromFile` for details.

imageSetFromStock Source #

Arguments

:: Image |
-> StockId | `stockId` - a stock icon name
-> IconSize | `size` - a stock icon size
-> IO () |

See `imageNewFromStock` for details.

imageSetFromIconName Source #

Arguments

:: GlibString string |
=> Image |
-> string | `iconName` - an icon name
-> IconSize | `size` - an icon size
-> IO () |

See `imageNewFromIconName` for details.

- Available since Gtk+ version 2.6

imageSetPixelSize Source #

Arguments

:: Image |
-> Int | `pixelSize` - the new pixel size
-> IO () |

Sets the pixel size to use for named icons. If the pixel size is set to a `value /= -1`, it is used instead of the icon size set by `imageSetFromIconName`.

- Available since Gtk+ version 2.6

imageGetPixelSize :: Image -> IO Int Source #

Gets the pixel size used for named icons.

- Available since Gtk+ version 2.6

imageClear :: Image -> IO () Source #

Resets the image to be empty.

- Available since Gtk+ version 2.8

# Icon Sizes

data IconSize Source #

The size of an icon in pixels.

- This enumeration contains one case that is not exported and which is used when new sizes are registered using `iconSizeRegister`.
- Applying `show` to this type will reveal the name of the size that is registered with Gtk+.

Constructors

IconSizeInvalid | Don't scale but use any of the available sizes.
IconSizeMenu | Icon size to use in next to menu items in drop-down menus.
IconSizeSmallToolbar | Icon size for small toolbars.
IconSizeLargeToolbar | Icon size for larger toolbars.
IconSizeButton | Icon size for icons in buttons, next to the label.
IconSizeDnd | Icon size for icons in drag-and-drop.
IconSizeDialog | Icon size for icons next to dialog text.
IconSizeUser Int |

#### Instances

Instances details

Enum IconSize Source # |

Instance details

Defined in Graphics.UI.Gtk.General.Structs

Methods

succ :: IconSize -> IconSize Source #

pred :: IconSize -> IconSize Source #

toEnum :: Int -> IconSize Source #

fromEnum :: IconSize -> Int Source #

enumFrom :: IconSize -> [IconSize] Source #

enumFromThen :: IconSize -> IconSize -> [IconSize] Source #

enumFromTo :: IconSize -> IconSize -> [IconSize] Source #

enumFromThenTo :: IconSize -> IconSize -> IconSize -> [IconSize] Source #

Show IconSize Source # |
Instance details Defined in Graphics.UI.Gtk.General.IconFactory Methods showsPrec :: Int -> IconSize -> ShowS Source # show :: IconSize -> String Source # showList :: [IconSize] -> ShowS Source #
Eq IconSize Source # |
Instance details Defined in Graphics.UI.Gtk.General.Structs Methods (==) :: IconSize -> IconSize -> Bool Source # (/=) :: IconSize -> IconSize -> Bool Source #

# Attributes

imagePixbuf :: PixbufClass pixbuf => ReadWriteAttr Image Pixbuf pixbuf Source #

A `Pixbuf` to display.

imageAnimation :: (PixbufClass pixbuf, PixbufAnimationClass animation) => ReadWriteAttr Image animation pixbuf Source #

imageImage :: ImageClass image => ReadWriteAttr Image Image image Source #

A `Image` to display.

imageFile :: GlibString string => Attr Image string Source #

Filename to load and display.

Default value: ""

imageStock :: GlibString string => Attr Image string Source #

Stock ID for a stock image to display.

Default value: ""

imageIconSize :: Attr Image Int Source #

Symbolic size to use for stock icon, icon set or named icon.

Allowed values: >= 0

Default value: 4

imagePixelSize :: Attr Image Int Source #

The pixel-size property can be used to specify a fixed size overriding the icon-size property for images of type `ImageIconName`.

Allowed values: >= -1

Default value: -1

imageIconName :: GlibString string => Attr Image string Source #

The name of the icon in the icon theme. If the icon theme is changed, the image will be updated automatically.

Default value: ""

imageStorageType :: ReadAttr Image ImageType Source #

The representation being used for image data.

Default value: `ImageEmpty`