]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/corefoundation/cfstring.h
wxMac compilation fixes for visibility (missing DLL export macros)
[wxWidgets.git] / include / wx / mac / corefoundation / cfstring.h
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
12 #ifndef __WX_CFSTRINGHOLDER_H__
13 #define __WX_CFSTRINGHOLDER_H__
14
15 #ifdef __DARWIN__
16 #include <CoreFoundation/CFString.h>
17 #else
18 #include <CFString.h>
19 #endif
20
21 #include "wx/dlimpexp.h"
22 #include "wx/fontenc.h"
23
24 class WXDLLIMPEXP_FWD_BASE wxString;
25
26 WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxString *data ) ;
27 WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( wxString *data ) ;
28
29 WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data ) ;
30 WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( char * data ) ;
31
32 WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
33 WXDLLIMPEXP_BASE wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
34 WXDLLIMPEXP_BASE void wxMacWakeUp() ;
35
36 class WXDLLIMPEXP_BASE wxMacCFStringHolder
37 {
38 public:
39 wxMacCFStringHolder()
40 : m_cfs(NULL) , m_release(false)
41 {
42 }
43
44 wxMacCFStringHolder(const wxString &str,
45 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
46 : m_cfs(NULL) , m_release(false)
47 {
48 Assign( str , encoding ) ;
49 }
50
51 wxMacCFStringHolder(CFStringRef ref , bool release = true )
52 : m_cfs(ref) , m_release(release)
53 {
54 }
55
56 ~wxMacCFStringHolder()
57 {
58 Release() ;
59 }
60
61 CFStringRef Detach()
62 {
63 CFStringRef retval = m_cfs ;
64 m_release = false ;
65 m_cfs = NULL ;
66 return retval ;
67 }
68
69 void Release()
70 {
71 if ( m_release && m_cfs)
72 CFRelease( m_cfs ) ;
73 m_cfs = NULL ;
74 }
75
76 void Assign(const wxString &str,
77 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
78
79 operator CFStringRef () const { return m_cfs; }
80 wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
81
82 private:
83
84 CFStringRef m_cfs;
85 bool m_release ;
86
87 DECLARE_NO_COPY_CLASS( wxMacCFStringHolder )
88 } ;
89
90 // corresponding class for holding UniChars (native unicode characters)
91
92 class WXDLLIMPEXP_BASE wxMacUniCharBuffer
93 {
94 public :
95 wxMacUniCharBuffer( const wxString &str ) ;
96
97 ~wxMacUniCharBuffer() ;
98
99 UniChar* GetBuffer() ;
100
101 UniCharCount GetChars() ;
102
103 private :
104 UniChar* m_ubuf ;
105 UniCharCount m_chars ;
106 };
107 #endif //__WXCFSTRINGHOLDER_H__