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