cleanup - reformatting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38647 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,9 +39,9 @@ public :
|
|||||||
wxMacControl( peer )
|
wxMacControl( peer )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxMacListControl()
|
~wxMacListControl()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UpdateLine( int n ) = 0;
|
virtual void UpdateLine( int n ) = 0;
|
||||||
@@ -67,7 +67,7 @@ public :
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// In case we have to replace data browser ...
|
// In case we have to replace data browser ...
|
||||||
// custom HIView based implementation
|
// custom HIView-based implementation
|
||||||
|
|
||||||
class wxMacCustomHIViewListControl : public wxMacListControl
|
class wxMacCustomHIViewListControl : public wxMacListControl
|
||||||
{
|
{
|
||||||
@@ -90,7 +90,7 @@ public :
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// data browser based implementation
|
// DataBrowser-based implementation
|
||||||
|
|
||||||
class wxMacDataBrowserListControl : public wxMacListControl
|
class wxMacDataBrowserListControl : public wxMacListControl
|
||||||
{
|
{
|
||||||
@@ -145,13 +145,19 @@ private :
|
|||||||
// events in the latter case
|
// events in the latter case
|
||||||
bool MacSuppressSelection( bool suppress );
|
bool MacSuppressSelection( bool suppress );
|
||||||
bool MacIsSelectionSuppressed() const { return m_suppressSelection; }
|
bool MacIsSelectionSuppressed() const { return m_suppressSelection; }
|
||||||
|
|
||||||
bool m_suppressSelection;
|
bool m_suppressSelection;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
static pascal void DataBrowserItemNotificationProc(
|
||||||
DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
|
ControlRef browser,
|
||||||
|
DataBrowserItemID itemID,
|
||||||
|
DataBrowserItemNotification message,
|
||||||
|
DataBrowserItemDataRef itemData );
|
||||||
#else
|
#else
|
||||||
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
static pascal void DataBrowserItemNotificationProc(
|
||||||
|
ControlRef browser,
|
||||||
|
DataBrowserItemID itemID,
|
||||||
DataBrowserItemNotification message );
|
DataBrowserItemNotification message );
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -173,15 +179,20 @@ DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
|
|||||||
DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
|
DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
|
||||||
DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
|
ControlRef browser,
|
||||||
|
DataBrowserItemID itemID,
|
||||||
|
DataBrowserItemNotification message,
|
||||||
|
DataBrowserItemDataRef itemData)
|
||||||
#else
|
#else
|
||||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
|
||||||
|
ControlRef browser,
|
||||||
|
DataBrowserItemID itemID,
|
||||||
DataBrowserItemNotification message)
|
DataBrowserItemNotification message)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
long ref = GetControlReference( browser );
|
long ref = GetControlReference( browser );
|
||||||
if ( ref )
|
if ( ref != 0 )
|
||||||
{
|
{
|
||||||
wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
|
wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
|
||||||
wxMacDataBrowserListControl* peer = (wxMacDataBrowserListControl*) list->GetPeer();
|
wxMacDataBrowserListControl* peer = (wxMacDataBrowserListControl*) list->GetPeer();
|
||||||
@@ -247,7 +258,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
switch (property)
|
switch (property)
|
||||||
{
|
{
|
||||||
case kTextColumnId:
|
case kTextColumnId:
|
||||||
{
|
|
||||||
if ( ref )
|
if ( ref )
|
||||||
{
|
{
|
||||||
int i = itemID - 1;
|
int i = itemID - 1;
|
||||||
@@ -258,11 +268,9 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
err = noErr;
|
err = noErr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCheckboxColumnId:
|
case kCheckboxColumnId:
|
||||||
{
|
|
||||||
if ( ref )
|
if ( ref )
|
||||||
{
|
{
|
||||||
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
||||||
@@ -273,13 +281,11 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
err = noErr;
|
err = noErr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kDataBrowserItemIsEditableProperty:
|
case kDataBrowserItemIsEditableProperty:
|
||||||
{
|
|
||||||
if ( isCheckList )
|
if ( isCheckList )
|
||||||
err = ::SetDataBrowserItemDataBooleanValue(itemData, true);
|
err = ::SetDataBrowserItemDataBooleanValue(itemData, true);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -291,7 +297,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
switch (property)
|
switch (property)
|
||||||
{
|
{
|
||||||
case kCheckboxColumnId:
|
case kCheckboxColumnId:
|
||||||
{
|
|
||||||
if ( ref )
|
if ( ref )
|
||||||
{
|
{
|
||||||
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
||||||
@@ -310,8 +315,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
list->GetEventHandler()->ProcessEvent(event);
|
list->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -322,19 +325,22 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , const wxPoint& pos, const wxSize& size, long style) :
|
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
|
||||||
wxMacListControl( peer )
|
: wxMacListControl( peer )
|
||||||
{
|
{
|
||||||
bool isCheckList = peer->IsKindOf( CLASSINFO(wxCheckListBox));
|
bool isCheckList = peer->IsKindOf( CLASSINFO(wxCheckListBox));
|
||||||
|
|
||||||
m_suppressSelection = false;
|
m_suppressSelection = false;
|
||||||
Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
|
Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
|
||||||
verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(peer->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , &m_controlRef ) );
|
OSStatus err = ::CreateDataBrowserControl(
|
||||||
|
MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
|
||||||
|
&bounds, kDataBrowserListView, &m_controlRef );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
DataBrowserSelectionFlags options = kDataBrowserDragSelect;
|
DataBrowserSelectionFlags options = kDataBrowserDragSelect;
|
||||||
if ( style & wxLB_MULTIPLE )
|
if ( style & wxLB_MULTIPLE )
|
||||||
{
|
{
|
||||||
options += kDataBrowserAlwaysExtendSelection + kDataBrowserCmdTogglesSelection ;
|
options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
|
||||||
}
|
}
|
||||||
else if ( style & wxLB_EXTENDED )
|
else if ( style & wxLB_EXTENDED )
|
||||||
{
|
{
|
||||||
@@ -342,11 +348,13 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options += kDataBrowserSelectOnlyOne;
|
options |= kDataBrowserSelectOnlyOne;
|
||||||
}
|
}
|
||||||
verify_noerr(SetSelectionFlags( options ) );
|
err = SetSelectionFlags( options );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
if ( gDataBrowserItemDataUPP == NULL ) gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(ListBoxGetSetItemData);
|
if ( gDataBrowserItemDataUPP == NULL )
|
||||||
|
gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(ListBoxGetSetItemData);
|
||||||
if ( gDataBrowserItemNotificationUPP == NULL )
|
if ( gDataBrowserItemNotificationUPP == NULL )
|
||||||
{
|
{
|
||||||
gDataBrowserItemNotificationUPP =
|
gDataBrowserItemNotificationUPP =
|
||||||
@@ -384,9 +392,12 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
|||||||
|
|
||||||
columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
|
columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
|
||||||
columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
|
columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
|
||||||
columnDesc.propertyDesc.propertyFlags = kDataBrowserPropertyIsMutable | kDataBrowserTableViewSelectionColumn |
|
columnDesc.propertyDesc.propertyFlags =
|
||||||
kDataBrowserDefaultPropertyFlags;
|
kDataBrowserPropertyIsMutable
|
||||||
verify_noerr(AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn) );
|
| kDataBrowserTableViewSelectionColumn
|
||||||
|
| kDataBrowserDefaultPropertyFlags;
|
||||||
|
err = AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn );
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
columnDesc.headerBtnDesc.minimumWidth = 0;
|
columnDesc.headerBtnDesc.minimumWidth = 0;
|
||||||
@@ -395,11 +406,10 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
|||||||
|
|
||||||
columnDesc.propertyDesc.propertyID = kTextColumnId;
|
columnDesc.propertyDesc.propertyID = kTextColumnId;
|
||||||
columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
|
columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
|
||||||
columnDesc.propertyDesc.propertyFlags =
|
columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
||||||
kDataBrowserListViewTypeSelectColumn |
|
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
|
||||||
#endif
|
#endif
|
||||||
kDataBrowserTableViewSelectionColumn;
|
|
||||||
|
|
||||||
verify_noerr( AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
verify_noerr( AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
||||||
verify_noerr( AutoSizeListViewColumns() );
|
verify_noerr( AutoSizeListViewColumns() );
|
||||||
@@ -413,9 +423,9 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
|||||||
m_peer->SetNeedsFocusRect( true );
|
m_peer->SetNeedsFocusRect( true );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
|
wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDataBrowserListControl::MacDelete( int n )
|
void wxMacDataBrowserListControl::MacDelete( int n )
|
||||||
@@ -424,7 +434,10 @@ void wxMacDataBrowserListControl::MacDelete( int n )
|
|||||||
MacGetSelections( selectionBefore );
|
MacGetSelections( selectionBefore );
|
||||||
|
|
||||||
UInt32 id = GetPeer()->GetCount() + 1;
|
UInt32 id = GetPeer()->GetCount() + 1;
|
||||||
verify_noerr( RemoveItems( kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) );
|
|
||||||
|
OSStatus err = RemoveItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
for ( size_t i = 0; i < selectionBefore.GetCount(); ++i )
|
for ( size_t i = 0; i < selectionBefore.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
int current = selectionBefore[i];
|
int current = selectionBefore[i];
|
||||||
@@ -440,8 +453,12 @@ void wxMacDataBrowserListControl::MacDelete( int n )
|
|||||||
MacSetSelection( current, false );
|
MacSetSelection( current, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
verify_noerr( UpdateItems( kDataBrowserNoItem , 1 , (UInt32*) kDataBrowserNoItem , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) );
|
err = UpdateItems(
|
||||||
|
kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
|
||||||
|
kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDataBrowserListControl::MacInsert( int n, const wxString& text)
|
void wxMacDataBrowserListControl::MacInsert( int n, const wxString& text)
|
||||||
@@ -450,7 +467,8 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxString& text)
|
|||||||
MacGetSelections( selectionBefore );
|
MacGetSelections( selectionBefore );
|
||||||
|
|
||||||
UInt32 id = GetPeer()->GetCount(); // this has already been increased
|
UInt32 id = GetPeer()->GetCount(); // this has already been increased
|
||||||
verify_noerr( AddItems( kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) );
|
OSStatus err = AddItems( kDataBrowserNoItem, 1, (UInt32*) &id, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
|
for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
|
||||||
{
|
{
|
||||||
@@ -463,7 +481,10 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxString& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
verify_noerr( UpdateItems( kDataBrowserNoItem , 1 , (UInt32*) kDataBrowserNoItem , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) );
|
err = UpdateItems(
|
||||||
|
kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
|
||||||
|
kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDataBrowserListControl::MacInsert( int n, const wxArrayString& items)
|
void wxMacDataBrowserListControl::MacInsert( int n, const wxArrayString& items)
|
||||||
@@ -476,7 +497,8 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxArrayString& items)
|
|||||||
for ( unsigned int i = 0; i < itemsCount; ++i )
|
for ( unsigned int i = 0; i < itemsCount; ++i )
|
||||||
ids[i] = GetPeer()->GetCount() - itemsCount + i + 1;
|
ids[i] = GetPeer()->GetCount() - itemsCount + i + 1;
|
||||||
|
|
||||||
verify_noerr( AddItems( kDataBrowserNoItem , itemsCount , ids , kDataBrowserItemNoProperty ) );
|
OSStatus err = AddItems( kDataBrowserNoItem, itemsCount, ids, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
delete [] ids;
|
delete [] ids;
|
||||||
|
|
||||||
for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
|
for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
|
||||||
@@ -490,7 +512,10 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxArrayString& items)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
verify_noerr( UpdateItems( kDataBrowserNoItem , 1 , (UInt32*) kDataBrowserNoItem , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) );
|
err = UpdateItems(
|
||||||
|
kDataBrowserNoItem, 1, (UInt32*)kDataBrowserNoItem,
|
||||||
|
kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDataBrowserListControl::MacAppend( const wxString& text)
|
void wxMacDataBrowserListControl::MacAppend( const wxString& text)
|
||||||
@@ -514,16 +539,21 @@ void wxMacDataBrowserListControl::MacDeselectAll()
|
|||||||
|
|
||||||
void wxMacDataBrowserListControl::MacSetSelection( int n, bool select )
|
void wxMacDataBrowserListControl::MacSetSelection( int n, bool select )
|
||||||
{
|
{
|
||||||
bool former = MacSuppressSelection( true );
|
|
||||||
UInt32 id = n + 1;
|
UInt32 id = n + 1;
|
||||||
|
bool former = MacSuppressSelection( true );
|
||||||
|
|
||||||
if ( IsItemSelected( id ) != select )
|
if ( IsItemSelected( id ) != select )
|
||||||
{
|
{
|
||||||
|
OSStatus err;
|
||||||
|
|
||||||
if ( select )
|
if ( select )
|
||||||
verify_noerr(SetSelectedItems( 1 , & id , GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign ) );
|
err = SetSelectedItems( 1, &id, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
|
||||||
else
|
else
|
||||||
verify_noerr(SetSelectedItems( 1 , & id , kDataBrowserItemsRemove ) );
|
err = SetSelectedItems( 1, &id, kDataBrowserItemsRemove );
|
||||||
|
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
MacScrollTo( n );
|
MacScrollTo( n );
|
||||||
MacSuppressSelection( former );
|
MacSuppressSelection( former );
|
||||||
}
|
}
|
||||||
@@ -532,6 +562,7 @@ bool wxMacDataBrowserListControl::MacSuppressSelection( bool suppress )
|
|||||||
{
|
{
|
||||||
bool former = m_suppressSelection;
|
bool former = m_suppressSelection;
|
||||||
m_suppressSelection = suppress;
|
m_suppressSelection = suppress;
|
||||||
|
|
||||||
return former;
|
return former;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,6 +580,7 @@ int wxMacDataBrowserListControl::MacGetSelection() const
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,6 +603,7 @@ int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return no_sel;
|
return no_sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,7 +666,9 @@ OSStatus wxMacDataBrowserListControl::SetCallbacks(const DataBrowserCallbacks *
|
|||||||
return SetDataBrowserCallbacks( m_controlRef, callbacks );
|
return SetDataBrowserCallbacks( m_controlRef, callbacks );
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus wxMacDataBrowserListControl::UpdateItems( DataBrowserItemID container, UInt32 numItems,
|
OSStatus wxMacDataBrowserListControl::UpdateItems(
|
||||||
|
DataBrowserItemID container,
|
||||||
|
UInt32 numItems,
|
||||||
const DataBrowserItemID *items,
|
const DataBrowserItemID *items,
|
||||||
DataBrowserPropertyID preSortProperty,
|
DataBrowserPropertyID preSortProperty,
|
||||||
DataBrowserPropertyID propertyID )
|
DataBrowserPropertyID propertyID )
|
||||||
@@ -646,28 +681,34 @@ bool wxMacDataBrowserListControl::IsItemSelected( DataBrowserItemID item ) const
|
|||||||
return IsDataBrowserItemSelected( m_controlRef, item );
|
return IsDataBrowserItemSelected( m_controlRef, item );
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus wxMacDataBrowserListControl::AddItems( DataBrowserItemID container, UInt32 numItems,
|
OSStatus wxMacDataBrowserListControl::AddItems(
|
||||||
|
DataBrowserItemID container,
|
||||||
|
UInt32 numItems,
|
||||||
const DataBrowserItemID *items,
|
const DataBrowserItemID *items,
|
||||||
DataBrowserPropertyID preSortProperty )
|
DataBrowserPropertyID preSortProperty )
|
||||||
{
|
{
|
||||||
return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
|
return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus wxMacDataBrowserListControl::RemoveItems( DataBrowserItemID container, UInt32 numItems,
|
OSStatus wxMacDataBrowserListControl::RemoveItems(
|
||||||
|
DataBrowserItemID container,
|
||||||
|
UInt32 numItems,
|
||||||
const DataBrowserItemID *items,
|
const DataBrowserItemID *items,
|
||||||
DataBrowserPropertyID preSortProperty )
|
DataBrowserPropertyID preSortProperty )
|
||||||
{
|
{
|
||||||
return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
|
return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus wxMacDataBrowserListControl::RevealItem( DataBrowserItemID item,
|
OSStatus wxMacDataBrowserListControl::RevealItem(
|
||||||
|
DataBrowserItemID item,
|
||||||
DataBrowserPropertyID propertyID,
|
DataBrowserPropertyID propertyID,
|
||||||
DataBrowserRevealOptions options )
|
DataBrowserRevealOptions options )
|
||||||
{
|
{
|
||||||
return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
|
return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus wxMacDataBrowserListControl::SetSelectedItems(UInt32 numItems,
|
OSStatus wxMacDataBrowserListControl::SetSelectedItems(
|
||||||
|
UInt32 numItems,
|
||||||
const DataBrowserItemID *items,
|
const DataBrowserItemID *items,
|
||||||
DataBrowserSetOption operation )
|
DataBrowserSetOption operation )
|
||||||
{
|
{
|
||||||
@@ -684,10 +725,11 @@ OSStatus wxMacDataBrowserListControl::GetSelectionAnchor( DataBrowserItemID * fi
|
|||||||
// in case we need that one day
|
// in case we need that one day
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// HIView owner draw based implementation
|
// HIView owner-draw-based implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item , DataBrowserPropertyID property ,
|
static pascal void ListBoxDrawProc(
|
||||||
|
ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property,
|
||||||
DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )
|
DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )
|
||||||
{
|
{
|
||||||
CFStringRef cfString;
|
CFStringRef cfString;
|
||||||
@@ -702,10 +744,10 @@ static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item
|
|||||||
{
|
{
|
||||||
ThemeBrush colorBrushID;
|
ThemeBrush colorBrushID;
|
||||||
|
|
||||||
|
// TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor
|
||||||
|
// is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor
|
||||||
|
// for inactive browser highlighting
|
||||||
Gestalt( gestaltSystemVersion, &systemVersion );
|
Gestalt( gestaltSystemVersion, &systemVersion );
|
||||||
|
|
||||||
// TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor is incorporated
|
|
||||||
// Panther DB starts using kThemeBrushSecondaryHighlightColor for inactive browser hilighting
|
|
||||||
if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) )
|
if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) )
|
||||||
colorBrushID = kThemeBrushSecondaryHighlightColor;
|
colorBrushID = kThemeBrushSecondaryHighlightColor;
|
||||||
else
|
else
|
||||||
@@ -725,7 +767,6 @@ static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// list box control implementation
|
// list box control implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -746,7 +787,8 @@ bool wxListBox::Create(wxWindow *parent,
|
|||||||
{
|
{
|
||||||
wxCArrayString chs(choices);
|
wxCArrayString chs(choices);
|
||||||
|
|
||||||
return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
|
return Create(
|
||||||
|
parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
|
||||||
style, validator, name);
|
style, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,7 +810,8 @@ bool wxListBox::Create(wxWindow *parent,
|
|||||||
if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name) )
|
if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_noItems = 0; // this will be increased by our append command
|
// this will be increased by our append command
|
||||||
|
m_noItems = 0;
|
||||||
|
|
||||||
m_peer = CreateMacListControl( pos, size, style );
|
m_peer = CreateMacListControl( pos, size, style );
|
||||||
|
|
||||||
@@ -776,9 +819,10 @@ bool wxListBox::Create(wxWindow *parent,
|
|||||||
|
|
||||||
InsertItems( n, choices, 0 );
|
InsertItems( n, choices, 0 );
|
||||||
|
|
||||||
SetBestSize(size); // Needed because it is a wxControlWithItems
|
// Needed because it is a wxControlWithItems
|
||||||
|
SetBestSize( size );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
@@ -798,7 +842,9 @@ void wxListBox::FreeData()
|
|||||||
if ( m_windowStyle & wxLB_OWNERDRAW )
|
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||||
{
|
{
|
||||||
size_t uiCount = m_aItems.Count();
|
size_t uiCount = m_aItems.Count();
|
||||||
while ( uiCount-- != 0 ) {
|
while ( uiCount != 0 )
|
||||||
|
{
|
||||||
|
uiCount--;
|
||||||
delete m_aItems[uiCount];
|
delete m_aItems[uiCount];
|
||||||
m_aItems[uiCount] = NULL;
|
m_aItems[uiCount] = NULL;
|
||||||
}
|
}
|
||||||
@@ -806,7 +852,7 @@ void wxListBox::FreeData()
|
|||||||
m_aItems.Clear();
|
m_aItems.Clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
{
|
{
|
||||||
for ( unsigned int n = 0; n < m_noItems; n++ )
|
for ( unsigned int n = 0; n < m_noItems; n++ )
|
||||||
@@ -830,18 +876,18 @@ void wxListBox::DoSetFirstItem(int n)
|
|||||||
|
|
||||||
void wxListBox::Delete(unsigned int n)
|
void wxListBox::Delete(unsigned int n)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( IsValid(n),
|
wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::Delete") );
|
||||||
wxT("invalid index in wxListBox::Delete") );
|
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
delete m_aItems[n];
|
delete m_aItems[n];
|
||||||
m_aItems.RemoveAt(n);
|
m_aItems.RemoveAt(n);
|
||||||
#else // !wxUSE_OWNER_DRAWN
|
#else
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
{
|
{
|
||||||
delete GetClientObject(n);
|
delete GetClientObject(n);
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
#endif
|
||||||
|
|
||||||
m_stringArray.RemoveAt( n );
|
m_stringArray.RemoveAt( n );
|
||||||
m_dataArray.RemoveAt( n );
|
m_dataArray.RemoveAt( n );
|
||||||
m_noItems--;
|
m_noItems--;
|
||||||
@@ -875,7 +921,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
|||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
wxASSERT_MSG(clientData[i] == NULL,
|
wxASSERT_MSG(clientData[i] == NULL,
|
||||||
wxT("Can't use client data with owner-drawn listboxes"));
|
wxT("Can't use client data with owner-drawn listboxes"));
|
||||||
#else // !wxUSE_OWNER_DRAWN
|
#else
|
||||||
Append( choices[i], clientData[i] );
|
Append( choices[i], clientData[i] );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -884,23 +930,28 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
if ( m_windowStyle & wxLB_OWNERDRAW ) {
|
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||||
|
{
|
||||||
// first delete old items
|
// first delete old items
|
||||||
size_t ui = m_aItems.Count();
|
size_t ui = m_aItems.Count();
|
||||||
while ( ui-- != 0 ) {
|
while ( ui != 0 )
|
||||||
|
{
|
||||||
|
ui--;
|
||||||
delete m_aItems[ui];
|
delete m_aItems[ui];
|
||||||
m_aItems[ui] = NULL;
|
m_aItems[ui] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_aItems.Empty();
|
m_aItems.Empty();
|
||||||
|
|
||||||
// then create new ones
|
// then create new ones
|
||||||
for ( ui = 0; ui < (size_t)m_noItems; ui++ ) {
|
for ( ui = 0; ui < (size_t)m_noItems; ui++ )
|
||||||
|
{
|
||||||
wxOwnerDrawn *pNewItem = CreateItem(ui);
|
wxOwnerDrawn *pNewItem = CreateItem(ui);
|
||||||
pNewItem->SetName(choices[ui]);
|
pNewItem->SetName(choices[ui]);
|
||||||
m_aItems.Add(pNewItem);
|
m_aItems.Add(pNewItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::FindString(const wxString& s, bool bCase) const
|
int wxListBox::FindString(const wxString& s, bool bCase) const
|
||||||
@@ -936,8 +987,7 @@ void wxListBox::DoSetSelection(int n, bool select)
|
|||||||
|
|
||||||
bool wxListBox::IsSelected(int n) const
|
bool wxListBox::IsSelected(int n) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsValid(n), false,
|
wxCHECK_MSG( IsValid(n), false, wxT("invalid index in wxListBox::Selected") );
|
||||||
wxT("invalid index in wxListBox::Selected") );
|
|
||||||
|
|
||||||
return GetPeer()->MacIsSelected( n );
|
return GetPeer()->MacIsSelected( n );
|
||||||
}
|
}
|
||||||
@@ -967,7 +1017,8 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
|
|||||||
// in OnMeasure/OnDraw.
|
// in OnMeasure/OnDraw.
|
||||||
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif
|
||||||
|
|
||||||
wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int) n, wxT("invalid client_data array") );
|
wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int) n, wxT("invalid client_data array") );
|
||||||
|
|
||||||
if ( m_dataArray.GetCount() > (unsigned int) n )
|
if ( m_dataArray.GetCount() > (unsigned int) n )
|
||||||
@@ -996,16 +1047,14 @@ int wxListBox::GetSelection() const
|
|||||||
// Find string for position
|
// Find string for position
|
||||||
wxString wxListBox::GetString(unsigned int n) const
|
wxString wxListBox::GetString(unsigned int n) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsValid(n), wxEmptyString,
|
wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxListBox::GetString") );
|
||||||
wxT("invalid index in wxListBox::GetString") );
|
|
||||||
|
|
||||||
return m_stringArray[n];
|
return m_stringArray[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( IsValidInsert(pos),
|
wxCHECK_RET( IsValidInsert(pos), wxT("invalid index in wxListBox::InsertItems") );
|
||||||
wxT("invalid index in wxListBox::InsertItems") );
|
|
||||||
|
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
|
|
||||||
@@ -1111,7 +1160,8 @@ public:
|
|||||||
wxListBoxItem(const wxString& str = "");
|
wxListBoxItem(const wxString& str = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
|
wxListBoxItem::wxListBoxItem(const wxString& str)
|
||||||
|
: wxOwnerDrawn(str, false)
|
||||||
{
|
{
|
||||||
// no bitmaps/checkmarks
|
// no bitmaps/checkmarks
|
||||||
SetMarginWidth(0);
|
SetMarginWidth(0);
|
||||||
@@ -1140,10 +1190,10 @@ wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
|||||||
|
|
||||||
int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||||
{
|
{
|
||||||
OSErr err;
|
OSStatus err;
|
||||||
|
|
||||||
// There are few reasons why this is complicated:
|
// There are few reasons why this is complicated:
|
||||||
// 1) There is no native hittest function for mac
|
// 1) There is no native HitTest function for Mac
|
||||||
// 2) GetDataBrowserItemPartBounds only works on visible items
|
// 2) GetDataBrowserItemPartBounds only works on visible items
|
||||||
// 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
|
// 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
|
||||||
// because what it returns is basically inaccurate in the context
|
// because what it returns is basically inaccurate in the context
|
||||||
@@ -1151,13 +1201,14 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
|||||||
// for where the first visible item lies
|
// for where the first visible item lies
|
||||||
|
|
||||||
wxPoint point = inpoint;
|
wxPoint point = inpoint;
|
||||||
|
|
||||||
// interestingly enough 10.2 (and below?) have GetDataBrowserItemPartBounds
|
// interestingly enough 10.2 (and below?) have GetDataBrowserItemPartBounds
|
||||||
// giving root window coordinates but 10.3 and above give client coordinates
|
// 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
|
// so we only compare using root window coordinates on 10.3 and up
|
||||||
if ( UMAGetSystemVersion() < 0x1030 )
|
if ( UMAGetSystemVersion() < 0x1030 )
|
||||||
MacClientToRootWindow(&point.x, &point.y);
|
MacClientToRootWindow(&point.x, &point.y);
|
||||||
|
|
||||||
// get column property id (req. for call to itempartbounds)
|
// get column property ID (req. for call to itempartbounds)
|
||||||
DataBrowserTableViewColumnID colId = 0;
|
DataBrowserTableViewColumnID colId = 0;
|
||||||
err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
|
err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
|
||||||
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
|
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
|
||||||
@@ -1180,16 +1231,16 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
|||||||
int low = scrolly / height,
|
int low = scrolly / height,
|
||||||
high = GetCount() - 1;
|
high = GetCount() - 1;
|
||||||
|
|
||||||
|
|
||||||
// search for the first visible item (note that the scroll guess above
|
// 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
|
// 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)
|
// starting point - we should reach it within 1 or 2 iterations of the loop)
|
||||||
while ( low <= high )
|
while ( low <= high )
|
||||||
{
|
{
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
err = GetDataBrowserItemPartBounds(m_peer->GetControlRef(), low + 1, colId,
|
err = GetDataBrowserItemPartBounds(
|
||||||
|
m_peer->GetControlRef(), low + 1, colId,
|
||||||
kDataBrowserPropertyEnclosingPart,
|
kDataBrowserPropertyEnclosingPart,
|
||||||
&bounds); //note +1 to trans to mac id
|
&bounds); // note +1 to translate to Mac ID
|
||||||
if ( err == noErr )
|
if ( err == noErr )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1208,7 +1259,8 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
|||||||
int mid = (low + high) / 2;
|
int mid = (low + high) / 2;
|
||||||
|
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
err = GetDataBrowserItemPartBounds(m_peer->GetControlRef(), mid + 1, colId,
|
err = GetDataBrowserItemPartBounds(
|
||||||
|
m_peer->GetControlRef(), mid + 1, colId,
|
||||||
kDataBrowserPropertyEnclosingPart,
|
kDataBrowserPropertyEnclosingPart,
|
||||||
&bounds); //note +1 to trans to mac id
|
&bounds); //note +1 to trans to mac id
|
||||||
wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
|
wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
|
||||||
@@ -1218,7 +1270,8 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
|||||||
if ( err == errDataBrowserItemNotFound )
|
if ( err == errDataBrowserItemNotFound )
|
||||||
{
|
{
|
||||||
// item not visible, attempt to find a visible one
|
// item not visible, attempt to find a visible one
|
||||||
high = mid - 1; // search lower
|
// search lower
|
||||||
|
high = mid - 1;
|
||||||
}
|
}
|
||||||
else // visible item, do actual hitttest
|
else // visible item, do actual hitttest
|
||||||
{
|
{
|
||||||
@@ -1228,13 +1281,16 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
|||||||
if ((point.x >= bounds.left && point.x <= bounds.right) &&
|
if ((point.x >= bounds.left && point.x <= bounds.right) &&
|
||||||
(point.y >= bounds.top && point.y <= bounds.bottom) )
|
(point.y >= bounds.top && point.y <= bounds.bottom) )
|
||||||
{
|
{
|
||||||
return mid; // found!
|
// found!
|
||||||
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( point.y < bounds.top )
|
if ( point.y < bounds.top )
|
||||||
high = mid - 1; // index(bounds) greater then key(point)
|
// index(bounds) greater then key(point)
|
||||||
|
high = mid - 1;
|
||||||
else
|
else
|
||||||
low = mid + 1; // index(bounds) less then key(point)
|
// index(bounds) less then key(point)
|
||||||
|
low = mid + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user