Added sending of column dragging events to the generic wxListCtrl.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8f69665389
commit
a77ec46ddc
@ -473,6 +473,8 @@ private:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
void SendListEvent(wxEventType type, wxPoint pos);
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
|
DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
@ -626,7 +628,7 @@ public:
|
|||||||
// suspend/resume redrawing the control
|
// suspend/resume redrawing the control
|
||||||
void Freeze();
|
void Freeze();
|
||||||
void Thaw();
|
void Thaw();
|
||||||
|
|
||||||
void SetFocus();
|
void SetFocus();
|
||||||
|
|
||||||
void OnRenameTimer();
|
void OnRenameTimer();
|
||||||
@ -1983,6 +1985,9 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
|
|
||||||
if (m_isDragging)
|
if (m_isDragging)
|
||||||
{
|
{
|
||||||
|
SendListEvent(wxEVT_COMMAND_LIST_COL_DRAGGING,
|
||||||
|
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
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@ -2000,6 +2005,8 @@ 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,
|
||||||
|
event.GetPosition());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2056,25 +2063,15 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
m_currentX = x;
|
m_currentX = x;
|
||||||
DrawCurrent();
|
DrawCurrent();
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
|
SendListEvent(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG,
|
||||||
|
event.GetPosition());
|
||||||
}
|
}
|
||||||
else // click on a column
|
else // click on a column
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
SendListEvent( event.LeftDown()
|
||||||
wxListEvent le( event.LeftDown()
|
|
||||||
? wxEVT_COMMAND_LIST_COL_CLICK
|
? wxEVT_COMMAND_LIST_COL_CLICK
|
||||||
: wxEVT_COMMAND_LIST_COL_RIGHT_CLICK,
|
: wxEVT_COMMAND_LIST_COL_RIGHT_CLICK,
|
||||||
parent->GetId() );
|
event.GetPosition());
|
||||||
le.SetEventObject( parent );
|
|
||||||
le.m_pointDrag = event.GetPosition();
|
|
||||||
|
|
||||||
// the position should be relative to the parent window, not
|
|
||||||
// this one for compatibility with MSW and common sense: the
|
|
||||||
// user code doesn't know anything at all about this header
|
|
||||||
// window, so why should it get positions relative to it?
|
|
||||||
le.m_pointDrag.y -= GetSize().y;
|
|
||||||
|
|
||||||
le.m_col = m_column;
|
|
||||||
parent->GetEventHandler()->ProcessEvent( le );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event.Moving())
|
else if (event.Moving())
|
||||||
@ -2102,6 +2099,23 @@ void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
|
|||||||
m_owner->SetFocus();
|
m_owner->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos)
|
||||||
|
{
|
||||||
|
wxWindow *parent = GetParent();
|
||||||
|
wxListEvent le( type, parent->GetId() );
|
||||||
|
le.SetEventObject( parent );
|
||||||
|
le.m_pointDrag = pos;
|
||||||
|
|
||||||
|
// the position should be relative to the parent window, not
|
||||||
|
// this one for compatibility with MSW and common sense: the
|
||||||
|
// user code doesn't know anything at all about this header
|
||||||
|
// window, so why should it get positions relative to it?
|
||||||
|
le.m_pointDrag.y -= GetSize().y;
|
||||||
|
|
||||||
|
le.m_col = m_column;
|
||||||
|
parent->GetEventHandler()->ProcessEvent( le );
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxListRenameTimer (internal)
|
// wxListRenameTimer (internal)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2221,7 +2235,7 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
|
|||||||
|
|
||||||
(*m_accept) = TRUE;
|
(*m_accept) = TRUE;
|
||||||
(*m_res) = GetValue();
|
(*m_res) = GetValue();
|
||||||
|
|
||||||
if ((*m_res) != m_startValue)
|
if ((*m_res) != m_startValue)
|
||||||
m_owner->OnRenameAccept();
|
m_owner->OnRenameAccept();
|
||||||
}
|
}
|
||||||
@ -3053,7 +3067,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
// FIXME: wxGTK generates bad sequence of events prior to doubleclick
|
// FIXME: wxGTK generates bad sequence of events prior to doubleclick
|
||||||
// ("down, up, down, double, up" while other ports
|
// ("down, up, down, double, up" while other ports
|
||||||
// do "down, up, double, up"). We have to have this hack
|
// do "down, up, double, up"). We have to have this hack
|
||||||
// in place till somebody fixes wxGTK...
|
// in place till somebody fixes wxGTK...
|
||||||
if ( current == m_lineBeforeLastClicked )
|
if ( current == m_lineBeforeLastClicked )
|
||||||
@ -3412,13 +3426,13 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
void wxListMainWindow::SetFocus()
|
void wxListMainWindow::SetFocus()
|
||||||
{
|
{
|
||||||
// VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
|
// VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
|
||||||
// overrides SetFocus in such way that it does never change focus from
|
// overrides SetFocus in such way that it does never change focus from
|
||||||
// panel's child to the panel itself. Unfortunately, we must be able to change
|
// panel's child to the panel itself. Unfortunately, we must be able to change
|
||||||
// focus to the panel from wxListTextCtrl because the text control should
|
// focus to the panel from wxListTextCtrl because the text control should
|
||||||
// disappear when the user clicks outside it.
|
// disappear when the user clicks outside it.
|
||||||
|
|
||||||
wxWindow *oldFocus = FindFocus();
|
wxWindow *oldFocus = FindFocus();
|
||||||
|
|
||||||
if ( oldFocus && oldFocus->GetParent() == this )
|
if ( oldFocus && oldFocus->GetParent() == this )
|
||||||
{
|
{
|
||||||
wxWindow::SetFocus();
|
wxWindow::SetFocus();
|
||||||
@ -3937,7 +3951,7 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
int clientWidth,
|
int clientWidth,
|
||||||
clientHeight;
|
clientHeight;
|
||||||
GetSize( &clientWidth, &clientHeight );
|
GetSize( &clientWidth, &clientHeight );
|
||||||
|
|
||||||
if ( HasFlag(wxLC_REPORT) )
|
if ( HasFlag(wxLC_REPORT) )
|
||||||
{
|
{
|
||||||
// all lines have the same height
|
// all lines have the same height
|
||||||
@ -3972,7 +3986,7 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
{
|
{
|
||||||
// We start with 4 for the border around all items
|
// We start with 4 for the border around all items
|
||||||
entireWidth = 4;
|
entireWidth = 4;
|
||||||
|
|
||||||
if (tries == 1)
|
if (tries == 1)
|
||||||
{
|
{
|
||||||
// Now we have decided that the items do not fit into the
|
// Now we have decided that the items do not fit into the
|
||||||
@ -3984,7 +3998,7 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
// a scrollbar at the bottom of its client area.
|
// a scrollbar at the bottom of its client area.
|
||||||
entireWidth += SCROLL_UNIT_X;
|
entireWidth += SCROLL_UNIT_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start at 2,2 so the text does not touch the border
|
// Start at 2,2 so the text does not touch the border
|
||||||
int x = 2;
|
int x = 2;
|
||||||
int y = 2;
|
int y = 2;
|
||||||
@ -4018,11 +4032,11 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
entireWidth += maxWidth+6;
|
entireWidth += maxWidth+6;
|
||||||
maxWidth = 0;
|
maxWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have reached the last item.
|
// We have reached the last item.
|
||||||
if ( i == count - 1 )
|
if ( i == count - 1 )
|
||||||
entireWidth += maxWidth;
|
entireWidth += maxWidth;
|
||||||
|
|
||||||
if ( (tries == 0) && (entireWidth+SCROLL_UNIT_X > clientWidth) )
|
if ( (tries == 0) && (entireWidth+SCROLL_UNIT_X > clientWidth) )
|
||||||
{
|
{
|
||||||
clientHeight -= 15; // We guess the scrollbar height. (FIXME)
|
clientHeight -= 15; // We guess the scrollbar height. (FIXME)
|
||||||
@ -4030,7 +4044,7 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
currentlyVisibleLines = 0;
|
currentlyVisibleLines = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( i == count - 1 )
|
if ( i == count - 1 )
|
||||||
tries = 1; // Everything fits, no second try required.
|
tries = 1; // Everything fits, no second try required.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user