X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d77016e8aaff75433fde23740a257e5c5ebb1dc2..5d7b75542e6cc3fe9823828a00889cb5d578814a:/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp diff --git a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp index 8a59591666..c28cf7927e 100644 --- a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp +++ b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp @@ -19,10 +19,6 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(__APPLE__) - #pragma implementation "treelistctrl.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -1074,7 +1070,7 @@ void wxTreeListTextCtrl::OnKillFocus( wxFocusEvent &event ) // wxTreeListHeaderWindow //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow,wxWindow); +IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow,wxWindow) BEGIN_EVENT_TABLE(wxTreeListHeaderWindow,wxWindow) EVT_ERASE_BACKGROUND (wxTreeListHeaderWindow::OnEraseBackground) @@ -1220,7 +1216,6 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.SetBackground(wxBrush(GetBackgroundColour())); dc.Clear(); - dc.BeginDrawing(); dc.SetFont( GetFont() ); dc.SetBackgroundMode(wxTRANSPARENT); @@ -1311,7 +1306,6 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) } // Finish up by drawing the buffer to the real dc - dc.EndDrawing(); dc.SelectObject(wxNullBitmap); real_dc.DrawBitmap(buffer, 0, 0, false); } @@ -1398,7 +1392,7 @@ void wxTreeListHeaderWindow::OnMouse( wxMouseEvent &event ) // end of the current column int xpos = 0; - // find the column where this event occured + // find the column where this event occurred int countCol = GetColumnCount(); for (int col = 0; col < countCol; col++) { @@ -1891,7 +1885,7 @@ void wxTreeListMainWindow::Init() m_underMouse = NULL; -#if defined( __WXMAC__ ) && defined(__WXMAC_CARBON__) +#ifdef __WXMAC_CARBON__ m_normalFont.MacCreateThemeFont( kThemeViewsFont ) ; #else m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); @@ -2463,7 +2457,7 @@ wxTreeItemId wxTreeListMainWindow::DoInsertItem(const wxTreeItemId& parentId, if ( data != NULL ) { - data->SetId((long)item); + data->SetId((void*)item); } parent->Insert( item, previous ); @@ -2500,7 +2494,7 @@ wxTreeItemId wxTreeListMainWindow::AddRoot(const wxString& text, #endif if ( data != NULL ) { - data->SetId((long)m_anchor); + data->SetId((void*)m_anchor); } if (!HasFlag(wxTR_MULTIPLE)) @@ -2575,7 +2569,7 @@ wxTreeItemId wxTreeListMainWindow::AppendItem(const wxTreeItemId& parentId, void wxTreeListMainWindow::SendDeleteEvent(wxTreeListItem *item) { wxTreeEvent event( wxEVT_COMMAND_TREE_DELETE_ITEM, m_owner->GetId() ); - event.SetItem((long) item); + event.SetItem((void*)item); event.SetEventObject( /*this*/m_owner ); m_owner->ProcessEvent( event ); } @@ -2652,7 +2646,7 @@ void wxTreeListMainWindow::Expand(const wxTreeItemId& itemId) return; wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_EXPANDING, m_owner->GetId() ); - event.SetItem( (long) item ); + event.SetItem( (void*)item ); event.SetEventObject( /*this*/m_owner ); if ( m_owner->ProcessEvent( event ) && !event.IsAllowed() ) @@ -2698,7 +2692,7 @@ void wxTreeListMainWindow::Collapse(const wxTreeItemId& itemId) return; wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_COLLAPSING, m_owner->GetId() ); - event.SetItem( (long) item ); + event.SetItem( (void*)item ); event.SetEventObject( /*this*/m_owner ); if ( m_owner->ProcessEvent( event ) && !event.IsAllowed() ) { @@ -2876,8 +2870,8 @@ void wxTreeListMainWindow::SelectItem(const wxTreeItemId& itemId, } wxTreeEvent event( wxEVT_COMMAND_TREE_SEL_CHANGING, m_owner->GetId() ); - event.SetItem( (long) item ); - event.SetOldItem( (long) m_current ); + event.SetItem( (void*)item ); + event.SetOldItem( (void*)m_current ); event.SetEventObject( /*this*/m_owner ); // TODO : Here we don't send any selection mode yet ! @@ -2936,7 +2930,7 @@ void wxTreeListMainWindow::SelectAll(bool extended_select) wxTreeEvent event( wxEVT_COMMAND_TREE_SEL_CHANGING, m_owner->GetId() ); event.SetItem( GetRootItem() ); - event.SetOldItem( (long) m_current ); + event.SetOldItem( (void*) m_current ); event.SetEventObject( /*this*/m_owner ); // TODO : Here we don't send any selection mode yet ! @@ -3455,8 +3449,8 @@ void wxTreeListMainWindow::PaintLevel (wxTreeListItem *item, wxDC &dc, int total_width = m_owner->GetHeaderWindow()->GetWidth(); // if the background colour is white, choose a // contrasting color for the lines - dc.SetPen (*((GetBackgroundColour() == *wxWHITE)? - wxMEDIUM_GREY_PEN : wxWHITE_PEN)); + dc.SetPen(((GetBackgroundColour() == *wxWHITE) ? + wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT) : *wxWHITE_PEN)); dc.DrawLine(0, y_top, total_width, y_top); dc.DrawLine(0, y, total_width, y); } @@ -3801,7 +3795,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event ) { wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, m_owner->GetId() ); - event.SetItem( (long) m_current); + event.SetItem( (void*) m_current); event.SetEventObject( /*this*/m_owner ); m_owner->GetEventHandler()->ProcessEvent( event ); } @@ -4072,7 +4066,7 @@ void wxTreeListMainWindow::Edit( const wxTreeItemId& item ) m_currentEdit = (wxTreeListItem*) item.m_pItem; wxTreeEvent te( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, m_owner->GetId() ); - te.SetItem( (long) m_currentEdit); + te.SetItem( (void*) m_currentEdit); te.SetEventObject( /*this*/m_owner ); m_owner->GetEventHandler()->ProcessEvent( te ); @@ -4113,7 +4107,7 @@ void wxTreeListMainWindow::OnRenameAccept() { // TODO if the validator fails this causes a crash wxTreeEvent le( wxEVT_COMMAND_TREE_END_LABEL_EDIT, m_owner->GetId() ); - le.SetItem( (long) m_currentEdit ); + le.SetItem( (void*)m_currentEdit ); le.SetEventObject( /*this*/m_owner ); le.SetLabel( m_renameRes ); m_owner->GetEventHandler()->ProcessEvent( le ); @@ -4133,6 +4127,9 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) int flags = 0; wxTreeListItem *item = m_anchor->HitTest(pt, this, flags, 0); wxTreeListItem *underMouse = item; +#if wxUSE_TOOLTIPS + bool underMouseChanged = (underMouse != m_underMouse) ; +#endif // wxUSE_TOOLTIPS if (underMouse && (flags & wxTREE_HITTEST_ONITEMBUTTON) && !event.LeftIsDown() && !m_isDragging && @@ -4159,6 +4156,25 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) RefreshLine( m_underMouse ); } +#if wxUSE_TOOLTIPS + // Determines what item we are hovering over and need a tooltip for + wxTreeItemId hoverItem = item; + + // We do not want a tooltip if we are dragging, or if the rename timer is running + if (underMouseChanged && hoverItem.IsOk() && !m_isDragging && (!m_renameTimer || !m_renameTimer->IsRunning())) + { + // Ask the tree control what tooltip (if any) should be shown + wxTreeEvent hevent(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, GetId()); + hevent.SetItem(hoverItem); + hevent.SetEventObject(this); + + if ( GetEventHandler()->ProcessEvent(hevent) && hevent.IsAllowed() ) + { + SetToolTip(hevent.GetLabel()); + } + } +#endif + // we process left mouse up event (enables in-place edit), right down // (pass to the user code), left dbl click (activate item) and // dragging/moving events for items drag-and-drop @@ -4201,8 +4217,9 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) : wxEVT_COMMAND_TREE_BEGIN_DRAG; wxTreeEvent nevent( command,/*ALB*/ m_owner->GetId() ); - nevent.SetItem( (long) m_current); + nevent.SetItem( (void*)m_current); nevent.SetEventObject(/*this*/m_owner); // ALB + nevent.SetPoint(pt); // by default the dragging is not supported, the user code must // explicitly allow the event for it to take place @@ -4263,7 +4280,7 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) // generate the drag end event wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG,/*ALB*/m_owner->GetId()); - event.SetItem( (long) item ); + event.SetItem( (void*)item ); event.SetPoint( wxPoint(x, y) ); event.SetEventObject(/*this*/m_owner); @@ -4291,7 +4308,7 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) SetFocus(); wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, m_owner->GetId()); - nevent.SetItem( (long) item ); + nevent.SetItem( (void*)item ); int nx, ny; CalcScrolledPosition(x, y, &nx, &ny); nevent.SetPoint( wxPoint(nx, ny)); @@ -4358,7 +4375,7 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) // send activate event first wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, m_owner->GetId() ); - nevent.SetItem( (long) item ); + nevent.SetItem( (void*)item ); int nx, ny; CalcScrolledPosition(x, y, &nx, &ny); nevent.SetPoint( wxPoint(nx, ny) ); @@ -4606,10 +4623,11 @@ void wxTreeListMainWindow::SetFocus() // wxTreeListCtrl //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTreeListCtrl, wxControl); +IMPLEMENT_DYNAMIC_CLASS(wxTreeListCtrl, wxControl) BEGIN_EVENT_TABLE(wxTreeListCtrl, wxControl) EVT_SIZE(wxTreeListCtrl::OnSize) + EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, wxTreeListCtrl::OnGetToolTip) END_EVENT_TABLE(); bool wxTreeListCtrl::Create(wxWindow *parent, wxWindowID id, @@ -5088,3 +5106,11 @@ wxSize wxTreeListCtrl::DoGetBestSize() const // something is better than nothing... return wxSize(100,80); } + +// Process the tooltip event, to speed up event processing. +// Doesn't actually get a tooltip. +void wxTreeListCtrl::OnGetToolTip( wxTreeEvent &event ) +{ + event.Veto(); +} +