rename round
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54109 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,97 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/cfdata.h
|
|
||||||
// Purpose: wxCFDataRef class
|
|
||||||
// Author: Stefan Csomor
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2007/05/10
|
|
||||||
// RCS-ID: $Id: cfdataref.h 46095 2007-05-18 07:29:49Z SC $
|
|
||||||
// Copyright: (c) 2007 Stefan Csomor
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
// Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBinaryData/index.html
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
/*! @header wx/mac/corefoundation/cfref.h
|
|
||||||
@abstract wxCFDataRef template class
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__
|
|
||||||
#define _WX_MAC_COREFOUNDATION_CFDATAREF_H__
|
|
||||||
|
|
||||||
#include "wx/mac/corefoundation/cfref.h"
|
|
||||||
|
|
||||||
#include <CoreFoundation/CFData.h>
|
|
||||||
|
|
||||||
/*! @class wxCFDataRef
|
|
||||||
@discussion Properly retains/releases reference to CoreFoundation data objects
|
|
||||||
*/
|
|
||||||
class wxCFDataRef : public wxCFRef< CFDataRef >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*! @method wxCFDataRef
|
|
||||||
@abstract Creates a NULL data ref
|
|
||||||
*/
|
|
||||||
wxCFDataRef()
|
|
||||||
{}
|
|
||||||
|
|
||||||
typedef wxCFRef<CFDataRef> super_type;
|
|
||||||
|
|
||||||
/*! @method wxCFDataRef
|
|
||||||
@abstract Assumes ownership of p and creates a reference to it.
|
|
||||||
@templatefield otherType Any type.
|
|
||||||
@param p The raw pointer to assume ownership of. May be NULL.
|
|
||||||
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to p and intends
|
|
||||||
to transfer ownership of that reference to this ref holder. If the object comes from
|
|
||||||
a Create or Copy method then this is the correct behavior. If the object comes from
|
|
||||||
a Get method then you must CFRetain it yourself before passing it to this constructor.
|
|
||||||
A handy way to do this is to use the non-member wxCFRefFromGet factory funcion.
|
|
||||||
This method is templated and takes an otherType *p. This prevents implicit conversion
|
|
||||||
using an operator refType() in a different ref-holding class type.
|
|
||||||
*/
|
|
||||||
explicit wxCFDataRef(CFDataRef r)
|
|
||||||
: super_type(r)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFDataRef
|
|
||||||
@abstract Copies a ref holder of the same type
|
|
||||||
@param otherRef The other ref holder to copy.
|
|
||||||
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
|
|
||||||
the object will be explicitly retained by this new ref.
|
|
||||||
*/
|
|
||||||
wxCFDataRef(const wxCFDataRef& otherRef)
|
|
||||||
: super_type( otherRef )
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFDataRef
|
|
||||||
@abstract Copies raw data into a data ref
|
|
||||||
@param data The raw data.
|
|
||||||
@param length The data length.
|
|
||||||
*/
|
|
||||||
wxCFDataRef(const UInt8* data, CFIndex length)
|
|
||||||
: super_type(CFDataCreate(kCFAllocatorDefault, data, length))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @method GetLength
|
|
||||||
@abstract returns the length in bytes of the data stored
|
|
||||||
*/
|
|
||||||
CFIndex GetLength() const
|
|
||||||
{
|
|
||||||
if ( m_ptr )
|
|
||||||
return CFDataGetLength( *this );
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @method GetBytes
|
|
||||||
@abstract Copies the data into an external buffer
|
|
||||||
@param range The desired range.
|
|
||||||
@param buffer The target buffer.
|
|
||||||
*/
|
|
||||||
void GetBytes( CFRange range, UInt8 *buffer ) const
|
|
||||||
{
|
|
||||||
if ( m_ptr )
|
|
||||||
CFDataGetBytes(m_ptr, range, buffer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__
|
|
||||||
|
|
@@ -1,389 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/cfref.h
|
|
||||||
// Purpose: wxCFRef template class
|
|
||||||
// Author: David Elliott <dfe@cox.net>
|
|
||||||
// Modified by: Stefan Csomor
|
|
||||||
// Created: 2007/05/10
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) 2007 David Elliott <dfe@cox.net>, Stefan Csomor
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
// Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/index.html
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
/*! @header wx/mac/corefoundation/cfref.h
|
|
||||||
@abstract wxCFRef template class
|
|
||||||
@discussion FIXME: Convert doc tags to something less buggy with C++
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _WX_MAC_COREFOUNDATION_CFREF_H__
|
|
||||||
#define _WX_MAC_COREFOUNDATION_CFREF_H__
|
|
||||||
|
|
||||||
// Include unistd to ensure that NULL is defined
|
|
||||||
#include <unistd.h>
|
|
||||||
// Include AvailabilityMacros for DEPRECATED_ATTRIBUTE
|
|
||||||
#include <AvailabilityMacros.h>
|
|
||||||
|
|
||||||
// #include <CoreFoundation/CFBase.h>
|
|
||||||
/* Don't include CFBase.h such that this header can be included from public
|
|
||||||
* headers with minimal namespace pollution.
|
|
||||||
* Note that Darwin CF uses extern for CF_EXPORT. If we need this on Win32
|
|
||||||
* or non-Darwin Mac OS we'll need to define the appropriate __declspec.
|
|
||||||
*/
|
|
||||||
typedef const void *CFTypeRef;
|
|
||||||
extern "C" {
|
|
||||||
extern /* CF_EXPORT */
|
|
||||||
CFTypeRef CFRetain(CFTypeRef cf);
|
|
||||||
extern /* CF_EXPORT */
|
|
||||||
void CFRelease(CFTypeRef cf);
|
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
|
|
||||||
/*! @function wxCFRelease
|
|
||||||
@abstract A CFRelease variant that checks for NULL before releasing.
|
|
||||||
@discussion The parameter is template not for type safety but to ensure the argument
|
|
||||||
is a raw pointer and not a ref holder of any type.
|
|
||||||
*/
|
|
||||||
template <class Type>
|
|
||||||
inline void wxCFRelease(Type *r)
|
|
||||||
{
|
|
||||||
if ( r != NULL )
|
|
||||||
::CFRelease((CFTypeRef)r);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @function wxCFRetain
|
|
||||||
@abstract A typesafe CFRetain variant that checks for NULL.
|
|
||||||
*/
|
|
||||||
template <class Type>
|
|
||||||
inline Type* wxCFRetain(Type *r)
|
|
||||||
{
|
|
||||||
// NOTE(DE): Setting r to the result of CFRetain improves efficiency on both x86 and PPC
|
|
||||||
// Casting r to CFTypeRef ensures we are calling the real C version defined in CFBase.h
|
|
||||||
// and not any possibly templated/overloaded CFRetain.
|
|
||||||
if ( r != NULL )
|
|
||||||
r = (Type*)::CFRetain((CFTypeRef)r);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class refType>
|
|
||||||
class wxCFRef;
|
|
||||||
|
|
||||||
/*! @class wxCFWeakRef
|
|
||||||
@templatefield refType The CF reference type (e.g. CFStringRef, CFRunLoopRef, etc.)
|
|
||||||
It should already be a pointer. This is different from
|
|
||||||
shared_ptr where the template parameter is the pointee type.
|
|
||||||
@discussion Wraps a raw pointer without any retain or release.
|
|
||||||
Provides a way to get what amounts to a raw pointer from a wxCFRef without
|
|
||||||
using a raw pointer. Unlike a raw pointer, constructing a wxCFRef from this
|
|
||||||
class will cause it to be retained because it is assumed that a wxCFWeakRef
|
|
||||||
does not own its pointer.
|
|
||||||
*/
|
|
||||||
template <class refType>
|
|
||||||
class wxCFWeakRef
|
|
||||||
{
|
|
||||||
template <class refTypeA, class otherRefType>
|
|
||||||
friend wxCFWeakRef<refTypeA> static_cfref_cast(const wxCFRef<otherRefType> &otherRef);
|
|
||||||
public:
|
|
||||||
/*! @method wxCFWeakRef
|
|
||||||
@abstract Creates a NULL reference
|
|
||||||
*/
|
|
||||||
wxCFWeakRef()
|
|
||||||
: m_ptr(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Default copy constructor is fine.
|
|
||||||
// Default destructor is fine but we'll set NULL to avoid bugs
|
|
||||||
~wxCFWeakRef()
|
|
||||||
{ m_ptr = NULL; }
|
|
||||||
|
|
||||||
// Do not implement a raw-pointer constructor.
|
|
||||||
|
|
||||||
/*! @method wxCFWeakRef
|
|
||||||
@abstract Copies another ref holder where its type can be converted to ours
|
|
||||||
@templatefield otherRefType Any type held by another wxCFWeakRef.
|
|
||||||
@param otherRef The other weak ref holder to copy.
|
|
||||||
@discussion This is merely a copy or implicit cast.
|
|
||||||
*/
|
|
||||||
template <class otherRefType>
|
|
||||||
wxCFWeakRef(const wxCFWeakRef<otherRefType>& otherRef)
|
|
||||||
: m_ptr(otherRef.get()) // Implicit conversion from otherRefType to refType should occur
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFWeakRef
|
|
||||||
@abstract Copies a strong ref holder where its type can be converted to ours
|
|
||||||
@templatefield otherRefType Any type held by a wxCFRef.
|
|
||||||
@param otherRef The strong ref holder to copy.
|
|
||||||
@discussion This ref is merely a pointer copy, the strong ref still holds the pointer.
|
|
||||||
*/
|
|
||||||
template <class otherRefType>
|
|
||||||
wxCFWeakRef(const wxCFRef<otherRefType>& otherRef)
|
|
||||||
: m_ptr(otherRef.get()) // Implicit conversion from otherRefType to refType should occur
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method get
|
|
||||||
@abstract Explicit conversion to the underlying pointer type
|
|
||||||
@discussion Allows the caller to explicitly get the underlying pointer.
|
|
||||||
*/
|
|
||||||
refType get() const
|
|
||||||
{ return m_ptr; }
|
|
||||||
|
|
||||||
/*! @method operator refType
|
|
||||||
@abstract Implicit conversion to the underlying pointer type
|
|
||||||
@discussion Allows the ref to be used in CF function calls.
|
|
||||||
*/
|
|
||||||
operator refType() const
|
|
||||||
{ return m_ptr; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/*! @method wxCFWeakRef
|
|
||||||
@abstract Constructs a weak reference to the raw pointer
|
|
||||||
@templatefield otherType Any type.
|
|
||||||
@param p The raw pointer to assume ownership of. May be NULL.
|
|
||||||
@discussion This method is private so that the friend static_cfref_cast can use it
|
|
||||||
*/
|
|
||||||
template <class otherType>
|
|
||||||
explicit wxCFWeakRef(otherType *p)
|
|
||||||
: m_ptr(p) // Implicit conversion from otherType* to refType should occur.
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @var m_ptr The raw pointer.
|
|
||||||
*/
|
|
||||||
refType m_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! @class wxCFRef
|
|
||||||
@templatefield refType The CF reference type (e.g. CFStringRef, CFRunLoopRef, etc.)
|
|
||||||
It should already be a pointer. This is different from
|
|
||||||
shared_ptr where the template parameter is the pointee type.
|
|
||||||
@discussion Properly retains/releases reference to CoreFoundation objects
|
|
||||||
*/
|
|
||||||
template <class refType>
|
|
||||||
class wxCFRef
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*! @method wxCFRef
|
|
||||||
@abstract Creates a NULL reference
|
|
||||||
*/
|
|
||||||
wxCFRef()
|
|
||||||
: m_ptr(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFRef
|
|
||||||
@abstract Assumes ownership of p and creates a reference to it.
|
|
||||||
@templatefield otherType Any type.
|
|
||||||
@param p The raw pointer to assume ownership of. May be NULL.
|
|
||||||
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to p and intends
|
|
||||||
to transfer ownership of that reference to this ref holder. If the object comes from
|
|
||||||
a Create or Copy method then this is the correct behavior. If the object comes from
|
|
||||||
a Get method then you must CFRetain it yourself before passing it to this constructor.
|
|
||||||
A handy way to do this is to use the non-member wxCFRefFromGet factory funcion.
|
|
||||||
This method is templated and takes an otherType *p. This prevents implicit conversion
|
|
||||||
using an operator refType() in a different ref-holding class type.
|
|
||||||
*/
|
|
||||||
template <class otherType>
|
|
||||||
explicit wxCFRef(otherType *p)
|
|
||||||
: m_ptr(p) // Implicit conversion from otherType* to refType should occur.
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFRef
|
|
||||||
@abstract Copies a ref holder of the same type
|
|
||||||
@param otherRef The other ref holder to copy.
|
|
||||||
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
|
|
||||||
the object will be explicitly retained by this new ref.
|
|
||||||
*/
|
|
||||||
wxCFRef(const wxCFRef& otherRef)
|
|
||||||
: m_ptr(wxCFRetain(otherRef.m_ptr))
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFRef
|
|
||||||
@abstract Copies a ref holder where its type can be converted to ours
|
|
||||||
@templatefield otherRefType Any type held by another wxCFRef.
|
|
||||||
@param otherRef The other ref holder to copy.
|
|
||||||
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
|
|
||||||
the object will be explicitly retained by this new ref.
|
|
||||||
*/
|
|
||||||
template <class otherRefType>
|
|
||||||
wxCFRef(const wxCFRef<otherRefType>& otherRef)
|
|
||||||
: m_ptr(wxCFRetain(otherRef.get())) // Implicit conversion from otherRefType to refType should occur
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method wxCFRef
|
|
||||||
@abstract Copies a weak ref holder where its type can be converted to ours
|
|
||||||
@templatefield otherRefType Any type held by a wxCFWeakRef.
|
|
||||||
@param otherRef The weak ref holder to copy.
|
|
||||||
@discussion Ownership will be taken by this newly created ref. That is,
|
|
||||||
the object will be explicitly retained by this new ref.
|
|
||||||
Ownership is most likely shared with some other ref as well.
|
|
||||||
*/
|
|
||||||
template <class otherRefType>
|
|
||||||
wxCFRef(const wxCFWeakRef<otherRefType>& otherRef)
|
|
||||||
: m_ptr(wxCFRetain(otherRef.get())) // Implicit conversion from otherRefType to refType should occur
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! @method ~wxCFRef
|
|
||||||
@abstract Releases (potentially shared) ownership of the ref.
|
|
||||||
@discussion A ref holder instance is always assumed to have ownership so ownership is always
|
|
||||||
released (CFRelease called) upon destruction.
|
|
||||||
*/
|
|
||||||
~wxCFRef()
|
|
||||||
{ reset(); }
|
|
||||||
|
|
||||||
/*! @method operator=
|
|
||||||
@abstract Assigns the other ref's pointer to us when the otherRef is the same type.
|
|
||||||
@param otherRef The other ref holder to copy.
|
|
||||||
@discussion The incoming pointer is retained, the original pointer is released, and this object
|
|
||||||
is made to point to the new pointer.
|
|
||||||
*/
|
|
||||||
wxCFRef& operator=(const wxCFRef& otherRef)
|
|
||||||
{
|
|
||||||
wxCFRetain(otherRef.m_ptr);
|
|
||||||
wxCFRelease(m_ptr);
|
|
||||||
m_ptr = otherRef.m_ptr;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @method operator=
|
|
||||||
@abstract Assigns the other ref's pointer to us when the other ref can be converted to our type.
|
|
||||||
@templatefield otherRefType Any type held by another wxCFRef
|
|
||||||
@param otherRef The other ref holder to copy.
|
|
||||||
@discussion The incoming pointer is retained, the original pointer is released, and this object
|
|
||||||
is made to point to the new pointer.
|
|
||||||
*/
|
|
||||||
template <class otherRefType>
|
|
||||||
wxCFRef& operator=(const wxCFRef<otherRefType>& otherRef)
|
|
||||||
{
|
|
||||||
wxCFRetain(otherRef.get());
|
|
||||||
wxCFRelease(m_ptr);
|
|
||||||
m_ptr = otherRef.get(); // Implicit conversion from otherRefType to refType should occur
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @method get
|
|
||||||
@abstract Explicit conversion to the underlying pointer type
|
|
||||||
@discussion Allows the caller to explicitly get the underlying pointer.
|
|
||||||
*/
|
|
||||||
refType get() const
|
|
||||||
{ return m_ptr; }
|
|
||||||
|
|
||||||
/*! @method operator refType
|
|
||||||
@abstract Implicit conversion to the underlying pointer type
|
|
||||||
@discussion Allows the ref to be used in CF function calls.
|
|
||||||
*/
|
|
||||||
operator refType() const
|
|
||||||
{ return m_ptr; }
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
< // HeaderDoc is retarded and thinks the GT from operator-> is part of a template param.
|
|
||||||
// So give it that < outside of a comment to fake it out. (if 0 is not a comment to HeaderDoc)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*! @method operator->
|
|
||||||
@abstract Implicit conversion to the underlying pointer type
|
|
||||||
@discussion This is nearly useless for CF types which are nearly always opaque
|
|
||||||
*/
|
|
||||||
refType operator-> () const
|
|
||||||
{ return m_ptr; }
|
|
||||||
|
|
||||||
/*! @method reset
|
|
||||||
@abstract Nullifies the reference
|
|
||||||
@discussion Releases ownership (calls CFRelease) before nullifying the pointer.
|
|
||||||
*/
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
wxCFRelease(m_ptr);
|
|
||||||
m_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @method reset
|
|
||||||
@abstract Sets this to a new reference
|
|
||||||
@templatefield otherType Any type.
|
|
||||||
@param p The raw pointer to assume ownership of
|
|
||||||
@discussion The existing reference is released (like destruction). It is assumed that the caller
|
|
||||||
has a strong reference to the new p and intends to transfer ownership of that reference
|
|
||||||
to this ref holder. Take care to call CFRetain if you received the object from a Get method.
|
|
||||||
This method is templated and takes an otherType *p. This prevents implicit conversion
|
|
||||||
using an operator refType() in a different ref-holding class type.
|
|
||||||
*/
|
|
||||||
template <class otherType>
|
|
||||||
void reset(otherType* p)
|
|
||||||
{
|
|
||||||
wxCFRelease(m_ptr);
|
|
||||||
m_ptr = p; // Automatic conversion should occur
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
/*! @var m_ptr The raw pointer.
|
|
||||||
*/
|
|
||||||
refType m_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! @function wxCFRefFromGet
|
|
||||||
@abstract Factory function to create wxCFRef from a raw pointer obtained from a Get-rule function
|
|
||||||
@param p The pointer to retain and create a wxCFRef from. May be NULL.
|
|
||||||
@discussion Unlike the wxCFRef raw pointer constructor, this function explicitly retains its
|
|
||||||
argument. This can be used for functions such as CFDictionaryGetValue() or
|
|
||||||
CFAttributedStringGetString() which return a temporary reference (Get-rule functions).
|
|
||||||
FIXME: Anybody got a better name?
|
|
||||||
*/
|
|
||||||
template <typename Type>
|
|
||||||
inline wxCFRef<Type*> wxCFRefFromGet(Type *p)
|
|
||||||
{
|
|
||||||
return wxCFRef<Type*>(wxCFRetain(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @function static_cfref_cast
|
|
||||||
@abstract Works like static_cast but with a wxCFRef as the argument.
|
|
||||||
@param refType Template parameter. The destination raw pointer type
|
|
||||||
@param otherRef Normal parameter. The source wxCFRef<> object.
|
|
||||||
@discussion This is intended to be a clever way to make static_cast work while allowing
|
|
||||||
the return value to be converted to either a strong ref or a raw pointer
|
|
||||||
while ensuring that the retain count is updated appropriately.
|
|
||||||
|
|
||||||
This is modeled after shared_ptr's static_pointer_cast. Just as wxCFRef is
|
|
||||||
parameterized on a pointer to an opaque type so is this class. Note that
|
|
||||||
this differs from shared_ptr which is parameterized on the pointee type.
|
|
||||||
|
|
||||||
FIXME: Anybody got a better name?
|
|
||||||
*/
|
|
||||||
template <class refType, class otherRefType>
|
|
||||||
inline wxCFWeakRef<refType> static_cfref_cast(const wxCFRef<otherRefType> &otherRef);
|
|
||||||
|
|
||||||
template <class refType, class otherRefType>
|
|
||||||
inline wxCFWeakRef<refType> static_cfref_cast(const wxCFRef<otherRefType> &otherRef)
|
|
||||||
{
|
|
||||||
return wxCFWeakRef<refType>(static_cast<refType>(otherRef.get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! @function CFRelease
|
|
||||||
@abstract Overloads CFRelease so that the user is warned of bad behavior.
|
|
||||||
@discussion It is rarely appropriate to retain or release a wxCFRef. If one absolutely
|
|
||||||
must do it he can explicitly get() the raw pointer
|
|
||||||
Normally, this function is unimplemented resulting in a linker error if used.
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
inline void CFRelease(const wxCFRef<T*> & cfref) DEPRECATED_ATTRIBUTE;
|
|
||||||
|
|
||||||
/*! @function CFRetain
|
|
||||||
@abstract Overloads CFRetain so that the user is warned of bad behavior.
|
|
||||||
@discussion It is rarely appropriate to retain or release a wxCFRef. If one absolutely
|
|
||||||
must do it he can explicitly get() the raw pointer
|
|
||||||
Normally, this function is unimplemented resulting in a linker error if used.
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
inline void CFRetain(const wxCFRef<T*>& cfref) DEPRECATED_ATTRIBUTE;
|
|
||||||
|
|
||||||
// Change the 0 to a 1 if you want the functions to work (no link errors)
|
|
||||||
// Neither function will cause retain/release side-effects if implemented.
|
|
||||||
#if 0
|
|
||||||
template <class T>
|
|
||||||
void CFRelease(const wxCFRef<T*> & cfref)
|
|
||||||
{
|
|
||||||
CFRelease(cfref.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void CFRetain(const wxCFRef<T*> & cfref)
|
|
||||||
{
|
|
||||||
CFRetain(cfref.get());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //ndef _WX_MAC_COREFOUNDATION_CFREF_H__
|
|
||||||
|
|
@@ -1,80 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/cfstring.h
|
|
||||||
// Purpose: wxCFStringRef and other string functions
|
|
||||||
// Author: Stefan Csomor
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2004-10-29 (from code in wx/mac/carbon/private.h)
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Stefan Csomor
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
// Usage: Darwin (base library)
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __WX_CFSTRINGHOLDER_H__
|
|
||||||
#define __WX_CFSTRINGHOLDER_H__
|
|
||||||
|
|
||||||
#include <CoreFoundation/CFString.h>
|
|
||||||
|
|
||||||
#include "wx/dlimpexp.h"
|
|
||||||
#include "wx/fontenc.h"
|
|
||||||
#include "wx/mac/corefoundation/cfref.h"
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxString;
|
|
||||||
|
|
||||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxString *data ) ;
|
|
||||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( wxString *data ) ;
|
|
||||||
|
|
||||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data ) ;
|
|
||||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( char * data ) ;
|
|
||||||
|
|
||||||
WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
|
|
||||||
WXDLLIMPEXP_BASE wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
|
|
||||||
WXDLLIMPEXP_BASE void wxMacWakeUp() ;
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxCFStringRef : public wxCFRef< CFStringRef >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxCFStringRef()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCFStringRef(const wxString &str,
|
|
||||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT) ;
|
|
||||||
|
|
||||||
wxCFStringRef(CFStringRef ref)
|
|
||||||
: wxCFRef< CFStringRef >(ref)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCFStringRef(const wxCFStringRef& otherRef )
|
|
||||||
: wxCFRef< CFStringRef >(otherRef)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~wxCFStringRef()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
|
|
||||||
|
|
||||||
private:
|
|
||||||
} ;
|
|
||||||
|
|
||||||
// corresponding class for holding UniChars (native unicode characters)
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxMacUniCharBuffer
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
wxMacUniCharBuffer( const wxString &str ) ;
|
|
||||||
|
|
||||||
~wxMacUniCharBuffer() ;
|
|
||||||
|
|
||||||
UniCharPtr GetBuffer() ;
|
|
||||||
|
|
||||||
UniCharCount GetChars() ;
|
|
||||||
|
|
||||||
private :
|
|
||||||
UniCharPtr m_ubuf ;
|
|
||||||
UniCharCount m_chars ;
|
|
||||||
};
|
|
||||||
#endif //__WXCFSTRINGHOLDER_H__
|
|
@@ -1,116 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/hid.h
|
|
||||||
// Purpose: DARWIN HID layer for WX
|
|
||||||
// Author: Ryan Norton
|
|
||||||
// Modified by:
|
|
||||||
// Created: 11/11/2003
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Ryan Norton
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// ===========================================================================
|
|
||||||
// declarations
|
|
||||||
// ===========================================================================
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// headers
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _WX_MACCARBONHID_H_
|
|
||||||
#define _WX_MACCARBONHID_H_
|
|
||||||
|
|
||||||
#include "wx/defs.h"
|
|
||||||
#include "wx/string.h"
|
|
||||||
|
|
||||||
//Mac OSX only
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
|
|
||||||
#include <IOKit/IOKitLib.h>
|
|
||||||
#include <IOKit/IOCFPlugIn.h>
|
|
||||||
#include <IOKit/hid/IOHIDLib.h>
|
|
||||||
#include <IOKit/hid/IOHIDKeys.h>
|
|
||||||
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
|
|
||||||
|
|
||||||
//Darn apple - doesn't properly wrap their headers in extern "C"!
|
|
||||||
//http://www.macosx.com/forums/archive/index.php/t-68069.html
|
|
||||||
//Needed for codewarrior link error with mach_port_deallocate()
|
|
||||||
extern "C" {
|
|
||||||
#include <mach/mach_port.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <mach/mach.h> //this actually includes mach_port.h (see above)
|
|
||||||
|
|
||||||
// ===========================================================================
|
|
||||||
// definitions
|
|
||||||
// ===========================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// wxHIDDevice
|
|
||||||
//
|
|
||||||
// A wrapper around OS X HID Manager procedures.
|
|
||||||
// The tutorial "Working With HID Class Device Interfaces" Is
|
|
||||||
// Quite good, as is the sample program associated with it
|
|
||||||
// (Depite the author's protests!).
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
class WXDLLIMPEXP_CORE wxHIDDevice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
|
|
||||||
|
|
||||||
bool Create (int nClass = -1, int nType = -1, int nDev = 1);
|
|
||||||
|
|
||||||
static size_t GetCount(int nClass = -1, int nType = -1);
|
|
||||||
|
|
||||||
void AddCookie(CFTypeRef Data, int i);
|
|
||||||
void AddCookieInQueue(CFTypeRef Data, int i);
|
|
||||||
void InitCookies(size_t dwSize, bool bQueue = false);
|
|
||||||
|
|
||||||
//Must be implemented by derived classes
|
|
||||||
//builds the cookie array -
|
|
||||||
//first call InitCookies to initialize the cookie
|
|
||||||
//array, then AddCookie to add a cookie at a certain point in an array
|
|
||||||
virtual void BuildCookies(CFArrayRef Array) = 0;
|
|
||||||
|
|
||||||
//checks to see whether the cookie at nIndex is active (element value != 0)
|
|
||||||
bool IsActive(int nIndex);
|
|
||||||
|
|
||||||
//checks to see whether an element in the internal cookie array
|
|
||||||
//exists
|
|
||||||
bool HasElement(int nIndex);
|
|
||||||
|
|
||||||
//closes the device and cleans the queue and cookies
|
|
||||||
virtual ~wxHIDDevice();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
IOHIDDeviceInterface** m_ppDevice; //this, essentially
|
|
||||||
IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
|
|
||||||
IOHIDElementCookie* m_pCookies; //cookies
|
|
||||||
|
|
||||||
wxString m_szProductName; //product name
|
|
||||||
int m_nProductId; //product id
|
|
||||||
int m_nManufacturerId; //manufacturer id
|
|
||||||
mach_port_t m_pPort; //mach port to use
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// wxHIDKeyboard
|
|
||||||
//
|
|
||||||
// Semi-simple implementation that opens a connection to the first
|
|
||||||
// keyboard of the machine. Used in wxGetKeyState.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
class WXDLLIMPEXP_CORE wxHIDKeyboard : public wxHIDDevice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static int GetCount();
|
|
||||||
bool Create(int nDev = 1);
|
|
||||||
void AddCookie(CFTypeRef Data, int i);
|
|
||||||
virtual void BuildCookies(CFArrayRef Array);
|
|
||||||
void DoBuildCookies(CFArrayRef Array);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__DARWIN__
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// _WX_MACCARBONHID_H_
|
|
@@ -1,93 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: joystick.h
|
|
||||||
// Purpose: wxJoystick class
|
|
||||||
// Author: Ryan Norton
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2/13/2005
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Ryan Norton
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _WX_JOYSTICK_H_
|
|
||||||
#define _WX_JOYSTICK_H_
|
|
||||||
|
|
||||||
#include "wx/event.h"
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxJoystickThread;
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxJoystick: public wxObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxJoystick)
|
|
||||||
public:
|
|
||||||
|
|
||||||
wxJoystick(int joystick = wxJOYSTICK1);
|
|
||||||
virtual ~wxJoystick();
|
|
||||||
|
|
||||||
// Attributes
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
wxPoint GetPosition() const;
|
|
||||||
int GetPosition(unsigned axis) const;
|
|
||||||
bool GetButtonState(unsigned button) const;
|
|
||||||
int GetZPosition() const;
|
|
||||||
int GetButtonState() const;
|
|
||||||
int GetPOVPosition() const;
|
|
||||||
int GetPOVCTSPosition() const;
|
|
||||||
int GetRudderPosition() const;
|
|
||||||
int GetUPosition() const;
|
|
||||||
int GetVPosition() const;
|
|
||||||
int GetMovementThreshold() const;
|
|
||||||
void SetMovementThreshold(int threshold) ;
|
|
||||||
|
|
||||||
// Capabilities
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool IsOk() const; // Checks that the joystick is functioning
|
|
||||||
static int GetNumberJoysticks() ;
|
|
||||||
int GetManufacturerId() const ;
|
|
||||||
int GetProductId() const ;
|
|
||||||
wxString GetProductName() const ;
|
|
||||||
int GetXMin() const;
|
|
||||||
int GetYMin() const;
|
|
||||||
int GetZMin() const;
|
|
||||||
int GetXMax() const;
|
|
||||||
int GetYMax() const;
|
|
||||||
int GetZMax() const;
|
|
||||||
int GetNumberButtons() const;
|
|
||||||
int GetNumberAxes() const;
|
|
||||||
int GetMaxButtons() const;
|
|
||||||
int GetMaxAxes() const;
|
|
||||||
int GetPollingMin() const;
|
|
||||||
int GetPollingMax() const;
|
|
||||||
int GetRudderMin() const;
|
|
||||||
int GetRudderMax() const;
|
|
||||||
int GetUMin() const;
|
|
||||||
int GetUMax() const;
|
|
||||||
int GetVMin() const;
|
|
||||||
int GetVMax() const;
|
|
||||||
|
|
||||||
bool HasRudder() const;
|
|
||||||
bool HasZ() const;
|
|
||||||
bool HasU() const;
|
|
||||||
bool HasV() const;
|
|
||||||
bool HasPOV() const;
|
|
||||||
bool HasPOV4Dir() const;
|
|
||||||
bool HasPOVCTS() const;
|
|
||||||
|
|
||||||
// Operations
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// pollingFreq = 0 means that movement events are sent when above the threshold.
|
|
||||||
// If pollingFreq > 0, events are received every this many milliseconds.
|
|
||||||
bool SetCapture(wxWindow* win, int pollingFreq = 0);
|
|
||||||
bool ReleaseCapture();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_joystick;
|
|
||||||
wxJoystickThread* m_thread;
|
|
||||||
class wxHIDJoystick* m_hid;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// _WX_JOYSTICK_H_
|
|
@@ -1,82 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/private.h
|
|
||||||
// Purpose: Private declarations: as this header is only included by
|
|
||||||
// wxWidgets itself, it may contain identifiers which don't start
|
|
||||||
// with "wx".
|
|
||||||
// Author: Stefan Csomor
|
|
||||||
// Modified by:
|
|
||||||
// Created: 1998-01-01
|
|
||||||
// RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
|
|
||||||
// Copyright: (c) Stefan Csomor
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _WX_PRIVATE_H_
|
|
||||||
#define _WX_PRIVATE_H_
|
|
||||||
|
|
||||||
#include "wx/defs.h"
|
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
|
||||||
|
|
||||||
#include "wx/mac/corefoundation/cfstring.h"
|
|
||||||
#include "wx/mac/corefoundation/cfdataref.h"
|
|
||||||
|
|
||||||
#if wxUSE_GUI
|
|
||||||
|
|
||||||
#include <CoreGraphics/CoreGraphics.h>
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
|
|
||||||
{
|
|
||||||
DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxMacCGContextStateSaver( CGContextRef cg )
|
|
||||||
{
|
|
||||||
m_cg = cg;
|
|
||||||
CGContextSaveGState( cg );
|
|
||||||
}
|
|
||||||
~wxMacCGContextStateSaver()
|
|
||||||
{
|
|
||||||
CGContextRestoreGState( m_cg );
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
CGContextRef m_cg;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Quartz
|
|
||||||
|
|
||||||
WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap );
|
|
||||||
|
|
||||||
WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data );
|
|
||||||
WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data );
|
|
||||||
WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf );
|
|
||||||
|
|
||||||
CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void);
|
|
||||||
|
|
||||||
#endif // wxUSE_GUI
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// cocoa bridging utilities
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool wxMacInitCocoa();
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxMacAutoreleasePool
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
wxMacAutoreleasePool();
|
|
||||||
~wxMacAutoreleasePool();
|
|
||||||
private :
|
|
||||||
void* m_pool;
|
|
||||||
};
|
|
||||||
|
|
||||||
// NSObject
|
|
||||||
|
|
||||||
void wxMacCocoaRelease( void* obj );
|
|
||||||
void wxMacCocoaAutorelease( void* obj );
|
|
||||||
void wxMacCocoaRetain( void* obj );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// _WX_PRIVATE_H_
|
|
@@ -1,67 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: wx/mac/corefoundation/stdpaths.h
|
|
||||||
// Purpose: wxStandardPaths for CoreFoundation systems
|
|
||||||
// Author: David Elliott
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2004-10-27
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) 2004 David Elliott
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _WX_MAC_STDPATHS_H_
|
|
||||||
#define _WX_MAC_STDPATHS_H_
|
|
||||||
|
|
||||||
struct __CFBundle;
|
|
||||||
struct __CFURL;
|
|
||||||
|
|
||||||
typedef const __CFURL * wxCFURLRef;
|
|
||||||
typedef __CFBundle * wxCFBundleRef;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxStandardPaths
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxStandardPathsCF : public wxStandardPathsBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxStandardPathsCF();
|
|
||||||
virtual ~wxStandardPathsCF();
|
|
||||||
|
|
||||||
// wxMac specific: allow user to specify a different bundle
|
|
||||||
wxStandardPathsCF(wxCFBundleRef bundle);
|
|
||||||
void SetBundle(wxCFBundleRef bundle);
|
|
||||||
|
|
||||||
// implement base class pure virtuals
|
|
||||||
virtual wxString GetExecutablePath() const;
|
|
||||||
virtual wxString GetConfigDir() const;
|
|
||||||
virtual wxString GetUserConfigDir() const;
|
|
||||||
virtual wxString GetDataDir() const;
|
|
||||||
virtual wxString GetLocalDataDir() const;
|
|
||||||
virtual wxString GetUserDataDir() const;
|
|
||||||
virtual wxString GetPluginsDir() const;
|
|
||||||
virtual wxString GetResourcesDir() const;
|
|
||||||
virtual wxString
|
|
||||||
GetLocalizedResourcesDir(const wxString& lang,
|
|
||||||
ResourceCat category = ResourceCat_None) const;
|
|
||||||
virtual wxString GetDocumentsDir() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// this function can be called with any of CFBundleCopyXXXURL function
|
|
||||||
// pointer as parameter
|
|
||||||
wxString GetFromFunc(wxCFURLRef (*func)(wxCFBundleRef)) const;
|
|
||||||
|
|
||||||
wxCFBundleRef m_bundle;
|
|
||||||
};
|
|
||||||
|
|
||||||
// If using UNIX (i.e. darwin) then use UNIX standard paths
|
|
||||||
#if defined(__UNIX__)
|
|
||||||
#include "wx/unix/stdpaths.h"
|
|
||||||
#else
|
|
||||||
// If compiling wxMac for CarbonLib then we are wxStandardPaths
|
|
||||||
class WXDLLIMPEXP_BASE wxStandardPaths: public wxStandardPathsCF
|
|
||||||
{
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _WX_MAC_STDPATHS_H_
|
|
Reference in New Issue
Block a user