//#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
wxMouseEvent* mouseEvent,
int selFlags )
{
+ const wxArrayPGProperty& selection = GetSelectedProperties();
bool alreadySelected = m_pState->DoIsPropertySelected(prop);
bool res = true;
- bool addToExistingSelection;
+
+ // Set to 2 if also add all items in between
+ int addToExistingSelection = 0;
if ( GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION )
{
}
else
{
- addToExistingSelection = mouseEvent->ShiftDown();
+ if ( mouseEvent->ControlDown() )
+ {
+ addToExistingSelection = 1;
+ }
+ else if ( mouseEvent->ShiftDown() )
+ {
+ if ( selection.size() > 0 && !prop->IsCategory() )
+ addToExistingSelection = 2;
+ else
+ addToExistingSelection = 1;
+ }
}
}
- else
- {
- addToExistingSelection = false;
- }
- }
- else
- {
- addToExistingSelection = false;
}
- if ( addToExistingSelection )
+ if ( addToExistingSelection == 1 )
{
+ // Add/remove one
if ( !alreadySelected )
{
res = DoAddToSelection(prop, selFlags);
res = DoRemoveFromSelection(prop, selFlags);
}
}
+ else if ( addToExistingSelection == 2 )
+ {
+ // Add this, and all in between
+
+ // Find top selected property
+ wxPGProperty* topSelProp = selection[0];
+ int topSelPropY = topSelProp->GetY();
+ for ( unsigned int i=1; i<selection.size(); i++ )
+ {
+ wxPGProperty* p = selection[i];
+ int y = p->GetY();
+ if ( y < topSelPropY )
+ {
+ topSelProp = p;
+ topSelPropY = y;
+ }
+ }
+
+ wxPGProperty* startFrom;
+ wxPGProperty* stopAt;
+
+ if ( prop->GetY() <= topSelPropY )
+ {
+ // Property is above selection (or same)
+ startFrom = prop;
+ stopAt = topSelProp;
+ }
+ else
+ {
+ // Property is below selection
+ startFrom = topSelProp;
+ stopAt = prop;
+ }
+
+ // Iterate through properties in-between, and select them
+ wxPropertyGridIterator it;
+
+ for ( it = GetIterator(wxPG_ITERATE_VISIBLE, startFrom);
+ !it.AtEnd();
+ it++ )
+ {
+ wxPGProperty* p = *it;
+
+ if ( !p->IsCategory() &&
+ !m_pState->DoIsPropertySelected(p) )
+ {
+ DoAddToSelection(p, selFlags);
+ }
+
+ if ( p == stopAt )
+ break;
+ }
+ }
else
{
res = DoSelectAndEdit(prop, colIndex, selFlags);
// 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 );
}
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);
// 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,
+ int splitterIndex,
+ int flags )
{
if ( ( newxpos < wxPG_DRAG_MARGIN ) )
return;
wxPropertyGridPageState* state = m_pState;
- state->DoSetSplitterPosition( newxpos, splitterIndex, allPages );
+ if ( flags & wxPG_SPLITTER_FROM_EVENT )
+ state->m_dontCenterSplitter = true;
+
+ state->DoSetSplitterPosition(newxpos, splitterIndex, flags);
- if ( refresh )
+ if ( flags & wxPG_SPLITTER_REFRESH )
{
if ( GetSelection() )
CorrectEditorWidgetSizeX();
Refresh();
}
+
+ return;
}
// -----------------------------------------------------------------------
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.
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;
//
unsigned int selFlags,
unsigned int column )
{
+ // selFlags should have wxPG_SEL_NOVALIDATE if event is not
+ // vetoable.
+
// Send property grid event of specific type and with specific property
wxPropertyGridEvent evt( eventType, m_eventObject->GetId() );
evt.SetPropertyGrid(this);
if ( event.GetEventType() == wxEVT_LEFT_DCLICK )
{
// Double-clicking the splitter causes auto-centering
- CenterSplitter( true );
+ if ( m_pState->GetColumnCount() <= 2 )
+ {
+ CenterSplitter( true );
+
+ SendEvent(wxEVT_PG_COL_DRAGGING,
+ m_propHover,
+ NULL,
+ wxPG_SEL_NOVALIDATE,
+ (unsigned int)m_draggedSplitter);
+ }
}
else if ( m_dragStatus == 0 )
{
// send event
DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE);
- if ( m_wndEditor )
+ // Allow application to veto dragging
+ if ( !SendEvent(wxEVT_PG_COL_BEGIN_DRAG,
+ p, NULL, 0,
+ (unsigned int)splitterHit) )
{
- // Changes must be committed here or the
- // value won't be drawn correctly
- if ( !CommitChangesFromEditor() )
- return res;
+ if ( m_wndEditor )
+ {
+ // Changes must be committed here or the
+ // value won't be drawn correctly
+ if ( !CommitChangesFromEditor() )
+ return res;
- m_wndEditor->Show ( false );
- }
+ m_wndEditor->Show ( false );
+ }
- if ( !(m_iFlags & wxPG_FL_MOUSE_CAPTURED) )
- {
- CaptureMouse();
- m_iFlags |= wxPG_FL_MOUSE_CAPTURED;
- }
+ if ( !(m_iFlags & wxPG_FL_MOUSE_CAPTURED) )
+ {
+ CaptureMouse();
+ m_iFlags |= wxPG_FL_MOUSE_CAPTURED;
+ }
- m_dragStatus = 1;
- m_draggedSplitter = splitterHit;
- m_dragOffset = splitterHitOffset;
+ m_dragStatus = 1;
+ m_draggedSplitter = splitterHit;
+ m_dragOffset = splitterHitOffset;
- #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
- // Fixes button disappearance bug
- if ( m_wndEditor2 )
- m_wndEditor2->Show ( false );
- #endif
+ #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
+ // Fixes button disappearance bug
+ if ( m_wndEditor2 )
+ m_wndEditor2->Show ( false );
+ #endif
- m_startingSplitterX = x - splitterHitOffset;
+ m_startingSplitterX = x - splitterHitOffset;
+ }
}
}
}
{
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;
if ( newSplitterX != splitterX )
{
// Move everything
- state->m_dontCenterSplitter = true;
- state->DoSetSplitterPosition(newSplitterX,
- m_draggedSplitter,
- false);
- state->m_fSplitterX = (float) newSplitterX;
-
- if ( GetSelection() )
- CorrectEditorWidgetSizeX();
-
- Update();
- Refresh();
+ DoSetSplitterPosition(newSplitterX,
+ m_draggedSplitter,
+ wxPG_SPLITTER_REFRESH |
+ wxPG_SPLITTER_FROM_EVENT);
+
+ SendEvent(wxEVT_PG_COL_DRAGGING,
+ m_propHover,
+ NULL,
+ wxPG_SEL_NOVALIDATE,
+ (unsigned int)m_draggedSplitter);
}
m_dragStatus = 2;
// (it is only here as a reminder to not to do it)
//splitterX = x;
+ SendEvent(wxEVT_PG_COL_END_DRAG,
+ m_propHover,
+ NULL,
+ wxPG_SEL_NOVALIDATE,
+ (unsigned int)m_draggedSplitter);
+
// Disable splitter auto-centering
state->m_dontCenterSplitter = true;
wxDEFINE_EVENT( wxEVT_PG_DOUBLE_CLICK, wxPropertyGridEvent );
wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_BEGIN, wxPropertyGridEvent );
wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_ENDING, wxPropertyGridEvent );
+wxDEFINE_EVENT( wxEVT_PG_COL_BEGIN_DRAG, wxPropertyGridEvent );
+wxDEFINE_EVENT( wxEVT_PG_COL_DRAGGING, wxPropertyGridEvent );
+wxDEFINE_EVENT( wxEVT_PG_COL_END_DRAG, wxPropertyGridEvent );
// -----------------------------------------------------------------------