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