{-# LANGUAGE ScopedTypeVariables #-}{-# LINE 2 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}-- -*-haskell-*--- GIMP Toolkit (GTK) Drawable---- Author : Axel Simon---- Created: 22 September 2002---- Copyright (C) 2002-2005 Axel Simon---- This library is free software; you can redistribute it and/or-- modify it under the terms of the GNU Lesser General Public-- License as published by the Free Software Foundation; either-- version 2.1 of the License, or (at your option) any later version.---- This library is distributed in the hope that it will be useful,-- but WITHOUT ANY WARRANTY; without even the implied warranty of-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU-- Lesser General Public License for more details.---- TODO---- if gdk_visuals are implemented, do: get_visual---- if gdk_colormaps are implemented, do: set_colormap, get_colormap---- |-- Maintainer : gtk2hs-users@lists.sourceforge.net-- Stability : provisional-- Portability : portable (depends on GHC)---- Drawing primitives.---- This module defines drawing primitives that can operate on 'DrawWindow's-- and 'Pixmap's.--moduleGraphics.UI.Gtk.Gdk.Drawable(Drawable,DrawableClass,castToDrawable,gTypeDrawable,toDrawable,drawableGetDepth,drawableGetSize,drawableGetClipRegion,drawableGetVisibleRegion,Point,drawPoint,drawPoints,drawLine,drawLines,Dither(..),drawPixbuf,drawSegments,drawRectangle,drawArc,drawPolygon,drawGlyphs,drawLayoutLine,drawLayoutLineWithColors,drawLayout,drawLayoutWithColors,drawDrawable)whereimportControl.Monad(liftM)importSystem.Glib.FFIimportGraphics.UI.Gtk.General.Structs(Point,Color)importGraphics.Rendering.Pango.StructsimportGraphics.Rendering.Pango.Types{-# LINE 72 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}importGraphics.Rendering.Pango.BasicTypes{-# LINE 73 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}importGraphics.UI.Gtk.Types{-# LINE 74 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}importGraphics.UI.Gtk.Gdk.Region(Region,makeNewRegion)importGraphics.UI.Gtk.Gdk.Enums(Dither(..)){-# LINE 78 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}-- methods-- | Get the size of pixels.---- * Returns the number of bits which are use to store information on each-- pixels in this 'Drawable'.--drawableGetDepth::DrawableClassd=>d->IOIntdrawableGetDepthd=liftMfromIntegral$(\(Drawablearg1)->withForeignPtrarg1$\argPtr1->gdk_drawable_get_depthargPtr1)(toDrawabled)-- | Retrieve the size of the 'Drawable'.---- * The result might not be up-to-date if there are still resizing messages-- to be processed.--drawableGetSize::DrawableClassd=>d->IO(Int,Int)drawableGetSized=alloca$\wPtr->alloca$\hPtr->do(\(Drawablearg1)arg2arg3->withForeignPtrarg1$\argPtr1->gdk_drawable_get_sizeargPtr1arg2arg3)(toDrawabled)wPtrhPtr(w::(CInt))<-peekwPtr(h::(CInt))<-peekhPtrreturn(fromIntegralw,fromIntegralh)-- | Determine where not to draw.---- * Computes the region of a drawable that potentially can be written-- to by drawing primitives. This region will not take into account the-- clip region for the GC, and may also not take into account other-- factors such as if the window is obscured by other windows, but no-- area outside of this region will be affected by drawing primitives.--drawableGetClipRegion::DrawableClassd=>d->IORegiondrawableGetClipRegiond=dorPtr<-(\(Drawablearg1)->withForeignPtrarg1$\argPtr1->gdk_drawable_get_clip_regionargPtr1)(toDrawabled)makeNewRegionrPtr-- | Determine what not to redraw.---- * Computes the region of a drawable that is potentially visible.-- This does not necessarily take into account if the window is obscured-- by other windows, but no area outside of this region is visible.--drawableGetVisibleRegion::DrawableClassd=>d->IORegiondrawableGetVisibleRegiond=dorPtr<-(\(Drawablearg1)->withForeignPtrarg1$\argPtr1->gdk_drawable_get_visible_regionargPtr1)(toDrawabled)makeNewRegionrPtr-- | Draw a point into a 'Drawable'.--drawPoint::DrawableClassd=>d->GC->Point->IO()drawPointdgc(x,y)=(\(Drawablearg1)(GCarg2)arg3arg4->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_pointargPtr1argPtr2arg3arg4)(toDrawabled)(toGCgc)(fromIntegralx)(fromIntegraly)-- | Draw several points into a 'Drawable'.---- * This function is more efficient than calling 'drawPoint' on-- several points.--drawPoints::DrawableClassd=>d->GC->[Point]->IO()drawPointsdgc[]=return()drawPointsdgcpoints=withArray(concatMap(\(x,y)->[fromIntegralx,fromIntegraly])points)$\(aPtr::Ptr(CInt))->(\(Drawablearg1)(GCarg2)arg3arg4->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_pointsargPtr1argPtr2arg3arg4)(toDrawabled)(toGCgc)(castPtraPtr)(fromIntegral(lengthpoints))-- | Draw a line into a 'Drawable'.---- * The parameters are x1, y1, x2, y2.---- * Drawing several separate lines can be done more efficiently by-- 'drawSegments'.--drawLine::DrawableClassd=>d->GC->Point->Point->IO()drawLinedgc(x1,y1)(x2,y2)=(\(Drawablearg1)(GCarg2)arg3arg4arg5arg6->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_lineargPtr1argPtr2arg3arg4arg5arg6)(toDrawabled)(toGCgc)(fromIntegralx1)(fromIntegraly1)(fromIntegralx2)(fromIntegraly2)-- | Draw several lines.---- * The function uses the current line width, dashing and especially the-- joining specification in the graphics context (in contrast to-- 'drawSegments'.--drawLines::DrawableClassd=>d->GC->[Point]->IO()drawLinesdgc[]=return()drawLinesdgcpoints=withArray(concatMap(\(x,y)->[fromIntegralx,fromIntegraly])points)$\(aPtr::Ptr(CInt))->(\(Drawablearg1)(GCarg2)arg3arg4->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_linesargPtr1argPtr2arg3arg4)(toDrawabled)(toGCgc)(castPtraPtr)(fromIntegral(lengthpoints))-- | Render a 'Pixbuf'.---- * Usage:-- @drawPixbuf d gc pb srcX srcY destX destY srcWidth srcHeight dither@-- Renders a rectangular portion of a 'Pixbuf' to a-- 'Drawable'. The @srcX@, @srcY@,-- @srcWidth@ and @srcHeight@ specify what part of the-- 'Pixbuf' should be rendered. The latter two values may be-- @-1@ in which case the width and height are taken from-- @pb@. The image is placed at @destX@, @destY@.-- If you render parts of an image at a time, set @ditherX@ and-- @ditherY@ to the origin of the image you are rendering.---- * Since 2.2.--drawPixbuf::DrawableClassd=>d->GC->Pixbuf->Int->Int->Int->Int->Int->Int->Dither->Int->Int->IO()drawPixbufdgcpbsrcXsrcYdestXdestYsrcWidthsrcHeightditherxDitheryDither=(\(Drawablearg1)(GCarg2)(Pixbufarg3)arg4arg5arg6arg7arg8arg9arg10arg11arg12->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg3$\argPtr3->gdk_draw_pixbufargPtr1argPtr2argPtr3arg4arg5arg6arg7arg8arg9arg10arg11arg12)(toDrawabled)gcpb(fromIntegralsrcX)(fromIntegralsrcY)(fromIntegraldestX)(fromIntegraldestY)(fromIntegralsrcWidth)(fromIntegralsrcHeight)((fromIntegral.fromEnum)dither)(fromIntegralxDither)(fromIntegralyDither)-- | Draw several unconnected lines.---- * This method draws several unrelated lines.--drawSegments::DrawableClassd=>d->GC->[(Point,Point)]->IO()drawSegmentsdgc[]=return()drawSegmentsdgcpps=withArray(concatMap(\((x1,y1),(x2,y2))->[fromIntegralx1,fromIntegraly1,fromIntegralx2,fromIntegraly2])pps)$\(aPtr::Ptr(CInt))->(\(Drawablearg1)(GCarg2)arg3arg4->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_segmentsargPtr1argPtr2arg3arg4)(toDrawabled)(toGCgc)(castPtraPtr)(fromIntegral(lengthpps))-- | Draw a rectangular object.---- * Draws a rectangular outline or filled rectangle, using the-- foreground color and other attributes of the 'GC'.---- * A rectangle drawn filled is 1 pixel smaller in both dimensions-- than a rectangle outlined. Calling 'drawRectangle' w gc-- True 0 0 20 20 results in a filled rectangle 20 pixels wide and 20-- pixels high. Calling 'drawRectangle' d gc False 0 0 20 20-- results in an outlined rectangle with corners at (0, 0), (0, 20), (20,-- 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high.--drawRectangle::DrawableClassd=>d->GC->Bool->Int->Int->Int->Int->IO()drawRectangledgcfilledxywidthheight=(\(Drawablearg1)(GCarg2)arg3arg4arg5arg6arg7->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_rectangleargPtr1argPtr2arg3arg4arg5arg6arg7){-# LINE 225 "./Graphics/UI/Gtk/Gdk/Drawable.chs" #-}(toDrawabled)(toGCgc)(fromBoolfilled)(fromIntegralx)(fromIntegraly)(fromIntegralwidth)(fromIntegralheight)-- | Draws an arc or a filled 'pie slice'.---- * The arc is defined by the bounding rectangle of the entire-- ellipse, and the start and end angles of the part of the ellipse to be-- drawn.---- * The starting angle @aStart@ is relative to the 3 o'clock-- position, counter-clockwise, in 1\/64ths of a degree. @aEnd@-- is measured similarly, but relative to @aStart@.--drawArc::DrawableClassd=>d->GC->Bool->Int->Int->Int->Int->Int->Int->IO()drawArcdgcfilledxywidthheightaStartaEnd=(\(Drawablearg1)(GCarg2)arg3arg4arg5arg6arg7arg8arg9->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_arcargPtr1argPtr2arg3arg4arg5arg6arg7arg8arg9)(toDrawabled)(toGCgc)(fromBoolfilled)(fromIntegralx)(fromIntegraly)(fromIntegralwidth)(fromIntegralheight)(fromIntegralaStart)(fromIntegralaEnd)-- | Draws an outlined or filled polygon.---- * The polygon is closed automatically, connecting the last point to-- the first point if necessary.--drawPolygon::DrawableClassd=>d->GC->Bool->[Point]->IO()drawPolygon___[]=return()drawPolygondgcfilledpoints=withArray(concatMap(\(x,y)->[fromIntegralx,fromIntegraly])points)$\(aPtr::Ptr(CInt))->(\(Drawablearg1)(GCarg2)arg3arg4arg5->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_draw_polygonargPtr1argPtr2arg3arg4arg5)(toDrawabled)(toGCgc)(fromBoolfilled)(castPtraPtr)(fromIntegral(lengthpoints))-- | Draw a segment of text.---- * This function draws a segment of text. These segements are the result-- of itemizing a string into segments with the same characteristics-- (font, text direction, etc.) using-- 'Graphics.Rendering.Pango.Rendering.itemize'. Each item is then turned-- into a shapes by calling 'Graphics.Rendering.Pango.Rendering.shape'.-- These shapes can then be drawn onto screen using this function.-- A simpler interface, that also takes care of breaking a paragraph-- into several lines is a 'Graphics.Rendering.Pango.Layout.LayoutLine'.--drawGlyphs::DrawableClassd=>d->GC->Int->Int->GlyphItem->IO()drawGlyphsdgcxy(GlyphItempigs)=dofont<-pangoItemGetFontpi(\(Drawablearg1)(GCarg2)(Fontarg3)arg4arg5(GlyphStringRawarg6)->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg3$\argPtr3->withForeignPtrarg6$\argPtr6->gdk_draw_glyphsargPtr1argPtr2argPtr3arg4arg5argPtr6)(toDrawabled)(toGCgc)font(fromIntegralx)(fromIntegraly)gs---- | Draw a single line of text.---- * The @x@ coordinate specifies the start of the string,-- the @y@ coordinate specifies the base line.--drawLayoutLine::DrawableClassd=>d->GC->Int->Int->LayoutLine->IO()drawLayoutLinedgcxy(LayoutLine_ll)=(\(Drawablearg1)(GCarg2)arg3arg4(LayoutLineRawarg5)->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg5$\argPtr5->gdk_draw_layout_lineargPtr1argPtr2arg3arg4argPtr5)(toDrawabled)(toGCgc)(fromIntegralx)(fromIntegraly)ll-- | Draw a single line of text.---- * The @x@ coordinate specifies the start of the string,-- the @y@ coordinate specifies the base line.---- * If both colors are @Nothing@ this function will behave like-- 'drawLayoutLine' in that it uses the default colors from-- the graphics context.--drawLayoutLineWithColors::DrawableClassd=>d->GC->Int->Int->LayoutLine->MaybeColor->MaybeColor->IO()drawLayoutLineWithColorsdgcxy(LayoutLine_ll)foregroundbackground=letwithMB::Storablea=>Maybea->(Ptra->IOb)->IObwithMBNothingf=fnullPtrwithMB(Justx)f=withxfinwithMBforeground$\fPtr->withMBbackground$\bPtr->(\(Drawablearg1)(GCarg2)arg3arg4(LayoutLineRawarg5)arg6arg7->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg5$\argPtr5->gdk_draw_layout_line_with_colorsargPtr1argPtr2arg3arg4argPtr5arg6arg7)(toDrawabled)(toGCgc)(fromIntegralx)(fromIntegraly)ll(castPtrfPtr)(castPtrbPtr)-- | Draw a paragraph of text.---- * The @x@ and @y@ values specify the upper left-- point of the layout.--drawLayout::DrawableClassd=>d->GC->Int->Int->PangoLayout->IO()drawLayoutdgcxy(PangoLayout_pl)=(\(Drawablearg1)(GCarg2)arg3arg4(PangoLayoutRawarg5)->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg5$\argPtr5->gdk_draw_layoutargPtr1argPtr2arg3arg4argPtr5)(toDrawabled)(toGCgc)(fromIntegralx)(fromIntegraly)pl-- | Draw a paragraph of text.---- * The @x@ and @y@ values specify the upper left-- point of the layout.---- * If both colors are @Nothing@ this function will behave like-- 'drawLayout' in that it uses the default colors from-- the graphics context.--drawLayoutWithColors::DrawableClassd=>d->GC->Int->Int->PangoLayout->MaybeColor->MaybeColor->IO()drawLayoutWithColorsdgcxy(PangoLayout_pl)foregroundbackground=letwithMB::Storablea=>Maybea->(Ptra->IOb)->IObwithMBNothingf=fnullPtrwithMB(Justx)f=withxfinwithMBforeground$\fPtr->withMBbackground$\bPtr->(\(Drawablearg1)(GCarg2)arg3arg4(PangoLayoutRawarg5)arg6arg7->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg5$\argPtr5->gdk_draw_layout_with_colorsargPtr1argPtr2arg3arg4argPtr5arg6arg7)(toDrawabled)(toGCgc)(fromIntegralx)(fromIntegraly)pl(castPtrfPtr)(castPtrbPtr)-- | Copies another 'Drawable'.---- * Copies the (width,height) region of the @src@ at coordinates-- (@xSrc@, @ySrc@) to coordinates (@xDest@,-- @yDest@) in the @dest@. The @width@ and\/or-- @height@ may be given as -1, in which case the entire source-- drawable will be copied.---- * Most fields in @gc@ are not used for this operation, but-- notably the clip mask or clip region will be honored. The source and-- destination drawables must have the same visual and colormap, or-- errors will result. (On X11, failure to match visual\/colormap results-- in a BadMatch error from the X server.) A common cause of this-- problem is an attempt to draw a bitmap to a color drawable. The way to-- draw a bitmap is to set the bitmap as a clip mask on your-- 'GC', then use 'drawRectangle' to draw a-- rectangle clipped to the bitmap.--drawDrawable::(DrawableClasssrc,DrawableClassdest)=>dest->GC->src->Int->Int->Int->Int->Int->Int->IO()drawDrawabledestgcsrcxSrcySrcxDestyDestwidthheight=(\(Drawablearg1)(GCarg2)(Drawablearg3)arg4arg5arg6arg7arg8arg9->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->withForeignPtrarg3$\argPtr3->gdk_draw_drawableargPtr1argPtr2argPtr3arg4arg5arg6arg7arg8arg9)(toDrawabledest)(toGCgc)(toDrawablesrc)(fromIntegralxSrc)(fromIntegralySrc)(fromIntegralxDest)(fromIntegralyDest)(fromIntegralwidth)(fromIntegralheight)foreignimportccallunsafe"gdk_drawable_get_depth"gdk_drawable_get_depth::((PtrDrawable)->(IOCInt))foreignimportccallunsafe"gdk_drawable_get_size"gdk_drawable_get_size::((PtrDrawable)->((PtrCInt)->((PtrCInt)->(IO()))))foreignimportccallunsafe"gdk_drawable_get_clip_region"gdk_drawable_get_clip_region::((PtrDrawable)->(IO(PtrRegion)))foreignimportccallunsafe"gdk_drawable_get_visible_region"gdk_drawable_get_visible_region::((PtrDrawable)->(IO(PtrRegion)))foreignimportccallunsafe"gdk_draw_point"gdk_draw_point::((PtrDrawable)->((PtrGC)->(CInt->(CInt->(IO())))))foreignimportccallunsafe"gdk_draw_points"gdk_draw_points::((PtrDrawable)->((PtrGC)->((Ptr())->(CInt->(IO())))))foreignimportccallunsafe"gdk_draw_line"gdk_draw_line::((PtrDrawable)->((PtrGC)->(CInt->(CInt->(CInt->(CInt->(IO())))))))foreignimportccallunsafe"gdk_draw_lines"gdk_draw_lines::((PtrDrawable)->((PtrGC)->((Ptr())->(CInt->(IO())))))foreignimportccallunsafe"gdk_draw_pixbuf"gdk_draw_pixbuf::((PtrDrawable)->((PtrGC)->((PtrPixbuf)->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(IO())))))))))))))foreignimportccallunsafe"gdk_draw_segments"gdk_draw_segments::((PtrDrawable)->((PtrGC)->((Ptr())->(CInt->(IO())))))foreignimportccallunsafe"gdk_draw_rectangle"gdk_draw_rectangle::((PtrDrawable)->((PtrGC)->(CInt->(CInt->(CInt->(CInt->(CInt->(IO()))))))))foreignimportccallunsafe"gdk_draw_arc"gdk_draw_arc::((PtrDrawable)->((PtrGC)->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(IO()))))))))))foreignimportccallunsafe"gdk_draw_polygon"gdk_draw_polygon::((PtrDrawable)->((PtrGC)->(CInt->((Ptr())->(CInt->(IO()))))))foreignimportccallunsafe"gdk_draw_glyphs"gdk_draw_glyphs::((PtrDrawable)->((PtrGC)->((PtrFont)->(CInt->(CInt->((PtrGlyphStringRaw)->(IO())))))))foreignimportccallunsafe"gdk_draw_layout_line"gdk_draw_layout_line::((PtrDrawable)->((PtrGC)->(CInt->(CInt->((PtrLayoutLineRaw)->(IO()))))))foreignimportccallunsafe"gdk_draw_layout_line_with_colors"gdk_draw_layout_line_with_colors::((PtrDrawable)->((PtrGC)->(CInt->(CInt->((PtrLayoutLineRaw)->((Ptr())->((Ptr())->(IO()))))))))foreignimportccallunsafe"gdk_draw_layout"gdk_draw_layout::((PtrDrawable)->((PtrGC)->(CInt->(CInt->((PtrPangoLayoutRaw)->(IO()))))))foreignimportccallunsafe"gdk_draw_layout_with_colors"gdk_draw_layout_with_colors::((PtrDrawable)->((PtrGC)->(CInt->(CInt->((PtrPangoLayoutRaw)->((Ptr())->((Ptr())->(IO()))))))))foreignimportccallunsafe"gdk_draw_drawable"gdk_draw_drawable::((PtrDrawable)->((PtrGC)->((PtrDrawable)->(CInt->(CInt->(CInt->(CInt->(CInt->(CInt->(IO()))))))))))