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