]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/cfstring.h
wxTheColourDatabase->Find() can fail.
[wxWidgets.git] / include / wx / mac / corefoundation / cfstring.h
CommitLineData
5185263f
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/mac/corefoundation/cfstring.h
3// Purpose: wxMacCFStringHolder and other string functions
4// Author: Stefan Csomor
5// Modified by:
6// Created: 2004-10-29 (from code in wx/mac/carbon/private.h)
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
ac7f7b51
RN
12#ifndef __WX_CFSTRINGHOLDER_H__
13#define __WX_CFSTRINGHOLDER_H__
14
5185263f
DE
15#ifdef __DARWIN__
16 #include <CoreFoundation/CFString.h>
17#else
18 #include <CFString.h>
19#endif
20
21void wxMacConvertNewlines13To10( char * data ) ;
22void wxMacConvertNewlines10To13( char * data ) ;
23void wxMacConvertNewlines13To10( wxString *data ) ;
24void wxMacConvertNewlines10To13( wxString *data ) ;
25
26#if wxUSE_UNICODE
27void wxMacConvertNewlines13To10( wxChar * data ) ;
28void wxMacConvertNewlines10To13( wxChar * data ) ;
29#endif
30
31wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
32wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
33void wxMacWakeUp() ;
34
35class wxMacCFStringHolder
36{
37public:
69ea41a7
SC
38 wxMacCFStringHolder()
39 : m_cfs(NULL) , m_release(false)
5185263f 40 {
5185263f
DE
41 }
42
43 wxMacCFStringHolder(const wxString &str , wxFontEncoding encoding )
69ea41a7 44 : m_cfs(NULL) , m_release(false)
5185263f 45 {
5185263f
DE
46 Assign( str , encoding ) ;
47 }
48
49 wxMacCFStringHolder(CFStringRef ref , bool release = true )
69ea41a7 50 : m_cfs(ref) , m_release(release)
5185263f 51 {
5185263f
DE
52 }
53
54 ~wxMacCFStringHolder()
55 {
56 Release() ;
57 }
58
59 CFStringRef Detach()
60 {
61 CFStringRef retval = m_cfs ;
62 m_release = false ;
63 m_cfs = NULL ;
64 return retval ;
65 }
66
67 void Release()
68 {
69 if ( m_release && m_cfs)
70 CFRelease( m_cfs ) ;
71 m_cfs = NULL ;
72 }
73
74 void Assign( const wxString &str , wxFontEncoding encoding ) ;
75
ac7f7b51 76 operator CFStringRef () const { return m_cfs; }
5185263f
DE
77 wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
78
79private:
80
81 CFStringRef m_cfs;
82 bool m_release ;
69ea41a7
SC
83
84 DECLARE_NO_COPY_CLASS( wxMacCFStringHolder )
5185263f
DE
85} ;
86
ac7f7b51 87#endif //__WXCFSTRINGHOLDER_H__