{-# LINE 2 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
module Graphics.UI.Gtk.Abstract.IMContext (
IMContext,
IMContextClass,
castToIMContext, gTypeIMContext,
toIMContext,
imContextSetClientWindow,
imContextGetPreeditString,
imContextFilterKeypress,
imContextFocusIn,
imContextFocusOut,
imContextReset,
imContextSetCursorLocation,
imContextSetUsePreedit,
imContextSetSurrounding,
imContextGetSurrounding,
imContextDeleteSurrounding,
imContextPreeditStart,
imContextPreeditEnd,
imContextPreeditChanged,
imContextCommit,
imContextRetrieveSurrounding,
imContextDeleteSurrounding',
) where
import Control.Monad (liftM)
import Control.Monad.Reader.Class (ask)
import Control.Monad.Trans (liftIO)
import Data.Maybe (fromMaybe)
import System.Glib.FFI
import System.Glib.UTFString (readUTFString, withUTFString, genUTFOfs,
ofsToUTF, ofsFromUTF, GlibString)
import Graphics.UI.Gtk.Types
{-# LINE 77 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
import Graphics.UI.Gtk.Signals
{-# LINE 78 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
import Graphics.UI.Gtk.Gdk.EventM (EventM, EKey)
import Graphics.UI.Gtk.General.Structs (Rectangle)
import Graphics.Rendering.Pango.Enums (PangoAttribute)
import Graphics.Rendering.Pango.Attributes (readAttrList)
{-# LINE 84 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
imContextSetClientWindow :: IMContextClass self => self
-> Maybe DrawWindow
-> IO ()
imContextSetClientWindow self window =
(\(IMContext arg1) (DrawWindow arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_im_context_set_client_window argPtr1 argPtr2)
{-# LINE 99 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
(fromMaybe (DrawWindow nullForeignPtr) window)
imContextGetPreeditString :: (IMContextClass self, GlibString string) => self
-> IO (string, [[PangoAttribute]], Int)
imContextGetPreeditString self =
alloca $ \strPtr ->
alloca $ \attrListPtr ->
alloca $ \cursorPosPtr ->
(\(IMContext arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_get_preedit_string argPtr1 arg2 arg3 arg4)
{-# LINE 115 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
strPtr
attrListPtr
cursorPosPtr
>>
peek strPtr >>= readUTFString >>= \str ->
peek attrListPtr >>= readAttrList (genUTFOfs str) >>= \attrs ->
peek cursorPosPtr >>= \cursorPos ->
return (str, attrs, fromIntegral cursorPos)
imContextFilterKeypress :: IMContextClass self => self
-> EventM EKey Bool
imContextFilterKeypress self =
liftM toBool $
ask >>= \eventPtr ->
liftIO $
(\(IMContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_filter_keypress argPtr1 arg2)
{-# LINE 137 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
(castPtr eventPtr)
imContextFocusIn :: IMContextClass self => self -> IO ()
imContextFocusIn self =
(\(IMContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_focus_in argPtr1)
{-# LINE 147 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
imContextFocusOut :: IMContextClass self => self -> IO ()
imContextFocusOut self =
(\(IMContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_focus_out argPtr1)
{-# LINE 156 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
imContextReset :: IMContextClass self => self -> IO ()
imContextReset self =
(\(IMContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_reset argPtr1)
{-# LINE 165 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
imContextSetCursorLocation :: IMContextClass self => self
-> Rectangle
-> IO ()
imContextSetCursorLocation self area =
with area $ \areaPtr ->
(\(IMContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_set_cursor_location argPtr1 arg2)
{-# LINE 176 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
(castPtr areaPtr)
imContextSetUsePreedit :: IMContextClass self => self
-> Bool
-> IO ()
imContextSetUsePreedit self usePreedit =
(\(IMContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_set_use_preedit argPtr1 arg2)
{-# LINE 190 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
(fromBool usePreedit)
imContextSetSurrounding :: (IMContextClass self, GlibString string) => self
-> string
-> Int
-> IO ()
imContextSetSurrounding self text cursorIndex =
withUTFString text $ \textPtr ->
(\(IMContext arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_set_surrounding argPtr1 arg2 arg3 arg4)
{-# LINE 207 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
textPtr
(-1)
(fromIntegral (ofsToUTF cursorIndex (genUTFOfs text)))
imContextGetSurrounding :: (IMContextClass self, GlibString string) => self
-> IO (Maybe (string, Int))
imContextGetSurrounding self =
alloca $ \textPtr ->
alloca $ \cursorIndexPtr ->
(\(IMContext arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_get_surrounding argPtr1 arg2 arg3)
{-# LINE 234 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
textPtr
cursorIndexPtr >>= \provided ->
if toBool provided then
peek textPtr >>= readUTFString >>= \text ->
peek cursorIndexPtr >>= \cursorIndex ->
return (Just (text, ofsFromUTF (fromIntegral cursorIndex)
(genUTFOfs text)))
else
return Nothing
imContextDeleteSurrounding :: IMContextClass self => self
-> Int
-> Int
-> IO Bool
imContextDeleteSurrounding self offset nChars =
liftM toBool $
(\(IMContext arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_im_context_delete_surrounding argPtr1 arg2 arg3)
{-# LINE 268 "./Graphics/UI/Gtk/Abstract/IMContext.chs" #-}
(toIMContext self)
(fromIntegral offset)
(fromIntegral nChars)
imContextPreeditStart :: IMContextClass self => Signal self (IO ())
imContextPreeditStart = Signal (connect_NONE__NONE "preedit-start")
imContextPreeditEnd :: IMContextClass self => Signal self (IO ())
imContextPreeditEnd = Signal (connect_NONE__NONE "preedit-end")
imContextPreeditChanged :: IMContextClass self => Signal self (IO ())
imContextPreeditChanged = Signal (connect_NONE__NONE "preedit-changed")
imContextCommit :: (IMContextClass self, GlibString string) => Signal self (string -> IO ())
imContextCommit = Signal (connect_GLIBSTRING__NONE "commit")
imContextRetrieveSurrounding :: IMContextClass self => Signal self (IO Bool)
imContextRetrieveSurrounding = Signal (connect_NONE__BOOL "retrieve-surrounding")
imContextDeleteSurrounding' :: IMContextClass self => Signal self (Int -> Int -> IO Bool)
imContextDeleteSurrounding' = Signal (connect_INT_INT__BOOL "delete-surrounding")
foreign import ccall safe "gtk_im_context_set_client_window"
gtk_im_context_set_client_window :: ((Ptr IMContext) -> ((Ptr DrawWindow) -> (IO ())))
foreign import ccall safe "gtk_im_context_get_preedit_string"
gtk_im_context_get_preedit_string :: ((Ptr IMContext) -> ((Ptr (Ptr CChar)) -> ((Ptr (Ptr ())) -> ((Ptr CInt) -> (IO ())))))
foreign import ccall safe "gtk_im_context_filter_keypress"
gtk_im_context_filter_keypress :: ((Ptr IMContext) -> ((Ptr ()) -> (IO CInt)))
foreign import ccall safe "gtk_im_context_focus_in"
gtk_im_context_focus_in :: ((Ptr IMContext) -> (IO ()))
foreign import ccall safe "gtk_im_context_focus_out"
gtk_im_context_focus_out :: ((Ptr IMContext) -> (IO ()))
foreign import ccall safe "gtk_im_context_reset"
gtk_im_context_reset :: ((Ptr IMContext) -> (IO ()))
foreign import ccall safe "gtk_im_context_set_cursor_location"
gtk_im_context_set_cursor_location :: ((Ptr IMContext) -> ((Ptr ()) -> (IO ())))
foreign import ccall safe "gtk_im_context_set_use_preedit"
gtk_im_context_set_use_preedit :: ((Ptr IMContext) -> (CInt -> (IO ())))
foreign import ccall safe "gtk_im_context_set_surrounding"
gtk_im_context_set_surrounding :: ((Ptr IMContext) -> ((Ptr CChar) -> (CInt -> (CInt -> (IO ())))))
foreign import ccall safe "gtk_im_context_get_surrounding"
gtk_im_context_get_surrounding :: ((Ptr IMContext) -> ((Ptr (Ptr CChar)) -> ((Ptr CInt) -> (IO CInt))))
foreign import ccall safe "gtk_im_context_delete_surrounding"
gtk_im_context_delete_surrounding :: ((Ptr IMContext) -> (CInt -> (CInt -> (IO CInt))))