respect Veto()ing the column resize events; added test for this in the sample

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-03-17 13:24:45 +00:00
parent 6d89ddefa9
commit 355f240724
2 changed files with 23 additions and 13 deletions

View File

@@ -672,6 +672,13 @@ void MyListCtrl::LogColEvent(const wxListEvent& event, const wxChar *name)
void MyListCtrl::OnColBeginDrag(wxListEvent& event) void MyListCtrl::OnColBeginDrag(wxListEvent& event)
{ {
LogColEvent( event, wxT("OnColBeginDrag") ); LogColEvent( event, wxT("OnColBeginDrag") );
if ( event.GetColumn() == 0 )
{
wxLogMessage(_T("Resizing this column shouldn't work."));
event.Veto();
}
} }
void MyListCtrl::OnColDragging(wxListEvent& event) void MyListCtrl::OnColDragging(wxListEvent& event)

View File

@@ -495,7 +495,9 @@ private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
void SendListEvent(wxEventType type, wxPoint pos); // generate and process the list event of the given type, return true if
// it wasn't vetoed, i.e. if we should proceed
bool SendListEvent(wxEventType type, wxPoint pos);
DECLARE_DYNAMIC_CLASS(wxListHeaderWindow) DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@@ -2130,8 +2132,7 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
if (m_isDragging) if (m_isDragging)
{ {
SendListEvent(wxEVT_COMMAND_LIST_COL_DRAGGING, SendListEvent(wxEVT_COMMAND_LIST_COL_DRAGGING, event.GetPosition());
event.GetPosition());
// we don't draw the line beyond our window, but we allow dragging it // we don't draw the line beyond our window, but we allow dragging it
// there // there
@@ -2150,8 +2151,7 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
m_isDragging = FALSE; m_isDragging = FALSE;
m_dirty = TRUE; m_dirty = TRUE;
m_owner->SetColumnWidth( m_column, m_currentX - m_minX ); m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
SendListEvent(wxEVT_COMMAND_LIST_COL_END_DRAG, SendListEvent(wxEVT_COMMAND_LIST_COL_END_DRAG, event.GetPosition());
event.GetPosition());
} }
else else
{ {
@@ -2204,12 +2204,15 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
{ {
if (hit_border && event.LeftDown()) if (hit_border && event.LeftDown())
{ {
m_isDragging = TRUE; if ( SendListEvent(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG,
m_currentX = x; event.GetPosition()) )
DrawCurrent(); {
CaptureMouse(); m_isDragging = TRUE;
SendListEvent(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, m_currentX = x;
event.GetPosition()); DrawCurrent();
CaptureMouse();
}
//else: column resizing was vetoed by the user code
} }
else // click on a column else // click on a column
{ {
@@ -2244,7 +2247,7 @@ void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
m_owner->SetFocus(); m_owner->SetFocus();
} }
void wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos) bool wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos)
{ {
wxWindow *parent = GetParent(); wxWindow *parent = GetParent();
wxListEvent le( type, parent->GetId() ); wxListEvent le( type, parent->GetId() );
@@ -2258,7 +2261,7 @@ void wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos)
le.m_pointDrag.y -= GetSize().y; le.m_pointDrag.y -= GetSize().y;
le.m_col = m_column; le.m_col = m_column;
parent->GetEventHandler()->ProcessEvent( le ); return !parent->GetEventHandler()->ProcessEvent( le ) || le.IsAllowed();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------