2004-10-29 14:29:35 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/mac/corefoundation/cfstring.h
|
|
|
|
// Purpose: wxMacCFStringHolder 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
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-04-21 19:35:02 -04:00
|
|
|
#ifndef __WX_CFSTRINGHOLDER_H__
|
|
|
|
#define __WX_CFSTRINGHOLDER_H__
|
|
|
|
|
2004-10-29 14:29:35 -04:00
|
|
|
#ifdef __DARWIN__
|
|
|
|
#include <CoreFoundation/CFString.h>
|
|
|
|
#else
|
|
|
|
#include <CFString.h>
|
|
|
|
#endif
|
|
|
|
|
2006-05-20 01:47:39 -04:00
|
|
|
#include "wx/fontenc.h"
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxString;
|
|
|
|
|
2004-10-29 14:29:35 -04:00
|
|
|
void wxMacConvertNewlines13To10( char * data ) ;
|
|
|
|
void wxMacConvertNewlines10To13( char * data ) ;
|
|
|
|
void wxMacConvertNewlines13To10( wxString *data ) ;
|
|
|
|
void wxMacConvertNewlines10To13( wxString *data ) ;
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
void wxMacConvertNewlines13To10( wxChar * data ) ;
|
|
|
|
void wxMacConvertNewlines10To13( wxChar * data ) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
|
|
|
|
wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
|
|
|
|
void wxMacWakeUp() ;
|
|
|
|
|
|
|
|
class wxMacCFStringHolder
|
|
|
|
{
|
|
|
|
public:
|
2006-07-24 14:01:39 -04:00
|
|
|
wxMacCFStringHolder()
|
|
|
|
: m_cfs(NULL) , m_release(false)
|
2004-10-29 14:29:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-24 14:01:39 -04:00
|
|
|
wxMacCFStringHolder(const wxString &str,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
|
|
|
: m_cfs(NULL) , m_release(false)
|
2004-10-29 14:29:35 -04:00
|
|
|
{
|
|
|
|
Assign( str , encoding ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMacCFStringHolder(CFStringRef ref , bool release = true )
|
2006-07-24 14:01:39 -04:00
|
|
|
: m_cfs(ref) , m_release(release)
|
2004-10-29 14:29:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~wxMacCFStringHolder()
|
|
|
|
{
|
|
|
|
Release() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
CFStringRef Detach()
|
|
|
|
{
|
|
|
|
CFStringRef retval = m_cfs ;
|
|
|
|
m_release = false ;
|
|
|
|
m_cfs = NULL ;
|
|
|
|
return retval ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Release()
|
|
|
|
{
|
|
|
|
if ( m_release && m_cfs)
|
|
|
|
CFRelease( m_cfs ) ;
|
|
|
|
m_cfs = NULL ;
|
|
|
|
}
|
|
|
|
|
2006-07-24 14:01:39 -04:00
|
|
|
void Assign(const wxString &str,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2004-10-29 14:29:35 -04:00
|
|
|
|
2005-04-21 19:35:02 -04:00
|
|
|
operator CFStringRef () const { return m_cfs; }
|
2004-10-29 14:29:35 -04:00
|
|
|
wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
CFStringRef m_cfs;
|
|
|
|
bool m_release ;
|
2006-07-24 14:01:39 -04:00
|
|
|
|
2005-02-14 00:51:52 -05:00
|
|
|
DECLARE_NO_COPY_CLASS( wxMacCFStringHolder )
|
2004-10-29 14:29:35 -04:00
|
|
|
} ;
|
|
|
|
|
2006-06-29 13:23:37 -04:00
|
|
|
// corresponding class for holding UniChars (native unicode characters)
|
|
|
|
|
|
|
|
class wxMacUniCharBuffer
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
wxMacUniCharBuffer( const wxString &str ) ;
|
2006-07-24 14:01:39 -04:00
|
|
|
|
2006-06-29 13:23:37 -04:00
|
|
|
~wxMacUniCharBuffer() ;
|
2006-07-24 14:01:39 -04:00
|
|
|
|
2006-06-29 13:23:37 -04:00
|
|
|
UniChar* GetBuffer() ;
|
2006-07-24 14:01:39 -04:00
|
|
|
|
2006-06-29 13:23:37 -04:00
|
|
|
UniCharCount GetChars() ;
|
2006-07-24 14:01:39 -04:00
|
|
|
|
2006-06-29 13:23:37 -04:00
|
|
|
private :
|
|
|
|
UniChar* m_ubuf ;
|
|
|
|
UniCharCount m_chars ;
|
|
|
|
};
|
2005-04-21 19:35:02 -04:00
|
|
|
#endif //__WXCFSTRINGHOLDER_H__
|