if ( value == m_startValue )
{
// nothing changed, always accept
+ // when an item remains unchanged, the owner
+ // needs to be notified that the user decided
+ // not to change the tree item label, and that
+ // the edit has been cancelled
+
+ m_owner->OnRenameCancelled(m_itemEdited);
return true;
}
switch ( event.m_keyCode )
{
case WXK_RETURN:
- if ( AcceptChanges() )
- {
- // Close the text control, changes were accepted
- Finish();
- }
- // else do nothing, do not accept and do not close
+ // Notify the owner about the changes
+ AcceptChanges();
+
+ // Even if vetoed, close the control (consistent with MSW)
+ Finish();
+
break;
case WXK_ESCAPE:
m_findTimer = NULL;
+ m_dropEffectAboveItem = false;
+
m_lastOnSame = false;
-#ifdef __WXMAC_CARBON__
+#ifdef __WXMAC_CARBON__
m_normalFont.MacCreateThemeFont( kThemeViewsFont ) ;
#else
m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
wxString wxGenericTreeCtrl::GetItemText(const wxTreeItemId& item) const
{
- wxCHECK_MSG( item.IsOk(), wxT(""), wxT("invalid tree item") );
+ wxCHECK_MSG( item.IsOk(), wxEmptyString, wxT("invalid tree item") );
return ((wxGenericTreeItem*) item.m_pItem)->GetText();
}
}
}
+void wxGenericTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item,
+ bool highlight)
+{
+ wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
+
+ wxColour fg, bg;
+
+ if (highlight)
+ {
+ bg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
+ fg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+ }
+
+ wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem;
+ pItem->Attr().SetTextColour(fg);
+ pItem->Attr().SetBackgroundColour(bg);
+ RefreshLine(pItem);
+}
+
void wxGenericTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
const wxColour& col)
{
if (item == m_select_me)
m_select_me = NULL;
-
+
delete item;
}
{
// draw a line under the drop target because the item will be
// dropped there
- DrawLine(item, true /* below */);
+ DrawLine(item, !m_dropEffectAboveItem );
}
SetCursor(wxCURSOR_BULLSEYE);
bool is_multiple, extended_select, unselect_others;
EventFlagsToSelType(GetWindowStyleFlag(),
event.ShiftDown(),
- event.ControlDown(),
+ event.CmdDown(),
is_multiple, extended_select, unselect_others);
// + : Expand
}
break;
+ case WXK_MENU:
+ {
+ wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() );
+ event.m_item = m_current;
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ break;
+ }
case ' ':
case WXK_RETURN:
if ( !event.HasModifiers() )
CaptureMouse();
}
}
- else if ( event.Moving() )
+ else if ( event.Dragging() )
{
if ( item != m_dropTarget )
{
// highlight the current drop target if any
DrawDropEffect(m_dropTarget);
-#if defined( __WXMSW__ ) || defined(__WXMAC__)
+#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__)
Update();
#else
wxYieldIfNeeded();
if ( event.RightDown() )
{
+ // If the item is already selected, do not update the selection.
+ // Multi-selections should not be cleared if a selected item is clicked.
+ if (!IsSelected(item))
+ {
+ DoSelectItem(item, true, false);
+ }
+
wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId());
nevent.m_item = item;
nevent.m_pointDrag = CalcScrolledPosition(pt);
nevent.SetEventObject(this);
- GetEventHandler()->ProcessEvent(nevent);
+ event.Skip(!GetEventHandler()->ProcessEvent(nevent));
}
else if ( event.LeftUp() )
{
size_t count = GetSelections(selections);
if (count > 1 &&
- !event.ControlDown() &&
+ !event.CmdDown() &&
!event.ShiftDown())
{
DoSelectItem(item, true, false);
// user clicked outside of the present selection.
// otherwise, perform the deselection on mouse-up.
// this allows multiple drag and drop to work.
-
- if (!IsSelected(item))
+ // but if Cmd is down, toggle selection of the clicked item
+ if (!IsSelected(item) || event.CmdDown())
{
// how should the selection work for this event?
bool is_multiple, extended_select, unselect_others;
EventFlagsToSelType(GetWindowStyleFlag(),
event.ShiftDown(),
- event.ControlDown(),
+ event.CmdDown(),
is_multiple, extended_select, unselect_others);
DoSelectItem(item, unselect_others, extended_select);
#endif
}
+#if WXWIN_COMPATIBILITY_2_4
+
+int wxGenericTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const
+{
+ return GetItemImage(item, wxTreeItemIcon_Selected);
+}
+
+void wxGenericTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image)
+{
+ SetItemImage(item, image, wxTreeItemIcon_Selected);
+}
+
+#endif // WXWIN_COMPATIBILITY_2_4
+
+#if WXWIN_COMPATIBILITY_2_2
+
+wxTreeItemId wxGenericTreeCtrl::GetParent(const wxTreeItemId& item) const
+{
+ return GetItemParent( item );
+}
+
+#endif // WXWIN_COMPATIBILITY_2_2
+
#endif // wxUSE_TREECTRL