]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/private.h
Header Cosmetics
[wxWidgets.git] / include / wx / mac / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: private.h
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
7 // Modified by:
8 // Created: 1998-01-01
9 // RCS-ID: $Id$
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
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() ;
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 ; }
101 private:
102 Point m_origin ;
103 GrafPtr m_formerPort ;
104 GrafPtr m_currentPort ;
105 PenState m_savedPenState ;
106 bool m_ok ;
107 } ;
108
109 // app.h
110 bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
111
112 #endif // wxUSE_GUI
113
114 // filefn.h
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 ) ;
118 # ifndef __DARWIN__
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);
124 # endif
125
126 // utils.h
127 WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
128 OSType folderType,
129 Boolean createFolder);
130
131 #if wxUSE_GUI
132
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 ) ;
140
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)
151
152 #endif // wxUSE_GUI
153
154 //---------------------------------------------------------------------------
155 // wxMac string conversions
156 //---------------------------------------------------------------------------
157
158 void wxMacSetupConverters() ;
159 void wxMacCleanupConverters() ;
160
161 void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
162 wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
163
164 void wxMacConvertNewlines13To10( char * data ) ;
165 void wxMacConvertNewlines10To13( char * data ) ;
166 void wxMacConvertNewlines13To10( wxString *data ) ;
167 void wxMacConvertNewlines10To13( wxString *data ) ;
168
169 #if wxUSE_UNICODE
170 void wxMacConvertNewlines13To10( wxChar * data ) ;
171 void wxMacConvertNewlines10To13( wxChar * data ) ;
172 #endif
173
174 #if TARGET_CARBON
175
176 class wxMacCFStringHolder
177 {
178 public:
179 wxMacCFStringHolder()
180 {
181 m_cfs = NULL ;
182 m_release = false ;
183 }
184
185 wxMacCFStringHolder(const wxString &str)
186 {
187 m_cfs = NULL ;
188 m_release = false ;
189 Assign( str ) ;
190 }
191
192 wxMacCFStringHolder(CFStringRef ref , bool release = true )
193 {
194 m_cfs = ref ;
195 m_release = release ;
196 }
197
198 ~wxMacCFStringHolder()
199 {
200 Release() ;
201 }
202
203 wxMacCFStringHolder& operator=(const wxString& str)
204 {
205 Release() ;
206 Assign( str ) ;
207 return *this;
208 }
209
210 CFStringRef Detach()
211 {
212 CFStringRef retval = m_cfs ;
213 m_release = false ;
214 m_cfs = NULL ;
215 return retval ;
216 }
217
218 void Release()
219 {
220 if ( m_release && m_cfs)
221 CFRelease( m_cfs ) ;
222 m_cfs = NULL ;
223 }
224
225 operator CFStringRef () { return m_cfs; }
226 wxString AsString() ;
227
228 private:
229 void Assign( const wxString &str ) ;
230
231 CFStringRef m_cfs;
232 bool m_release ;
233 } ;
234
235 #endif
236
237 #endif
238 // _WX_PRIVATE_H_