Import r67258 of the wxWidgets trunk, which I expect will before

long become wxWidgets 2.9.2, which in turn is expected to be the
last 2.9 release before the 3.0 stable release.

Since the full wxWidgets distribution is rather large, I have
imported only the parts that we use, on a subdirectory basis:

art
include/wx/*.*
include/wx/aui
include/wx/cocoa
include/wx/generic
include/wx/gtk
include/wx/meta
include/wx/msw
include/wx/osx
include/wx/persist
include/wx/private
include/wx/protocol
include/wx/unix
src/aui
src/common
src/generic
src/gtk
src/msw
src/osx
src/unix


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7380 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-03-20 18:05:19 +00:00
parent 205637ccc3
commit d14efe561b
1945 changed files with 694474 additions and 0 deletions

View File

@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfdataref.h
// Purpose: wxCFDataRef class
// Author: Stefan Csomor
// Modified by:
// Created: 2007/05/10
// RCS-ID: $Id: cfdataref.h 67232 2011-03-18 15:10:15Z DS $
// Copyright: (c) 2007 Stefan Csomor
// Licence: wxWindows licence
// Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBinaryData/index.html
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cfdataref.h
@abstract wxCFDataRef template class
*/
#ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__
#define _WX_MAC_COREFOUNDATION_CFDATAREF_H__
#include "wx/osx/core/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__

View File

@ -0,0 +1,401 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfref.h
// Purpose: wxCFRef template class
// Author: David Elliott <dfe@cox.net>
// Modified by: Stefan Csomor
// Created: 2007/05/10
// RCS-ID: $Id: cfref.h 64943 2010-07-13 13:29:58Z VZ $
// 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/osx/core/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)
{
if (this != &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-&gt;
@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
}
// Release the pointer, i.e. give up its ownership.
refType release()
{
refType p = m_ptr;
m_ptr = NULL;
return p;
}
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__

View File

@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/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: cfstring.h 64943 2010-07-13 13:29:58Z VZ $
// 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/osx/core/cfref.h"
#ifdef WORDS_BIGENDIAN
#define kCFStringEncodingUTF32Native kCFStringEncodingUTF32BE
#else
#define kCFStringEncodingUTF32Native kCFStringEncodingUTF32LE
#endif
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) ;
#if wxOSX_USE_COCOA_OR_IPHONE
wxCFStringRef(NSString* ref)
: wxCFRef< CFStringRef >((CFStringRef) ref)
{
}
#endif
wxCFStringRef(CFStringRef ref)
: wxCFRef< CFStringRef >(ref)
{
}
wxCFStringRef(const wxCFStringRef& otherRef )
: wxCFRef< CFStringRef >(otherRef)
{
}
~wxCFStringRef()
{
}
wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) const;
static wxString AsString( CFStringRef ref, wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
#if wxOSX_USE_COCOA_OR_IPHONE
static wxString AsString( NSString* ref, wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
#endif
#if wxOSX_USE_COCOA_OR_IPHONE
NSString* AsNSString() const { return (NSString*)(CFStringRef) *this; }
#endif
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__

View File

@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/colour.h
// Purpose: wxColour class
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id: colour.h 67068 2011-02-27 12:48:42Z VZ $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_
#define _WX_COLOUR_H_
#include "wx/object.h"
#include "wx/string.h"
#include "wx/osx/core/cfref.h"
struct RGBColor;
// Colour
class WXDLLIMPEXP_CORE wxColour: public wxColourBase
{
public:
// constructors
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// default copy ctor and dtor are ok
// accessors
virtual bool IsOk() const { return m_cgColour != NULL; }
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Red() const { return m_red; }
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Green() const { return m_green; }
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Blue() const { return m_blue; }
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Alpha() const { return m_alpha; }
// comparison
bool operator == (const wxColour& colour) const;
bool operator != (const wxColour& colour) const { return !(*this == colour); }
CGColorRef GetPixel() const { return m_cgColour; };
CGColorRef GetCGColor() const { return m_cgColour; };
CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); };
#if wxOSX_USE_COCOA_OR_CARBON
void GetRGBColor( RGBColor *col ) const;
#endif
// Mac-specific ctor and assignment operator from the native colour
// assumes ownership of CGColorRef
wxColour( CGColorRef col );
#if wxOSX_USE_COCOA_OR_CARBON
wxColour(const RGBColor& col);
wxColour& operator=(const RGBColor& col);
#endif
#if wxOSX_USE_COCOA
wxColour(WX_NSColor color);
WX_NSColor OSXGetNSColor() const;
#endif
wxColour& operator=(CGColorRef col);
wxColour& operator=(const wxColour& col);
protected :
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a);
#if wxOSX_USE_COCOA_OR_CARBON
void InitRGBColor( const RGBColor& col );
#endif
void InitCGColorRef( CGColorRef col );
void InitFromComponents(const CGFloat* components, size_t numComponents );
private:
wxCFRef<CGColorRef> m_cgColour;
ChannelType m_red;
ChannelType m_blue;
ChannelType m_green;
ChannelType m_alpha;
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif
// _WX_COLOUR_H_

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/dataview.h
// Purpose: wxDataViewCtrl native implementation header for OSX
// Author:
// Id: $Id: dataview.h 57374 2009-01-27
// Copyright: (c) 2009
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAVIEWCTRL_CORE_H_
#define _WX_DATAVIEWCTRL_CORE_H_
#include "wx/dataview.h"
#if wxOSX_USE_CARBON
typedef wxMacControl wxWidgetImplType;
#else
typedef wxWidgetImpl wxWidgetImplType;
#endif
// ---------------------------------------------------------
// Helper functions for dataview implementation on OSX
// ---------------------------------------------------------
wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID id,
wxPoint const& pos, wxSize const& size,
long style, long extraStyle);
wxString ConcatenateDataViewItemValues(wxDataViewCtrl const* dataViewCtrlPtr, wxDataViewItem const& dataViewItem); // concatenates all data of the visible columns of the passed control
// and item TAB separated into a string and returns it
// ---------------------------------------------------------
// wxDataViewWidgetImpl
// Common interface of the native dataview implementation
// for the carbon and cocoa environment.
// ATTENTION
// All methods assume that the passed column pointers are
// valid (unless a NULL pointer is explicitely allowed
// to be passed)!
// ATTENTION
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewWidgetImpl
{
public:
//
// constructors / destructor
//
virtual ~wxDataViewWidgetImpl(void)
{
}
//
// column related methods
//
virtual bool ClearColumns (void) = 0; // deletes all columns in the native control
virtual bool DeleteColumn (wxDataViewColumn* columnPtr) = 0; // deletes the column in the native control
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr) = 0; // sets the disclosure column in the native control
virtual wxDataViewColumn* GetColumn (unsigned int pos) const = 0; // returns the column belonging to 'pos' in the native control
virtual int GetColumnPosition (wxDataViewColumn const* columnPtr) const = 0; // returns the position of the passed column in the native control
virtual bool InsertColumn (unsigned int pos, wxDataViewColumn* columnPtr) = 0; // inserts a column at pos in the native control;
// the method can assume that the column's owner is already set
virtual void FitColumnWidthToContent(unsigned int pos) = 0; // resizes column to fit its content
//
// item related methods
//
virtual bool Add (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // adds an item to the native control
virtual bool Add (wxDataViewItem const& parent, wxDataViewItemArray const& itesm) = 0; // adds a items to the native control
virtual void Collapse (wxDataViewItem const& item) = 0; // collapses the passed item in the native control
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // ensures that the passed item's value in the passed column is visible (column pointer can be NULL)
virtual void Expand (wxDataViewItem const& item) = 0; // expands the passed item in the native control
virtual unsigned int GetCount (void) const = 0; // returns the number of items in the native control
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // returns the rectangle that is used by the passed item and column in the native control
virtual bool IsExpanded (wxDataViewItem const& item) const = 0; // checks if the passed item is expanded in the native control
virtual bool Reload (void) = 0; // clears the native control and reloads all data
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // removes an item from the native control
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItemArray const& item) = 0; // removes items from the native control
virtual bool Update (wxDataViewColumn const* columnPtr) = 0; // updates the items in the passed column of the native control
virtual bool Update (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // updates the passed item in the native control
virtual bool Update (wxDataViewItem const& parent, wxDataViewItemArray const& items) = 0; // updates the passed items in the native control
//
// model related methods
//
virtual bool AssociateModel(wxDataViewModel* model) = 0; // informs the native control that a model is present
//
// selection related methods
//
virtual wxDataViewItem GetCurrentItem() const = 0;
virtual void SetCurrentItem(const wxDataViewItem& item) = 0;
virtual int GetSelections(wxDataViewItemArray& sel) const = 0; // returns all selected items in the native control
virtual bool IsSelected (wxDataViewItem const& item) const = 0; // checks if the passed item is selected in the native control
virtual void Select (wxDataViewItem const& item) = 0; // selects the passed item in the native control
virtual void SelectAll (void) = 0; // selects all items in the native control
virtual void Unselect (wxDataViewItem const& item) = 0; // unselects the passed item in the native control
virtual void UnselectAll (void) = 0; // unselects all items in the native control
//
// sorting related methods
//
virtual wxDataViewColumn* GetSortingColumn (void) const = 0; // returns the column that is primarily responsible for sorting in the native control
virtual void Resort (void) = 0; // asks the native control to start a resorting process
//
// other methods
//
virtual void DoSetIndent (int indent) = 0; // sets the indention in the native control
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const = 0; // return the item and column pointer that contains with the passed point
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height) = 0; // sets the height of the row containg the passed item in the native control
virtual void OnSize (void) = 0; // updates the layout of the native control after a size event
};
#endif // _WX_DATAVIEWCTRL_CORE_H_

