{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

The 'GI.Gtk.Interfaces.Orientable.Orientable' interface is implemented by all widgets that can be
oriented horizontally or vertically. Historically, such widgets have been
realized as subclasses of a common base class (e.g 'GI.Gtk.Objects.Box.Box'\/'GI.Gtk.Objects.HBox.HBox'\/'GI.Gtk.Objects.VBox.VBox'
or 'GI.Gtk.Objects.Scale.Scale'\/'GI.Gtk.Objects.HScale.HScale'\/'GI.Gtk.Objects.VScale.VScale'). 'GI.Gtk.Interfaces.Orientable.Orientable' is more flexible in that
it allows the orientation to be changed at runtime, allowing the widgets
to “flip”.

'GI.Gtk.Interfaces.Orientable.Orientable' was introduced in GTK+ 2.16.
-}

module GI.Gtk.Interfaces.Orientable
    ( 

-- * Exported types
    Orientable(..)                          ,
    noOrientable                            ,
    IsOrientable                            ,
    toOrientable                            ,


 -- * Methods
-- ** getOrientation #method:getOrientation#
    OrientableGetOrientationMethodInfo      ,
    orientableGetOrientation                ,


-- ** setOrientation #method:setOrientation#
    OrientableSetOrientationMethodInfo      ,
    orientableSetOrientation                ,




 -- * Properties
-- ** orientation #attr:orientation#
    OrientableOrientationPropertyInfo       ,
    constructOrientableOrientation          ,
    getOrientableOrientation                ,
    orientableOrientation                   ,
    setOrientableOrientation                ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gtk.Enums as Gtk.Enums

-- interface Orientable 
newtype Orientable = Orientable (ManagedPtr Orientable)
noOrientable :: Maybe Orientable
noOrientable = Nothing

type family ResolveOrientableMethod (t :: Symbol) (o :: *) :: * where
    ResolveOrientableMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveOrientableMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveOrientableMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveOrientableMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveOrientableMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveOrientableMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveOrientableMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveOrientableMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveOrientableMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveOrientableMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveOrientableMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveOrientableMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveOrientableMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveOrientableMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveOrientableMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveOrientableMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveOrientableMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveOrientableMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveOrientableMethod "getOrientation" o = OrientableGetOrientationMethodInfo
    ResolveOrientableMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveOrientableMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveOrientableMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveOrientableMethod "setOrientation" o = OrientableSetOrientationMethodInfo
    ResolveOrientableMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveOrientableMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveOrientableMethod t Orientable, O.MethodInfo info Orientable p) => O.IsLabelProxy t (Orientable -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveOrientableMethod t Orientable, O.MethodInfo info Orientable p) => O.IsLabel t (Orientable -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "orientation"
   -- Type: TInterface (Name {namespace = "Gtk", name = "Orientation"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getOrientableOrientation :: (MonadIO m, IsOrientable o) => o -> m Gtk.Enums.Orientation
getOrientableOrientation obj = liftIO $ getObjectPropertyEnum obj "orientation"

setOrientableOrientation :: (MonadIO m, IsOrientable o) => o -> Gtk.Enums.Orientation -> m ()
setOrientableOrientation obj val = liftIO $ setObjectPropertyEnum obj "orientation" val

constructOrientableOrientation :: (IsOrientable o) => Gtk.Enums.Orientation -> IO (GValueConstruct o)
constructOrientableOrientation val = constructObjectPropertyEnum "orientation" val

data OrientableOrientationPropertyInfo
instance AttrInfo OrientableOrientationPropertyInfo where
    type AttrAllowedOps OrientableOrientationPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint OrientableOrientationPropertyInfo = (~) Gtk.Enums.Orientation
    type AttrBaseTypeConstraint OrientableOrientationPropertyInfo = IsOrientable
    type AttrGetType OrientableOrientationPropertyInfo = Gtk.Enums.Orientation
    type AttrLabel OrientableOrientationPropertyInfo = "orientation"
    type AttrOrigin OrientableOrientationPropertyInfo = Orientable
    attrGet _ = getOrientableOrientation
    attrSet _ = setOrientableOrientation
    attrConstruct _ = constructOrientableOrientation
    attrClear _ = undefined

instance O.HasAttributeList Orientable
type instance O.AttributeList Orientable = OrientableAttributeList
type OrientableAttributeList = ('[ '("orientation", OrientableOrientationPropertyInfo)] :: [(Symbol, *)])

orientableOrientation :: AttrLabelProxy "orientation"
orientableOrientation = AttrLabelProxy

type instance O.SignalList Orientable = OrientableSignalList
type OrientableSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "gtk_orientable_get_type"
    c_gtk_orientable_get_type :: IO GType

instance GObject Orientable where
    gobjectType _ = c_gtk_orientable_get_type
    

class GObject o => IsOrientable o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Orientable a) =>
    IsOrientable a
#endif
instance IsOrientable Orientable
instance GObject.Object.IsObject Orientable

toOrientable :: IsOrientable o => o -> IO Orientable
toOrientable = unsafeCastTo Orientable

-- method Orientable::get_orientation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "orientable", argType = TInterface (Name {namespace = "Gtk", name = "Orientable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkOrientable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "Orientation"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_orientable_get_orientation" gtk_orientable_get_orientation :: 
    Ptr Orientable ->                       -- orientable : TInterface (Name {namespace = "Gtk", name = "Orientable"})
    IO CUInt

{- |
Retrieves the orientation of the /@orientable@/.

@since 2.16
-}
orientableGetOrientation ::
    (B.CallStack.HasCallStack, MonadIO m, IsOrientable a) =>
    a
    {- ^ /@orientable@/: a 'GI.Gtk.Interfaces.Orientable.Orientable' -}
    -> m Gtk.Enums.Orientation
    {- ^ __Returns:__ the orientation of the /@orientable@/. -}
orientableGetOrientation orientable = liftIO $ do
    orientable' <- unsafeManagedPtrCastPtr orientable
    result <- gtk_orientable_get_orientation orientable'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr orientable
    return result'

data OrientableGetOrientationMethodInfo
instance (signature ~ (m Gtk.Enums.Orientation), MonadIO m, IsOrientable a) => O.MethodInfo OrientableGetOrientationMethodInfo a signature where
    overloadedMethod _ = orientableGetOrientation

-- method Orientable::set_orientation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "orientable", argType = TInterface (Name {namespace = "Gtk", name = "Orientable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkOrientable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "orientation", argType = TInterface (Name {namespace = "Gtk", name = "Orientation"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the orientable\8217s new orientation.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_orientable_set_orientation" gtk_orientable_set_orientation :: 
    Ptr Orientable ->                       -- orientable : TInterface (Name {namespace = "Gtk", name = "Orientable"})
    CUInt ->                                -- orientation : TInterface (Name {namespace = "Gtk", name = "Orientation"})
    IO ()

{- |
Sets the orientation of the /@orientable@/.

@since 2.16
-}
orientableSetOrientation ::
    (B.CallStack.HasCallStack, MonadIO m, IsOrientable a) =>
    a
    {- ^ /@orientable@/: a 'GI.Gtk.Interfaces.Orientable.Orientable' -}
    -> Gtk.Enums.Orientation
    {- ^ /@orientation@/: the orientable’s new orientation. -}
    -> m ()
orientableSetOrientation orientable orientation = liftIO $ do
    orientable' <- unsafeManagedPtrCastPtr orientable
    let orientation' = (fromIntegral . fromEnum) orientation
    gtk_orientable_set_orientation orientable' orientation'
    touchManagedPtr orientable
    return ()

data OrientableSetOrientationMethodInfo
instance (signature ~ (Gtk.Enums.Orientation -> m ()), MonadIO m, IsOrientable a) => O.MethodInfo OrientableSetOrientationMethodInfo a signature where
    overloadedMethod _ = orientableSetOrientation