]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/cfstring.h
Updated wxPallete information.
[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( char * data ) ;
26void wxMacConvertNewlines10To13( char * data ) ;
27void wxMacConvertNewlines13To10( wxString *data ) ;
28void wxMacConvertNewlines10To13( wxString *data ) ;
29
30#if wxUSE_UNICODE
31void wxMacConvertNewlines13To10( wxChar * data ) ;
32void wxMacConvertNewlines10To13( wxChar * data ) ;
33#endif
34
35wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
36wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
37void wxMacWakeUp() ;
38
39class wxMacCFStringHolder
40{
41public:
a8d69700
VZ
42 wxMacCFStringHolder()
43 : m_cfs(NULL) , m_release(false)
5185263f 44 {
5185263f
DE
45 }
46
a8d69700
VZ
47 wxMacCFStringHolder(const wxString &str,
48 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
49 : m_cfs(NULL) , m_release(false)
5185263f 50 {
5185263f
DE
51 Assign( str , encoding ) ;
52 }
53
54 wxMacCFStringHolder(CFStringRef ref , bool release = true )
a8d69700 55 : m_cfs(ref) , m_release(release)
5185263f 56 {
5185263f
DE
57 }
58
59 ~wxMacCFStringHolder()
60 {
61 Release() ;
62 }
63
64 CFStringRef Detach()
65 {
66 CFStringRef retval = m_cfs ;
67 m_release = false ;
68 m_cfs = NULL ;
69 return retval ;
70 }
71
72 void Release()
73 {
74 if ( m_release && m_cfs)
75 CFRelease( m_cfs ) ;
76 m_cfs = NULL ;
77 }
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
85private:
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
95class wxMacUniCharBuffer
96{
97public :
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
106private :
107 UniChar* m_ubuf ;
108 UniCharCount m_chars ;
109};
ac7f7b51 110#endif //__WXCFSTRINGHOLDER_H__