]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/carbon/private.h
Fix missing documentation for several GDI functions.
[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
5c6eb3a8
SC
17#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
18typedef UInt32 URefCon;
19typedef SInt32 SRefCon;
20#endif
21
22#if wxUSE_GUI
23
524c47aa
SC
24#include "wx/osx/uma.h"
25
5c6eb3a8 26#include "wx/listbox.h"
ccd5d46c
SC
27#include "wx/osx/dc.h"
28#include "wx/osx/dcclient.h"
29#include "wx/osx/dcmemory.h"
5c6eb3a8 30
5c6eb3a8
SC
31// app.h
32
33#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
34bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
35#endif
36
37#endif // wxUSE_GUI
38
39// filefn.h
40WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
41WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
42
43// utils.h
44WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum,
45 OSType folderType,
46 Boolean createFolder);
47WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum,
48 OSType folderType,
49 Boolean createFolder);
50
51template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
5398a2e0 52template<> inline EventParamType wxMacGetEventParamType<HIShapeRef>() { return typeHIShapeRef; }
5c6eb3a8
SC
53template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; }
54template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; }
55template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; }
56template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; }
57template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; }
58template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; }
59template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; }
60template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; }
61template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; }
62template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; }
63template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; }
64template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; }
65template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; }
66template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; }
67template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; }
68template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; }
69template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; }
70template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
71template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
72template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
73/*
74 These are ambiguous
75 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
76 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
77 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
78 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
79 */
80
81class WXDLLIMPEXP_CORE wxMacCarbonEvent
82{
83
84public :
85 wxMacCarbonEvent()
86 {
87 m_eventRef = 0;
88 m_release = false;
89 }
90
91 wxMacCarbonEvent( EventRef event , bool release = false )
92 {
93 m_eventRef = event;
94 m_release = release;
95 }
96
97 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
98 {
99 m_eventRef = NULL;
100 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
101 m_release = true;
102 }
103
104 ~wxMacCarbonEvent()
105 {
106 if ( m_release )
107 ReleaseEvent( m_eventRef );
108 }
109
110 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
111 {
112 verify( (m_eventRef == NULL) || m_release );
113 if ( m_eventRef && m_release )
114 {
115 ReleaseEvent( m_eventRef );
116 m_release = false;
117 m_eventRef = NULL;
118 }
119 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
120 if ( err == noErr )
121 m_release = true;
122 return err;
123 }
124
125 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
126
127 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
128 {
129 return GetParameter( inName, type , sizeof( T ) , data );
130 }
131 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
132 {
133 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
134 }
135
136 template <typename T> T GetParameter( EventParamName inName )
137 {
138 T value;
139 verify_noerr( GetParameter<T>( inName, &value ) );
140 return value;
141 }
142 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
143 {
144 T value;
145 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
146 return value;
147 }
148
149 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
150 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
151 {
152 return SetParameter( inName, inDesiredType , sizeof( T ) , data );
153 }
154 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
155 {
156 return SetParameter<T>( inName, inDesiredType , &data );
157 }
158 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
159 {
160 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
161 }
162 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
163 {
164 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
165 }
166 UInt32 GetClass()
167 {
168 return ::GetEventClass( m_eventRef );
169 }
170 UInt32 GetKind()
171 {
172 return ::GetEventKind( m_eventRef );
173 }
174 EventTime GetTime()
175 {
176 return ::GetEventTime( m_eventRef );
177 }
178 UInt32 GetTicks()
179 {
180 return EventTimeToTicks( GetTime() );
181 }
182 OSStatus SetCurrentTime( )
183 {
184 return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
185 }
186 OSStatus SetTime( EventTime when )
187 {
188 return ::SetEventTime( m_eventRef , when );
189 }
190 operator EventRef () { return m_eventRef; }
191
192 bool IsValid() { return m_eventRef != 0; }
193protected :
194 EventRef m_eventRef;
195 bool m_release;
196};
197
5c6eb3a8
SC
198#if wxUSE_GUI
199
200class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer ;
201
202class WXDLLIMPEXP_CORE wxMacToolTip
203{
204public :
205 wxMacToolTip() ;
206 ~wxMacToolTip() ;
207
208 void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ;
209 void Draw() ;
210 void Clear() ;
211
212 long GetMark()
213 { return m_mark ; }
214
215 bool IsShown()
216 { return m_shown ; }
217
218private :
219 wxString m_label ;
220 wxPoint m_position ;
221 Rect m_rect ;
222 WindowRef m_window ;
223 PicHandle m_backpict ;
224 bool m_shown ;
225 long m_mark ;
226#if wxUSE_TIMER
227 wxMacToolTipTimer* m_timer ;
228#endif
229 wxCFStringRef m_helpTextRef ;
230} ;
231
232// Quartz
233
234WXDLLIMPEXP_CORE void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
235WXDLLIMPEXP_CORE void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
5c6eb3a8
SC
236
237#define MAC_WXHBITMAP(a) (GWorldPtr(a))
238#define MAC_WXHMETAFILE(a) (PicHandle(a))
239#define MAC_WXHICON(a) (IconRef(a))
240#define MAC_WXHCURSOR(a) (CursHandle(a))
241#define MAC_WXHRGN(a) (RgnHandle(a))
242#define MAC_WXHWND(a) (WindowPtr(a))
243#define MAC_WXRECPTR(a) ((Rect*)a)
244#define MAC_WXPOINTPTR(a) ((Point*)a)
245#define MAC_WXHMENU(a) ((MenuHandle)a)
246
247struct wxOpaqueWindowRef
248{
249 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
250 operator WindowRef() { return m_data; }
251private :
252 WindowRef m_data;
253};
254
255WXDLLIMPEXP_CORE void wxMacRectToNative( const wxRect *wx , Rect *n );
256WXDLLIMPEXP_CORE void wxMacNativeToRect( const Rect *n , wxRect* wx );
257WXDLLIMPEXP_CORE void wxMacPointToNative( const wxPoint* wx , Point *n );
258WXDLLIMPEXP_CORE void wxMacNativeToPoint( const Point *n , wxPoint* wx );
259
5c6eb3a8
SC
260WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
261
262WXDLLIMPEXP_CORE int wxMacCommandToId( UInt32 macCommandId );
263WXDLLIMPEXP_CORE UInt32 wxIdToMacCommand( int wxId );
264WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
265
5c6eb3a8 266WXDLLIMPEXP_CORE pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data );
bcb07ff0 267WXDLLIMPEXP_CORE Rect wxMacGetBoundsForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true );
5c6eb3a8
SC
268
269ControlActionUPP GetwxMacLiveScrollbarActionProc();
270
271// additional optional event defines
272
273#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
274enum {
275 kEventControlFocusPartChanged = 164
276};
277#endif
278
bcb07ff0 279class WXDLLIMPEXP_CORE wxMacControl : public wxWidgetImpl
5c6eb3a8
SC
280{
281public :
415f4a01 282 wxMacControl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false );
5c6eb3a8
SC
283 wxMacControl() ;
284 virtual ~wxMacControl();
285
286 void Init();
287
5c6eb3a8
SC
288 void SetReferenceInNativeControl();
289 static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
290
291 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
292 virtual ControlRef GetControlRef() const { return m_controlRef; }
293
bcb07ff0
SC
294 virtual WXWidget GetWXWidget() const { return (WXWidget) m_controlRef; }
295
bcb07ff0
SC
296 virtual bool IsVisible() const;
297
298 virtual void Raise();
03647350 299
bcb07ff0
SC
300 virtual void Lower();
301
302 virtual void ScrollRect( const wxRect *rect, int dx, int dy );
303
03647350 304 virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
bcb07ff0
SC
305 virtual void Move(int x, int y, int width, int height);
306 virtual void GetPosition( int &x, int &y ) const;
307 virtual void GetSize( int &width, int &height ) const;
524c47aa 308 virtual void SetControlSize( wxWindowVariant variant ) ;
bcb07ff0
SC
309
310 // where is in native window relative coordinates
311 virtual void SetNeedsDisplay( const wxRect* where = NULL );
312 virtual bool GetNeedsDisplay() const;
03647350 313
bcb07ff0
SC
314 virtual bool CanFocus() const;
315 // return true if successful
316 virtual bool SetFocus();
317 virtual bool HasFocus() const;
318
319 void RemoveFromParent();
320 void Embed( wxWidgetImpl *parent );
03647350 321
524c47aa
SC
322 void SetDefaultButton( bool isDefault );
323 void PerformClick();
324 void SetLabel( const wxString& title, wxFontEncoding encoding );
325
54f11060
SC
326 void SetCursor( const wxCursor & cursor );
327 void CaptureMouse();
328 void ReleaseMouse();
329
524c47aa
SC
330 wxInt32 GetValue() const;
331 void SetValue( wxInt32 v );
e5d05b90 332 wxBitmap GetBitmap() const;
524c47aa 333 void SetBitmap( const wxBitmap& bitmap );
e5d05b90 334 void SetBitmapPosition( wxDirection dir );
524c47aa
SC
335
336 void GetBestRect( wxRect *r ) const;
337 bool IsEnabled() const;
338 void Enable( bool enable );
339 bool ButtonClickDidStateChange() { return false ;}
340 void SetMinimum( wxInt32 v );
341 void SetMaximum( wxInt32 v );
342 void PulseGauge() ;
343 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
344
345 // temp convenience methods
346
347 void GetBestRect( Rect *r ) const;
5c6eb3a8
SC
348 /*
349 void operator= (ControlRef c) { m_controlRef = c; }
350 operator ControlRef () { return m_controlRef; }
351 operator ControlRef * () { return &m_controlRef; }
352 */
353 // accessing data and values
354
355 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
356 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
357 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
358 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
359 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
360
361 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
362
19c7ac3d
SC
363 virtual wxInt32 GetMaximum() const;
364 virtual wxInt32 GetMinimum() const;
03647350 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 428 virtual void SetBackgroundColour( const wxColour& col );
bc5c09a3 429 virtual bool SetBackgroundStyle(wxBackgroundStyle style);
5c6eb3a8
SC
430 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
431 void SetActionProc( ControlActionUPP actionProc );
5c6eb3a8
SC
432 SInt32 GetViewSize() const;
433
bcb07ff0 434 virtual void SetVisibility( bool visible );
524c47aa 435
5c6eb3a8 436 virtual bool IsActive() const;
5c6eb3a8
SC
437
438 // invalidates this control and all children
439 virtual void InvalidateWithChildren();
440 virtual void SetDrawingEnabled( bool enable );
5c6eb3a8
SC
441
442 // in native parent window relative coordinates
5c6eb3a8
SC
443
444 virtual void GetRectInWindowCoords( Rect *r );
bcb07ff0 445
5c6eb3a8
SC
446
447 virtual void GetFeatures( UInt32 *features );
03647350 448
bcb07ff0 449 // to be moved into a tab control class
5c6eb3a8 450
bcb07ff0 451 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
5c6eb3a8 452
4dd9fdf8 453 virtual 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 );
51c72a7b
JS
563
564 OSStatus GetItemPartBounds( DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect * bounds );
5c6eb3a8
SC
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
03647350 639class WXDLLIMPEXP_CORE wxMacDataItem
524c47aa 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 // as we are getting the same events for human and API selection we have to suppress
735 // events in the latter case, since this will be used from many subclasses we keep it here
736
737 bool IsSelectionSuppressed() const { return m_suppressSelection; }
738 bool SuppressSelection( bool suppress );
739
5c6eb3a8
SC
740 // client data
741
742 virtual wxClientDataType GetClientDataType() const;
743 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
744 //virtual ListSortOrder GetSortOrder() const;
745 //virtual void SetSortOrder(const ListSortOrder sort);
746
747
748
749protected:
750
751 ListSortOrder m_sortOrder;
752 wxClientDataType m_clientDataItemsType;
753
754 // ID aware base methods, should be 'final' ie not changed in subclasses
755
756 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
757 DataBrowserItemID itemTwoID,
758 DataBrowserPropertyID sortProperty);
759
760 virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
761 DataBrowserPropertyID property,
762 DataBrowserItemDataRef itemData,
763 Boolean changeValue );
764
765 virtual void ItemNotification(
766 DataBrowserItemID itemID,
767 DataBrowserItemNotification message,
768 DataBrowserItemDataRef itemData);
769
770
771private :
772
773 bool m_suppressSelection;
774 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
775};
776
777class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
778{
779public :
780 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
781 ~wxMacDataItemBrowserSelectionSuppressor();
782
783private :
784
785 bool m_former;
786 wxMacDataItemBrowserControl* m_browser;
787};
788
789// ============================================================================
790// platform listbox implementation
791// ============================================================================
792
793// exposed for reuse in wxCheckListBox
794
795class WXDLLIMPEXP_CORE wxMacListBoxItem : public wxMacDataItem
796{
797public :
798 wxMacListBoxItem();
799
800 virtual ~wxMacListBoxItem();
801
524c47aa
SC
802 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
803 DataBrowserPropertyID property,
804 DataBrowserItemDataRef itemData,
805 bool changeValue );
806
5c6eb3a8
SC
807 virtual void Notification(wxMacDataItemBrowserControl *owner ,
808 DataBrowserItemNotification message,
809 DataBrowserItemDataRef itemData ) const;
524c47aa 810protected :
5c6eb3a8
SC
811};
812
524c47aa
SC
813class WXDLLIMPEXP_CORE wxMacDataBrowserColumn : public wxListWidgetColumn
814{
815public :
03647350 816 wxMacDataBrowserColumn( DataBrowserPropertyID propertyId, DataBrowserPropertyType colType, bool editable )
524c47aa
SC
817 : m_property(propertyId), m_editable(editable), m_type( colType )
818 {
819 }
820 ~wxMacDataBrowserColumn()
821 {
822 }
823 DataBrowserPropertyID GetProperty() const { return m_property ; }
03647350 824
524c47aa 825 bool IsEditable() const { return m_editable; }
03647350 826
524c47aa
SC
827 DataBrowserPropertyType GetType() const { return m_type; }
828
829protected :
830 DataBrowserPropertyID m_property;
831 bool m_editable;
832 DataBrowserPropertyType m_type;
833} ;
834
835WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn *, wxArrayMacDataBrowserColumns);
836
837
838class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue : public wxListWidgetCellValue
839{
840public :
841 wxMacDataBrowserCellValue(DataBrowserItemDataRef data) : m_data(data) {}
842 virtual ~wxMacDataBrowserCellValue() {}
03647350 843
60ebcb8a 844 virtual void Set( CFStringRef value );
524c47aa
SC
845 virtual void Set( const wxString& value );
846 virtual void Set( int value ) ;
60ebcb8a 847 virtual void Check( bool check );
03647350 848
524c47aa
SC
849 virtual int GetIntValue() const ;
850 virtual wxString GetStringValue() const ;
851protected :
852 DataBrowserItemDataRef m_data;
853} ;
854
855
856class WXDLLIMPEXP_CORE wxMacDataBrowserListControl : public wxMacDataItemBrowserControl, public wxListWidgetImpl
5c6eb3a8
SC
857{
858public:
859 wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
860 wxMacDataBrowserListControl() {}
861 virtual ~wxMacDataBrowserListControl();
862
524c47aa 863 // wxListWidgetImpl Methods
5c6eb3a8 864
524c47aa
SC
865 wxListWidgetColumn* InsertTextColumn( unsigned int pos, const wxString& title, bool editable = false,
866 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
03647350 867 wxListWidgetColumn* InsertCheckColumn( unsigned int pos , const wxString& title, bool editable = false,
524c47aa
SC
868 wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
869
03647350 870 wxMacDataBrowserColumn* DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
524c47aa
SC
871 const wxString& title, bool editable,
872 DataBrowserPropertyType colType, SInt16 just, int width );
873 // add and remove
874
875 virtual void ListDelete( unsigned int n );
876 virtual void ListInsert( unsigned int n );
877 virtual void ListClear();
878
879 // selecting
880
881 virtual void ListDeselectAll();
882 virtual void ListSetSelection( unsigned int n, bool select, bool multi = false );
883 virtual int ListGetSelection() const;
884 virtual int ListGetSelections( wxArrayInt& aSelections ) const;
885 virtual bool ListIsSelected( unsigned int n ) const;
886
887 // display
888
889 virtual void ListScrollTo( unsigned int n );
890
891 // accessing content
892
893 virtual unsigned int ListGetCount() const;
20196e15 894 virtual int DoListHitTest( const wxPoint& inpoint ) const;
524c47aa
SC
895
896 virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL );
897 virtual void UpdateLineToEnd( unsigned int n) ;
898
cff9681b
PC
899 // pointing back
900
901 wxMacDataBrowserColumn* GetColumnFromProperty( DataBrowserPropertyID );
902
903protected:
524c47aa 904 virtual void ItemNotification(
0698ed3c 905 DataBrowserItemID itemID,
524c47aa
SC
906 DataBrowserItemNotification message,
907 DataBrowserItemDataRef itemData);
5c6eb3a8 908
524c47aa
SC
909private:
910 wxArrayMacDataBrowserColumns m_columns;
911 int m_nextColumnId ;
5c6eb3a8
SC
912
913 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
914};
915
916// ============================================================================
917// graphics implementation
918// ============================================================================
919
920// draw the image 'upside down' corrected as HIViewDrawCGImage does
921
922OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
923 CGContextRef inContext,
924 const HIRect * inBounds,
925 CGImageRef inImage) ;
926
927CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
928
5c6eb3a8
SC
929#endif // wxUSE_GUI
930
931#define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
932UPP Get##x() \
933{ \
934 static UPP sHandler = NULL; \
935 if ( sHandler == NULL ) \
936 sHandler = New##UPP( x ); \
937 return sHandler; \
938}
939
5c6eb3a8
SC
940//---------------------------------------------------------------------------
941// cocoa bridging utilities
942//---------------------------------------------------------------------------
943
944bool wxMacInitCocoa();
945
5c6eb3a8
SC
946typedef Cursor ClassicCursor;
947
5c6eb3a8
SC
948// -------------
949// Common to all
950// -------------
951
952// Cursor support
953
954const short kwxCursorBullseye = 0;
955const short kwxCursorBlank = 1;
956const short kwxCursorPencil = 2;
957const short kwxCursorMagnifier = 3;
958const short kwxCursorNoEntry = 4;
959const short kwxCursorPaintBrush = 5;
960const short kwxCursorPointRight = 6;
961const short kwxCursorPointLeft = 7;
962const short kwxCursorQuestionArrow = 8;
963const short kwxCursorRightArrow = 9;
964const short kwxCursorSizeNS = 10;
965const short kwxCursorSize = 11;
966const short kwxCursorSizeNESW = 12;
967const short kwxCursorSizeNWSE = 13;
968const short kwxCursorRoller = 14;
e878c347
SC
969const short kwxCursorWatch = 15;
970const short kwxCursorLast = kwxCursorWatch;
5c6eb3a8
SC
971
972// exposing our fallback cursor map
973
974extern ClassicCursor gMacCursors[];
975
bcb07ff0
SC
976//
977//
978//
979
980#if wxUSE_GUI
981
982class wxNonOwnedWindowCarbonImpl : public wxNonOwnedWindowImpl
983{
984public :
985 wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) ;
17e2694c 986
bcb07ff0
SC
987 wxNonOwnedWindowCarbonImpl();
988 virtual ~wxNonOwnedWindowCarbonImpl();
03647350 989
0aaa6ace 990 virtual void WillBeDestroyed() ;
bcb07ff0
SC
991 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
992 long style, long extraStyle, const wxString& name ) ;
17e2694c 993 void Create( wxWindow* parent, WXWindow nativeWindow );
03647350 994
bcb07ff0 995 WXWindow GetWXWindow() const;
03647350 996 void Raise();
bcb07ff0 997 void Lower();
03647350 998 bool Show(bool show);
bcb07ff0 999 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
03647350 1000
bcb07ff0
SC
1001
1002 void Update();
1003 bool SetTransparent(wxByte alpha);
1004 bool SetBackgroundColour(const wxColour& col );
03647350
VZ
1005 void SetExtraStyle( long exStyle );
1006 bool SetBackgroundStyle(wxBackgroundStyle style);
bcb07ff0
SC
1007 bool CanSetTransparent();
1008 void MoveWindow(int x, int y, int width, int height);
1009 void GetPosition( int &x, int &y ) const;
1010 void GetSize( int &width, int &height ) const;
03647350 1011 void GetContentArea( int &left , int &top , int &width , int &height ) const;
bcb07ff0
SC
1012
1013 bool SetShape(const wxRegion& region);
1014
1015 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
03647350 1016
bcb07ff0 1017 virtual bool IsMaximized() const;
03647350 1018
bcb07ff0 1019 virtual bool IsIconized() const;
03647350 1020
bcb07ff0 1021 virtual void Iconize( bool iconize );
03647350 1022
bcb07ff0 1023 virtual void Maximize(bool maximize);
03647350 1024
bcb07ff0 1025 virtual bool IsFullScreen() const;
03647350 1026
bcb07ff0 1027 virtual bool ShowFullScreen(bool show, long style);
ce00f59b 1028
dbc7ceb9 1029 virtual void ShowWithoutActivating();
bcb07ff0
SC
1030
1031 virtual void RequestUserAttention(int flags);
03647350 1032
bcb07ff0 1033 virtual void ScreenToWindow( int *x, int *y );
03647350 1034
bcb07ff0 1035 virtual void WindowToScreen( int *x, int *y );
dbc7ceb9 1036 virtual bool IsActive();
03647350 1037
bcb07ff0
SC
1038
1039 bool MacGetUnifiedAppearance() const ;
1040 void MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) ;
1041 wxUint32 MacGetWindowAttributes() const ;
1042 void MacSetMetalAppearance( bool set ) ;
1043 bool MacGetMetalAppearance() const ;
1044 void MacSetUnifiedAppearance( bool set );
03647350 1045
bcb07ff0
SC
1046 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
1047
1048 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
1049protected :
1050 void MacInstallTopLevelWindowEventHandler();
03647350 1051
bcb07ff0
SC
1052 WXEVENTHANDLERREF m_macEventHandler ;
1053 WindowRef m_macWindow;
1054 void * m_macFullScreenData ;
03647350
VZ
1055 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl)
1056};
bcb07ff0
SC
1057
1058#endif // wxUSE_GUI
1059
5c6eb3a8
SC
1060#endif
1061 // _WX_PRIVATE_H_