X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5e184c6ff77339d861cc34826f2454ec816881c..cc26010927f5bb12825a32487949d063e6c605fc:/src/propgrid/propgrid.cpp diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 85da101b67..9a9da1c396 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -115,6 +115,11 @@ //#define wxPG_TOOLTIP_DELAY 1000 +// This is the number of pixels the expander button inside +// property cells (i.e. not in the grey margin area are +// adjusted. +#define IN_CELL_EXPANDER_BUTTON_X_ADJUST 2 + // ----------------------------------------------------------------------- #if wxUSE_INTL @@ -406,7 +411,7 @@ void wxPropertyGrid::Init2() } if ( !(m_windowStyle & wxPG_SPLITTER_AUTO_CENTER) ) - m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER; + m_pState->m_dontCenterSplitter = true; if ( m_windowStyle & wxPG_HIDE_CATEGORIES ) { @@ -662,7 +667,7 @@ void wxPropertyGrid::Thaw() // Force property re-selection // NB: We must copy the selection. wxArrayPGProperty selection = m_pState->m_selection; - DoSetSelection(selection, wxPG_SEL_FORCE); + DoSetSelection(selection, wxPG_SEL_FORCE | wxPG_SEL_NONVISIBLE); } } @@ -1740,9 +1745,8 @@ void wxPropertyGrid::OnPaint( wxPaintEvent& WXUNUSED(event) ) // FIXME: This is just a workaround for a bug that causes splitters not // to paint when other windows are being dragged over the grid. - wxRect fullRect = GetRect(); - r.x = fullRect.x; - r.width = fullRect.width; + r.x = 0; + r.width = GetClientSize().x; // Repaint this rectangle DrawItems( dc, r.y, r.y + r.height, &r ); @@ -1982,13 +1986,13 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, long windowStyle = m_windowStyle; int xRelMod = 0; - int yRelMod = 0; // // With wxPG_DOUBLE_BUFFER, do double buffering // - buffer's y = 0, so align drawRect and coordinates to that // #if wxPG_DOUBLE_BUFFER + int yRelMod = 0; wxRect cr2; @@ -2272,6 +2276,10 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, } else { + // Fine tune button rectangle to actually fit the cell + if ( butRect.x > 0 ) + butRect.x += IN_CELL_EXPANDER_BUTTON_X_ADJUST; + if ( p->m_flags & wxPG_PROP_MODIFIED && (windowStyle & wxPG_BOLD_MODIFIED) ) { dc.SetFont(m_captionFont); @@ -2634,10 +2642,11 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState ) { // // Just in case, fully re-center splitter - if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) ) - pNewState->m_fSplitterX = -1.0; + //if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) ) + // pNewState->m_fSplitterX = -1.0; - pNewState->OnClientWidthChange( pgWidth, pgWidth - pNewState->m_width ); + pNewState->OnClientWidthChange(pgWidth, + pgWidth - pNewState->m_width); } m_propHover = NULL; @@ -2668,7 +2677,9 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState ) // Call to SetSplitterPosition will always disable splitter auto-centering // if parent window is shown. -void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, int splitterIndex, bool allPages ) +void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, + int splitterIndex, + bool allPages ) { if ( ( newxpos < wxPG_DRAG_MARGIN ) ) return; @@ -2690,9 +2701,9 @@ void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, int spli void wxPropertyGrid::CenterSplitter( bool enableAutoCentering ) { - SetSplitterPosition( m_width/2, true ); - if ( enableAutoCentering && ( m_windowStyle & wxPG_SPLITTER_AUTO_CENTER ) ) - m_iFlags &= ~(wxPG_FL_DONT_CENTER_SPLITTER); + SetSplitterPosition( m_width/2 ); + if ( enableAutoCentering && HasFlag(wxPG_SPLITTER_AUTO_CENTER) ) + m_pState->m_dontCenterSplitter = false; } // ----------------------------------------------------------------------- @@ -3267,6 +3278,12 @@ bool wxPropertyGrid::DoEditorValidate() void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event ) { + // It is possible that this handler receives event even before + // the control has been properly initialized. Let's skip the + // event handling in that case. + if ( !m_pState ) + return; + wxPGProperty* selected = GetSelection(); // Somehow, event is handled after property has been deselected. @@ -4087,8 +4104,8 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents ) } // Store dont-center-splitter flag 'cause we need to temporarily set it - wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER; - m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER; + bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter; + m_pState->m_dontCenterSplitter = true; bool res = m_pState->DoCollapse(pwc); @@ -4101,8 +4118,7 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents ) Refresh(); } - // Clear dont-center-splitter flag if it wasn't set - m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag; + m_pState->m_dontCenterSplitter = prevDontCenterSplitter; return res; } @@ -4116,8 +4132,8 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents ) wxPGProperty* pwc = (wxPGProperty*)p; // Store dont-center-splitter flag 'cause we need to temporarily set it - wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER; - m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER; + bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter; + m_pState->m_dontCenterSplitter = true; bool res = m_pState->DoExpand(pwc); @@ -4130,8 +4146,7 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents ) Refresh(); } - // Clear dont-center-splitter flag if it wasn't set - m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag; + m_pState->m_dontCenterSplitter = prevDontCenterSplitter; return res; } @@ -4171,7 +4186,9 @@ bool wxPropertyGrid::DoHideProperty( wxPGProperty* p, bool hide, int flags ) void wxPropertyGrid::RecalculateVirtualSize( int forceXPos ) { - if ( (m_iFlags & wxPG_FL_RECALCULATING_VIRTUAL_SIZE) || m_frozen ) + if ( (m_iFlags & wxPG_FL_RECALCULATING_VIRTUAL_SIZE) || + m_frozen || + !m_pState ) return; // @@ -4505,6 +4522,10 @@ bool wxPropertyGrid::HandleMouseClick( int x, unsigned int y, wxMouseEvent &even { int nx = x + m_marginWidth - marginEnds; // Normalize x. + // Fine tune cell button x + if ( !p->IsCategory() ) + nx -= IN_CELL_EXPANDER_BUTTON_X_ADJUST; + if ( (nx >= m_gutterWidth && nx < (m_gutterWidth+m_iconWidth)) ) { int y2 = y % m_lineHeight; @@ -4620,7 +4641,7 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, if ( newSplitterX != splitterX ) { // Move everything - SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER); + state->m_dontCenterSplitter = true; state->DoSetSplitterPosition(newSplitterX, m_draggedSplitter, false); @@ -4849,7 +4870,7 @@ bool wxPropertyGrid::HandleMouseUp( int x, unsigned int WXUNUSED(y), //splitterX = x; // Disable splitter auto-centering - m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER; + state->m_dontCenterSplitter = true; // This is necessary to return cursor if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )