Portability | portable (depends on GHC) |
---|---|
Stability | provisional |
Maintainer | gtk2hs-users@lists.sourceforge.net |
- data ImageView
- class WidgetClass o => ImageViewClass o
- imageViewNew :: IO ImageView
- imageViewGetViewport :: ImageViewClass view => view -> IO (Maybe Rectangle)
- imageViewGetDrawRect :: ImageViewClass view => view -> IO (Maybe Rectangle)
- imageViewGetCheckColors :: ImageViewClass view => view -> IO (Int, Int)
- imageViewImageToWidgetRect :: ImageViewClass view => view -> Rectangle -> Rectangle -> IO Bool
- imageViewSetOffset :: ImageViewClass view => view -> Double -> Double -> Bool -> IO ()
- imageViewSetTransp :: ImageViewClass view => view -> ImageTransp -> Int -> IO ()
- imageViewGetFitting :: ImageViewClass view => view -> IO Bool
- imageViewSetFitting :: ImageViewClass view => view -> Bool -> IO ()
- imageViewGetPixbuf :: ImageViewClass view => view -> IO Pixbuf
- imageViewSetPixbuf :: ImageViewClass view => view -> Maybe Pixbuf -> Bool -> IO ()
- imageViewGetZoom :: ImageViewClass view => view -> IO Double
- imageViewSetZoom :: ImageViewClass view => view -> Double -> IO ()
- imageViewSetBlackBg :: ImageViewClass view => view -> Bool -> IO ()
- imageViewGetBlackBg :: ImageViewClass view => view -> IO Bool
- imageViewSetShowFrame :: ImageViewClass view => view -> Bool -> IO ()
- imageViewGetShowFrame :: ImageViewClass view => view -> IO Bool
- imageViewSetInterpolation :: ImageViewClass view => view -> InterpType -> IO ()
- imageViewGetInterpolation :: ImageViewClass view => view -> IO InterpType
- imageViewSetShowCursor :: ImageViewClass view => view -> Bool -> IO ()
- imageViewGetShowCursor :: ImageViewClass view => view -> IO Bool
- imageViewSetTool :: ImageViewClass view => view -> IImageTool -> IO ()
- imageViewGetTool :: ImageViewClass view => view -> IO IImageTool
- imageViewZoomIn :: ImageViewClass view => view -> IO ()
- imageViewZoomOut :: ImageViewClass view => view -> IO ()
- imageViewDamagePixels :: ImageViewClass view => view -> Maybe Rectangle -> IO ()
- imageViewLibraryVersion :: IO String
- mouseWheelScroll :: ImageViewClass view => Signal view (ScrollDirection -> IO ())
- pixbufChanged :: ImageViewClass view => Signal view (IO ())
- scroll :: ImageViewClass view => Signal view (ScrollType -> ScrollType -> IO ())
- setFitting :: ImageViewClass view => Signal view (Int -> IO ())
- setScrollAdjustments :: ImageViewClass view => Signal view (Adjustment -> Adjustment -> IO ())
- setZoom :: ImageViewClass view => Signal view (Double -> IO ())
- zoomChanged :: ImageViewClass view => Signal view (IO ())
- zoomIn :: ImageViewClass view => Signal view (IO ())
- zoomOut :: ImageViewClass view => Signal view (IO ())
Details
ImageView
is a full-featured general purpose image viewer widget for GTK. It provides a
scrollable, zoomable pane in which a pixbuf can be displayed.
Types
Methods
imageViewNew :: IO ImageViewSource
Creates a new image view with default values. The default values are:
- black bg :
False
* fitting :True
* image tool : aImageToolDragger
instance * interpolation mode :InterpBilinear
* offset : (0, 0) * pixbuf :Nothing
* show cursor:True
* show frame :True
* transp :ImageTranspGrid
* zoom : 1.0
imageViewGetViewport :: ImageViewClass view => view -> IO (Maybe Rectangle)Source
Fills in the rectangle with the current viewport. If pixbuf is Nothing
, there is no viewport, rect is
left untouched and False
is returned. If the view is not allocated, the rectangles coordinates are
set to the views offset and its width and height to zero.
The current viewport is defined as the rectangle, in zoomspace coordinates as the area of the loaded
pixbuf the ImageView
is currently showing.
imageViewGetDrawRect :: ImageViewClass view => view -> IO (Maybe Rectangle)Source
Get the rectangle in the widget where the pixbuf is painted.
For example, if the widgets allocated size is 100, 100 and the pixbufs size is 50, 50 and the zoom factor is 1.0, then the pixbuf will be drawn centered on the widget. rect will then be (25,25)-[50,50].
If the view is not allocated, then the rectangle will be set to (0,0)-[0,0] and True
is returned.
This method is useful when converting from widget to image or zoom space coordinates.
imageViewGetCheckColors :: ImageViewClass view => view -> IO (Int, Int)Source
Reads the two colors used to draw transparent parts of images with an alpha channel. Note that if
the transp setting of the view is ImageTranspBackground
or ImageTranspColor
, then both
colors will be equal.
imageViewImageToWidgetRectSource
:: ImageViewClass view | |
=> view | |
-> Rectangle |
|
-> Rectangle |
|
-> IO Bool | returns |
Convert a rectangle in image space coordinates to widget space coordinates. If the view is not
realized, or if it contains no pixbuf, then the conversion was unsuccessful, False
is returned and
rectOut
is left unmodified.
The size of rectOut
is rounded up. For example, if the zoom factor is 0.25 and the width of the
input rectangle is 2, then its with in widget space coordinates is 0.5 which is rounded up to 1.
Note that this function may return a rectangle that is not visible on the widget.
:: ImageViewClass view | |
=> view | |
-> Double |
|
-> Double |
|
-> Bool |
|
-> IO () |
Sets the offset of where in the image the ImageView
should begin displaying image data.
The offset is clamped so that it will never cause the ImageView
to display pixels outside the
pixbuf. Setting this attribute causes the widget to repaint itself if it is realized.
If invalidate is True
, the views entire area will be invalidated instead of redrawn immediately. The
view is then queued for redraw, which means that additional operations can be performed on it before
it is redrawn.
The difference can sometimes be important like when you are overlaying data and get flicker or
artifacts when setting the offset. If that happens, setting invalidate to True
could fix the
problem. See the source code to ImageToolSelector
for an example.
Normally, invalidate should always be False
because it is much faster to repaint immedately than
invalidating.
:: ImageViewClass view | |
=> view | |
-> ImageTransp |
|
-> Int |
|
-> IO () |
Sets how the view should draw transparent parts of images with an alpha channel. If transp is
ImageTranspColor
, the specified color will be used. Otherwise the transpColor
argument is
ignored. If it is ImageTranspBackground
, the background color of the widget will be used. If
it is ImageTranspGrid
, then a grid with light and dark gray boxes will be drawn on the
transparent parts.
Calling this method causes the widget to immediately repaint. It also causes the pixbufChanged
signal to be emitted. This is done so that other widgets (such as ImageNav
) will have a chance to
render a view of the pixbuf with the new transparency settings.
The default values are:
- transp :
ImageTranspGrid
*transpColor
: 0x000000
:: ImageViewClass view | |
=> view | |
-> IO Bool | returns |
Returns the fitting setting of the view.
:: ImageViewClass view | |
=> view | |
-> Bool |
|
-> IO () |
:: ImageViewClass view | |
=> view | |
-> IO Pixbuf | returns The pixbuf this view shows. |
Returns the pixbuf this view shows.
:: ImageViewClass view | |
=> view | |
-> Maybe Pixbuf |
|
-> Bool |
|
-> IO () |
Sets the pixbuf to display, or Nothing
to not display any pixbuf. Normally, resetFit
should be True
which enables fitting. Which means that, initially, the whole pixbuf will be shown.
Sometimes, the fit mode should not be reset. For example, if ImageView
is showing an animation,
it would be bad to reset the fit mode for each new frame. The parameter should then be False
which
leaves the fit mode of the view untouched.
This method should not be used if merely the contents of the pixbuf has changed. See
imageViewDamagePixels
for that.
If resetFit
is True
, the zoomChanged
signal is emitted, otherwise not. The pixbufChanged
signal is also emitted.
The default pixbuf is Nothing
.
:: ImageViewClass view | |
=> view | |
-> IO Double | returns the current zoom factor |
Get the current zoom factor of the view.
:: ImageViewClass view | |
=> view | |
-> Double |
|
-> IO () |
Sets the zoom of the view.
Fitting is always disabled after this method has run. The zoomChanged
signal is unconditionally
emitted.
The default value is 1.0.
:: ImageViewClass view | |
=> view | |
-> Bool |
|
-> IO () |
:: ImageViewClass view | |
=> view | |
-> IO Bool | returns |
Returns whether the view renders the widget on a black background or not.
:: ImageViewClass view | |
=> view | |
-> Bool |
|
-> IO () |
imageViewGetShowFrame :: ImageViewClass view => view -> IO BoolSource
Returns whether a one pixel frame is drawn around the pixbuf or not.
imageViewSetInterpolationSource
:: ImageViewClass view | |
=> view | |
-> InterpType |
|
-> IO () |
Sets the interpolation mode of how the view. InterpHyper
is the slowest, but produces the best
results. InterpNearest
is the fastest, but provides bad rendering quality. InterpBilinear
is a good compromise.
Setting the interpolation mode causes the widget to immediately repaint itself.
The default interpolation mode is InterpBilinear
.
imageViewGetInterpolation :: ImageViewClass view => view -> IO InterpTypeSource
Returns the current interpolation mode of the view.
:: ImageViewClass view | |
=> view | |
-> Bool |
|
-> IO () |
Sets whether to show the mouse cursor when the mouse is over the widget or not. Hiding the cursor is useful when the widget is fullscreened.
The default value is True
.
:: ImageViewClass view | |
=> view | |
-> IO Bool |
Returns whether to show the mouse cursor when the mouse is over the widget or not.
:: ImageViewClass view | |
=> view | |
-> IImageTool |
|
-> IO () |
Set the image tool to use. If the new tool is the same as the current tool, then nothing will be
done. Otherwise iimageToolPixbufChanged
is called so that the tool has a chance to generate
initial data for the pixbuf.
Setting the tool causes the widget to immediately repaint itself.
The default image tool is a ImageToolDragger
instance. See also IImageTool
.
imageViewGetTool :: ImageViewClass view => view -> IO IImageToolSource
Gets the image tool ImageView
uses for rendering and handling input events.
imageViewZoomIn :: ImageViewClass view => view -> IO ()Source
Zoom in the view one step. Calling this method causes the widget to immediately repaint itself.
imageViewZoomOut :: ImageViewClass view => view -> IO ()Source
Zoom out the view one step. Calling this method causes the widget to immediately repaint itself.
:: ImageViewClass view | |
=> view | |
-> Maybe Rectangle |
|
-> IO () |
Mark the pixels in the rectangle as damaged. That the pixels are damaged, means that they have been
modified and that the view must redraw them to ensure that the visible part of the image corresponds
to the pixels in that image. Calling this method emits the pixbufChanged
signal.
This method must be used when modifying the image data:
'imageViewDamagePixels (View, &(Gdkrectangle){20, 20, 60, 60})';
If the whole pixbuf has been modified then rect should be Nothing
to indicate that a total update is
needed.
| See also imageViewSetPixbuf
.
imageViewLibraryVersion :: IO StringSource
Returns a string with the format major.minor.micro which denotes the runtime version of
ImageView
being used.
Signals
mouseWheelScroll :: ImageViewClass view => Signal view (ScrollDirection -> IO ())Source
The mouseWheelScroll
signal is emitted when the mouse wheel is scrolled on the view and
ControlMask
is not held down.
pixbufChanged :: ImageViewClass view => Signal view (IO ())Source
The pixbufChanged
signal is emitted when the pixbuf the image view shows is changed and when its
image data is changed. Listening to this signal is useful if you, for example, have a label that
displays the width and height of the pixbuf in the view.
scroll :: ImageViewClass view => Signal view (ScrollType -> ScrollType -> IO ())Source
The scroll
signal is a keybinding signal emitted when a key is used to scroll the view. The signal
should not be used by clients of this library.
setFitting :: ImageViewClass view => Signal view (Int -> IO ())Source
setScrollAdjustments :: ImageViewClass view => Signal view (Adjustment -> Adjustment -> IO ())Source
setZoom :: ImageViewClass view => Signal view (Double -> IO ())Source
The setZoom
signal is a keybinding signal emitted when GDK_1, GDK_2 or GDK_3 is pressed on the
widget which causes the zoom to be set to 100%, 200% or 300%. The signal should not be used by
clients of this library.
zoomChanged :: ImageViewClass view => Signal view (IO ())Source
The zoomChanged
signal is emitted when the zoom factor of the view changes. Listening to this
signal is useful if, for example, you have a label that displays the zoom factor of the view. Use
imageViewGetZoom
to retrieve the value.