diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 7a34b8f4f1..6f2bff9894 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1591,11 +1591,12 @@ protected: // 0 = not dragging, 1 = drag just started, 2 = drag in progress unsigned char m_dragStatus; +#if WXWIN_COMPATIBILITY_3_0 + // Unused variable. // 0 = margin, 1 = label, 2 = value. unsigned char m_mouseSide; // True when editor control is focused. -#if WXWIN_COMPATIBILITY_3_0 unsigned char m_editorFocused; #else bool m_editorFocused; @@ -1634,8 +1635,8 @@ protected: int m_clearThisMany; #endif - // Mouse is hovering over this column (index) - unsigned int m_colHover; + // Mouse is hovering over this column (index), -1 for margin + int m_colHover; // pointer to property that has mouse hovering wxPGProperty* m_propHover; diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 61302cc2bc..87bc222a8b 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -355,7 +355,6 @@ void wxPropertyGrid::Init1() m_inOnValidationFailure = false; m_permanentValidationFailureBehavior = wxPG_VFB_DEFAULT; m_dragStatus = 0; - m_mouseSide = 16; m_editorFocused = false; // Set up default unspecified value 'colour' @@ -5003,6 +5002,10 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, int splitterHitOffset; int columnHit = state->HitTestH( x, &splitterHit, &splitterHitOffset ); + #if wxUSE_TOOLTIPS + wxPGProperty* prevHover = m_propHover; + int prevCol = m_colHover; + #endif m_colHover = columnHit; if ( m_dragStatus > 0 ) @@ -5042,10 +5045,6 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, int ih = m_lineHeight; int sy = y; - #if wxUSE_TOOLTIPS - wxPGProperty* prevHover = m_propHover; - unsigned char prevSide = m_mouseSide; - #endif int curPropHoverY = y - (y % ih); // On which item it hovers @@ -5064,20 +5063,13 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, } #if wxUSE_TOOLTIPS - // Store which side we are on - m_mouseSide = 0; - if ( columnHit == 1 ) - m_mouseSide = 2; - else if ( columnHit == 0 ) - m_mouseSide = 1; - // // If tooltips are enabled, show label or value as a tip // in case it doesn't otherwise show in full length. // if ( m_windowStyle & wxPG_TOOLTIPS ) { - if ( m_propHover != prevHover || prevSide != m_mouseSide ) + if ( m_propHover != prevHover || prevCol != m_colHover ) { if ( m_propHover && !m_propHover->IsCategory() ) { @@ -5089,43 +5081,35 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, SetToolTip(tipString); } - else + else if ( m_colHover >= 0 && m_colHover < (int)m_pState->GetColumnCount()) { // Show cropped value string as a tooltip wxString tipString; - int space = 0; + m_propHover->GetDisplayInfo(m_colHover, -1, 0, &tipString, (wxPGCell*)NULL); + int space = m_pState->GetColumnWidth(m_colHover); - if ( m_mouseSide == 1 ) + if ( m_colHover == 0 ) { - tipString = m_propHover->GetLabel(); - space = m_pState->GetColumnWidth(0); if ( !(m_windowStyle & wxPG_HIDE_CATEGORIES) || m_propHover->GetParent() != m_pState->DoGetRoot() ) space -= (m_propHover->GetDepth()-1)*m_subgroup_extramargin; } - else if ( m_mouseSide == 2 ) + else if ( m_colHover == 1 ) { - tipString = m_propHover->GetDisplayedString(); - - space = m_pState->GetColumnWidth(1); if ( m_propHover->HasFlag(wxPG_PROP_CUSTOMIMAGE) ) space -= wxPG_CUSTOM_IMAGE_WIDTH + wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2; } - if ( space ) - { - space -= (wxPG_XBEFORETEXT + 1); - int tw, th; - GetTextExtent( tipString, &tw, &th, 0, 0 ); - if ( tw > space ) - SetToolTip( tipString ); - } - else - { - SetToolTip(wxEmptyString); - } - + space -= (wxPG_XBEFORETEXT + 1); + int tw, th; + GetTextExtent( tipString, &tw, &th, 0, 0 ); + if ( tw > space ) + SetToolTip( tipString ); + } + else + { + SetToolTip(wxEmptyString); } } else