hsqml-0.1.1: Haskell binding for Qt Quick

Safe HaskellNone

Graphics.QML.Objects

Contents

Description

Facilities for defining new object types which can be marshalled between Haskell and QML.

Synopsis

Class Definition

class Typeable tt => Object tt whereSource

The class Object allows Haskell types to expose an object-oriented interface to QML.

data ClassDef tt Source

Represents the API of the QML class which wraps the type tt.

data Member tt Source

Represents a named member of the QML class which wraps type tt.

defClass :: forall tt. Object tt => [Member tt] -> ClassDef ttSource

Generates a ClassDef from a list of Members.

Methods

defMethod :: forall tt ms. (MarshalThis tt, MethodSuffix ms) => String -> (tt -> ms) -> Member (ThisObj tt)Source

Defines a named method using a function f in the IO monad.

The first argument to f receives the "this" object and hence must match the type of the class on which the method is being defined. Subsequently, there may be zero or more parameter arguments followed by an optional return argument in the IO monad. These argument types must be members of the MarshalThis, MarshalIn, and MarshalOut typeclasses respectively.

class MethodSuffix a Source

Supports marshalling Haskell functions with an arbitrary number of arguments.

Instances

Properties

defPropertyRO :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> Member (ThisObj tt)Source

Defines a named read-only property using an accessor function in the IO monad.

defPropertyRW :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> (tt -> tr -> IO ()) -> Member (ThisObj tt)Source

Defines a named read-write property using a pair of accessor and mutator functions in the IO monad.

Object References

data ObjRef tt Source

Represents an instance of the QML class which wraps the type tt.

Instances

(MarshalIn (ObjRef tt), Object tt) => MarshalOut (ObjRef tt) 
Object tt => MarshalIn (ObjRef tt) 
(Object (ThisObj (ObjRef tt)), Object tt) => MarshalThis (ObjRef tt) 

newObject :: forall tt. Object tt => tt -> IO (ObjRef tt)Source

Creates an instance of a QML class given a value of the underlying Haskell type tt.

fromObjRef :: ObjRef tt -> ttSource

Returns the associated value of the underlying Haskell type tt from an instance of the QML class which wraps it.

Marshalling Type-classes

objectInMarshaller :: Object tt => InMarshaller ttSource

Provides an InMarshaller which allows you to define instances of MarshalIn for custom object types. For example:

 instance MarshalIn MyObjectType where
     mIn = objectInMarshaller

This instance would allow MyObjectType to be used as a parameter type in callbacks. An instance is provided for ObjRef MyObjectType by default.

class Object (ThisObj tt) => MarshalThis tt whereSource

The class MarshalThis allows objects to be marshalled back into Haskell as the "this" value for callbacks.

Associated Types

type ThisObj tt Source

Methods

mThis :: ThisMarshaller ttSource

Instances

(Object (ThisObj (ObjRef tt)), Object tt) => MarshalThis (ObjRef tt) 

objectThisMarshaller :: (Object tt, ThisObj tt ~ tt) => ThisMarshaller ttSource

Provides an ThisMarshaller which allows you to define instances of MarshalThis for custom object types. For example:

 instance MarshalThis MyObjectType where
     type (ThisObj MyObjectType) = MyObjectType
     mIn = objectInMarshaller

This instance would allow MyObjectType to be used as the "this" type for callbacks. An instance is provided for ObjRef MyObjectType by default.