]>
Commit | Line | Data |
---|---|---|
8cf73271 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 |
8cf73271 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 |
8cf73271 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 | |
4f305456 | 23 | # include <Debugging.h> |
8cf73271 SC |
24 | # include <Quickdraw.h> |
25 | # include <Appearance.h> | |
26 | # include <Folders.h> | |
27 | # include <Controls.h> | |
28 | # include <ControlDefinitions.h> | |
29 | # include <LowMem.h> | |
30 | # include <Gestalt.h> | |
d9af087c | 31 | # include <FixMath.h> |
8cf73271 SC |
32 | #endif |
33 | ||
34 | #if UNIVERSAL_INTERFACES_VERSION < 0x0340 | |
35 | #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/" | |
36 | #endif | |
37 | ||
c3a404b0 SC |
38 | #ifndef MAC_OS_X_VERSION_10_3 |
39 | #define MAC_OS_X_VERSION_10_3 1030 | |
40 | #endif | |
41 | ||
5185263f DE |
42 | #ifdef __WXMAC_CARBON__ |
43 | #include "wx/mac/corefoundation/cfstring.h" | |
44 | #endif | |
45 | ||
3d639707 SC |
46 | #ifndef FixedToInt |
47 | // as macro in FixMath.h for 10.3 | |
48 | inline Fixed IntToFixed( int inInt ) | |
49 | { | |
50 | return (((SInt32) inInt) << 16); | |
51 | } | |
52 | ||
53 | inline int FixedToInt( Fixed inFixed ) | |
54 | { | |
55 | return (((SInt32) inFixed) >> 16); | |
56 | } | |
57 | #endif | |
58 | ||
8cf73271 SC |
59 | #if wxUSE_GUI |
60 | ||
20b69855 | 61 | #include "wx/dc.h" |
8cf73271 SC |
62 | #include "wx/window.h" |
63 | ||
64 | class wxMacPortStateHelper | |
65 | { | |
66 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) | |
67 | ||
68 | public: | |
69 | wxMacPortStateHelper( GrafPtr newport) ; | |
70 | wxMacPortStateHelper() ; | |
71 | ~wxMacPortStateHelper() ; | |
72 | ||
73 | void Setup( GrafPtr newport ) ; | |
74 | void Clear() ; | |
75 | bool IsCleared() { return m_clip == NULL ; } | |
76 | GrafPtr GetCurrentPort() { return m_currentPort ; } | |
77 | ||
78 | private: | |
79 | GrafPtr m_currentPort ; | |
80 | GrafPtr m_oldPort ; | |
81 | RgnHandle m_clip ; | |
82 | ThemeDrawingState m_drawingState ; | |
83 | short m_textFont ; | |
84 | short m_textSize ; | |
85 | short m_textStyle ; | |
86 | short m_textMode ; | |
87 | } ; | |
88 | ||
4f305456 SC |
89 | class WXDLLEXPORT wxMacPortSaver |
90 | { | |
91 | DECLARE_NO_COPY_CLASS(wxMacPortSaver) | |
92 | ||
93 | public: | |
94 | wxMacPortSaver( GrafPtr port ) | |
95 | { | |
96 | ::GetPort( &m_port ) ; | |
97 | ::SetPort( port ) ; | |
98 | } | |
99 | ~wxMacPortSaver() | |
100 | { | |
101 | ::SetPort( m_port ) ; | |
102 | } | |
103 | private : | |
104 | GrafPtr m_port ; | |
105 | } ; | |
106 | ||
8cf73271 SC |
107 | class WXDLLEXPORT wxMacPortSetter |
108 | { | |
109 | DECLARE_NO_COPY_CLASS(wxMacPortSetter) | |
110 | ||
111 | public: | |
112 | wxMacPortSetter( const wxDC* dc ) ; | |
113 | ~wxMacPortSetter() ; | |
114 | private: | |
115 | wxMacPortStateHelper m_ph ; | |
116 | const wxDC* m_dc ; | |
117 | } ; | |
118 | ||
4f305456 SC |
119 | /* |
120 | Clips to the visible region of a control within the current port | |
121 | */ | |
122 | ||
123 | class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver | |
8cf73271 SC |
124 | { |
125 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
126 | ||
127 | public: | |
128 | wxMacWindowClipper( const wxWindow* win ) ; | |
129 | ~wxMacWindowClipper() ; | |
130 | private: | |
01299d56 | 131 | GrafPtr m_newPort ; |
8cf73271 SC |
132 | RgnHandle m_formerClip ; |
133 | RgnHandle m_newClip ; | |
134 | } ; | |
135 | ||
01299d56 SC |
136 | class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper |
137 | { | |
138 | DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver) | |
139 | ||
140 | public: | |
141 | wxMacWindowStateSaver( const wxWindow* win ) ; | |
142 | ~wxMacWindowStateSaver() ; | |
143 | private: | |
144 | GrafPtr m_newPort ; | |
145 | ThemeDrawingState m_themeDrawingState ; | |
146 | } ; | |
147 | ||
4f305456 | 148 | /* |
8cf73271 SC |
149 | class wxMacDrawingHelper |
150 | { | |
151 | DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) | |
152 | ||
153 | public: | |
154 | wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ; | |
155 | ~wxMacDrawingHelper() ; | |
156 | bool Ok() { return m_ok ; } | |
157 | void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; } | |
158 | void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; } | |
159 | void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; } | |
160 | const Point& GetOrigin() { return m_origin ; } | |
161 | private: | |
162 | Point m_origin ; | |
163 | GrafPtr m_formerPort ; | |
164 | GrafPtr m_currentPort ; | |
165 | PenState m_savedPenState ; | |
166 | bool m_ok ; | |
167 | } ; | |
4f305456 | 168 | */ |
8cf73271 SC |
169 | |
170 | // app.h | |
171 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; | |
172 | ||
173 | #endif // wxUSE_GUI | |
174 | ||
175 | // filefn.h | |
176 | WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; | |
a2b77260 | 177 | WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ; |
8cf73271 SC |
178 | |
179 | // utils.h | |
180 | WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, | |
181 | OSType folderType, | |
182 | Boolean createFolder); | |
183 | ||
4f305456 SC |
184 | template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; } |
185 | template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle ; } | |
186 | template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef ; } | |
187 | template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef ; } | |
188 | template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef ; } | |
189 | template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef ; } | |
190 | template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint ; } | |
191 | template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle ; } | |
192 | template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean ; } | |
193 | #if TARGET_API_MAC_OSX | |
6d4c54a7 | 194 | template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; } |
4f305456 SC |
195 | template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; } |
196 | template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; } | |
197 | template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; } | |
198 | template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; } | |
199 | #endif | |
200 | template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; } | |
201 | template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef ; } | |
202 | /* | |
885fb02f SC |
203 | These are ambiguous |
204 | template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; } | |
205 | template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; } | |
206 | template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; } | |
207 | template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; } | |
208 | */ | |
4f305456 SC |
209 | |
210 | class wxMacCarbonEvent | |
211 | { | |
212 | ||
213 | public : | |
a4848597 SC |
214 | wxMacCarbonEvent() |
215 | { | |
216 | m_eventRef = 0 ; | |
217 | m_release = false ; | |
218 | } | |
219 | ||
6d4c54a7 | 220 | wxMacCarbonEvent( EventRef event , bool release = false ) |
4f305456 SC |
221 | { |
222 | m_eventRef = event ; | |
6d4c54a7 SC |
223 | m_release = release ; |
224 | } | |
885fb02f | 225 | |
6d4c54a7 SC |
226 | wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) |
227 | { | |
228 | m_eventRef = NULL ; | |
229 | verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ; | |
230 | m_release = true ; | |
231 | } | |
885fb02f | 232 | |
6d4c54a7 SC |
233 | ~wxMacCarbonEvent() |
234 | { | |
235 | if ( m_release ) | |
236 | ReleaseEvent( m_eventRef ) ; | |
4f305456 SC |
237 | } |
238 | ||
a4848597 SC |
239 | OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) |
240 | { | |
241 | verify( (m_eventRef == NULL) || m_release ) ; | |
242 | if ( m_eventRef && m_release ) | |
243 | { | |
244 | ReleaseEvent( m_eventRef ) ; | |
245 | m_release = false ; | |
246 | m_eventRef = NULL ; | |
247 | ||
248 | } | |
249 | OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ; | |
250 | if ( err == noErr ) | |
251 | m_release = true ; | |
252 | return err ; | |
253 | } | |
885fb02f | 254 | |
4f305456 SC |
255 | OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ; |
256 | ||
257 | template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) | |
258 | { | |
259 | return GetParameter( inName, type , sizeof( T ) , data ) ; | |
260 | } | |
261 | template <typename T> OSStatus GetParameter( EventParamName inName, T *data ) | |
262 | { | |
263 | return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ; | |
264 | } | |
265 | ||
266 | template <typename T> T GetParameter( EventParamName inName ) | |
267 | { | |
268 | T value ; | |
269 | verify_noerr( GetParameter<T>( inName, &value ) ) ; | |
270 | return value ; | |
271 | } | |
272 | template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType ) | |
273 | { | |
274 | T value ; | |
275 | verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ; | |
276 | return value ; | |
277 | } | |
885fb02f | 278 | |
6d4c54a7 SC |
279 | OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ; |
280 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data ) | |
4f305456 | 281 | { |
2aefa0ef SC |
282 | return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ; |
283 | } | |
6d4c54a7 | 284 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data ) |
2aefa0ef SC |
285 | { |
286 | return SetParameter<T>( inName, inDesiredType , &data ) ; | |
4f305456 | 287 | } |
6d4c54a7 | 288 | template <typename T> OSStatus SetParameter( EventParamName inName, const T *data ) |
4f305456 SC |
289 | { |
290 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ; | |
291 | } | |
6d4c54a7 | 292 | template <typename T> OSStatus SetParameter( EventParamName inName, const T& data ) |
2aefa0ef SC |
293 | { |
294 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ; | |
295 | } | |
86d8b744 SC |
296 | UInt32 GetClass() |
297 | { | |
298 | return ::GetEventClass( m_eventRef ) ; | |
299 | } | |
41b53169 | 300 | UInt32 GetKind() |
4f305456 SC |
301 | { |
302 | return ::GetEventKind( m_eventRef ) ; | |
303 | } | |
304 | EventTime GetTime() | |
305 | { | |
306 | return ::GetEventTime( m_eventRef ) ; | |
307 | } | |
308 | UInt32 GetTicks() | |
309 | { | |
310 | return EventTimeToTicks( GetTime() ) ; | |
311 | } | |
a4848597 SC |
312 | OSStatus SetTime( EventTime inWhen = 0 /*now*/ ) |
313 | { | |
314 | return ::SetEventTime( m_eventRef , inWhen ? inWhen : GetCurrentEventTime() ) ; | |
315 | } | |
316 | operator EventRef () { return m_eventRef; } | |
885fb02f | 317 | |
a4848597 | 318 | bool IsValid() { return m_eventRef != 0 ; } |
4f305456 SC |
319 | protected : |
320 | EventRef m_eventRef ; | |
6d4c54a7 | 321 | bool m_release ; |
4f305456 SC |
322 | } ; |
323 | ||
3feeb1e1 SC |
324 | // |
325 | // helper class for allocating and deallocating Universal Proc Ptrs | |
326 | // | |
327 | ||
328 | template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP | |
329 | { | |
330 | public : | |
331 | wxMacUPP( procType proc ) | |
332 | { | |
333 | m_upp = NULL ; | |
334 | m_upp = (*newUPP)( NULL ) ; | |
335 | } | |
336 | ~wxMacUPP() | |
337 | { | |
338 | if ( m_upp ) | |
339 | disposeUPP( m_upp ) ; | |
340 | } | |
341 | operator uppType() { return m_upp ; } | |
342 | private : | |
343 | uppType m_upp ; | |
344 | } ; | |
345 | ||
346 | typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ; | |
347 | ||
885fb02f | 348 | #if wxUSE_GUI |
20b69855 | 349 | /* |
885fb02f SC |
350 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; |
351 | void wxMacDestroyGWorld( GWorldPtr gw ) ; | |
352 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; | |
353 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; | |
354 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; | |
355 | CTabHandle wxMacCreateColorTable( int numColors ) ; | |
20b69855 | 356 | */ |
71cc158e | 357 | PicHandle wxMacCreatePicHandle( const wxBitmap &bmp ) ; |
20b69855 | 358 | IconRef wxMacCreateIconRef(const wxBitmap& bmp) ; |
885fb02f | 359 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; |
20b69855 | 360 | void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ; |
885fb02f SC |
361 | |
362 | #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) | |
363 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) | |
364 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
20b69855 | 365 | #define MAC_WXHICON(a) (IconRef(a)) |
885fb02f SC |
366 | #define MAC_WXHCURSOR(a) (CursHandle(a)) |
367 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
368 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
369 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
370 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
371 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
372 | ||
373 | struct wxOpaqueWindowRef | |
374 | { | |
375 | wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; } | |
376 | operator WindowRef() { return m_data ; } | |
377 | private : | |
378 | WindowRef m_data ; | |
379 | } ; | |
380 | ||
381 | wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ; | |
382 | wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ; | |
383 | wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ; | |
384 | ||
385 | extern wxWindow* g_MacLastWindow ; | |
386 | pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; | |
387 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ; | |
388 | ||
86d8b744 SC |
389 | class wxMacControl |
390 | { | |
391 | public : | |
6d4c54a7 SC |
392 | wxMacControl() |
393 | { | |
394 | m_controlRef = NULL ; | |
395 | } | |
396 | ||
86d8b744 SC |
397 | wxMacControl( ControlRef control ) |
398 | { | |
399 | m_controlRef = control ; | |
400 | } | |
401 | wxMacControl( WXWidget control ) | |
402 | { | |
403 | m_controlRef = (ControlRef) control ; | |
404 | } | |
0fc3bc3b SC |
405 | virtual ~wxMacControl() |
406 | { | |
407 | } | |
6d4c54a7 | 408 | |
5ca0d812 SC |
409 | virtual void Dispose() ; |
410 | ||
411 | bool Ok() const { return GetControlRef() != NULL ; } | |
412 | ||
413 | virtual ControlRef * GetControlRefAddr() { return &m_controlRef; } | |
414 | virtual ControlRef GetControlRef() const { return m_controlRef ; } | |
415 | ||
416 | virtual void SetReference( SInt32 data ) ; | |
417 | /* | |
2837271a SC |
418 | void operator= (ControlRef c) { m_controlRef = c ; } |
419 | operator ControlRef () { return m_controlRef; } | |
420 | operator ControlRef * () { return &m_controlRef; } | |
5ca0d812 | 421 | */ |
2837271a SC |
422 | // accessing data and values |
423 | ||
424 | virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ; | |
0fc3bc3b SC |
425 | virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ; |
426 | virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ; | |
2837271a SC |
427 | virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ; |
428 | virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ; | |
429 | ||
0fc3bc3b | 430 | virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ; |
2837271a | 431 | |
0fc3bc3b SC |
432 | virtual SInt32 GetValue() const ; |
433 | virtual SInt32 GetMaximum() const ; | |
434 | virtual SInt32 GetMinimum() const ; | |
2837271a | 435 | |
0fc3bc3b SC |
436 | virtual void SetValue( SInt32 v ) ; |
437 | virtual void SetMinimum( SInt32 v ) ; | |
438 | virtual void SetMaximum( SInt32 v ) ; | |
2837271a | 439 | |
0fc3bc3b SC |
440 | virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ; |
441 | virtual void SetRange( SInt32 minimum , SInt32 maximum ) ; | |
2837271a | 442 | |
5ca0d812 SC |
443 | virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; |
444 | virtual bool HasFocus() const ; | |
445 | virtual bool NeedsFocusRect() const ; | |
446 | ||
2837271a SC |
447 | // templated helpers |
448 | ||
0fc3bc3b | 449 | Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 SC |
450 | { |
451 | Size sz ; | |
452 | verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ; | |
453 | return sz ; | |
454 | } | |
6d4c54a7 | 455 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data ) |
86d8b744 SC |
456 | { |
457 | return SetData( inPartCode , inTag , sizeof( T ) , data ) ; | |
458 | } | |
6d4c54a7 | 459 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data ) |
86d8b744 SC |
460 | { |
461 | return SetData( inPartCode , inTag , sizeof( T ) , &data ) ; | |
462 | } | |
0fc3bc3b | 463 | template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const |
86d8b744 SC |
464 | { |
465 | Size dummy ; | |
466 | return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ; | |
467 | } | |
0fc3bc3b | 468 | template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 SC |
469 | { |
470 | T value ; | |
471 | verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ; | |
472 | return value ; | |
473 | } | |
2837271a | 474 | |
6d4c54a7 | 475 | // Flash the control for the specified amount of time |
0fc3bc3b SC |
476 | virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ; |
477 | virtual void VisibilityChanged( bool shown ) ; | |
478 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ; | |
7ea087b7 | 479 | virtual void SetBackground( const wxBrush &brush ) ; |
5ca0d812 SC |
480 | virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ; |
481 | void SetActionProc( ControlActionUPP actionProc ) ; | |
482 | void SetViewSize( SInt32 viewSize ) ; | |
483 | SInt32 GetViewSize() const ; | |
484 | ||
485 | virtual bool IsVisible() const ; | |
486 | virtual void SetVisibility( bool visible , bool redraw ) ; | |
487 | virtual bool IsEnabled() const ; | |
488 | virtual bool IsActive() const ; | |
489 | virtual void Enable( bool enable ) ; | |
490 | ||
491 | // invalidates this control and all children | |
492 | virtual void InvalidateWithChildren() ; | |
493 | virtual void SetDrawingEnabled( bool enable ) ; | |
494 | virtual bool GetNeedsDisplay() const ; | |
495 | virtual void SetNeedsDisplay( bool needsDisplay , RgnHandle where = NULL ) ; | |
496 | ||
497 | virtual void ScrollRect( const wxRect &rect , int dx , int dy ) ; | |
498 | ||
499 | virtual void GetRect( Rect *r ) ; | |
500 | virtual void SetRect( Rect *r ) ; | |
501 | virtual void GetRectInWindowCoords( Rect *r ) ; | |
502 | virtual void GetBestRect( Rect *r ) ; | |
503 | virtual void SetTitle( const wxString &title ) ; | |
504 | // converts from Toplevel-Content relative to local | |
505 | static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ; | |
506 | ||
507 | virtual void GetFeatures( UInt32 *features ) ; | |
508 | virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ; | |
509 | virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ; | |
510 | // to be moved into a databrowser subclass | |
511 | ||
512 | virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ; | |
513 | virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc, | |
514 | DataBrowserTableViewColumnIndex position ) ; | |
515 | virtual OSStatus AutoSizeListViewColumns() ; | |
516 | virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ; | |
517 | virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ; | |
518 | virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ; | |
519 | virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ; | |
520 | virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
521 | const DataBrowserItemID* items, | |
522 | DataBrowserPropertyID preSortProperty, | |
523 | DataBrowserPropertyID propertyID ) ; | |
524 | virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems, | |
525 | const DataBrowserItemID* items, | |
526 | DataBrowserPropertyID preSortProperty ) ; | |
527 | virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
528 | const DataBrowserItemID* items, | |
529 | DataBrowserPropertyID preSortProperty ) ; | |
530 | virtual OSStatus RevealItem( DataBrowserItemID item, | |
531 | DataBrowserPropertyID propertyID, | |
532 | DataBrowserRevealOptions options ) ; | |
fe3dc505 | 533 | virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ; |
5ca0d812 SC |
534 | virtual bool IsItemSelected( DataBrowserItemID item ) ; |
535 | virtual OSStatus SetSelectedItems(UInt32 numItems, | |
536 | const DataBrowserItemID * items, | |
537 | DataBrowserSetOption operation ) ; | |
538 | ||
539 | // to be moved into a tab control class | |
540 | ||
541 | virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ; | |
86d8b744 | 542 | protected : |
0fc3bc3b SC |
543 | ControlRef m_controlRef ; |
544 | wxFont m_font ; | |
545 | long m_windowStyle ; | |
86d8b744 SC |
546 | } ; |
547 | ||
20b69855 SC |
548 | #if wxMAC_USE_CORE_GRAPHICS |
549 | ||
550 | class WXDLLEXPORT wxMacCGPath : public wxGraphicPath | |
551 | { | |
552 | DECLARE_NO_COPY_CLASS(wxMacCGPath) | |
553 | public : | |
554 | wxMacCGPath() ; | |
555 | ~wxMacCGPath() ; | |
556 | ||
557 | // Starts a new subpath at | |
558 | void MoveToPoint( wxCoord x1 , wxCoord y1 ) ; | |
559 | void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ; | |
560 | void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ; | |
561 | void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ; | |
562 | ||
563 | // closes the current subpath | |
564 | void CloseSubpath() ; | |
565 | ||
566 | CGPathRef GetPath() const ; | |
567 | private : | |
568 | CGMutablePathRef m_path ; | |
569 | } ; | |
570 | ||
571 | class WXDLLEXPORT wxMacCGContext : public wxGraphicContext | |
572 | { | |
573 | DECLARE_NO_COPY_CLASS(wxMacCGContext) | |
574 | ||
575 | public: | |
576 | wxMacCGContext( CGrafPtr port ) ; | |
577 | wxMacCGContext( CGContextRef cgcontext ) ; | |
578 | wxMacCGContext() ; | |
579 | ~wxMacCGContext() ; | |
580 | ||
581 | virtual void Clip( const wxRegion ®ion ) ; | |
582 | virtual void StrokePath( const wxGraphicPath *p ) ; | |
583 | virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ; | |
584 | virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ; | |
585 | ||
586 | virtual wxGraphicPath* CreatePath() ; | |
587 | virtual void SetPen( const wxPen &pen ) ; | |
588 | virtual void SetBrush( const wxBrush &brush ) ; | |
589 | CGContextRef GetNativeContext() ; | |
590 | void SetNativeContext( CGContextRef cg ) ; | |
591 | CGPathDrawingMode GetDrawingMode() const { return m_mode ; } | |
592 | private: | |
593 | CGContextRef m_cgContext ; | |
594 | CGrafPtr m_qdPort ; | |
595 | CGPathDrawingMode m_mode ; | |
596 | wxPen m_pen ; | |
597 | wxBrush m_brush ; | |
598 | } ; | |
599 | ||
600 | CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ; | |
71cc158e | 601 | void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ; |
20b69855 SC |
602 | |
603 | #endif // wxMAC_USE_CORE_GRAPHICS | |
604 | ||
605 | class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData | |
606 | { | |
607 | DECLARE_NO_COPY_CLASS(wxBitmapRefData) | |
608 | ||
609 | friend class WXDLLEXPORT wxIcon; | |
610 | friend class WXDLLEXPORT wxCursor; | |
611 | public: | |
612 | wxBitmapRefData(int width , int height , int depth); | |
613 | wxBitmapRefData(); | |
614 | ~wxBitmapRefData(); | |
615 | ||
616 | void Free() ; | |
617 | bool Ok() const { return m_ok ; } | |
618 | void SetOk( bool isOk) { m_ok = isOk ; } | |
619 | ||
620 | void SetWidth( int width ) { m_width = width ; } | |
621 | void SetHeight( int height ) { m_height = height ; } | |
622 | void SetDepth( int depth ) { m_depth = depth ; } | |
623 | ||
624 | int GetWidth() const { return m_width ; } | |
625 | int GetHeight() const { return m_height ; } | |
626 | int GetDepth() const { return m_depth ; } | |
627 | ||
628 | void *GetRawAccess() const ; | |
629 | void *BeginRawAccess() ; | |
630 | void EndRawAccess() ; | |
631 | ||
632 | bool HasAlpha() const { return m_hasAlpha ; } | |
633 | void UseAlpha( bool useAlpha ) ; | |
634 | ||
635 | public: | |
636 | #if wxUSE_PALETTE | |
637 | wxPalette m_bitmapPalette; | |
638 | #endif // wxUSE_PALETTE | |
639 | ||
640 | wxMask * m_bitmapMask; // Optional mask | |
641 | #if wxMAC_USE_CORE_GRAPHICS | |
642 | CGImageRef CGImageCreate() const ; | |
71cc158e | 643 | #endif |
20b69855 SC |
644 | GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ; |
645 | void UpdateAlphaMask() const ; | |
71cc158e | 646 | |
20b69855 SC |
647 | private : |
648 | bool Create(int width , int height , int depth) ; | |
649 | void Init() ; | |
650 | ||
651 | int m_width; | |
652 | int m_height; | |
653 | int m_bytesPerRow ; | |
654 | int m_depth; | |
655 | bool m_hasAlpha; | |
656 | wxMemoryBuffer m_memBuf ; | |
657 | int m_rawAccessCount ; | |
658 | bool m_ok; | |
659 | #if wxMAC_USE_CORE_GRAPHICS | |
660 | mutable CGImageRef m_cgImageRef ; | |
71cc158e | 661 | #endif |
20b69855 SC |
662 | GWorldPtr m_hBitmap; |
663 | GWorldPtr m_hMaskBitmap ; | |
664 | wxMemoryBuffer m_maskMemBuf ; | |
665 | int m_maskBytesPerRow ; | |
20b69855 SC |
666 | }; |
667 | ||
668 | #define M_BITMAPDATA ((wxBitmapRefData *)m_refData) | |
669 | ||
670 | class WXDLLEXPORT wxIconRefData : public wxGDIRefData | |
671 | { | |
672 | public: | |
673 | wxIconRefData() ; | |
674 | wxIconRefData( WXHICON ) ; | |
675 | virtual ~wxIconRefData() { Free(); } | |
676 | ||
677 | void Init() ; | |
678 | virtual void Free(); | |
679 | WXHICON GetHICON() const { return (WXHICON) m_iconRef ; } | |
680 | private : | |
681 | IconRef m_iconRef ; | |
682 | }; | |
683 | ||
8cf73271 SC |
684 | #endif // wxUSE_GUI |
685 | ||
686 | //--------------------------------------------------------------------------- | |
687 | // wxMac string conversions | |
688 | //--------------------------------------------------------------------------- | |
689 | ||
690 | void wxMacSetupConverters() ; | |
691 | void wxMacCleanupConverters() ; | |
692 | ||
693 | void wxMacStringToPascal( const wxString&from , StringPtr to ) ; | |
694 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; | |
695 | ||
1a42f89c SC |
696 | // toplevel.cpp |
697 | ||
698 | ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ; | |
8cf73271 | 699 | |
a2b77260 SC |
700 | // filefn.cpp |
701 | ||
702 | wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ; | |
703 | OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ; | |
704 | wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ; | |
aa0cc8a1 | 705 | |
8cf73271 SC |
706 | #endif |
707 | // _WX_PRIVATE_H_ |