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