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 )
|
||||
{
|
||||
}
|
||||
|
||||
~wxMacListControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void UpdateLine( int n ) = 0;
|
||||
@@ -67,7 +67,7 @@ public :
|
||||
|
||||
#if 0
|
||||
// In case we have to replace data browser ...
|
||||
// custom HIView based implementation
|
||||
// custom HIView-based implementation
|
||||
|
||||
class wxMacCustomHIViewListControl : public wxMacListControl
|
||||
{
|
||||
@@ -90,7 +90,7 @@ public :
|
||||
};
|
||||
#endif
|
||||
|
||||
// data browser based implementation
|
||||
// DataBrowser-based implementation
|
||||
|
||||
class wxMacDataBrowserListControl : public wxMacListControl
|
||||
{
|
||||
@@ -145,13 +145,19 @@ private :
|
||||
// events in the latter case
|
||||
bool MacSuppressSelection( bool suppress );
|
||||
bool MacIsSelectionSuppressed() const { return m_suppressSelection; }
|
||||
|
||||
bool m_suppressSelection;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message, DataBrowserItemDataRef itemData);
|
||||
static pascal void DataBrowserItemNotificationProc(
|
||||
ControlRef browser,
|
||||
DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message,
|
||||
DataBrowserItemDataRef itemData );
|
||||
#else
|
||||
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
||||
static pascal void DataBrowserItemNotificationProc(
|
||||
ControlRef browser,
|
||||
DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message );
|
||||
#endif
|
||||
};
|
||||
@@ -173,15 +179,20 @@ DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
|
||||
DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
|
||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
|
||||
ControlRef browser,
|
||||
DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message,
|
||||
DataBrowserItemDataRef itemData)
|
||||
#else
|
||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
|
||||
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
|
||||
ControlRef browser,
|
||||
DataBrowserItemID itemID,
|
||||
DataBrowserItemNotification message)
|
||||
#endif
|
||||
{
|
||||
long ref = GetControlReference( browser );
|
||||
if ( ref )
|
||||
if ( ref != 0 )
|
||||
{
|
||||
wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
|
||||
wxMacDataBrowserListControl* peer = (wxMacDataBrowserListControl*) list->GetPeer();
|
||||
@@ -247,7 +258,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
switch (property)
|
||||
{
|
||||
case kTextColumnId:
|
||||
{
|
||||
if ( ref )
|
||||
{
|
||||
int i = itemID - 1;
|
||||
@@ -258,11 +268,9 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
err = noErr;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case kCheckboxColumnId:
|
||||
{
|
||||
if ( ref )
|
||||
{
|
||||
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
||||
@@ -273,13 +281,11 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
err = noErr;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case kDataBrowserItemIsEditableProperty:
|
||||
{
|
||||
if ( isCheckList )
|
||||
err = ::SetDataBrowserItemDataBooleanValue(itemData, true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -291,7 +297,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
switch (property)
|
||||
{
|
||||
case kCheckboxColumnId:
|
||||
{
|
||||
if ( ref )
|
||||
{
|
||||
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
|
||||
@@ -310,8 +315,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
list->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -322,19 +325,22 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
|
||||
return err;
|
||||
}
|
||||
|
||||
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , const wxPoint& pos, const wxSize& size, long style) :
|
||||
wxMacListControl( peer )
|
||||
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxMacListControl( peer )
|
||||
{
|
||||
bool isCheckList = peer->IsKindOf( CLASSINFO(wxCheckListBox));
|
||||
|
||||
m_suppressSelection = false;
|
||||
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;
|
||||
if ( style & wxLB_MULTIPLE )
|
||||
{
|
||||
options += kDataBrowserAlwaysExtendSelection + kDataBrowserCmdTogglesSelection ;
|
||||
options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
|
||||
}
|
||||
else if ( style & wxLB_EXTENDED )
|
||||
{
|
||||
@@ -342,11 +348,13 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
||||
}
|
||||
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 )
|
||||
{
|
||||
gDataBrowserItemNotificationUPP =
|
||||
@@ -384,9 +392,12 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
||||
|
||||
columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
|
||||
columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
|
||||
columnDesc.propertyDesc.propertyFlags = kDataBrowserPropertyIsMutable | kDataBrowserTableViewSelectionColumn |
|
||||
kDataBrowserDefaultPropertyFlags;
|
||||
verify_noerr(AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn) );
|
||||
columnDesc.propertyDesc.propertyFlags =
|
||||
kDataBrowserPropertyIsMutable
|
||||
| kDataBrowserTableViewSelectionColumn
|
||||
| kDataBrowserDefaultPropertyFlags;
|
||||
err = AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn );
|
||||
verify_noerr( err );
|
||||
}
|
||||
|
||||
columnDesc.headerBtnDesc.minimumWidth = 0;
|
||||
@@ -395,11 +406,10 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
||||
|
||||
columnDesc.propertyDesc.propertyID = kTextColumnId;
|
||||
columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
|
||||
columnDesc.propertyDesc.propertyFlags =
|
||||
columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
||||
kDataBrowserListViewTypeSelectColumn |
|
||||
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
|
||||
#endif
|
||||
kDataBrowserTableViewSelectionColumn;
|
||||
|
||||
verify_noerr( AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
||||
verify_noerr( AutoSizeListViewColumns() );
|
||||
@@ -413,9 +423,9 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer , cons
|
||||
m_peer->SetNeedsFocusRect( true );
|
||||
#endif
|
||||
}
|
||||
|
||||
wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void wxMacDataBrowserListControl::MacDelete( int n )
|
||||
@@ -424,7 +434,10 @@ void wxMacDataBrowserListControl::MacDelete( int n )
|
||||
MacGetSelections( selectionBefore );
|
||||
|
||||
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 )
|
||||
{
|
||||
int current = selectionBefore[i];
|
||||
@@ -440,8 +453,12 @@ void wxMacDataBrowserListControl::MacDelete( int n )
|
||||
MacSetSelection( current, false );
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
@@ -450,7 +467,8 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxString& text)
|
||||
MacGetSelections( selectionBefore );
|
||||
|
||||
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 )
|
||||
{
|
||||
@@ -463,7 +481,10 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxString& text)
|
||||
}
|
||||
|
||||
// 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)
|
||||
@@ -476,7 +497,8 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxArrayString& items)
|
||||
for ( unsigned int i = 0; i < itemsCount; ++i )
|
||||
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;
|
||||
|
||||
for ( int i = selectionBefore.GetCount() - 1; i >= 0; --i )
|
||||
@@ -490,7 +512,10 @@ void wxMacDataBrowserListControl::MacInsert( int n , const wxArrayString& items)
|
||||
}
|
||||
|
||||
// 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)
|
||||
@@ -514,16 +539,21 @@ void wxMacDataBrowserListControl::MacDeselectAll()
|
||||
|
||||
void wxMacDataBrowserListControl::MacSetSelection( int n, bool select )
|
||||
{
|
||||
bool former = MacSuppressSelection( true );
|
||||
UInt32 id = n + 1;
|
||||
bool former = MacSuppressSelection( true );
|
||||
|
||||
if ( IsItemSelected( id ) != select )
|
||||
{
|
||||
OSStatus err;
|
||||
|
||||
if ( select )
|
||||
verify_noerr(SetSelectedItems( 1 , & id , GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign ) );
|
||||
err = SetSelectedItems( 1, &id, GetPeer()->HasMultipleSelection() ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
|
||||
else
|
||||
verify_noerr(SetSelectedItems( 1 , & id , kDataBrowserItemsRemove ) );
|
||||
err = SetSelectedItems( 1, &id, kDataBrowserItemsRemove );
|
||||
|
||||
verify_noerr( err );
|
||||
}
|
||||
|
||||
MacScrollTo( n );
|
||||
MacSuppressSelection( former );
|
||||
}
|
||||
@@ -532,6 +562,7 @@ bool wxMacDataBrowserListControl::MacSuppressSelection( bool suppress )
|
||||
{
|
||||
bool former = m_suppressSelection;
|
||||
m_suppressSelection = suppress;
|
||||
|
||||
return former;
|
||||
}
|
||||
|
||||
@@ -549,6 +580,7 @@ int wxMacDataBrowserListControl::MacGetSelection() const
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -571,6 +603,7 @@ int wxMacDataBrowserListControl::MacGetSelections( wxArrayInt& aSelections ) con
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return no_sel;
|
||||
}
|
||||
|
||||
@@ -633,7 +666,9 @@ OSStatus wxMacDataBrowserListControl::SetCallbacks(const DataBrowserCallbacks *
|
||||
return SetDataBrowserCallbacks( m_controlRef, callbacks );
|
||||
}
|
||||
|
||||
OSStatus wxMacDataBrowserListControl::UpdateItems( DataBrowserItemID container, UInt32 numItems,
|
||||
OSStatus wxMacDataBrowserListControl::UpdateItems(
|
||||
DataBrowserItemID container,
|
||||
UInt32 numItems,
|
||||
const DataBrowserItemID *items,
|
||||
DataBrowserPropertyID preSortProperty,
|
||||
DataBrowserPropertyID propertyID )
|
||||
@@ -646,28 +681,34 @@ bool wxMacDataBrowserListControl::IsItemSelected( DataBrowserItemID item ) const
|
||||
return IsDataBrowserItemSelected( m_controlRef, item );
|
||||
}
|
||||
|
||||
OSStatus wxMacDataBrowserListControl::AddItems( DataBrowserItemID container, UInt32 numItems,
|
||||
OSStatus wxMacDataBrowserListControl::AddItems(
|
||||
DataBrowserItemID container,
|
||||
UInt32 numItems,
|
||||
const DataBrowserItemID *items,
|
||||
DataBrowserPropertyID 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,
|
||||
DataBrowserPropertyID preSortProperty )
|
||||
{
|
||||
return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
|
||||
}
|
||||
|
||||
OSStatus wxMacDataBrowserListControl::RevealItem( DataBrowserItemID item,
|
||||
OSStatus wxMacDataBrowserListControl::RevealItem(
|
||||
DataBrowserItemID item,
|
||||
DataBrowserPropertyID propertyID,
|
||||
DataBrowserRevealOptions options )
|
||||
{
|
||||
return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
|
||||
}
|
||||
|
||||
OSStatus wxMacDataBrowserListControl::SetSelectedItems(UInt32 numItems,
|
||||
OSStatus wxMacDataBrowserListControl::SetSelectedItems(
|
||||
UInt32 numItems,
|
||||
const DataBrowserItemID *items,
|
||||
DataBrowserSetOption operation )
|
||||
{
|
||||
@@ -684,10 +725,11 @@ OSStatus wxMacDataBrowserListControl::GetSelectionAnchor( DataBrowserItemID * fi
|
||||
// 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 )
|
||||
{
|
||||
CFStringRef cfString;
|
||||
@@ -702,10 +744,10 @@ static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item
|
||||
{
|
||||
ThemeBrush colorBrushID;
|
||||
|
||||
// TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor
|
||||
// is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor
|
||||
// for inactive browser highlighting
|
||||
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 ) )
|
||||
colorBrushID = kThemeBrushSecondaryHighlightColor;
|
||||
else
|
||||
@@ -725,7 +767,6 @@ static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// list box control implementation
|
||||
// ============================================================================
|
||||
@@ -746,7 +787,8 @@ bool wxListBox::Create(wxWindow *parent,
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -768,7 +810,8 @@ bool wxListBox::Create(wxWindow *parent,
|
||||
if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name) )
|
||||
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 );
|
||||
|
||||
@@ -776,9 +819,10 @@ bool wxListBox::Create(wxWindow *parent,
|
||||
|
||||
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()
|
||||
@@ -798,7 +842,9 @@ void wxListBox::FreeData()
|
||||
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||
{
|
||||
size_t uiCount = m_aItems.Count();
|
||||
while ( uiCount-- != 0 ) {
|
||||
while ( uiCount != 0 )
|
||||
{
|
||||
uiCount--;
|
||||
delete m_aItems[uiCount];
|
||||
m_aItems[uiCount] = NULL;
|
||||
}
|
||||
@@ -806,7 +852,7 @@ void wxListBox::FreeData()
|
||||
m_aItems.Clear();
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_OWNER_DRAWN
|
||||
#endif
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
for ( unsigned int n = 0; n < m_noItems; n++ )
|
||||
@@ -830,18 +876,18 @@ void wxListBox::DoSetFirstItem(int n)
|
||||
|
||||
void wxListBox::Delete(unsigned int n)
|
||||
{
|
||||
wxCHECK_RET( IsValid(n),
|
||||
wxT("invalid index in wxListBox::Delete") );
|
||||
wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::Delete") );
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
delete m_aItems[n];
|
||||
m_aItems.RemoveAt(n);
|
||||
#else // !wxUSE_OWNER_DRAWN
|
||||
#else
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
delete GetClientObject(n);
|
||||
}
|
||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||
#endif
|
||||
|
||||
m_stringArray.RemoveAt( n );
|
||||
m_dataArray.RemoveAt( n );
|
||||
m_noItems--;
|
||||
@@ -875,7 +921,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
wxASSERT_MSG(clientData[i] == NULL,
|
||||
wxT("Can't use client data with owner-drawn listboxes"));
|
||||
#else // !wxUSE_OWNER_DRAWN
|
||||
#else
|
||||
Append( choices[i], clientData[i] );
|
||||
#endif
|
||||
}
|
||||
@@ -884,23 +930,28 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||
}
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
if ( m_windowStyle & wxLB_OWNERDRAW ) {
|
||||
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||
{
|
||||
// first delete old items
|
||||
size_t ui = m_aItems.Count();
|
||||
while ( ui-- != 0 ) {
|
||||
while ( ui != 0 )
|
||||
{
|
||||
ui--;
|
||||
delete m_aItems[ui];
|
||||
m_aItems[ui] = NULL;
|
||||
}
|
||||
|
||||
m_aItems.Empty();
|
||||
|
||||
// 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);
|
||||
pNewItem->SetName(choices[ui]);
|
||||
m_aItems.Add(pNewItem);
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_OWNER_DRAWN
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( IsValid(n), false,
|
||||
wxT("invalid index in wxListBox::Selected") );
|
||||
wxCHECK_MSG( IsValid(n), false, wxT("invalid index in wxListBox::Selected") );
|
||||
|
||||
return GetPeer()->MacIsSelected( n );
|
||||
}
|
||||
@@ -967,7 +1017,8 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
|
||||
// in OnMeasure/OnDraw.
|
||||
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") );
|
||||
|
||||
if ( m_dataArray.GetCount() > (unsigned int) n )
|
||||
@@ -996,16 +1047,14 @@ int wxListBox::GetSelection() const
|
||||
// Find string for position
|
||||
wxString wxListBox::GetString(unsigned int n) const
|
||||
{
|
||||
wxCHECK_MSG( IsValid(n), wxEmptyString,
|
||||
wxT("invalid index in wxListBox::GetString") );
|
||||
wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxListBox::GetString") );
|
||||
|
||||
return m_stringArray[n];
|
||||
}
|
||||
|
||||
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
||||
{
|
||||
wxCHECK_RET( IsValidInsert(pos),
|
||||
wxT("invalid index in wxListBox::InsertItems") );
|
||||
wxCHECK_RET( IsValidInsert(pos), wxT("invalid index in wxListBox::InsertItems") );
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
@@ -1111,7 +1160,8 @@ public:
|
||||
wxListBoxItem(const wxString& str = "");
|
||||
};
|
||||
|
||||
wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
|
||||
wxListBoxItem::wxListBoxItem(const wxString& str)
|
||||
: wxOwnerDrawn(str, false)
|
||||
{
|
||||
// no bitmaps/checkmarks
|
||||
SetMarginWidth(0);
|
||||
@@ -1140,10 +1190,10 @@ wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||
|
||||
int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||
{
|
||||
OSErr err;
|
||||
OSStatus err;
|
||||
|
||||
// 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
|
||||
// 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
|
||||
// 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
|
||||
|
||||
wxPoint point = inpoint;
|
||||
|
||||
// interestingly enough 10.2 (and below?) have GetDataBrowserItemPartBounds
|
||||
// giving root window coordinates but 10.3 and above give client coordinates
|
||||
// so we only compare using root window coordinates on 10.3 and up
|
||||
if ( UMAGetSystemVersion() < 0x1030 )
|
||||
MacClientToRootWindow(&point.x, &point.y);
|
||||
|
||||
// get column property id (req. for call to itempartbounds)
|
||||
// get column property ID (req. for call to itempartbounds)
|
||||
DataBrowserTableViewColumnID colId = 0;
|
||||
err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
|
||||
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
|
||||
@@ -1180,16 +1231,16 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||
int low = scrolly / height,
|
||||
high = GetCount() - 1;
|
||||
|
||||
|
||||
// search for the first visible item (note that the scroll guess above
|
||||
// is the low bounds of where the item might lie so we only use that as a
|
||||
// starting point - we should reach it within 1 or 2 iterations of the loop)
|
||||
while ( low <= high )
|
||||
{
|
||||
Rect bounds;
|
||||
err = GetDataBrowserItemPartBounds(m_peer->GetControlRef(), low + 1, colId,
|
||||
err = GetDataBrowserItemPartBounds(
|
||||
m_peer->GetControlRef(), low + 1, colId,
|
||||
kDataBrowserPropertyEnclosingPart,
|
||||
&bounds); //note +1 to trans to mac id
|
||||
&bounds); // note +1 to translate to Mac ID
|
||||
if ( err == noErr )
|
||||
break;
|
||||
|
||||
@@ -1208,7 +1259,8 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||
int mid = (low + high) / 2;
|
||||
|
||||
Rect bounds;
|
||||
err = GetDataBrowserItemPartBounds(m_peer->GetControlRef(), mid + 1, colId,
|
||||
err = GetDataBrowserItemPartBounds(
|
||||
m_peer->GetControlRef(), mid + 1, colId,
|
||||
kDataBrowserPropertyEnclosingPart,
|
||||
&bounds); //note +1 to trans to mac id
|
||||
wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
|
||||
@@ -1218,7 +1270,8 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||
if ( err == errDataBrowserItemNotFound )
|
||||
{
|
||||
// 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
|
||||
{
|
||||
@@ -1228,13 +1281,16 @@ int wxListBox::DoListHitTest(const wxPoint& inpoint) const
|
||||
if ((point.x >= bounds.left && point.x <= bounds.right) &&
|
||||
(point.y >= bounds.top && point.y <= bounds.bottom) )
|
||||
{
|
||||
return mid; // found!
|
||||
// found!
|
||||
return mid;
|
||||
}
|
||||
|
||||
if ( point.y < bounds.top )
|
||||
high = mid - 1; // index(bounds) greater then key(point)
|
||||
// index(bounds) greater then key(point)
|
||||
high = mid - 1;
|
||||
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