X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b771aa29dd34686cc92ef4675978b1fdc1a47a29..2fe212b0336512aac9eace69fab09ce856b0bf4b:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index f2b3ca9dde..3176b1eb92 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -360,21 +360,6 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) m_owner->OnRenameAccept(); } -#if 0 -// ----------------------------------------------------------------------------- -// wxTreeEvent -// ----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent) - -wxTreeEvent::wxTreeEvent( wxEventType commandType, int id ) - : wxNotifyEvent( commandType, id ) -{ - m_code = 0; - m_itemOld = (wxGenericTreeItem *)NULL; -} -#endif - // ----------------------------------------------------------------------------- // wxGenericTreeItem // ----------------------------------------------------------------------------- @@ -679,7 +664,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) ); // m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86 - m_dottedPen = wxPen( "grey", 0, 0 ); + m_dottedPen = wxPen( wxT("grey"), 0, 0 ); return TRUE; } @@ -1032,15 +1017,6 @@ wxTreeItemId wxGenericTreeCtrl::GetNext(const wxTreeItemId& item) const } } -wxTreeItemId wxGenericTreeCtrl::GetPrev(const wxTreeItemId& item) const -{ - wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); - - wxFAIL_MSG(wxT("not implemented")); - - return wxTreeItemId(); -} - wxTreeItemId wxGenericTreeCtrl::GetFirstVisibleItem() const { wxTreeItemId id = GetRootItem(); @@ -2018,7 +1994,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level wxTRANSPARENT_PEN; wxColour colText; - if (item->IsSelected() && m_hasFocus) + if ( item->IsSelected() ) { colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT); } @@ -2181,9 +2157,13 @@ void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &event ) void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) { wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() ); - te.m_code = (int)event.KeyCode(); + te.m_evtKey = event; te.SetEventObject( this ); - GetEventHandler()->ProcessEvent( te ); + if ( GetEventHandler()->ProcessEvent( te ) ) + { + // intercepted by the user code + return; + } if ( (m_current == 0) || (m_key_current == 0) ) { @@ -2241,7 +2221,6 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) { wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() ); event.m_item = (long) m_current; - event.m_code = 0; event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); } @@ -2666,7 +2645,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) { wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId()); nevent.m_item = (long) item; - nevent.m_code = 0; CalcScrolledPosition(x, y, &nevent.m_pointDrag.x, &nevent.m_pointDrag.y); @@ -2727,23 +2705,22 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) m_renameTimer->Stop(); m_lastOnSame = FALSE; - if (item->HasPlus()) - { - // for a "directory" node, toggle expansion - Toggle(item); - } - else + // send activate event first + wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() ); + nevent.m_item = (long) item; + CalcScrolledPosition(x, y, + &nevent.m_pointDrag.x, + &nevent.m_pointDrag.y); + nevent.SetEventObject( this ); + if ( !GetEventHandler()->ProcessEvent( nevent ) ) { - // for a "file" node, activate it - wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, - GetId() ); - nevent.m_item = (long) item; - nevent.m_code = 0; - CalcScrolledPosition(x, y, - &nevent.m_pointDrag.x, - &nevent.m_pointDrag.y); - nevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( nevent ); + // if the user code didn't process the activate event, + // handle it ourselves by toggling the item when it is + // double clicked + if ( item->HasPlus() ) + { + Toggle(item); + } } } } @@ -2922,4 +2899,28 @@ void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) } } +// ---------------------------------------------------------------------------- +// changing colours: we need to refresh the tree control +// ---------------------------------------------------------------------------- + +bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour) +{ + if ( !wxWindow::SetBackgroundColour(colour) ) + return FALSE; + + Refresh(); + + return TRUE; +} + +bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour) +{ + if ( !wxWindow::SetForegroundColour(colour) ) + return FALSE; + + Refresh(); + + return TRUE; +} + #endif // wxUSE_TREECTRL