View File

@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/hid.h
// Purpose: DARWIN HID layer for WX
// Author: Ryan Norton
// Modified by:
// Created: 11/11/2003
// RCS-ID: $Id: hid.h 64943 2010-07-13 13:29:58Z VZ $
// 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_

View File

@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/joystick.h
// Purpose: wxJoystick class
// Author: Ryan Norton
// Modified by:
// Created: 2/13/2005
// RCS-ID: $Id: joystick.h 67254 2011-03-20 00:14:35Z DS $
// 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_

View File

@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/mimetype.h
// Purpose: Mac implementation for wx mime-related classes
// Author: Neil Perkins
// Modified by:
// Created: 2010-05-15
// RCS-ID: $Id: mimetype.h 67232 2011-03-18 15:10:15Z DS $
// Copyright: (C) 2010 Neil Perkins
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _MIMETYPE_IMPL_H
#define _MIMETYPE_IMPL_H
#include "wx/defs.h"
#if wxUSE_MIMETYPE
#include "wx/mimetype.h"
#include "wx/hashmap.h"
#include "wx/iconloc.h"
// This class implements mime type functionality for Mac OS X using UTIs and Launch Services
// Currently only the GetFileTypeFromXXXX public functions have been implemented
class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
{
public:
wxMimeTypesManagerImpl();
virtual ~wxMimeTypesManagerImpl();
// These functions are not needed on Mac OS X and have no-op implementations
void Initialize(int mailcapStyles = wxMAILCAP_STANDARD, const wxString& extraDir = wxEmptyString);
void ClearData();
// Functions to look up types by ext, mime or UTI
wxFileType *GetFileTypeFromExtension(const wxString& ext);
wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
wxFileType *GetFileTypeFromUti(const wxString& uti);
// These functions are only stubs on Mac OS X
size_t EnumAllFileTypes(wxArrayString& mimetypes);
wxFileType *Associate(const wxFileTypeInfo& ftInfo);
bool Unassociate(wxFileType *ft);
private:
// The work of querying the OS for type data is done in these two functions
void LoadTypeDataForUti(const wxString& uti);
void LoadDisplayDataForUti(const wxString& uti);
// These functions are pass-throughs from wxFileTypeImpl
bool GetExtensions(const wxString& uti, wxArrayString& extensions);
bool GetMimeType(const wxString& uti, wxString *mimeType);
bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
// Structure to represent file types
typedef struct FileTypeData
{
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
wxString description;
}
FileTypeInfo;
// Map types
WX_DECLARE_STRING_HASH_MAP( wxString, TagMap );
WX_DECLARE_STRING_HASH_MAP( FileTypeData, UtiMap );
// Data store
TagMap m_extMap;
TagMap m_mimeMap;
UtiMap m_utiMap;
friend class wxFileTypeImpl;
};
// This class provides the interface between wxFileType and wxMimeTypesManagerImple for Mac OS X
// Currently only extension, mimetype, description and icon information is available
// All other methods have no-op implementation
class WXDLLIMPEXP_BASE wxFileTypeImpl
{
public:
wxFileTypeImpl();
virtual ~wxFileTypeImpl();
bool GetExtensions(wxArrayString& extensions) const ;
bool GetMimeType(wxString *mimeType) const ;
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
// These functions are only stubs on Mac OS X
bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
bool Unassociate(wxFileType *ft);
private:
// All that is needed to query type info - UTI and pointer to the manager
wxString m_uti;
wxMimeTypesManagerImpl* m_manager;
friend class wxMimeTypesManagerImpl;
};
#endif // wxUSE_MIMETYPE
#endif //_MIMETYPE_IMPL_H

