listbox rewrite, cleanup
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -427,6 +427,9 @@ private :
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
|
||||||
|
#include "wx/listbox.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
|
GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
|
||||||
void wxMacDestroyGWorld( GWorldPtr gw );
|
void wxMacDestroyGWorld( GWorldPtr gw );
|
||||||
@@ -490,6 +493,9 @@ public :
|
|||||||
|
|
||||||
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 * GetControlRefAddr() { return &m_controlRef; }
|
||||||
virtual ControlRef GetControlRef() const { return m_controlRef; }
|
virtual ControlRef GetControlRef() const { return m_controlRef; }
|
||||||
|
|
||||||
@@ -557,7 +563,10 @@ public :
|
|||||||
template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
|
template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
|
||||||
{
|
{
|
||||||
T value;
|
T value;
|
||||||
verify_noerr( GetData<T>( inPartCode , inTag , &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;
|
return value;
|
||||||
}
|
}
|
||||||
template <typename T> OSStatus GetData( ResType inTag , T *data ) const
|
template <typename T> OSStatus GetData( ResType inTag , T *data ) const
|
||||||
@@ -567,9 +576,7 @@ public :
|
|||||||
}
|
}
|
||||||
template <typename T> T GetData( ResType inTag ) const
|
template <typename T> T GetData( ResType inTag ) const
|
||||||
{
|
{
|
||||||
T value ;
|
return GetData<T>( kControlEntireControl , inTag );
|
||||||
verify_noerr( GetData<T>( kControlEntireControl , inTag , &value ) ) ;
|
|
||||||
return value ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flash the control for the specified amount of time
|
// Flash the control for the specified amount of time
|
||||||
@@ -625,6 +632,11 @@ public :
|
|||||||
bool IsCompositing() { return m_isCompositing; }
|
bool IsCompositing() { return m_isCompositing; }
|
||||||
bool IsRootControl() { return m_isRootControl; }
|
bool IsRootControl() { return m_isRootControl; }
|
||||||
|
|
||||||
|
wxWindow* GetPeer() const
|
||||||
|
{
|
||||||
|
return m_peer;
|
||||||
|
}
|
||||||
|
|
||||||
// to be moved into a tab control class
|
// to be moved into a tab control class
|
||||||
|
|
||||||
virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
|
virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
|
||||||
@@ -638,6 +650,363 @@ protected :
|
|||||||
bool m_isRootControl;
|
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 :
|
||||||
|
|
||||||
|
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
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
|
||||||
class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
|
class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
|
||||||
|
@@ -30,6 +30,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
|||||||
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
|
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
|
||||||
END_EVENT_TABLE()
|
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()
|
void wxCheckListBox::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -69,9 +81,9 @@ bool wxCheckListBox::Create(
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// this will be increased by our Append command
|
// this will be increased by our Append command
|
||||||
m_noItems = 0;
|
wxMacDataBrowserCheckListControl* control = new wxMacDataBrowserCheckListControl( this, pos, size, style );
|
||||||
|
control->SetClientDataType( m_clientDataItemsType );
|
||||||
m_peer = (wxMacControl*) CreateMacListControl(pos , size , style );
|
m_peer = control;
|
||||||
|
|
||||||
MacPostControlCreate(pos,size);
|
MacPostControlCreate(pos,size);
|
||||||
|
|
||||||
@@ -92,7 +104,7 @@ bool wxCheckListBox::IsChecked(unsigned int item) const
|
|||||||
wxCHECK_MSG( IsValid(item), false,
|
wxCHECK_MSG( IsValid(item), false,
|
||||||
wxT("invalid index in wxCheckListBox::IsChecked") );
|
wxT("invalid index in wxCheckListBox::IsChecked") );
|
||||||
|
|
||||||
return m_checks[item] != 0;
|
return GetPeer()->MacIsChecked( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCheckListBox::Check(unsigned int item, bool check)
|
void wxCheckListBox::Check(unsigned int item, bool check)
|
||||||
@@ -100,62 +112,158 @@ void wxCheckListBox::Check(unsigned int item, bool check)
|
|||||||
wxCHECK_RET( IsValid(item),
|
wxCHECK_RET( IsValid(item),
|
||||||
wxT("invalid index in wxCheckListBox::Check") );
|
wxT("invalid index in wxCheckListBox::Check") );
|
||||||
|
|
||||||
bool isChecked = m_checks[item] != 0;
|
bool isChecked = GetPeer()->MacIsChecked( item );
|
||||||
if ( check != isChecked )
|
if ( check != isChecked )
|
||||||
{
|
{
|
||||||
m_checks[item] = check;
|
GetPeer()->MacCheck( item , check );
|
||||||
MacUpdateLine( item );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
wxMacCheckListControl* wxCheckListBox::GetPeer() const
|
||||||
// methods forwarded to wxCheckListBox
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxCheckListBox::Delete(unsigned int n)
|
|
||||||
{
|
{
|
||||||
wxCHECK_RET( IsValid(n), wxT("invalid index in wxCheckListBox::Delete") );
|
return dynamic_cast<wxMacCheckListControl*>(m_peer);
|
||||||
|
|
||||||
wxListBox::Delete( n );
|
|
||||||
m_checks.RemoveAt( n );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxCheckListBox::DoAppend(const wxString& item)
|
const short kCheckboxColumnId = 1026;
|
||||||
|
|
||||||
|
wxMacDataBrowserCheckListControl::wxMacDataBrowserCheckListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
|
||||||
|
: wxMacDataBrowserListControl( peer, pos, size, style )
|
||||||
{
|
{
|
||||||
int pos = wxListBox::DoAppend( item );
|
OSStatus err = noErr;
|
||||||
|
|
||||||
// the item is initially unchecked
|
DataBrowserListViewColumnDesc columnDesc;
|
||||||
m_checks.Insert( false, pos );
|
columnDesc.headerBtnDesc.titleOffset = 0;
|
||||||
|
columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
|
||||||
|
|
||||||
return pos;
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
wxMacDataBrowserCheckListControl::~wxMacDataBrowserCheckListControl()
|
||||||
{
|
{
|
||||||
wxListBox::DoInsertItems( items, pos );
|
|
||||||
|
|
||||||
unsigned int count = items.GetCount();
|
}
|
||||||
for ( unsigned int n = 0; n < count; n++ )
|
|
||||||
|
class wxMacCheckListBoxItem : public wxMacListBoxItem
|
||||||
{
|
{
|
||||||
m_checks.Insert( false, pos + n );
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
|
if ( err == errDataBrowserPropertyNotSupported )
|
||||||
{
|
err = wxMacListBoxItem::GetSetData( owner , property, itemData , changeValue);
|
||||||
// call it first as it does DoClear()
|
|
||||||
wxListBox::DoSetItems( items, clientData );
|
|
||||||
|
|
||||||
unsigned int count = items.GetCount();
|
return err;
|
||||||
for ( unsigned int n = 0; n < count; n++ )
|
|
||||||
{
|
|
||||||
m_checks.Add( false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCheckListBox::DoClear()
|
void Check( bool check )
|
||||||
{
|
{
|
||||||
m_checks.Empty();
|
m_isChecked = check;
|
||||||
}
|
}
|
||||||
|
bool IsChecked() const
|
||||||
|
{
|
||||||
|
return m_isChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected :
|
||||||
|
bool m_isChecked;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxMacListBoxItem* wxMacDataBrowserCheckListControl::CreateItem()
|
||||||
|
{
|
||||||
|
return new wxMacCheckListBoxItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMacDataBrowserCheckListControl::MacCheck( unsigned int n, bool bCheck)
|
||||||
|
{
|
||||||
|
wxMacCheckListBoxItem* item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n) );
|
||||||
|
item->Check( bCheck);
|
||||||
|
UpdateItem(wxMacDataBrowserRootContainer, item , kCheckboxColumnId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxMacDataBrowserCheckListControl::MacIsChecked( unsigned int n) const
|
||||||
|
{
|
||||||
|
wxMacCheckListBoxItem * item = dynamic_cast<wxMacCheckListBoxItem*>( GetItemFromLine( n ) );
|
||||||
|
return item->IsChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_CHECKLISTBOX
|
#endif // wxUSE_CHECKLISTBOX
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -57,8 +57,10 @@
|
|||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#if defined(__MWERKS__) && wxUSE_UNICODE
|
#if defined(__MWERKS__) && wxUSE_UNICODE
|
||||||
|
#if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
|
||||||
#include <wtime.h>
|
#include <wtime.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// code used in both base and GUI compilation
|
// code used in both base and GUI compilation
|
||||||
@@ -1420,6 +1422,629 @@ void wxMacControl::ScrollRect( wxRect *r , int dx , int dy )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// Tab Control
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user