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/"
36 #include "wx/window.h"
38 class wxMacPortStateHelper
40 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper
)
43 wxMacPortStateHelper( GrafPtr newport
) ;
44 wxMacPortStateHelper() ;
45 ~wxMacPortStateHelper() ;
47 void Setup( GrafPtr newport
) ;
49 bool IsCleared() { return m_clip
== NULL
; }
50 GrafPtr
GetCurrentPort() { return m_currentPort
; }
53 GrafPtr m_currentPort
;
56 ThemeDrawingState m_drawingState
;
63 class WXDLLEXPORT wxMacPortSetter
65 DECLARE_NO_COPY_CLASS(wxMacPortSetter
)
68 wxMacPortSetter( const wxDC
* dc
) ;
71 wxMacPortStateHelper m_ph
;
75 class WXDLLEXPORT wxMacWindowClipper
77 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
80 wxMacWindowClipper( const wxWindow
* win
) ;
81 ~wxMacWindowClipper() ;
83 RgnHandle m_formerClip
;
87 class wxMacDrawingHelper
89 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper
)
92 wxMacDrawingHelper( wxWindowMac
* theWindow
, bool clientArea
= false ) ;
93 ~wxMacDrawingHelper() ;
94 bool Ok() { return m_ok
; }
95 void LocalToWindow( Rect
*rect
) { OffsetRect( rect
, m_origin
.h
, m_origin
.v
) ; }
96 void LocalToWindow( Point
*pt
) { AddPt( m_origin
, pt
) ; }
97 void LocalToWindow( RgnHandle rgn
) { OffsetRgn( rgn
, m_origin
.h
, m_origin
.v
) ; }
98 const Point
& GetOrigin() { return m_origin
; }
101 GrafPtr m_formerPort
;
102 GrafPtr m_currentPort
;
103 PenState m_savedPenState
;
108 bool wxMacConvertEventToRecord( EventRef event
, EventRecord
*rec
) ;
111 WXDLLEXPORT wxString
wxMacFSSpec2MacFilename( const FSSpec
*spec
) ;
112 WXDLLEXPORT
void wxMacFilename2FSSpec( const char *path
, FSSpec
*spec
) ;
113 WXDLLEXPORT
void wxMacFilename2FSSpec( const wxChar
*path
, FSSpec
*spec
) ;
115 // Mac file names are POSIX (Unix style) under Darwin, so these are not needed
116 WXDLLEXPORT wxString
wxMacFSSpec2UnixFilename( const FSSpec
*spec
) ;
117 WXDLLEXPORT
void wxUnixFilename2FSSpec( const char *path
, FSSpec
*spec
) ;
118 WXDLLEXPORT wxString
wxMac2UnixFilename( const char *s
) ;
119 WXDLLEXPORT wxString
wxUnix2MacFilename( const char *s
);
123 WXDLLEXPORT wxString
wxMacFindFolder(short vRefNum
,
125 Boolean createFolder
);
127 GWorldPtr
wxMacCreateGWorld( int width
, int height
, int depth
) ;
128 void wxMacDestroyGWorld( GWorldPtr gw
) ;
129 PicHandle
wxMacCreatePict( GWorldPtr gw
, GWorldPtr mask
= NULL
) ;
130 CIconHandle
wxMacCreateCIcon(GWorldPtr image
, GWorldPtr mask
, short dstDepth
, short iconSize
) ;
131 void wxMacSetColorTableEntry( CTabHandle newColors
, int index
, int red
, int green
, int blue
) ;
132 CTabHandle
wxMacCreateColorTable( int numColors
) ;
133 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
= 0 ) ;
135 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
136 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
137 #define MAC_WXHMETAFILE(a) (PicHandle(a))
138 #define MAC_WXHICON(a) (CIconHandle(a))
139 #define MAC_WXHCURSOR(a) (CursHandle(a))
140 #define MAC_WXHRGN(a) (RgnHandle(a))
141 #define MAC_WXHWND(a) (WindowPtr(a))
142 #define MAC_WXRECPTR(a) ((Rect*)a)
143 #define MAC_WXPOINTPTR(a) ((Point*)a)
144 #define MAC_WXHMENU(a) ((MenuHandle)a)
146 //---------------------------------------------------------------------------
147 // wxMac string conversions
148 //---------------------------------------------------------------------------
150 void wxMacSetupConverters() ;
151 void wxMacCleanupConverters() ;
153 void wxMacStringToPascal( const wxString
&from
, StringPtr to
) ;
154 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
) ;
156 wxCharBuffer
wxMacStringToCString( const wxString
&from
) ;
157 wxWCharBuffer
wxMacStringToWString( const wxString
&from
) ;
158 wxString
wxMacMakeStringFromCString( const char * from
, int len
) ;
159 wxString
wxMacMakeStringFromCString( const char * from
) ;
163 class wxMacCFStringHolder
166 wxMacCFStringHolder()
172 wxMacCFStringHolder(const wxString
&str
)
179 wxMacCFStringHolder(CFStringRef ref
, bool release
= true )
182 m_release
= release
;
185 ~wxMacCFStringHolder()
190 wxMacCFStringHolder
& operator=(const wxString
& str
)
199 CFStringRef retval
= m_cfs
;
207 if ( m_release
&& m_cfs
)
212 operator CFStringRef () { return m_cfs
; }
213 wxString
AsString() ;
216 void Assign( const wxString
&str
) ;
222 // CFStringRef wxMacStringToCFString( const wxString &str ) ;
223 // wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
228 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
229 void wxMacConvertFromPC( const char *from
, char *to
, int len
) ;
230 void wxMacConvertToPC( const char *from
, char *to
, int len
) ;
232 wxString
wxMacMakeMacStringFromPC( const wxChar
* p
) ;
234 wxString
wxMacMakePCStringFromMac( const wxChar
* p
) ;
237 // converts this c string into a wxString with optional mac 2 pc encoding
238 wxString
wxMacMakeStringFromMacString( const wxChar
* from
, bool mac2pcEncoding
) ;
240 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
241 inline wxString
wxMacMakeStringFromMacString( const wxChar
* from
)
242 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
246 wxString
wxMacMakeMacStringFromPC( const char * p
) ;
248 wxString
wxMacMakePCStringFromMac( const char * p
) ;
250 // converts this c string into a wxString with optional mac 2 pc encoding
251 wxString
wxMacMakeStringFromMacString( const char* from
, bool mac2pcEncoding
) ;
253 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
254 inline wxString
wxMacMakeStringFromMacString( const char* from
)
255 { return wxMacMakeStringFromMacString( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
259 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
260 inline wxString
wxMacMakeStringFromMacString( const wxString
& from
)
261 { return wxApp::s_macDefaultEncodingIsPC
?
262 wxMacMakeStringFromMacString( from
.c_str() , true ) : from
; }
268 // converts this string into a pascal with optional pc 2 mac encoding
269 void wxMacStringToPascal( const wxChar
* from
, StringPtr to
, bool pc2macEncoding
) ;
271 // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
272 inline void wxMacStringToPascal( const wxChar
* from
, StringPtr to
)
273 { wxMacStringToPascal( from
, to
, wxApp::s_macDefaultEncodingIsPC
) ; }
275 // converts this string into a pascal with optional mac 2 pc encoding
276 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
, bool mac2pcEncoding
) ;
278 // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
279 inline wxString
wxMacMakeStringFromPascal( ConstStringPtr from
)
280 { return wxMacMakeStringFromPascal( from
, wxApp::s_macDefaultEncodingIsPC
) ; }
283 // CFStringRefs (Carbon only)
287 // converts this string into a carbon foundation string with optional pc 2 mac encoding
288 CFStringRef
wxMacStringToCFString( const wxString
&str
, bool pc2macEncoding
) ;
290 // converts this string into a carbon foundation string with optional pc 2 mac encoding
291 inline CFStringRef
wxMacStringToCFString( const wxString
&str
)
292 { return wxMacStringToCFString( str
, wxApp::s_macDefaultEncodingIsPC
) ; }
294 #endif //TARGET_CARBON