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