generate wxEVT_GRID_{COL,ROW}_SIZE events when the user double clicks the separating line too; do not generate these events if the size didn't really change (further improvements to grid events are possible and remain needed, see #10754)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60435 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1956,10 +1956,10 @@ protected:
|
|||||||
// it was processed (but not vetoed) and 0 if it wasn't processed
|
// it was processed (but not vetoed) and 0 if it wasn't processed
|
||||||
int SendEvent(const wxEventType evtType,
|
int SendEvent(const wxEventType evtType,
|
||||||
int row, int col,
|
int row, int col,
|
||||||
wxMouseEvent& e);
|
const wxMouseEvent& e);
|
||||||
int SendEvent(const wxEventType evtType,
|
int SendEvent(const wxEventType evtType,
|
||||||
const wxGridCellCoords& coords,
|
const wxGridCellCoords& coords,
|
||||||
wxMouseEvent& e)
|
const wxMouseEvent& e)
|
||||||
{ return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); }
|
{ return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); }
|
||||||
int SendEvent(const wxEventType evtType,
|
int SendEvent(const wxEventType evtType,
|
||||||
int row, int col,
|
int row, int col,
|
||||||
@@ -1971,6 +1971,11 @@ protected:
|
|||||||
int SendEvent(const wxEventType evtType, const wxString& s = wxString())
|
int SendEvent(const wxEventType evtType, const wxString& s = wxString())
|
||||||
{ return SendEvent(evtType, m_currentCellCoords, s); }
|
{ return SendEvent(evtType, m_currentCellCoords, s); }
|
||||||
|
|
||||||
|
// send wxEVT_GRID_{ROW,COL}_SIZE
|
||||||
|
void SendSizeEvent(wxEventType type,
|
||||||
|
int row, int col,
|
||||||
|
const wxMouseEvent& mouseEv);
|
||||||
|
|
||||||
void OnPaint( wxPaintEvent& );
|
void OnPaint( wxPaintEvent& );
|
||||||
void OnSize( wxSizeEvent& );
|
void OnSize( wxSizeEvent& );
|
||||||
void OnKeyDown( wxKeyEvent& );
|
void OnKeyDown( wxKeyEvent& );
|
||||||
@@ -2084,14 +2089,14 @@ private:
|
|||||||
void DoUpdateResizeColWidth(int w);
|
void DoUpdateResizeColWidth(int w);
|
||||||
void DoStartMoveCol(int col);
|
void DoStartMoveCol(int col);
|
||||||
|
|
||||||
void DoEndDragResizeRow();
|
void DoEndDragResizeRow(const wxMouseEvent& event);
|
||||||
void DoEndDragResizeCol(wxMouseEvent *event = NULL);
|
void DoEndDragResizeCol(const wxMouseEvent& event);
|
||||||
void DoEndMoveCol(int pos);
|
void DoEndMoveCol(int pos);
|
||||||
|
|
||||||
|
|
||||||
// common implementations of methods defined for both rows and columns
|
// common implementations of methods defined for both rows and columns
|
||||||
void DeselectLine(int line, const wxGridOperations& oper);
|
void DeselectLine(int line, const wxGridOperations& oper);
|
||||||
void DoEndDragResizeLine(const wxGridOperations& oper);
|
bool DoEndDragResizeLine(const wxGridOperations& oper);
|
||||||
int PosToLinePos(int pos, bool clipToMinMax,
|
int PosToLinePos(int pos, bool clipToMinMax,
|
||||||
const wxGridOperations& oper) const;
|
const wxGridOperations& oper) const;
|
||||||
int PosToLine(int pos, bool clipToMinMax,
|
int PosToLine(int pos, bool clipToMinMax,
|
||||||
|
@@ -195,7 +195,12 @@ private:
|
|||||||
|
|
||||||
// as this is done by the user we should notify the main program about
|
// as this is done by the user we should notify the main program about
|
||||||
// it
|
// it
|
||||||
GetOwner()->SendEvent(wxEVT_GRID_COL_SIZE, -1, idx);
|
|
||||||
|
// make up a dummy event for the grid event to use -- unfortunately we
|
||||||
|
// can't do anything else here
|
||||||
|
wxMouseEvent e;
|
||||||
|
e.SetState(wxGetMouseState());
|
||||||
|
GetOwner()->SendSizeEvent(wxEVT_GRID_COL_SIZE, -1, idx, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// overridden to react to the columns order changes in the customization
|
// overridden to react to the columns order changes in the customization
|
||||||
@@ -226,7 +231,12 @@ private:
|
|||||||
|
|
||||||
void OnEndResize(wxHeaderCtrlEvent& event)
|
void OnEndResize(wxHeaderCtrlEvent& event)
|
||||||
{
|
{
|
||||||
GetOwner()->DoEndDragResizeCol();
|
// we again need to pass a mouse event to be used for the grid event
|
||||||
|
// generation but we don't have it here so use a dummy one as in
|
||||||
|
// UpdateColumnVisibility()
|
||||||
|
wxMouseEvent e;
|
||||||
|
e.SetState(wxGetMouseState());
|
||||||
|
GetOwner()->DoEndDragResizeCol(e);
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
@@ -3639,18 +3639,16 @@ public:
|
|||||||
This event class contains information about a row/column resize event.
|
This event class contains information about a row/column resize event.
|
||||||
|
|
||||||
@beginEventTable{wxGridSizeEvent}
|
@beginEventTable{wxGridSizeEvent}
|
||||||
@event{EVT_GRID_COL_SIZE(func)}
|
|
||||||
The user resized a column by dragging it. Processes a
|
|
||||||
@c wxEVT_GRID_COL_SIZE event type.
|
|
||||||
@event{EVT_GRID_ROW_SIZE(func)}
|
|
||||||
The user resized a row by dragging it. Processes a
|
|
||||||
@c wxEVT_GRID_ROW_SIZE event type.
|
|
||||||
@event{EVT_GRID_CMD_COL_SIZE(id, func)}
|
@event{EVT_GRID_CMD_COL_SIZE(id, func)}
|
||||||
The user resized a column by dragging it; variant taking a window
|
The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
|
||||||
identifier. Processes a @c wxEVT_GRID_COL_SIZE event type.
|
type.
|
||||||
@event{EVT_GRID_CMD_ROW_SIZE(id, func)}
|
@event{EVT_GRID_CMD_ROW_SIZE(id, func)}
|
||||||
The user resized a row by dragging it; variant taking a window
|
The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
|
||||||
identifier. Processes a @c wxEVT_GRID_ROW_SIZE event type.
|
type.
|
||||||
|
@event{EVT_GRID_COL_SIZE(func)}
|
||||||
|
Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
|
||||||
|
@event{EVT_GRID_ROW_SIZE(func)}
|
||||||
|
Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
|
||||||
@endEventTable
|
@endEventTable
|
||||||
|
|
||||||
@library{wxadv}
|
@library{wxadv}
|
||||||
|
@@ -2969,8 +2969,12 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
if ( row != wxNOT_FOUND && CanDragRowSize(row) )
|
if ( row != wxNOT_FOUND && CanDragRowSize(row) )
|
||||||
{
|
{
|
||||||
// adjust row height depending on label text
|
// adjust row height depending on label text
|
||||||
|
//
|
||||||
|
// TODO: generate RESIZING event, see #10754
|
||||||
AutoSizeRowLabelSize( row );
|
AutoSizeRowLabelSize( row );
|
||||||
|
|
||||||
|
SendSizeEvent(wxEVT_GRID_ROW_SIZE, row, -1, event);
|
||||||
|
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
}
|
}
|
||||||
@@ -2990,14 +2994,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.LeftUp() )
|
else if ( event.LeftUp() )
|
||||||
{
|
{
|
||||||
if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
|
if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
|
||||||
{
|
DoEndDragResizeRow(event);
|
||||||
DoEndDragResizeRow();
|
|
||||||
|
|
||||||
// Note: we are ending the event *after* doing
|
|
||||||
// default processing in this case
|
|
||||||
//
|
|
||||||
SendEvent( wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
@@ -3318,8 +3315,12 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// adjust column width depending on label text
|
// adjust column width depending on label text
|
||||||
|
//
|
||||||
|
// TODO: generate RESIZING event, see #10754
|
||||||
AutoSizeColLabelSize( colEdge );
|
AutoSizeColLabelSize( colEdge );
|
||||||
|
|
||||||
|
SendSizeEvent(wxEVT_GRID_COL_SIZE, -1, colEdge, event);
|
||||||
|
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
}
|
}
|
||||||
@@ -3332,7 +3333,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
switch ( m_cursorMode )
|
switch ( m_cursorMode )
|
||||||
{
|
{
|
||||||
case WXGRID_CURSOR_RESIZE_COL:
|
case WXGRID_CURSOR_RESIZE_COL:
|
||||||
DoEndDragResizeCol();
|
DoEndDragResizeCol(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXGRID_CURSOR_MOVE_COL:
|
case WXGRID_CURSOR_MOVE_COL:
|
||||||
@@ -3754,17 +3755,12 @@ wxGrid::DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords)
|
|||||||
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
|
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
|
||||||
{
|
{
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
|
||||||
DoEndDragResizeRow();
|
DoEndDragResizeRow(event);
|
||||||
|
|
||||||
// Note: we are ending the event *after* doing
|
|
||||||
// default processing in this case
|
|
||||||
//
|
|
||||||
SendEvent( wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
|
||||||
}
|
}
|
||||||
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
|
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
|
||||||
{
|
{
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
|
||||||
DoEndDragResizeCol();
|
DoEndDragResizeCol(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
@@ -3894,10 +3890,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DoEndDragResizeLine(const wxGridOperations& oper)
|
// this function returns true only if the size really changed
|
||||||
|
bool wxGrid::DoEndDragResizeLine(const wxGridOperations& oper)
|
||||||
{
|
{
|
||||||
if ( m_dragLastPos == -1 )
|
if ( m_dragLastPos == -1 )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
const wxGridOperations& doper = oper.Dual();
|
const wxGridOperations& doper = oper.Dual();
|
||||||
|
|
||||||
@@ -3921,9 +3918,12 @@ void wxGrid::DoEndDragResizeLine(const wxGridOperations& oper)
|
|||||||
|
|
||||||
// do resize the line
|
// do resize the line
|
||||||
const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
|
const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
|
||||||
|
const int lineSizeOld = oper.GetLineSize(this, m_dragRowOrCol);
|
||||||
oper.SetLineSize(this, m_dragRowOrCol,
|
oper.SetLineSize(this, m_dragRowOrCol,
|
||||||
wxMax(m_dragLastPos - lineStart,
|
wxMax(m_dragLastPos - lineStart,
|
||||||
oper.GetMinimalLineSize(this, m_dragRowOrCol)));
|
oper.GetMinimalLineSize(this, m_dragRowOrCol)));
|
||||||
|
const bool
|
||||||
|
sizeChanged = oper.GetLineSize(this, m_dragRowOrCol) != lineSizeOld;
|
||||||
|
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
|
|
||||||
@@ -3986,24 +3986,24 @@ void wxGrid::DoEndDragResizeLine(const wxGridOperations& oper)
|
|||||||
|
|
||||||
// show the edit control back again
|
// show the edit control back again
|
||||||
ShowCellEditControl();
|
ShowCellEditControl();
|
||||||
|
|
||||||
|
return sizeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DoEndDragResizeRow()
|
void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
DoEndDragResizeLine(wxGridRowOperations());
|
// TODO: generate RESIZING event, see #10754
|
||||||
|
|
||||||
|
if ( DoEndDragResizeLine(wxGridRowOperations()) )
|
||||||
|
SendSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DoEndDragResizeCol(wxMouseEvent *event)
|
void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
DoEndDragResizeLine(wxGridColumnOperations());
|
// TODO: generate RESIZING event, see #10754
|
||||||
|
|
||||||
// Note: we are ending the event *after* doing
|
if ( DoEndDragResizeLine(wxGridColumnOperations()) )
|
||||||
// default processing in this case
|
SendSizeEvent(wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event);
|
||||||
//
|
|
||||||
if ( event )
|
|
||||||
SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, *event );
|
|
||||||
else
|
|
||||||
SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DoStartMoveCol(int col)
|
void wxGrid::DoStartMoveCol(int col)
|
||||||
@@ -4177,37 +4177,40 @@ wxGrid::DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t),
|
|||||||
return (m_table->*funcAppend)(num);
|
return (m_table->*funcAppend)(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// ----------------------------------------------------------------------------
|
||||||
// ----- event handlers
|
// event generation helpers
|
||||||
//
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void
|
||||||
|
wxGrid::SendSizeEvent(wxEventType type,
|
||||||
|
int row, int col,
|
||||||
|
const wxMouseEvent& mouseEv)
|
||||||
|
{
|
||||||
|
int rowOrCol = row == -1 ? col : row;
|
||||||
|
|
||||||
|
wxGridSizeEvent gridEvt( GetId(),
|
||||||
|
type,
|
||||||
|
this,
|
||||||
|
rowOrCol,
|
||||||
|
mouseEv.GetX() + GetRowLabelSize(),
|
||||||
|
mouseEv.GetY() + GetColLabelSize(),
|
||||||
|
mouseEv);
|
||||||
|
|
||||||
|
GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a grid event based on a mouse event and return:
|
// Generate a grid event based on a mouse event and return:
|
||||||
// -1 if the event was vetoed
|
// -1 if the event was vetoed
|
||||||
// +1 if the event was processed (but not vetoed)
|
// +1 if the event was processed (but not vetoed)
|
||||||
// 0 if the event wasn't handled
|
// 0 if the event wasn't handled
|
||||||
int
|
int
|
||||||
wxGrid::SendEvent(const wxEventType type,
|
wxGrid::SendEvent(wxEventType type,
|
||||||
int row, int col,
|
int row, int col,
|
||||||
wxMouseEvent& mouseEv)
|
const wxMouseEvent& mouseEv)
|
||||||
{
|
{
|
||||||
bool claimed, vetoed;
|
bool claimed, vetoed;
|
||||||
|
|
||||||
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
|
if ( type == wxEVT_GRID_RANGE_SELECT )
|
||||||
{
|
|
||||||
int rowOrCol = (row == -1 ? col : row);
|
|
||||||
|
|
||||||
wxGridSizeEvent gridEvt( GetId(),
|
|
||||||
type,
|
|
||||||
this,
|
|
||||||
rowOrCol,
|
|
||||||
mouseEv.GetX() + GetRowLabelSize(),
|
|
||||||
mouseEv.GetY() + GetColLabelSize(),
|
|
||||||
mouseEv);
|
|
||||||
|
|
||||||
claimed = GetEventHandler()->ProcessEvent(gridEvt);
|
|
||||||
vetoed = !gridEvt.IsAllowed();
|
|
||||||
}
|
|
||||||
else if ( type == wxEVT_GRID_RANGE_SELECT )
|
|
||||||
{
|
{
|
||||||
// Right now, it should _never_ end up here!
|
// Right now, it should _never_ end up here!
|
||||||
wxGridRangeSelectEvent gridEvt( GetId(),
|
wxGridRangeSelectEvent gridEvt( GetId(),
|
||||||
@@ -4270,28 +4273,13 @@ wxGrid::SendEvent(const wxEventType type,
|
|||||||
int
|
int
|
||||||
wxGrid::SendEvent(const wxEventType type, int row, int col, const wxString& s)
|
wxGrid::SendEvent(const wxEventType type, int row, int col, const wxString& s)
|
||||||
{
|
{
|
||||||
bool claimed, vetoed;
|
wxGridEvent gridEvt( GetId(), type, this, row, col );
|
||||||
|
gridEvt.SetString(s);
|
||||||
|
|
||||||
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
|
const bool claimed = GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
{
|
|
||||||
int rowOrCol = (row == -1 ? col : row);
|
|
||||||
|
|
||||||
wxGridSizeEvent gridEvt( GetId(), type, this, rowOrCol );
|
|
||||||
|
|
||||||
claimed = GetEventHandler()->ProcessEvent(gridEvt);
|
|
||||||
vetoed = !gridEvt.IsAllowed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxGridEvent gridEvt( GetId(), type, this, row, col );
|
|
||||||
gridEvt.SetString(s);
|
|
||||||
|
|
||||||
claimed = GetEventHandler()->ProcessEvent(gridEvt);
|
|
||||||
vetoed = !gridEvt.IsAllowed();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Veto'd event may not be `claimed' so test this first
|
// A Veto'd event may not be `claimed' so test this first
|
||||||
if (vetoed)
|
if ( !gridEvt.IsAllowed() )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return claimed ? 1 : 0;
|
return claimed ? 1 : 0;
|
||||||
|
Reference in New Issue
Block a user