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