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