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