add the possibility to cancel drag-resizing by pressing Esc
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -65,6 +65,7 @@ private:
|
|||||||
// event handlers
|
// event handlers
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
void OnMouse(wxMouseEvent& event);
|
void OnMouse(wxMouseEvent& event);
|
||||||
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
void OnCaptureLost(wxMouseCaptureLostEvent& event);
|
void OnCaptureLost(wxMouseCaptureLostEvent& event);
|
||||||
|
|
||||||
// return the horizontal start position of the given column in physical
|
// return the horizontal start position of the given column in physical
|
||||||
@@ -87,6 +88,9 @@ private:
|
|||||||
// column 1 but close enough to the divider separating it from column 0)
|
// column 1 but close enough to the divider separating it from column 0)
|
||||||
int FindColumnAtPos(int x, bool& onSeparator) const;
|
int FindColumnAtPos(int x, bool& onSeparator) const;
|
||||||
|
|
||||||
|
// return true if a drag resizing operation is currently in progress
|
||||||
|
bool IsResizing() const;
|
||||||
|
|
||||||
// end any drag operation currently in progress (resizing or reordering)
|
// end any drag operation currently in progress (resizing or reordering)
|
||||||
void EndDragging();
|
void EndDragging();
|
||||||
|
|
||||||
|
@@ -214,6 +214,11 @@ void wxHeaderCtrl::RefreshColsAfter(unsigned int idx)
|
|||||||
// wxHeaderCtrl dragging
|
// wxHeaderCtrl dragging
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxHeaderCtrl::IsResizing() const
|
||||||
|
{
|
||||||
|
return m_colBeingResized != COL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void wxHeaderCtrl::UpdateResizingMarker(int xPhysical)
|
void wxHeaderCtrl::UpdateResizingMarker(int xPhysical)
|
||||||
{
|
{
|
||||||
// unfortunately drawing the marker over the parent window doesn't work as
|
// unfortunately drawing the marker over the parent window doesn't work as
|
||||||
@@ -244,8 +249,7 @@ void wxHeaderCtrl::EndDragging()
|
|||||||
|
|
||||||
void wxHeaderCtrl::EndResizing(int width)
|
void wxHeaderCtrl::EndResizing(int width)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_colBeingResized != COL_NONE,
|
wxASSERT_MSG( IsResizing(), "shouldn't be called if we're not resizing" );
|
||||||
"shouldn't be called if we're not resizing" );
|
|
||||||
|
|
||||||
EndDragging();
|
EndDragging();
|
||||||
|
|
||||||
@@ -277,6 +281,8 @@ BEGIN_EVENT_TABLE(wxHeaderCtrl, wxHeaderCtrlBase)
|
|||||||
EVT_MOUSE_EVENTS(wxHeaderCtrl::OnMouse)
|
EVT_MOUSE_EVENTS(wxHeaderCtrl::OnMouse)
|
||||||
|
|
||||||
EVT_MOUSE_CAPTURE_LOST(wxHeaderCtrl::OnCaptureLost)
|
EVT_MOUSE_CAPTURE_LOST(wxHeaderCtrl::OnCaptureLost)
|
||||||
|
|
||||||
|
EVT_KEY_DOWN(wxHeaderCtrl::OnKeyDown)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
@@ -345,10 +351,23 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void wxHeaderCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
|
void wxHeaderCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if ( m_colBeingResized != COL_NONE )
|
if ( IsResizing() )
|
||||||
EndResizing(-1);
|
EndResizing(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxHeaderCtrl::OnKeyDown(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
if ( IsResizing() && event.GetKeyCode() == WXK_ESCAPE )
|
||||||
|
{
|
||||||
|
ReleaseMouse();
|
||||||
|
EndResizing(-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
|
void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
|
||||||
{
|
{
|
||||||
// do this in advance to allow simply returning if we're not interested,
|
// do this in advance to allow simply returning if we're not interested,
|
||||||
@@ -362,7 +381,7 @@ void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
|
|||||||
|
|
||||||
// first deal with the [continuation of any] dragging operations in
|
// first deal with the [continuation of any] dragging operations in
|
||||||
// progress
|
// progress
|
||||||
if ( m_colBeingResized != COL_NONE )
|
if ( IsResizing() )
|
||||||
{
|
{
|
||||||
if ( mevent.LeftUp() )
|
if ( mevent.LeftUp() )
|
||||||
EndResizing(xPhysical - GetColStart(m_colBeingResized));
|
EndResizing(xPhysical - GetColStart(m_colBeingResized));
|
||||||
|
Reference in New Issue
Block a user