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