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