{-# 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.
--
module Graphics.UI.Gtk.Gdk.Cursor (
-- * Types
  Cursor(..),

-- * Enums
  CursorType(..),

-- * Constructors
  cursorNew,

-- * Methods



  cursorNewFromPixbuf,
  cursorNewFromName,
  cursorNewForDisplay,
  cursorGetDisplay,
  cursorGetImage
  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.UTFString




import Graphics.UI.Gtk.Types hiding (Arrow)


{-# LINE 62 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}

--------------------
-- Types
newtype Cursor = Cursor (ForeignPtr (Cursor))
{-# LINE 66 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}

--------------------
-- Enums
-- | Cursor types.
data CursorType = 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
                | CursorIsPixmap
                deriving (CursorType
CursorType -> CursorType -> Bounded CursorType
forall a. a -> a -> Bounded a
$cminBound :: CursorType
minBound :: CursorType
$cmaxBound :: CursorType
maxBound :: CursorType
Bounded,CursorType -> CursorType -> Bool
(CursorType -> CursorType -> Bool)
-> (CursorType -> CursorType -> Bool) -> Eq CursorType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CursorType -> CursorType -> Bool
== :: CursorType -> CursorType -> Bool
$c/= :: CursorType -> CursorType -> Bool
/= :: CursorType -> CursorType -> Bool
Eq,Int -> CursorType -> ShowS
[CursorType] -> ShowS
CursorType -> String
(Int -> CursorType -> ShowS)
-> (CursorType -> String)
-> ([CursorType] -> ShowS)
-> Show CursorType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CursorType -> ShowS
showsPrec :: Int -> CursorType -> ShowS
$cshow :: CursorType -> String
show :: CursorType -> String
$cshowList :: [CursorType] -> ShowS
showList :: [CursorType] -> ShowS
Show)
instance Enum CursorType where
  fromEnum XCursor = 0
  fromEnum Arrow = 2
  fromEnum BasedArrowDown = 4
  fromEnum BasedArrowUp = 6
  fromEnum Boat = 8
  fromEnum Bogosity = 10
  fromEnum BottomLeftCorner = 12
  fromEnum BottomRightCorner = 14
  fromEnum BottomSide = 16
  fromEnum BottomTee = 18
  fromEnum BoxSpiral = 20
  fromEnum CenterPtr = 22
  fromEnum Circle = 24
  fromEnum Clock = 26
  fromEnum CoffeeMug = 28
  fromEnum Cross = 30
  fromEnum CrossReverse = 32
  fromEnum Crosshair = 34
  fromEnum DiamondCross = 36
  fromEnum Dot = 38
  fromEnum Dotbox = 40
  fromEnum DoubleArrow = 42
  fromEnum DraftLarge = 44
  fromEnum DraftSmall = 46
  fromEnum DrapedBox = 48
  fromEnum Exchange = 50
  fromEnum Fleur = 52
  fromEnum Gobbler = 54
  fromEnum Gumby = 56
  fromEnum Hand1 = 58
  fromEnum Hand2 = 60
  fromEnum Heart = 62
  fromEnum Icon = 64
  fromEnum IronCross = 66
  fromEnum LeftPtr = 68
  fromEnum LeftSide = 70
  fromEnum LeftTee = 72
  fromEnum Leftbutton = 74
  fromEnum LlAngle = 76
  fromEnum LrAngle = 78
  fromEnum Man = 80
  fromEnum Middlebutton = 82
  fromEnum Mouse = 84
  fromEnum Pencil = 86
  fromEnum Pirate = 88
  fromEnum Plus = 90
  fromEnum QuestionArrow = 92
  fromEnum RightPtr = 94
  fromEnum RightSide = 96
  fromEnum RightTee = 98
  fromEnum Rightbutton = 100
  fromEnum RtlLogo = 102
  fromEnum Sailboat = 104
  fromEnum SbDownArrow = 106
  fromEnum SbHDoubleArrow = 108
  fromEnum SbLeftArrow = 110
  fromEnum SbRightArrow = 112
  fromEnum SbUpArrow = 114
  fromEnum SbVDoubleArrow = 116
  fromEnum Shuttle = 118
  fromEnum Sizing = 120
  fromEnum Spider = 122
  fromEnum Spraycan = 124
  fromEnum Star = 126
  fromEnum Target = 128
  fromEnum Tcross = 130
  fromEnum TopLeftArrow = 132
  fromEnum TopLeftCorner = 134
  fromEnum TopRightCorner = 136
  fromEnum TopSide = 138
  fromEnum TopTee = 140
  fromEnum Trek = 142
  fromEnum UlAngle = 144
  fromEnum Umbrella = 146
  fromEnum UrAngle = 148
  fromEnum Watch = 150
  fromEnum Xterm = 152
  fromEnum LastCursor = 153
  fromEnum BlankCursor = (-2)
  fromEnum CursorIsPixmap = (-1)

  toEnum :: Int -> CursorType
toEnum Int
0 = CursorType
XCursor
  toEnum Int
2 = CursorType
Arrow
  toEnum Int
4 = CursorType
BasedArrowDown
  toEnum Int
6 = CursorType
BasedArrowUp
  toEnum Int
8 = CursorType
Boat
  toEnum Int
10 = CursorType
Bogosity
  toEnum Int
12 = CursorType
BottomLeftCorner
  toEnum Int
14 = CursorType
BottomRightCorner
  toEnum Int
16 = CursorType
BottomSide
  toEnum Int
18 = CursorType
BottomTee
  toEnum Int
20 = CursorType
BoxSpiral
  toEnum Int
22 = CursorType
CenterPtr
  toEnum Int
24 = CursorType
Circle
  toEnum Int
26 = CursorType
Clock
  toEnum Int
28 = CursorType
CoffeeMug
  toEnum Int
30 = CursorType
Cross
  toEnum Int
32 = CursorType
CrossReverse
  toEnum Int
34 = CursorType
Crosshair
  toEnum Int
36 = CursorType
DiamondCross
  toEnum Int
38 = CursorType
Dot
  toEnum Int
40 = CursorType
Dotbox
  toEnum Int
42 = CursorType
DoubleArrow
  toEnum Int
44 = CursorType
DraftLarge
  toEnum Int
46 = CursorType
DraftSmall
  toEnum Int
48 = CursorType
DrapedBox
  toEnum Int
50 = CursorType
Exchange
  toEnum Int
52 = CursorType
Fleur
  toEnum Int
54 = CursorType
Gobbler
  toEnum Int
56 = CursorType
Gumby
  toEnum Int
58 = CursorType
Hand1
  toEnum Int
60 = CursorType
Hand2
  toEnum Int
62 = CursorType
Heart
  toEnum Int
64 = CursorType
Icon
  toEnum Int
66 = CursorType
IronCross
  toEnum Int
68 = CursorType
LeftPtr
  toEnum Int
70 = CursorType
LeftSide
  toEnum Int
72 = CursorType
LeftTee
  toEnum Int
74 = CursorType
Leftbutton
  toEnum Int
76 = CursorType
LlAngle
  toEnum Int
78 = CursorType
LrAngle
  toEnum Int
80 = CursorType
Man
  toEnum Int
82 = CursorType
Middlebutton
  toEnum Int
84 = CursorType
Mouse
  toEnum Int
86 = CursorType
Pencil
  toEnum Int
88 = CursorType
Pirate
  toEnum Int
90 = CursorType
Plus
  toEnum Int
92 = CursorType
QuestionArrow
  toEnum Int
94 = CursorType
RightPtr
  toEnum Int
96 = CursorType
RightSide
  toEnum Int
98 = CursorType
RightTee
  toEnum Int
100 = CursorType
Rightbutton
  toEnum Int
102 = CursorType
RtlLogo
  toEnum Int
104 = CursorType
Sailboat
  toEnum Int
106 = CursorType
SbDownArrow
  toEnum Int
108 = CursorType
SbHDoubleArrow
  toEnum Int
110 = CursorType
SbLeftArrow
  toEnum Int
112 = CursorType
SbRightArrow
  toEnum Int
114 = CursorType
SbUpArrow
  toEnum Int
116 = CursorType
SbVDoubleArrow
  toEnum Int
118 = CursorType
Shuttle
  toEnum Int
120 = CursorType
Sizing
  toEnum Int
122 = CursorType
Spider
  toEnum Int
124 = CursorType
Spraycan
  toEnum Int
126 = CursorType
Star
  toEnum Int
128 = CursorType
Target
  toEnum Int
130 = CursorType
Tcross
  toEnum Int
132 = CursorType
TopLeftArrow
  toEnum Int
134 = CursorType
TopLeftCorner
  toEnum Int
136 = CursorType
TopRightCorner
  toEnum Int
138 = CursorType
TopSide
  toEnum Int
140 = CursorType
TopTee
  toEnum Int
142 = CursorType
Trek
  toEnum Int
144 = CursorType
UlAngle
  toEnum Int
146 = CursorType
Umbrella
  toEnum Int
148 = CursorType
UrAngle
  toEnum Int
150 = CursorType
Watch
  toEnum Int
152 = CursorType
Xterm
  toEnum Int
153 = CursorType
LastCursor
  toEnum (-2) = CursorType
BlankCursor
  toEnum (-1) = CursorType
CursorIsPixmap
  toEnum Int
unmatched = String -> CursorType
forall a. HasCallStack => String -> a
error (String
"CursorType.toEnum: Cannot match " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
unmatched)

  succ :: CursorType -> CursorType
succ CursorType
XCursor = CursorType
Arrow
  succ CursorType
Arrow = CursorType
BasedArrowDown
  succ CursorType
BasedArrowDown = CursorType
BasedArrowUp
  succ CursorType
BasedArrowUp = CursorType
Boat
  succ CursorType
Boat = CursorType
Bogosity
  succ CursorType
Bogosity = CursorType
BottomLeftCorner
  succ CursorType
BottomLeftCorner = CursorType
BottomRightCorner
  succ CursorType
BottomRightCorner = CursorType
BottomSide
  succ CursorType
BottomSide = CursorType
BottomTee
  succ CursorType
BottomTee = CursorType
BoxSpiral
  succ CursorType
BoxSpiral = CursorType
CenterPtr
  succ CursorType
CenterPtr = CursorType
Circle
  succ CursorType
Circle = CursorType
Clock
  succ CursorType
Clock = CursorType
CoffeeMug
  succ CursorType
CoffeeMug = CursorType
Cross
  succ CursorType
Cross = CursorType
CrossReverse
  succ CursorType
CrossReverse = CursorType
Crosshair
  succ CursorType
Crosshair = CursorType
DiamondCross
  succ CursorType
DiamondCross = CursorType
Dot
  succ CursorType
Dot = CursorType
Dotbox
  succ CursorType
Dotbox = CursorType
DoubleArrow
  succ CursorType
DoubleArrow = CursorType
DraftLarge
  succ CursorType
DraftLarge = CursorType
DraftSmall
  succ CursorType
DraftSmall = CursorType
DrapedBox
  succ CursorType
DrapedBox = CursorType
Exchange
  succ CursorType
Exchange = CursorType
Fleur
  succ CursorType
Fleur = CursorType
Gobbler
  succ CursorType
Gobbler = CursorType
Gumby
  succ CursorType
Gumby = CursorType
Hand1
  succ CursorType
Hand1 = CursorType
Hand2
  succ CursorType
Hand2 = CursorType
Heart
  succ CursorType
Heart = CursorType
Icon
  succ CursorType
Icon = CursorType
IronCross
  succ CursorType
IronCross = CursorType
LeftPtr
  succ CursorType
LeftPtr = CursorType
LeftSide
  succ CursorType
LeftSide = CursorType
LeftTee
  succ CursorType
LeftTee = CursorType
Leftbutton
  succ CursorType
Leftbutton = CursorType
LlAngle
  succ CursorType
LlAngle = CursorType
LrAngle
  succ CursorType
LrAngle = CursorType
Man
  succ CursorType
Man = CursorType
Middlebutton
  succ CursorType
Middlebutton = CursorType
Mouse
  succ CursorType
Mouse = CursorType
Pencil
  succ CursorType
Pencil = CursorType
Pirate
  succ CursorType
Pirate = CursorType
Plus
  succ CursorType
Plus = CursorType
QuestionArrow
  succ CursorType
QuestionArrow = CursorType
RightPtr
  succ CursorType
RightPtr = CursorType
RightSide
  succ CursorType
RightSide = CursorType
RightTee
  succ CursorType
RightTee = CursorType
Rightbutton
  succ CursorType
Rightbutton = CursorType
RtlLogo
  succ CursorType
RtlLogo = CursorType
Sailboat
  succ CursorType
Sailboat = CursorType
SbDownArrow
  succ CursorType
SbDownArrow = CursorType
SbHDoubleArrow
  succ CursorType
SbHDoubleArrow = CursorType
SbLeftArrow
  succ CursorType
SbLeftArrow = CursorType
SbRightArrow
  succ CursorType
SbRightArrow = CursorType
SbUpArrow
  succ CursorType
SbUpArrow = CursorType
SbVDoubleArrow
  succ CursorType
SbVDoubleArrow = CursorType
Shuttle
  succ CursorType
Shuttle = CursorType
Sizing
  succ CursorType
Sizing = CursorType
Spider
  succ CursorType
Spider = CursorType
Spraycan
  succ CursorType
Spraycan = CursorType
Star
  succ CursorType
Star = CursorType
Target
  succ CursorType
Target = CursorType
Tcross
  succ CursorType
Tcross = CursorType
TopLeftArrow
  succ CursorType
TopLeftArrow = CursorType
TopLeftCorner
  succ CursorType
TopLeftCorner = CursorType
TopRightCorner
  succ CursorType
TopRightCorner = CursorType
TopSide
  succ CursorType
TopSide = CursorType
TopTee
  succ CursorType
TopTee = CursorType
Trek
  succ CursorType
Trek = CursorType
UlAngle
  succ CursorType
UlAngle = CursorType
Umbrella
  succ CursorType
Umbrella = CursorType
UrAngle
  succ CursorType
UrAngle = CursorType
Watch
  succ CursorType
Watch = CursorType
Xterm
  succ CursorType
Xterm = CursorType
LastCursor
  succ CursorType
LastCursor = CursorType
BlankCursor
  succ CursorType
BlankCursor = CursorType
CursorIsPixmap
  succ CursorType
_ = CursorType
forall a. HasCallStack => a
undefined

  pred :: CursorType -> CursorType
pred CursorType
Arrow = CursorType
XCursor
  pred CursorType
BasedArrowDown = CursorType
Arrow
  pred CursorType
BasedArrowUp = CursorType
BasedArrowDown
  pred CursorType
Boat = CursorType
BasedArrowUp
  pred CursorType
Bogosity = CursorType
Boat
  pred CursorType
BottomLeftCorner = CursorType
Bogosity
  pred CursorType
BottomRightCorner = CursorType
BottomLeftCorner
  pred CursorType
BottomSide = CursorType
BottomRightCorner
  pred CursorType
BottomTee = CursorType
BottomSide
  pred CursorType
BoxSpiral = CursorType
BottomTee
  pred CursorType
CenterPtr = CursorType
BoxSpiral
  pred CursorType
Circle = CursorType
CenterPtr
  pred CursorType
Clock = CursorType
Circle
  pred CursorType
CoffeeMug = CursorType
Clock
  pred CursorType
Cross = CursorType
CoffeeMug
  pred CursorType
CrossReverse = CursorType
Cross
  pred CursorType
Crosshair = CursorType
CrossReverse
  pred CursorType
DiamondCross = CursorType
Crosshair
  pred CursorType
Dot = CursorType
DiamondCross
  pred CursorType
Dotbox = CursorType
Dot
  pred CursorType
DoubleArrow = CursorType
Dotbox
  pred CursorType
DraftLarge = CursorType
DoubleArrow
  pred CursorType
DraftSmall = CursorType
DraftLarge
  pred CursorType
DrapedBox = CursorType
DraftSmall
  pred CursorType
Exchange = CursorType
DrapedBox
  pred CursorType
Fleur = CursorType
Exchange
  pred CursorType
Gobbler = CursorType
Fleur
  pred CursorType
Gumby = CursorType
Gobbler
  pred CursorType
Hand1 = CursorType
Gumby
  pred CursorType
Hand2 = CursorType
Hand1
  pred CursorType
Heart = CursorType
Hand2
  pred CursorType
Icon = CursorType
Heart
  pred CursorType
IronCross = CursorType
Icon
  pred CursorType
LeftPtr = CursorType
IronCross
  pred CursorType
LeftSide = CursorType
LeftPtr
  pred CursorType
LeftTee = CursorType
LeftSide
  pred CursorType
Leftbutton = CursorType
LeftTee
  pred CursorType
LlAngle = CursorType
Leftbutton
  pred CursorType
LrAngle = CursorType
LlAngle
  pred CursorType
Man = CursorType
LrAngle
  pred CursorType
Middlebutton = CursorType
Man
  pred CursorType
Mouse = CursorType
Middlebutton
  pred CursorType
Pencil = CursorType
Mouse
  pred CursorType
Pirate = CursorType
Pencil
  pred CursorType
Plus = CursorType
Pirate
  pred CursorType
QuestionArrow = CursorType
Plus
  pred CursorType
RightPtr = CursorType
QuestionArrow
  pred CursorType
RightSide = CursorType
RightPtr
  pred CursorType
RightTee = CursorType
RightSide
  pred CursorType
Rightbutton = CursorType
RightTee
  pred CursorType
RtlLogo = CursorType
Rightbutton
  pred CursorType
Sailboat = CursorType
RtlLogo
  pred CursorType
SbDownArrow = CursorType
Sailboat
  pred CursorType
SbHDoubleArrow = CursorType
SbDownArrow
  pred CursorType
SbLeftArrow = CursorType
SbHDoubleArrow
  pred CursorType
SbRightArrow = CursorType
SbLeftArrow
  pred CursorType
SbUpArrow = CursorType
SbRightArrow
  pred CursorType
SbVDoubleArrow = CursorType
SbUpArrow
  pred CursorType
Shuttle = CursorType
SbVDoubleArrow
  pred CursorType
Sizing = CursorType
Shuttle
  pred CursorType
Spider = CursorType
Sizing
  pred CursorType
Spraycan = CursorType
Spider
  pred CursorType
Star = CursorType
Spraycan
  pred CursorType
Target = CursorType
Star
  pred CursorType
Tcross = CursorType
Target
  pred CursorType
TopLeftArrow = CursorType
Tcross
  pred CursorType
TopLeftCorner = CursorType
TopLeftArrow
  pred CursorType
TopRightCorner = CursorType
TopLeftCorner
  pred CursorType
TopSide = CursorType
TopRightCorner
  pred CursorType
TopTee = CursorType
TopSide
  pred CursorType
Trek = CursorType
TopTee
  pred CursorType
UlAngle = CursorType
Trek
  pred CursorType
Umbrella = CursorType
UlAngle
  pred CursorType
UrAngle = CursorType
Umbrella
  pred CursorType
Watch = CursorType
UrAngle
  pred CursorType
Xterm = CursorType
Watch
  pred CursorType
LastCursor = CursorType
Xterm
  pred CursorType
BlankCursor = CursorType
LastCursor
  pred CursorType
CursorIsPixmap = CursorType
BlankCursor
  pred CursorType
_ = CursorType
forall a. HasCallStack => a
undefined

  enumFromTo :: CursorType -> CursorType -> [CursorType]
enumFromTo CursorType
x CursorType
y | CursorType -> Int
forall a. Enum a => a -> Int
fromEnum CursorType
x Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== CursorType -> Int
forall a. Enum a => a -> Int
fromEnum CursorType
y = [ CursorType
y ]
                 | Bool
otherwise = CursorType
x CursorType -> [CursorType] -> [CursorType]
forall a. a -> [a] -> [a]
: CursorType -> CursorType -> [CursorType]
forall a. Enum a => a -> a -> [a]
enumFromTo (CursorType -> CursorType
forall a. Enum a => a -> a
succ CursorType
x) CursorType
y
  enumFrom :: CursorType -> [CursorType]
enumFrom CursorType
x = CursorType -> CursorType -> [CursorType]
forall a. Enum a => a -> a -> [a]
enumFromTo CursorType
x CursorType
CursorIsPixmap
  enumFromThen :: CursorType -> CursorType -> [CursorType]
enumFromThen CursorType
_ CursorType
_ =     String -> [CursorType]
forall a. HasCallStack => String -> a
error String
"Enum CursorType: enumFromThen not implemented"
  enumFromThenTo :: CursorType -> CursorType -> CursorType -> [CursorType]
enumFromThenTo CursorType
_ CursorType
_ CursorType
_ =     String -> [CursorType]
forall a. HasCallStack => String -> a
error String
"Enum CursorType: enumFromThenTo not implemented"

{-# LINE 71 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}

--------------------
-- Utils
makeNewCursor :: Ptr Cursor -> IO Cursor
makeNewCursor rPtr = do
  cursor <- newForeignPtr rPtr cursor_unref
  return (Cursor cursor)

foreign import ccall unsafe "&gdk_cursor_unref"
  cursor_unref :: FinalizerPtr Cursor

--------------------
-- 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
 -> IO Cursor -- ^ return a new 'Cursor'
cursorNew cursorType = do
  cursorPtr <- gdk_cursor_new $fromIntegral (fromEnum cursorType)
  makeNewCursor cursorPtr

--------------------
-- Methods
{-# LINE 120 "./Graphics/UI/Gtk/Gdk/Cursor.chs" #-}
-- | 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 sufficiently 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.
 -> IO Cursor -- ^ return a new 'Cursor'.
cursorNewFromPixbuf display pixbuf x y = do
  cursorPtr <- (\(Display arg1) (Pixbuf arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_cursor_new_from_pixbuf argPtr1 argPtr2 arg3 arg4) display pixbuf (fromIntegral x) (fromIntegral y)
  makeNewCursor cursorPtr

-- | Creates a new cursor by looking up name in the current cursor theme.
cursorNewFromName :: GlibString string
 => Display -- ^ @display@ the 'Display' for which the cursor will be created
 -> string -- ^ @name@ the name of the cursor
 -> IO (Maybe Cursor) -- ^ return a new 'Cursor', or @Nothing@ if there is no cursor with the given name
cursorNewFromName display name =
    withUTFString name $ \namePtr -> do
      cursorPtr <- (\(Display arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gdk_cursor_new_from_name argPtr1 arg2) display namePtr
      if cursorPtr == nullPtr then return Nothing else liftM Just $ makeNewCursor cursorPtr

-- | 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
 -> IO Cursor -- ^ return a new 'Cursor'
cursorNewForDisplay display cursorType = do
  cursorPtr <- (\(Display arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gdk_cursor_new_for_display argPtr1 arg2) display $fromIntegral (fromEnum cursorType)
  makeNewCursor cursorPtr

-- | Returns the display on which the GdkCursor is defined.
cursorGetDisplay ::
    Cursor -- ^ @cursor@ 'Cursor'
 -> IO Display -- ^ return the 'Display' associated to cursor
cursorGetDisplay cursor =
    makeNewGObject mkDisplay $ (\(Cursor arg1) -> withForeignPtr arg1 $ \argPtr1 ->gdk_cursor_get_display argPtr1) 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 (Maybe Pixbuf) -- ^ a 'Pixbuf' representing cursor, or @Nothing@
cursorGetImage cursor =
    maybeNull (makeNewGObject mkPixbuf) $ (\(Cursor arg1) -> withForeignPtr arg1 $ \argPtr1 ->gdk_cursor_get_image argPtr1) cursor

foreign import ccall safe "gdk_cursor_new"
  gdk_cursor_new :: (CInt -> (IO (Ptr Cursor)))

foreign import ccall safe "gdk_cursor_new_from_pixbuf"
  gdk_cursor_new_from_pixbuf :: ((Ptr Display) -> ((Ptr Pixbuf) -> (CInt -> (CInt -> (IO (Ptr Cursor))))))

foreign import ccall safe "gdk_cursor_new_from_name"
  gdk_cursor_new_from_name :: ((Ptr Display) -> ((Ptr CChar) -> (IO (Ptr Cursor))))

foreign import ccall safe "gdk_cursor_new_for_display"
  gdk_cursor_new_for_display :: ((Ptr Display) -> (CInt -> (IO (Ptr Cursor))))

foreign import ccall safe "gdk_cursor_get_display"
  gdk_cursor_get_display :: ((Ptr Cursor) -> (IO (Ptr Display)))

foreign import ccall safe "gdk_cursor_get_image"
  gdk_cursor_get_image :: ((Ptr Cursor) -> (IO (Ptr Pixbuf)))