use wxSwap()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -303,22 +303,10 @@ public:
|
|||||||
size_type size() const { return GetCount(); }
|
size_type size() const { return GetCount(); }
|
||||||
void swap(wxArrayString& other)
|
void swap(wxArrayString& other)
|
||||||
{
|
{
|
||||||
// not sure if we can rely on having std::swap() everywhere so do it
|
wxSwap(m_nSize, other.m_nSize);
|
||||||
// manually
|
wxSwap(m_nCount, other.m_nCount);
|
||||||
const size_t savedSize = m_nSize;
|
wxSwap(m_pItems, other.m_pItems);
|
||||||
const size_t savedCount = m_nCount;
|
wxSwap(m_autoSort, other.m_autoSort);
|
||||||
wxString * const savedItems = m_pItems;
|
|
||||||
const bool savedAutoSort = m_autoSort;
|
|
||||||
|
|
||||||
m_nSize = other.m_nSize;
|
|
||||||
m_nCount = other.m_nCount;
|
|
||||||
m_pItems = other.m_pItems;
|
|
||||||
m_autoSort = other.m_autoSort;
|
|
||||||
|
|
||||||
other.m_nSize = savedSize;
|
|
||||||
other.m_nCount = savedCount;
|
|
||||||
other.m_pItems = savedItems;
|
|
||||||
other.m_autoSort = savedAutoSort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -284,17 +284,9 @@ protected: \
|
|||||||
\
|
\
|
||||||
void swap(name& other) \
|
void swap(name& other) \
|
||||||
{ \
|
{ \
|
||||||
const size_t savedSize = m_nSize; \
|
wxSwap(m_nSize, other.m_nSize); \
|
||||||
const size_t savedCount = m_nCount; \
|
wxSwap(m_nCount, other.m_nCount); \
|
||||||
T * const savedItems = m_pItems; \
|
wxSwap(m_pItems, other.m_pItems); \
|
||||||
\
|
|
||||||
m_nSize = other.m_nSize; \
|
|
||||||
m_nCount = other.m_nCount; \
|
|
||||||
m_pItems = other.m_pItems; \
|
|
||||||
\
|
|
||||||
other.m_nSize = savedSize; \
|
|
||||||
other.m_nCount = savedCount; \
|
|
||||||
other.m_pItems = savedItems; \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/* the following functions may be made directly public because */ \
|
/* the following functions may be made directly public because */ \
|
||||||
|
@@ -439,6 +439,23 @@ static const size_t GRID_SCROLL_LINE_Y = GRID_SCROLL_LINE_X;
|
|||||||
// in these hash tables is the number of rows/columns)
|
// in these hash tables is the number of rows/columns)
|
||||||
static const int GRID_HASH_SIZE = 100;
|
static const int GRID_HASH_SIZE = 100;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private helpers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
// ensure that first is less or equal to second, swapping the values if
|
||||||
|
// necessary
|
||||||
|
void EnsureFirstLessThanSecond(int& first, int& second)
|
||||||
|
{
|
||||||
|
if ( first > second )
|
||||||
|
wxSwap(first, second);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -7181,7 +7198,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
|
|
||||||
void wxGrid::HighlightBlock(int topRow, int leftCol, int bottomRow, int rightCol)
|
void wxGrid::HighlightBlock(int topRow, int leftCol, int bottomRow, int rightCol)
|
||||||
{
|
{
|
||||||
int temp;
|
|
||||||
wxGridCellCoords updateTopLeft, updateBottomRight;
|
wxGridCellCoords updateTopLeft, updateBottomRight;
|
||||||
|
|
||||||
if ( m_selection )
|
if ( m_selection )
|
||||||
@@ -7198,19 +7214,8 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( topRow > bottomRow )
|
EnsureFirstLessThanSecond(topRow, bottomRow);
|
||||||
{
|
EnsureFirstLessThanSecond(leftCol, rightCol);
|
||||||
temp = topRow;
|
|
||||||
topRow = bottomRow;
|
|
||||||
bottomRow = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( leftCol > rightCol )
|
|
||||||
{
|
|
||||||
temp = leftCol;
|
|
||||||
leftCol = rightCol;
|
|
||||||
rightCol = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTopLeft = wxGridCellCoords( topRow, leftCol );
|
updateTopLeft = wxGridCellCoords( topRow, leftCol );
|
||||||
updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
|
updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
|
||||||
@@ -7247,30 +7252,10 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
|
|||||||
wxCoord oldBottom = m_selectingBottomRight.GetRow();
|
wxCoord oldBottom = m_selectingBottomRight.GetRow();
|
||||||
|
|
||||||
// Determine the outer/inner coordinates.
|
// Determine the outer/inner coordinates.
|
||||||
if (oldLeft > leftCol)
|
EnsureFirstLessThanSecond(oldLeft, leftCol);
|
||||||
{
|
EnsureFirstLessThanSecond(oldTop, topRow);
|
||||||
temp = oldLeft;
|
EnsureFirstLessThanSecond(rightCol, oldRight);
|
||||||
oldLeft = leftCol;
|
EnsureFirstLessThanSecond(bottomRow, oldBottom);
|
||||||
leftCol = temp;
|
|
||||||
}
|
|
||||||
if (oldTop > topRow )
|
|
||||||
{
|
|
||||||
temp = oldTop;
|
|
||||||
oldTop = topRow;
|
|
||||||
topRow = temp;
|
|
||||||
}
|
|
||||||
if (oldRight < rightCol )
|
|
||||||
{
|
|
||||||
temp = oldRight;
|
|
||||||
oldRight = rightCol;
|
|
||||||
rightCol = temp;
|
|
||||||
}
|
|
||||||
if (oldBottom < bottomRow)
|
|
||||||
{
|
|
||||||
temp = oldBottom;
|
|
||||||
oldBottom = bottomRow;
|
|
||||||
bottomRow = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, either the stuff marked old is the outer
|
// Now, either the stuff marked old is the outer
|
||||||
// rectangle or we don't have a situation where one
|
// rectangle or we don't have a situation where one
|
||||||
|
Reference in New Issue
Block a user