View File

@ -0,0 +1,895 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/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 67233 2011-03-18 15:45:51Z SC $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_CORE_H_
#define _WX_PRIVATE_CORE_H_
#include "wx/defs.h"
#include <CoreFoundation/CoreFoundation.h>
#include "wx/osx/core/cfstring.h"
#include "wx/osx/core/cfdataref.h"
// Define helper macros allowing to insert small snippets of code to be
// compiled for high enough OS X version only: this shouldn't be abused for
// anything big but it's handy for e.g. specifying OS X 10.6-only protocols in
// the Objective C classes declarations when they're not supported under the
// previous versions
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#define wxOSX_10_6_AND_LATER(x) x
#else
#define wxOSX_10_6_AND_LATER(x)
#endif
#if !wxUSE_GUI || wxOSX_USE_COCOA_OR_CARBON
// Carbon functions are currently still used in wxOSX/Cocoa too (including
// wxBase part of it).
#include <Carbon/Carbon.h>
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to );
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from );
WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
#endif
#if wxUSE_GUI
#if wxOSX_USE_IPHONE
#include <CoreGraphics/CoreGraphics.h>
#else
#include <ApplicationServices/ApplicationServices.h>
#endif
#include "wx/bitmap.h"
#include "wx/window.h"
class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
{
wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver);
public:
wxMacCGContextStateSaver( CGContextRef cg )
{
m_cg = cg;
CGContextSaveGState( cg );
}
~wxMacCGContextStateSaver()
{
CGContextRestoreGState( m_cg );
}
private:
CGContextRef m_cg;
};
class WXDLLIMPEXP_CORE wxDeferredObjectDeleter : public wxObject
{
public :
wxDeferredObjectDeleter( wxObject* obj ) : m_obj(obj)
{
}
virtual ~wxDeferredObjectDeleter()
{
delete m_obj;
}
protected :
wxObject* m_obj ;
} ;
// 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);
class wxWindowMac;
// to
extern wxWindow* g_MacLastWindow;
class wxNonOwnedWindow;
// temporary typedef so that no additional casts are necessary within carbon code at the moment
class wxMacControl;
class wxWidgetImpl;
class wxComboBox;
class wxNotebook;
class wxTextCtrl;
class wxSearchCtrl;
WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl );
#if wxOSX_USE_CARBON
typedef wxMacControl wxWidgetImplType;
#else
typedef wxWidgetImpl wxWidgetImplType;
#endif
#if wxUSE_MENUS
class wxMenuItemImpl : public wxObject
{
public :
wxMenuItemImpl( wxMenuItem* peer ) : m_peer(peer)
{
}
virtual ~wxMenuItemImpl() ;
virtual void SetBitmap( const wxBitmap& bitmap ) = 0;
virtual void Enable( bool enable ) = 0;
virtual void Check( bool check ) = 0;
virtual void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) = 0;
virtual void Hide( bool hide = true ) = 0;
virtual void * GetHMenuItem() = 0;
wxMenuItem* GetWXPeer() { return m_peer ; }
static wxMenuItemImpl* Create( wxMenuItem* peer, wxMenu *pParentMenu,
int id,
const wxString& text,
wxAcceleratorEntry *entry,
const wxString& strHelp,
wxItemKind kind,
wxMenu *pSubMenu );
// handle OS specific menu items if they weren't handled during normal processing
virtual bool DoDefault() { return false; }
protected :
wxMenuItem* m_peer;
DECLARE_ABSTRACT_CLASS(wxMenuItemImpl)
} ;
class wxMenuImpl : public wxObject
{
public :
wxMenuImpl( wxMenu* peer ) : m_peer(peer)
{
}
virtual ~wxMenuImpl() ;
virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) = 0;
virtual void Remove( wxMenuItem *pItem ) = 0;
virtual void MakeRoot() = 0;
virtual void SetTitle( const wxString& text ) = 0;
virtual WXHMENU GetHMenu() = 0;
wxMenu* GetWXPeer() { return m_peer ; }
virtual void PopUp( wxWindow *win, int x, int y ) = 0;
static wxMenuImpl* Create( wxMenu* peer, const wxString& title );
static wxMenuImpl* CreateRootMenu( wxMenu* peer );
protected :
wxMenu* m_peer;
DECLARE_ABSTRACT_CLASS(wxMenuItemImpl)
} ;
#endif
class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject
{
public :
wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false );
wxWidgetImpl();
virtual ~wxWidgetImpl();
void Init();
bool IsRootControl() const { return m_isRootControl; }
bool IsUserPane() const { return m_isUserPane; }
wxWindowMac* GetWXPeer() const { return m_wxPeer; }
bool IsOk() const { return GetWXWidget() != NULL; }
// not only the control itself, but also all its parents must be visible
// in order for this function to return true
virtual bool IsVisible() const = 0;
// set the visibility of this widget (maybe latent)
virtual void SetVisibility( bool visible ) = 0;
virtual bool ShowWithEffect(bool WXUNUSED(show),
wxShowEffect WXUNUSED(effect),
unsigned WXUNUSED(timeout))
{
return false;
}
virtual void Raise() = 0;
virtual void Lower() = 0;
virtual void ScrollRect( const wxRect *rect, int dx, int dy ) = 0;
virtual WXWidget GetWXWidget() const = 0;
virtual void SetBackgroundColour( const wxColour& col ) = 0;
virtual bool SetBackgroundStyle(wxBackgroundStyle style) = 0;
// all coordinates in native parent widget relative coordinates
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0;
virtual void Move(int x, int y, int width, int height) = 0;
virtual void GetPosition( int &x, int &y ) const = 0;
virtual void GetSize( int &width, int &height ) const = 0;
virtual void SetControlSize( wxWindowVariant variant ) = 0;
virtual float GetContentScaleFactor() const
{
return 1.0;
}
// the native coordinates may have an 'aura' for shadows etc, if this is the case the layout
// inset indicates on which insets the real control is drawn
virtual void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
{
left = top = right = bottom = 0;
}
// native view coordinates are topleft to bottom right (flipped regarding CoreGraphics origin)
virtual bool IsFlipped() const { return true; }
virtual void SetNeedsDisplay( const wxRect* where = NULL ) = 0;
virtual bool GetNeedsDisplay() const = 0;
virtual bool NeedsFocusRect() const;
virtual void SetNeedsFocusRect( bool needs );
virtual bool NeedsFrame() const;
virtual void SetNeedsFrame( bool needs );
virtual bool CanFocus() const = 0;
// return true if successful
virtual bool SetFocus() = 0;
virtual bool HasFocus() const = 0;
virtual void RemoveFromParent() = 0;
virtual void Embed( wxWidgetImpl *parent ) = 0;
virtual void SetDefaultButton( bool isDefault ) = 0;
virtual void PerformClick() = 0;
virtual void SetLabel( const wxString& title, wxFontEncoding encoding ) = 0;
#if wxUSE_MARKUP && wxOSX_USE_COCOA
virtual void SetLabelMarkup( const wxString& WXUNUSED(markup) ) { }
#endif
virtual void SetCursor( const wxCursor & cursor ) = 0;
virtual void CaptureMouse() = 0;
virtual void ReleaseMouse() = 0;
virtual wxInt32 GetValue() const = 0;
virtual void SetValue( wxInt32 v ) = 0;
virtual wxBitmap GetBitmap() const = 0;
virtual void SetBitmap( const wxBitmap& bitmap ) = 0;
virtual void SetBitmapPosition( wxDirection dir ) = 0;
virtual void SetupTabs( const wxNotebook &notebook ) =0;
virtual void GetBestRect( wxRect *r ) const = 0;
virtual bool IsEnabled() const = 0;
virtual void Enable( bool enable ) = 0;
virtual void SetMinimum( wxInt32 v ) = 0;
virtual void SetMaximum( wxInt32 v ) = 0;
virtual wxInt32 GetMinimum() const = 0;
virtual wxInt32 GetMaximum() const = 0;
virtual void PulseGauge() = 0;
virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0;
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0;
virtual void SetToolTip(wxToolTip* WXUNUSED(tooltip)) { }
// is the clicked event sent AFTER the state already changed, so no additional
// state changing logic is required from the outside
virtual bool ButtonClickDidStateChange() = 0;
virtual void InstallEventHandler( WXWidget control = NULL ) = 0;
// Mechanism used to keep track of whether a change should send an event
// Do SendEvents(false) when starting actions that would trigger programmatic events
// and SendEvents(true) at the end of the block.
virtual void SendEvents(bool shouldSendEvents) { m_shouldSendEvents = shouldSendEvents; }
virtual bool ShouldSendEvents() { return m_shouldSendEvents; }
// static methods for associating native controls and their implementations
static wxWidgetImpl*
FindFromWXWidget(WXWidget control);
static void RemoveAssociations( wxWidgetImpl* impl);
static void Associate( WXWidget control, wxWidgetImpl *impl );
static WXWidget FindFocus();
// static creation methods, must be implemented by all toolkits
static wxWidgetImplType* CreateUserPane( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateContentView( wxNonOwnedWindow* now ) ;
static wxWidgetImplType* CreateButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateDisclosureTriangle( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateStaticLine( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateGroupBox( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateStaticText( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateTextControl( wxTextCtrl* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& content,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateSearchControl( wxSearchCtrl* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& content,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle) ;
static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateRadioButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateToggleButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateBitmapToggleButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateBitmapButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateTabView( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateGauge( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxInt32 value,
wxInt32 minimum,
wxInt32 maximum,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateSlider( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxInt32 value,
wxInt32 minimum,
wxInt32 maximum,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateSpinButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxInt32 value,
wxInt32 minimum,
wxInt32 maximum,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateScrollBar( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateChoice( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxMenu* menu,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
static wxWidgetImplType* CreateListBox( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
#if wxOSX_USE_COCOA
static wxWidgetImplType* CreateComboBox( wxComboBox* wxpeer,
wxWindowMac* parent,
wxWindowID id,
wxMenu* menu,
const wxPoint& pos,
const wxSize& size,
long style,
long extraStyle);
#endif
// converts from Toplevel-Content relative to local
static void Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to );
protected :
bool m_isRootControl;
bool m_isUserPane;
wxWindowMac* m_wxPeer;
bool m_needsFocusRect;
bool m_needsFrame;
bool m_shouldSendEvents;
DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
};
//
// the interface to be implemented eg by a listbox
//
class WXDLLIMPEXP_CORE wxListWidgetColumn
{
public :
virtual ~wxListWidgetColumn() {}
} ;
class WXDLLIMPEXP_CORE wxListWidgetCellValue
{
public :
wxListWidgetCellValue() {}
virtual ~wxListWidgetCellValue() {}
virtual void Set( CFStringRef value ) = 0;
virtual void Set( const wxString& value ) = 0;
virtual void Set( int value ) = 0;
virtual void Check( bool check );
virtual bool IsChecked() const;
virtual int GetIntValue() const = 0;
virtual wxString GetStringValue() const = 0;
} ;
class WXDLLIMPEXP_CORE wxListWidgetImpl
{
public:
wxListWidgetImpl() {}
virtual ~wxListWidgetImpl() { }
virtual wxListWidgetColumn* InsertTextColumn( unsigned pos, const wxString& title, bool editable = false,
wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ;
virtual wxListWidgetColumn* InsertCheckColumn( unsigned pos , const wxString& title, bool editable = false,
wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ;
// add and remove
// TODO will be replaced
virtual void ListDelete( unsigned int n ) = 0;
virtual void ListInsert( unsigned int n ) = 0;
virtual void ListClear() = 0;
// selecting
virtual void ListDeselectAll() = 0;
virtual void ListSetSelection( unsigned int n, bool select, bool multi ) = 0;
virtual int ListGetSelection() const = 0;
virtual int ListGetSelections( wxArrayInt& aSelections ) const = 0;
virtual bool ListIsSelected( unsigned int n ) const = 0;
// display
virtual void ListScrollTo( unsigned int n ) = 0;
virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) = 0;
virtual void UpdateLineToEnd( unsigned int n) = 0;
// accessing content
virtual unsigned int ListGetCount() const = 0;
virtual int DoListHitTest( const wxPoint& inpoint ) const = 0;
};
//
// interface to be implemented by a textcontrol
//
class WXDLLIMPEXP_FWD_CORE wxTextAttr;
class WXDLLIMPEXP_FWD_CORE wxTextEntry;
// common interface for all implementations
class WXDLLIMPEXP_CORE wxTextWidgetImpl
{
public :
// Any widgets implementing this interface must be associated with a
// wxTextEntry so instead of requiring the derived classes to implement
// another (pure) virtual function, just take the pointer to this entry in
// our ctor and implement GetTextEntry() ourselves.
wxTextWidgetImpl(wxTextEntry *entry) : m_entry(entry) {}
virtual ~wxTextWidgetImpl() {}
wxTextEntry *GetTextEntry() const { return m_entry; }
virtual bool CanFocus() const { return true; }
virtual wxString GetStringValue() const = 0 ;
virtual void SetStringValue( const wxString &val ) = 0 ;
virtual void SetSelection( long from, long to ) = 0 ;
virtual void GetSelection( long* from, long* to ) const = 0 ;
virtual void WriteText( const wxString& str ) = 0 ;
virtual bool GetStyle( long position, wxTextAttr& style);
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
virtual void Copy() ;
virtual void Cut() ;
virtual void Paste() ;
virtual bool CanPaste() const ;
virtual void SetEditable( bool editable ) ;
virtual long GetLastPosition() const ;
virtual void Replace( long from, long to, const wxString &str ) ;
virtual void Remove( long from, long to ) ;
virtual bool HasOwnContextMenu() const
{ return false ; }
virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
{ return false ; }
virtual void Clear() ;
virtual bool CanUndo() const;
virtual void Undo() ;
virtual bool CanRedo() const;
virtual void Redo() ;
virtual int GetNumberOfLines() const ;
virtual long XYToPosition(long x, long y) const;
virtual bool PositionToXY(long pos, long *x, long *y) const ;
virtual void ShowPosition(long WXUNUSED(pos)) ;
virtual int GetLineLength(long lineNo) const ;
virtual wxString GetLineText(long lineNo) const ;
virtual void CheckSpelling(bool WXUNUSED(check)) { }
virtual wxSize GetBestSize() const { return wxDefaultSize; }
virtual bool SetHint(const wxString& WXUNUSED(hint)) { return false; }
private:
wxTextEntry * const m_entry;
wxDECLARE_NO_COPY_CLASS(wxTextWidgetImpl);
};
// common interface for all implementations
class WXDLLIMPEXP_CORE wxComboWidgetImpl
{
public :
wxComboWidgetImpl() {}
virtual ~wxComboWidgetImpl() {}
virtual int GetSelectedItem() const { return -1; };
virtual void SetSelectedItem(int WXUNUSED(item)) {};
virtual int GetNumberOfItems() const { return -1; };
virtual void InsertItem(int WXUNUSED(pos), const wxString& WXUNUSED(item)) {}
virtual void RemoveItem(int WXUNUSED(pos)) {}
virtual void Clear() {}
virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; }
virtual int FindString(const wxString& WXUNUSED(text)) const { return -1; }
};
//
// common interface for buttons
//
class wxButtonImpl
{
public :
wxButtonImpl(){}
virtual ~wxButtonImpl(){}
virtual void SetPressedBitmap( const wxBitmap& bitmap ) = 0;
} ;
//
// common interface for search controls
//
class wxSearchWidgetImpl
{
public :
wxSearchWidgetImpl(){}
virtual ~wxSearchWidgetImpl(){}
// search field options
virtual void ShowSearchButton( bool show ) = 0;
virtual bool IsSearchButtonVisible() const = 0;
virtual void ShowCancelButton( bool show ) = 0;
virtual bool IsCancelButtonVisible() const = 0;
virtual void SetSearchMenu( wxMenu* menu ) = 0;
virtual void SetDescriptiveText(const wxString& text) = 0;
} ;
//
// toplevel window implementation class
//
class wxNonOwnedWindowImpl : public wxObject
{
public :
wxNonOwnedWindowImpl( wxNonOwnedWindow* nonownedwnd) : m_wxPeer(nonownedwnd)
{
}
wxNonOwnedWindowImpl()
{
}
virtual ~wxNonOwnedWindowImpl()
{
}
virtual void WillBeDestroyed()
{
}
virtual void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) = 0;
virtual WXWindow GetWXWindow() const = 0;
virtual void Raise()
{
}
virtual void Lower()
{
}
virtual bool Show(bool WXUNUSED(show))
{
return false;
}
virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout))
{
return Show(show);
}
virtual void Update()
{
}
virtual bool SetTransparent(wxByte WXUNUSED(alpha))
{
return false;
}
virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) )
{
return false;
}
virtual void SetExtraStyle( long WXUNUSED(exStyle) )
{
}
virtual void SetWindowStyleFlag( long WXUNUSED(style) )
{
}
virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style))
{
return false ;
}
virtual bool CanSetTransparent()
{
return false;
}
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0;
virtual void MoveWindow(int x, int y, int width, int height) = 0;
virtual void GetPosition( int &x, int &y ) const = 0;
virtual void GetSize( int &width, int &height ) const = 0;
virtual bool SetShape(const wxRegion& WXUNUSED(region))
{
return false;
}
virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0;
virtual bool IsMaximized() const = 0;
virtual bool IsIconized() const= 0;
virtual void Iconize( bool iconize )= 0;
virtual void Maximize(bool maximize) = 0;
virtual bool IsFullScreen() const= 0;
virtual void ShowWithoutActivating() { Show(true); }
virtual bool ShowFullScreen(bool show, long style)= 0;
virtual void RequestUserAttention(int flags) = 0;
virtual void ScreenToWindow( int *x, int *y ) = 0;
virtual void WindowToScreen( int *x, int *y ) = 0;
virtual bool IsActive() = 0;
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
static wxNonOwnedWindowImpl*
FindFromWXWindow(WXWindow window);
static void RemoveAssociations( wxNonOwnedWindowImpl* impl);
static void Associate( WXWindow window, wxNonOwnedWindowImpl *impl );
// static creation methods, must be implemented by all toolkits
static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow native) ;
static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
virtual void SetModified(bool WXUNUSED(modified)) { }
virtual bool IsModified() const { return false; }
#if wxOSX_USE_IPHONE
virtual CGFloat GetWindowLevel() const { return 0.0; }
#else
virtual CGWindowLevel GetWindowLevel() const { return kCGNormalWindowLevel; }
#endif
virtual void RestoreWindowLevel() {}
protected :
wxNonOwnedWindow* m_wxPeer;
DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl)
};
#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_CORE_H_

View File

@ -0,0 +1,338 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/private/strconv_cf.h
// Purpose: Unicode conversion classes
// Author: David Elliott, Ryan Norton
// Modified by:
// Created: 2007-07-06
// RCS-ID: $Id: strconv_cf.h 67215 2011-03-16 10:55:30Z SC $
// Copyright: (c) 2004 Ryan Norton
// (c) 2007 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/strconv.h"
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFStringEncodingExt.h>
// ============================================================================
// CoreFoundation conversion classes
// ============================================================================
inline CFStringEncoding wxCFStringEncFromFontEnc(wxFontEncoding encoding)
{
CFStringEncoding enc = kCFStringEncodingInvalidId ;
switch (encoding)
{
case wxFONTENCODING_DEFAULT :
enc = CFStringGetSystemEncoding();
break ;
case wxFONTENCODING_ISO8859_1 :
enc = kCFStringEncodingISOLatin1 ;
break ;
case wxFONTENCODING_ISO8859_2 :
enc = kCFStringEncodingISOLatin2;
break ;
case wxFONTENCODING_ISO8859_3 :
enc = kCFStringEncodingISOLatin3 ;
break ;
case wxFONTENCODING_ISO8859_4 :
enc = kCFStringEncodingISOLatin4;
break ;
case wxFONTENCODING_ISO8859_5 :
enc = kCFStringEncodingISOLatinCyrillic;
break ;
case wxFONTENCODING_ISO8859_6 :
enc = kCFStringEncodingISOLatinArabic;
break ;
case wxFONTENCODING_ISO8859_7 :
enc = kCFStringEncodingISOLatinGreek;
break ;
case wxFONTENCODING_ISO8859_8 :
enc = kCFStringEncodingISOLatinHebrew;
break ;
case wxFONTENCODING_ISO8859_9 :
enc = kCFStringEncodingISOLatin5;
break ;
case wxFONTENCODING_ISO8859_10 :
enc = kCFStringEncodingISOLatin6;
break ;
case wxFONTENCODING_ISO8859_11 :
enc = kCFStringEncodingISOLatinThai;
break ;
case wxFONTENCODING_ISO8859_13 :
enc = kCFStringEncodingISOLatin7;
break ;
case wxFONTENCODING_ISO8859_14 :
enc = kCFStringEncodingISOLatin8;
break ;
case wxFONTENCODING_ISO8859_15 :
enc = kCFStringEncodingISOLatin9;
break ;
case wxFONTENCODING_KOI8 :
enc = kCFStringEncodingKOI8_R;
break ;
case wxFONTENCODING_ALTERNATIVE : // MS-DOS CP866
enc = kCFStringEncodingDOSRussian;
break ;
// case wxFONTENCODING_BULGARIAN :
// enc = ;
// break ;
case wxFONTENCODING_CP437 :
enc = kCFStringEncodingDOSLatinUS ;
break ;
case wxFONTENCODING_CP850 :
enc = kCFStringEncodingDOSLatin1;
break ;
case wxFONTENCODING_CP852 :
enc = kCFStringEncodingDOSLatin2;
break ;
case wxFONTENCODING_CP855 :
enc = kCFStringEncodingDOSCyrillic;
break ;
case wxFONTENCODING_CP866 :
enc = kCFStringEncodingDOSRussian ;
break ;
case wxFONTENCODING_CP874 :
enc = kCFStringEncodingDOSThai;
break ;
case wxFONTENCODING_CP932 :
enc = kCFStringEncodingDOSJapanese;
break ;
case wxFONTENCODING_CP936 :
enc = kCFStringEncodingDOSChineseSimplif ;
break ;
case wxFONTENCODING_CP949 :
enc = kCFStringEncodingDOSKorean;
break ;
case wxFONTENCODING_CP950 :
enc = kCFStringEncodingDOSChineseTrad;
break ;
case wxFONTENCODING_CP1250 :
enc = kCFStringEncodingWindowsLatin2;
break ;
case wxFONTENCODING_CP1251 :
enc = kCFStringEncodingWindowsCyrillic ;
break ;
case wxFONTENCODING_CP1252 :
enc = kCFStringEncodingWindowsLatin1 ;
break ;
case wxFONTENCODING_CP1253 :
enc = kCFStringEncodingWindowsGreek;
break ;
case wxFONTENCODING_CP1254 :
enc = kCFStringEncodingWindowsLatin5;
break ;
case wxFONTENCODING_CP1255 :
enc = kCFStringEncodingWindowsHebrew ;
break ;
case wxFONTENCODING_CP1256 :
enc = kCFStringEncodingWindowsArabic ;
break ;
case wxFONTENCODING_CP1257 :
enc = kCFStringEncodingWindowsBalticRim;
break ;
// This only really encodes to UTF7 (if that) evidently
// case wxFONTENCODING_UTF7 :
// enc = kCFStringEncodingNonLossyASCII ;
// break ;
case wxFONTENCODING_UTF8 :
enc = kCFStringEncodingUTF8 ;
break ;
case wxFONTENCODING_EUC_JP :
enc = kCFStringEncodingEUC_JP;
break ;
/* Don't support conversion to/from UTF16 as wxWidgets can do this better.
* In particular, ToWChar would fail miserably using strlen on an input UTF16.
case wxFONTENCODING_UTF16 :
enc = kCFStringEncodingUnicode ;
break ;
*/
case wxFONTENCODING_MACROMAN :
enc = kCFStringEncodingMacRoman ;
break ;
case wxFONTENCODING_MACJAPANESE :
enc = kCFStringEncodingMacJapanese ;
break ;
case wxFONTENCODING_MACCHINESETRAD :
enc = kCFStringEncodingMacChineseTrad ;
break ;
case wxFONTENCODING_MACKOREAN :
enc = kCFStringEncodingMacKorean ;
break ;
case wxFONTENCODING_MACARABIC :
enc = kCFStringEncodingMacArabic ;
break ;
case wxFONTENCODING_MACHEBREW :
enc = kCFStringEncodingMacHebrew ;
break ;
case wxFONTENCODING_MACGREEK :
enc = kCFStringEncodingMacGreek ;
break ;
case wxFONTENCODING_MACCYRILLIC :
enc = kCFStringEncodingMacCyrillic ;
break ;
case wxFONTENCODING_MACDEVANAGARI :
enc = kCFStringEncodingMacDevanagari ;
break ;
case wxFONTENCODING_MACGURMUKHI :
enc = kCFStringEncodingMacGurmukhi ;
break ;
case wxFONTENCODING_MACGUJARATI :
enc = kCFStringEncodingMacGujarati ;
break ;
case wxFONTENCODING_MACORIYA :
enc = kCFStringEncodingMacOriya ;
break ;
case wxFONTENCODING_MACBENGALI :
enc = kCFStringEncodingMacBengali ;
break ;
case wxFONTENCODING_MACTAMIL :
enc = kCFStringEncodingMacTamil ;
break ;
case wxFONTENCODING_MACTELUGU :
enc = kCFStringEncodingMacTelugu ;
break ;
case wxFONTENCODING_MACKANNADA :
enc = kCFStringEncodingMacKannada ;
break ;
case wxFONTENCODING_MACMALAJALAM :
enc = kCFStringEncodingMacMalayalam ;
break ;
case wxFONTENCODING_MACSINHALESE :
enc = kCFStringEncodingMacSinhalese ;
break ;
case wxFONTENCODING_MACBURMESE :
enc = kCFStringEncodingMacBurmese ;
break ;
case wxFONTENCODING_MACKHMER :
enc = kCFStringEncodingMacKhmer ;
break ;
case wxFONTENCODING_MACTHAI :
enc = kCFStringEncodingMacThai ;
break ;
case wxFONTENCODING_MACLAOTIAN :
enc = kCFStringEncodingMacLaotian ;
break ;
case wxFONTENCODING_MACGEORGIAN :
enc = kCFStringEncodingMacGeorgian ;
break ;
case wxFONTENCODING_MACARMENIAN :
enc = kCFStringEncodingMacArmenian ;
break ;
case wxFONTENCODING_MACCHINESESIMP :
enc = kCFStringEncodingMacChineseSimp ;
break ;
case wxFONTENCODING_MACTIBETAN :
enc = kCFStringEncodingMacTibetan ;
break ;
case wxFONTENCODING_MACMONGOLIAN :
enc = kCFStringEncodingMacMongolian ;
break ;
case wxFONTENCODING_MACETHIOPIC :
enc = kCFStringEncodingMacEthiopic ;
break ;
case wxFONTENCODING_MACCENTRALEUR :
enc = kCFStringEncodingMacCentralEurRoman ;
break ;
case wxFONTENCODING_MACVIATNAMESE :
enc = kCFStringEncodingMacVietnamese ;
break ;
case wxFONTENCODING_MACARABICEXT :
enc = kCFStringEncodingMacExtArabic ;
break ;
case wxFONTENCODING_MACSYMBOL :
enc = kCFStringEncodingMacSymbol ;
break ;
case wxFONTENCODING_MACDINGBATS :
enc = kCFStringEncodingMacDingbats ;
break ;
case wxFONTENCODING_MACTURKISH :
enc = kCFStringEncodingMacTurkish ;
break ;
case wxFONTENCODING_MACCROATIAN :
enc = kCFStringEncodingMacCroatian ;
break ;
case wxFONTENCODING_MACICELANDIC :
enc = kCFStringEncodingMacIcelandic ;
break ;
case wxFONTENCODING_MACROMANIAN :
enc = kCFStringEncodingMacRomanian ;
break ;
case wxFONTENCODING_MACCELTIC :
enc = kCFStringEncodingMacCeltic ;
break ;
case wxFONTENCODING_MACGAELIC :
enc = kCFStringEncodingMacGaelic ;
break ;
/* CFString is known to support this back to the original CarbonLib */
/* http://developer.apple.com/samplecode/CarbonMDEF/listing2.html */
case wxFONTENCODING_MACKEYBOARD :
/* We don't wish to pollute the namespace too much, even though we're a private header. */
/* The constant is well-defined as 41 and is not expected to change. */
enc = 41 /*kTextEncodingMacKeyboardGlyphs*/ ;
break ;
default :
// because gcc is picky
break ;
}
return enc ;
}
class wxMBConv_cf : public wxMBConv
{
public:
wxMBConv_cf()
{
Init(CFStringGetSystemEncoding()) ;
}
wxMBConv_cf(const wxMBConv_cf& conv) : wxMBConv()
{
m_encoding = conv.m_encoding;
}
#if wxUSE_FONTMAP
wxMBConv_cf(const char* name)
{
Init( wxCFStringEncFromFontEnc(wxFontMapperBase::Get()->CharsetToEncoding(name, false) ) ) ;
}
#endif
wxMBConv_cf(wxFontEncoding encoding)
{
Init( wxCFStringEncFromFontEnc(encoding) );
}
virtual ~wxMBConv_cf()
{
}
void Init( CFStringEncoding encoding)
{
m_encoding = encoding ;
}
virtual size_t ToWChar(wchar_t * dst, size_t dstSize, const char * src, size_t srcSize = wxNO_LEN) const;
virtual size_t FromWChar(char *dst, size_t dstSize, const wchar_t *src, size_t srcSize = wxNO_LEN) const;
virtual wxMBConv *Clone() const { return new wxMBConv_cf(*this); }
bool IsOk() const
{
return m_encoding != kCFStringEncodingInvalidId &&
CFStringIsEncodingAvailable(m_encoding);
}
private:
CFStringEncoding m_encoding ;
};

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/private/timer.h
// Purpose: wxTimer class based on core foundation
// Author: Stefan Csomor
// Created: 2008-07-16
// RCS-ID: $Id: timer.h 67232 2011-03-18 15:10:15Z DS $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CORE_PRIVATE_TIMER_H_
#define _WX_OSX_CORE_PRIVATE_TIMER_H_
#include "wx/private/timer.h"
struct wxOSXTimerInfo;
class WXDLLIMPEXP_CORE wxOSXTimerImpl : public wxTimerImpl
{
public:
wxOSXTimerImpl(wxTimer *timer);
virtual ~wxOSXTimerImpl();
virtual bool Start(int milliseconds = -1, bool one_shot = false);
virtual void Stop();
virtual bool IsRunning() const;
private:
wxOSXTimerInfo *m_info;
};
#endif // _WX_OSX_CORE_PRIVATE_TIMER_H_

View File

@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/stdpaths.h
// Purpose: wxStandardPaths for CoreFoundation systems
// Author: David Elliott
// Modified by:
// Created: 2004-10-27
// RCS-ID: $Id: stdpaths.h 64943 2010-07-13 13:29:58Z VZ $
// 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;
// we inherit the GUI CF-based wxStandardPaths implementation from the Unix one
// used for console programs if possible (i.e. if we're under a Unix system at
// all)
#if defined(__UNIX__)
#include "wx/unix/stdpaths.h"
#define wxStandardPathsCFBase wxStandardPaths
#else
#define wxStandardPathsCFBase wxStandardPathsBase
#endif
// ----------------------------------------------------------------------------
// wxStandardPaths
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStandardPathsCF : public wxStandardPathsCFBase
{
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;
};
#endif // _WX_MAC_STDPATHS_H_