X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e778b8f059449d473052463ccad26cd32f19a7d2..3103e8a97e834e9793f0eb149aa82a99fd64ef9a:/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp?ds=sidebyside diff --git a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp index 1c0f6066e1..cb83cda0e6 100644 --- a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp +++ b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "wx/treelistctrl.h" @@ -1112,7 +1113,7 @@ wxTreeListHeaderWindow::wxTreeListHeaderWindow( wxWindow *win, m_owner = owner; m_resizeCursor = new wxCursor(wxCURSOR_SIZEWE); - SetBackgroundColour(wxSystemSettings::GetSystemColour( + SetBackgroundColour(wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE)); } @@ -1138,7 +1139,7 @@ void wxTreeListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h ) dc->SetBrush( *wxTRANSPARENT_BRUSH ); - dc->SetPen( wxPen(wxSystemSettings::GetSystemColour( + dc->SetPen( wxPen(wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID)); dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer) dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer) @@ -1163,7 +1164,7 @@ void wxTreeListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h ) dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer) dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer) - wxPen pen(wxSystemSettings::GetSystemColour( + wxPen pen(wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID); dc->SetPen( pen ); @@ -1227,7 +1228,7 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) // function to set it separately //dc.SetTextForeground( *wxBLACK ); dc.SetTextForeground(wxSystemSettings:: - GetSystemColour( wxSYS_COLOUR_WINDOWTEXT )); + GetColour( wxSYS_COLOUR_WINDOWTEXT )); int x = HEADER_OFFSET_X; @@ -1858,7 +1859,7 @@ void wxTreeListMainWindow::Init() m_hilightBrush = new wxBrush ( - wxSystemSettings::GetSystemColour + wxSystemSettings::GetColour ( wxSYS_COLOUR_HIGHLIGHT ), @@ -1867,7 +1868,7 @@ void wxTreeListMainWindow::Init() m_hilightUnfocusedBrush = new wxBrush ( - wxSystemSettings::GetSystemColour + wxSystemSettings::GetColour ( wxSYS_COLOUR_BTNSHADOW ), @@ -1890,7 +1891,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 ); @@ -1935,7 +1936,7 @@ bool wxTreeListMainWindow::Create(wxTreeListCtrl *parent, SetValidator( validator ); #endif - SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) ); + SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) ); #ifdef __WXMSW__ { @@ -3313,7 +3314,7 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc) if (item->IsSelected() && HasFlag(wxTR_FULL_ROW_HIGHLIGHT)) { dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush)); dc.SetPen(*wxBLACK_PEN); - colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT); + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); } else { wxColour colBg; if (attr && attr->HasBackgroundColour()) { @@ -3379,7 +3380,7 @@ void wxTreeListMainWindow::PaintItem(wxTreeListItem *item, wxDC& dc) int width = wxMin(text_w+2, colwidth - text_x - x_colstart); dc.DrawRectangle(text_x-1, item->GetY() + offset, width, total_h-offset); dc.SetBackgroundMode(wxTRANSPARENT); - dc.SetTextForeground(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); + dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); }else{ dc.SetTextForeground(colText); } @@ -4132,6 +4133,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 && @@ -4158,6 +4162,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 @@ -4202,6 +4225,7 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event ) wxTreeEvent nevent( command,/*ALB*/ m_owner->GetId() ); nevent.SetItem( (long) 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 @@ -4609,6 +4633,7 @@ 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, @@ -4652,8 +4677,7 @@ void wxTreeListCtrl::CalculateAndSetHeaderHeight() } } - -void wxTreeListCtrl::OnSize(wxSizeEvent& WXUNUSED(event)) +void wxTreeListCtrl::DoHeaderLayout() { int w, h; GetClientSize(&w, &h); @@ -4664,6 +4688,11 @@ void wxTreeListCtrl::OnSize(wxSizeEvent& WXUNUSED(event)) } if (m_main_win) m_main_win->SetSize(0, m_headerHeight + 1, w, h - m_headerHeight - 1); +} + +void wxTreeListCtrl::OnSize(wxSizeEvent& WXUNUSED(event)) +{ + DoHeaderLayout(); } @@ -5014,7 +5043,10 @@ wxString wxTreeListCtrl::GetColumnText(size_t column) const { return m_header_win->GetColumnText(column); } void wxTreeListCtrl::AddColumn(const wxTreeListColumnInfo& col) -{ m_header_win->AddColumn(col); } +{ + m_header_win->AddColumn(col); + DoHeaderLayout(); +} void wxTreeListCtrl::InsertColumn(size_t before, const wxTreeListColumnInfo& col) @@ -5080,3 +5112,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(); +} +