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