]>
Commit | Line | Data |
---|---|---|
8cf73271 | 1 | ///////////////////////////////////////////////////////////////////////////// |
fb5246be | 2 | // Name: wx/mac/carbon/private.h |
8cf73271 | 3 | // Purpose: Private declarations: as this header is only included by |
77ffb593 | 4 | // wxWidgets itself, it may contain identifiers which don't start |
8cf73271 SC |
5 | // with "wx". |
6 | // Author: Stefan Csomor | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id$ | |
10 | // Copyright: (c) Stefan Csomor | |
65571936 | 11 | // Licence: wxWindows licence |
8cf73271 SC |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_PRIVATE_H_ | |
15 | #define _WX_PRIVATE_H_ | |
16 | ||
17 | #include "wx/defs.h" | |
8cf73271 | 18 | |
a9479081 | 19 | #include <Carbon/Carbon.h> |
fe63cfad | 20 | |
5185263f | 21 | #include "wx/mac/corefoundation/cfstring.h" |
ebf2a1ec | 22 | #include "wx/mac/corefoundation/cfdataref.h" |
3d639707 | 23 | |
fc964c0d | 24 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 |
fe63cfad SC |
25 | typedef UInt32 URefCon; |
26 | typedef SInt32 SRefCon; | |
27 | #endif | |
28 | ||
8cf73271 SC |
29 | #if wxUSE_GUI |
30 | ||
dd0d56f5 | 31 | #include "wx/listbox.h" |
8cf73271 | 32 | |
fb5246be | 33 | class WXDLLEXPORT wxMacCGContextStateSaver |
ddb08e02 SC |
34 | { |
35 | DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver) | |
fb5246be | 36 | |
ddb08e02 | 37 | public: |
fb5246be | 38 | wxMacCGContextStateSaver( CGContextRef cg ) |
ddb08e02 | 39 | { |
6cce68ea SC |
40 | m_cg = cg; |
41 | CGContextSaveGState( cg ); | |
ddb08e02 | 42 | } |
fb5246be | 43 | ~wxMacCGContextStateSaver() |
ddb08e02 | 44 | { |
6cce68ea | 45 | CGContextRestoreGState( m_cg ); |
ddb08e02 SC |
46 | } |
47 | private: | |
6cce68ea SC |
48 | CGContextRef m_cg; |
49 | }; | |
ddb08e02 | 50 | |
8cf73271 | 51 | // app.h |
0beae935 SC |
52 | |
53 | #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 | |
6cce68ea | 54 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec); |
0beae935 | 55 | #endif |
8cf73271 SC |
56 | |
57 | #endif // wxUSE_GUI | |
58 | ||
59 | // filefn.h | |
e17206f7 VS |
60 | WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec ); |
61 | WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ); | |
8cf73271 SC |
62 | |
63 | // utils.h | |
e17206f7 VS |
64 | WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum, |
65 | OSType folderType, | |
66 | Boolean createFolder); | |
67 | WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum, | |
68 | OSType folderType, | |
69 | Boolean createFolder); | |
8cf73271 | 70 | |
6cce68ea SC |
71 | template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; } |
72 | template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; } | |
73 | template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; } | |
74 | template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; } | |
75 | template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; } | |
76 | template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; } | |
77 | template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; } | |
78 | template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; } | |
79 | template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; } | |
80 | template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; } | |
81 | template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; } | |
82 | template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; } | |
83 | template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; } | |
6cce68ea SC |
84 | template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; } |
85 | template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; } | |
86 | template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; } | |
87 | template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; } | |
88 | template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; } | |
6cce68ea | 89 | template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; } |
6cce68ea SC |
90 | template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; } |
91 | template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; } | |
4f305456 | 92 | /* |
885fb02f | 93 | These are ambiguous |
6cce68ea SC |
94 | template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; } |
95 | template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; } | |
96 | template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; } | |
97 | template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; } | |
885fb02f | 98 | */ |
4f305456 SC |
99 | |
100 | class wxMacCarbonEvent | |
101 | { | |
fb5246be | 102 | |
4f305456 | 103 | public : |
a4848597 SC |
104 | wxMacCarbonEvent() |
105 | { | |
6cce68ea SC |
106 | m_eventRef = 0; |
107 | m_release = false; | |
a4848597 | 108 | } |
fb5246be WS |
109 | |
110 | wxMacCarbonEvent( EventRef event , bool release = false ) | |
4f305456 | 111 | { |
6cce68ea SC |
112 | m_eventRef = event; |
113 | m_release = release; | |
6d4c54a7 | 114 | } |
fb5246be WS |
115 | |
116 | wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
6d4c54a7 | 117 | { |
6cce68ea SC |
118 | m_eventRef = NULL; |
119 | verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ); | |
120 | m_release = true; | |
6d4c54a7 | 121 | } |
fb5246be | 122 | |
6d4c54a7 SC |
123 | ~wxMacCarbonEvent() |
124 | { | |
125 | if ( m_release ) | |
6cce68ea | 126 | ReleaseEvent( m_eventRef ); |
4f305456 | 127 | } |
fb5246be WS |
128 | |
129 | OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
a4848597 | 130 | { |
6cce68ea | 131 | verify( (m_eventRef == NULL) || m_release ); |
a4848597 SC |
132 | if ( m_eventRef && m_release ) |
133 | { | |
6cce68ea SC |
134 | ReleaseEvent( m_eventRef ); |
135 | m_release = false; | |
136 | m_eventRef = NULL; | |
a4848597 | 137 | } |
6cce68ea | 138 | OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef); |
a4848597 | 139 | if ( err == noErr ) |
6cce68ea SC |
140 | m_release = true; |
141 | return err; | |
a4848597 | 142 | } |
fb5246be | 143 | |
6cce68ea | 144 | OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData); |
fb5246be | 145 | |
4f305456 SC |
146 | template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) |
147 | { | |
6cce68ea | 148 | return GetParameter( inName, type , sizeof( T ) , data ); |
4f305456 SC |
149 | } |
150 | template <typename T> OSStatus GetParameter( EventParamName inName, T *data ) | |
151 | { | |
6cce68ea | 152 | return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 153 | } |
fb5246be | 154 | |
4f305456 SC |
155 | template <typename T> T GetParameter( EventParamName inName ) |
156 | { | |
6cce68ea SC |
157 | T value; |
158 | verify_noerr( GetParameter<T>( inName, &value ) ); | |
159 | return value; | |
4f305456 SC |
160 | } |
161 | template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType ) | |
162 | { | |
6cce68ea SC |
163 | T value; |
164 | verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ); | |
165 | return value; | |
4f305456 | 166 | } |
fb5246be | 167 | |
6cce68ea | 168 | OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData); |
6d4c54a7 | 169 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data ) |
4f305456 | 170 | { |
6cce68ea | 171 | return SetParameter( inName, inDesiredType , sizeof( T ) , data ); |
2aefa0ef | 172 | } |
6d4c54a7 | 173 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data ) |
2aefa0ef | 174 | { |
6cce68ea | 175 | return SetParameter<T>( inName, inDesiredType , &data ); |
4f305456 | 176 | } |
6d4c54a7 | 177 | template <typename T> OSStatus SetParameter( EventParamName inName, const T *data ) |
4f305456 | 178 | { |
6cce68ea | 179 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 180 | } |
6d4c54a7 | 181 | template <typename T> OSStatus SetParameter( EventParamName inName, const T& data ) |
2aefa0ef | 182 | { |
6cce68ea | 183 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ); |
2aefa0ef | 184 | } |
86d8b744 SC |
185 | UInt32 GetClass() |
186 | { | |
6cce68ea | 187 | return ::GetEventClass( m_eventRef ); |
86d8b744 | 188 | } |
41b53169 | 189 | UInt32 GetKind() |
4f305456 | 190 | { |
6cce68ea | 191 | return ::GetEventKind( m_eventRef ); |
4f305456 SC |
192 | } |
193 | EventTime GetTime() | |
194 | { | |
6cce68ea | 195 | return ::GetEventTime( m_eventRef ); |
4f305456 SC |
196 | } |
197 | UInt32 GetTicks() | |
198 | { | |
6cce68ea | 199 | return EventTimeToTicks( GetTime() ); |
4f305456 | 200 | } |
2c01d335 | 201 | OSStatus SetCurrentTime( ) |
a4848597 | 202 | { |
6cce68ea | 203 | return ::SetEventTime( m_eventRef , GetCurrentEventTime() ); |
2c01d335 | 204 | } |
fb5246be | 205 | OSStatus SetTime( EventTime when ) |
2c01d335 | 206 | { |
6cce68ea | 207 | return ::SetEventTime( m_eventRef , when ); |
a4848597 SC |
208 | } |
209 | operator EventRef () { return m_eventRef; } | |
fb5246be | 210 | |
6cce68ea | 211 | bool IsValid() { return m_eventRef != 0; } |
4f305456 | 212 | protected : |
6cce68ea SC |
213 | EventRef m_eventRef; |
214 | bool m_release; | |
215 | }; | |
4f305456 | 216 | |
3feeb1e1 SC |
217 | // |
218 | // helper class for allocating and deallocating Universal Proc Ptrs | |
219 | // | |
220 | ||
221 | template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP | |
222 | { | |
223 | public : | |
89954433 | 224 | wxMacUPP( procType WXUNUSED(proc) ) |
3feeb1e1 | 225 | { |
6cce68ea SC |
226 | m_upp = NULL; |
227 | m_upp = (*newUPP)( NULL ); | |
3feeb1e1 SC |
228 | } |
229 | ~wxMacUPP() | |
230 | { | |
231 | if ( m_upp ) | |
6cce68ea | 232 | disposeUPP( m_upp ); |
3feeb1e1 | 233 | } |
6cce68ea | 234 | operator uppType() { return m_upp; } |
3feeb1e1 | 235 | private : |
6cce68ea SC |
236 | uppType m_upp; |
237 | }; | |
3feeb1e1 | 238 | |
6cce68ea | 239 | typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP; |
3feeb1e1 | 240 | |
18b94824 SC |
241 | template <typename refType> class wxMacCFRefHolder |
242 | { | |
243 | public : | |
244 | wxMacCFRefHolder() | |
fb5246be | 245 | : m_ref(NULL) , m_release(false) |
18b94824 SC |
246 | { |
247 | } | |
fb5246be WS |
248 | |
249 | wxMacCFRefHolder( refType ref , bool release = true ) | |
18b94824 SC |
250 | : m_ref(ref) , m_release(release) |
251 | { | |
252 | } | |
fb5246be | 253 | |
18b94824 SC |
254 | ~wxMacCFRefHolder() |
255 | { | |
6cce68ea | 256 | Release(); |
18b94824 | 257 | } |
fb5246be | 258 | |
18b94824 SC |
259 | void Release() |
260 | { | |
261 | if ( m_release && m_ref != NULL ) | |
6cce68ea SC |
262 | CFRelease( m_ref ); |
263 | m_ref = NULL; | |
18b94824 | 264 | } |
fb5246be | 265 | |
18b94824 SC |
266 | refType Detach() |
267 | { | |
6cce68ea SC |
268 | refType val = m_ref; |
269 | m_release = false; | |
270 | m_ref = NULL; | |
271 | return val; | |
18b94824 | 272 | } |
fb5246be | 273 | |
18b94824 SC |
274 | void Set( refType ref , bool release = true ) |
275 | { | |
6cce68ea SC |
276 | Release(); |
277 | m_release = release; | |
278 | m_ref = ref; | |
18b94824 | 279 | } |
fb5246be | 280 | |
18b94824 | 281 | operator refType () const { return m_ref; } |
fb5246be | 282 | |
ebf2a1ec SC |
283 | wxMacCFRefHolder& operator=(refType r) |
284 | { | |
285 | Set( r ); | |
286 | return *this; | |
287 | } | |
18b94824 | 288 | private : |
6cce68ea SC |
289 | refType m_ref; |
290 | bool m_release; | |
fb5246be | 291 | |
18b94824 | 292 | DECLARE_NO_COPY_CLASS( wxMacCFRefHolder ) |
6cce68ea | 293 | }; |
18b94824 | 294 | |
885fb02f | 295 | #if wxUSE_GUI |
6cce68ea | 296 | |
ebf2a1ec SC |
297 | class wxMacToolTipTimer ; |
298 | ||
299 | class wxMacToolTip | |
300 | { | |
301 | public : | |
302 | wxMacToolTip() ; | |
303 | ~wxMacToolTip() ; | |
304 | ||
305 | void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ; | |
306 | void Draw() ; | |
307 | void Clear() ; | |
308 | ||
309 | long GetMark() | |
310 | { return m_mark ; } | |
311 | ||
312 | bool IsShown() | |
313 | { return m_shown ; } | |
314 | ||
315 | private : | |
316 | wxString m_label ; | |
317 | wxPoint m_position ; | |
318 | Rect m_rect ; | |
319 | WindowRef m_window ; | |
320 | PicHandle m_backpict ; | |
321 | bool m_shown ; | |
322 | long m_mark ; | |
323 | #if wxUSE_TIMER | |
324 | wxMacToolTipTimer* m_timer ; | |
325 | #endif | |
ebf2a1ec | 326 | wxMacCFStringHolder m_helpTextRef ; |
ebf2a1ec SC |
327 | } ; |
328 | ||
3e109f6d SC |
329 | // Quartz |
330 | ||
331 | WXDLLIMPEXP_CORE void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ); | |
332 | WXDLLIMPEXP_CORE void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ); | |
333 | WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ); | |
334 | ||
335 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data ); | |
336 | WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data ); | |
337 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); | |
338 | ||
885fb02f | 339 | |
885fb02f SC |
340 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) |
341 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
20b69855 | 342 | #define MAC_WXHICON(a) (IconRef(a)) |
885fb02f SC |
343 | #define MAC_WXHCURSOR(a) (CursHandle(a)) |
344 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
345 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
346 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
347 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
348 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
349 | ||
350 | struct wxOpaqueWindowRef | |
351 | { | |
6cce68ea SC |
352 | wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; } |
353 | operator WindowRef() { return m_data; } | |
885fb02f | 354 | private : |
6cce68ea SC |
355 | WindowRef m_data; |
356 | }; | |
885fb02f | 357 | |
6cce68ea SC |
358 | void wxMacRectToNative( const wxRect *wx , Rect *n ); |
359 | void wxMacNativeToRect( const Rect *n , wxRect* wx ); | |
360 | void wxMacPointToNative( const wxPoint* wx , Point *n ); | |
361 | void wxMacNativeToPoint( const Point *n , wxPoint* wx ); | |
285b5ce0 | 362 | |
2301cda0 SC |
363 | WXDLLIMPEXP_CORE wxWindow * wxFindControlFromMacControl(ControlRef inControl ); |
364 | WXDLLIMPEXP_CORE wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ); | |
365 | WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef); | |
885fb02f | 366 | |
2301cda0 SC |
367 | WXDLLIMPEXP_CORE int wxMacCommandToId( UInt32 macCommandId ); |
368 | WXDLLIMPEXP_CORE UInt32 wxIdToMacCommand( int wxId ); | |
369 | WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ); | |
1628261e | 370 | |
6cce68ea | 371 | extern wxWindow* g_MacLastWindow; |
2301cda0 SC |
372 | WXDLLIMPEXP_CORE pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ); |
373 | WXDLLIMPEXP_CORE Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ); | |
885fb02f | 374 | |
6cce68ea | 375 | ControlActionUPP GetwxMacLiveScrollbarActionProc(); |
285b5ce0 | 376 | |
577246ef SC |
377 | // additional optional event defines |
378 | ||
379 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 | |
380 | enum { | |
381 | kEventControlFocusPartChanged = 164 | |
382 | }; | |
383 | #endif | |
384 | ||
bf9a1615 | 385 | class wxMacControl : public wxObject |
86d8b744 SC |
386 | { |
387 | public : | |
6cce68ea SC |
388 | wxMacControl( wxWindow* peer , bool isRootControl = false ); |
389 | wxMacControl( wxWindow* peer , ControlRef control ); | |
390 | wxMacControl( wxWindow* peer , WXWidget control ); | |
bf9a1615 | 391 | wxMacControl() ; |
6cce68ea SC |
392 | virtual ~wxMacControl(); |
393 | ||
394 | void Init(); | |
fb5246be | 395 | |
6cce68ea | 396 | virtual void Dispose(); |
fb5246be | 397 | |
b7cacb43 VZ |
398 | bool Ok() const { return IsOk(); } |
399 | bool IsOk() const { return GetControlRef() != NULL; } | |
5ca0d812 | 400 | |
6cce68ea SC |
401 | void SetReferenceInNativeControl(); |
402 | static wxMacControl* GetReferenceFromNativeControl(ControlRef control); | |
5ca0d812 | 403 | |
fb5246be | 404 | virtual ControlRef * GetControlRefAddr() { return &m_controlRef; } |
6cce68ea | 405 | virtual ControlRef GetControlRef() const { return m_controlRef; } |
fb5246be | 406 | |
eb89f88a | 407 | virtual void SetReference( URefCon data ); |
5ca0d812 | 408 | /* |
6cce68ea | 409 | void operator= (ControlRef c) { m_controlRef = c; } |
fb5246be WS |
410 | operator ControlRef () { return m_controlRef; } |
411 | operator ControlRef * () { return &m_controlRef; } | |
5ca0d812 | 412 | */ |
2837271a SC |
413 | // accessing data and values |
414 | ||
6cce68ea SC |
415 | virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ); |
416 | virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const; | |
417 | virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const; | |
418 | virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ); | |
419 | virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ); | |
2837271a | 420 | |
6cce68ea | 421 | virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ); |
2837271a | 422 | |
6cce68ea SC |
423 | virtual SInt32 GetValue() const; |
424 | virtual SInt32 GetMaximum() const; | |
425 | virtual SInt32 GetMinimum() const; | |
fb5246be | 426 | |
6cce68ea SC |
427 | virtual void SetValue( SInt32 v ); |
428 | virtual void SetMinimum( SInt32 v ); | |
429 | virtual void SetMaximum( SInt32 v ); | |
2837271a | 430 | |
6cce68ea SC |
431 | virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ); |
432 | virtual void SetRange( SInt32 minimum , SInt32 maximum ); | |
fb5246be | 433 | |
6cce68ea SC |
434 | virtual OSStatus SetFocus( ControlFocusPart focusPart ); |
435 | virtual bool HasFocus() const; | |
436 | virtual bool NeedsFocusRect() const; | |
437 | virtual void SetNeedsFocusRect( bool needs ); | |
fb5246be | 438 | |
2837271a SC |
439 | // templated helpers |
440 | ||
0fc3bc3b | 441 | Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 442 | { |
6cce68ea SC |
443 | Size sz; |
444 | verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ); | |
445 | return sz; | |
86d8b744 | 446 | } |
6d4c54a7 | 447 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data ) |
86d8b744 | 448 | { |
6cce68ea | 449 | return SetData( inPartCode , inTag , sizeof( T ) , data ); |
86d8b744 | 450 | } |
6d4c54a7 | 451 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data ) |
86d8b744 | 452 | { |
6cce68ea | 453 | return SetData( inPartCode , inTag , sizeof( T ) , &data ); |
86d8b744 | 454 | } |
fbb7ee81 SC |
455 | template <typename T> OSStatus SetData( ResType inTag , const T *data ) |
456 | { | |
6cce68ea | 457 | return SetData( kControlEntireControl , inTag , sizeof( T ) , data ); |
fbb7ee81 SC |
458 | } |
459 | template <typename T> OSStatus SetData( ResType inTag , const T& data ) | |
460 | { | |
6cce68ea | 461 | return SetData( kControlEntireControl , inTag , sizeof( T ) , &data ); |
fbb7ee81 | 462 | } |
0fc3bc3b | 463 | template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const |
86d8b744 | 464 | { |
6cce68ea SC |
465 | Size dummy; |
466 | return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ); | |
86d8b744 | 467 | } |
0fc3bc3b | 468 | template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 469 | { |
6cce68ea SC |
470 | T value; |
471 | OSStatus err = GetData<T>( inPartCode , inTag , &value ); | |
725566ca VZ |
472 | |
473 | wxASSERT_MSG( err == noErr, | |
474 | wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"), | |
475 | inPartCode, (int)inTag) ); | |
6cce68ea | 476 | return value; |
86d8b744 | 477 | } |
fbb7ee81 SC |
478 | template <typename T> OSStatus GetData( ResType inTag , T *data ) const |
479 | { | |
6cce68ea SC |
480 | Size dummy; |
481 | return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy ); | |
fbb7ee81 SC |
482 | } |
483 | template <typename T> T GetData( ResType inTag ) const | |
484 | { | |
6cce68ea | 485 | return GetData<T>( kControlEntireControl , inTag ); |
fbb7ee81 | 486 | } |
725566ca | 487 | |
6d4c54a7 | 488 | // Flash the control for the specified amount of time |
6cce68ea | 489 | virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ); |
89a66f11 | 490 | |
6cce68ea SC |
491 | virtual void VisibilityChanged( bool shown ); |
492 | virtual void SuperChangedPosition(); | |
89a66f11 SC |
493 | |
494 | ||
6cce68ea | 495 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ); |
850df2d7 | 496 | virtual void SetBackgroundColour( const wxColour& col ); |
6cce68ea 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; | |
fb5246be | 501 | |
6cce68ea SC |
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 ); | |
fb5246be | 507 | |
5ca0d812 | 508 | // invalidates this control and all children |
6cce68ea SC |
509 | virtual void InvalidateWithChildren(); |
510 | virtual void SetDrawingEnabled( bool enable ); | |
6cce68ea | 511 | virtual bool GetNeedsDisplay() const; |
a9479081 | 512 | |
285b5ce0 | 513 | // where is in native window relative coordinates |
6cce68ea | 514 | virtual void SetNeedsDisplay( RgnHandle where ); |
285b5ce0 | 515 | // where is in native window relative coordinates |
6cce68ea | 516 | virtual void SetNeedsDisplay( Rect* where = NULL ); |
285b5ce0 | 517 | |
fb5246be | 518 | // if rect = NULL, entire view |
6cce68ea | 519 | virtual void ScrollRect( wxRect *rect , int dx , int dy ); |
5ca0d812 | 520 | |
285b5ce0 | 521 | // in native parent window relative coordinates |
6cce68ea | 522 | virtual void GetRect( Rect *r ); |
285b5ce0 SC |
523 | |
524 | // in native parent window relative coordinates | |
6cce68ea | 525 | virtual void SetRect( Rect *r ); |
285b5ce0 | 526 | |
6cce68ea SC |
527 | virtual void GetRectInWindowCoords( Rect *r ); |
528 | virtual void GetBestRect( Rect *r ); | |
529 | virtual void SetLabel( const wxString &title ); | |
5ca0d812 | 530 | // converts from Toplevel-Content relative to local |
6cce68ea | 531 | static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ); |
fb5246be | 532 | |
6cce68ea SC |
533 | virtual void GetFeatures( UInt32 *features ); |
534 | virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ); | |
535 | virtual OSStatus SetZOrder( bool above , wxMacControl* other ); | |
725566ca | 536 | |
6cce68ea | 537 | bool IsRootControl() { return m_isRootControl; } |
725566ca | 538 | |
6cce68ea SC |
539 | wxWindow* GetPeer() const |
540 | { | |
541 | return m_peer; | |
542 | } | |
ba5b8a68 SC |
543 | |
544 | // to be moved into a tab control class | |
545 | ||
6cce68ea SC |
546 | virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ); |
547 | protected : | |
548 | ControlRef m_controlRef; | |
549 | wxFont m_font; | |
550 | long m_windowStyle; | |
551 | wxWindow* m_peer; | |
552 | bool m_needsFocusRect; | |
6cce68ea | 553 | bool m_isRootControl; |
bf9a1615 | 554 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl) |
6cce68ea SC |
555 | }; |
556 | ||
557 | // ============================================================================ | |
558 | // DataBrowser Wrapper | |
559 | // ============================================================================ | |
560 | // | |
561 | // basing on DataBrowserItemIDs | |
562 | // | |
563 | ||
564 | class wxMacDataBrowserControl : public wxMacControl | |
565 | { | |
566 | public : | |
567 | wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style); | |
bf9a1615 | 568 | wxMacDataBrowserControl() {} |
6cce68ea SC |
569 | |
570 | OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks ); | |
725566ca | 571 | |
6cce68ea SC |
572 | OSStatus GetItemCount( DataBrowserItemID container, |
573 | Boolean recurse, | |
574 | DataBrowserItemState state, | |
eb89f88a | 575 | ItemCount *numItems) const; |
725566ca | 576 | |
6cce68ea SC |
577 | OSStatus GetItems( DataBrowserItemID container, |
578 | Boolean recurse, | |
579 | DataBrowserItemState state, | |
580 | Handle items) const; | |
725566ca | 581 | |
6cce68ea SC |
582 | |
583 | OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc, | |
584 | DataBrowserTableViewColumnIndex position ); | |
7b514b3b | 585 | |
e2bc1d69 | 586 | OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position ); |
725566ca | 587 | |
6cce68ea | 588 | OSStatus AutoSizeColumns(); |
725566ca | 589 | |
6cce68ea SC |
590 | OSStatus SetHasScrollBars( bool horiz, bool vert ); |
591 | OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ); | |
725566ca | 592 | |
6cce68ea SC |
593 | OSStatus SetHeaderButtonHeight( UInt16 height ); |
594 | OSStatus GetHeaderButtonHeight( UInt16 *height ); | |
595 | ||
596 | OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
597 | const DataBrowserItemID *items, | |
598 | DataBrowserPropertyID preSortProperty, | |
599 | DataBrowserPropertyID propertyID ) const; | |
725566ca | 600 | |
6cce68ea SC |
601 | OSStatus AddItems( DataBrowserItemID container, UInt32 numItems, |
602 | const DataBrowserItemID *items, | |
603 | DataBrowserPropertyID preSortProperty ); | |
604 | OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
605 | const DataBrowserItemID *items, | |
606 | DataBrowserPropertyID preSortProperty ); | |
607 | OSStatus RevealItem( DataBrowserItemID item, | |
608 | DataBrowserPropertyID propertyID, | |
609 | DataBrowserRevealOptions options ) const; | |
610 | ||
611 | OSStatus SetSelectionFlags( DataBrowserSelectionFlags ); | |
612 | OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const; | |
613 | bool IsItemSelected( DataBrowserItemID item ) const; | |
614 | OSStatus SetSelectedItems( UInt32 numItems, | |
615 | const DataBrowserItemID *items, | |
616 | DataBrowserSetOption operation ); | |
617 | ||
725566ca | 618 | OSStatus GetItemID( DataBrowserTableViewRowIndex row, |
6cce68ea | 619 | DataBrowserItemID * item ) const; |
725566ca | 620 | OSStatus GetItemRow( DataBrowserItemID item, |
6cce68ea | 621 | DataBrowserTableViewRowIndex * row ) const; |
725566ca | 622 | |
6cce68ea SC |
623 | OSStatus SetDefaultRowHeight( UInt16 height ); |
624 | OSStatus GetDefaultRowHeight( UInt16 * height ) const; | |
725566ca | 625 | |
6cce68ea SC |
626 | OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height); |
627 | OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const; | |
725566ca | 628 | |
6cce68ea SC |
629 | OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const; |
630 | OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width ); | |
725566ca | 631 | |
6cce68ea SC |
632 | OSStatus GetDefaultColumnWidth( UInt16 *width ) const; |
633 | OSStatus SetDefaultColumnWidth( UInt16 width ); | |
725566ca | 634 | |
6cce68ea SC |
635 | OSStatus GetColumnCount( UInt32* numColumns) const; |
636 | ||
e2bc1d69 KO |
637 | OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ); |
638 | ||
eb89f88a SC |
639 | OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const; |
640 | OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position); | |
725566ca | 641 | |
6cce68ea SC |
642 | OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const; |
643 | OSStatus SetScrollPosition( UInt32 top , UInt32 left ); | |
725566ca | 644 | |
6cce68ea SC |
645 | OSStatus GetSortProperty( DataBrowserPropertyID *column ) const; |
646 | OSStatus SetSortProperty( DataBrowserPropertyID column ); | |
725566ca | 647 | |
6cce68ea SC |
648 | OSStatus GetSortOrder( DataBrowserSortOrder *order ) const; |
649 | OSStatus SetSortOrder( DataBrowserSortOrder order ); | |
725566ca | 650 | |
6cce68ea SC |
651 | OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const; |
652 | OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags ); | |
725566ca | 653 | |
6cce68ea SC |
654 | OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const; |
655 | OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ); | |
725566ca | 656 | |
6cce68ea | 657 | OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows ); |
86d8b744 | 658 | protected : |
725566ca | 659 | |
6cce68ea SC |
660 | static pascal void DataBrowserItemNotificationProc( |
661 | ControlRef browser, | |
662 | DataBrowserItemID itemID, | |
663 | DataBrowserItemNotification message, | |
664 | DataBrowserItemDataRef itemData ); | |
665 | ||
666 | virtual void ItemNotification( | |
667 | DataBrowserItemID itemID, | |
668 | DataBrowserItemNotification message, | |
669 | DataBrowserItemDataRef itemData) = 0; | |
670 | ||
671 | static pascal OSStatus DataBrowserGetSetItemDataProc( | |
672 | ControlRef browser, | |
673 | DataBrowserItemID itemID, | |
674 | DataBrowserPropertyID property, | |
675 | DataBrowserItemDataRef itemData, | |
676 | Boolean changeValue ); | |
677 | ||
678 | virtual OSStatus GetSetItemData( | |
679 | DataBrowserItemID itemID, | |
680 | DataBrowserPropertyID property, | |
681 | DataBrowserItemDataRef itemData, | |
682 | Boolean changeValue ) = 0; | |
683 | ||
684 | static pascal Boolean DataBrowserCompareProc( | |
1b88201f WS |
685 | ControlRef browser, |
686 | DataBrowserItemID itemOneID, | |
687 | DataBrowserItemID itemTwoID, | |
688 | DataBrowserPropertyID sortProperty); | |
689 | ||
690 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
691 | DataBrowserItemID itemTwoID, | |
692 | DataBrowserPropertyID sortProperty) = 0; | |
bf9a1615 | 693 | DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl) |
6cce68ea SC |
694 | }; |
695 | ||
696 | // ============================================================================ | |
725566ca | 697 | // Higher-level Databrowser |
6cce68ea SC |
698 | // ============================================================================ |
699 | // | |
700 | // basing on data item objects | |
701 | // | |
702 | ||
703 | // forward decl | |
704 | ||
705 | class wxMacDataItemBrowserControl; | |
e2bc1d69 KO |
706 | class wxMacListBoxItem; |
707 | ||
e362c2b9 SC |
708 | const DataBrowserPropertyID kTextColumnId = 1024; |
709 | const DataBrowserPropertyID kNumericOrderColumnId = 1025; | |
e2bc1d69 | 710 | |
7b514b3b | 711 | // for multi-column controls, we will use this + the column ID to identify the |
e2bc1d69 | 712 | // column. We don't use kTextColumnId there, and ideally the two should merge. |
e362c2b9 | 713 | const DataBrowserPropertyID kMinColumnId = 1050; |
e2bc1d69 KO |
714 | |
715 | // base API for high-level databrowser operations | |
716 | ||
717 | class wxMacListControl | |
718 | { | |
719 | public: | |
720 | virtual void MacDelete( unsigned int n ) = 0; | |
a236aa20 | 721 | virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ) = 0; |
e2bc1d69 KO |
722 | // returns index of newly created line |
723 | virtual int MacAppend( const wxString& item ) = 0; | |
724 | virtual void MacSetString( unsigned int n, const wxString& item ) = 0; | |
725 | virtual void MacClear() = 0; | |
726 | virtual void MacDeselectAll() = 0; | |
727 | virtual void MacSetSelection( unsigned int n, bool select, bool multi ) = 0; | |
728 | virtual int MacGetSelection() const = 0; | |
729 | virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0; | |
730 | virtual bool MacIsSelected( unsigned int n ) const = 0; | |
731 | virtual void MacScrollTo( unsigned int n ) = 0; | |
732 | virtual wxString MacGetString( unsigned int n) const = 0; | |
733 | virtual unsigned int MacGetCount() const = 0; | |
734 | ||
735 | virtual void MacSetClientData( unsigned int n, void * data) = 0; | |
736 | virtual void * MacGetClientData( unsigned int) const = 0; | |
737 | ||
738 | virtual ~wxMacListControl() { } | |
7b514b3b | 739 | }; |
6cce68ea SC |
740 | |
741 | // base class for databrowser items | |
742 | ||
e2bc1d69 KO |
743 | enum DataItemType { |
744 | DataItem_Text | |
745 | }; | |
746 | ||
6cce68ea SC |
747 | class wxMacDataItem |
748 | { | |
749 | public : | |
750 | wxMacDataItem(); | |
751 | virtual ~wxMacDataItem(); | |
725566ca VZ |
752 | |
753 | virtual bool IsLessThan(wxMacDataItemBrowserControl *owner , | |
754 | const wxMacDataItem*, | |
6cce68ea | 755 | DataBrowserPropertyID property) const; |
725566ca | 756 | |
6cce68ea | 757 | // returns true if access was successful, otherwise false |
725566ca | 758 | virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
759 | DataBrowserPropertyID property, |
760 | DataBrowserItemDataRef itemData, | |
761 | bool changeValue ); | |
762 | ||
725566ca | 763 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
764 | DataBrowserItemNotification message, |
765 | DataBrowserItemDataRef itemData ) const; | |
7b514b3b | 766 | |
e2bc1d69 | 767 | void SetLabel( const wxString& str); |
7b514b3b | 768 | const wxString& GetLabel() const; |
e2bc1d69 KO |
769 | |
770 | void SetOrder( SInt32 order ); | |
771 | SInt32 GetOrder() const; | |
772 | ||
773 | void SetData( void* data); | |
774 | void* GetData() const; | |
7b514b3b | 775 | |
e2bc1d69 | 776 | void SetColumn( short col ); |
7b514b3b VZ |
777 | short GetColumn(); |
778 | ||
e2bc1d69 KO |
779 | protected : |
780 | wxString m_label; | |
781 | wxMacCFStringHolder m_cfLabel; | |
782 | void * m_data; | |
783 | SInt32 m_order; | |
7b514b3b VZ |
784 | DataBrowserPropertyID m_colId; |
785 | ||
e2bc1d69 KO |
786 | }; |
787 | ||
788 | enum ListSortOrder { | |
789 | SortOrder_None, | |
790 | SortOrder_Text_Ascending, | |
791 | SortOrder_Text_Descending | |
6cce68ea SC |
792 | }; |
793 | ||
794 | typedef wxMacDataItem* wxMacDataItemPtr; | |
795 | const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL; | |
796 | ||
797 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE); | |
798 | ||
e2bc1d69 | 799 | class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl |
6cce68ea SC |
800 | { |
801 | public : | |
802 | wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style); | |
bf9a1615 | 803 | wxMacDataItemBrowserControl() {} |
e2bc1d69 KO |
804 | // create a list item (can be a subclass of wxMacListBoxItem) |
805 | ||
806 | virtual wxMacDataItem* CreateItem(); | |
807 | ||
6cce68ea | 808 | unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const; |
725566ca | 809 | void GetItems(const wxMacDataItem* container, bool recurse , |
6cce68ea | 810 | DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const; |
7b514b3b | 811 | |
e2bc1d69 | 812 | unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const; |
725566ca | 813 | |
6cce68ea SC |
814 | unsigned int GetLineFromItem(const wxMacDataItem *item) const; |
815 | wxMacDataItem * GetItemFromLine(unsigned int n) const; | |
725566ca VZ |
816 | |
817 | void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item, | |
6cce68ea | 818 | DataBrowserPropertyID property) const; |
725566ca | 819 | void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items, |
6cce68ea | 820 | DataBrowserPropertyID property) const; |
725566ca | 821 | |
3ef4e126 SC |
822 | void InsertColumn(int colId, DataBrowserPropertyType colType, |
823 | const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1); | |
7b514b3b | 824 | |
e2bc1d69 KO |
825 | int GetColumnWidth(int colId); |
826 | void SetColumnWidth(int colId, int width); | |
827 | ||
6cce68ea SC |
828 | void AddItem(wxMacDataItem *container, wxMacDataItem *item); |
829 | void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items ); | |
830 | ||
831 | void RemoveAllItems(wxMacDataItem *container); | |
832 | void RemoveItem(wxMacDataItem *container, wxMacDataItem* item); | |
833 | void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items); | |
725566ca | 834 | |
6cce68ea SC |
835 | void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option); |
836 | void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option); | |
837 | void SetSelectedAllItems( DataBrowserSetOption option); | |
838 | Boolean IsItemSelected( const wxMacDataItem* item) const; | |
725566ca | 839 | |
6cce68ea | 840 | void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options); |
725566ca | 841 | |
6cce68ea | 842 | void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const; |
725566ca | 843 | |
6cce68ea | 844 | // item aware methods, to be used in subclasses |
725566ca VZ |
845 | |
846 | virtual Boolean CompareItems(const wxMacDataItem* itemOneID, | |
847 | const wxMacDataItem* itemTwoID, | |
6cce68ea SC |
848 | DataBrowserPropertyID sortProperty); |
849 | ||
850 | virtual OSStatus GetSetItemData(wxMacDataItem* itemID, | |
851 | DataBrowserPropertyID property, | |
852 | DataBrowserItemDataRef itemData, | |
853 | Boolean changeValue ); | |
854 | ||
855 | virtual void ItemNotification( | |
856 | const wxMacDataItem* itemID, | |
857 | DataBrowserItemNotification message, | |
858 | DataBrowserItemDataRef itemData); | |
8b64a7e2 PC |
859 | |
860 | // as we are getting the same events for human and API selection we have to suppress | |
861 | // events in the latter case, since this will be used from many subclasses we keep it here | |
862 | ||
863 | bool IsSelectionSuppressed() const { return m_suppressSelection; } | |
864 | bool SuppressSelection( bool suppress ); | |
7b514b3b VZ |
865 | |
866 | ||
e2bc1d69 KO |
867 | // wxMacListControl Methods |
868 | // add and remove | |
869 | ||
870 | virtual void MacDelete( unsigned int n ); | |
a236aa20 | 871 | virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ); |
e2bc1d69 KO |
872 | virtual int MacAppend( const wxString& item ); |
873 | virtual void MacClear(); | |
874 | ||
875 | // selecting | |
876 | ||
877 | virtual void MacDeselectAll(); | |
878 | virtual void MacSetSelection( unsigned int n, bool select, bool multi = false ); | |
879 | virtual int MacGetSelection() const; | |
880 | virtual int MacGetSelections( wxArrayInt& aSelections ) const; | |
881 | virtual bool MacIsSelected( unsigned int n ) const; | |
882 | ||
883 | // display | |
884 | ||
885 | virtual void MacScrollTo( unsigned int n ); | |
886 | ||
887 | // accessing content | |
888 | ||
889 | virtual void MacSetString( unsigned int n, const wxString& item ); | |
890 | virtual void MacSetClientData( unsigned int n, void * data); | |
891 | virtual wxString MacGetString( unsigned int n) const; | |
892 | virtual void * MacGetClientData( unsigned int) const; | |
893 | virtual unsigned int MacGetCount() const; | |
894 | ||
895 | // client data | |
896 | ||
897 | virtual wxClientDataType GetClientDataType() const; | |
898 | virtual void SetClientDataType(wxClientDataType clientDataItemsType); | |
67650ea0 KO |
899 | //virtual ListSortOrder GetSortOrder() const; |
900 | //virtual void SetSortOrder(const ListSortOrder sort); | |
e2bc1d69 | 901 | |
7b514b3b | 902 | |
8b64a7e2 PC |
903 | |
904 | protected: | |
e2bc1d69 KO |
905 | |
906 | ListSortOrder m_sortOrder; | |
907 | wxClientDataType m_clientDataItemsType; | |
908 | ||
6cce68ea | 909 | // ID aware base methods, should be 'final' ie not changed in subclasses |
725566ca VZ |
910 | |
911 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
912 | DataBrowserItemID itemTwoID, | |
6cce68ea SC |
913 | DataBrowserPropertyID sortProperty); |
914 | ||
915 | virtual OSStatus GetSetItemData(DataBrowserItemID itemID, | |
916 | DataBrowserPropertyID property, | |
917 | DataBrowserItemDataRef itemData, | |
918 | Boolean changeValue ); | |
919 | ||
920 | virtual void ItemNotification( | |
921 | DataBrowserItemID itemID, | |
922 | DataBrowserItemNotification message, | |
923 | DataBrowserItemDataRef itemData); | |
924 | ||
e2bc1d69 | 925 | |
6cce68ea SC |
926 | private : |
927 | ||
928 | bool m_suppressSelection; | |
bf9a1615 | 929 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl) |
6cce68ea SC |
930 | }; |
931 | ||
932 | class wxMacDataItemBrowserSelectionSuppressor | |
933 | { | |
934 | public : | |
935 | wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser); | |
936 | ~wxMacDataItemBrowserSelectionSuppressor(); | |
725566ca | 937 | |
6cce68ea SC |
938 | private : |
939 | ||
940 | bool m_former; | |
941 | wxMacDataItemBrowserControl* m_browser; | |
942 | }; | |
943 | ||
944 | // ============================================================================ | |
945 | // platform listbox implementation | |
946 | // ============================================================================ | |
e2bc1d69 | 947 | |
6cce68ea SC |
948 | // exposed for reuse in wxCheckListBox |
949 | ||
950 | class wxMacListBoxItem : public wxMacDataItem | |
951 | { | |
952 | public : | |
953 | wxMacListBoxItem(); | |
725566ca | 954 | |
6cce68ea | 955 | virtual ~wxMacListBoxItem(); |
725566ca | 956 | |
725566ca | 957 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
958 | DataBrowserItemNotification message, |
959 | DataBrowserItemDataRef itemData ) const; | |
6cce68ea SC |
960 | }; |
961 | ||
e2bc1d69 | 962 | class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl |
6cce68ea SC |
963 | { |
964 | public: | |
e2bc1d69 | 965 | wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style ); |
bf9a1615 | 966 | wxMacDataBrowserListControl() {} |
d3c7fc99 | 967 | virtual ~wxMacDataBrowserListControl(); |
6cce68ea | 968 | |
e6fd62dd RD |
969 | virtual wxMacDataItem* CreateItem(); |
970 | ||
6cce68ea SC |
971 | // pointing back |
972 | ||
e2bc1d69 KO |
973 | wxWindow * GetPeer() const; |
974 | ||
bf9a1615 | 975 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl) |
6cce68ea SC |
976 | }; |
977 | ||
978 | // ============================================================================ | |
979 | // graphics implementation | |
980 | // ============================================================================ | |
86d8b744 | 981 | |
11556386 SC |
982 | // draw the image 'upside down' corrected as HIViewDrawCGImage does |
983 | ||
3e109f6d | 984 | OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( |
11556386 SC |
985 | CGContextRef inContext, |
986 | const HIRect * inBounds, | |
987 | CGImageRef inImage) ; | |
988 | ||
3e109f6d | 989 | CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ; |
850df2d7 | 990 | |
3e109f6d | 991 | CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void); |
20b69855 | 992 | |
285b5ce0 SC |
993 | // toplevel.cpp |
994 | ||
ebf2a1ec SC |
995 | class wxMacDeferredWindowDeleter : public wxObject |
996 | { | |
997 | public : | |
998 | wxMacDeferredWindowDeleter( WindowRef windowRef ); | |
999 | virtual ~wxMacDeferredWindowDeleter(); | |
1000 | ||
1001 | protected : | |
1002 | WindowRef m_macWindow ; | |
1003 | } ; | |
1004 | ||
8cf73271 SC |
1005 | #endif // wxUSE_GUI |
1006 | ||
285b5ce0 SC |
1007 | #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \ |
1008 | UPP Get##x() \ | |
1009 | { \ | |
1010 | static UPP sHandler = NULL; \ | |
1011 | if ( sHandler == NULL ) \ | |
1012 | sHandler = New##UPP( x ); \ | |
1013 | return sHandler; \ | |
1014 | } | |
1015 | ||
8cf73271 SC |
1016 | //--------------------------------------------------------------------------- |
1017 | // wxMac string conversions | |
1018 | //--------------------------------------------------------------------------- | |
1019 | ||
6cce68ea SC |
1020 | void wxMacSetupConverters(); |
1021 | void wxMacCleanupConverters(); | |
8cf73271 | 1022 | |
e17206f7 VS |
1023 | WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to ); |
1024 | WXDLLIMPEXP_BASE wxString wxMacMakeStringFromPascal( ConstStringPtr from ); | |
8cf73271 | 1025 | |
a2b77260 SC |
1026 | // filefn.cpp |
1027 | ||
e17206f7 VS |
1028 | WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); |
1029 | WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
1030 | WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
aa0cc8a1 | 1031 | |
eb89f88a SC |
1032 | #if wxUSE_GUI |
1033 | ||
1034 | // deprecating QD | |
1035 | ||
1036 | void wxMacLocalToGlobal( WindowRef window , Point*pt ); | |
1037 | void wxMacGlobalToLocal( WindowRef window , Point*pt ); | |
1038 | ||
1039 | #endif | |
1040 | ||
ebf2a1ec SC |
1041 | //--------------------------------------------------------------------------- |
1042 | // cocoa bridging utilities | |
1043 | //--------------------------------------------------------------------------- | |
1044 | ||
1045 | bool wxMacInitCocoa(); | |
1046 | ||
1047 | class wxMacAutoreleasePool | |
1048 | { | |
1049 | public : | |
1050 | wxMacAutoreleasePool(); | |
1051 | ~wxMacAutoreleasePool(); | |
1052 | private : | |
1053 | void* m_pool; | |
1054 | }; | |
1055 | ||
1056 | // NSObject | |
1057 | ||
1058 | void wxMacCocoaRelease( void* obj ); | |
1059 | void wxMacCocoaAutorelease( void* obj ); | |
1060 | void wxMacCocoaRetain( void* obj ); | |
1061 | ||
1062 | #if wxMAC_USE_COCOA | |
1063 | ||
1064 | // NSCursor | |
1065 | ||
1066 | WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); | |
1067 | WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); | |
1068 | void wxMacCocoaSetCursor( WX_NSCursor cursor ); | |
1069 | void wxMacCocoaHideCursor(); | |
1070 | void wxMacCocoaShowCursor(); | |
1071 | ||
1072 | typedef struct tagClassicCursor | |
1073 | { | |
1074 | wxUint16 bits[16]; | |
1075 | wxUint16 mask[16]; | |
1076 | wxInt16 hotspot[2]; | |
1077 | }ClassicCursor; | |
1078 | ||
1079 | #else // !wxMAC_USE_COCOA | |
1080 | ||
1081 | // non Darwin | |
1082 | ||
1083 | typedef Cursor ClassicCursor; | |
1084 | ||
1085 | #endif // wxMAC_USE_COCOA | |
1086 | ||
1087 | // ------------- | |
1088 | // Common to all | |
1089 | // ------------- | |
1090 | ||
1091 | // Cursor support | |
1092 | ||
1093 | const short kwxCursorBullseye = 0; | |
1094 | const short kwxCursorBlank = 1; | |
1095 | const short kwxCursorPencil = 2; | |
1096 | const short kwxCursorMagnifier = 3; | |
1097 | const short kwxCursorNoEntry = 4; | |
1098 | const short kwxCursorPaintBrush = 5; | |
1099 | const short kwxCursorPointRight = 6; | |
1100 | const short kwxCursorPointLeft = 7; | |
1101 | const short kwxCursorQuestionArrow = 8; | |
1102 | const short kwxCursorRightArrow = 9; | |
1103 | const short kwxCursorSizeNS = 10; | |
1104 | const short kwxCursorSize = 11; | |
1105 | const short kwxCursorSizeNESW = 12; | |
1106 | const short kwxCursorSizeNWSE = 13; | |
1107 | const short kwxCursorRoller = 14; | |
1108 | const short kwxCursorLast = kwxCursorRoller; | |
1109 | ||
1110 | // exposing our fallback cursor map | |
1111 | ||
1112 | extern ClassicCursor gMacCursors[]; | |
1113 | ||
8cf73271 SC |
1114 | #endif |
1115 | // _WX_PRIVATE_H_ |