]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/cfstring.h
take wxString, not wxChar* in wxStandardPaths::GetLocalizedResourcesDir
[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
dd0d56f5
PC
21#include "wx/fontenc.h"
22
23class WXDLLIMPEXP_BASE wxString;
24
5185263f
DE
25void wxMacConvertNewlines13To10( wxString *data ) ;
26void wxMacConvertNewlines10To13( wxString *data ) ;
27
e6893d5d
SC
28void wxMacConvertNewlines13To10( char * data ) ;
29void wxMacConvertNewlines10To13( char * data ) ;
5185263f
DE
30
31wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
32wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
33void wxMacWakeUp() ;
34
35class wxMacCFStringHolder
36{
37public:
a8d69700
VZ
38 wxMacCFStringHolder()
39 : m_cfs(NULL) , m_release(false)
5185263f 40 {
5185263f
DE
41 }
42
a8d69700
VZ
43 wxMacCFStringHolder(const wxString &str,
44 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
45 : m_cfs(NULL) , m_release(false)
5185263f 46 {
5185263f
DE
47 Assign( str , encoding ) ;
48 }
49
50 wxMacCFStringHolder(CFStringRef ref , bool release = true )
a8d69700 51 : m_cfs(ref) , m_release(release)
5185263f 52 {
5185263f
DE
53 }
54
55 ~wxMacCFStringHolder()
56 {
57 Release() ;
58 }
59
60 CFStringRef Detach()
61 {
62 CFStringRef retval = m_cfs ;
63 m_release = false ;
64 m_cfs = NULL ;
65 return retval ;
66 }
67
68 void Release()
69 {
70 if ( m_release && m_cfs)
71 CFRelease( m_cfs ) ;
72 m_cfs = NULL ;
73 }
74
a8d69700
VZ
75 void Assign(const wxString &str,
76 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
5185263f 77
ac7f7b51 78 operator CFStringRef () const { return m_cfs; }
5185263f
DE
79 wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
80
81private:
82
83 CFStringRef m_cfs;
84 bool m_release ;
a8d69700 85
69ea41a7 86 DECLARE_NO_COPY_CLASS( wxMacCFStringHolder )
5185263f
DE
87} ;
88
dfd468aa
SC
89// corresponding class for holding UniChars (native unicode characters)
90
91class wxMacUniCharBuffer
92{
93public :
94 wxMacUniCharBuffer( const wxString &str ) ;
a8d69700 95
dfd468aa 96 ~wxMacUniCharBuffer() ;
a8d69700 97
dfd468aa 98 UniChar* GetBuffer() ;
a8d69700 99
dfd468aa 100 UniCharCount GetChars() ;
a8d69700 101
dfd468aa
SC
102private :
103 UniChar* m_ubuf ;
104 UniCharCount m_chars ;
105};
ac7f7b51 106#endif //__WXCFSTRINGHOLDER_H__