Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
end editing of a property label. You can veto this event to prevent the
action.
+ @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
+ Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user
+ starts resizing a column - can be vetoed.
+ @event{EVT_PG_COL_DRAGGING,(id, func)}
+ Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
+ column resize by user is in progress.
+ @event{EVT_PG_COL_END_DRAG(id, func)}
+ Respond to wxEVT_PG_COL_END_DRAG event, generated after column
+ resize by user has finished.
@endEventTable
@remarks
wxEVT_PG_LABEL_EDIT_BEGIN, wxPropertyGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
wxEVT_PG_LABEL_EDIT_ENDING, wxPropertyGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
+ wxEVT_PG_COL_BEGIN_DRAG, wxPropertyGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
+ wxEVT_PG_COL_DRAGGING, wxPropertyGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
+ wxEVT_PG_COL_END_DRAG, wxPropertyGridEvent );
#else
enum {
wxEVT_PG_ITEM_EXPANDED,
wxEVT_PG_DOUBLE_CLICK,
wxEVT_PG_LABEL_EDIT_BEGIN,
- wxEVT_PG_LABEL_EDIT_ENDING
+ wxEVT_PG_LABEL_EDIT_ENDING,
+ wxEVT_PG_COL_BEGIN_DRAG,
+ wxEVT_PG_COL_DRAGGING,
+ wxEVT_PG_COL_END_DRAG
};
#endif
#define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_LABEL_EDIT_BEGIN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define EVT_PG_LABEL_EDIT_ENDING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_COL_BEGIN_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_BEGIN_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_COL_DRAGGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_DRAGGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_COL_END_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_END_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
#define wxPropertyGridEventHandler(fn) \
wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
/**
Returns the column index associated with this event.
+ For the column dragging events, it is the column to the left
+ of the splitter being dragged
*/
unsigned int GetColumn() const
{
Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
end editing of a property label. You can veto this event to prevent the
action.
+ @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
+ Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user
+ starts resizing a column - can be vetoed.
+ @event{EVT_PG_COL_DRAGGING,(id, func)}
+ Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
+ column resize by user is in progress.
+ @event{EVT_PG_COL_END_DRAG(id, func)}
+ Respond to wxEVT_PG_COL_END_DRAG event, generated after column
+ resize by user has finished.
@endEventTable
@remarks
*/
bool CanVeto() const;
+ /**
+ Returns the column index associated with this event.
+ For the column dragging events, it is the column to the left
+ of the splitter being dragged
+ */
+ unsigned int GetColumn() const;
+
/**
Returns highest level non-category, non-root parent of property for
which event occurred. Useful when you have nested properties with
ID_SAVESTATE,
ID_RESTORESTATE,
ID_RUNMINIMAL,
- ID_ENABLELABELEDITING
+ ID_ENABLELABELEDITING,
+ ID_VETOCOLDRAG
};
// -----------------------------------------------------------------------
EVT_PG_ITEM_COLLAPSED( PGID, FormMain::OnPropertyGridItemCollapse )
EVT_PG_ITEM_EXPANDED( PGID, FormMain::OnPropertyGridItemExpand )
+ EVT_PG_COL_BEGIN_DRAG( PGID, FormMain::OnPropertyGridColBeginDrag )
+ EVT_PG_COL_DRAGGING( PGID, FormMain::OnPropertyGridColDragging )
+ EVT_PG_COL_END_DRAG( PGID, FormMain::OnPropertyGridColEndDrag )
+
EVT_TEXT( PGID, FormMain::OnPropertyGridTextUpdate )
//
// -----------------------------------------------------------------------
+void FormMain::OnPropertyGridColBeginDrag( wxPropertyGridEvent& event )
+{
+ if ( m_itemVetoDragging->IsChecked() )
+ {
+ wxLogDebug("Splitter %i resize was vetoed", event.GetColumn());
+ event.Veto();
+ }
+ else
+ {
+ wxLogDebug("Splitter %i resize began", event.GetColumn());
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void FormMain::OnPropertyGridColDragging( wxPropertyGridEvent& event )
+{
+ // For now, let's not spam the log output
+ //wxLogDebug("Splitter %i is being resized", event.GetColumn());
+}
+
+// -----------------------------------------------------------------------
+
+void FormMain::OnPropertyGridColEndDrag( wxPropertyGridEvent& event )
+{
+ wxLogDebug("Splitter %i resize ended", event.GetColumn());
+}
+
+// -----------------------------------------------------------------------
+
// EVT_TEXT handling
void FormMain::OnPropertyGridTextUpdate( wxCommandEvent& event )
{
menuTools2->Append(ID_REMOVEPAGE, wxT("Remove Page") );
menuTools2->AppendSeparator();
menuTools2->Append(ID_FITCOLUMNS, wxT("Fit Columns") );
+ m_itemVetoDragging =
+ menuTools2->AppendCheckItem(ID_VETOCOLDRAG,
+ "Veto Column Dragging");
menuTools2->AppendSeparator();
menuTools2->Append(ID_CHANGEFLAGSITEMS, wxT("Change Children of FlagsProp") );
menuTools2->AppendSeparator();
wxMenuItem* m_itemCatColours;
wxMenuItem* m_itemFreeze;
wxMenuItem* m_itemEnable;
+ wxMenuItem* m_itemVetoDragging;
wxVariant m_storedValues;
void OnPropertyGridItemExpand( wxPropertyGridEvent& event );
void OnPropertyGridLabelEditBegin( wxPropertyGridEvent& event );
void OnPropertyGridLabelEditEnding( wxPropertyGridEvent& event );
+ void OnPropertyGridColBeginDrag( wxPropertyGridEvent& event );
+ void OnPropertyGridColDragging( wxPropertyGridEvent& event );
+ void OnPropertyGridColEndDrag( wxPropertyGridEvent& event );
void OnAbout( wxCommandEvent& event );
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);
// 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;
+ }
}
}
}
Update();
Refresh();
+
+ 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 );
// -----------------------------------------------------------------------