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