]>
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> |
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 SC |
69 | |
70 | class wxMacPortStateHelper | |
71 | { | |
72 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) | |
73 | ||
74 | public: | |
75 | wxMacPortStateHelper( GrafPtr newport) ; | |
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) | |
98 | ||
99 | public: | |
100 | wxMacPortSaver( GrafPtr port ) | |
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) | |
116 | ||
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 | */ | |
128 | ||
129 | class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver | |
8cf73271 SC |
130 | { |
131 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
132 | ||
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) | |
145 | ||
146 | public: | |
147 | wxMacWindowStateSaver( const wxWindow* win ) ; | |
148 | ~wxMacWindowStateSaver() ; | |
149 | private: | |
150 | GrafPtr m_newPort ; | |
151 | ThemeDrawingState m_themeDrawingState ; | |
152 | } ; | |
153 | ||
ddb08e02 SC |
154 | #if wxMAC_USE_CORE_GRAPHICS |
155 | class WXDLLEXPORT wxMacCGContextStateSaver | |
156 | { | |
157 | DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver) | |
158 | ||
159 | public: | |
160 | wxMacCGContextStateSaver( CGContextRef cg ) | |
161 | { | |
162 | m_cg = cg ; | |
163 | CGContextSaveGState( cg ) ; | |
164 | } | |
165 | ~wxMacCGContextStateSaver() | |
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) | |
178 | ||
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 | { | |
238 | ||
239 | public : | |
a4848597 SC |
240 | wxMacCarbonEvent() |
241 | { | |
242 | m_eventRef = 0 ; | |
243 | m_release = false ; | |
244 | } | |
245 | ||
6d4c54a7 | 246 | wxMacCarbonEvent( EventRef event , bool release = false ) |
4f305456 SC |
247 | { |
248 | m_eventRef = event ; | |
6d4c54a7 SC |
249 | m_release = release ; |
250 | } | |
885fb02f | 251 | |
6d4c54a7 SC |
252 | wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) |
253 | { | |
254 | m_eventRef = NULL ; | |
255 | verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ; | |
256 | m_release = true ; | |
257 | } | |
885fb02f | 258 | |
6d4c54a7 SC |
259 | ~wxMacCarbonEvent() |
260 | { | |
261 | if ( m_release ) | |
262 | ReleaseEvent( m_eventRef ) ; | |
4f305456 SC |
263 | } |
264 | ||
a4848597 SC |
265 | OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) |
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 ; | |
273 | ||
274 | } | |
275 | OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ; | |
276 | if ( err == noErr ) | |
277 | m_release = true ; | |
278 | return err ; | |
279 | } | |
885fb02f | 280 | |
4f305456 SC |
281 | OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ; |
282 | ||
283 | template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) | |
284 | { | |
285 | return GetParameter( inName, type , sizeof( T ) , data ) ; | |
286 | } | |
287 | template <typename T> OSStatus GetParameter( EventParamName inName, T *data ) | |
288 | { | |
289 | return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ; | |
290 | } | |
291 | ||
292 | template <typename T> T GetParameter( EventParamName inName ) | |
293 | { | |
294 | T value ; | |
295 | verify_noerr( GetParameter<T>( inName, &value ) ) ; | |
296 | return value ; | |
297 | } | |
298 | template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType ) | |
299 | { | |
300 | T value ; | |
301 | verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ; | |
302 | return value ; | |
303 | } | |
885fb02f | 304 | |
6d4c54a7 SC |
305 | OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ; |
306 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data ) | |
4f305456 | 307 | { |
2aefa0ef SC |
308 | return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ; |
309 | } | |
6d4c54a7 | 310 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data ) |
2aefa0ef SC |
311 | { |
312 | return SetParameter<T>( inName, inDesiredType , &data ) ; | |
4f305456 | 313 | } |
6d4c54a7 | 314 | template <typename T> OSStatus SetParameter( EventParamName inName, const T *data ) |
4f305456 SC |
315 | { |
316 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ; | |
317 | } | |
6d4c54a7 | 318 | template <typename T> OSStatus SetParameter( EventParamName inName, const T& data ) |
2aefa0ef SC |
319 | { |
320 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ; | |
321 | } | |
86d8b744 SC |
322 | UInt32 GetClass() |
323 | { | |
324 | return ::GetEventClass( m_eventRef ) ; | |
325 | } | |
41b53169 | 326 | UInt32 GetKind() |
4f305456 SC |
327 | { |
328 | return ::GetEventKind( m_eventRef ) ; | |
329 | } | |
330 | EventTime GetTime() | |
331 | { | |
332 | return ::GetEventTime( m_eventRef ) ; | |
333 | } | |
334 | UInt32 GetTicks() | |
335 | { | |
336 | return EventTimeToTicks( GetTime() ) ; | |
337 | } | |
a4848597 SC |
338 | OSStatus SetTime( EventTime inWhen = 0 /*now*/ ) |
339 | { | |
340 | return ::SetEventTime( m_eventRef , inWhen ? inWhen : GetCurrentEventTime() ) ; | |
341 | } | |
342 | operator EventRef () { return m_eventRef; } | |
885fb02f | 343 | |
a4848597 | 344 | bool IsValid() { return m_eventRef != 0 ; } |
4f305456 SC |
345 | protected : |
346 | EventRef m_eventRef ; | |
6d4c54a7 | 347 | bool m_release ; |
4f305456 SC |
348 | } ; |
349 | ||
3feeb1e1 SC |
350 | // |
351 | // helper class for allocating and deallocating Universal Proc Ptrs | |
352 | // | |
353 | ||
354 | template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP | |
355 | { | |
356 | public : | |
357 | wxMacUPP( procType proc ) | |
358 | { | |
359 | m_upp = NULL ; | |
360 | m_upp = (*newUPP)( NULL ) ; | |
361 | } | |
362 | ~wxMacUPP() | |
363 | { | |
364 | if ( m_upp ) | |
365 | disposeUPP( m_upp ) ; | |
366 | } | |
367 | operator uppType() { return m_upp ; } | |
368 | private : | |
369 | uppType m_upp ; | |
370 | } ; | |
371 | ||
372 | typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ; | |
373 | ||
885fb02f | 374 | #if wxUSE_GUI |
20b69855 | 375 | /* |
885fb02f SC |
376 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; |
377 | void wxMacDestroyGWorld( GWorldPtr gw ) ; | |
378 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; | |
379 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; | |
380 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; | |
381 | CTabHandle wxMacCreateColorTable( int numColors ) ; | |
20b69855 | 382 | */ |
885fb02f | 383 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; |
20b69855 | 384 | void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ; |
885fb02f SC |
385 | |
386 | #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) | |
387 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) | |
388 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
20b69855 | 389 | #define MAC_WXHICON(a) (IconRef(a)) |
885fb02f SC |
390 | #define MAC_WXHCURSOR(a) (CursHandle(a)) |
391 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
392 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
393 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
394 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
395 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
396 | ||
397 | struct wxOpaqueWindowRef | |
398 | { | |
399 | wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; } | |
400 | operator WindowRef() { return m_data ; } | |
401 | private : | |
402 | WindowRef m_data ; | |
403 | } ; | |
404 | ||
285b5ce0 SC |
405 | void wxMacRectToNative( const wxRect *wx , Rect *n ) ; |
406 | void wxMacNativeToRect( const Rect *n , wxRect* wx ) ; | |
407 | void wxMacPointToNative( const wxPoint* wx , Point *n ) ; | |
408 | void wxMacNativeToPoint( const Point *n , wxPoint* wx ) ; | |
409 | ||
885fb02f SC |
410 | wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ; |
411 | wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ; | |
412 | wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ; | |
413 | ||
414 | extern wxWindow* g_MacLastWindow ; | |
415 | pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; | |
416 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ; | |
417 | ||
285b5ce0 SC |
418 | ControlActionUPP GetwxMacLiveScrollbarActionProc() ; |
419 | ||
86d8b744 SC |
420 | class wxMacControl |
421 | { | |
422 | public : | |
285b5ce0 | 423 | wxMacControl( wxWindow* peer , bool isRootControl = false ) ; |
9b89f11a SC |
424 | wxMacControl( wxWindow* peer , ControlRef control ) ; |
425 | wxMacControl( wxWindow* peer , WXWidget control ) ; | |
426 | virtual ~wxMacControl() ; | |
6d4c54a7 | 427 | |
9b89f11a | 428 | void Init() ; |
6d4c54a7 | 429 | |
5ca0d812 SC |
430 | virtual void Dispose() ; |
431 | ||
432 | bool Ok() const { return GetControlRef() != NULL ; } | |
433 | ||
434 | virtual ControlRef * GetControlRefAddr() { return &m_controlRef; } | |
435 | virtual ControlRef GetControlRef() const { return m_controlRef ; } | |
436 | ||
437 | virtual void SetReference( SInt32 data ) ; | |
438 | /* | |
2837271a SC |
439 | void operator= (ControlRef c) { m_controlRef = c ; } |
440 | operator ControlRef () { return m_controlRef; } | |
441 | operator ControlRef * () { return &m_controlRef; } | |
5ca0d812 | 442 | */ |
2837271a SC |
443 | // accessing data and values |
444 | ||
445 | virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ; | |
0fc3bc3b SC |
446 | virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ; |
447 | virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ; | |
2837271a SC |
448 | virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ; |
449 | virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ; | |
450 | ||
0fc3bc3b | 451 | virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ; |
2837271a | 452 | |
0fc3bc3b SC |
453 | virtual SInt32 GetValue() const ; |
454 | virtual SInt32 GetMaximum() const ; | |
455 | virtual SInt32 GetMinimum() const ; | |
2837271a | 456 | |
0fc3bc3b SC |
457 | virtual void SetValue( SInt32 v ) ; |
458 | virtual void SetMinimum( SInt32 v ) ; | |
459 | virtual void SetMaximum( SInt32 v ) ; | |
2837271a | 460 | |
0fc3bc3b SC |
461 | virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ; |
462 | virtual void SetRange( SInt32 minimum , SInt32 maximum ) ; | |
2837271a | 463 | |
5ca0d812 SC |
464 | virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; |
465 | virtual bool HasFocus() const ; | |
466 | virtual bool NeedsFocusRect() const ; | |
9b89f11a | 467 | virtual void SetNeedsFocusRect( bool needs ) ; |
5ca0d812 | 468 | |
2837271a SC |
469 | // templated helpers |
470 | ||
0fc3bc3b | 471 | Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 SC |
472 | { |
473 | Size sz ; | |
474 | verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ; | |
475 | return sz ; | |
476 | } | |
6d4c54a7 | 477 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data ) |
86d8b744 SC |
478 | { |
479 | return SetData( inPartCode , inTag , sizeof( T ) , data ) ; | |
480 | } | |
6d4c54a7 | 481 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data ) |
86d8b744 SC |
482 | { |
483 | return SetData( inPartCode , inTag , sizeof( T ) , &data ) ; | |
484 | } | |
0fc3bc3b | 485 | template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const |
86d8b744 SC |
486 | { |
487 | Size dummy ; | |
488 | return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ; | |
489 | } | |
0fc3bc3b | 490 | template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 SC |
491 | { |
492 | T value ; | |
493 | verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ; | |
494 | return value ; | |
495 | } | |
2837271a | 496 | |
6d4c54a7 | 497 | // Flash the control for the specified amount of time |
0fc3bc3b | 498 | virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ; |
89a66f11 | 499 | |
0fc3bc3b | 500 | virtual void VisibilityChanged( bool shown ) ; |
89a66f11 SC |
501 | virtual void SuperChangedPosition() ; |
502 | ||
503 | ||
0fc3bc3b | 504 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ; |
7ea087b7 | 505 | virtual void SetBackground( const wxBrush &brush ) ; |
5ca0d812 SC |
506 | virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ; |
507 | void SetActionProc( ControlActionUPP actionProc ) ; | |
508 | void SetViewSize( SInt32 viewSize ) ; | |
509 | SInt32 GetViewSize() const ; | |
510 | ||
511 | virtual bool IsVisible() const ; | |
512 | virtual void SetVisibility( bool visible , bool redraw ) ; | |
513 | virtual bool IsEnabled() const ; | |
514 | virtual bool IsActive() const ; | |
515 | virtual void Enable( bool enable ) ; | |
516 | ||
517 | // invalidates this control and all children | |
518 | virtual void InvalidateWithChildren() ; | |
519 | virtual void SetDrawingEnabled( bool enable ) ; | |
b905d6cc | 520 | #ifdef __WXMAC_OSX__ |
5ca0d812 | 521 | virtual bool GetNeedsDisplay() const ; |
b905d6cc | 522 | #endif |
285b5ce0 SC |
523 | // where is in native window relative coordinates |
524 | virtual void SetNeedsDisplay( RgnHandle where ) ; | |
525 | // where is in native window relative coordinates | |
526 | virtual void SetNeedsDisplay( Rect* where = NULL ) ; | |
527 | ||
92346151 SC |
528 | // if rect = NULL, entire view |
529 | virtual void ScrollRect( wxRect *rect , int dx , int dy ) ; | |
5ca0d812 | 530 | |
285b5ce0 | 531 | // in native parent window relative coordinates |
5ca0d812 | 532 | virtual void GetRect( Rect *r ) ; |
285b5ce0 SC |
533 | |
534 | // in native parent window relative coordinates | |
5ca0d812 | 535 | virtual void SetRect( Rect *r ) ; |
285b5ce0 | 536 | |
5ca0d812 SC |
537 | virtual void GetRectInWindowCoords( Rect *r ) ; |
538 | virtual void GetBestRect( Rect *r ) ; | |
539 | virtual void SetTitle( const wxString &title ) ; | |
540 | // converts from Toplevel-Content relative to local | |
541 | static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ; | |
542 | ||
543 | virtual void GetFeatures( UInt32 *features ) ; | |
544 | virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ; | |
545 | virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ; | |
546 | // to be moved into a databrowser subclass | |
547 | ||
548 | virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ; | |
549 | virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc, | |
550 | DataBrowserTableViewColumnIndex position ) ; | |
551 | virtual OSStatus AutoSizeListViewColumns() ; | |
552 | virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ; | |
553 | virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ; | |
554 | virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ; | |
555 | virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ; | |
556 | virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
557 | const DataBrowserItemID* items, | |
558 | DataBrowserPropertyID preSortProperty, | |
559 | DataBrowserPropertyID propertyID ) ; | |
560 | virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems, | |
561 | const DataBrowserItemID* items, | |
562 | DataBrowserPropertyID preSortProperty ) ; | |
563 | virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
564 | const DataBrowserItemID* items, | |
565 | DataBrowserPropertyID preSortProperty ) ; | |
566 | virtual OSStatus RevealItem( DataBrowserItemID item, | |
567 | DataBrowserPropertyID propertyID, | |
568 | DataBrowserRevealOptions options ) ; | |
fe3dc505 | 569 | virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ; |
5ca0d812 SC |
570 | virtual bool IsItemSelected( DataBrowserItemID item ) ; |
571 | virtual OSStatus SetSelectedItems(UInt32 numItems, | |
572 | const DataBrowserItemID * items, | |
573 | DataBrowserSetOption operation ) ; | |
574 | ||
575 | // to be moved into a tab control class | |
576 | ||
577 | virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ; | |
9b89f11a | 578 | bool IsCompositing() { return m_isCompositing ; } |
285b5ce0 | 579 | bool IsRootControl() { return m_isRootControl ; } |
86d8b744 | 580 | protected : |
0fc3bc3b SC |
581 | ControlRef m_controlRef ; |
582 | wxFont m_font ; | |
583 | long m_windowStyle ; | |
b905d6cc | 584 | wxWindow* m_peer ; |
9b89f11a SC |
585 | bool m_needsFocusRect ; |
586 | bool m_isCompositing ; | |
285b5ce0 | 587 | bool m_isRootControl ; |
86d8b744 SC |
588 | } ; |
589 | ||
20b69855 SC |
590 | #if wxMAC_USE_CORE_GRAPHICS |
591 | ||
592 | class WXDLLEXPORT wxMacCGPath : public wxGraphicPath | |
593 | { | |
594 | DECLARE_NO_COPY_CLASS(wxMacCGPath) | |
595 | public : | |
596 | wxMacCGPath() ; | |
597 | ~wxMacCGPath() ; | |
598 | ||
599 | // Starts a new subpath at | |
600 | void MoveToPoint( wxCoord x1 , wxCoord y1 ) ; | |
601 | void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ; | |
fea3713c | 602 | void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ) ; |
20b69855 SC |
603 | void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ; |
604 | void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ; | |
605 | ||
606 | // closes the current subpath | |
607 | void CloseSubpath() ; | |
608 | ||
609 | CGPathRef GetPath() const ; | |
610 | private : | |
611 | CGMutablePathRef m_path ; | |
612 | } ; | |
613 | ||
614 | class WXDLLEXPORT wxMacCGContext : public wxGraphicContext | |
615 | { | |
616 | DECLARE_NO_COPY_CLASS(wxMacCGContext) | |
617 | ||
618 | public: | |
619 | wxMacCGContext( CGrafPtr port ) ; | |
620 | wxMacCGContext( CGContextRef cgcontext ) ; | |
621 | wxMacCGContext() ; | |
622 | ~wxMacCGContext() ; | |
623 | ||
624 | virtual void Clip( const wxRegion ®ion ) ; | |
625 | virtual void StrokePath( const wxGraphicPath *p ) ; | |
626 | virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ; | |
627 | virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ; | |
628 | ||
629 | virtual wxGraphicPath* CreatePath() ; | |
630 | virtual void SetPen( const wxPen &pen ) ; | |
631 | virtual void SetBrush( const wxBrush &brush ) ; | |
632 | CGContextRef GetNativeContext() ; | |
633 | void SetNativeContext( CGContextRef cg ) ; | |
634 | CGPathDrawingMode GetDrawingMode() const { return m_mode ; } | |
635 | private: | |
636 | CGContextRef m_cgContext ; | |
637 | CGrafPtr m_qdPort ; | |
638 | CGPathDrawingMode m_mode ; | |
639 | wxPen m_pen ; | |
640 | wxBrush m_brush ; | |
641 | } ; | |
642 | ||
30e77b5c SC |
643 | #endif // wxMAC_USE_CORE_GRAPHICS |
644 | ||
645 | #ifdef __WXMAC_OSX__ | |
646 | ||
20b69855 | 647 | CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ; |
71cc158e | 648 | void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ; |
20b69855 | 649 | |
30e77b5c | 650 | #endif |
20b69855 SC |
651 | |
652 | class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData | |
653 | { | |
654 | DECLARE_NO_COPY_CLASS(wxBitmapRefData) | |
655 | ||
656 | friend class WXDLLEXPORT wxIcon; | |
657 | friend class WXDLLEXPORT wxCursor; | |
658 | public: | |
659 | wxBitmapRefData(int width , int height , int depth); | |
660 | wxBitmapRefData(); | |
661 | ~wxBitmapRefData(); | |
662 | ||
663 | void Free() ; | |
664 | bool Ok() const { return m_ok ; } | |
665 | void SetOk( bool isOk) { m_ok = isOk ; } | |
666 | ||
667 | void SetWidth( int width ) { m_width = width ; } | |
668 | void SetHeight( int height ) { m_height = height ; } | |
669 | void SetDepth( int depth ) { m_depth = depth ; } | |
670 | ||
671 | int GetWidth() const { return m_width ; } | |
672 | int GetHeight() const { return m_height ; } | |
673 | int GetDepth() const { return m_depth ; } | |
674 | ||
675 | void *GetRawAccess() const ; | |
676 | void *BeginRawAccess() ; | |
677 | void EndRawAccess() ; | |
678 | ||
679 | bool HasAlpha() const { return m_hasAlpha ; } | |
680 | void UseAlpha( bool useAlpha ) ; | |
681 | ||
682 | public: | |
683 | #if wxUSE_PALETTE | |
684 | wxPalette m_bitmapPalette; | |
685 | #endif // wxUSE_PALETTE | |
686 | ||
687 | wxMask * m_bitmapMask; // Optional mask | |
30e77b5c | 688 | #ifdef __WXMAC_OSX__ |
20b69855 | 689 | CGImageRef CGImageCreate() const ; |
71cc158e | 690 | #endif |
6d2c830a SC |
691 | |
692 | // returns true if the bitmap has a size that | |
693 | // can be natively transferred into a true icon | |
694 | // if no is returned GetIconRef will still produce | |
695 | // an icon but it will be generated via a PICT and | |
696 | // rescaled to 16 x 16 | |
697 | bool HasNativeSize() ; | |
698 | ||
699 | // caller should increase ref count if needed longer | |
700 | // than the bitmap exists | |
701 | IconRef GetIconRef() ; | |
702 | ||
703 | // returns a Pict from the bitmap content | |
704 | PicHandle GetPictHandle() ; | |
20b69855 SC |
705 | GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ; |
706 | void UpdateAlphaMask() const ; | |
71cc158e | 707 | |
20b69855 SC |
708 | private : |
709 | bool Create(int width , int height , int depth) ; | |
710 | void Init() ; | |
711 | ||
712 | int m_width; | |
713 | int m_height; | |
714 | int m_bytesPerRow ; | |
715 | int m_depth; | |
716 | bool m_hasAlpha; | |
717 | wxMemoryBuffer m_memBuf ; | |
718 | int m_rawAccessCount ; | |
719 | bool m_ok; | |
30e77b5c | 720 | #ifdef __WXMAC_OSX__ |
20b69855 | 721 | mutable CGImageRef m_cgImageRef ; |
71cc158e | 722 | #endif |
6d2c830a SC |
723 | IconRef m_iconRef ; |
724 | PicHandle m_pictHandle ; | |
20b69855 SC |
725 | GWorldPtr m_hBitmap; |
726 | GWorldPtr m_hMaskBitmap ; | |
727 | wxMemoryBuffer m_maskMemBuf ; | |
728 | int m_maskBytesPerRow ; | |
20b69855 SC |
729 | }; |
730 | ||
20b69855 SC |
731 | class WXDLLEXPORT wxIconRefData : public wxGDIRefData |
732 | { | |
733 | public: | |
734 | wxIconRefData() ; | |
735 | wxIconRefData( WXHICON ) ; | |
736 | virtual ~wxIconRefData() { Free(); } | |
737 | ||
738 | void Init() ; | |
739 | virtual void Free(); | |
ddb08e02 SC |
740 | |
741 | void SetWidth( int width ) { m_width = width ; } | |
742 | void SetHeight( int height ) { m_height = height ; } | |
743 | ||
744 | int GetWidth() const { return m_width ; } | |
745 | int GetHeight() const { return m_height ; } | |
746 | ||
20b69855 SC |
747 | WXHICON GetHICON() const { return (WXHICON) m_iconRef ; } |
748 | private : | |
749 | IconRef m_iconRef ; | |
ddb08e02 SC |
750 | int m_width ; |
751 | int m_height ; | |
20b69855 SC |
752 | }; |
753 | ||
285b5ce0 SC |
754 | // toplevel.cpp |
755 | ||
fbfb8bcc | 756 | ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ) ; |
285b5ce0 | 757 | |
8cf73271 SC |
758 | #endif // wxUSE_GUI |
759 | ||
285b5ce0 SC |
760 | #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \ |
761 | UPP Get##x() \ | |
762 | { \ | |
763 | static UPP sHandler = NULL; \ | |
764 | if ( sHandler == NULL ) \ | |
765 | sHandler = New##UPP( x ); \ | |
766 | return sHandler; \ | |
767 | } | |
768 | ||
8cf73271 SC |
769 | //--------------------------------------------------------------------------- |
770 | // wxMac string conversions | |
771 | //--------------------------------------------------------------------------- | |
772 | ||
773 | void wxMacSetupConverters() ; | |
774 | void wxMacCleanupConverters() ; | |
775 | ||
776 | void wxMacStringToPascal( const wxString&from , StringPtr to ) ; | |
777 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; | |
778 | ||
a2b77260 SC |
779 | // filefn.cpp |
780 | ||
781 | wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ; | |
782 | OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ; | |
783 | wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ; | |
aa0cc8a1 | 784 | |
8cf73271 SC |
785 | #endif |
786 | // _WX_PRIVATE_H_ |