1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Private declarations: as this header is only included by
4 // wxWindows itself, it may contain identifiers which don't start
6 // Author: Stefan Csomor
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
21 # include <Carbon/Carbon.h>
23 # include <Quickdraw.h>
24 # include <Appearance.h>
26 # include <Controls.h>
27 # include <ControlDefinitions.h>
32 #if UNIVERSAL_INTERFACES_VERSION < 0x0340
33 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
38 #include "wx/window.h"
40 class wxMacPortStateHelper
42 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
45 wxMacPortStateHelper( GrafPtr newport
) ;
46 wxMacPortStateHelper() ;
47 ~wxMacPortStateHelper() ;
49 void Setup( GrafPtr newport
) ;
51 bool IsCleared() { return m_clip
== NULL
; }
52 GrafPtr
GetCurrentPort() { return m_currentPort
; }
55 GrafPtr m_currentPort
;
58 ThemeDrawingState m_drawingState
;
65 class WXDLLEXPORT wxMacPortSetter
67 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
70 wxMacPortSetter( const wxDC
* dc
) ;
73 wxMacPortStateHelper m_ph
;
77 class WXDLLEXPORT wxMacWindowClipper
79 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
82 wxMacWindowClipper( const wxWindow
* win
) ;
83 ~wxMacWindowClipper() ;
85 RgnHandle m_formerClip
;
89 class wxMacDrawingHelper
91 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper
)
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
; }
103 GrafPtr m_formerPort
;
104 GrafPtr m_currentPort
;
105 PenState m_savedPenState
;
110 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
) ;
115 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
) ;
116 WXDLLEXPORT
void wxMacFilename2FSSpec( const char *path
, FSSpec
*spec
) ;
117 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxChar
*path
, FSSpec
*spec
) ;
119 // Mac file names are POSIX (Unix style) under Darwin, so these are not needed
120 WXDLLEXPORT wxString
wxMacFSSpec2UnixFilename( const FSSpec
*spec
) ;
121 WXDLLEXPORT
void wxUnixFilename2FSSpec( const char *path
, FSSpec
*spec
) ;
122 WXDLLEXPORT wxString
wxMac2UnixFilename( const char *s
) ;
123 WXDLLEXPORT wxString
wxUnix2MacFilename( const char *s
);
127 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
129 Boolean createFolder
);
133 GWorldPtr
wxMacCreateGWorld( int width
, int height
, int depth
) ;
134 void wxMacDestroyGWorld( GWorldPtr gw
) ;
135 PicHandle
wxMacCreatePict( GWorldPtr gw
, GWorldPtr mask
= NULL
) ;
136 CIconHandle
wxMacCreateCIcon(GWorldPtr image
, GWorldPtr mask
, short dstDepth
, short iconSize
) ;
137 void wxMacSetColorTableEntry( CTabHandle newColors
, int index
, int red
, int green
, int blue
) ;
138 CTabHandle
wxMacCreateColorTable( int numColors
) ;
139 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 ) ;
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)
154 //---------------------------------------------------------------------------
155 // wxMac string conversions
156 //---------------------------------------------------------------------------
158 void wxMacSetupConverters() ;
159 void wxMacCleanupConverters() ;
161 void wxMacStringToPascal( const wxString
&from
, StringPtr to
) ;
162 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
) ;
164 wxCharBuffer
wxMacStringToCString( const wxString
&from
) ;
165 wxWCharBuffer
wxMacStringToWString( const wxString
&from
) ;
166 wxString
wxMacMakeStringFromCString( const char * from
, int len
) ;
167 wxString
wxMacMakeStringFromCString( const char * from
) ;
171 class wxMacCFStringHolder
174 wxMacCFStringHolder()
180 wxMacCFStringHolder(const wxString
&str
)
187 wxMacCFStringHolder(CFStringRef ref
, bool release
= true )
190 m_release
= release
;
193 ~wxMacCFStringHolder()
198 wxMacCFStringHolder
& operator=(const wxString
& str
)
207 CFStringRef retval
= m_cfs
;
215 if ( m_release
&& m_cfs
)
220 operator CFStringRef () { return m_cfs
; }
221 wxString
AsString() ;
224 void Assign( const wxString
&str
) ;
230 // CFStringRef wxMacStringToCFString( const wxString &str ) ;
231 // wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
236 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
237 void wxMacConvertFromPC( const char *from
, char *to
, int len
) ;
238 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
240 wxString
wxMacMakeMacStringFromPC( const wxChar
* p
) ;
242 wxString
wxMacMakePCStringFromMac( const wxChar
* p
) ;
245 // converts this c string into a wxString with optional mac 2 pc encoding
246 wxString
wxMacMakeStringFromMacString( const wxChar
* from
, bool mac2pcEncoding
) ;
248 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
249 inline wxString
wxMacMakeStringFromMacString( const wxChar
* from
)
250 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
254 wxString
wxMacMakeMacStringFromPC( const char * p
) ;
256 wxString
wxMacMakePCStringFromMac( const char * p
) ;
258 // converts this c string into a wxString with optional mac 2 pc encoding
259 wxString
wxMacMakeStringFromMacString( const char* from
, bool mac2pcEncoding
) ;
261 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
262 inline wxString
wxMacMakeStringFromMacString( const char* from
)
263 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
267 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
268 inline wxString
wxMacMakeStringFromMacString( const wxString
& from
)
269 { return wxApp::s_macDefaultEncodingIsPC
?
270 wxMacMakeStringFromMacString( from
.c_str() , true ) : from
; }
276 // converts this string into a pascal with optional pc 2 mac encoding
277 void wxMacStringToPascal( const wxChar
* from
, StringPtr to
, bool pc2macEncoding
) ;
279 // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
280 inline void wxMacStringToPascal( const wxChar
* from
, StringPtr to
)
281 { wxMacStringToPascal( from
, to
, wxApp::s_macDefaultEncodingIsPC
) ; }
283 // converts this string into a pascal with optional mac 2 pc encoding
284 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
, bool mac2pcEncoding
) ;
286 // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
287 inline wxString
wxMacMakeStringFromPascal( ConstStringPtr from
)
288 { return wxMacMakeStringFromPascal( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
291 // CFStringRefs (Carbon only)
295 // converts this string into a carbon foundation string with optional pc 2 mac encoding
296 CFStringRef
wxMacStringToCFString( const wxString
&str
, bool pc2macEncoding
) ;
298 // converts this string into a carbon foundation string with optional pc 2 mac encoding
299 inline CFStringRef
wxMacStringToCFString( const wxString
&str
)
300 { return wxMacStringToCFString( str
, wxApp::s_macDefaultEncodingIsPC
) ; }
302 #endif //TARGET_CARBON