]>
Commit | Line | Data |
---|---|---|
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 | ||
fa9d617b GD |
36 | #include "wx/window.h" |
37 | ||
5273bf2f SC |
38 | class wxMacPortStateHelper |
39 | { | |
d84afea9 GD |
40 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) |
41 | ||
42 | public: | |
43 | wxMacPortStateHelper( GrafPtr newport) ; | |
44 | wxMacPortStateHelper() ; | |
45 | ~wxMacPortStateHelper() ; | |
5273bf2f | 46 | |
d84afea9 GD |
47 | void Setup( GrafPtr newport ) ; |
48 | void Clear() ; | |
49 | bool IsCleared() { return m_clip == NULL ; } | |
50 | GrafPtr GetCurrentPort() { return m_currentPort ; } | |
5273bf2f | 51 | |
d84afea9 | 52 | private: |
e40298d5 JS |
53 | GrafPtr m_currentPort ; |
54 | GrafPtr m_oldPort ; | |
55 | RgnHandle m_clip ; | |
d84afea9 | 56 | ThemeDrawingState m_drawingState ; |
e40298d5 JS |
57 | short m_textFont ; |
58 | short m_textSize ; | |
59 | short m_textStyle ; | |
60 | short m_textMode ; | |
5273bf2f SC |
61 | } ; |
62 | ||
63 | class WXDLLEXPORT wxMacPortSetter | |
64 | { | |
d84afea9 GD |
65 | DECLARE_NO_COPY_CLASS(wxMacPortSetter) |
66 | ||
67 | public: | |
68 | wxMacPortSetter( const wxDC* dc ) ; | |
69 | ~wxMacPortSetter() ; | |
70 | private: | |
71 | wxMacPortStateHelper m_ph ; | |
72 | const wxDC* m_dc ; | |
5273bf2f SC |
73 | } ; |
74 | ||
e671beca SC |
75 | class WXDLLEXPORT wxMacWindowClipper |
76 | { | |
77 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
78 | ||
79 | public: | |
80 | wxMacWindowClipper( const wxWindow* win ) ; | |
81 | ~wxMacWindowClipper() ; | |
82 | private: | |
83 | RgnHandle m_formerClip ; | |
84 | RgnHandle m_newClip ; | |
85 | } ; | |
86 | ||
5273bf2f SC |
87 | class wxMacDrawingHelper |
88 | { | |
d84afea9 GD |
89 | DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) |
90 | ||
91 | public: | |
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 ; } | |
99 | private: | |
100 | Point m_origin ; | |
101 | GrafPtr m_formerPort ; | |
102 | GrafPtr m_currentPort ; | |
103 | PenState m_savedPenState ; | |
104 | bool m_ok ; | |
5273bf2f SC |
105 | } ; |
106 | ||
33426639 SC |
107 | // app.h |
108 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; | |
5273bf2f SC |
109 | |
110 | // filefn.h | |
111 | WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; | |
112 | WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ; | |
c4e41ce3 | 113 | WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ; |
5273bf2f SC |
114 | # ifndef __DARWIN__ |
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); | |
120 | # endif | |
121 | ||
122 | // utils.h | |
123 | WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, | |
124 | OSType folderType, | |
125 | Boolean createFolder); | |
126 | ||
e40298d5 JS |
127 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; |
128 | void wxMacDestroyGWorld( GWorldPtr gw ) ; | |
129 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; | |
5273bf2f | 130 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; |
e40298d5 JS |
131 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; |
132 | CTabHandle wxMacCreateColorTable( int numColors ) ; | |
2b5f62a0 | 133 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; |
0dbd6262 | 134 | |
5273bf2f SC |
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) | |
3d963f81 | 145 | |
88522554 SC |
146 | //--------------------------------------------------------------------------- |
147 | // wxMac string conversions | |
148 | //--------------------------------------------------------------------------- | |
149 | ||
c4e41ce3 SC |
150 | void wxMacSetupConverters() ; |
151 | void wxMacCleanupConverters() ; | |
152 | ||
153 | void wxMacStringToPascal( const wxString&from , StringPtr to ) ; | |
154 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; | |
155 | ||
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 ) ; | |
160 | ||
161 | #if TARGET_CARBON | |
162 | ||
163 | class wxMacCFStringHolder | |
164 | { | |
165 | public: | |
166 | wxMacCFStringHolder() | |
167 | { | |
168 | m_cfs = NULL ; | |
169 | m_release = false ; | |
170 | } | |
171 | ||
172 | wxMacCFStringHolder(const wxString &str) | |
173 | { | |
174 | m_cfs = NULL ; | |
175 | m_release = false ; | |
176 | Assign( str ) ; | |
177 | } | |
178 | ||
179 | wxMacCFStringHolder(CFStringRef ref , bool release = true ) | |
180 | { | |
181 | m_cfs = ref ; | |
182 | m_release = release ; | |
183 | } | |
184 | ||
185 | ~wxMacCFStringHolder() | |
186 | { | |
187 | Release() ; | |
188 | } | |
189 | ||
190 | wxMacCFStringHolder& operator=(const wxString& str) | |
191 | { | |
192 | Release() ; | |
193 | Assign( str ) ; | |
194 | return *this; | |
195 | } | |
196 | ||
197 | CFStringRef Detach() | |
198 | { | |
199 | CFStringRef retval = m_cfs ; | |
200 | m_release = false ; | |
201 | m_cfs = NULL ; | |
202 | return retval ; | |
203 | } | |
204 | ||
205 | void Release() | |
206 | { | |
207 | if ( m_release && m_cfs) | |
208 | CFRelease( m_cfs ) ; | |
209 | m_cfs = NULL ; | |
210 | } | |
211 | ||
212 | operator CFStringRef () { return m_cfs; } | |
213 | wxString AsString() ; | |
214 | ||
215 | private: | |
216 | void Assign( const wxString &str ) ; | |
217 | ||
218 | CFStringRef m_cfs; | |
219 | bool m_release ; | |
220 | } ; | |
221 | ||
222 | // CFStringRef wxMacStringToCFString( const wxString &str ) ; | |
223 | // wxString wxMacMakeStringFromCFString( CFStringRef cf ) ; | |
224 | #endif | |
225 | ||
226 | #if 0 | |
227 | ||
88522554 SC |
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 ) ; | |
231 | ||
c4e41ce3 SC |
232 | wxString wxMacMakeMacStringFromPC( const wxChar * p ) ; |
233 | ||
234 | wxString wxMacMakePCStringFromMac( const wxChar * p ) ; | |
235 | ||
236 | ||
237 | // converts this c string into a wxString with optional mac 2 pc encoding | |
238 | wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) ; | |
239 | ||
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 ) ; } | |
243 | ||
244 | #if wxUSE_UNICODE | |
245 | ||
88522554 SC |
246 | wxString wxMacMakeMacStringFromPC( const char * p ) ; |
247 | ||
248 | wxString wxMacMakePCStringFromMac( const char * p ) ; | |
249 | ||
88522554 SC |
250 | // converts this c string into a wxString with optional mac 2 pc encoding |
251 | wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ; | |
252 | ||
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 ) ; } | |
256 | ||
c4e41ce3 SC |
257 | #endif |
258 | ||
88522554 SC |
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 ? | |
e40298d5 | 262 | wxMacMakeStringFromMacString( from.c_str() , true ) : from ; } |
88522554 SC |
263 | |
264 | // | |
265 | // Pascal Strings | |
266 | // | |
267 | ||
268 | // converts this string into a pascal with optional pc 2 mac encoding | |
c4e41ce3 | 269 | void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) ; |
88522554 SC |
270 | |
271 | // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC | |
c4e41ce3 | 272 | inline void wxMacStringToPascal( const wxChar * from , StringPtr to ) |
88522554 SC |
273 | { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; } |
274 | ||
275 | // converts this string into a pascal with optional mac 2 pc encoding | |
276 | wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) ; | |
277 | ||
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 ) ; } | |
281 | ||
282 | // | |
283 | // CFStringRefs (Carbon only) | |
284 | // | |
b89f2376 | 285 | |
3d963f81 SC |
286 | #if TARGET_CARBON |
287 | // converts this string into a carbon foundation string with optional pc 2 mac encoding | |
c4e41ce3 | 288 | CFStringRef wxMacStringToCFString( const wxString &str , bool pc2macEncoding ) ; |
3d963f81 SC |
289 | |
290 | // converts this string into a carbon foundation string with optional pc 2 mac encoding | |
c4e41ce3 SC |
291 | inline CFStringRef wxMacStringToCFString( const wxString &str ) |
292 | { return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; } | |
3d963f81 SC |
293 | |
294 | #endif //TARGET_CARBON | |
295 | ||
c4e41ce3 | 296 | #endif |
b89f2376 | 297 | |
0dbd6262 SC |
298 | #endif |
299 | // _WX_PRIVATE_H_ |