]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/private.h
corrected the value of EUC_JP
[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: ??/??/98
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 #include "wx/window.h"
37
38 class wxMacPortStateHelper
39 {
40 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
41
42 public:
43 wxMacPortStateHelper( GrafPtr newport) ;
44 wxMacPortStateHelper() ;
45 ~wxMacPortStateHelper() ;
46
47 void Setup( GrafPtr newport ) ;
48 void Clear() ;
49 bool IsCleared() { return m_clip == NULL ; }
50 GrafPtr GetCurrentPort() { return m_currentPort ; }
51
52 private:
53 GrafPtr m_currentPort ;
54 GrafPtr m_oldPort ;
55 RgnHandle m_clip ;
56 ThemeDrawingState m_drawingState ;
57 short m_textFont ;
58 short m_textSize ;
59 short m_textStyle ;
60 short m_textMode ;
61 } ;
62
63 class WXDLLEXPORT wxMacPortSetter
64 {
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 ;
73 } ;
74
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
87 class wxMacDrawingHelper
88 {
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 ;
105 } ;
106
107 // app.h
108 bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
109
110 // filefn.h
111 WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
112 WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
113 # ifndef __DARWIN__
114 // Mac file names are POSIX (Unix style) under Darwin, so these are not needed
115 WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
116 WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
117 WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
118 WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
119 # endif
120
121 // utils.h
122 WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
123 OSType folderType,
124 Boolean createFolder);
125
126 GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
127 void wxMacDestroyGWorld( GWorldPtr gw ) ;
128 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
129 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
130 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
131 CTabHandle wxMacCreateColorTable( int numColors ) ;
132 void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
133
134 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
135 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
136 #define MAC_WXHMETAFILE(a) (PicHandle(a))
137 #define MAC_WXHICON(a) (CIconHandle(a))
138 #define MAC_WXHCURSOR(a) (CursHandle(a))
139 #define MAC_WXHRGN(a) (RgnHandle(a))
140 #define MAC_WXHWND(a) (WindowPtr(a))
141 #define MAC_WXRECPTR(a) ((Rect*)a)
142 #define MAC_WXPOINTPTR(a) ((Point*)a)
143 #define MAC_WXHMENU(a) ((MenuHandle)a)
144
145 //---------------------------------------------------------------------------
146 // wxMac string conversions
147 //---------------------------------------------------------------------------
148
149 void wxMacConvertToPC( const char *from , char *to , int len ) ;
150 void wxMacConvertFromPC( const char *from , char *to , int len ) ;
151 void wxMacConvertToPC( const char *from , char *to , int len ) ;
152
153 wxString wxMacMakeMacStringFromPC( const char * p ) ;
154
155 wxString wxMacMakePCStringFromMac( const char * p ) ;
156
157
158 // converts this c string into a wxString with optional mac 2 pc encoding
159 wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
160
161 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
162 inline wxString wxMacMakeStringFromMacString( const char* from )
163 { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
164
165 // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
166 inline wxString wxMacMakeStringFromMacString( const wxString& from )
167 { return wxApp::s_macDefaultEncodingIsPC ?
168 wxMacMakeStringFromMacString( from.c_str() , true ) : from ; }
169
170 //
171 // Pascal Strings
172 //
173
174 // converts this string into a pascal with optional pc 2 mac encoding
175 void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) ;
176
177 // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
178 inline void wxMacStringToPascal( const char * from , StringPtr to )
179 { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
180
181 // converts this string into a pascal with optional mac 2 pc encoding
182 wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) ;
183
184 // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
185 inline wxString wxMacMakeStringFromPascal( ConstStringPtr from )
186 { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
187
188 //
189 // CFStringRefs (Carbon only)
190 //
191
192 #if TARGET_CARBON
193 // converts this string into a carbon foundation string with optional pc 2 mac encoding
194 CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) ;
195
196 // converts this string into a carbon foundation string with optional pc 2 mac encoding
197 inline CFStringRef wxMacCreateCFString( const wxString &str )
198 { return wxMacCreateCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; }
199
200 #endif //TARGET_CARBON
201
202
203 #endif
204 // _WX_PRIVATE_H_