]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/private.h
moved smart phone test to chkconf.h from features.h
[wxWidgets.git] / include / wx / mac / private.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: private.h
5273bf2f
SC
3// Purpose: Private declarations: as this header is only included by
4// wxWindows itself, it may contain identifiers which don't start
5// with "wx".
6// Author: Stefan Csomor
0dbd6262 7// Modified by:
a31a5f85 8// Created: 1998-01-01
0dbd6262 9// RCS-ID: $Id$
5273bf2f 10// Copyright: (c) Stefan Csomor
e40298d5 11// Licence: wxWindows licence
0dbd6262
SC
12/////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_PRIVATE_H_
15#define _WX_PRIVATE_H_
16
17#include "wx/defs.h"
9f67b776 18#include "wx/app.h"
0dbd6262 19
82d43113 20#ifdef __DARWIN__
fa9d617b 21# include <Carbon/Carbon.h>
5273bf2f 22#else
5921f83f
SC
23# include <Quickdraw.h>
24# include <Appearance.h>
25# include <Folders.h>
26# include <Controls.h>
27# include <ControlDefinitions.h>
28# include <LowMem.h>
29# include <Gestalt.h>
5273bf2f 30#endif
5921f83f 31
5273bf2f
SC
32#if UNIVERSAL_INTERFACES_VERSION < 0x0340
33 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
34#endif
35
2ba721aa
VZ
36#if wxUSE_GUI
37
fa9d617b
GD
38#include "wx/window.h"
39
5273bf2f
SC
40class wxMacPortStateHelper
41{
d84afea9
GD
42 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
43
44public:
45 wxMacPortStateHelper( GrafPtr newport) ;
46 wxMacPortStateHelper() ;
47 ~wxMacPortStateHelper() ;
5273bf2f 48
d84afea9
GD
49 void Setup( GrafPtr newport ) ;
50 void Clear() ;
51 bool IsCleared() { return m_clip == NULL ; }
52 GrafPtr GetCurrentPort() { return m_currentPort ; }
5273bf2f 53
d84afea9 54private:
e40298d5
JS
55 GrafPtr m_currentPort ;
56 GrafPtr m_oldPort ;
57 RgnHandle m_clip ;
d84afea9 58 ThemeDrawingState m_drawingState ;
e40298d5
JS
59 short m_textFont ;
60 short m_textSize ;
61 short m_textStyle ;
62 short m_textMode ;
5273bf2f
SC
63} ;
64
65class WXDLLEXPORT wxMacPortSetter
66{
d84afea9
GD
67 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
68
69public:
70 wxMacPortSetter( const wxDC* dc ) ;
71 ~wxMacPortSetter() ;
72private:
73 wxMacPortStateHelper m_ph ;
74 const wxDC* m_dc ;
5273bf2f
SC
75} ;
76
e671beca
SC
77class WXDLLEXPORT wxMacWindowClipper
78{
79 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
80
81public:
82 wxMacWindowClipper( const wxWindow* win ) ;
83 ~wxMacWindowClipper() ;
84private:
85 RgnHandle m_formerClip ;
86 RgnHandle m_newClip ;
87} ;
88
5273bf2f
SC
89class wxMacDrawingHelper
90{
d84afea9
GD
91 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
92
93public:
94 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
95 ~wxMacDrawingHelper() ;
96 bool Ok() { return m_ok ; }
97 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
98 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
99 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
100 const Point& GetOrigin() { return m_origin ; }
101private:
102 Point m_origin ;
103 GrafPtr m_formerPort ;
104 GrafPtr m_currentPort ;
105 PenState m_savedPenState ;
106 bool m_ok ;
5273bf2f
SC
107} ;
108
33426639
SC
109// app.h
110bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
5273bf2f 111
2ba721aa
VZ
112#endif // wxUSE_GUI
113
5273bf2f
SC
114// filefn.h
115WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
116WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
c4e41ce3 117WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
5273bf2f
SC
118# ifndef __DARWIN__
119// Mac file names are POSIX (Unix style) under Darwin, so these are not needed
120WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
121WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
122WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
123WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
124# endif
125
126// utils.h
127WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
128 OSType folderType,
129 Boolean createFolder);
130
2ba721aa
VZ
131#if wxUSE_GUI
132
e40298d5
JS
133GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
134void wxMacDestroyGWorld( GWorldPtr gw ) ;
135PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
5273bf2f 136CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
e40298d5
JS
137void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
138CTabHandle wxMacCreateColorTable( int numColors ) ;
2b5f62a0 139void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
0dbd6262 140
5273bf2f
SC
141#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
142#define MAC_WXHBITMAP(a) (GWorldPtr(a))
143#define MAC_WXHMETAFILE(a) (PicHandle(a))
144#define MAC_WXHICON(a) (CIconHandle(a))
145#define MAC_WXHCURSOR(a) (CursHandle(a))
146#define MAC_WXHRGN(a) (RgnHandle(a))
147#define MAC_WXHWND(a) (WindowPtr(a))
148#define MAC_WXRECPTR(a) ((Rect*)a)
149#define MAC_WXPOINTPTR(a) ((Point*)a)
150#define MAC_WXHMENU(a) ((MenuHandle)a)
3d963f81 151
2ba721aa
VZ
152#endif // wxUSE_GUI
153
88522554
SC
154//---------------------------------------------------------------------------
155// wxMac string conversions
156//---------------------------------------------------------------------------
157
c4e41ce3
SC
158void wxMacSetupConverters() ;
159void wxMacCleanupConverters() ;
160
161void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
162wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
163
164wxCharBuffer wxMacStringToCString( const wxString &from ) ;
165wxWCharBuffer wxMacStringToWString( const wxString &from ) ;
166wxString wxMacMakeStringFromCString( const char * from , int len ) ;
167wxString wxMacMakeStringFromCString( const char * from ) ;
168
169#if TARGET_CARBON
170
171class wxMacCFStringHolder
172{
173public:
174 wxMacCFStringHolder()
175 {
176 m_cfs = NULL ;
177 m_release = false ;
178 }
179
180 wxMacCFStringHolder(const wxString &str)
181 {
182 m_cfs = NULL ;
183 m_release = false ;
184 Assign( str ) ;
185 }
186
187 wxMacCFStringHolder(CFStringRef ref , bool release = true )
188 {
189 m_cfs = ref ;
190 m_release = release ;
191 }
192
193 ~wxMacCFStringHolder()
194 {
195 Release() ;
196 }
197
198 wxMacCFStringHolder& operator=(const wxString& str)
199 {
200 Release() ;
201 Assign( str ) ;
202 return *this;
203 }
204
205 CFStringRef Detach()
206 {
207 CFStringRef retval = m_cfs ;
208 m_release = false ;
209 m_cfs = NULL ;
210 return retval ;
211 }
212
213 void Release()
214 {
215 if ( m_release && m_cfs)
216 CFRelease( m_cfs ) ;
217 m_cfs = NULL ;
218 }
219
220 operator CFStringRef () { return m_cfs; }
221 wxString AsString() ;
222
223private:
224 void Assign( const wxString &str ) ;
225
226 CFStringRef m_cfs;
227 bool m_release ;
228} ;
229
230// CFStringRef wxMacStringToCFString( const wxString &str ) ;
231// wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
232#endif
233
234#if 0
235
88522554
SC
236void wxMacConvertToPC( const char *from , char *to , int len ) ;
237void wxMacConvertFromPC( const char *from , char *to , int len ) ;
238void wxMacConvertToPC( const char *from , char *to , int len ) ;
239
c4e41ce3
SC
240wxString wxMacMakeMacStringFromPC( const wxChar * p ) ;
241
242wxString wxMacMakePCStringFromMac( const wxChar * p ) ;
243
244
245// converts this c string into a wxString with optional mac 2 pc encoding
246wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) ;
247
248// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
249inline wxString wxMacMakeStringFromMacString( const wxChar* from )
250 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
251
252#if wxUSE_UNICODE
253
88522554
SC
254wxString wxMacMakeMacStringFromPC( const char * p ) ;
255
256wxString wxMacMakePCStringFromMac( const char * p ) ;
257
88522554
SC
258// converts this c string into a wxString with optional mac 2 pc encoding
259wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
260
261// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
262inline wxString wxMacMakeStringFromMacString( const char* from )
263 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
264
c4e41ce3
SC
265#endif
266
88522554
SC
267// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
268inline wxString wxMacMakeStringFromMacString( const wxString& from )
269 { return wxApp::s_macDefaultEncodingIsPC ?
e40298d5 270 wxMacMakeStringFromMacString( from.c_str() , true ) : from ; }
88522554
SC
271
272//
273// Pascal Strings
274//
275
276// converts this string into a pascal with optional pc 2 mac encoding
c4e41ce3 277void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) ;
88522554
SC
278
279// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
c4e41ce3 280inline void wxMacStringToPascal( const wxChar * from , StringPtr to )
88522554
SC
281 { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
282
283// converts this string into a pascal with optional mac 2 pc encoding
284wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) ;
285
286// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
287inline wxString wxMacMakeStringFromPascal( ConstStringPtr from )
288 { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
289
290//
291// CFStringRefs (Carbon only)
292//
b89f2376 293
3d963f81
SC
294#if TARGET_CARBON
295// converts this string into a carbon foundation string with optional pc 2 mac encoding
c4e41ce3 296CFStringRef wxMacStringToCFString( const wxString &str , bool pc2macEncoding ) ;
3d963f81
SC
297
298// converts this string into a carbon foundation string with optional pc 2 mac encoding
c4e41ce3
SC
299inline CFStringRef wxMacStringToCFString( const wxString &str )
300 { return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; }
3d963f81
SC
301
302#endif //TARGET_CARBON
303
2ba721aa 304#endif // 0
b89f2376 305
0dbd6262
SC
306#endif
307 // _WX_PRIVATE_H_