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