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