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