]>
Commit | Line | Data |
---|---|---|
52479aef SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: private.h | |
3 | // Purpose: Private declarations: as this header is only included by | |
77ffb593 | 4 | // wxWidgets itself, it may contain identifiers which don't start |
52479aef SC |
5 | // with "wx". |
6 | // Author: Stefan Csomor | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id$ | |
10 | // Copyright: (c) Stefan Csomor | |
65571936 | 11 | // Licence: wxWindows licence |
52479aef SC |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_PRIVATE_H_ | |
15 | #define _WX_PRIVATE_H_ | |
16 | ||
17 | #include "wx/defs.h" | |
18 | #include "wx/app.h" | |
19 | ||
20 | #ifdef __DARWIN__ | |
21 | # include <Carbon/Carbon.h> | |
22 | #else | |
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> | |
30 | #endif | |
31 | ||
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 | ||
36 | #if wxUSE_GUI | |
37 | ||
38 | #include "wx/window.h" | |
39 | ||
40 | class wxMacPortStateHelper | |
41 | { | |
42 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) | |
43 | ||
44 | public: | |
45 | wxMacPortStateHelper( GrafPtr newport) ; | |
46 | wxMacPortStateHelper() ; | |
47 | ~wxMacPortStateHelper() ; | |
48 | ||
49 | void Setup( GrafPtr newport ) ; | |
50 | void Clear() ; | |
51 | bool IsCleared() { return m_clip == NULL ; } | |
52 | GrafPtr GetCurrentPort() { return m_currentPort ; } | |
53 | ||
54 | private: | |
55 | GrafPtr m_currentPort ; | |
56 | GrafPtr m_oldPort ; | |
57 | RgnHandle m_clip ; | |
58 | ThemeDrawingState m_drawingState ; | |
59 | short m_textFont ; | |
60 | short m_textSize ; | |
61 | short m_textStyle ; | |
62 | short m_textMode ; | |
63 | } ; | |
64 | ||
65 | class WXDLLEXPORT wxMacPortSetter | |
66 | { | |
67 | DECLARE_NO_COPY_CLASS(wxMacPortSetter) | |
68 | ||
69 | public: | |
70 | wxMacPortSetter( const wxDC* dc ) ; | |
71 | ~wxMacPortSetter() ; | |
72 | private: | |
73 | wxMacPortStateHelper m_ph ; | |
74 | const wxDC* m_dc ; | |
75 | } ; | |
76 | ||
77 | class WXDLLEXPORT wxMacWindowClipper | |
78 | { | |
79 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
80 | ||
81 | public: | |
82 | wxMacWindowClipper( const wxWindow* win ) ; | |
83 | ~wxMacWindowClipper() ; | |
84 | private: | |
85 | RgnHandle m_formerClip ; | |
86 | RgnHandle m_newClip ; | |
87 | } ; | |
88 | ||
89 | class wxMacDrawingHelper | |
90 | { | |
91 | DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) | |
92 | ||
93 | public: | |
94 | wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ; | |
95 | ~wxMacDrawingHelper() ; | |
b7cacb43 VZ |
96 | bool Ok() const { return IsOk(); } |
97 | bool IsOk() { return m_ok ; } | |
52479aef SC |
98 | void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; } |
99 | void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; } | |
100 | void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; } | |
101 | const Point& GetOrigin() { return m_origin ; } | |
102 | private: | |
103 | Point m_origin ; | |
104 | GrafPtr m_formerPort ; | |
105 | GrafPtr m_currentPort ; | |
106 | PenState m_savedPenState ; | |
107 | bool m_ok ; | |
108 | } ; | |
109 | ||
110 | // app.h | |
111 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; | |
112 | ||
113 | #endif // wxUSE_GUI | |
114 | ||
115 | // filefn.h | |
116 | WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; | |
117 | WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ; | |
118 | WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ; | |
119 | # ifndef __DARWIN__ | |
120 | // Mac file names are POSIX (Unix style) under Darwin, so these are not needed | |
121 | WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ; | |
6b941b35 SC |
122 | WXDLLEXPORT void wxUnixFilename2FSSpec( const wxChar *path , FSSpec *spec ) ; |
123 | WXDLLEXPORT wxString wxMac2UnixFilename( const wxChar *s) ; | |
124 | WXDLLEXPORT wxString wxUnix2MacFilename( const wxChar *s); | |
52479aef SC |
125 | # endif |
126 | ||
127 | // utils.h | |
17af82fb VZ |
128 | WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum, |
129 | OSType folderType, | |
130 | Boolean createFolder); | |
52479aef SC |
131 | WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, |
132 | OSType folderType, | |
133 | Boolean createFolder); | |
134 | ||
135 | #if wxUSE_GUI | |
136 | ||
137 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; | |
138 | void wxMacDestroyGWorld( GWorldPtr gw ) ; | |
139 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; | |
140 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; | |
141 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; | |
142 | CTabHandle wxMacCreateColorTable( int numColors ) ; | |
143 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; | |
144 | ||
145 | #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) | |
146 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) | |
147 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
148 | #define MAC_WXHICON(a) (CIconHandle(a)) | |
149 | #define MAC_WXHCURSOR(a) (CursHandle(a)) | |
150 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
151 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
152 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
153 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
154 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
155 | ||
156 | #endif // wxUSE_GUI | |
157 | ||
158 | //--------------------------------------------------------------------------- | |
159 | // wxMac string conversions | |
160 | //--------------------------------------------------------------------------- | |
161 | ||
162 | void wxMacSetupConverters() ; | |
163 | void wxMacCleanupConverters() ; | |
164 | ||
165 | void wxMacStringToPascal( const wxString&from , StringPtr to ) ; | |
166 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; | |
167 | ||
168 | void wxMacConvertNewlines13To10( char * data ) ; | |
169 | void wxMacConvertNewlines10To13( char * data ) ; | |
170 | void wxMacConvertNewlines13To10( wxString *data ) ; | |
171 | void wxMacConvertNewlines10To13( wxString *data ) ; | |
172 | ||
173 | #if wxUSE_UNICODE | |
174 | void wxMacConvertNewlines13To10( wxChar * data ) ; | |
175 | void wxMacConvertNewlines10To13( wxChar * data ) ; | |
176 | #endif | |
177 | ||
178 | #if TARGET_CARBON | |
179 | ||
180 | class wxMacCFStringHolder | |
181 | { | |
182 | public: | |
183 | wxMacCFStringHolder() | |
184 | { | |
185 | m_cfs = NULL ; | |
186 | m_release = false ; | |
187 | } | |
188 | ||
189 | wxMacCFStringHolder(const wxString &str , wxFontEncoding encoding ) | |
190 | { | |
191 | m_cfs = NULL ; | |
192 | m_release = false ; | |
193 | Assign( str , encoding ) ; | |
194 | } | |
195 | ||
196 | wxMacCFStringHolder(CFStringRef ref , bool release = true ) | |
197 | { | |
198 | m_cfs = ref ; | |
199 | m_release = release ; | |
200 | } | |
201 | ||
202 | ~wxMacCFStringHolder() | |
203 | { | |
204 | Release() ; | |
205 | } | |
206 | ||
207 | CFStringRef Detach() | |
208 | { | |
209 | CFStringRef retval = m_cfs ; | |
210 | m_release = false ; | |
211 | m_cfs = NULL ; | |
212 | return retval ; | |
213 | } | |
214 | ||
215 | void Release() | |
216 | { | |
217 | if ( m_release && m_cfs) | |
218 | CFRelease( m_cfs ) ; | |
219 | m_cfs = NULL ; | |
220 | } | |
221 | ||
222 | void Assign( const wxString &str , wxFontEncoding encoding ) ; | |
223 | ||
224 | operator CFStringRef () { return m_cfs; } | |
225 | wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ; | |
226 | ||
227 | private: | |
228 | ||
229 | CFStringRef m_cfs; | |
230 | bool m_release ; | |
231 | } ; | |
232 | ||
233 | #endif | |
234 | ||
235 | ||
236 | ||
237 | wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ; | |
238 | wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ; | |
239 | ||
240 | ||
241 | #endif | |
242 | // _WX_PRIVATE_H_ |