]>
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 | |
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 | ||
23 | class WXDLLIMPEXP_BASE wxString; | |
24 | ||
5185263f DE |
25 | void wxMacConvertNewlines13To10( char * data ) ; |
26 | void wxMacConvertNewlines10To13( char * data ) ; | |
27 | void wxMacConvertNewlines13To10( wxString *data ) ; | |
28 | void wxMacConvertNewlines10To13( wxString *data ) ; | |
29 | ||
30 | #if wxUSE_UNICODE | |
31 | void wxMacConvertNewlines13To10( wxChar * data ) ; | |
32 | void wxMacConvertNewlines10To13( wxChar * data ) ; | |
33 | #endif | |
34 | ||
35 | wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ; | |
36 | wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ; | |
37 | void wxMacWakeUp() ; | |
38 | ||
39 | class wxMacCFStringHolder | |
40 | { | |
41 | public: | |
69ea41a7 SC |
42 | wxMacCFStringHolder() |
43 | : m_cfs(NULL) , m_release(false) | |
5185263f | 44 | { |
5185263f DE |
45 | } |
46 | ||
47 | wxMacCFStringHolder(const wxString &str , wxFontEncoding encoding ) | |
69ea41a7 | 48 | : m_cfs(NULL) , m_release(false) |
5185263f | 49 | { |
5185263f DE |
50 | Assign( str , encoding ) ; |
51 | } | |
52 | ||
53 | wxMacCFStringHolder(CFStringRef ref , bool release = true ) | |
69ea41a7 | 54 | : m_cfs(ref) , m_release(release) |
5185263f | 55 | { |
5185263f DE |
56 | } |
57 | ||
58 | ~wxMacCFStringHolder() | |
59 | { | |
60 | Release() ; | |
61 | } | |
62 | ||
63 | CFStringRef Detach() | |
64 | { | |
65 | CFStringRef retval = m_cfs ; | |
66 | m_release = false ; | |
67 | m_cfs = NULL ; | |
68 | return retval ; | |
69 | } | |
70 | ||
71 | void Release() | |
72 | { | |
73 | if ( m_release && m_cfs) | |
74 | CFRelease( m_cfs ) ; | |
75 | m_cfs = NULL ; | |
76 | } | |
77 | ||
78 | void Assign( const wxString &str , wxFontEncoding encoding ) ; | |
79 | ||
ac7f7b51 | 80 | operator CFStringRef () const { return m_cfs; } |
5185263f DE |
81 | wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ; |
82 | ||
83 | private: | |
84 | ||
85 | CFStringRef m_cfs; | |
86 | bool m_release ; | |
69ea41a7 SC |
87 | |
88 | DECLARE_NO_COPY_CLASS( wxMacCFStringHolder ) | |
5185263f DE |
89 | } ; |
90 | ||
ac7f7b51 | 91 | #endif //__WXCFSTRINGHOLDER_H__ |