+ wxASSERT_MSG( item < GetCount(), _T("Invalid item index") );
+
+ // extend the array to have entries for all our items on first use
+ if ( !m_itemsTooltips )
+ {
+ m_itemsTooltips = new wxToolTipArray;
+ m_itemsTooltips->resize(GetCount());
+ }
+
+ wxToolTip *tooltip = (*m_itemsTooltips)[item];
+
+ bool changed = true;
+ if ( text.empty() )
+ {
+ if ( tooltip )
+ {
+ // delete the tooltip
+ delete tooltip;
+ tooltip = NULL;
+ }
+ else // nothing to do
+ {
+ changed = false;
+ }
+ }
+ else // non empty tooltip text
+ {
+ if ( tooltip )
+ {
+ // just change the existing tooltip text, don't change the tooltip
+ tooltip->SetTip(text);
+ changed = false;
+ }
+ else // no tooltip yet
+ {
+ // create the new one
+ tooltip = new wxToolTip(text);
+ }
+ }
+
+ if ( changed )
+ {
+ (*m_itemsTooltips)[item] = tooltip;
+ DoSetItemToolTip(item, tooltip);
+ }