DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
public:
- wxMacPortStateHelper( GrafPtr newport) ;
- wxMacPortStateHelper() ;
- ~wxMacPortStateHelper() ;
+ wxMacPortStateHelper( GrafPtr newport);
+ wxMacPortStateHelper();
+ ~wxMacPortStateHelper();
- void Setup( GrafPtr newport ) ;
- void Clear() ;
- bool IsCleared() { return m_clip == NULL ; }
- GrafPtr GetCurrentPort() { return m_currentPort ; }
+ void Setup( GrafPtr newport );
+ void Clear();
+ bool IsCleared() { return m_clip == NULL; }
+ GrafPtr GetCurrentPort() { return m_currentPort; }
private:
- GrafPtr m_currentPort ;
- GrafPtr m_oldPort ;
- RgnHandle m_clip ;
- ThemeDrawingState m_drawingState ;
- short m_textFont ;
- short m_textSize ;
- short m_textStyle ;
- short m_textMode ;
-} ;
+ GrafPtr m_currentPort;
+ GrafPtr m_oldPort;
+ RgnHandle m_clip;
+ ThemeDrawingState m_drawingState;
+ short m_textFont;
+ short m_textSize;
+ short m_textStyle;
+ short m_textMode;
+};
class WXDLLEXPORT wxMacPortSaver
{
wxMacPortSaver( GrafPtr port );
~wxMacPortSaver();
private :
- GrafPtr m_port ;
-} ;
+ GrafPtr m_port;
+};
class WXDLLEXPORT wxMacPortSetter
{
DECLARE_NO_COPY_CLASS(wxMacPortSetter)
public:
- wxMacPortSetter( const wxDC* dc ) ;
- ~wxMacPortSetter() ;
+ wxMacPortSetter( const wxDC* dc );
+ ~wxMacPortSetter();
private:
- wxMacPortStateHelper m_ph ;
- const wxDC* m_dc ;
-} ;
+ wxMacPortStateHelper m_ph;
+ const wxDC* m_dc;
+};
/*
Clips to the visible region of a control within the current port
DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
public:
- wxMacWindowClipper( const wxWindow* win ) ;
- ~wxMacWindowClipper() ;
+ wxMacWindowClipper( const wxWindow* win );
+ ~wxMacWindowClipper();
private:
- GrafPtr m_newPort ;
- RgnHandle m_formerClip ;
- RgnHandle m_newClip ;
-} ;
+ GrafPtr m_newPort;
+ RgnHandle m_formerClip;
+ RgnHandle m_newClip;
+};
class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
{
DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
public:
- wxMacWindowStateSaver( const wxWindow* win ) ;
- ~wxMacWindowStateSaver() ;
+ wxMacWindowStateSaver( const wxWindow* win );
+ ~wxMacWindowStateSaver();
private:
- GrafPtr m_newPort ;
- ThemeDrawingState m_themeDrawingState ;
-} ;
+ GrafPtr m_newPort;
+ ThemeDrawingState m_themeDrawingState;
+};
#if wxMAC_USE_CORE_GRAPHICS
class WXDLLEXPORT wxMacCGContextStateSaver
public:
wxMacCGContextStateSaver( CGContextRef cg )
{
- m_cg = cg ;
- CGContextSaveGState( cg ) ;
+ m_cg = cg;
+ CGContextSaveGState( cg );
}
~wxMacCGContextStateSaver()
{
- CGContextRestoreGState( m_cg ) ;
+ CGContextRestoreGState( m_cg );
}
private:
- CGContextRef m_cg ;
-} ;
+ CGContextRef m_cg;
+};
#endif
/*
DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
public:
- wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
- ~wxMacDrawingHelper() ;
- bool Ok() { return m_ok ; }
- void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
- void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
- void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
- const Point& GetOrigin() { return m_origin ; }
+ wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
+ ~wxMacDrawingHelper();
+ bool Ok() { return m_ok; }
+ void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
+ void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
+ void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
+ const Point& GetOrigin() { return m_origin; }
private:
- Point m_origin ;
- GrafPtr m_formerPort ;
- GrafPtr m_currentPort ;
- PenState m_savedPenState ;
- bool m_ok ;
-} ;
+ Point m_origin;
+ GrafPtr m_formerPort;
+ GrafPtr m_currentPort;
+ PenState m_savedPenState;
+ bool m_ok;
+};
*/
// app.h
-bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
+bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
#endif // wxUSE_GUI
// filefn.h
-WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
-WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
+WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
+WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
// utils.h
WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
OSType folderType,
Boolean createFolder);
-template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; }
-template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle ; }
-template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef ; }
-template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef ; }
-template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef ; }
-template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef ; }
-template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint ; }
-template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle ; }
-template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean ; }
-template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16 ; }
-template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32 ; }
-template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32 ; }
-template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor ; }
+template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
+template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; }
+template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; }
+template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; }
+template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; }
+template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; }
+template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; }
+template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; }
+template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; }
+template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; }
+template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; }
+template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; }
+template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; }
#if TARGET_API_MAC_OSX
-template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; }
-template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; }
-template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; }
-template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; }
-template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; }
+template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; }
+template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; }
+template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; }
+template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; }
+template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; }
#endif
#if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
-template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef ; }
+template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
#endif
-template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; }
-template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef ; }
+template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
+template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
/*
These are ambiguous
- template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; }
- template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; }
- template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; }
- template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; }
+ template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
+ template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
+ template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
+ template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
*/
class wxMacCarbonEvent
public :
wxMacCarbonEvent()
{
- m_eventRef = 0 ;
- m_release = false ;
+ m_eventRef = 0;
+ m_release = false;
}
wxMacCarbonEvent( EventRef event , bool release = false )
{
- m_eventRef = event ;
- m_release = release ;
+ m_eventRef = event;
+ m_release = release;
}
wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
{
- m_eventRef = NULL ;
- verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ;
- m_release = true ;
+ m_eventRef = NULL;
+ verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
+ m_release = true;
}
~wxMacCarbonEvent()
{
if ( m_release )
- ReleaseEvent( m_eventRef ) ;
+ ReleaseEvent( m_eventRef );
}
OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
{
- verify( (m_eventRef == NULL) || m_release ) ;
+ verify( (m_eventRef == NULL) || m_release );
if ( m_eventRef && m_release )
{
- ReleaseEvent( m_eventRef ) ;
- m_release = false ;
- m_eventRef = NULL ;
+ ReleaseEvent( m_eventRef );
+ m_release = false;
+ m_eventRef = NULL;
}
- OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ;
+ OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
if ( err == noErr )
- m_release = true ;
- return err ;
+ m_release = true;
+ return err;
}
- OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ;
+ OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
{
- return GetParameter( inName, type , sizeof( T ) , data ) ;
+ return GetParameter( inName, type , sizeof( T ) , data );
}
template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
{
- return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
+ return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
}
template <typename T> T GetParameter( EventParamName inName )
{
- T value ;
- verify_noerr( GetParameter<T>( inName, &value ) ) ;
- return value ;
+ T value;
+ verify_noerr( GetParameter<T>( inName, &value ) );
+ return value;
}
template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
{
- T value ;
- verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ;
- return value ;
+ T value;
+ verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
+ return value;
}
- OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ;
+ OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
{
- return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ;
+ return SetParameter( inName, inDesiredType , sizeof( T ) , data );
}
template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
{
- return SetParameter<T>( inName, inDesiredType , &data ) ;
+ return SetParameter<T>( inName, inDesiredType , &data );
}
template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
{
- return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
+ return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
}
template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
{
- return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ;
+ return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
}
UInt32 GetClass()
{
- return ::GetEventClass( m_eventRef ) ;
+ return ::GetEventClass( m_eventRef );
}
UInt32 GetKind()
{
- return ::GetEventKind( m_eventRef ) ;
+ return ::GetEventKind( m_eventRef );
}
EventTime GetTime()
{
- return ::GetEventTime( m_eventRef ) ;
+ return ::GetEventTime( m_eventRef );
}
UInt32 GetTicks()
{
- return EventTimeToTicks( GetTime() ) ;
+ return EventTimeToTicks( GetTime() );
}
OSStatus SetCurrentTime( )
{
- return ::SetEventTime( m_eventRef , GetCurrentEventTime() ) ;
+ return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
}
OSStatus SetTime( EventTime when )
{
- return ::SetEventTime( m_eventRef , when ) ;
+ return ::SetEventTime( m_eventRef , when );
}
operator EventRef () { return m_eventRef; }
- bool IsValid() { return m_eventRef != 0 ; }
+ bool IsValid() { return m_eventRef != 0; }
protected :
- EventRef m_eventRef ;
- bool m_release ;
-} ;
+ EventRef m_eventRef;
+ bool m_release;
+};
//
// helper class for allocating and deallocating Universal Proc Ptrs
public :
wxMacUPP( procType proc )
{
- m_upp = NULL ;
- m_upp = (*newUPP)( NULL ) ;
+ m_upp = NULL;
+ m_upp = (*newUPP)( NULL );
}
~wxMacUPP()
{
if ( m_upp )
- disposeUPP( m_upp ) ;
+ disposeUPP( m_upp );
}
- operator uppType() { return m_upp ; }
+ operator uppType() { return m_upp; }
private :
- uppType m_upp ;
-} ;
+ uppType m_upp;
+};
-typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
+typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP;
template <typename refType> class wxMacCFRefHolder
{
~wxMacCFRefHolder()
{
- Release() ;
+ Release();
}
void Release()
{
if ( m_release && m_ref != NULL )
- CFRelease( m_ref ) ;
- m_ref = NULL ;
+ CFRelease( m_ref );
+ m_ref = NULL;
}
refType Detach()
{
- refType val = m_ref ;
- m_release = false ;
- m_ref = NULL ;
- return val ;
+ refType val = m_ref;
+ m_release = false;
+ m_ref = NULL;
+ return val;
}
void Set( refType ref , bool release = true )
{
- Release() ;
- m_release = release ;
- m_ref = ref ;
+ Release();
+ m_release = release;
+ m_ref = ref;
}
operator refType () const { return m_ref; }
private :
- refType m_ref ;
- bool m_release ;
+ refType m_ref;
+ bool m_release;
DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
-} ;
+};
#if wxUSE_GUI
+
+#include "wx/listbox.h"
+
/*
-GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
-void wxMacDestroyGWorld( GWorldPtr gw ) ;
-PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
-CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
-void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
-CTabHandle wxMacCreateColorTable( int numColors ) ;
+GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
+void wxMacDestroyGWorld( GWorldPtr gw );
+PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
+CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
+void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
+CTabHandle wxMacCreateColorTable( int numColors );
*/
-void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
-void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
+void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
+void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
struct wxOpaqueWindowRef
{
- wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; }
- operator WindowRef() { return m_data ; }
+ wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
+ operator WindowRef() { return m_data; }
private :
- WindowRef m_data ;
-} ;
+ WindowRef m_data;
+};
-void wxMacRectToNative( const wxRect *wx , Rect *n ) ;
-void wxMacNativeToRect( const Rect *n , wxRect* wx ) ;
-void wxMacPointToNative( const wxPoint* wx , Point *n ) ;
-void wxMacNativeToPoint( const Point *n , wxPoint* wx ) ;
+void wxMacRectToNative( const wxRect *wx , Rect *n );
+void wxMacNativeToRect( const Rect *n , wxRect* wx );
+void wxMacPointToNative( const wxPoint* wx , Point *n );
+void wxMacNativeToPoint( const Point *n , wxPoint* wx );
-wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ;
-wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ;
-wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ;
+wxWindow * wxFindControlFromMacControl(ControlRef inControl );
+wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow );
+wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
-int wxMacCommandToId( UInt32 macCommandId ) ;
-UInt32 wxIdToMacCommand( int wxId ) ;
-wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ) ;
+int wxMacCommandToId( UInt32 macCommandId );
+UInt32 wxIdToMacCommand( int wxId );
+wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
-extern wxWindow* g_MacLastWindow ;
-pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
-Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ;
+extern wxWindow* g_MacLastWindow;
+pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data );
+Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true );
-ControlActionUPP GetwxMacLiveScrollbarActionProc() ;
+ControlActionUPP GetwxMacLiveScrollbarActionProc();
class wxMacControl
{
public :
- wxMacControl( wxWindow* peer , bool isRootControl = false ) ;
- wxMacControl( wxWindow* peer , ControlRef control ) ;
- wxMacControl( wxWindow* peer , WXWidget control ) ;
- virtual ~wxMacControl() ;
+ wxMacControl( wxWindow* peer , bool isRootControl = false );
+ wxMacControl( wxWindow* peer , ControlRef control );
+ wxMacControl( wxWindow* peer , WXWidget control );
+ virtual ~wxMacControl();
+
+ void Init();
- void Init() ;
+ virtual void Dispose();
- virtual void Dispose() ;
+ bool Ok() const { return GetControlRef() != NULL; }
- bool Ok() const { return GetControlRef() != NULL ; }
+ void SetReferenceInNativeControl();
+ static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
- virtual ControlRef GetControlRef() const { return m_controlRef ; }
+ virtual ControlRef GetControlRef() const { return m_controlRef; }
- virtual void SetReference( SInt32 data ) ;
+ virtual void SetReference( SInt32 data );
/*
- void operator= (ControlRef c) { m_controlRef = c ; }
+ void operator= (ControlRef c) { m_controlRef = c; }
operator ControlRef () { return m_controlRef; }
operator ControlRef * () { return &m_controlRef; }
*/
// accessing data and values
- virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ;
- virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ;
- virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ;
- virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ;
- virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ;
+ virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
+ virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
+ virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
+ virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
+ virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
- virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ;
+ virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
- virtual SInt32 GetValue() const ;
- virtual SInt32 GetMaximum() const ;
- virtual SInt32 GetMinimum() const ;
+ virtual SInt32 GetValue() const;
+ virtual SInt32 GetMaximum() const;
+ virtual SInt32 GetMinimum() const;
- virtual void SetValue( SInt32 v ) ;
- virtual void SetMinimum( SInt32 v ) ;
- virtual void SetMaximum( SInt32 v ) ;
+ virtual void SetValue( SInt32 v );
+ virtual void SetMinimum( SInt32 v );
+ virtual void SetMaximum( SInt32 v );
- virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ;
- virtual void SetRange( SInt32 minimum , SInt32 maximum ) ;
+ virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
+ virtual void SetRange( SInt32 minimum , SInt32 maximum );
- virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
- virtual bool HasFocus() const ;
- virtual bool NeedsFocusRect() const ;
- virtual void SetNeedsFocusRect( bool needs ) ;
+ virtual OSStatus SetFocus( ControlFocusPart focusPart );
+ virtual bool HasFocus() const;
+ virtual bool NeedsFocusRect() const;
+ virtual void SetNeedsFocusRect( bool needs );
// templated helpers
Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
{
- Size sz ;
- verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ;
- return sz ;
+ Size sz;
+ verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
+ return sz;
}
template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
{
- return SetData( inPartCode , inTag , sizeof( T ) , data ) ;
+ return SetData( inPartCode , inTag , sizeof( T ) , data );
}
template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
{
- return SetData( inPartCode , inTag , sizeof( T ) , &data ) ;
+ return SetData( inPartCode , inTag , sizeof( T ) , &data );
}
template <typename T> OSStatus SetData( ResType inTag , const T *data )
{
- return SetData( kControlEntireControl , inTag , sizeof( T ) , data ) ;
+ return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
}
template <typename T> OSStatus SetData( ResType inTag , const T& data )
{
- return SetData( kControlEntireControl , inTag , sizeof( T ) , &data ) ;
+ return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
}
template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
{
- Size dummy ;
- return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ;
+ Size dummy;
+ return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
}
template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
{
- T value ;
- verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ;
- return value ;
+ T value;
+ OSStatus err = GetData<T>( inPartCode , inTag , &value );
+
+ wxASSERT_MSG(err == noErr, wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
+ inPartCode, inTag));
+ return value;
}
template <typename T> OSStatus GetData( ResType inTag , T *data ) const
{
- Size dummy ;
- return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy ) ;
+ Size dummy;
+ return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
}
template <typename T> T GetData( ResType inTag ) const
{
- T value ;
- verify_noerr( GetData<T>( kControlEntireControl , inTag , &value ) ) ;
- return value ;
+ return GetData<T>( kControlEntireControl , inTag );
}
// Flash the control for the specified amount of time
- virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
+ virtual void Flash( ControlPartCode part , UInt32 ticks = 8 );
- virtual void VisibilityChanged( bool shown ) ;
- virtual void SuperChangedPosition() ;
+ virtual void VisibilityChanged( bool shown );
+ virtual void SuperChangedPosition();
- virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
- virtual void SetBackground( const wxBrush &brush ) ;
- virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ;
- void SetActionProc( ControlActionUPP actionProc ) ;
- void SetViewSize( SInt32 viewSize ) ;
- SInt32 GetViewSize() const ;
+ virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
+ virtual void SetBackground( const wxBrush &brush );
+ virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
+ void SetActionProc( ControlActionUPP actionProc );
+ void SetViewSize( SInt32 viewSize );
+ SInt32 GetViewSize() const;
- virtual bool IsVisible() const ;
- virtual void SetVisibility( bool visible , bool redraw ) ;
- virtual bool IsEnabled() const ;
- virtual bool IsActive() const ;
- virtual void Enable( bool enable ) ;
+ virtual bool IsVisible() const;
+ virtual void SetVisibility( bool visible , bool redraw );
+ virtual bool IsEnabled() const;
+ virtual bool IsActive() const;
+ virtual void Enable( bool enable );
// invalidates this control and all children
- virtual void InvalidateWithChildren() ;
- virtual void SetDrawingEnabled( bool enable ) ;
+ virtual void InvalidateWithChildren();
+ virtual void SetDrawingEnabled( bool enable );
#ifdef __WXMAC_OSX__
- virtual bool GetNeedsDisplay() const ;
+ virtual bool GetNeedsDisplay() const;
#endif
// where is in native window relative coordinates
- virtual void SetNeedsDisplay( RgnHandle where ) ;
+ virtual void SetNeedsDisplay( RgnHandle where );
// where is in native window relative coordinates
- virtual void SetNeedsDisplay( Rect* where = NULL ) ;
+ virtual void SetNeedsDisplay( Rect* where = NULL );
// if rect = NULL, entire view
- virtual void ScrollRect( wxRect *rect , int dx , int dy ) ;
+ virtual void ScrollRect( wxRect *rect , int dx , int dy );
// in native parent window relative coordinates
- virtual void GetRect( Rect *r ) ;
+ virtual void GetRect( Rect *r );
// in native parent window relative coordinates
- virtual void SetRect( Rect *r ) ;
+ virtual void SetRect( Rect *r );
- virtual void GetRectInWindowCoords( Rect *r ) ;
- virtual void GetBestRect( Rect *r ) ;
- virtual void SetLabel( const wxString &title ) ;
+ virtual void GetRectInWindowCoords( Rect *r );
+ virtual void GetBestRect( Rect *r );
+ virtual void SetLabel( const wxString &title );
// converts from Toplevel-Content relative to local
- static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ;
+ static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to );
- virtual void GetFeatures( UInt32 *features ) ;
- virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ;
- virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ;
+ virtual void GetFeatures( UInt32 *features );
+ virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region );
+ virtual OSStatus SetZOrder( bool above , wxMacControl* other );
- bool IsCompositing() { return m_isCompositing ; }
- bool IsRootControl() { return m_isRootControl ; }
+ bool IsCompositing() { return m_isCompositing; }
+ bool IsRootControl() { return m_isRootControl; }
+
+ wxWindow* GetPeer() const
+ {
+ return m_peer;
+ }
// to be moved into a tab control class
- virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ;
+ virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
+protected :
+ ControlRef m_controlRef;
+ wxFont m_font;
+ long m_windowStyle;
+ wxWindow* m_peer;
+ bool m_needsFocusRect;
+ bool m_isCompositing;
+ bool m_isRootControl;
+};
+
+// ============================================================================
+// DataBrowser Wrapper
+// ============================================================================
+//
+// basing on DataBrowserItemIDs
+//
+
+class wxMacDataBrowserControl : public wxMacControl
+{
+public :
+ wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
+
+ OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
+
+ OSStatus GetItemCount( DataBrowserItemID container,
+ Boolean recurse,
+ DataBrowserItemState state,
+ UInt32 *numItems) const;
+
+ OSStatus GetItems( DataBrowserItemID container,
+ Boolean recurse,
+ DataBrowserItemState state,
+ Handle items) const;
+
+
+ OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
+ DataBrowserTableViewColumnIndex position );
+
+ OSStatus AutoSizeColumns();
+
+ OSStatus SetHasScrollBars( bool horiz, bool vert );
+ OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
+
+ OSStatus SetHeaderButtonHeight( UInt16 height );
+ OSStatus GetHeaderButtonHeight( UInt16 *height );
+
+ OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty,
+ DataBrowserPropertyID propertyID ) const;
+
+ OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty );
+ OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty );
+ OSStatus RevealItem( DataBrowserItemID item,
+ DataBrowserPropertyID propertyID,
+ DataBrowserRevealOptions options ) const;
+
+ OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
+ OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
+ bool IsItemSelected( DataBrowserItemID item ) const;
+ OSStatus SetSelectedItems( UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserSetOption operation );
+
+ OSStatus GetItemID( DataBrowserTableViewRowIndex row,
+ DataBrowserItemID * item ) const;
+ OSStatus GetItemRow( DataBrowserItemID item,
+ DataBrowserTableViewRowIndex * row ) const;
+
+ OSStatus SetDefaultRowHeight( UInt16 height );
+ OSStatus GetDefaultRowHeight( UInt16 * height ) const;
+
+ OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
+ OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
+
+ OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
+ OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
+
+ OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
+ OSStatus SetDefaultColumnWidth( UInt16 width );
+
+ OSStatus GetColumnCount( UInt32* numColumns) const;
+
+ OSStatus GetColumnPosition( DataBrowserPropertyID column, UInt32 *position) const;
+ OSStatus SetColumnPosition( DataBrowserPropertyID column, UInt32 position);
+
+ OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
+ OSStatus SetScrollPosition( UInt32 top , UInt32 left );
+
+ OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
+ OSStatus SetSortProperty( DataBrowserPropertyID column );
+
+ OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
+ OSStatus SetSortOrder( DataBrowserSortOrder order );
+
+ OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
+ OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
+
+ OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
+ OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
+
+ OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
protected :
- ControlRef m_controlRef ;
- wxFont m_font ;
- long m_windowStyle ;
- wxWindow* m_peer ;
- bool m_needsFocusRect ;
- bool m_isCompositing ;
- bool m_isRootControl ;
-} ;
+
+ static pascal void DataBrowserItemNotificationProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData );
+
+ virtual void ItemNotification(
+ DataBrowserItemID itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData) = 0;
+
+ static pascal OSStatus DataBrowserGetSetItemDataProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue );
+
+ virtual OSStatus GetSetItemData(
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue ) = 0;
+
+ static pascal Boolean DataBrowserCompareProc(
+ ControlRef browser,
+ DataBrowserItemID itemOneID,
+ DataBrowserItemID itemTwoID,
+ DataBrowserPropertyID sortProperty);
+
+ virtual Boolean CompareItems(DataBrowserItemID itemOneID,
+ DataBrowserItemID itemTwoID,
+ DataBrowserPropertyID sortProperty) = 0;
+};
+
+// ============================================================================
+// Higher-level Databrowser
+// ============================================================================
+//
+// basing on data item objects
+//
+
+// forward decl
+
+class wxMacDataItemBrowserControl;
+
+// base class for databrowser items
+
+class wxMacDataItem
+{
+public :
+ wxMacDataItem();
+ virtual ~wxMacDataItem();
+
+ virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
+ const wxMacDataItem*,
+ DataBrowserPropertyID property) const;
+
+ // returns true if access was successful, otherwise false
+ virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue );
+
+ virtual void Notification(wxMacDataItemBrowserControl *owner ,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData ) const;
+};
+
+typedef wxMacDataItem* wxMacDataItemPtr;
+const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
+
+WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
+
+class wxMacDataItemBrowserControl : public wxMacDataBrowserControl
+{
+public :
+ wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
+
+ unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
+ void GetItems(const wxMacDataItem* container, bool recurse ,
+ DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
+
+ unsigned int GetLineFromItem(const wxMacDataItem *item) const;
+ wxMacDataItem * GetItemFromLine(unsigned int n) const;
+
+ void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
+ DataBrowserPropertyID property) const;
+ void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
+ DataBrowserPropertyID property) const;
+
+ void AddItem(wxMacDataItem *container, wxMacDataItem *item);
+ void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
+
+ void RemoveAllItems(wxMacDataItem *container);
+ void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
+ void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
+
+ void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
+ void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
+ void SetSelectedAllItems( DataBrowserSetOption option);
+ Boolean IsItemSelected( const wxMacDataItem* item) const;
+
+ void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
+
+ void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
+
+ // item aware methods, to be used in subclasses
+
+ virtual Boolean CompareItems(const wxMacDataItem* itemOneID,
+ const wxMacDataItem* itemTwoID,
+ DataBrowserPropertyID sortProperty);
+
+ virtual OSStatus GetSetItemData(wxMacDataItem* itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue );
+
+ virtual void ItemNotification(
+ const wxMacDataItem* itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData);
+
+ // ID aware base methods, should be 'final' ie not changed in subclasses
+
+ virtual Boolean CompareItems(DataBrowserItemID itemOneID,
+ DataBrowserItemID itemTwoID,
+ DataBrowserPropertyID sortProperty);
+
+ virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue );
+
+ virtual void ItemNotification(
+ DataBrowserItemID itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData);
+
+ // as we are getting the same events for human and API selection we have to suppress
+ // events in the latter case, since this will be used from many subclasses we keep it here
+
+ bool IsSelectionSuppressed() const { return m_suppressSelection; }
+ bool SuppressSelection( bool suppress );
+
+private :
+
+ bool m_suppressSelection;
+};
+
+class wxMacDataItemBrowserSelectionSuppressor
+{
+public :
+ wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
+ ~wxMacDataItemBrowserSelectionSuppressor();
+
+private :
+
+ bool m_former;
+ wxMacDataItemBrowserControl* m_browser;
+};
+
+// ============================================================================
+// platform listbox implementation
+// ============================================================================
+//
+// exposed for reuse in wxCheckListBox
+
+class wxMacListBoxItem : public wxMacDataItem
+{
+public :
+ wxMacListBoxItem();
+
+ virtual ~wxMacListBoxItem();
+
+ void SetLabel( const wxString& str);
+ const wxString& GetLabel() const;
+
+ virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
+ const wxMacDataItem* rhs,
+ DataBrowserPropertyID sortProperty) const;
+
+ virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue );
+
+ virtual void Notification(wxMacDataItemBrowserControl *owner ,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData ) const;
+
+ void SetOrder( SInt32 order );
+ SInt32 GetOrder() const;
+
+ void SetData( void* data);
+ void* GetData() const;
+
+private :
+ wxString m_label;
+ wxMacCFStringHolder m_cfLabel;
+ void * m_data;
+ SInt32 m_order;
+};
+
+class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl , public wxMacListControl
+{
+public:
+ wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
+ ~wxMacDataBrowserListControl();
+
+ // create a list item (can be a subclass of wxMacListBoxItem)
+
+ virtual wxMacListBoxItem* CreateItem();
+
+ // add and remove
+
+ void MacDelete( unsigned int n );
+ void MacInsert( unsigned int n, const wxString& item );
+ void MacInsert( unsigned int n, const wxArrayString& items );
+ int MacAppend( const wxString& item );
+ void MacClear();
+
+ // selecting
+
+ void MacDeselectAll();
+ void MacSetSelection( unsigned int n, bool select );
+ int MacGetSelection() const;
+ int MacGetSelections( wxArrayInt& aSelections ) const;
+ bool MacIsSelected( unsigned int n ) const;
+
+ // display
+
+ void MacScrollTo( unsigned int n );
+
+ // accessing content
+
+ void MacSetString( unsigned int n, const wxString& item );
+ void MacSetClientData( unsigned int n, void * data);
+ wxString MacGetString( unsigned int n) const;
+ void * MacGetClientData( unsigned int) const;
+ unsigned int MacGetCount() const;
+
+ // client data
+
+ wxClientDataType GetClientDataType() const;
+ void SetClientDataType(wxClientDataType clientDataItemsType);
+
+ // pointing back
+
+ wxListBox * GetPeer() const;
+private :
+ bool m_stringSorted;
+ wxClientDataType m_clientDataItemsType;
+};
+
+// ============================================================================
+// graphics implementation
+// ============================================================================
#if wxMAC_USE_CORE_GRAPHICS
{
DECLARE_NO_COPY_CLASS(wxMacCGPath)
public :
- wxMacCGPath() ;
- ~wxMacCGPath() ;
+ wxMacCGPath();
+ ~wxMacCGPath();
// Starts a new subpath at
- void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
- void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
- void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ) ;
- void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
- void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
+ void MoveToPoint( wxCoord x1 , wxCoord y1 );
+ void AddLineToPoint( wxCoord x1 , wxCoord y1 );
+ void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 );
+ void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
+ void AddCircle( wxCoord x, wxCoord y , wxCoord r );
// closes the current subpath
- void CloseSubpath() ;
+ void CloseSubpath();
- CGPathRef GetPath() const ;
+ CGPathRef GetPath() const;
private :
- CGMutablePathRef m_path ;
-} ;
+ CGMutablePathRef m_path;
+};
class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
{
DECLARE_NO_COPY_CLASS(wxMacCGContext)
public:
- wxMacCGContext( CGrafPtr port ) ;
- wxMacCGContext( CGContextRef cgcontext ) ;
- wxMacCGContext() ;
- ~wxMacCGContext() ;
-
- virtual void Clip( const wxRegion ®ion ) ;
- virtual void StrokePath( const wxGraphicPath *p ) ;
- virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
- virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
-
- virtual wxGraphicPath* CreatePath() ;
- virtual void SetPen( const wxPen &pen ) ;
- virtual void SetBrush( const wxBrush &brush ) ;
- CGContextRef GetNativeContext() ;
- void SetNativeContext( CGContextRef cg ) ;
- CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
+ wxMacCGContext( CGrafPtr port );
+ wxMacCGContext( CGContextRef cgcontext );
+ wxMacCGContext();
+ ~wxMacCGContext();
+
+ virtual void Clip( const wxRegion ®ion );
+ virtual void StrokePath( const wxGraphicPath *p );
+ virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE );
+ virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE );
+
+ virtual wxGraphicPath* CreatePath();
+ virtual void SetPen( const wxPen &pen ) ;
+ virtual void SetBrush( const wxBrush &brush );
+ CGContextRef GetNativeContext();
+ void SetNativeContext( CGContextRef cg );
+ CGPathDrawingMode GetDrawingMode() const { return m_mode; }
private:
- CGContextRef m_cgContext ;
- CGrafPtr m_qdPort ;
- CGPathDrawingMode m_mode ;
- wxPen m_pen ;
- wxBrush m_brush ;
-} ;
+ CGContextRef m_cgContext;
+ CGrafPtr m_qdPort;
+ CGPathDrawingMode m_mode;
+ wxPen m_pen;
+ wxBrush m_brush;
+};
#endif // wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
-CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
-void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ;
+CGColorSpaceRef wxMacGetGenericRGBColorSpace(void);
+void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
#endif
wxBitmapRefData();
~wxBitmapRefData();
- void Free() ;
- bool Ok() const { return m_ok ; }
- void SetOk( bool isOk) { m_ok = isOk ; }
+ void Free();
+ bool Ok() const { return m_ok; }
+ void SetOk( bool isOk) { m_ok = isOk; }
- void SetWidth( int width ) { m_width = width ; }
- void SetHeight( int height ) { m_height = height ; }
- void SetDepth( int depth ) { m_depth = depth ; }
+ void SetWidth( int width ) { m_width = width; }
+ void SetHeight( int height ) { m_height = height; }
+ void SetDepth( int depth ) { m_depth = depth; }
- int GetWidth() const { return m_width ; }
- int GetHeight() const { return m_height ; }
- int GetDepth() const { return m_depth ; }
+ int GetWidth() const { return m_width; }
+ int GetHeight() const { return m_height; }
+ int GetDepth() const { return m_depth; }
- void *GetRawAccess() const ;
- void *BeginRawAccess() ;
- void EndRawAccess() ;
+ void *GetRawAccess() const;
+ void *BeginRawAccess();
+ void EndRawAccess();
- bool HasAlpha() const { return m_hasAlpha ; }
- void UseAlpha( bool useAlpha ) ;
+ bool HasAlpha() const { return m_hasAlpha; }
+ void UseAlpha( bool useAlpha );
public:
#if wxUSE_PALETTE
wxMask * m_bitmapMask; // Optional mask
#ifdef __WXMAC_OSX__
- CGImageRef CGImageCreate() const ;
+ CGImageRef CGImageCreate() const;
#endif
// returns true if the bitmap has a size that
// if no is returned GetIconRef will still produce
// an icon but it will be generated via a PICT and
// rescaled to 16 x 16
- bool HasNativeSize() ;
+ bool HasNativeSize();
// caller should increase ref count if needed longer
// than the bitmap exists
- IconRef GetIconRef() ;
+ IconRef GetIconRef();
// returns a Pict from the bitmap content
- PicHandle GetPictHandle() ;
- GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
- void UpdateAlphaMask() const ;
+ PicHandle GetPictHandle();
+ GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const;
+ void UpdateAlphaMask() const;
private :
- bool Create(int width , int height , int depth) ;
- void Init() ;
+ bool Create(int width , int height , int depth);
+ void Init();
int m_width;
int m_height;
- int m_bytesPerRow ;
+ int m_bytesPerRow;
int m_depth;
bool m_hasAlpha;
- wxMemoryBuffer m_memBuf ;
- int m_rawAccessCount ;
+ wxMemoryBuffer m_memBuf;
+ int m_rawAccessCount;
bool m_ok;
#ifdef __WXMAC_OSX__
- mutable CGImageRef m_cgImageRef ;
+ mutable CGImageRef m_cgImageRef;
#endif
- IconRef m_iconRef ;
- PicHandle m_pictHandle ;
+ IconRef m_iconRef;
+ PicHandle m_pictHandle;
GWorldPtr m_hBitmap;
- GWorldPtr m_hMaskBitmap ;
- wxMemoryBuffer m_maskMemBuf ;
- int m_maskBytesPerRow ;
+ GWorldPtr m_hMaskBitmap;
+ wxMemoryBuffer m_maskMemBuf;
+ int m_maskBytesPerRow;
};
class WXDLLEXPORT wxIconRefData : public wxGDIRefData
{
public:
- wxIconRefData() ;
- wxIconRefData( WXHICON ) ;
+ wxIconRefData();
+ wxIconRefData( WXHICON );
virtual ~wxIconRefData() { Free(); }
- void Init() ;
+ void Init();
virtual void Free();
- void SetWidth( int width ) { m_width = width ; }
- void SetHeight( int height ) { m_height = height ; }
+ void SetWidth( int width ) { m_width = width; }
+ void SetHeight( int height ) { m_height = height; }
- int GetWidth() const { return m_width ; }
- int GetHeight() const { return m_height ; }
+ int GetWidth() const { return m_width; }
+ int GetHeight() const { return m_height; }
- WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
+ WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
private :
- IconRef m_iconRef ;
- int m_width ;
- int m_height ;
+ IconRef m_iconRef;
+ int m_width;
+ int m_height;
};
// toplevel.cpp
-ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ) ;
+ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
#ifdef WORDS_BIGENDIAN
inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
{
- *rect = (**pict).picFrame ;
- return rect ;
+ *rect = (**pict).picFrame;
+ return rect;
}
#else
inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
{
- return QDGetPictureBounds( pict , rect ) ;
+ return QDGetPictureBounds( pict , rect );
}
#endif
// wxMac string conversions
//---------------------------------------------------------------------------
-void wxMacSetupConverters() ;
-void wxMacCleanupConverters() ;
+void wxMacSetupConverters();
+void wxMacCleanupConverters();
-void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
-wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
+void wxMacStringToPascal( const wxString&from , StringPtr to );
+wxString wxMacMakeStringFromPascal( ConstStringPtr from );
// filefn.cpp
-wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
-OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
-wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
+wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
+OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
+wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
#endif
// _WX_PRIVATE_H_
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
END_EVENT_TABLE()
+class wxMacDataBrowserCheckListControl : public wxMacDataBrowserListControl , public wxMacCheckListControl
+{
+public:
+ wxMacDataBrowserCheckListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
+ ~wxMacDataBrowserCheckListControl();
+
+ virtual wxMacListBoxItem* CreateItem();
+
+ virtual bool MacIsChecked(unsigned int n) const;
+ virtual void MacCheck(unsigned int n, bool bCheck = true);
+};
+
void wxCheckListBox::Init()
{
}
return false;
// this will be increased by our Append command
- m_noItems = 0;
-
- m_peer = (wxMacControl*) CreateMacListControl(pos , size , style );
+ wxMacDataBrowserCheckListControl* control = new wxMacDataBrowserCheckListControl( this, pos, size, style );
+ control->SetClientDataType( m_clientDataItemsType );
+ m_peer = control;
MacPostControlCreate(pos,size);
wxCHECK_MSG( IsValid(item), false,
wxT("invalid index in wxCheckListBox::IsChecked") );
- return m_checks[item] != 0;
+ return GetPeer()->MacIsChecked( item );
}
void wxCheckListBox::Check(unsigned int item, bool check)
wxCHECK_RET( IsValid(item),
wxT("invalid index in wxCheckListBox::Check") );
- bool isChecked = m_checks[item] != 0;
+ bool isChecked = GetPeer()->MacIsChecked( item );
if ( check != isChecked )
{
- m_checks[item] = check;
- MacUpdateLine( item );
+ GetPeer()->MacCheck( item , check );
}
}
-// ----------------------------------------------------------------------------
-// methods forwarded to wxCheckListBox
-// ----------------------------------------------------------------------------
+wxMacCheckListControl* wxCheckListBox::GetPeer() const
+{
+ return dynamic_cast<wxMacCheckListControl*>(m_peer);
+}
-void wxCheckListBox::Delete(unsigned int n)
-{
- wxCHECK_RET( IsValid(n), wxT("invalid index in wxCheckListBox::Delete") );
+const short kCheckboxColumnId = 1026;
- wxListBox::Delete( n );
- m_checks.RemoveAt( n );
+wxMacDataBrowserCheckListControl::wxMacDataBrowserCheckListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
+ : wxMacDataBrowserListControl( peer, pos, size, style )
+{
+ OSStatus err = noErr;
+
+ DataBrowserListViewColumnDesc columnDesc;
+ columnDesc.headerBtnDesc.titleOffset = 0;
+ columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
+
+ columnDesc.headerBtnDesc.btnFontStyle.flags =
+ kControlUseFontMask | kControlUseJustMask;
+
+ columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
+ columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
+ columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
+ columnDesc.headerBtnDesc.btnFontStyle.style = normal;
+ columnDesc.headerBtnDesc.titleString = NULL;
+
+ columnDesc.headerBtnDesc.minimumWidth = 30;
+ columnDesc.headerBtnDesc.maximumWidth = 30;
+
+ columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
+ columnDesc.propertyDesc.propertyFlags =
+ kDataBrowserPropertyIsMutable
+ | kDataBrowserTableViewSelectionColumn
+ | kDataBrowserDefaultPropertyFlags;
+
+ err = AddColumn( &columnDesc, 0 );
+ verify_noerr( err );
}
-int wxCheckListBox::DoAppend(const wxString& item)
+wxMacDataBrowserCheckListControl::~wxMacDataBrowserCheckListControl()
{
- int pos = wxListBox::DoAppend( item );
-
- // the item is initially unchecked
- m_checks.Insert( false, pos );
-
- return pos;
+
}
-void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
+class wxMacCheckListBoxItem : public wxMacListBoxItem
{
- wxListBox::DoInsertItems( items, pos );
+public :
+ wxMacCheckListBoxItem()
+ {
+ m_isChecked = false;
+ }
+
+ ~wxMacCheckListBoxItem()
+ {
+ }
+
+ virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue )
+ {
+ OSStatus err = errDataBrowserPropertyNotSupported;
+
+ wxCheckListBox *checklist = wxDynamicCast( owner->GetPeer() , wxCheckListBox );
+ wxCHECK_MSG( checklist != NULL , errDataBrowserPropertyNotSupported , wxT("wxCheckListBox expected"));
+
+ if ( !changeValue )
+ {
+ switch (property)
+ {
+ case kCheckboxColumnId:
+ verify_noerr(SetDataBrowserItemDataButtonValue( itemData, m_isChecked ? kThemeButtonOn : kThemeButtonOff ));
+ err = noErr;
+ break;
+
+ case kDataBrowserItemIsEditableProperty:
+ verify_noerr(SetDataBrowserItemDataBooleanValue( itemData, true ));
+ err = noErr;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (property)
+ {
+ case kCheckboxColumnId:
+ {
+ // we have to change this behind the back, since Check() would be triggering another update round
+ bool newVal = !m_isChecked;
+ verify_noerr(SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff ));
+ m_isChecked = newVal;
+ err = noErr;
+
+ wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, checklist->GetId() );
+ event.SetInt( owner->GetLineFromItem( this ) );
+ event.SetEventObject( checklist );
+ checklist->GetEventHandler()->ProcessEvent( event );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if ( err == errDataBrowserPropertyNotSupported )
+ err = wxMacListBoxItem::GetSetData( owner , property, itemData , changeValue);
+
+ return err;
+ }
- unsigned int count = items.GetCount();
- for ( unsigned int n = 0; n < count; n++ )
+ void Check( bool check )
{
- m_checks.Insert( false, pos + n );
+ m_isChecked = check;
}
-}
+ bool IsChecked() const
+ {
+ return m_isChecked;
+ }
+
+protected :
+ bool m_isChecked;
+};
-void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
+wxMacListBoxItem* wxMacDataBrowserCheckListControl::CreateItem()
{
- // call it first as it does DoClear()
- wxListBox::DoSetItems( items, clientData );
+ return new wxMacCheckListBoxItem();
+}
- unsigned int count = items.GetCount();
- for ( unsigned int n = 0; n < count; n++ )
- {
- m_checks.Add( false );
- }
+void wxMacDataBrowserCheckListControl::MacCheck( unsigned int n, bool bCheck)
+{
+ wxMacCheckListBoxItem* item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n) );
+ item->Check( bCheck);
+ UpdateItem(wxMacDataBrowserRootContainer, item , kCheckboxColumnId);
}
-void wxCheckListBox::DoClear()
+bool wxMacDataBrowserCheckListControl::MacIsChecked( unsigned int n) const
{
- m_checks.Empty();
+ wxMacCheckListBoxItem * item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n ) );
+ return item->IsChecked();
}
+
+
#endif // wxUSE_CHECKLISTBOX
#include "wx/app.h"
#include "wx/listbox.h"
-#include "wx/checklst.h"
#include "wx/button.h"
#include "wx/settings.h"
#include "wx/toplevel.h"
END_EVENT_TABLE()
#include "wx/mac/uma.h"
-
-// common interface for all implementations
-class wxMacListControl : public wxMacControl
-{
-public:
- wxMacListControl( wxListBox *peer )
- : wxMacControl( peer )
- {
- }
-
- ~wxMacListControl()
- {
- }
-
- virtual void UpdateLine( int n ) = 0;
-
- virtual void MacDelete( int n ) = 0;
- virtual void MacInsert( int n, const wxString& item ) = 0;
- virtual void MacInsert( int n, const wxArrayString& items ) = 0;
- virtual void MacAppend( const wxString& item ) = 0;
- virtual void MacSet( int n, const wxString& item ) = 0;
- virtual void MacClear() = 0;
- virtual void MacDeselectAll() = 0;
- virtual void MacSetSelection( int n, bool select ) = 0;
- virtual int MacGetSelection() const = 0;
- virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
- virtual bool MacIsSelected( int n ) const = 0;
- virtual void MacScrollTo( int n ) = 0;
-
- wxListBox * GetPeer() const
- { return (wxListBox*)m_peer; }
-};
-
-#if 0
-// In case we have to replace data browser ...
-// custom HIView-based implementation
-
-class wxMacCustomHIViewListControl : public wxMacListControl
-{
-public:
- wxMacCustomHIViewListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
- ~wxMacCustomHIViewListControl();
-
- void MacDelete( int n );
- void MacInsert( int n, const wxString& item );
- void MacInsert( int n, const wxArrayString& items );
- void MacAppend( const wxString& item );
- void MacSet( int n, const wxString& item );
- void MacClear();
- void MacDeselectAll();
- void MacSetSelection( int n, bool select );
- int MacGetSelection() const;
- int MacGetSelections( wxArrayInt& aSelections ) const;
- bool MacIsSelected( int n ) const;
- void MacScrollTo( int n );
-};
-#endif
-
-// DataBrowser-based implementation
-
-class wxMacDataBrowserListControl : public wxMacListControl
-{
-public:
- wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
- ~wxMacDataBrowserListControl();
-
- void UpdateLine( int n );
-
- void MacDelete( int n );
- void MacInsert( int n, const wxString& item );
- void MacInsert( int n, const wxArrayString& items );
- void MacAppend( const wxString& item );
- void MacSet( int n, const wxString& item );
- void MacClear();
- void MacDeselectAll();
- void MacSetSelection( int n, bool select );
- int MacGetSelection() const;
- int MacGetSelections( wxArrayInt& aSelections ) const;
- bool MacIsSelected( int n ) const;
- void MacScrollTo( int n );
-
- virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
- virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
- DataBrowserTableViewColumnIndex position );
- virtual OSStatus AutoSizeListViewColumns();
- virtual OSStatus SetHasScrollBars( bool horiz, bool vert );
- virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
- virtual OSStatus SetListViewHeaderBtnHeight( UInt16 height );
- virtual OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
- virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty,
- DataBrowserPropertyID propertyID );
- virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty );
- virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty );
- virtual OSStatus RevealItem( DataBrowserItemID item,
- DataBrowserPropertyID propertyID,
- DataBrowserRevealOptions options );
- virtual OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
- virtual bool IsItemSelected( DataBrowserItemID item ) const;
- virtual OSStatus SetSelectedItems( UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserSetOption operation );
-
-private:
- // as we are getting the same events for human and API selection we have to suppress
- // events in the latter case
- bool MacSuppressSelection( bool suppress );
- bool MacIsSelectionSuppressed() const { return m_suppressSelection; }
-
- bool m_suppressSelection;
-
-#if TARGET_API_MAC_OSX
- static pascal void DataBrowserItemNotificationProc(
- ControlRef browser,
- DataBrowserItemID itemID,
- DataBrowserItemNotification message,
- DataBrowserItemDataRef itemData );
-#else
- static pascal void DataBrowserItemNotificationProc(
- ControlRef browser,
- DataBrowserItemID itemID,
- DataBrowserItemNotification message );
-#endif
-};
+#include "wx/dynarray.h"
+#include "wx/arrstr.h"
// ============================================================================
-// data browser based implementation
+// list box control implementation
// ============================================================================
-const short kTextColumnId = 1024;
-const short kCheckboxColumnId = 1025;
-
-// new DataBrowser-based version
-// because of the limited insert
-// functionality of DataBrowser,
-// we just introduce IDs corresponding
-// to the line number
-
-DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
-DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
-
-#if TARGET_API_MAC_OSX
-pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
- ControlRef browser,
- DataBrowserItemID itemID,
- DataBrowserItemNotification message,
- DataBrowserItemDataRef itemData )
-#else
-pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
- ControlRef browser,
- DataBrowserItemID itemID,
- DataBrowserItemNotification message )
-#endif
+wxListBox::wxListBox()
{
- long ref = GetControlReference( browser );
- if ( ref != 0 )
- {
- wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
- wxMacDataBrowserListControl *peer = (wxMacDataBrowserListControl*) list->GetPeer();
-
- int i = itemID - 1;
- if (i >= 0 && i < (int)list->GetCount())
- {
- bool trigger = false;
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
- switch (message)
- {
- case kDataBrowserItemDeselected:
- if ( list->HasMultipleSelection() )
- trigger = !peer->MacIsSelectionSuppressed();
- break;
-
- case kDataBrowserItemSelected:
- trigger = !peer->MacIsSelectionSuppressed();
- break;
-
- case kDataBrowserItemDoubleClicked:
- event.SetEventType( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED );
- trigger = true;
- break;
-
- default:
- break;
- }
-
- if ( trigger )
- {
- event.SetEventObject( list );
- if ( list->HasClientObjectData() )
- event.SetClientObject( list->GetClientObject( i ) );
- else if ( list->HasClientUntypedData() )
- event.SetClientData( list->GetClientData( i ) );
- event.SetString( list->GetString( i ) );
- event.SetInt( i );
- event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true );
- wxPostEvent( list->GetEventHandler(), event );
-
- // direct notification is not always having the listbox GetSelection() having in synch with event
- // list->GetEventHandler()->ProcessEvent(event);
- }
- }
- }
}
-static pascal OSStatus ListBoxGetSetItemData(
- ControlRef browser,
- DataBrowserItemID itemID,
- DataBrowserPropertyID property,
- DataBrowserItemDataRef itemData,
- Boolean changeValue )
+bool wxListBox::Create(
+ wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name )
{
- OSStatus err = errDataBrowserPropertyNotSupported;
-
- long ref = GetControlReference( browser );
-
- if ( !changeValue )
- {
- wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
- bool isCheckList = false;
- if (list)
- isCheckList = list->IsKindOf( CLASSINFO(wxCheckListBox) );
-
- switch (property)
- {
- case kTextColumnId:
- if ( ref != 0 )
- {
- int i = itemID - 1;
- if (i >= 0 && i < (int)list->GetCount())
- {
- wxMacCFStringHolder cf( list->GetString( i ), list->GetFont().GetEncoding() );
- err = ::SetDataBrowserItemDataText( itemData, cf );
- verify_noerr( err );
- err = noErr;
- }
- }
- break;
-
- case kCheckboxColumnId:
- if ( ref != 0 )
- {
- wxCheckListBox *list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
- int i = itemID - 1;
- if (i >= 0 && (unsigned int) i < list->GetCount())
- {
- err = ::SetDataBrowserItemDataButtonValue( itemData, list->IsChecked( i ) ? kThemeButtonOn : kThemeButtonOff );
- verify_noerr( err );
- err = noErr;
- }
- }
- break;
-
- case kDataBrowserItemIsEditableProperty:
- if ( isCheckList )
- err = ::SetDataBrowserItemDataBooleanValue( itemData, true );
- break;
-
- default:
- break;
- }
- }
- else
- {
- switch (property)
- {
- case kCheckboxColumnId:
- if ( ref != 0 )
- {
- wxCheckListBox *list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
- int i = itemID - 1;
- if (i >= 0 && (unsigned int)i < list->GetCount())
- {
- // we have to change this behind the back, since Check() would be triggering another update round
- bool newVal = !list->IsChecked( i );
- err = ::SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff );
- verify_noerr( err );
- err = noErr;
- list->m_checks[i] = newVal;
-
- wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, list->GetId() );
- event.SetInt( i );
- event.SetEventObject( list );
- list->GetEventHandler()->ProcessEvent( event );
- }
- }
- break;
+ wxCArrayString chs(choices);
- default:
- break;
- }
- }
+ return Create(
+ parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
+ style, validator, name );
+}
- return err;
+wxMacListControl* wxListBox::GetPeer() const
+{
+ return dynamic_cast<wxMacListControl*>(m_peer);
}
-wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
- : wxMacListControl( peer )
+bool wxListBox::Create(
+ wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n,
+ const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name )
{
- bool isCheckList = peer->IsKindOf( CLASSINFO(wxCheckListBox));
-
- m_suppressSelection = false;
- Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
- OSStatus err = ::CreateDataBrowserControl(
- MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
- &bounds, kDataBrowserListView, &m_controlRef );
- verify_noerr( err );
-
- DataBrowserSelectionFlags options = kDataBrowserDragSelect;
- if ( style & wxLB_MULTIPLE )
- {
- options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
- }
- else if ( style & wxLB_EXTENDED )
- {
- // default behaviour
- }
- else
- {
- options |= kDataBrowserSelectOnlyOne;
- }
- err = SetSelectionFlags( options );
- verify_noerr( err );
-
- if ( gDataBrowserItemDataUPP == NULL )
- gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(ListBoxGetSetItemData);
- if ( gDataBrowserItemNotificationUPP == NULL )
- {
- gDataBrowserItemNotificationUPP =
-#if TARGET_API_MAC_OSX
- (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc);
-#else
- NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc);
-#endif
- }
+ m_macIsUserPane = false;
- DataBrowserCallbacks callbacks;
- InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks );
+ wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
+ wxT("only a single listbox selection mode can be specified") );
- callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
- callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
- SetCallbacks( &callbacks );
+ if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
+ return false;
+
+ wxMacDataBrowserListControl* control = new wxMacDataBrowserListControl( this, pos, size, style );
+ control->SetClientDataType( m_clientDataItemsType );
+ m_peer = control;
- DataBrowserListViewColumnDesc columnDesc;
- columnDesc.headerBtnDesc.titleOffset = 0;
- columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
+ MacPostControlCreate( pos, size );
- columnDesc.headerBtnDesc.btnFontStyle.flags =
- kControlUseFontMask | kControlUseJustMask;
+ InsertItems( n, choices, 0 );
- columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
- columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
- columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
- columnDesc.headerBtnDesc.btnFontStyle.style = normal;
- columnDesc.headerBtnDesc.titleString = NULL;
+ // Needed because it is a wxControlWithItems
+ SetBestSize( size );
- if ( isCheckList )
- {
- columnDesc.headerBtnDesc.minimumWidth = 30;
- columnDesc.headerBtnDesc.maximumWidth = 30;
-
- columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
- columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
- columnDesc.propertyDesc.propertyFlags =
- kDataBrowserPropertyIsMutable
- | kDataBrowserTableViewSelectionColumn
- | kDataBrowserDefaultPropertyFlags;
- err = AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn );
- verify_noerr( err );
- }
+ return true;
+}
- columnDesc.headerBtnDesc.minimumWidth = 0;
- columnDesc.headerBtnDesc.maximumWidth = 10000;
+wxListBox::~wxListBox()
+{
+ FreeData();
+ m_peer->SetReference( 0 );
+}
- columnDesc.propertyDesc.propertyID = kTextColumnId;
- columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
- columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
- columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
-#endif
+void wxListBox::FreeData()
+{
+ GetPeer()->MacClear();
+}
- verify_noerr( AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
- verify_noerr( AutoSizeListViewColumns() );
- verify_noerr( SetHasScrollBars( false, true ) );
- verify_noerr( SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite ) );
- verify_noerr( SetListViewHeaderBtnHeight( 0 ) );
+void wxListBox::DoSetFirstItem(int n)
+{
+ GetPeer()->MacScrollTo( n );
+}
-#if 0
- // shouldn't be necessary anymore under 10.2
- m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
- m_peer->SetNeedsFocusRect( true );
-#endif
+void wxListBox::EnsureVisible(int n)
+{
+ GetPeer()->MacScrollTo( n );
}
-wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
+void wxListBox::Delete(unsigned int n)
{
+ wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::Delete") );
+
+ GetPeer()->MacDelete( n );
}
-void wxMacDataBrowserListControl::MacDelete( int n )
+int wxListBox::DoAppend(const wxString& item)
{
- wxArrayInt selectionBefore;
- MacGetSelections( selectionBefore );
+ InvalidateBestSize();
- UInt32 id = GetPeer()->GetCount() + 1;
+ return GetPeer()->MacAppend( item );
+}
- OSStatus err = RemoveItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty );
- verify_noerr( err );
+void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
+{
+ Clear();
+
+ unsigned int n = choices.GetCount();
- for ( size_t i = 0; i < selectionBefore.GetCount(); ++i )
+ for ( size_t i = 0; i < n; ++i )
{
- int current = selectionBefore[i];
- if ( current == n )
- {
- // selection was deleted
- MacSetSelection( current, false );
- }
- else if ( current > n )
+ if ( clientData )
{
- // something behind the deleted item was selected -> move up
- MacSetSelection( current - 1, true );
- MacSetSelection( current, false );
+ Append( choices[i], clientData[i] );
}
+ else
+ Append( choices[i] );
}
- // refresh all
- err = UpdateItems(
- kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
- kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
- verify_noerr( err );
}
-void wxMacDataBrowserListControl::MacInsert( int n, const wxString& text)
+int wxListBox::FindString(const wxString& s, bool bCase) const
{
- wxArrayInt selectionBefore;
- MacGetSelections( selectionBefore );
-
- UInt32 id = GetPeer()->GetCount(); // this has already been increased
- OSStatus err = AddItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty );
- verify_noerr( err );
-
- for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
+ for ( size_t i = 0; i < GetCount(); ++ i )
{
- int current = selectionBefore[i];
- if ( current >= n )
- {
- MacSetSelection( current + 1, true );
- MacSetSelection( current, false );
- }
+ if (s.IsSameAs( GetString( i ), bCase) )
+ return (int)i;
}
- // refresh all
- err = UpdateItems(
- kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
- kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
- verify_noerr( err );
+ return wxNOT_FOUND;
}
-void wxMacDataBrowserListControl::MacInsert( int n, const wxArrayString& items)
+void wxListBox::Clear()
{
- wxArrayInt selectionBefore;
- MacGetSelections( selectionBefore );
- size_t itemsCount = items.GetCount();
+ FreeData();
+}
- UInt32 *ids = new UInt32[itemsCount];
- for ( unsigned int i = 0; i < itemsCount; ++i )
- ids[i] = GetPeer()->GetCount() - itemsCount + i + 1;
+void wxListBox::DoSetSelection(int n, bool select)
+{
+ wxCHECK_RET( n == wxNOT_FOUND || IsValid(n),
+ wxT("invalid index in wxListBox::SetSelection") );
- OSStatus err = AddItems( kDataBrowserNoItem, itemsCount, ids, kDataBrowserItemNoProperty );
- verify_noerr( err );
- delete [] ids;
+ if ( n == wxNOT_FOUND )
+ GetPeer()->MacDeselectAll();
+ else
+ GetPeer()->MacSetSelection( n, select );
+}
- for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
- {
- int current = selectionBefore[i];
- if ( current >= n )
- {
- MacSetSelection( current + 1, true );
- MacSetSelection( current, false );
- }
- }
+bool wxListBox::IsSelected(int n) const
+{
+ wxCHECK_MSG( IsValid(n), false, wxT("invalid index in wxListBox::Selected") );
- // refresh all
- err = UpdateItems(
- kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
- kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
- verify_noerr( err );
+ return GetPeer()->MacIsSelected( n );
}
-void wxMacDataBrowserListControl::MacAppend( const wxString& text)
+void *wxListBox::DoGetItemClientData(unsigned int n) const
{
- UInt32 id = GetPeer()->GetCount(); // this has already been increased
- verify_noerr( AddItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty ) );
- // no need to deal with selections nor refreshed, as we have appended
+ wxCHECK_MSG( IsValid(n), NULL, wxT("invalid index in wxListBox::GetClientData"));
+ return GetPeer()->MacGetClientData( n );
}
-void wxMacDataBrowserListControl::MacClear()
+wxClientData *wxListBox::DoGetItemClientObject(unsigned int n) const
{
- verify_noerr( RemoveItems( kDataBrowserNoItem, 0, NULL, kDataBrowserItemNoProperty ) );
+ return (wxClientData*)DoGetItemClientData( n );
}
-void wxMacDataBrowserListControl::MacDeselectAll()
+void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
{
- bool former = MacSuppressSelection( true );
- verify_noerr(SetSelectedItems( 0, NULL, kDataBrowserItemsRemove ) );
- MacSuppressSelection( former );
+ wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") );
+ GetPeer()->MacSetClientData( n , clientData);
}
-void wxMacDataBrowserListControl::MacSetSelection( int n, bool select )
+void wxListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
{
- UInt32 id = n + 1;
- bool former = MacSuppressSelection( true );
-
- if ( IsItemSelected( id ) != select )
- {
- OSStatus err;
-
- if ( select )
- err = SetSelectedItems( 1, &id, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
- else
- err = SetSelectedItems( 1, &id, kDataBrowserItemsRemove );
-
- verify_noerr( err );
- }
-
- MacScrollTo( n );
- MacSuppressSelection( former );
+ DoSetItemClientData(n, clientData);
}
-bool wxMacDataBrowserListControl::MacSuppressSelection( bool suppress )
+// Return number of selections and an array of selected integers
+int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
- bool former = m_suppressSelection;
- m_suppressSelection = suppress;
+ return GetPeer()->MacGetSelections( aSelections );
+}
- return former;
+// Get single selection, for single choice list items
+int wxListBox::GetSelection() const
+{
+ return GetPeer()->MacGetSelection();
}
-bool wxMacDataBrowserListControl::MacIsSelected( int n ) const
+// Find string for position
+wxString wxListBox::GetString(unsigned int n) const
{
- return IsItemSelected( n + 1 );
+ wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxListBox::GetString") );
+ return GetPeer()->MacGetString(n);
}
-int wxMacDataBrowserListControl::MacGetSelection() const
+void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
{
- for ( unsigned int i = 0; i < GetPeer()->GetCount(); ++i )
- {
- if ( IsItemSelected( i + 1 ) )
- {
- return i;
- }
- }
+ wxCHECK_RET( IsValidInsert(pos), wxT("invalid index in wxListBox::InsertItems") );
- return -1;
+ InvalidateBestSize();
+
+ GetPeer()->MacInsert( pos, items );
}
-int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) const
+void wxListBox::SetString(unsigned int n, const wxString& s)
{
- int no_sel = 0;
+ GetPeer()->MacSetString( n, s );
+}
- aSelections.Empty();
+wxSize wxListBox::DoGetBestSize() const
+{
+ int lbWidth = 100; // some defaults
+ int lbHeight = 110;
+ int wLine;
- UInt32 first, last;
- GetSelectionAnchor( &first, &last );
- if ( first != kDataBrowserNoItem )
{
- for ( size_t i = first; i <= last; ++i )
+ wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) );
+
+ // TODO: clean this up
+ if ( m_font.Ok() )
{
- if ( IsItemSelected( i ) )
- {
- aSelections.Add( i - 1 );
- no_sel++;
- }
+ ::TextFont( m_font.MacGetFontNum() );
+ ::TextSize( m_font.MacGetFontSize() );
+ ::TextFace( m_font.MacGetFontStyle() );
+ }
+ else
+ {
+ ::TextFont( kFontIDMonaco );
+ ::TextSize( 9 );
+ ::TextFace( 0 );
}
- }
- return no_sel;
-}
+ // Find the widest line
+ for (unsigned int i = 0; i < GetCount(); i++)
+ {
+ wxString str( GetString( i ) );
-void wxMacDataBrowserListControl::MacSet( int n, const wxString& text )
-{
- // as we don't store the strings we only have to issue a redraw
- UInt32 id = n + 1;
- verify_noerr( UpdateItems( kDataBrowserNoItem, 1, &id, kDataBrowserItemNoProperty, kDataBrowserItemNoProperty ) );
-}
+#if wxUSE_UNICODE
+ Point bounds = {0, 0};
+ SInt16 baseline;
-void wxMacDataBrowserListControl::MacScrollTo( int n )
-{
- UInt32 id = n + 1;
- verify_noerr( RevealItem( id, kTextColumnId, kDataBrowserRevealWithoutSelecting ) );
-}
+ // NB: what if m_font.Ok() == false ???
+ ::GetThemeTextDimensions(
+ wxMacCFStringHolder( str, m_font.GetEncoding() ),
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &bounds,
+ &baseline );
+ wLine = bounds.h;
+#else
+ wLine = ::TextWidth( str.c_str(), 0, str.length() );
+#endif
-void wxMacDataBrowserListControl::UpdateLine( int n )
-{
- UInt32 id = n + 1;
- verify_noerr( UpdateItems(kDataBrowserNoItem, 1, &id, kDataBrowserItemNoProperty, kDataBrowserItemNoProperty ) );
-}
+ lbWidth = wxMax( lbWidth, wLine );
+ }
-//
-// Databrowser
-//
+ // Add room for the scrollbar
+ lbWidth += wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
-OSStatus wxMacDataBrowserListControl::SetSelectionFlags( DataBrowserSelectionFlags options )
-{
- return SetDataBrowserSelectionFlags( m_controlRef, options );
-}
+ // And just a bit more
+ int cy = 12;
+ int cx = ::TextWidth( "X", 0, 1 );
+ lbWidth += cx;
-OSStatus wxMacDataBrowserListControl::AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
- DataBrowserTableViewColumnIndex position )
-{
- return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
-}
+ // don't make the listbox too tall (limit height to around 10 items)
+ // but don't make it too small neither
+ lbHeight = wxMax( (cy + 4) * wxMin( wxMax( GetCount(), 3 ), 10 ), 70 );
+ }
-OSStatus wxMacDataBrowserListControl::AutoSizeListViewColumns()
-{
- return AutoSizeDataBrowserListViewColumns(m_controlRef);
+ return wxSize( lbWidth, lbHeight );
}
-OSStatus wxMacDataBrowserListControl::SetHasScrollBars( bool horiz, bool vert )
+unsigned int wxListBox::GetCount() const
{
- return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert );
+ return GetPeer()->MacGetCount();
}
-OSStatus wxMacDataBrowserListControl::SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
+void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
{
- return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle );
+ wxControl::Refresh( eraseBack, rect );
}
-OSStatus wxMacDataBrowserListControl::SetListViewHeaderBtnHeight(UInt16 height)
+// Some custom controls depend on this
+/* static */ wxVisualAttributes
+wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
- return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
-}
+ wxVisualAttributes attr;
-OSStatus wxMacDataBrowserListControl::SetCallbacks(const DataBrowserCallbacks *callbacks)
-{
- return SetDataBrowserCallbacks( m_controlRef, callbacks );
-}
+ attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
+ attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
+ attr.font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
-OSStatus wxMacDataBrowserListControl::UpdateItems(
- DataBrowserItemID container,
- UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty,
- DataBrowserPropertyID propertyID )
-{
- return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID );
+ return attr;
}
-bool wxMacDataBrowserListControl::IsItemSelected( DataBrowserItemID item ) const
+int wxListBox::DoListHitTest(const wxPoint& inpoint) const
{
- return IsDataBrowserItemSelected( m_controlRef, item );
-}
+ OSStatus err;
-OSStatus wxMacDataBrowserListControl::AddItems(
- DataBrowserItemID container,
- UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty )
-{
- return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
-}
+ // There are few reasons why this is complicated:
+ // 1) There is no native HitTest function for Mac
+ // 2) GetDataBrowserItemPartBounds only works on visible items
+ // 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
+ // because what it returns is basically inaccurate in the context
+ // of the coordinates we want here, but we use this as a guess
+ // for where the first visible item lies
-OSStatus wxMacDataBrowserListControl::RemoveItems(
- DataBrowserItemID container,
- UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserPropertyID preSortProperty )
-{
- return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
-}
+ wxPoint point = inpoint;
-OSStatus wxMacDataBrowserListControl::RevealItem(
- DataBrowserItemID item,
- DataBrowserPropertyID propertyID,
- DataBrowserRevealOptions options )
-{
- return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
-}
+ // interestingly enough 10.2 (and below?) have GetDataBrowserItemPartBounds
+ // giving root window coordinates but 10.3 and above give client coordinates
+ // so we only compare using root window coordinates on 10.3 and up
+ if ( UMAGetSystemVersion() < 0x1030 )
+ MacClientToRootWindow(&point.x, &point.y);
-OSStatus wxMacDataBrowserListControl::SetSelectedItems(
- UInt32 numItems,
- const DataBrowserItemID *items,
- DataBrowserSetOption operation )
-{
- return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation );
-}
+ // get column property ID (req. for call to itempartbounds)
+ DataBrowserTableViewColumnID colId = 0;
+ err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
+ wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
-OSStatus wxMacDataBrowserListControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const
-{
- return GetDataBrowserSelectionAnchor( m_controlRef, first, last );
-}
+ // OK, first we need to find the first visible item we have -
+ // this will be the "low" for our binary search. There is no real
+ // easy way around this, as we will need to do a SLOW linear search
+ // until we find a visible item, but we can do a cheap calculation
+ // via the row height to speed things up a bit
+ UInt32 scrollx, scrolly;
+ err = GetDataBrowserScrollPosition(m_peer->GetControlRef(), &scrollx, &scrolly);
+ wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserScrollPosition"));
-#if 0
+ UInt16 height;
+ err = GetDataBrowserTableViewRowHeight(m_peer->GetControlRef(), &height);
+ wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewRowHeight"));
-// in case we need that one day
+ // these indices are 0-based, as usual, so we need to add 1 to them when
+ // passing them to data browser functions which use 1-based indices
+ int low = scrolly / height,
+ high = GetCount() - 1;
-// ============================================================================
-// HIView owner-draw-based implementation
-// ============================================================================
+ // search for the first visible item (note that the scroll guess above
+ // is the low bounds of where the item might lie so we only use that as a
+ // starting point - we should reach it within 1 or 2 iterations of the loop)
+ while ( low <= high )
+ {
+ Rect bounds;
+ err = GetDataBrowserItemPartBounds(
+ m_peer->GetControlRef(), low + 1, colId,
+ kDataBrowserPropertyEnclosingPart,
+ &bounds); // note +1 to translate to Mac ID
+ if ( err == noErr )
+ break;
-static pascal void ListBoxDrawProc(
- ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property,
- DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )
-{
- CFStringRef cfString;
- ThemeDrawingState themeState;
- long systemVersion;
+ // errDataBrowserItemNotFound is expected as it simply means that the
+ // item is not currently visible -- but other errors are not
+ wxCHECK_MSG( err == errDataBrowserItemNotFound, wxNOT_FOUND,
+ wxT("Unexpected error from GetDataBrowserItemPartBounds") );
- GetThemeDrawingState( &themeState );
- cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item );
+ low++;
+ }
- // In this sample we handle the "selected" state; all others fall through to our "active" state
- if ( itemState == kDataBrowserItemIsSelected )
+ // NOW do a binary search for where the item lies, searching low again if
+ // we hit an item that isn't visible
+ while ( low <= high )
{
- ThemeBrush colorBrushID;
+ int mid = (low + high) / 2;
- // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor
- // is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor
- // for inactive browser highlighting
- Gestalt( gestaltSystemVersion, &systemVersion );
- if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) )
- colorBrushID = kThemeBrushSecondaryHighlightColor;
- else
- colorBrushID = kThemeBrushPrimaryHighlightColor;
+ Rect bounds;
+ err = GetDataBrowserItemPartBounds(
+ m_peer->GetControlRef(), mid + 1, colId,
+ kDataBrowserPropertyEnclosingPart,
+ &bounds); //note +1 to trans to mac id
+ wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
+ wxNOT_FOUND,
+ wxT("Unexpected error from GetDataBrowserItemPartBounds") );
- // First paint the hilite rect, then the text on top
- SetThemePen( colorBrushID, 32, true );
- PaintRect( itemRect );
- SetThemeDrawingState( themeState, false );
- }
+ if ( err == errDataBrowserItemNotFound )
+ {
+ // item not visible, attempt to find a visible one
+ // search lower
+ high = mid - 1;
+ }
+ else // visible item, do actual hitttest
+ {
+ // if point is within the bounds, return this item (since we assume
+ // all x coords of items are equal we only test the x coord in
+ // equality)
+ if ((point.x >= bounds.left && point.x <= bounds.right) &&
+ (point.y >= bounds.top && point.y <= bounds.bottom) )
+ {
+ // found!
+ return mid;
+ }
- DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL );
- SetThemeDrawingState( themeState, true );
+ if ( point.y < bounds.top )
+ // index(bounds) greater then key(point)
+ high = mid - 1;
+ else
+ // index(bounds) less then key(point)
+ low = mid + 1;
+ }
+ }
- if ( cfString != NULL )
- CFRelease( cfString );
+ return wxNOT_FOUND;
}
-#endif
// ============================================================================
-// list box control implementation
+// data browser based implementation
// ============================================================================
-wxListBox::wxListBox()
+const short kTextColumnId = 1024;
+const short kNumericOrderColumnId = 1025;
+
+wxMacListBoxItem::wxMacListBoxItem()
{
- m_noItems = 0;
+ m_data = NULL;
+ m_order = 0;
}
-bool wxListBox::Create(
- wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString& name )
+wxMacListBoxItem::~wxMacListBoxItem()
{
- wxCArrayString chs(choices);
-
- return Create(
- parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
- style, validator, name );
}
-bool wxListBox::Create(
- wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- int n,
- const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name )
+void wxMacListBoxItem::SetOrder( SInt32 order )
{
- m_macIsUserPane = false;
-
- wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
- wxT("only a single listbox selection mode can be specified") );
-
- if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
- return false;
-
- // this will be increased by our append command
- m_noItems = 0;
-
- m_peer = CreateMacListControl( pos, size, style );
-
- MacPostControlCreate( pos, size );
-
- InsertItems( n, choices, 0 );
-
- // Needed because it is a wxControlWithItems
- SetBestSize( size );
-
- return true;
+ m_order = order;
}
-wxListBox::~wxListBox()
+SInt32 wxMacListBoxItem::GetOrder() const
{
- m_peer->SetReference( 0 );
- FreeData();
+ return m_order;
}
-wxMacListControl * wxListBox::CreateMacListControl(const wxPoint& pos, const wxSize& size, long style)
+void wxMacListBoxItem::SetData( void* data)
{
- return new wxMacDataBrowserListControl( this, pos, size, style );
+ m_data = data;
}
-void wxListBox::FreeData()
+void* wxMacListBoxItem::GetData() const
{
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
- {
- size_t uiCount = m_aItems.Count();
- while ( uiCount != 0 )
- {
- uiCount--;
- delete m_aItems[uiCount];
- m_aItems[uiCount] = NULL;
- }
-
- m_aItems.Clear();
- }
- else
-#endif
- if ( HasClientObjectData() )
- {
- for ( unsigned int n = 0; n < m_noItems; n++ )
- {
- delete GetClientObject( n );
- }
- }
+ return m_data;
}
-void wxListBox::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags )
+void wxMacListBoxItem::SetLabel( const wxString& str)
{
- wxControl::DoSetSize( x, y, width, height, sizeFlags );
+ m_label = str;
+ m_cfLabel.Assign( str , wxLocale::GetSystemEncoding());
}
-void wxListBox::DoSetFirstItem(int n)
+const wxString& wxMacListBoxItem::GetLabel() const
{
- GetPeer()->MacScrollTo( n );
+ return m_label;
}
-void wxListBox::Delete(unsigned int n)
+bool wxMacListBoxItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
+ const wxMacDataItem* rhs,
+ DataBrowserPropertyID sortProperty) const
{
- wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::Delete") );
-
-#if wxUSE_OWNER_DRAWN
- delete m_aItems[n];
- m_aItems.RemoveAt(n);
-#else
- if ( HasClientObjectData() )
+ const wxMacListBoxItem* otherItem = dynamic_cast<const wxMacListBoxItem*>(rhs);
+ bool retval = false;
+ switch (sortProperty)
{
- delete GetClientObject(n);
- }
-#endif
-
- m_stringArray.RemoveAt( n );
- m_dataArray.RemoveAt( n );
- m_noItems--;
-
- GetPeer()->MacDelete( n );
-}
+ case kTextColumnId:
+ retval = m_label.CmpNoCase( otherItem->m_label) < 0;
+ break;
-int wxListBox::DoAppend(const wxString& item)
-{
- InvalidateBestSize();
+ case kNumericOrderColumnId:
+ retval = m_order < otherItem->m_order;
+ break;
- unsigned int index = m_noItems;
- m_stringArray.Add( item );
- m_dataArray.Add( NULL );
- m_noItems++;
- DoSetItemClientData( index, NULL );
- GetPeer()->MacAppend( item );
+ default:
+ break;
+ };
- return index;
+ return retval;
}
-void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
+OSStatus wxMacListBoxItem::GetSetData( wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue )
{
- Clear();
- unsigned int n = choices.GetCount();
+ OSStatus err = errDataBrowserPropertyNotSupported;
+ wxListBox *list = wxDynamicCast( owner->GetPeer() , wxListBox );
+ wxCHECK_MSG( list != NULL , errDataBrowserPropertyNotSupported , wxT("Listbox expected"));
+ wxCheckListBox *checklist = wxDynamicCast( list , wxCheckListBox );
- for ( size_t i = 0; i < n; ++i )
+ if ( !changeValue )
{
- if ( clientData )
+ switch (property)
{
-#if wxUSE_OWNER_DRAWN
- wxASSERT_MSG(clientData[i] == NULL,
- wxT("Cannot use client data with owner-drawn listboxes"));
-#else
- Append( choices[i], clientData[i] );
-#endif
+ case kTextColumnId:
+ err = ::SetDataBrowserItemDataText( itemData, m_cfLabel );
+ err = noErr;
+ break;
+
+ case kNumericOrderColumnId:
+ err = ::SetDataBrowserItemDataValue( itemData, m_order );
+ err = noErr;
+ break;
+
+ default:
+ break;
}
- else
- Append( choices[i] );
}
-
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
+ else
{
- // first delete old items
- size_t ui = m_aItems.Count();
- while ( ui != 0 )
+ switch (property)
{
- ui--;
- delete m_aItems[ui];
- m_aItems[ui] = NULL;
+ // no editable props here
+ default:
+ break;
}
+ }
+
+ return err;
+}
- m_aItems.Empty();
+void wxMacListBoxItem::Notification(wxMacDataItemBrowserControl *owner ,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData ) const
+{
+ wxMacDataBrowserListControl *lb = dynamic_cast<wxMacDataBrowserListControl*>(owner);
- // then create new ones
- for ( ui = 0; ui < (size_t)m_noItems; ui++ )
+ // we want to depend on as little as possible to make sure tear-down of controls is safe
+
+ if ( message == kDataBrowserItemRemoved)
+ {
+ if ( lb != NULL && lb->GetClientDataType() == wxClientData_Object )
{
- wxOwnerDrawn *pNewItem = CreateItem(ui);
- pNewItem->SetName(choices[ui]);
- m_aItems.Add(pNewItem);
+ delete (wxClientData*) (m_data);
}
+
+ delete this;
+ return;
}
-#endif
-}
+
+ wxListBox *list = wxDynamicCast( owner->GetPeer() , wxListBox );
+ wxCHECK_RET( list != NULL , wxT("Listbox expected"));
-int wxListBox::FindString(const wxString& s, bool bCase) const
-{
- for ( size_t i = 0; i < m_noItems; ++ i )
+ bool trigger = false;
+ wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
+ switch (message)
{
- if (s.IsSameAs( GetString( i ), bCase) )
- return (int)i;
- }
+ case kDataBrowserItemDeselected:
+ if ( list->HasMultipleSelection() )
+ trigger = !lb->IsSelectionSuppressed();
+ break;
- return wxNOT_FOUND;
-}
+ case kDataBrowserItemSelected:
+ trigger = !lb->IsSelectionSuppressed();
+ break;
-void wxListBox::Clear()
-{
- FreeData();
- m_noItems = 0;
- m_stringArray.Empty();
- m_dataArray.Empty();
- GetPeer()->MacClear();
-}
+ case kDataBrowserItemDoubleClicked:
+ event.SetEventType( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED );
+ trigger = true;
+ break;
-void wxListBox::DoSetSelection(int n, bool select)
-{
- wxCHECK_RET( n == wxNOT_FOUND || IsValid(n),
- wxT("invalid index in wxListBox::SetSelection") );
+ default:
+ break;
+ }
- if ( n == wxNOT_FOUND )
- GetPeer()->MacDeselectAll();
- else
- GetPeer()->MacSetSelection( n, select );
+ if ( trigger )
+ {
+ event.SetEventObject( list );
+ if ( list->HasClientObjectData() )
+ event.SetClientObject( (wxClientData*) m_data );
+ else if ( list->HasClientUntypedData() )
+ event.SetClientData( m_data );
+ event.SetString( m_label );
+ event.SetInt( owner->GetLineFromItem( this ) );
+ event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true );
+ wxPostEvent( list->GetEventHandler(), event );
+
+ // direct notification is not always having the listbox GetSelection() having in synch with event
+ // list->GetEventHandler()->ProcessEvent(event);
+ }
}
-bool wxListBox::IsSelected(int n) const
+wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
+ : wxMacDataItemBrowserControl( peer, pos, size, style )
{
- wxCHECK_MSG( IsValid(n), false, wxT("invalid index in wxListBox::Selected") );
-
- return GetPeer()->MacIsSelected( n );
-}
+ OSStatus err = noErr;
+ m_clientDataItemsType = wxClientData_None;
+ m_stringSorted = style & wxLB_SORT;
+
+ DataBrowserSelectionFlags options = kDataBrowserDragSelect;
+ if ( style & wxLB_MULTIPLE )
+ {
+ options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
+ }
+ else if ( style & wxLB_EXTENDED )
+ {
+ // default behaviour
+ }
+ else
+ {
+ options |= kDataBrowserSelectOnlyOne;
+ }
+ err = SetSelectionFlags( options );
+ verify_noerr( err );
+
+ DataBrowserListViewColumnDesc columnDesc;
+ columnDesc.headerBtnDesc.titleOffset = 0;
+ columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
-void *wxListBox::DoGetItemClientData(unsigned int n) const
-{
- wxCHECK_MSG( IsValid(n), NULL, wxT("invalid index in wxListBox::GetClientData"));
+ columnDesc.headerBtnDesc.btnFontStyle.flags =
+ kControlUseFontMask | kControlUseJustMask;
- wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int)n, wxT("invalid client_data array") );
+ columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
+ columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
+ columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
+ columnDesc.headerBtnDesc.btnFontStyle.style = normal;
+ columnDesc.headerBtnDesc.titleString = NULL;
- return (void*)m_dataArray[n];
-}
+ columnDesc.headerBtnDesc.minimumWidth = 0;
+ columnDesc.headerBtnDesc.maximumWidth = 10000;
-wxClientData *wxListBox::DoGetItemClientObject(unsigned int n) const
-{
- return (wxClientData*)DoGetItemClientData( n );
-}
+ columnDesc.propertyDesc.propertyID = kTextColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
+ columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
+#endif
-void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
-{
- wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") );
+ verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
- {
- // client data must be pointer to wxOwnerDrawn, otherwise we would crash
- // in OnMeasure/OnDraw.
- wxFAIL_MSG(wxT("Cannot use client data with owner-drawn listboxes"));
- }
+ columnDesc.headerBtnDesc.minimumWidth = 0;
+ columnDesc.headerBtnDesc.maximumWidth = 0;
+ columnDesc.propertyDesc.propertyID = kNumericOrderColumnId;
+ columnDesc.propertyDesc.propertyType = kDataBrowserPropertyRelevanceRankPart;
+ columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
#endif
- wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int)n, wxT("invalid client_data array") );
+ verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
- if ( m_dataArray.GetCount() > (unsigned int)n )
- m_dataArray[n] = (char*)clientData;
+ SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
+ if ( m_stringSorted )
+ {
+ SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
+ SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
+ }
else
- m_dataArray.Add( (char*)clientData );
-}
-
-void wxListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
- DoSetItemClientData(n, clientData);
-}
+ {
+ SetDataBrowserSortProperty( m_controlRef , kNumericOrderColumnId);
+ SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
+ }
-// Return number of selections and an array of selected integers
-int wxListBox::GetSelections(wxArrayInt& aSelections) const
-{
- return GetPeer()->MacGetSelections( aSelections );
+ verify_noerr( AutoSizeColumns() );
+ verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );
+ verify_noerr( SetHeaderButtonHeight( 0 ) );
+ err = SetHasScrollBars( (style & wxHSCROLL) != 0 , true );
+#if 0
+ // shouldn't be necessary anymore under 10.2
+ m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
+ m_peer->SetNeedsFocusRect( true );
+#endif
}
-// Get single selection, for single choice list items
-int wxListBox::GetSelection() const
+wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
{
- return GetPeer()->MacGetSelection();
}
-// Find string for position
-wxString wxListBox::GetString(unsigned int n) const
+
+wxMacListBoxItem* wxMacDataBrowserListControl::CreateItem()
{
- wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxListBox::GetString") );
+ return new wxMacListBoxItem();
+}
- return m_stringArray[n];
+wxListBox * wxMacDataBrowserListControl::GetPeer() const
+{
+ return wxDynamicCast( wxMacControl::GetPeer() , wxListBox );
}
-void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
+wxClientDataType wxMacDataBrowserListControl::GetClientDataType() const
{
- wxCHECK_RET( IsValidInsert(pos), wxT("invalid index in wxListBox::InsertItems") );
-
- InvalidateBestSize();
-
- unsigned int nItems = items.GetCount();
+ return m_clientDataItemsType;
+}
+void wxMacDataBrowserListControl::SetClientDataType(wxClientDataType clientDataItemsType)
+{
+ m_clientDataItemsType = clientDataItemsType;
+}
- for ( unsigned int i = 0; i < nItems; i++ )
- m_stringArray.Insert( items[i], pos + i );
- m_dataArray.Insert( NULL, pos, nItems );
- m_noItems += nItems;
- GetPeer()->MacInsert( pos, items );
+unsigned int wxMacDataBrowserListControl::MacGetCount() const
+{
+ return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemNoState);
}
-void wxListBox::SetString(unsigned int n, const wxString& s)
+void wxMacDataBrowserListControl::MacDelete( unsigned int n )
{
- m_stringArray[n] = s;
- GetPeer()->MacSet( n, s );
+ wxMacListBoxItem* item = (wxMacListBoxItem*)GetItemFromLine( n );
+ RemoveItem( wxMacDataBrowserRootContainer, item );
}
-wxSize wxListBox::DoGetBestSize() const
+void wxMacDataBrowserListControl::MacInsert( unsigned int n, const wxString& text)
{
- int lbWidth = 100; // some defaults
- int lbHeight = 110;
- int wLine;
+ wxMacListBoxItem* newItem = CreateItem();
+ newItem->SetLabel( text );
+ if ( !m_stringSorted )
{
- wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) );
-
- // TODO: clean this up
- if ( m_font.Ok() )
+ // increase the order of the lines to be shifted
+ unsigned int lines = MacGetCount();
+ for ( unsigned int i = n; i < lines; ++i)
{
- ::TextFont( m_font.MacGetFontNum() );
- ::TextSize( m_font.MacGetFontSize() );
- ::TextFace( m_font.MacGetFontStyle() );
+ wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(i);
+ iter->SetOrder( iter->GetOrder() + 1 );
}
- else
+
+ SInt32 frontLineOrder = 0;
+ if ( n > 0 )
{
- ::TextFont( kFontIDMonaco );
- ::TextSize( 9 );
- ::TextFace( 0 );
+ wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(n-1);
+ frontLineOrder = iter->GetOrder();
}
+ newItem->SetOrder( frontLineOrder + 1 );
+ }
+
+ AddItem( wxMacDataBrowserRootContainer, newItem );
+}
- // Find the widest line
- for (unsigned int i = 0; i < GetCount(); i++)
+void wxMacDataBrowserListControl::MacInsert( unsigned int n, const wxArrayString& items)
+{
+ size_t itemsCount = items.GetCount();
+ if ( itemsCount == 0 )
+ return;
+
+ SInt32 frontLineOrder = 0;
+
+ if ( !m_stringSorted )
+ {
+ // increase the order of the lines to be shifted
+ unsigned int lines = MacGetCount();
+ for ( unsigned int i = n; i < lines; ++i)
{
- wxString str( GetString( i ) );
-
-#if wxUSE_UNICODE
- Point bounds = {0, 0};
- SInt16 baseline;
-
- // NB: what if m_font.Ok() == false ???
- ::GetThemeTextDimensions(
- wxMacCFStringHolder( str, m_font.GetEncoding() ),
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- wLine = bounds.h;
-#else
- wLine = ::TextWidth( str.c_str(), 0, str.length() );
-#endif
-
- lbWidth = wxMax( lbWidth, wLine );
+ wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(i);
+ iter->SetOrder( iter->GetOrder() + itemsCount );
+ }
+ if ( n > 0 )
+ {
+ wxMacListBoxItem* iter = (wxMacListBoxItem*) GetItemFromLine(n-1);
+ frontLineOrder = iter->GetOrder();
}
+ }
- // Add room for the scrollbar
- lbWidth += wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
+ wxArrayMacDataItemPtr ids;
+ ids.SetCount( itemsCount );
- // And just a bit more
- int cy = 12;
- int cx = ::TextWidth( "X", 0, 1 );
- lbWidth += cx;
+ for ( unsigned int i = 0; i < itemsCount; ++i )
+ {
+ wxMacListBoxItem* item = CreateItem();
+ item->SetLabel( items[i]);
+ if ( !m_stringSorted )
+ item->SetOrder( frontLineOrder + 1 + i );
- // don't make the listbox too tall (limit height to around 10 items)
- // but don't make it too small neither
- lbHeight = wxMax( (cy + 4) * wxMin( wxMax( GetCount(), 3 ), 10 ), 70 );
+ ids[i] = item;
}
- return wxSize( lbWidth, lbHeight );
+ AddItems( wxMacDataBrowserRootContainer, ids );
}
-unsigned int wxListBox::GetCount() const
+int wxMacDataBrowserListControl::MacAppend( const wxString& text)
{
- return m_noItems;
+ wxMacListBoxItem* item = CreateItem();
+ item->SetLabel( text );
+ if ( !m_stringSorted )
+ {
+ unsigned int lines = MacGetCount();
+ if ( lines == 0 )
+ item->SetOrder( 1 );
+ else
+ {
+ wxMacListBoxItem* frontItem = (wxMacListBoxItem*) GetItemFromLine(lines-1);
+ item->SetOrder( frontItem->GetOrder() + 1 );
+ }
+ }
+ AddItem( wxMacDataBrowserRootContainer, item );
+
+ return GetLineFromItem(item);
}
-void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
+void wxMacDataBrowserListControl::MacClear()
{
- wxControl::Refresh( eraseBack, rect );
+ wxMacDataItemBrowserSelectionSuppressor suppressor(this);
+ RemoveAllItems(wxMacDataBrowserRootContainer);
}
-void wxListBox::MacUpdateLine(int n)
+void wxMacDataBrowserListControl::MacDeselectAll()
{
- GetPeer()->UpdateLine(n);
+ wxMacDataItemBrowserSelectionSuppressor suppressor(this);
+ SetSelectedAllItems( kDataBrowserItemsRemove );
}
-#if wxUSE_OWNER_DRAWN
-
-class wxListBoxItem : public wxOwnerDrawn
+void wxMacDataBrowserListControl::MacSetSelection( unsigned int n, bool select )
{
-public:
- wxListBoxItem(const wxString& str = "");
-};
+ wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine(n);
+ wxMacDataItemBrowserSelectionSuppressor suppressor(this);
-wxListBoxItem::wxListBoxItem(const wxString& str)
- : wxOwnerDrawn(str, false)
-{
- // no bitmaps/checkmarks
- SetMarginWidth( 0 );
+ if ( IsItemSelected( item ) != select )
+ {
+ if ( select )
+ SetSelectedItem( item, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
+ else
+ SetSelectedItem( item, kDataBrowserItemsRemove );
+ }
+
+ MacScrollTo( n );
}
-wxOwnerDrawn *wxListBox::CreateItem(size_t n)
+bool wxMacDataBrowserListControl::MacIsSelected( unsigned int n ) const
{
- return new wxListBoxItem();
+ wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine(n);
+ return IsItemSelected( item );
}
-#endif // USE_OWNER_DRAWN
+int wxMacDataBrowserListControl::MacGetSelection() const
+{
+ wxMacDataItemPtr first, last;
+ GetSelectionAnchor( &first, &last );
+ if ( first != NULL )
+ {
+ return GetLineFromItem( first );
+ }
-// Some custom controls depend on this
-/* static */ wxVisualAttributes
-wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+ return -1;
+}
+
+int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) const
{
- wxVisualAttributes attr;
+ aSelections.Empty();
+ wxArrayMacDataItemPtr selectedItems;
+ GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
- attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
- attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
- attr.font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
+ int count = selectedItems.GetCount();
- return attr;
+ for ( int i = 0; i < count; ++i)
+ {
+ aSelections.Add(GetLineFromItem(selectedItems[i]));
+ }
+
+ return count;
}
-int wxListBox::DoListHitTest(const wxPoint& inpoint) const
+void wxMacDataBrowserListControl::MacSetString( unsigned int n, const wxString& text )
{
- OSStatus err;
-
- // There are few reasons why this is complicated:
- // 1) There is no native HitTest function for Mac
- // 2) GetDataBrowserItemPartBounds only works on visible items
- // 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
- // because what it returns is basically inaccurate in the context
- // of the coordinates we want here, but we use this as a guess
- // for where the first visible item lies
+ // as we don't store the strings we only have to issue a redraw
+ wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine( n);
+ item->SetLabel( text );
+ UpdateItem( wxMacDataBrowserRootContainer, item , kTextColumnId );
+}
- wxPoint point = inpoint;
+wxString wxMacDataBrowserListControl::MacGetString( unsigned int n ) const
+{
+ wxMacListBoxItem * item = (wxMacListBoxItem*) GetItemFromLine( n );
+ return item->GetLabel();
+}
- // interestingly enough 10.2 (and below?) have GetDataBrowserItemPartBounds
- // giving root window coordinates but 10.3 and above give client coordinates
- // so we only compare using root window coordinates on 10.3 and up
- if ( UMAGetSystemVersion() < 0x1030 )
- MacClientToRootWindow(&point.x, &point.y);
+void wxMacDataBrowserListControl::MacSetClientData( unsigned int n, void * data)
+{
+ wxMacListBoxItem* item = (wxMacListBoxItem*) GetItemFromLine( n);
+ item->SetData( data );
+ // not displayed, therefore no Update infos to DataBrowser
+}
- // get column property ID (req. for call to itempartbounds)
- DataBrowserTableViewColumnID colId = 0;
- err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
- wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
+void * wxMacDataBrowserListControl::MacGetClientData( unsigned int n) const
+{
+ wxMacListBoxItem * item = (wxMacListBoxItem*) GetItemFromLine( n );
+ return item->GetData();
+}
- // OK, first we need to find the first visible item we have -
- // this will be the "low" for our binary search. There is no real
- // easy way around this, as we will need to do a SLOW linear search
- // until we find a visible item, but we can do a cheap calculation
- // via the row height to speed things up a bit
- UInt32 scrollx, scrolly;
- err = GetDataBrowserScrollPosition(m_peer->GetControlRef(), &scrollx, &scrolly);
- wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserScrollPosition"));
+void wxMacDataBrowserListControl::MacScrollTo( unsigned int n )
+{
+ RevealItem( GetItemFromLine( n) , kDataBrowserRevealWithoutSelecting );
+}
- UInt16 height;
- err = GetDataBrowserTableViewRowHeight(m_peer->GetControlRef(), &height);
- wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewRowHeight"));
+#if 0
- // these indices are 0-based, as usual, so we need to add 1 to them when
- // passing them to data browser functions which use 1-based indices
- int low = scrolly / height,
- high = GetCount() - 1;
+// in case we need that one day
- // search for the first visible item (note that the scroll guess above
- // is the low bounds of where the item might lie so we only use that as a
- // starting point - we should reach it within 1 or 2 iterations of the loop)
- while ( low <= high )
- {
- Rect bounds;
- err = GetDataBrowserItemPartBounds(
- m_peer->GetControlRef(), low + 1, colId,
- kDataBrowserPropertyEnclosingPart,
- &bounds); // note +1 to translate to Mac ID
- if ( err == noErr )
- break;
+// ============================================================================
+// HIView owner-draw-based implementation
+// ============================================================================
- // errDataBrowserItemNotFound is expected as it simply means that the
- // item is not currently visible -- but other errors are not
- wxCHECK_MSG( err == errDataBrowserItemNotFound, wxNOT_FOUND,
- wxT("Unexpected error from GetDataBrowserItemPartBounds") );
+static pascal void ListBoxDrawProc(
+ ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property,
+ DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )
+{
+ CFStringRef cfString;
+ ThemeDrawingState themeState;
+ long systemVersion;
- low++;
- }
+ GetThemeDrawingState( &themeState );
+ cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item );
- // NOW do a binary search for where the item lies, searching low again if
- // we hit an item that isn't visible
- while ( low <= high )
+ // In this sample we handle the "selected" state; all others fall through to our "active" state
+ if ( itemState == kDataBrowserItemIsSelected )
{
- int mid = (low + high) / 2;
-
- Rect bounds;
- err = GetDataBrowserItemPartBounds(
- m_peer->GetControlRef(), mid + 1, colId,
- kDataBrowserPropertyEnclosingPart,
- &bounds); //note +1 to trans to mac id
- wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
- wxNOT_FOUND,
- wxT("Unexpected error from GetDataBrowserItemPartBounds") );
+ ThemeBrush colorBrushID;
- if ( err == errDataBrowserItemNotFound )
- {
- // item not visible, attempt to find a visible one
- // search lower
- high = mid - 1;
- }
- else // visible item, do actual hitttest
- {
- // if point is within the bounds, return this item (since we assume
- // all x coords of items are equal we only test the x coord in
- // equality)
- if ((point.x >= bounds.left && point.x <= bounds.right) &&
- (point.y >= bounds.top && point.y <= bounds.bottom) )
- {
- // found!
- return mid;
- }
+ // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor
+ // is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor
+ // for inactive browser highlighting
+ Gestalt( gestaltSystemVersion, &systemVersion );
+ if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) )
+ colorBrushID = kThemeBrushSecondaryHighlightColor;
+ else
+ colorBrushID = kThemeBrushPrimaryHighlightColor;
- if ( point.y < bounds.top )
- // index(bounds) greater then key(point)
- high = mid - 1;
- else
- // index(bounds) less then key(point)
- low = mid + 1;
- }
+ // First paint the hilite rect, then the text on top
+ SetThemePen( colorBrushID, 32, true );
+ PaintRect( itemRect );
+ SetThemeDrawingState( themeState, false );
}
- return wxNOT_FOUND;
+ DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL );
+ SetThemeDrawingState( themeState, true );
+
+ if ( cfString != NULL )
+ CFRelease( cfString );
}
#endif
+
+
+#endif
#include "wx/mac/private.h"
#if defined(__MWERKS__) && wxUSE_UNICODE
+#if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
#include <wtime.h>
#endif
+#endif
// ---------------------------------------------------------------------------
// code used in both base and GUI compilation
// our OS version is the same in non GUI and GUI cases
static int DoGetOSVersion(int *majorVsn, int *minorVsn)
{
- long theSystem ;
+ long theSystem;
// are there x-platform conventions ?
- Gestalt(gestaltSystemVersion, &theSystem) ;
+ Gestalt(gestaltSystemVersion, &theSystem);
if (minorVsn != NULL)
- *minorVsn = (theSystem & 0xFF) ;
+ *minorVsn = (theSystem & 0xFF);
if (majorVsn != NULL)
- *majorVsn = (theSystem >> 8) ;
+ *majorVsn = (theSystem >> 8);
#ifdef __DARWIN__
return wxMAC_DARWIN;
// Get user ID e.g. jacs
bool wxGetUserId(wxChar *buf, int maxSize)
{
- return wxGetUserName( buf , maxSize ) ;
+ return wxGetUserName( buf , maxSize );
}
const wxChar* wxGetHomeDir(wxString *pstr)
{
- *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ;
- return pstr->c_str() ;
+ *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder );
+ return pstr->c_str();
}
// Get hostname only (without domain name)
bool wxGetHostName(wxChar *buf, int maxSize)
{
// Gets Chooser name of user by examining a System resource.
- buf[0] = 0 ;
+ buf[0] = 0;
const short kComputerNameID = -16413;
- short oldResFile = CurResFile() ;
+ short oldResFile = CurResFile();
UseResFile(0);
StringHandle chooserName = (StringHandle)::GetString(kComputerNameID);
UseResFile(oldResFile);
if (chooserName && *chooserName)
{
- HLock( (Handle) chooserName ) ;
- wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
- HUnlock( (Handle) chooserName ) ;
- ReleaseResource( (Handle) chooserName ) ;
- wxStrncpy( buf , name , maxSize - 1 ) ;
+ HLock( (Handle) chooserName );
+ wxString name = wxMacMakeStringFromPascal( *chooserName );
+ HUnlock( (Handle) chooserName );
+ ReleaseResource( (Handle) chooserName );
+ wxStrncpy( buf , name , maxSize - 1 );
}
return true;
bool wxGetUserName(wxChar *buf, int maxSize)
{
// Gets Chooser name of user by examining a System resource.
- buf[0] = 0 ;
+ buf[0] = 0;
const short kChooserNameID = -16096;
- short oldResFile = CurResFile() ;
+ short oldResFile = CurResFile();
UseResFile(0);
StringHandle chooserName = (StringHandle)::GetString(kChooserNameID);
UseResFile(oldResFile);
if (chooserName && *chooserName)
{
- HLock( (Handle) chooserName ) ;
- wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
- HUnlock( (Handle) chooserName ) ;
- ReleaseResource( (Handle) chooserName ) ;
- wxStrncpy( buf , name , maxSize - 1 ) ;
+ HLock( (Handle) chooserName );
+ wxString name = wxMacMakeStringFromPascal( *chooserName );
+ HUnlock( (Handle) chooserName );
+ ReleaseResource( (Handle) chooserName );
+ wxStrncpy( buf , name , maxSize - 1 );
}
return true;
WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
{
// TODO : under classic there is no environement support, under X yes
- return false ;
+ return false;
}
// set the env var name to the given value, return true on success
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
{
// TODO : under classic there is no environement support, under X yes
- return false ;
+ return false;
}
// Execute a program in an Interactive Shell
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
wxMemorySize wxGetFreeMemory()
{
- return (wxMemorySize)FreeMem() ;
+ return (wxMemorySize)FreeMem();
}
#ifndef __DARWIN__
#endif // wxUSE_RESOURCES
int gs_wxBusyCursorCount = 0;
-extern wxCursor gMacCurrentCursor ;
-wxCursor gMacStoredActiveCursor ;
+extern wxCursor gMacCurrentCursor;
+wxCursor gMacStoredActiveCursor;
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(const wxCursor *cursor)
{
if (gs_wxBusyCursorCount++ == 0)
{
- gMacStoredActiveCursor = gMacCurrentCursor ;
- cursor->MacInstall() ;
+ gMacStoredActiveCursor = gMacCurrentCursor;
+ cursor->MacInstall();
}
//else: nothing to do, already set
}
if (--gs_wxBusyCursorCount == 0)
{
- gMacStoredActiveCursor.MacInstall() ;
- gMacStoredActiveCursor = wxNullCursor ;
+ gMacStoredActiveCursor.MacInstall();
+ gMacStoredActiveCursor = wxNullCursor;
}
}
OSType folderType,
Boolean createFolder)
{
- FSRef fsRef ;
- wxString strDir ;
+ FSRef fsRef;
+ wxString strDir;
if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
{
strDir = wxMacFSRefToPath( &fsRef );
}
- return strDir ;
+ return strDir;
}
wxString wxMacFindFolder( short vol,
void wxGetMousePosition( int* x, int* y )
{
- Point pt ;
+ Point pt;
- GetMouse( &pt ) ;
- LocalToGlobal( &pt ) ;
- *x = pt.h ;
- *y = pt.v ;
+ GetMouse( &pt );
+ LocalToGlobal( &pt );
+ *x = pt.h;
+ *y = pt.v;
};
// Return true if we have a colour display
// Returns depth of screen
int wxDisplayDepth()
{
- Rect globRect ;
+ Rect globRect;
SetRect(&globRect, -32760, -32760, 32760, 32760);
GDHandle theMaxDevice;
if (theMaxDevice != NULL)
theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
- return theDepth ;
+ return theDepth;
}
// Get size of display
GetQDGlobalsScreenBits( &screenBits );
if (width != NULL)
- *width = screenBits.bounds.right - screenBits.bounds.left ;
+ *width = screenBits.bounds.right - screenBits.bounds.left;
if (height != NULL)
- *height = screenBits.bounds.bottom - screenBits.bounds.top ;
+ *height = screenBits.bounds.bottom - screenBits.bounds.top;
}
void wxDisplaySizeMM(int *width, int *height)
{
wxDisplaySize(width, height);
- // on mac 72 is fixed (at least now ;-)
+ // on mac 72 is fixed (at least now;-)
float cvPt2Mm = 25.4 / 72;
if (width != NULL)
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
{
- Rect r ;
+ Rect r;
- GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ;
+ GetAvailableWindowPositioningBounds( GetMainDevice() , &r );
if ( x )
- *x = r.left ;
+ *x = r.left;
if ( y )
- *y = r.top ;
+ *y = r.top;
if ( width )
- *width = r.right - r.left ;
+ *width = r.right - r.left;
if ( height )
- *height = r.bottom - r.top ;
+ *height = r.bottom - r.top;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
// use configure generated description if available
return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")"));
#else
- return wxT("MacOS") ; //TODO:define further
+ return wxT("MacOS"); //TODO:define further
#endif
}
if ( path.empty() )
return false;
- wxString p = path ;
+ wxString p = path;
if (p[0u] == ':' )
- p = wxGetCwd() + p ;
+ p = wxGetCwd() + p;
- int pos = p.Find(':') ;
+ int pos = p.Find(':');
if ( pos != wxNOT_FOUND )
- p = p.Mid(1,pos) ;
+ p = p.Mid(1,pos);
- p = p + wxT(":") ;
+ p = p + wxT(":");
- OSErr err = noErr ;
+ OSErr err = noErr;
- FSRef fsRef ;
- err = wxMacPathToFSRef( p , &fsRef ) ;
+ FSRef fsRef;
+ err = wxMacPathToFSRef( p , &fsRef );
if ( noErr == err )
{
- FSVolumeRefNum vRefNum ;
- err = FSGetVRefNum( &fsRef , &vRefNum ) ;
+ FSVolumeRefNum vRefNum;
+ err = FSGetVRefNum( &fsRef , &vRefNum );
if ( noErr == err )
{
- UInt64 freeBytes , totalBytes ;
- err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes ) ;
+ UInt64 freeBytes , totalBytes;
+ err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes );
if ( noErr == err )
{
if ( pTotal )
- *pTotal = wxDiskspaceSize_t( totalBytes ) ;
+ *pTotal = wxDiskspaceSize_t( totalBytes );
if ( pFree )
- *pFree = wxDiskspaceSize_t( freeBytes ) ;
+ *pFree = wxDiskspaceSize_t( freeBytes );
}
}
}
- return err == noErr ;
+ return err == noErr;
}
#endif // !__DARWIN__
void wxMacStringToPascal( const wxString&from , StringPtr to )
{
- wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
- int len = strlen(buf) ;
+ wxCharBuffer buf = from.mb_str( wxConvLocal );
+ int len = strlen(buf);
if ( len > 255 )
- len = 255 ;
- to[0] = len ;
- memcpy( (char*) &to[1] , buf , len ) ;
+ len = 255;
+ to[0] = len;
+ memcpy( (char*) &to[1] , buf , len );
}
wxString wxMacMakeStringFromPascal( ConstStringPtr from )
{
- return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ;
+ return wxString( (char*) &from[1] , wxConvLocal , from[0] );
}
// ----------------------------------------------------------------------------
// Common Event Support
// ----------------------------------------------------------------------------
-extern ProcessSerialNumber gAppProcess ;
+extern ProcessSerialNumber gAppProcess;
void wxMacWakeUp()
{
- ProcessSerialNumber psn ;
- Boolean isSame ;
- psn.highLongOfPSN = 0 ;
- psn.lowLongOfPSN = kCurrentProcess ;
- SameProcess( &gAppProcess , &psn , &isSame ) ;
+ ProcessSerialNumber psn;
+ Boolean isSame;
+ psn.highLongOfPSN = 0;
+ psn.lowLongOfPSN = kCurrentProcess;
+ SameProcess( &gAppProcess , &psn , &isSame );
if ( isSame )
{
#if TARGET_CARBON
- OSStatus err = noErr ;
+ OSStatus err = noErr;
#if 0
// lead sometimes to race conditions, although all calls used should be thread safe ...
- static wxMacCarbonEvent s_wakeupEvent ;
+ static wxMacCarbonEvent s_wakeupEvent;
if ( !s_wakeupEvent.IsValid() )
{
err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
- kEventAttributeNone ) ;
+ kEventAttributeNone );
}
if ( err == noErr )
{
if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) )
- return ;
- s_wakeupEvent.SetCurrentTime() ;
+ return;
+ s_wakeupEvent.SetCurrentTime();
err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent,
kEventPriorityHigh );
}
#else
- wxMacCarbonEvent wakeupEvent ;
+ wxMacCarbonEvent wakeupEvent;
wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
- kEventAttributeNone ) ;
+ kEventAttributeNone );
err = PostEventToQueue(GetMainEventQueue(), wakeupEvent,
kEventPriorityHigh );
#endif
#else
- PostEvent( nullEvent , 0 ) ;
+ PostEvent( nullEvent , 0 );
#endif
}
else
{
- WakeUpProcess( &gAppProcess ) ;
+ WakeUpProcess( &gAppProcess );
}
}
void wxMacRectToNative( const wxRect *wx , Rect *n )
{
- n->left = wx->x ;
- n->top = wx->y ;
- n->right = wx->x + wx->width ;
- n->bottom = wx->y + wx->height ;
+ n->left = wx->x;
+ n->top = wx->y;
+ n->right = wx->x + wx->width;
+ n->bottom = wx->y + wx->height;
}
void wxMacNativeToRect( const Rect *n , wxRect* wx )
{
- wx->x = n->left ;
- wx->y = n->top ;
- wx->width = n->right - n->left ;
- wx->height = n->bottom - n->top ;
+ wx->x = n->left;
+ wx->y = n->top;
+ wx->width = n->right - n->left;
+ wx->height = n->bottom - n->top;
}
void wxMacPointToNative( const wxPoint* wx , Point *n )
{
- n->h = wx->x ;
- n->v = wx->y ;
+ n->h = wx->x;
+ n->v = wx->y;
}
void wxMacNativeToPoint( const Point *n , wxPoint* wx )
{
- wx->x = n->h ;
- wx->y = n->v ;
+ wx->x = n->h;
+ wx->y = n->v;
}
// ----------------------------------------------------------------------------
OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData)
{
- return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ;
+ return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData );
}
OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData)
{
- return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ;
+ return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData );
}
// ----------------------------------------------------------------------------
wxMacControl::wxMacControl(wxWindow* peer , bool isRootControl )
{
- Init() ;
- m_peer = peer ;
- m_isRootControl = isRootControl ;
- m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ;
+ Init();
+ m_peer = peer;
+ m_isRootControl = isRootControl;
+ m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing();
}
wxMacControl::wxMacControl( wxWindow* peer , ControlRef control )
{
- Init() ;
- m_peer = peer ;
- m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ;
- m_controlRef = control ;
+ Init();
+ m_peer = peer;
+ m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing();
+ m_controlRef = control;
}
wxMacControl::wxMacControl( wxWindow* peer , WXWidget control )
{
- Init() ;
- m_peer = peer ;
- m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ;
- m_controlRef = (ControlRef) control ;
+ Init();
+ m_peer = peer;
+ m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing();
+ m_controlRef = (ControlRef) control;
}
wxMacControl::~wxMacControl()
void wxMacControl::Init()
{
- m_peer = NULL ;
- m_controlRef = NULL ;
- m_needsFocusRect = false ;
- m_isCompositing = false ;
- m_isRootControl = false ;
+ m_peer = NULL;
+ m_controlRef = NULL;
+ m_needsFocusRect = false;
+ m_isCompositing = false;
+ m_isRootControl = false;
}
void wxMacControl::Dispose()
{
- ::DisposeControl( m_controlRef ) ;
- m_controlRef = NULL ;
+ ::DisposeControl( m_controlRef );
+ m_controlRef = NULL;
}
void wxMacControl::SetReference( SInt32 data )
{
- SetControlReference( m_controlRef , data ) ;
+ SetControlReference( m_controlRef , data );
}
OSStatus wxMacControl::GetData(ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const
{
- return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize ) ;
+ return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize );
}
OSStatus wxMacControl::GetDataSize(ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const
{
- return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize ) ;
+ return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize );
}
OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData)
{
- return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData ) ;
+ return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData );
}
OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions )
HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions );
#else
#pragma unused(inOptions)
- return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) ) ;
+ return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) );
#endif
}
OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions )
{
- wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess ) ;
+ wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess );
- event.SetParameter<HICommand>(kEventParamDirectObject,command) ;
+ event.SetParameter<HICommand>(kEventParamDirectObject,command);
- return SendEvent( event , inOptions ) ;
+ return SendEvent( event , inOptions );
}
OSStatus wxMacControl::SendHICommand( UInt32 commandID , OptionBits inOptions )
{
- HICommand command ;
+ HICommand command;
- memset( &command, 0 , sizeof(command) ) ;
- command.commandID = commandID ;
- return SendHICommand( command , inOptions ) ;
+ memset( &command, 0 , sizeof(command) );
+ command.commandID = commandID;
+ return SendHICommand( command , inOptions );
}
void wxMacControl::Flash( ControlPartCode part , UInt32 ticks )
{
- unsigned long finalTicks ;
+ unsigned long finalTicks;
- HiliteControl( m_controlRef , part ) ;
- Delay( ticks , &finalTicks ) ;
- HiliteControl( m_controlRef , kControlNoPart ) ;
+ HiliteControl( m_controlRef , part );
+ Delay( ticks , &finalTicks );
+ HiliteControl( m_controlRef , kControlNoPart );
}
SInt32 wxMacControl::GetValue() const
{
- return ::GetControl32BitValue( m_controlRef ) ;
+ return ::GetControl32BitValue( m_controlRef );
}
SInt32 wxMacControl::GetMaximum() const
{
- return ::GetControl32BitMaximum( m_controlRef ) ;
+ return ::GetControl32BitMaximum( m_controlRef );
}
SInt32 wxMacControl::GetMinimum() const
{
- return ::GetControl32BitMinimum( m_controlRef ) ;
+ return ::GetControl32BitMinimum( m_controlRef );
}
void wxMacControl::SetValue( SInt32 v )
{
- ::SetControl32BitValue( m_controlRef , v ) ;
+ ::SetControl32BitValue( m_controlRef , v );
}
void wxMacControl::SetMinimum( SInt32 v )
{
- ::SetControl32BitMinimum( m_controlRef , v ) ;
+ ::SetControl32BitMinimum( m_controlRef , v );
}
void wxMacControl::SetMaximum( SInt32 v )
{
- ::SetControl32BitMaximum( m_controlRef , v ) ;
+ ::SetControl32BitMaximum( m_controlRef , v );
}
void wxMacControl::SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum )
{
- ::SetControl32BitMinimum( m_controlRef , minimum ) ;
- ::SetControl32BitMaximum( m_controlRef , maximum ) ;
- ::SetControl32BitValue( m_controlRef , value ) ;
+ ::SetControl32BitMinimum( m_controlRef , minimum );
+ ::SetControl32BitMaximum( m_controlRef , maximum );
+ ::SetControl32BitValue( m_controlRef , value );
}
OSStatus wxMacControl::SetFocus( ControlFocusPart focusPart )
{
- return SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, focusPart ) ;
+ return SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, focusPart );
}
bool wxMacControl::HasFocus() const
{
- ControlRef control ;
- GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
- return control == m_controlRef ;
+ ControlRef control;
+ GetKeyboardFocus( GetUserFocusWindow() , &control );
+ return control == m_controlRef;
}
void wxMacControl::SetNeedsFocusRect( bool needs )
{
- m_needsFocusRect = needs ;
+ m_needsFocusRect = needs;
}
bool wxMacControl::NeedsFocusRect() const
{
- return m_needsFocusRect ;
+ return m_needsFocusRect;
}
void wxMacControl::VisibilityChanged(bool shown)
void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
{
- m_font = font ;
+ m_font = font;
ControlFontStyleRec fontStyle;
if ( font.MacGetThemeFontID() != kThemeCurrentPortFont )
{
switch ( font.MacGetThemeFontID() )
{
case kThemeSmallSystemFont :
- fontStyle.font = kControlFontSmallSystemFont ;
- break ;
+ fontStyle.font = kControlFontSmallSystemFont;
+ break;
case 109 : // mini font
- fontStyle.font = -5 ;
- break ;
+ fontStyle.font = -5;
+ break;
case kThemeSystemFont :
- fontStyle.font = kControlFontBigSystemFont ;
- break ;
+ fontStyle.font = kControlFontBigSystemFont;
+ break;
default :
- fontStyle.font = kControlFontBigSystemFont ;
- break ;
+ fontStyle.font = kControlFontBigSystemFont;
+ break;
}
- fontStyle.flags = kControlUseFontMask ;
+ fontStyle.flags = kControlUseFontMask;
}
else
{
- fontStyle.font = font.MacGetFontNum() ;
- fontStyle.style = font.MacGetFontStyle() ;
- fontStyle.size = font.MacGetFontSize() ;
- fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask ;
+ fontStyle.font = font.MacGetFontNum();
+ fontStyle.style = font.MacGetFontStyle();
+ fontStyle.size = font.MacGetFontSize();
+ fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask;
}
- fontStyle.just = teJustLeft ;
- fontStyle.flags |= kControlUseJustMask ;
+ fontStyle.just = teJustLeft;
+ fontStyle.flags |= kControlUseJustMask;
if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL )
- fontStyle.just = teJustCenter ;
+ fontStyle.just = teJustCenter;
else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT )
- fontStyle.just = teJustRight ;
+ fontStyle.just = teJustRight;
// we only should do this in case of a non-standard color, as otherwise 'disabled' controls
if ( foreground != *wxBLACK )
{
- fontStyle.foreColor = MAC_WXCOLORREF( foreground.GetPixel() ) ;
- fontStyle.flags |= kControlUseForeColorMask ;
+ fontStyle.foreColor = MAC_WXCOLORREF( foreground.GetPixel() );
+ fontStyle.flags |= kControlUseForeColorMask;
}
::SetControlFontStyle( m_controlRef , &fontStyle );
void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
{
- ::SetControl32BitMinimum( m_controlRef , minimum ) ;
- ::SetControl32BitMaximum( m_controlRef , maximum ) ;
+ ::SetControl32BitMinimum( m_controlRef , minimum );
+ ::SetControl32BitMaximum( m_controlRef , maximum );
}
short wxMacControl::HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers )
{
- return HandleControlKey( m_controlRef , keyCode , charCode , modifiers ) ;
+ return HandleControlKey( m_controlRef , keyCode , charCode , modifiers );
}
void wxMacControl::SetActionProc( ControlActionUPP actionProc )
{
- SetControlAction( m_controlRef , actionProc ) ;
+ SetControlAction( m_controlRef , actionProc );
}
void wxMacControl::SetViewSize( SInt32 viewSize )
{
- SetControlViewSize(m_controlRef , viewSize ) ;
+ SetControlViewSize(m_controlRef , viewSize );
}
SInt32 wxMacControl::GetViewSize() const
{
- return GetControlViewSize( m_controlRef ) ;
+ return GetControlViewSize( m_controlRef );
}
bool wxMacControl::IsVisible() const
{
- return IsControlVisible( m_controlRef ) ;
+ return IsControlVisible( m_controlRef );
}
void wxMacControl::SetVisibility( bool visible , bool redraw )
{
- SetControlVisibility( m_controlRef , visible , redraw ) ;
+ SetControlVisibility( m_controlRef , visible , redraw );
}
bool wxMacControl::IsEnabled() const
{
#if TARGET_API_MAC_OSX
- return IsControlEnabled( m_controlRef ) ;
+ return IsControlEnabled( m_controlRef );
#else
- return IsControlActive( m_controlRef ) ;
+ return IsControlActive( m_controlRef );
#endif
}
bool wxMacControl::IsActive() const
{
- return IsControlActive( m_controlRef ) ;
+ return IsControlActive( m_controlRef );
}
void wxMacControl::Enable( bool enable )
{
#if TARGET_API_MAC_OSX
if ( enable )
- EnableControl( m_controlRef ) ;
+ EnableControl( m_controlRef );
else
- DisableControl( m_controlRef ) ;
+ DisableControl( m_controlRef );
#else
if ( enable )
- ActivateControl( m_controlRef ) ;
+ ActivateControl( m_controlRef );
else
- DeactivateControl( m_controlRef ) ;
+ DeactivateControl( m_controlRef );
#endif
}
void wxMacControl::SetDrawingEnabled( bool enable )
{
#if TARGET_API_MAC_OSX
- HIViewSetDrawingEnabled( m_controlRef , enable ) ;
+ HIViewSetDrawingEnabled( m_controlRef , enable );
#endif
}
#if TARGET_API_MAC_OSX
if ( m_isCompositing )
{
- return HIViewGetNeedsDisplay( m_controlRef ) ;
+ return HIViewGetNeedsDisplay( m_controlRef );
}
else
#endif
{
if ( !IsVisible() )
- return false ;
+ return false;
- Rect controlBounds ;
- GetControlBounds( m_controlRef, &controlBounds ) ;
- RgnHandle rgn = NewRgn() ;
- GetWindowRegion ( GetControlOwner( m_controlRef ) , kWindowUpdateRgn , rgn ) ;
- Boolean intersect = RectInRgn ( &controlBounds , rgn ) ;
- DisposeRgn( rgn ) ;
+ Rect controlBounds;
+ GetControlBounds( m_controlRef, &controlBounds );
+ RgnHandle rgn = NewRgn();
+ GetWindowRegion ( GetControlOwner( m_controlRef ) , kWindowUpdateRgn , rgn );
+ Boolean intersect = RectInRgn ( &controlBounds , rgn );
+ DisposeRgn( rgn );
- return intersect ;
+ return intersect;
}
}
#endif
void wxMacControl::SetNeedsDisplay( RgnHandle where )
{
if ( !IsVisible() )
- return ;
+ return;
#if TARGET_API_MAC_OSX
if ( m_isCompositing )
{
- HIViewSetNeedsDisplayInRegion( m_controlRef , where , true ) ;
+ HIViewSetNeedsDisplayInRegion( m_controlRef , where , true );
}
else
#endif
{
- Rect controlBounds ;
- GetControlBounds( m_controlRef, &controlBounds ) ;
- RgnHandle update = NewRgn() ;
- CopyRgn( where , update ) ;
- OffsetRgn( update , controlBounds.left , controlBounds.top ) ;
- InvalWindowRgn( GetControlOwner( m_controlRef) , update ) ;
+ Rect controlBounds;
+ GetControlBounds( m_controlRef, &controlBounds );
+ RgnHandle update = NewRgn();
+ CopyRgn( where , update );
+ OffsetRgn( update , controlBounds.left , controlBounds.top );
+ InvalWindowRgn( GetControlOwner( m_controlRef) , update );
}
}
void wxMacControl::SetNeedsDisplay( Rect* where )
{
if ( !IsVisible() )
- return ;
+ return;
#if TARGET_API_MAC_OSX
if ( m_isCompositing )
{
if ( where != NULL )
{
- RgnHandle update = NewRgn() ;
- RectRgn( update , where ) ;
- HIViewSetNeedsDisplayInRegion( m_controlRef , update , true ) ;
- DisposeRgn( update ) ;
+ RgnHandle update = NewRgn();
+ RectRgn( update , where );
+ HIViewSetNeedsDisplayInRegion( m_controlRef , update , true );
+ DisposeRgn( update );
}
else
- HIViewSetNeedsDisplay( m_controlRef , true ) ;
+ HIViewSetNeedsDisplay( m_controlRef , true );
}
else
#endif
{
- Rect controlBounds ;
+ Rect controlBounds;
- GetControlBounds( m_controlRef, &controlBounds ) ;
+ GetControlBounds( m_controlRef, &controlBounds );
if ( where )
{
- Rect whereLocal = *where ;
- OffsetRect( &whereLocal , controlBounds.left , controlBounds.top ) ;
- SectRect( &controlBounds , &whereLocal, &controlBounds ) ;
+ Rect whereLocal = *where;
+ OffsetRect( &whereLocal , controlBounds.left , controlBounds.top );
+ SectRect( &controlBounds , &whereLocal, &controlBounds );
}
- InvalWindowRect( GetControlOwner( m_controlRef) , &controlBounds ) ;
+ InvalWindowRect( GetControlOwner( m_controlRef) , &controlBounds );
}
}
#if TARGET_API_MAC_OSX
if ( from->m_peer->MacGetTopLevelWindow()->MacUsesCompositing() )
{
- HIPoint hiPoint ;
+ HIPoint hiPoint;
- hiPoint.x = pt->x ;
- hiPoint.y = pt->y ;
- HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef ) ;
- pt->x = (int)hiPoint.x ;
- pt->y = (int)hiPoint.y ;
+ hiPoint.x = pt->x;
+ hiPoint.y = pt->y;
+ HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef );
+ pt->x = (int)hiPoint.x;
+ pt->y = (int)hiPoint.y;
}
else
#endif
{
- Rect fromRect, toRect ;
+ Rect fromRect, toRect;
- GetControlBounds( from->m_controlRef , &fromRect ) ;
- GetControlBounds( to->m_controlRef , &toRect ) ;
+ GetControlBounds( from->m_controlRef , &fromRect );
+ GetControlBounds( to->m_controlRef , &toRect );
if ( from->m_isRootControl )
- fromRect.left = fromRect.top = 0 ;
+ fromRect.left = fromRect.top = 0;
if ( to->m_isRootControl )
- toRect.left = toRect.top = 0 ;
+ toRect.left = toRect.top = 0;
- pt->x = pt->x + fromRect.left - toRect.left ;
- pt->y = pt->y + fromRect.top - toRect.top ;
+ pt->x = pt->x + fromRect.left - toRect.left;
+ pt->y = pt->y + fromRect.top - toRect.top;
}
}
{
//A HIRect is actually a CGRect on OSX - which consists of two structures -
//CGPoint and CGSize, which have two floats each
- HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } } ;
- HIViewSetFrame ( m_controlRef , &hir ) ;
- // eventuall we might have to do a SetVisibility( false , true ) ;
- // before and a SetVisibility( true , true ) ; after
+ HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } };
+ HIViewSetFrame ( m_controlRef , &hir );
+ // eventuall we might have to do a SetVisibility( false , true );
+ // before and a SetVisibility( true , true ); after
}
else
#endif
{
- bool vis = IsVisible() ;
+ bool vis = IsVisible();
if ( vis )
{
- Rect former ;
- GetControlBounds( m_controlRef , &former ) ;
- InvalWindowRect( GetControlOwner( m_controlRef ) , &former ) ;
+ Rect former;
+ GetControlBounds( m_controlRef , &former );
+ InvalWindowRect( GetControlOwner( m_controlRef ) , &former );
}
- Rect controlBounds = *r ;
+ Rect controlBounds = *r;
// since the rect passed in is always (even in non-compositing) relative
// to the (native) parent, we have to adjust to window relative here
- wxMacControl* parent = m_peer->GetParent()->GetPeer() ;
+ wxMacControl* parent = m_peer->GetParent()->GetPeer();
if ( !parent->m_isRootControl )
{
- Rect superRect ;
- GetControlBounds( parent->m_controlRef , &superRect ) ;
- OffsetRect( &controlBounds , superRect.left , superRect.top ) ;
+ Rect superRect;
+ GetControlBounds( parent->m_controlRef , &superRect );
+ OffsetRect( &controlBounds , superRect.left , superRect.top );
}
- SetControlBounds( m_controlRef , &controlBounds ) ;
+ SetControlBounds( m_controlRef , &controlBounds );
if ( vis )
- InvalWindowRect( GetControlOwner( m_controlRef ) , &controlBounds ) ;
+ InvalWindowRect( GetControlOwner( m_controlRef ) , &controlBounds );
}
}
void wxMacControl::GetRect( Rect *r )
{
- GetControlBounds( m_controlRef , r ) ;
+ GetControlBounds( m_controlRef , r );
if ( !m_isCompositing )
{
// correct the case of the root control
if ( m_isRootControl )
{
- WindowRef wr = GetControlOwner( m_controlRef ) ;
- GetWindowBounds( wr , kWindowContentRgn , r ) ;
- r->right -= r->left ;
- r->bottom -= r->top ;
- r->left = 0 ;
- r->top = 0 ;
+ WindowRef wr = GetControlOwner( m_controlRef );
+ GetWindowBounds( wr , kWindowContentRgn , r );
+ r->right -= r->left;
+ r->bottom -= r->top;
+ r->left = 0;
+ r->top = 0;
}
else
{
- wxMacControl* parent = m_peer->GetParent()->GetPeer() ;
+ wxMacControl* parent = m_peer->GetParent()->GetPeer();
if ( !parent->m_isRootControl )
{
- Rect superRect ;
- GetControlBounds( parent->m_controlRef , &superRect ) ;
- OffsetRect( r , -superRect.left , -superRect.top ) ;
+ Rect superRect;
+ GetControlBounds( parent->m_controlRef , &superRect );
+ OffsetRect( r , -superRect.left , -superRect.top );
}
}
}
void wxMacControl::GetRectInWindowCoords( Rect *r )
{
- UMAGetControlBoundsInWindowCoords( m_controlRef , r ) ;
+ UMAGetControlBoundsInWindowCoords( m_controlRef , r );
}
void wxMacControl::GetBestRect( Rect *r )
{
- short baselineoffset ;
+ short baselineoffset;
- GetBestControlRect( m_controlRef , r , &baselineoffset ) ;
+ GetBestControlRect( m_controlRef , r , &baselineoffset );
}
void wxMacControl::SetLabel( const wxString &title )
else
encoding = wxFont::GetDefaultEncoding();
- UMASetControlTitle( m_controlRef , title , encoding ) ;
+ UMASetControlTitle( m_controlRef , title , encoding );
}
void wxMacControl::GetFeatures( UInt32 * features )
{
- GetControlFeatures( m_controlRef , features ) ;
+ GetControlFeatures( m_controlRef , features );
}
OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region )
{
- OSStatus err = GetControlRegion( m_controlRef , partCode , region ) ;
+ OSStatus err = GetControlRegion( m_controlRef , partCode , region );
if ( !m_isCompositing )
{
if ( !m_isRootControl )
{
- Rect r ;
+ Rect r;
- GetControlBounds(m_controlRef, &r ) ;
+ GetControlBounds(m_controlRef, &r );
if ( !EmptyRgn( region ) )
- OffsetRgn( region , -r.left , -r.top ) ;
+ OffsetRgn( region , -r.left , -r.top );
}
}
- return err ;
+ return err;
}
OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other )
{
#if TARGET_API_MAC_OSX
return HIViewSetZOrder( m_controlRef,above ? kHIViewZOrderAbove : kHIViewZOrderBelow,
- (other != NULL) ? other->m_controlRef : NULL) ;
+ (other != NULL) ? other->m_controlRef : NULL);
#else
- return 0 ;
+ return 0;
#endif
}
// SetNeedsDisplay would not invalidate the children
static void InvalidateControlAndChildren( HIViewRef control )
{
- HIViewSetNeedsDisplay( control , true ) ;
- UInt16 childrenCount = 0 ;
- OSStatus err = CountSubControls( control , &childrenCount ) ;
+ HIViewSetNeedsDisplay( control , true );
+ UInt16 childrenCount = 0;
+ OSStatus err = CountSubControls( control , &childrenCount );
if ( err == errControlIsNotEmbedder )
- return ;
+ return;
- wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
+ wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") );
- for ( UInt16 i = childrenCount ; i >=1 ; --i )
+ for ( UInt16 i = childrenCount; i >=1; --i )
{
- HIViewRef child ;
+ HIViewRef child;
- err = GetIndexedSubControl( control , i , & child ) ;
+ err = GetIndexedSubControl( control , i , & child );
if ( err == errControlIsNotEmbedder )
- return ;
+ return;
- InvalidateControlAndChildren( child ) ;
+ InvalidateControlAndChildren( child );
}
}
#endif
void wxMacControl::InvalidateWithChildren()
{
#if TARGET_API_MAC_OSX
- InvalidateControlAndChildren( m_controlRef ) ;
+ InvalidateControlAndChildren( m_controlRef );
#endif
}
void wxMacControl::ScrollRect( wxRect *r , int dx , int dy )
{
- wxASSERT( r != NULL ) ;
+ wxASSERT( r != NULL );
#if TARGET_API_MAC_OSX
if ( m_isCompositing )
{
- HIRect scrollarea = CGRectMake( r->x , r->y , r->width , r->height) ;
- HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy ) ;
+ HIRect scrollarea = CGRectMake( r->x , r->y , r->width , r->height);
+ HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy );
}
else
#endif
{
- Rect bounds ;
-
- GetControlBounds( m_controlRef , &bounds ) ;
- bounds.left += r->x ;
- bounds.top += r->y ;
- bounds.bottom = bounds.top + r->height ;
- bounds.right = bounds.left + r->width ;
- wxMacWindowClipper clip( m_peer ) ;
- RgnHandle updateRgn = NewRgn() ;
- ::ScrollRect( &bounds , dx , dy , updateRgn ) ;
- InvalWindowRgn( GetControlOwner( m_controlRef ) , updateRgn ) ;
+ Rect bounds;
+
+ GetControlBounds( m_controlRef , &bounds );
+ bounds.left += r->x;
+ bounds.top += r->y;
+ bounds.bottom = bounds.top + r->height;
+ bounds.right = bounds.left + r->width;
+ wxMacWindowClipper clip( m_peer );
+ RgnHandle updateRgn = NewRgn();
+ ::ScrollRect( &bounds , dx , dy , updateRgn );
+ InvalWindowRgn( GetControlOwner( m_controlRef ) , updateRgn );
DisposeRgn( updateRgn );
}
}
+OSType wxMacCreator = 'WXMC';
+OSType wxMacControlProperty = 'MCCT';
+
+void wxMacControl::SetReferenceInNativeControl()
+{
+ void * data = this;
+ verify_noerr( SetControlProperty ( m_controlRef ,
+ wxMacCreator,wxMacControlProperty, sizeof(data), &data ) );
+}
+
+wxMacControl* wxMacControl::GetReferenceFromNativeControl(ControlRef control)
+{
+ wxMacControl* ctl = NULL;
+ UInt32 actualSize;
+ if ( GetControlProperty( control ,wxMacCreator,wxMacControlProperty, sizeof(ctl) ,
+ &actualSize , &ctl ) == noErr )
+ {
+ return ctl;
+ }
+ return NULL;
+}
+
+// ============================================================================
+// DataBrowser Wrapper
+// ============================================================================
+//
+// basing on DataBrowserItemIDs
+//
+
+pascal void wxMacDataBrowserControl::DataBrowserItemNotificationProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData )
+{
+ wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
+ if ( ctl != 0 )
+ {
+ ctl->ItemNotification(itemID, message, itemData);
+ }
+}
+
+pascal OSStatus wxMacDataBrowserControl::DataBrowserGetSetItemDataProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue )
+{
+ OSStatus err = errDataBrowserPropertyNotSupported;
+
+ wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
+ if ( ctl != 0 )
+ {
+ err = ctl->GetSetItemData(itemID, property, itemData, changeValue);
+ }
+ return err;
+}
+
+pascal Boolean wxMacDataBrowserControl::DataBrowserCompareProc(
+ ControlRef browser,
+ DataBrowserItemID itemOneID,
+ DataBrowserItemID itemTwoID,
+ DataBrowserPropertyID sortProperty)
+{
+ wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
+ if ( ctl != 0 )
+ {
+ return ctl->CompareItems(itemOneID, itemTwoID, sortProperty);
+ }
+ return false;
+}
+
+DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
+DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
+DataBrowserItemCompareUPP gDataBrowserItemCompareUPP = NULL;
+
+wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style) : wxMacControl( peer )
+{
+ Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
+ OSStatus err = ::CreateDataBrowserControl(
+ MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
+ &bounds, kDataBrowserListView, &m_controlRef );
+ SetReferenceInNativeControl();
+ verify_noerr( err );
+ if ( gDataBrowserItemCompareUPP == NULL )
+ gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc);
+ if ( gDataBrowserItemDataUPP == NULL )
+ gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc);
+ if ( gDataBrowserItemNotificationUPP == NULL )
+ {
+ gDataBrowserItemNotificationUPP =
+#if TARGET_API_MAC_OSX
+ (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc);
+#else
+ NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc);
+#endif
+ }
+
+ DataBrowserCallbacks callbacks;
+ InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks );
+
+ callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
+ callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP;
+ callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
+ SetCallbacks( &callbacks );
+
+}
+
+OSStatus wxMacDataBrowserControl::GetItemCount( DataBrowserItemID container,
+ Boolean recurse,
+ DataBrowserItemState state,
+ UInt32 *numItems) const
+{
+ return GetDataBrowserItemCount( m_controlRef, container, recurse, state, numItems );
+}
+
+OSStatus wxMacDataBrowserControl::GetItems( DataBrowserItemID container,
+ Boolean recurse,
+ DataBrowserItemState state,
+ Handle items) const
+{
+ return GetDataBrowserItems( m_controlRef, container, recurse, state, items );
+}
+
+OSStatus wxMacDataBrowserControl::SetSelectionFlags( DataBrowserSelectionFlags options )
+{
+ return SetDataBrowserSelectionFlags( m_controlRef, options );
+}
+
+OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *columnDesc,
+ DataBrowserTableViewColumnIndex position )
+{
+ return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
+}
+
+OSStatus wxMacDataBrowserControl::AutoSizeColumns()
+{
+ return AutoSizeDataBrowserListViewColumns(m_controlRef);
+}
+
+OSStatus wxMacDataBrowserControl::SetHasScrollBars( bool horiz, bool vert )
+{
+ return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert );
+}
+
+OSStatus wxMacDataBrowserControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
+{
+ return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle );
+}
+
+OSStatus wxMacDataBrowserControl::SetHeaderButtonHeight(UInt16 height)
+{
+ return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
+}
+
+OSStatus wxMacDataBrowserControl::GetHeaderButtonHeight(UInt16 *height)
+{
+ return GetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
+}
+
+OSStatus wxMacDataBrowserControl::SetCallbacks(const DataBrowserCallbacks *callbacks)
+{
+ return SetDataBrowserCallbacks( m_controlRef, callbacks );
+}
+
+OSStatus wxMacDataBrowserControl::UpdateItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty,
+ DataBrowserPropertyID propertyID ) const
+{
+ return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID );
+}
+
+bool wxMacDataBrowserControl::IsItemSelected( DataBrowserItemID item ) const
+{
+ return IsDataBrowserItemSelected( m_controlRef, item );
+}
+
+OSStatus wxMacDataBrowserControl::AddItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty )
+{
+ return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
+}
+
+OSStatus wxMacDataBrowserControl::RemoveItems(
+ DataBrowserItemID container,
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty )
+{
+ return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
+}
+
+OSStatus wxMacDataBrowserControl::RevealItem(
+ DataBrowserItemID item,
+ DataBrowserPropertyID propertyID,
+ DataBrowserRevealOptions options ) const
+{
+ return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
+}
+
+OSStatus wxMacDataBrowserControl::SetSelectedItems(
+ UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserSetOption operation )
+{
+ return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation );
+}
+
+OSStatus wxMacDataBrowserControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const
+{
+ return GetDataBrowserSelectionAnchor( m_controlRef, first, last );
+}
+
+OSStatus wxMacDataBrowserControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
+{
+ return GetDataBrowserTableViewItemID( m_controlRef, row, item );
+}
+
+OSStatus wxMacDataBrowserControl::GetItemRow( DataBrowserItemID item, DataBrowserTableViewRowIndex * row ) const
+{
+ return GetDataBrowserTableViewItemRow( m_controlRef, item, row );
+}
+
+OSStatus wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height )
+{
+ return SetDataBrowserTableViewRowHeight( m_controlRef , height );
+}
+
+OSStatus wxMacDataBrowserControl::GetDefaultRowHeight( UInt16 * height ) const
+{
+ return GetDataBrowserTableViewRowHeight( m_controlRef, height );
+}
+
+OSStatus wxMacDataBrowserControl::SetRowHeight( DataBrowserItemID item , UInt16 height)
+{
+ return SetDataBrowserTableViewItemRowHeight( m_controlRef, item , height );
+}
+
+OSStatus wxMacDataBrowserControl::GetRowHeight( DataBrowserItemID item , UInt16 *height) const
+{
+ return GetDataBrowserTableViewItemRowHeight( m_controlRef, item , height);
+}
+
+OSStatus wxMacDataBrowserControl::GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const
+{
+ return GetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
+}
+
+OSStatus wxMacDataBrowserControl::SetColumnWidth( DataBrowserPropertyID column , UInt16 width )
+{
+ return SetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
+}
+
+OSStatus wxMacDataBrowserControl::GetDefaultColumnWidth( UInt16 *width ) const
+{
+ return GetDataBrowserTableViewColumnWidth( m_controlRef , width );
+}
+
+OSStatus wxMacDataBrowserControl::SetDefaultColumnWidth( UInt16 width )
+{
+ return SetDataBrowserTableViewColumnWidth( m_controlRef , width );
+}
+
+OSStatus wxMacDataBrowserControl::GetColumnCount(UInt32* numColumns) const
+{
+ return GetDataBrowserTableViewColumnCount( m_controlRef, numColumns);
+}
+
+OSStatus wxMacDataBrowserControl::GetColumnPosition( DataBrowserPropertyID column,
+ UInt32 *position) const
+{
+ return GetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
+}
+
+OSStatus wxMacDataBrowserControl::SetColumnPosition( DataBrowserPropertyID column, UInt32 position)
+{
+ return SetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
+}
+
+OSStatus wxMacDataBrowserControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
+{
+ return GetDataBrowserScrollPosition( m_controlRef , top , left );
+}
+
+OSStatus wxMacDataBrowserControl::SetScrollPosition( UInt32 top , UInt32 left )
+{
+ return SetDataBrowserScrollPosition( m_controlRef , top , left );
+}
+
+OSStatus wxMacDataBrowserControl::GetSortProperty( DataBrowserPropertyID *column ) const
+{
+ return GetDataBrowserSortProperty( m_controlRef , column );
+}
+
+OSStatus wxMacDataBrowserControl::SetSortProperty( DataBrowserPropertyID column )
+{
+ return SetDataBrowserSortProperty( m_controlRef , column );
+}
+
+OSStatus wxMacDataBrowserControl::GetSortOrder( DataBrowserSortOrder *order ) const
+{
+ return GetDataBrowserSortOrder( m_controlRef , order );
+}
+
+OSStatus wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order )
+{
+ return SetDataBrowserSortOrder( m_controlRef , order );
+}
+
+OSStatus wxMacDataBrowserControl::GetPropertyFlags( DataBrowserPropertyID property,
+ DataBrowserPropertyFlags *flags ) const
+{
+ return GetDataBrowserPropertyFlags( m_controlRef , property , flags );
+}
+
+OSStatus wxMacDataBrowserControl::SetPropertyFlags( DataBrowserPropertyID property,
+ DataBrowserPropertyFlags flags )
+{
+ return SetDataBrowserPropertyFlags( m_controlRef , property , flags );
+}
+
+OSStatus wxMacDataBrowserControl::GetHeaderDesc( DataBrowserPropertyID property,
+ DataBrowserListViewHeaderDesc *desc ) const
+{
+ return GetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
+}
+
+OSStatus wxMacDataBrowserControl::SetHeaderDesc( DataBrowserPropertyID property,
+ DataBrowserListViewHeaderDesc *desc )
+{
+ return SetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
+}
+
+OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID property ,
+ Boolean expandableRows )
+{
+ return SetDataBrowserListViewDisclosureColumn( m_controlRef, property, expandableRows);
+}
+
+// ============================================================================
+// Higher-level Databrowser
+// ============================================================================
+//
+// basing on data item objects
+//
+
+wxMacDataItem::wxMacDataItem()
+{
+}
+
+wxMacDataItem::~wxMacDataItem()
+{
+}
+
+bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
+ const wxMacDataItem*,
+ DataBrowserPropertyID property) const
+{
+ return false;
+}
+
+OSStatus wxMacDataItem::GetSetData(wxMacDataItemBrowserControl *owner ,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ bool changeValue )
+{
+ return errDataBrowserPropertyNotSupported;
+}
+
+void wxMacDataItem::Notification(wxMacDataItemBrowserControl *owner ,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData ) const
+{
+}
+
+
+wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style) :
+ wxMacDataBrowserControl( peer, pos, size, style )
+{
+ m_suppressSelection = false;
+}
+
+wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser)
+{
+ m_former = browser->SuppressSelection(true);
+ m_browser = browser;
+}
+
+wxMacDataItemBrowserSelectionSuppressor::~wxMacDataItemBrowserSelectionSuppressor()
+{
+ m_browser->SuppressSelection(m_former);
+}
+
+bool wxMacDataItemBrowserControl::SuppressSelection( bool suppress )
+{
+ bool former = m_suppressSelection;
+ m_suppressSelection = suppress;
+
+ return former;
+}
+
+Boolean wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID,
+ DataBrowserItemID itemTwoID,
+ DataBrowserPropertyID sortProperty)
+{
+ wxMacDataItem* itemOne = (wxMacDataItem*) itemOneID;
+ wxMacDataItem* itemTwo = (wxMacDataItem*) itemTwoID;
+ return CompareItems( itemOne , itemTwo , sortProperty );
+}
+
+Boolean wxMacDataItemBrowserControl::CompareItems(const wxMacDataItem* itemOne,
+ const wxMacDataItem* itemTwo,
+ DataBrowserPropertyID sortProperty)
+{
+ Boolean retval = false;
+ if ( itemOne != NULL )
+ retval = itemOne->IsLessThan( this , itemTwo , sortProperty);
+ return retval;
+}
+
+OSStatus wxMacDataItemBrowserControl::GetSetItemData(
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue )
+{
+ wxMacDataItem* item = (wxMacDataItem*) itemID;
+ return GetSetItemData(item, property, itemData , changeValue );
+}
+
+OSStatus wxMacDataItemBrowserControl::GetSetItemData(
+ wxMacDataItem* item,
+ DataBrowserPropertyID property,
+ DataBrowserItemDataRef itemData,
+ Boolean changeValue )
+{
+ OSStatus err = errDataBrowserPropertyNotSupported;
+ switch( property )
+ {
+ case kDataBrowserContainerIsClosableProperty :
+ case kDataBrowserContainerIsSortableProperty :
+ case kDataBrowserContainerIsOpenableProperty :
+ // right now default behaviour on these
+ break;
+ default :
+ if ( item != NULL )
+ err = item->GetSetData( this, property , itemData , changeValue );
+ break;
+
+ }
+ return err;
+}
+
+void wxMacDataItemBrowserControl::ItemNotification(
+ DataBrowserItemID itemID,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData)
+{
+ wxMacDataItem* item = (wxMacDataItem*) itemID;
+ ItemNotification( item , message, itemData);
+}
+
+void wxMacDataItemBrowserControl::ItemNotification(
+ const wxMacDataItem* item,
+ DataBrowserItemNotification message,
+ DataBrowserItemDataRef itemData)
+{
+ if (item != NULL)
+ item->Notification( this, message, itemData);
+}
+
+unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem* container,
+ bool recurse , DataBrowserItemState state) const
+{
+ UInt32 numItems = 0;
+ verify_noerr( wxMacDataBrowserControl::GetItemCount( (DataBrowserItemID)container,
+ recurse, state, &numItems ) );
+ return numItems;
+}
+
+void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container,
+ bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const
+{
+ Handle handle = NewHandle(0);
+ verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID)container ,
+ recurse , state, handle) );
+
+ int itemCount = GetHandleSize(handle)/sizeof(DataBrowserItemID);
+ HLock( handle );
+ wxMacDataItemPtr* itemsArray = (wxMacDataItemPtr*) *handle;
+ for ( int i = 0; i < itemCount; ++i)
+ {
+ items.Add(itemsArray[i]);
+ }
+ HUnlock( handle );
+ DisposeHandle( handle );
+}
+
+unsigned int wxMacDataItemBrowserControl::GetLineFromItem(const wxMacDataItem* item) const
+{
+ DataBrowserTableViewRowIndex row;
+ OSStatus err = GetItemRow( (DataBrowserItemID) item , &row);
+ wxASSERT( err == noErr);
+ return row;
+}
+
+wxMacDataItem* wxMacDataItemBrowserControl::GetItemFromLine(unsigned int n) const
+{
+ DataBrowserItemID id;
+ OSStatus err = GetItemID( (DataBrowserTableViewRowIndex) n , &id);
+ wxASSERT( err == noErr);
+ return (wxMacDataItem*) id;
+}
+
+void wxMacDataItemBrowserControl::UpdateItem(const wxMacDataItem *container,
+ const wxMacDataItem *item , DataBrowserPropertyID property) const
+{
+ verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, 1,
+ (DataBrowserItemID*) &item, kDataBrowserItemNoProperty /* notSorted */, property ) );
+}
+
+void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container,
+ wxArrayMacDataItemPtr &itemArray , DataBrowserPropertyID property) const
+{
+ unsigned int noItems = itemArray.GetCount();
+ DataBrowserItemID *items = new DataBrowserItemID[noItems];
+ for ( unsigned int i = 0; i < noItems; ++i )
+ items[i] = (DataBrowserItemID) itemArray[i];
+
+ verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, noItems,
+ items, kDataBrowserItemNoProperty /* notSorted */, property ) );
+ delete [] items;
+}
+
+void wxMacDataItemBrowserControl::AddItem(wxMacDataItem *container, wxMacDataItem *item)
+{
+ verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, 1,
+ (DataBrowserItemID*) &item, kDataBrowserItemNoProperty ) );
+}
+
+void wxMacDataItemBrowserControl::AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray )
+{
+ unsigned int noItems = itemArray.GetCount();
+ DataBrowserItemID *items = new DataBrowserItemID[noItems];
+ for ( unsigned int i = 0; i < noItems; ++i )
+ items[i] = (DataBrowserItemID) itemArray[i];
+
+ verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, noItems,
+ (DataBrowserItemID*) items, kDataBrowserItemNoProperty ) );
+ delete [] items;
+}
+
+void wxMacDataItemBrowserControl::RemoveItem(wxMacDataItem *container, wxMacDataItem* item)
+{
+ OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 1,
+ (UInt32*) &item, kDataBrowserItemNoProperty );
+ verify_noerr( err );
+}
+
+void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray)
+{
+ unsigned int noItems = itemArray.GetCount();
+ DataBrowserItemID *items = new DataBrowserItemID[noItems];
+ for ( unsigned int i = 0; i < noItems; ++i )
+ items[i] = (DataBrowserItemID) itemArray[i];
+
+ OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, noItems,
+ (UInt32*) items, kDataBrowserItemNoProperty );
+ verify_noerr( err );
+ delete [] items;
+}
+
+void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container)
+{
+ OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty );
+ verify_noerr( err );
+}
+
+void wxMacDataItemBrowserControl::SetSelectedItem(wxMacDataItem* item , DataBrowserSetOption option)
+{
+ verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 1, (DataBrowserItemID*) &item, option ));
+}
+
+void wxMacDataItemBrowserControl::SetSelectedAllItems(DataBrowserSetOption option)
+{
+ verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 0 , NULL , option ));
+}
+
+void wxMacDataItemBrowserControl::SetSelectedItems(wxArrayMacDataItemPtr &itemArray , DataBrowserSetOption option)
+{
+ unsigned int noItems = itemArray.GetCount();
+ DataBrowserItemID *items = new DataBrowserItemID[noItems];
+ for ( unsigned int i = 0; i < noItems; ++i )
+ items[i] = (DataBrowserItemID) itemArray[i];
+
+ verify_noerr(wxMacDataBrowserControl::SetSelectedItems( noItems, (DataBrowserItemID*) items, option ));
+ delete [] items;
+}
+
+Boolean wxMacDataItemBrowserControl::IsItemSelected( const wxMacDataItem* item) const
+{
+ return wxMacDataBrowserControl::IsItemSelected( (DataBrowserItemID) item);
+}
+
+void wxMacDataItemBrowserControl::RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options)
+{
+ verify_noerr(wxMacDataBrowserControl::RevealItem( (DataBrowserItemID) item, kDataBrowserNoItem , options ) );
+}
+
+void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const
+{
+ verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID*) first, (DataBrowserItemID*) last) );
+}
+
+
+
//
// Tab Control
//
OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
{
- return ::SetTabEnabled( m_controlRef , tabNo , enable ) ;
+ return ::SetTabEnabled( m_controlRef , tabNo , enable );
}
//
CGColorSpaceRef wxMacGetGenericRGBColorSpace()
{
- static wxMacCFRefHolder<CGColorSpaceRef> genericRGBColorSpace ;
+ static wxMacCFRefHolder<CGColorSpaceRef> genericRGBColorSpace;
if (genericRGBColorSpace == NULL)
{
if ( UMAGetSystemVersion() >= 0x1040 )
{
- genericRGBColorSpace.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) ) ;
+ genericRGBColorSpace.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) );
}
else
{
if (genericRGBProfile)
{
- genericRGBColorSpace.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile) ) ;
+ genericRGBColorSpace.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile) );
- wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") ) ;
+ wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") );
// we opened the profile so it is up to us to close it
CMCloseProfile(genericRGBProfile);
wxMacPortSaver::wxMacPortSaver( GrafPtr port )
{
- ::GetPort( &m_port ) ;
- ::SetPort( port ) ;
+ ::GetPort( &m_port );
+ ::SetPort( port );
}
wxMacPortSaver::~wxMacPortSaver()
{
- ::SetPort( m_port ) ;
+ ::SetPort( m_port );
}
#endif // wxUSE_GUI