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