]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/carbon/private.h
switching notebook implementation to common
[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
336 void GetBestRect( wxRect *r ) const;
337 bool IsEnabled() const;
338 void Enable( bool enable );
339 bool ButtonClickDidStateChange() { return false ;}
340 void SetMinimum( wxInt32 v );
341 void SetMaximum( wxInt32 v );
342 void PulseGauge() ;
343 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
344
345 // temp convenience methods
346
347 void GetBestRect( Rect *r ) const;
348 /*
349 void operator= (ControlRef c) { m_controlRef = c; }
350 operator ControlRef () { return m_controlRef; }
351 operator ControlRef * () { return &m_controlRef; }
352 */
353 // accessing data and values
354
355 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
356 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
357 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
358 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
359 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
360
361 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
362
363 virtual wxInt32 GetMaximum() const;
364 virtual wxInt32 GetMinimum() const;
365
366 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
367 virtual void SetRange( SInt32 minimum , SInt32 maximum );
368
369 // templated helpers
370
371 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
372 {
373 Size sz;
374 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
375 return sz;
376 }
377 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
378 {
379 return SetData( inPartCode , inTag , sizeof( T ) , data );
380 }
381 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
382 {
383 return SetData( inPartCode , inTag , sizeof( T ) , &data );
384 }
385 template <typename T> OSStatus SetData( ResType inTag , const T *data )
386 {
387 return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
388 }
389 template <typename T> OSStatus SetData( ResType inTag , const T& data )
390 {
391 return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
392 }
393 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
394 {
395 Size dummy;
396 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
397 }
398 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
399 {
400 T value;
401 OSStatus err = GetData<T>( inPartCode , inTag , &value );
402
403 if ( err != noErr )
404 {
405 wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
406 inPartCode, (int)inTag) );
407 }
408
409 return value;
410 }
411 template <typename T> OSStatus GetData( ResType inTag , T *data ) const
412 {
413 Size dummy;
414 return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
415 }
416 template <typename T> T GetData( ResType inTag ) const
417 {
418 return GetData<T>( kControlEntireControl , inTag );
419 }
420
421 // Flash the control for the specified amount of time
422
423 virtual void VisibilityChanged( bool shown );
424 virtual void SuperChangedPosition();
425
426
427 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
428 virtual void SetBackgroundColour( const wxColour& col );
429 virtual bool SetBackgroundStyle(wxBackgroundStyle style);
430 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
431 void SetActionProc( ControlActionUPP actionProc );
432 SInt32 GetViewSize() const;
433
434 virtual void SetVisibility( bool visible );
435
436 virtual bool IsActive() const;
437
438 // invalidates this control and all children
439 virtual void InvalidateWithChildren();
440 virtual void SetDrawingEnabled( bool enable );
441
442 // in native parent window relative coordinates
443
444 virtual void GetRectInWindowCoords( Rect *r );
445
446
447 virtual void GetFeatures( UInt32 *features );
448
449 // to be moved into a tab control class
450
451 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
452
453 virtual void InstallEventHandler( WXWidget control = NULL );
454 protected :
455 WXEVENTHANDLERREF m_macControlEventHandler ;
456 ControlRef m_controlRef;
457 wxFont m_font;
458 long m_windowStyle;
459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl)
460 };
461
462 // ============================================================================
463 // DataBrowser Wrapper
464 // ============================================================================
465 //
466 // basing on DataBrowserItemIDs
467 //
468
469 class WXDLLIMPEXP_CORE wxMacDataBrowserControl : public wxMacControl
470 {
471 public :
472 wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
473 wxMacDataBrowserControl() {}
474
475 OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
476
477 OSStatus GetItemCount( DataBrowserItemID container,
478 Boolean recurse,
479 DataBrowserItemState state,
480 ItemCount *numItems) const;
481
482 OSStatus GetItems( DataBrowserItemID container,
483 Boolean recurse,
484 DataBrowserItemState state,
485 Handle items) const;
486
487
488 OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
489 DataBrowserTableViewColumnIndex position );
490
491 OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
492
493 OSStatus AutoSizeColumns();
494
495 OSStatus SetHasScrollBars( bool horiz, bool vert );
496 OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
497
498 OSStatus SetHeaderButtonHeight( UInt16 height );
499 OSStatus GetHeaderButtonHeight( UInt16 *height );
500
501 OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
502 const DataBrowserItemID *items,
503 DataBrowserPropertyID preSortProperty,
504 DataBrowserPropertyID propertyID ) const;
505
506 OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
507 const DataBrowserItemID *items,
508 DataBrowserPropertyID preSortProperty );
509 OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
510 const DataBrowserItemID *items,
511 DataBrowserPropertyID preSortProperty );
512 OSStatus RevealItem( DataBrowserItemID item,
513 DataBrowserPropertyID propertyID,
514 DataBrowserRevealOptions options ) const;
515
516 OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
517 OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
518 bool IsItemSelected( DataBrowserItemID item ) const;
519 OSStatus SetSelectedItems( UInt32 numItems,
520 const DataBrowserItemID *items,
521 DataBrowserSetOption operation );
522
523 OSStatus GetItemID( DataBrowserTableViewRowIndex row,
524 DataBrowserItemID * item ) const;
525 OSStatus GetItemRow( DataBrowserItemID item,
526 DataBrowserTableViewRowIndex * row ) const;
527
528 OSStatus SetDefaultRowHeight( UInt16 height );
529 OSStatus GetDefaultRowHeight( UInt16 * height ) const;
530
531 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
532 OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
533
534 OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
535 OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
536
537 OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
538 OSStatus SetDefaultColumnWidth( UInt16 width );
539
540 OSStatus GetColumnCount( UInt32* numColumns) const;
541
542 OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
543
544 OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const;
545 OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
546
547 OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
548 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
549
550 OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
551 OSStatus SetSortProperty( DataBrowserPropertyID column );
552
553 OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
554 OSStatus SetSortOrder( DataBrowserSortOrder order );
555
556 OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
557 OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
558
559 OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
560 OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
561
562 OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
563
564 OSStatus GetItemPartBounds( DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect * bounds );
565 protected :
566
567 static pascal void DataBrowserItemNotificationProc(
568 ControlRef browser,
569 DataBrowserItemID itemID,
570 DataBrowserItemNotification message,
571 DataBrowserItemDataRef itemData );
572
573 virtual void ItemNotification(
574 DataBrowserItemID itemID,
575 DataBrowserItemNotification message,
576 DataBrowserItemDataRef itemData) = 0;
577
578 static pascal OSStatus DataBrowserGetSetItemDataProc(
579 ControlRef browser,
580 DataBrowserItemID itemID,
581 DataBrowserPropertyID property,
582 DataBrowserItemDataRef itemData,
583 Boolean changeValue );
584
585 virtual OSStatus GetSetItemData(
586 DataBrowserItemID itemID,
587 DataBrowserPropertyID property,
588 DataBrowserItemDataRef itemData,
589 Boolean changeValue ) = 0;
590
591 static pascal Boolean DataBrowserCompareProc(
592 ControlRef browser,
593 DataBrowserItemID itemOneID,
594 DataBrowserItemID itemTwoID,
595 DataBrowserPropertyID sortProperty);
596
597 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
598 DataBrowserItemID itemTwoID,
599 DataBrowserPropertyID sortProperty) = 0;
600 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl)
601 };
602
603 // ============================================================================
604 // Higher-level Databrowser
605 // ============================================================================
606 //
607 // basing on data item objects
608 //
609
610 // forward decl
611
612 class wxMacDataItemBrowserControl;
613 class wxMacListBoxItem;
614
615 const DataBrowserPropertyID kTextColumnId = 1024;
616 const DataBrowserPropertyID kNumericOrderColumnId = 1025;
617
618 // for multi-column controls, we will use this + the column ID to identify the
619 // column. We don't use kTextColumnId there, and ideally the two should merge.
620 const DataBrowserPropertyID kMinColumnId = 1050;
621
622 // base API for high-level databrowser operations
623
624 // base class for databrowser items
625
626 enum DataItemType {
627 DataItem_Text
628 };
629
630 /*
631 class WXDLLIMPEXP_CORE wxMacDataItem
632 {
633 public :
634 wxMacDataItem();
635 virtual ~wxMacDataItem();
636 } ;
637 */
638
639 class WXDLLIMPEXP_CORE wxMacDataItem
640 {
641 public :
642 wxMacDataItem();
643 virtual ~wxMacDataItem();
644
645 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
646 const wxMacDataItem*,
647 DataBrowserPropertyID property) const;
648
649 // returns true if access was successful, otherwise false
650 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
651 DataBrowserPropertyID property,
652 DataBrowserItemDataRef itemData,
653 bool changeValue );
654
655 virtual void Notification(wxMacDataItemBrowserControl *owner ,
656 DataBrowserItemNotification message,
657 DataBrowserItemDataRef itemData ) const;
658
659 void SetOrder( SInt32 order );
660 SInt32 GetOrder() const;
661
662 protected :
663 SInt32 m_order;
664
665 };
666
667 enum ListSortOrder {
668 SortOrder_None,
669 SortOrder_Text_Ascending,
670 SortOrder_Text_Descending
671 };
672
673 typedef wxMacDataItem* wxMacDataItemPtr;
674 const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
675 typedef void * wxListColumnId ;
676
677 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
678
679 class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl : public wxMacDataBrowserControl
680 {
681 public :
682 wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
683 wxMacDataItemBrowserControl() {}
684 // create a list item (can be a subclass of wxMacListBoxItem)
685
686 unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
687 void GetItems(const wxMacDataItem* container, bool recurse ,
688 DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
689
690 unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
691
692 unsigned int GetLineFromItem(const wxMacDataItem *item) const;
693 wxMacDataItem * GetItemFromLine(unsigned int n) const;
694
695 void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
696 DataBrowserPropertyID property) const;
697 void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
698 DataBrowserPropertyID property) const;
699
700 void InsertColumn(int colId, DataBrowserPropertyType colType,
701 const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
702
703 int GetColumnWidth(int colId);
704 void SetColumnWidth(int colId, int width);
705
706 void AddItem(wxMacDataItem *container, wxMacDataItem *item);
707 void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
708
709 void RemoveAllItems(wxMacDataItem *container);
710 void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
711 void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
712
713 void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
714 void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
715 void SetSelectedAllItems( DataBrowserSetOption option);
716 Boolean IsItemSelected( const wxMacDataItem* item) const;
717
718 void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
719
720 void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
721
722 // add and remove
723
724 virtual void MacDelete( unsigned int n );
725 virtual void MacInsert( unsigned int n, wxMacDataItem* item);
726 virtual void MacClear();
727
728 // accessing content
729
730 virtual unsigned int MacGetCount() const;
731
732 public :
733
734 // as we are getting the same events for human and API selection we have to suppress
735 // events in the latter case, since this will be used from many subclasses we keep it here
736
737 bool IsSelectionSuppressed() const { return m_suppressSelection; }
738 bool SuppressSelection( bool suppress );
739
740 // client data
741
742 virtual wxClientDataType GetClientDataType() const;
743 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
744 //virtual ListSortOrder GetSortOrder() const;
745 //virtual void SetSortOrder(const ListSortOrder sort);
746
747
748
749 protected:
750
751 ListSortOrder m_sortOrder;
752 wxClientDataType m_clientDataItemsType;
753
754 // ID aware base methods, should be 'final' ie not changed in subclasses
755
756 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
757 DataBrowserItemID itemTwoID,
758 DataBrowserPropertyID sortProperty);
759
760 virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
761 DataBrowserPropertyID property,
762 DataBrowserItemDataRef itemData,
763 Boolean changeValue );
764
765 virtual void ItemNotification(
766 DataBrowserItemID itemID,
767 DataBrowserItemNotification message,
768 DataBrowserItemDataRef itemData);
769
770
771 private :
772
773 bool m_suppressSelection;
774 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
775 };
776
777 class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
778 {
779 public :
780 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
781 ~wxMacDataItemBrowserSelectionSuppressor();
782
783 private :
784
785 bool m_former;
786 wxMacDataItemBrowserControl* m_browser;
787 };
788
789 // ============================================================================
790 // platform listbox implementation
791 // ============================================================================
792
793 // exposed for reuse in wxCheckListBox
794
795 class WXDLLIMPEXP_CORE wxMacListBoxItem : public wxMacDataItem
796 {
797 public :
798 wxMacListBoxItem();
799
800 virtual ~wxMacListBoxItem();
801
802 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
803 DataBrowserPropertyID property,
804 DataBrowserItemDataRef itemData,
805 bool changeValue );
806
807 virtual void Notification(wxMacDataItemBrowserControl *owner ,
808 DataBrowserItemNotification message,
809 DataBrowserItemDataRef itemData ) const;
810 protected :
811 };
812
813 class WXDLLIMPEXP_CORE wxMacDataBrowserColumn : public wxListWidgetColumn
814 {
815 public :
816 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId, DataBrowserPropertyType colType, bool editable )
817 : m_property(propertyId), m_editable(editable), m_type( colType )
818 {
819 }
820 ~wxMacDataBrowserColumn()
821 {
822 }
823 DataBrowserPropertyID GetProperty() const { return m_property ; }
824
825 bool IsEditable() const { return m_editable; }
826
827 DataBrowserPropertyType GetType() const { return m_type; }
828
829 protected :
830 DataBrowserPropertyID m_property;
831 bool m_editable;
832 DataBrowserPropertyType m_type;
833 } ;
834
835 WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn *, wxArrayMacDataBrowserColumns);
836
837
838 class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue : public wxListWidgetCellValue
839 {
840 public :
841 wxMacDataBrowserCellValue(DataBrowserItemDataRef data) : m_data(data) {}
842 virtual ~wxMacDataBrowserCellValue() {}
843
844 virtual void Set( CFStringRef value );
845 virtual void Set( const wxString& value );
846 virtual void Set( int value ) ;
847 virtual void Check( bool check );
848
849 virtual int GetIntValue() const ;
850 virtual wxString GetStringValue() const ;
851 protected :
852 DataBrowserItemDataRef m_data;
853 } ;
854
855
856 class WXDLLIMPEXP_CORE wxMacDataBrowserListControl : public wxMacDataItemBrowserControl, public wxListWidgetImpl
857 {
858 public:
859 wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
860 wxMacDataBrowserListControl() {}
861 virtual ~wxMacDataBrowserListControl();
862
863 // wxListWidgetImpl Methods
864
865 wxListWidgetColumn* InsertTextColumn( unsigned int pos, const wxString& title, bool editable = false,
866 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
867 wxListWidgetColumn* InsertCheckColumn( unsigned int pos , const wxString& title, bool editable = false,
868 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
869
870 wxMacDataBrowserColumn* DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
871 const wxString& title, bool editable,
872 DataBrowserPropertyType colType, SInt16 just, int width );
873 // add and remove
874
875 virtual void ListDelete( unsigned int n );
876 virtual void ListInsert( unsigned int n );
877 virtual void ListClear();
878
879 // selecting
880
881 virtual void ListDeselectAll();
882 virtual void ListSetSelection( unsigned int n, bool select, bool multi = false );
883 virtual int ListGetSelection() const;
884 virtual int ListGetSelections( wxArrayInt& aSelections ) const;
885 virtual bool ListIsSelected( unsigned int n ) const;
886
887 // display
888
889 virtual void ListScrollTo( unsigned int n );
890
891 // accessing content
892
893 virtual unsigned int ListGetCount() const;
894 virtual int DoListHitTest( const wxPoint& inpoint ) const;
895
896 virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL );
897 virtual void UpdateLineToEnd( unsigned int n) ;
898
899 // pointing back
900
901 wxMacDataBrowserColumn* GetColumnFromProperty( DataBrowserPropertyID );
902
903 protected:
904 virtual void ItemNotification(
905 DataBrowserItemID itemID,
906 DataBrowserItemNotification message,
907 DataBrowserItemDataRef itemData);
908
909 private:
910 wxArrayMacDataBrowserColumns m_columns;
911 int m_nextColumnId ;
912
913 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
914 };
915
916 // ============================================================================
917 // graphics implementation
918 // ============================================================================
919
920 // draw the image 'upside down' corrected as HIViewDrawCGImage does
921
922 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
923 CGContextRef inContext,
924 const HIRect * inBounds,
925 CGImageRef inImage) ;
926
927 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
928
929 #endif // wxUSE_GUI
930
931 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
932 UPP Get##x() \
933 { \
934 static UPP sHandler = NULL; \
935 if ( sHandler == NULL ) \
936 sHandler = New##UPP( x ); \
937 return sHandler; \
938 }
939
940 //---------------------------------------------------------------------------
941 // cocoa bridging utilities
942 //---------------------------------------------------------------------------
943
944 bool wxMacInitCocoa();
945
946 typedef Cursor ClassicCursor;
947
948 // -------------
949 // Common to all
950 // -------------
951
952 // Cursor support
953
954 const short kwxCursorBullseye = 0;
955 const short kwxCursorBlank = 1;
956 const short kwxCursorPencil = 2;
957 const short kwxCursorMagnifier = 3;
958 const short kwxCursorNoEntry = 4;
959 const short kwxCursorPaintBrush = 5;
960 const short kwxCursorPointRight = 6;
961 const short kwxCursorPointLeft = 7;
962 const short kwxCursorQuestionArrow = 8;
963 const short kwxCursorRightArrow = 9;
964 const short kwxCursorSizeNS = 10;
965 const short kwxCursorSize = 11;
966 const short kwxCursorSizeNESW = 12;
967 const short kwxCursorSizeNWSE = 13;
968 const short kwxCursorRoller = 14;
969 const short kwxCursorWatch = 15;
970 const short kwxCursorLast = kwxCursorWatch;
971
972 // exposing our fallback cursor map
973
974 extern ClassicCursor gMacCursors[];
975
976 //
977 //
978 //
979
980 #if wxUSE_GUI
981
982 class wxNonOwnedWindowCarbonImpl : public wxNonOwnedWindowImpl
983 {
984 public :
985 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) ;
986
987 wxNonOwnedWindowCarbonImpl();
988 virtual ~wxNonOwnedWindowCarbonImpl();
989
990 virtual void WillBeDestroyed() ;
991 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
992 long style, long extraStyle, const wxString& name ) ;
993 void Create( wxWindow* parent, WXWindow nativeWindow );
994
995 WXWindow GetWXWindow() const;
996 void Raise();
997 void Lower();
998 bool Show(bool show);
999 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
1000
1001
1002 void Update();
1003 bool SetTransparent(wxByte alpha);
1004 bool SetBackgroundColour(const wxColour& col );
1005 void SetExtraStyle( long exStyle );
1006 bool SetBackgroundStyle(wxBackgroundStyle style);
1007 bool CanSetTransparent();
1008 void MoveWindow(int x, int y, int width, int height);
1009 void GetPosition( int &x, int &y ) const;
1010 void GetSize( int &width, int &height ) const;
1011 void GetContentArea( int &left , int &top , int &width , int &height ) const;
1012
1013 bool SetShape(const wxRegion& region);
1014
1015 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
1016
1017 virtual bool IsMaximized() const;
1018
1019 virtual bool IsIconized() const;
1020
1021 virtual void Iconize( bool iconize );
1022
1023 virtual void Maximize(bool maximize);
1024
1025 virtual bool IsFullScreen() const;
1026
1027 virtual bool ShowFullScreen(bool show, long style);
1028
1029 virtual void ShowWithoutActivating();
1030
1031 virtual void RequestUserAttention(int flags);
1032
1033 virtual void ScreenToWindow( int *x, int *y );
1034
1035 virtual void WindowToScreen( int *x, int *y );
1036 virtual bool IsActive();
1037
1038
1039 bool MacGetUnifiedAppearance() const ;
1040 void MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) ;
1041 wxUint32 MacGetWindowAttributes() const ;
1042 void MacSetMetalAppearance( bool set ) ;
1043 bool MacGetMetalAppearance() const ;
1044 void MacSetUnifiedAppearance( bool set );
1045
1046 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
1047
1048 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
1049 protected :
1050 void MacInstallTopLevelWindowEventHandler();
1051
1052 WXEVENTHANDLERREF m_macEventHandler ;
1053 WindowRef m_macWindow;
1054 void * m_macFullScreenData ;
1055 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl)
1056 };
1057
1058 #endif // wxUSE_GUI
1059
1060 #endif
1061 // _WX_PRIVATE_H_