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