{-# LINE 2 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}-- -*-haskell-*--- GIMP Toolkit (GTK) Cursor---- Author : Bit Connor <bit@mutantlemon.com>-- Andy Stewart <lazycat.manatee@gmail.com>---- Created: 18 November 2007---- Copyright (C) 2007 Bit Connor-- Copyright (C) 2009 Andy Stewart---- 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.---- |-- Maintainer : gtk2hs-users@lists.sourceforge.net-- Stability : provisional-- Portability : portable (depends on GHC)---- Cursors | Standard and pixmap cursors.--moduleGraphics.UI.Gtk.Gdk.Cursor(-- * TypesCursor(..),-- * EnumsCursorType(..),-- * ConstructorscursorNew,-- * MethodscursorNewFromPixmap,cursorNewFromPixbuf,cursorNewFromName,cursorNewForDisplay,cursorGetDisplay,cursorGetImage)whereimportControl.Monad(liftM)importSystem.Glib.FFIimportSystem.Glib.UTFStringimportForeign.ForeignPtr(ForeignPtr,castForeignPtr,unsafeForeignPtrToPtr)importGraphics.UI.Gtk.General.StructsimportGraphics.UI.Gtk.Typeshiding(Arrow){-# LINE 59 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}---------------------- TypesnewtypeCursor=Cursor(ForeignPtr(Cursor)){-# LINE 63 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}---------------------- Enums-- | Cursor types.dataCursorType=XCursor|Arrow|BasedArrowDown|BasedArrowUp|Boat|Bogosity|BottomLeftCorner|BottomRightCorner|BottomSide|BottomTee|BoxSpiral|CenterPtr|Circle|Clock|CoffeeMug|Cross|CrossReverse|Crosshair|DiamondCross|Dot|Dotbox|DoubleArrow|DraftLarge|DraftSmall|DrapedBox|Exchange|Fleur|Gobbler|Gumby|Hand1|Hand2|Heart|Icon|IronCross|LeftPtr|LeftSide|LeftTee|Leftbutton|LlAngle|LrAngle|Man|Middlebutton|Mouse|Pencil|Pirate|Plus|QuestionArrow|RightPtr|RightSide|RightTee|Rightbutton|RtlLogo|Sailboat|SbDownArrow|SbHDoubleArrow|SbLeftArrow|SbRightArrow|SbUpArrow|SbVDoubleArrow|Shuttle|Sizing|Spider|Spraycan|Star|Target|Tcross|TopLeftArrow|TopLeftCorner|TopRightCorner|TopSide|TopTee|Trek|UlAngle|Umbrella|UrAngle|Watch|Xterm|LastCursor|BlankCursor|CursorIsPixmapderiving(Bounded,Eq,Show)instanceEnumCursorTypewherefromEnumXCursor=0fromEnumArrow=2fromEnumBasedArrowDown=4fromEnumBasedArrowUp=6fromEnumBoat=8fromEnumBogosity=10fromEnumBottomLeftCorner=12fromEnumBottomRightCorner=14fromEnumBottomSide=16fromEnumBottomTee=18fromEnumBoxSpiral=20fromEnumCenterPtr=22fromEnumCircle=24fromEnumClock=26fromEnumCoffeeMug=28fromEnumCross=30fromEnumCrossReverse=32fromEnumCrosshair=34fromEnumDiamondCross=36fromEnumDot=38fromEnumDotbox=40fromEnumDoubleArrow=42fromEnumDraftLarge=44fromEnumDraftSmall=46fromEnumDrapedBox=48fromEnumExchange=50fromEnumFleur=52fromEnumGobbler=54fromEnumGumby=56fromEnumHand1=58fromEnumHand2=60fromEnumHeart=62fromEnumIcon=64fromEnumIronCross=66fromEnumLeftPtr=68fromEnumLeftSide=70fromEnumLeftTee=72fromEnumLeftbutton=74fromEnumLlAngle=76fromEnumLrAngle=78fromEnumMan=80fromEnumMiddlebutton=82fromEnumMouse=84fromEnumPencil=86fromEnumPirate=88fromEnumPlus=90fromEnumQuestionArrow=92fromEnumRightPtr=94fromEnumRightSide=96fromEnumRightTee=98fromEnumRightbutton=100fromEnumRtlLogo=102fromEnumSailboat=104fromEnumSbDownArrow=106fromEnumSbHDoubleArrow=108fromEnumSbLeftArrow=110fromEnumSbRightArrow=112fromEnumSbUpArrow=114fromEnumSbVDoubleArrow=116fromEnumShuttle=118fromEnumSizing=120fromEnumSpider=122fromEnumSpraycan=124fromEnumStar=126fromEnumTarget=128fromEnumTcross=130fromEnumTopLeftArrow=132fromEnumTopLeftCorner=134fromEnumTopRightCorner=136fromEnumTopSide=138fromEnumTopTee=140fromEnumTrek=142fromEnumUlAngle=144fromEnumUmbrella=146fromEnumUrAngle=148fromEnumWatch=150fromEnumXterm=152fromEnumLastCursor=153fromEnumBlankCursor=(-2)fromEnumCursorIsPixmap=(-1)toEnum0=XCursortoEnum2=ArrowtoEnum4=BasedArrowDowntoEnum6=BasedArrowUptoEnum8=BoattoEnum10=BogositytoEnum12=BottomLeftCornertoEnum14=BottomRightCornertoEnum16=BottomSidetoEnum18=BottomTeetoEnum20=BoxSpiraltoEnum22=CenterPtrtoEnum24=CircletoEnum26=ClocktoEnum28=CoffeeMugtoEnum30=CrosstoEnum32=CrossReversetoEnum34=CrosshairtoEnum36=DiamondCrosstoEnum38=DottoEnum40=DotboxtoEnum42=DoubleArrowtoEnum44=DraftLargetoEnum46=DraftSmalltoEnum48=DrapedBoxtoEnum50=ExchangetoEnum52=FleurtoEnum54=GobblertoEnum56=GumbytoEnum58=Hand1toEnum60=Hand2toEnum62=HearttoEnum64=IcontoEnum66=IronCrosstoEnum68=LeftPtrtoEnum70=LeftSidetoEnum72=LeftTeetoEnum74=LeftbuttontoEnum76=LlAngletoEnum78=LrAngletoEnum80=MantoEnum82=MiddlebuttontoEnum84=MousetoEnum86=PenciltoEnum88=PiratetoEnum90=PlustoEnum92=QuestionArrowtoEnum94=RightPtrtoEnum96=RightSidetoEnum98=RightTeetoEnum100=RightbuttontoEnum102=RtlLogotoEnum104=SailboattoEnum106=SbDownArrowtoEnum108=SbHDoubleArrowtoEnum110=SbLeftArrowtoEnum112=SbRightArrowtoEnum114=SbUpArrowtoEnum116=SbVDoubleArrowtoEnum118=ShuttletoEnum120=SizingtoEnum122=SpidertoEnum124=SpraycantoEnum126=StartoEnum128=TargettoEnum130=TcrosstoEnum132=TopLeftArrowtoEnum134=TopLeftCornertoEnum136=TopRightCornertoEnum138=TopSidetoEnum140=TopTeetoEnum142=TrektoEnum144=UlAngletoEnum146=UmbrellatoEnum148=UrAngletoEnum150=WatchtoEnum152=XtermtoEnum153=LastCursortoEnum(-2)=BlankCursortoEnum(-1)=CursorIsPixmaptoEnumunmatched=error("CursorType.toEnum: Cannot match "++showunmatched)succXCursor=ArrowsuccArrow=BasedArrowDownsuccBasedArrowDown=BasedArrowUpsuccBasedArrowUp=BoatsuccBoat=BogositysuccBogosity=BottomLeftCornersuccBottomLeftCorner=BottomRightCornersuccBottomRightCorner=BottomSidesuccBottomSide=BottomTeesuccBottomTee=BoxSpiralsuccBoxSpiral=CenterPtrsuccCenterPtr=CirclesuccCircle=ClocksuccClock=CoffeeMugsuccCoffeeMug=CrosssuccCross=CrossReversesuccCrossReverse=CrosshairsuccCrosshair=DiamondCrosssuccDiamondCross=DotsuccDot=DotboxsuccDotbox=DoubleArrowsuccDoubleArrow=DraftLargesuccDraftLarge=DraftSmallsuccDraftSmall=DrapedBoxsuccDrapedBox=ExchangesuccExchange=FleursuccFleur=GobblersuccGobbler=GumbysuccGumby=Hand1succHand1=Hand2succHand2=HeartsuccHeart=IconsuccIcon=IronCrosssuccIronCross=LeftPtrsuccLeftPtr=LeftSidesuccLeftSide=LeftTeesuccLeftTee=LeftbuttonsuccLeftbutton=LlAnglesuccLlAngle=LrAnglesuccLrAngle=MansuccMan=MiddlebuttonsuccMiddlebutton=MousesuccMouse=PencilsuccPencil=PiratesuccPirate=PlussuccPlus=QuestionArrowsuccQuestionArrow=RightPtrsuccRightPtr=RightSidesuccRightSide=RightTeesuccRightTee=RightbuttonsuccRightbutton=RtlLogosuccRtlLogo=SailboatsuccSailboat=SbDownArrowsuccSbDownArrow=SbHDoubleArrowsuccSbHDoubleArrow=SbLeftArrowsuccSbLeftArrow=SbRightArrowsuccSbRightArrow=SbUpArrowsuccSbUpArrow=SbVDoubleArrowsuccSbVDoubleArrow=ShuttlesuccShuttle=SizingsuccSizing=SpidersuccSpider=SpraycansuccSpraycan=StarsuccStar=TargetsuccTarget=TcrosssuccTcross=TopLeftArrowsuccTopLeftArrow=TopLeftCornersuccTopLeftCorner=TopRightCornersuccTopRightCorner=TopSidesuccTopSide=TopTeesuccTopTee=TreksuccTrek=UlAnglesuccUlAngle=UmbrellasuccUmbrella=UrAnglesuccUrAngle=WatchsuccWatch=XtermsuccXterm=LastCursorsuccLastCursor=BlankCursorsuccBlankCursor=CursorIsPixmapsucc_=undefinedpredArrow=XCursorpredBasedArrowDown=ArrowpredBasedArrowUp=BasedArrowDownpredBoat=BasedArrowUppredBogosity=BoatpredBottomLeftCorner=BogositypredBottomRightCorner=BottomLeftCornerpredBottomSide=BottomRightCornerpredBottomTee=BottomSidepredBoxSpiral=BottomTeepredCenterPtr=BoxSpiralpredCircle=CenterPtrpredClock=CirclepredCoffeeMug=ClockpredCross=CoffeeMugpredCrossReverse=CrosspredCrosshair=CrossReversepredDiamondCross=CrosshairpredDot=DiamondCrosspredDotbox=DotpredDoubleArrow=DotboxpredDraftLarge=DoubleArrowpredDraftSmall=DraftLargepredDrapedBox=DraftSmallpredExchange=DrapedBoxpredFleur=ExchangepredGobbler=FleurpredGumby=GobblerpredHand1=GumbypredHand2=Hand1predHeart=Hand2predIcon=HeartpredIronCross=IconpredLeftPtr=IronCrosspredLeftSide=LeftPtrpredLeftTee=LeftSidepredLeftbutton=LeftTeepredLlAngle=LeftbuttonpredLrAngle=LlAnglepredMan=LrAnglepredMiddlebutton=ManpredMouse=MiddlebuttonpredPencil=MousepredPirate=PencilpredPlus=PiratepredQuestionArrow=PluspredRightPtr=QuestionArrowpredRightSide=RightPtrpredRightTee=RightSidepredRightbutton=RightTeepredRtlLogo=RightbuttonpredSailboat=RtlLogopredSbDownArrow=SailboatpredSbHDoubleArrow=SbDownArrowpredSbLeftArrow=SbHDoubleArrowpredSbRightArrow=SbLeftArrowpredSbUpArrow=SbRightArrowpredSbVDoubleArrow=SbUpArrowpredShuttle=SbVDoubleArrowpredSizing=ShuttlepredSpider=SizingpredSpraycan=SpiderpredStar=SpraycanpredTarget=StarpredTcross=TargetpredTopLeftArrow=TcrosspredTopLeftCorner=TopLeftArrowpredTopRightCorner=TopLeftCornerpredTopSide=TopRightCornerpredTopTee=TopSidepredTrek=TopTeepredUlAngle=TrekpredUmbrella=UlAnglepredUrAngle=UmbrellapredWatch=UrAnglepredXterm=WatchpredLastCursor=XtermpredBlankCursor=LastCursorpredCursorIsPixmap=BlankCursorpred_=undefinedenumFromToxy|fromEnumx==fromEnumy=[y]|otherwise=x:enumFromTo(succx)yenumFromx=enumFromToxCursorIsPixmapenumFromThen__=error"Enum CursorType: enumFromThen not implemented"enumFromThenTo___=error"Enum CursorType: enumFromThenTo not implemented"{-# LINE 68 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}---------------------- UtilsmakeNewCursor::PtrCursor->IOCursormakeNewCursorrPtr=docursor<-newForeignPtrrPtrcursor_unrefreturn(Cursorcursor)foreignimportccallunsafe"&gdk_cursor_unref"cursor_unref::FinalizerPtrCursor---------------------- Constructors-- | Creates a new cursor from the set of builtin cursors for the default display.-- See 'cursorNewForDisplay'.-- To make the cursor invisible, use 'BlankCursor'.cursorNew::CursorType-- ^ @cursorType@ cursor to create->IOCursor-- ^ return a new 'Cursor'cursorNewcursorType=docursorPtr<-gdk_cursor_new$fromIntegral(fromEnumcursorType)makeNewCursorcursorPtr---------------------- Methods-- | Creates a new cursor from a given pixmap and mask. Both the pixmap and-- mask must have a depth of 1 (i.e. each pixel has only 2 values - on or off).-- The standard cursor size is 16 by 16 pixels.--cursorNewFromPixmap::Pixmap-- ^ @source@ - the pixmap specifying the cursor.->Pixmap-- ^ @mask@ - the pixmap specifying the mask, which must be the-- same size as source.->Color-- ^ @fg@ - the foreground color, used for the bits in the source-- which are 1. The color does not have to be allocated first.->Color-- ^ @bg@ - the background color, used for the bits in the source-- which are 0. The color does not have to be allocated first.->Int-- ^ @x@ - the horizontal offset of the \'hotspot\' of the cursor.->Int-- ^ @y@ - the vertical offset of the \'hotspot\' of the cursor.->IOCursorcursorNewFromPixmapsourcemaskfgbgxy=withfg$\fgPtr->withbg$\bgPtr->dorPtr<-(\(Pixmaparg1)(Pixmaparg2)arg3arg4arg5arg6->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_cursor_new_from_pixmapargPtr1argPtr2arg3arg4arg5arg6)sourcemask(castPtrfgPtr)(castPtrbgPtr)(fromIntegralx)(fromIntegraly)makeNewCursorrPtr-- | Creates a new cursor from a pixbuf.-- Not all GDK backends support RGBA cursors. If they are not supported, a monochrome approximation will be displayed.-- The functions 'displaySupportsCursorAlpha' and 'displaySupportsCursorColor' can be used to determine whether RGBA cursors are supported;-- 'displayGetDefaultCursorSize' and 'displayGetMaximalCursorSize' give information about cursor sizes.---- On the X backend, support for RGBA cursors requires a sufficently new version of the X Render extension.--cursorNewFromPixbuf::Display-- ^ @display@ the 'Display' for which the cursor will be created->Pixbuf-- ^ @pixbuf@ the 'Pixbuf' containing the cursor image->Int-- ^ @x@ the horizontal offset of the 'hotspot' of the cursor.->Int-- ^ @y@ the vertical offset of the 'hotspot' of the cursor.->IOCursor-- ^ return a new 'Cursor'.cursorNewFromPixbufdisplaypixbufxy=docursorPtr<-(\(Displayarg1)(Pixbufarg2)arg3arg4->withForeignPtrarg1$\argPtr1->withForeignPtrarg2$\argPtr2->gdk_cursor_new_from_pixbufargPtr1argPtr2arg3arg4)displaypixbuf(fromIntegralx)(fromIntegraly)makeNewCursorcursorPtr-- | Creates a new cursor by looking up name in the current cursor theme.cursorNewFromName::Display-- ^ @display@ the 'Display' for which the cursor will be created->String-- ^ @name@ the name of the cursor->IO(MaybeCursor)-- ^ return a new 'Cursor', or @Nothing@ if there is no cursor with the given namecursorNewFromNamedisplayname=withUTFStringname$\namePtr->docursorPtr<-(\(Displayarg1)arg2->withForeignPtrarg1$\argPtr1->gdk_cursor_new_from_nameargPtr1arg2)displaynamePtrifcursorPtr==nullPtrthenreturnNothingelseliftMJust$makeNewCursorcursorPtr-- | Creates a new cursor from the set of builtin cursors.cursorNewForDisplay::Display-- ^ @display@ the 'Display' for which the cursor will be created->CursorType-- ^ @cursorType@ cursor to create->IOCursor-- ^ return a new 'Cursor'cursorNewForDisplaydisplaycursorType=docursorPtr<-(\(Displayarg1)arg2->withForeignPtrarg1$\argPtr1->gdk_cursor_new_for_displayargPtr1arg2)display$fromIntegral(fromEnumcursorType)makeNewCursorcursorPtr-- | Returns the display on which the GdkCursor is defined.cursorGetDisplay::Cursor-- ^ @cursor@ 'Cursor'->IODisplay-- ^ return the 'Display' associated to cursorcursorGetDisplaycursor=makeNewGObjectmkDisplay$(\(Cursorarg1)->withForeignPtrarg1$\argPtr1->gdk_cursor_get_displayargPtr1)cursor-- | Returns a 'Pixbuf' with the image used to display the cursor.-- Note that depending on the capabilities of the windowing system and on the cursor, GDK may not be able to obtain the image data.-- In this case, @Nothing@ is returned.cursorGetImage::Cursor-- ^ @cursor@ 'Cursor'->IO(MaybePixbuf)-- ^ a 'Pixbuf' representing cursor, or @Nothing@cursorGetImagecursor=maybeNull(makeNewGObjectmkPixbuf)$(\(Cursorarg1)->withForeignPtrarg1$\argPtr1->gdk_cursor_get_imageargPtr1)cursorforeignimportccallsafe"gdk_cursor_new"gdk_cursor_new::(CInt->(IO(PtrCursor)))foreignimportccallunsafe"gdk_cursor_new_from_pixmap"gdk_cursor_new_from_pixmap::((PtrPixmap)->((PtrPixmap)->((Ptr())->((Ptr())->(CInt->(CInt->(IO(PtrCursor))))))))foreignimportccallsafe"gdk_cursor_new_from_pixbuf"gdk_cursor_new_from_pixbuf::((PtrDisplay)->((PtrPixbuf)->(CInt->(CInt->(IO(PtrCursor))))))foreignimportccallsafe"gdk_cursor_new_from_name"gdk_cursor_new_from_name::((PtrDisplay)->((PtrCChar)->(IO(PtrCursor))))foreignimportccallsafe"gdk_cursor_new_for_display"gdk_cursor_new_for_display::((PtrDisplay)->(CInt->(IO(PtrCursor))))foreignimportccallsafe"gdk_cursor_get_display"gdk_cursor_get_display::((PtrCursor)->(IO(PtrDisplay)))foreignimportccallsafe"gdk_cursor_get_image"gdk_cursor_get_image::((PtrCursor)->(IO(PtrPixbuf)))