module Graphics.UI.Gtk.Entry.Editable (
Editable,
EditableClass,
castToEditable, gTypeEditable,
toEditable,
editableSelectRegion,
editableGetSelectionBounds,
editableInsertText,
editableDeleteText,
editableGetChars,
editableCutClipboard,
editableCopyClipboard,
editablePasteClipboard,
editableDeleteSelection,
editableSetEditable,
editableGetEditable,
editableSetPosition,
editableGetPosition,
editablePosition,
editableEditable,
editableChanged,
deleteText,
insertText,
stopDeleteText,
stopInsertText,
onEditableChanged,
afterEditableChanged,
onDeleteText,
afterDeleteText,
onInsertText,
afterInsertText
) where
import Control.Monad (liftM)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import Graphics.UI.Gtk.Types
import Graphics.UI.Gtk.Signals
editableSelectRegion :: EditableClass self => self
-> Int
-> Int
-> IO ()
editableSelectRegion self start end =
(\(Editable arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_select_region argPtr1 arg2 arg3)
(toEditable self)
(fromIntegral start)
(fromIntegral end)
editableGetSelectionBounds :: EditableClass self => self
-> IO (Int,Int)
editableGetSelectionBounds self =
alloca $ \startPtr ->
alloca $ \endPtr -> do
(\(Editable arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_get_selection_bounds argPtr1 arg2 arg3)
(toEditable self)
startPtr
endPtr
start <- liftM fromIntegral $ peek startPtr
end <- liftM fromIntegral $ peek endPtr
return (start,end)
editableInsertText :: EditableClass self => self
-> String
-> Int
-> IO Int
editableInsertText self newText position =
with (fromIntegral position) $ \positionPtr ->
withUTFStringLen newText $ \(newTextPtr, newTextLength) -> do
(\(Editable arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_insert_text argPtr1 arg2 arg3 arg4)
(toEditable self)
newTextPtr
(fromIntegral newTextLength)
positionPtr
position <- peek positionPtr
return (fromIntegral position)
editableDeleteText :: EditableClass self => self
-> Int
-> Int
-> IO ()
editableDeleteText self startPos endPos =
(\(Editable arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_delete_text argPtr1 arg2 arg3)
(toEditable self)
(fromIntegral startPos)
(fromIntegral endPos)
editableGetChars :: EditableClass self => self
-> Int
-> Int
-> IO String
editableGetChars self startPos endPos =
(\(Editable arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_get_chars argPtr1 arg2 arg3)
(toEditable self)
(fromIntegral startPos)
(fromIntegral endPos)
>>= readUTFString
editableCutClipboard :: EditableClass self => self -> IO ()
editableCutClipboard self =
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_cut_clipboard argPtr1)
(toEditable self)
editableCopyClipboard :: EditableClass self => self -> IO ()
editableCopyClipboard self =
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_copy_clipboard argPtr1)
(toEditable self)
editablePasteClipboard :: EditableClass self => self -> IO ()
editablePasteClipboard self =
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_paste_clipboard argPtr1)
(toEditable self)
editableDeleteSelection :: EditableClass self => self -> IO ()
editableDeleteSelection self =
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_delete_selection argPtr1)
(toEditable self)
editableSetPosition :: EditableClass self => self
-> Int
-> IO ()
editableSetPosition self position =
(\(Editable arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_set_position argPtr1 arg2)
(toEditable self)
(fromIntegral position)
editableGetPosition :: EditableClass self => self
-> IO Int
editableGetPosition self =
liftM fromIntegral $
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_get_position argPtr1)
(toEditable self)
editableSetEditable :: EditableClass self => self
-> Bool
-> IO ()
editableSetEditable self isEditable =
(\(Editable arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_set_editable argPtr1 arg2)
(toEditable self)
(fromBool isEditable)
editableGetEditable :: EditableClass self => self -> IO Bool
editableGetEditable self =
liftM toBool $
(\(Editable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_editable_get_editable argPtr1)
(toEditable self)
editablePosition :: EditableClass self => Attr self Int
editablePosition = newAttr
editableGetPosition
editableSetPosition
editableEditable :: EditableClass self => Attr self Bool
editableEditable = newAttr
editableGetEditable
editableSetEditable
editableChanged :: EditableClass ec => Signal ec (IO ())
editableChanged = Signal (connect_NONE__NONE "changed")
deleteText :: EditableClass self
=> Signal self (Int -> Int -> IO ())
deleteText = Signal (connect_INT_INT__NONE "delete-text")
stopDeleteText :: EditableClass self => ConnectId self -> IO ()
stopDeleteText (ConnectId _ obj) =
signalStopEmission obj "delete-text"
insertText :: EditableClass self => Signal self (String -> Int -> IO Int)
insertText = Signal $ \after obj handler ->
connect_PTR_INT_PTR__NONE "insert-text" after obj
(\strPtr strLen posPtr -> do
str <- if strLen<0 then peekUTFString strPtr
else peekUTFStringLen (strPtr, strLen)
pos <- peek (posPtr :: Ptr (CInt))
pos' <- handler str (fromIntegral pos)
poke (posPtr :: Ptr (CInt)) (fromIntegral pos')
)
stopInsertText :: EditableClass self => ConnectId self -> IO ()
stopInsertText (ConnectId _ obj) =
signalStopEmission obj "insert-text"
onEditableChanged, afterEditableChanged :: EditableClass ec => ec -> IO () ->
IO (ConnectId ec)
onEditableChanged = connect_NONE__NONE "changed" False
afterEditableChanged = connect_NONE__NONE "changed" True
onDeleteText, afterDeleteText :: EditableClass self => self
-> (Int -> Int -> IO ())
-> IO (ConnectId self)
onDeleteText = connect_INT_INT__NONE "delete_text" False
afterDeleteText = connect_INT_INT__NONE "delete_text" True
onInsertText, afterInsertText :: EditableClass self => self
-> (String -> Int -> IO Int)
-> IO (ConnectId self)
onInsertText obj handler =
connect_PTR_INT_PTR__NONE "insert_text" False obj
(\strPtr strLen posPtr -> do
str <- if strLen<0 then peekUTFString strPtr
else peekUTFStringLen (strPtr, strLen)
pos <- peek (posPtr :: Ptr (CInt))
pos' <- handler str (fromIntegral pos)
poke (posPtr :: Ptr (CInt)) (fromIntegral pos')
)
afterInsertText obj handler =
connect_PTR_INT_PTR__NONE "insert_text" True obj
(\strPtr strLen posPtr -> do
str <- if strLen<0 then peekUTFString strPtr
else peekUTFStringLen (strPtr, strLen)
pos <- peek (posPtr :: Ptr (CInt))
pos' <- handler str (fromIntegral pos)
poke (posPtr :: Ptr (CInt)) (fromIntegral pos')
)
foreign import ccall safe "gtk_editable_select_region"
gtk_editable_select_region :: ((Ptr Editable) -> (CInt -> (CInt -> (IO ()))))
foreign import ccall unsafe "gtk_editable_get_selection_bounds"
gtk_editable_get_selection_bounds :: ((Ptr Editable) -> ((Ptr CInt) -> ((Ptr CInt) -> (IO CInt))))
foreign import ccall safe "gtk_editable_insert_text"
gtk_editable_insert_text :: ((Ptr Editable) -> ((Ptr CChar) -> (CInt -> ((Ptr CInt) -> (IO ())))))
foreign import ccall safe "gtk_editable_delete_text"
gtk_editable_delete_text :: ((Ptr Editable) -> (CInt -> (CInt -> (IO ()))))
foreign import ccall unsafe "gtk_editable_get_chars"
gtk_editable_get_chars :: ((Ptr Editable) -> (CInt -> (CInt -> (IO (Ptr CChar)))))
foreign import ccall safe "gtk_editable_cut_clipboard"
gtk_editable_cut_clipboard :: ((Ptr Editable) -> (IO ()))
foreign import ccall safe "gtk_editable_copy_clipboard"
gtk_editable_copy_clipboard :: ((Ptr Editable) -> (IO ()))
foreign import ccall safe "gtk_editable_paste_clipboard"
gtk_editable_paste_clipboard :: ((Ptr Editable) -> (IO ()))
foreign import ccall safe "gtk_editable_delete_selection"
gtk_editable_delete_selection :: ((Ptr Editable) -> (IO ()))
foreign import ccall safe "gtk_editable_set_position"
gtk_editable_set_position :: ((Ptr Editable) -> (CInt -> (IO ())))
foreign import ccall unsafe "gtk_editable_get_position"
gtk_editable_get_position :: ((Ptr Editable) -> (IO CInt))
foreign import ccall safe "gtk_editable_set_editable"
gtk_editable_set_editable :: ((Ptr Editable) -> (CInt -> (IO ())))
foreign import ccall safe "gtk_editable_get_editable"
gtk_editable_get_editable :: ((Ptr Editable) -> (IO CInt))