wxcore-0.92.2.0: wxHaskell core

Copyright(c) Daan Leijen 2003, 2004
LicensewxWindows
Maintainerwxhaskell-devel@lists.sourceforge.net
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Graphics.UI.WXCore.WxcObject

Contents

Description

Basic object type.

Synopsis

Object types

data Object a Source

An Object a is a pointer to an object of type a. The a parameter is used to encode the inheritance relation. When the type parameter is unit (), it denotes an object of exactly that class, when the parameter is a type variable a, it specifies an object that is at least an instance of that class. For example in wxWidgets, we have the following class hierarchy:

EvtHandler
  |- Window
       |- Frame
       |- Control
           |- Button
           |- Radiobox

In wxHaskell, all the creation functions will return objects of exactly that class and use the () type:

frameCreate :: Window a -> ... -> IO (Frame ())
buttonCreate :: Window a -> ... -> IO (Button ())
...

In contrast, all the this (or self) pointers of methods can take objects of any instance of that class and have a type variable, for example:

windowSetClientSize :: Window a -> Size -> IO ()
controlSetLabel     :: Control a -> String -> IO ()
buttonSetDefault    :: Button a -> IO ()

This means that we can use windowSetClientSize on any window, including buttons and frames, but we can only use controlSetLabel on controls, not including frames.

In wxHaskell, this works since a Frame () is actually a type synonym for Window (CFrame ()) (where CFrame is an abstract data type). We can thus pass a value of type Frame () to anything that expects some Window a. For a button this works too, as it is a synonym for Control (CButton ()) which is in turn a synonym for Window (CControl (CButton ())). Note that we can't pass a frame to something that expects a value of type Control a. Of course, a Window a is actually a type synonym for EvtHandler (CWindow a). If you study the documentation in Graphics.UI.WX.Classes closely, you can discover where this chain ends :-).

Objects are not automatically deleted. Normally you can use a delete function like windowDelete to delete an object. However, almost all objects in the wxWidgets library are automatically deleted by the library. The only objects that should be used with care are resources as bitmaps, fonts and brushes.

objectNull :: Object a Source

A null object. Use with care.

objectIsNull :: Object a -> Bool Source

Test for null object.

objectCast :: Object a -> Object b Source

Cast an object to another type. Use with care.

objectIsManaged :: Object a -> Bool Source

Is this a managed object?

objectFromPtr :: Ptr a -> Object a Source

Create an unmanaged object.

objectFromManagedPtr :: ManagedPtr a -> IO (Object a) Source

Create a managed object with a given finalizer.

withObjectPtr :: Object a -> (Ptr a -> IO b) -> IO b Source

Do something with the object pointer.

objectFinalize :: Object a -> IO () Source

Finalize a managed object manually. (No effect on unmanaged objects.)

objectNoFinalize :: Object a -> IO () Source

Remove the finalizer on a managed object. (No effect on unmanaged objects.)

Managed objects

type ManagedPtr a = Ptr (CManagedPtr a) Source

Managed pointer (proxy) objects

data CManagedPtr a Source

Constructors

CManagedPtr