Code cleanup and clarification
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1953,8 +1953,10 @@ protected:
|
|||||||
wxPGProperty* property ) const;
|
wxPGProperty* property ) const;
|
||||||
|
|
||||||
/** Draws items from topitemy to bottomitemy */
|
/** Draws items from topitemy to bottomitemy */
|
||||||
void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy,
|
void DrawItems( wxDC& dc,
|
||||||
const wxRect* clip_rect = (const wxRect*) NULL );
|
unsigned int topItemY,
|
||||||
|
unsigned int bottomItemY,
|
||||||
|
const wxRect* drawRect = NULL );
|
||||||
|
|
||||||
// Translate wxKeyEvent to wxPG_ACTION_XXX
|
// Translate wxKeyEvent to wxPG_ACTION_XXX
|
||||||
int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
|
int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
|
||||||
|
@@ -1831,11 +1831,14 @@ void wxPropertyGrid::DrawExpanderButton( wxDC& dc, const wxRect& rect,
|
|||||||
// topy and bottomy are already unscrolled (ie. physical)
|
// topy and bottomy are already unscrolled (ie. physical)
|
||||||
//
|
//
|
||||||
void wxPropertyGrid::DrawItems( wxDC& dc,
|
void wxPropertyGrid::DrawItems( wxDC& dc,
|
||||||
unsigned int topy,
|
unsigned int topItemY,
|
||||||
unsigned int bottomy,
|
unsigned int bottomItemY,
|
||||||
const wxRect* drawRect )
|
const wxRect* drawRect )
|
||||||
{
|
{
|
||||||
if ( m_frozen || m_height < 1 || bottomy < topy || !m_pState )
|
if ( m_frozen ||
|
||||||
|
m_height < 1 ||
|
||||||
|
bottomItemY < topItemY ||
|
||||||
|
!m_pState )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_pState->EnsureVirtualHeight();
|
m_pState->EnsureVirtualHeight();
|
||||||
@@ -1843,9 +1846,9 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
wxRect tempDrawRect;
|
wxRect tempDrawRect;
|
||||||
if ( !drawRect )
|
if ( !drawRect )
|
||||||
{
|
{
|
||||||
tempDrawRect = wxRect(0, topy,
|
tempDrawRect = wxRect(0, topItemY,
|
||||||
m_pState->m_width,
|
m_pState->m_width,
|
||||||
bottomy);
|
bottomItemY);
|
||||||
drawRect = &tempDrawRect;
|
drawRect = &tempDrawRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1888,7 +1891,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
paintFinishY = DoDrawItems( *dcPtr, drawRect, isBuffered );
|
paintFinishY = DoDrawItems( *dcPtr, drawRect, isBuffered );
|
||||||
int drawBottomY = drawRect->y + drawRect->height;
|
int drawBottomY = drawRect->y + drawRect->height;
|
||||||
|
|
||||||
// Clear area beyond bottomY?
|
// Clear area beyond last painted property
|
||||||
if ( paintFinishY < drawBottomY )
|
if ( paintFinishY < drawBottomY )
|
||||||
{
|
{
|
||||||
dcPtr->SetPen(m_colEmptySpace);
|
dcPtr->SetPen(m_colEmptySpace);
|
||||||
@@ -1923,22 +1926,23 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
||||||
const wxRect* clipRect,
|
const wxRect* drawRect,
|
||||||
bool isBuffered ) const
|
bool isBuffered ) const
|
||||||
{
|
{
|
||||||
const wxPGProperty* firstItem;
|
const wxPGProperty* firstItem;
|
||||||
const wxPGProperty* lastItem;
|
const wxPGProperty* lastItem;
|
||||||
|
|
||||||
firstItem = DoGetItemAtY(clipRect->y);
|
firstItem = DoGetItemAtY(drawRect->y);
|
||||||
lastItem = DoGetItemAtY(clipRect->y+clipRect->height-1);
|
lastItem = DoGetItemAtY(drawRect->y+drawRect->height-1);
|
||||||
|
|
||||||
if ( !lastItem )
|
if ( !lastItem )
|
||||||
lastItem = GetLastItem( wxPG_ITERATE_VISIBLE );
|
lastItem = GetLastItem( wxPG_ITERATE_VISIBLE );
|
||||||
|
|
||||||
if ( m_frozen || m_height < 1 || firstItem == NULL )
|
if ( m_frozen || m_height < 1 || firstItem == NULL )
|
||||||
return clipRect->y;
|
return drawRect->y;
|
||||||
|
|
||||||
wxCHECK_MSG( !m_pState->m_itemsAdded, clipRect->y, wxT("no items added") );
|
wxCHECK_MSG( !m_pState->m_itemsAdded, drawRect->y,
|
||||||
|
"no items added" );
|
||||||
wxASSERT( m_pState->m_properties->GetChildCount() );
|
wxASSERT( m_pState->m_properties->GetChildCount() );
|
||||||
|
|
||||||
int lh = m_lineHeight;
|
int lh = m_lineHeight;
|
||||||
@@ -1946,8 +1950,8 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
int firstItemTopY;
|
int firstItemTopY;
|
||||||
int lastItemBottomY;
|
int lastItemBottomY;
|
||||||
|
|
||||||
firstItemTopY = clipRect->y;
|
firstItemTopY = drawRect->y;
|
||||||
lastItemBottomY = clipRect->y + clipRect->height;
|
lastItemBottomY = drawRect->y + drawRect->height;
|
||||||
|
|
||||||
// Align y coordinates to item boundaries
|
// Align y coordinates to item boundaries
|
||||||
firstItemTopY -= firstItemTopY % lh;
|
firstItemTopY -= firstItemTopY % lh;
|
||||||
@@ -1955,19 +1959,22 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
lastItemBottomY -= 1;
|
lastItemBottomY -= 1;
|
||||||
|
|
||||||
// Entire range outside scrolled, visible area?
|
// Entire range outside scrolled, visible area?
|
||||||
if ( firstItemTopY >= (int)m_pState->GetVirtualHeight() || lastItemBottomY <= 0 )
|
if ( firstItemTopY >= (int)m_pState->GetVirtualHeight() ||
|
||||||
return clipRect->y;
|
lastItemBottomY <= 0 )
|
||||||
|
return drawRect->y;
|
||||||
wxCHECK_MSG( firstItemTopY < lastItemBottomY, clipRect->y, wxT("invalid y values") );
|
|
||||||
|
|
||||||
|
wxCHECK_MSG( firstItemTopY < lastItemBottomY,
|
||||||
|
drawRect->y,
|
||||||
|
"invalid y values" );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wxLogDebug(wxT(" -> DoDrawItems ( \"%s\" -> \"%s\", height=%i (ch=%i), clipRect = 0x%lX )"),
|
wxLogDebug(" -> DoDrawItems ( \"%s\" -> \"%s\"
|
||||||
|
"height=%i (ch=%i), drawRect = 0x%lX )",
|
||||||
firstItem->GetLabel().c_str(),
|
firstItem->GetLabel().c_str(),
|
||||||
lastItem->GetLabel().c_str(),
|
lastItem->GetLabel().c_str(),
|
||||||
(int)(lastItemBottomY - firstItemTopY),
|
(int)(lastItemBottomY - firstItemTopY),
|
||||||
(int)m_height,
|
(int)m_height,
|
||||||
(unsigned long)clipRect );
|
(unsigned long)drawRect );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxRect r;
|
wxRect r;
|
||||||
@@ -1979,7 +1986,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
|
|
||||||
//
|
//
|
||||||
// With wxPG_DOUBLE_BUFFER, do double buffering
|
// With wxPG_DOUBLE_BUFFER, do double buffering
|
||||||
// - buffer's y = 0, so align cliprect and coordinates to that
|
// - buffer's y = 0, so align drawRect and coordinates to that
|
||||||
//
|
//
|
||||||
#if wxPG_DOUBLE_BUFFER
|
#if wxPG_DOUBLE_BUFFER
|
||||||
|
|
||||||
@@ -1987,15 +1994,15 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
|
|
||||||
if ( isBuffered )
|
if ( isBuffered )
|
||||||
{
|
{
|
||||||
xRelMod = clipRect->x;
|
xRelMod = drawRect->x;
|
||||||
yRelMod = clipRect->y;
|
yRelMod = drawRect->y;
|
||||||
|
|
||||||
//
|
//
|
||||||
// clipRect conversion
|
// drawRect conversion
|
||||||
cr2 = *clipRect;
|
cr2 = *drawRect;
|
||||||
cr2.x -= xRelMod;
|
cr2.x -= xRelMod;
|
||||||
cr2.y -= yRelMod;
|
cr2.y -= yRelMod;
|
||||||
clipRect = &cr2;
|
drawRect = &cr2;
|
||||||
firstItemTopY -= yRelMod;
|
firstItemTopY -= yRelMod;
|
||||||
lastItemBottomY -= yRelMod;
|
lastItemBottomY -= yRelMod;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user