Fix MSVS 2015 warnings about hiding variables in wxRichText code

These warnings were apparently harmless, but really annoying, so get rid of
them by renaming the variables instead of reusing the same name in the nested
scope.

Closes #17351.
This commit is contained in:
Tobias Taschner
2016-02-05 21:49:08 +01:00
committed by Vadim Zeitlin
parent 89669e507b
commit 63803dd8d9
5 changed files with 95 additions and 103 deletions

View File

@@ -737,8 +737,8 @@ bool wxRichTextObject::DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, con
dc.SetBrush(wxBrush(shadowColour));
if (attr.GetTextBoxAttr().HasCornerRadius() && attr.GetTextBoxAttr().GetCornerRadius().GetValue() > 0)
{
wxTextAttrDimensionConverter converter(dc, buffer ? buffer->GetScale() : 1.0);
int cornerRadius = converter.GetPixels(attr.GetTextBoxAttr().GetCornerRadius());
wxTextAttrDimensionConverter radConverter(dc, buffer ? buffer->GetScale() : 1.0);
int cornerRadius = radConverter.GetPixels(attr.GetTextBoxAttr().GetCornerRadius());
if (cornerRadius > 0)
{
dc.DrawRoundedRectangle(shadowRect, cornerRadius);
@@ -2353,29 +2353,29 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& co
while (node)
{
wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph);
if (child)
wxRichTextParagraph* nodeChild = wxDynamicCast(node->GetData(), wxRichTextParagraph);
if (nodeChild)
{
if (child->GetLines().GetCount() == 0)
if (nodeChild->GetLines().GetCount() == 0)
{
child->SetImpactedByFloatingObjects(-1);
nodeChild->SetImpactedByFloatingObjects(-1);
// Lays out the object first with a given amount of space, and then if no width was specified in attr,
// lays out the object again using the minimum size
child->LayoutToBestSize(dc, context, GetBuffer(),
attr, child->GetAttributes(), availableSpace, rect, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
nodeChild->LayoutToBestSize(dc, context, GetBuffer(),
attr, nodeChild->GetAttributes(), availableSpace, rect, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
}
else
{
if (wxRichTextBuffer::GetFloatingLayoutMode() && GetFloatCollector())
GetFloatCollector()->CollectFloat(child);
child->Move(wxPoint(child->GetPosition().x, child->GetPosition().y + inc));
GetFloatCollector()->CollectFloat(nodeChild);
nodeChild->Move(wxPoint(nodeChild->GetPosition().x, nodeChild->GetPosition().y + inc));
}
availableSpace.y += child->GetCachedSize().y;
maxWidth = wxMax(maxWidth, child->GetCachedSize().x);
maxMinWidth = wxMax(maxMinWidth, child->GetMinSize().x);
maxMaxWidth = wxMax(maxMaxWidth, child->GetMaxSize().x);
availableSpace.y += nodeChild->GetCachedSize().y;
maxWidth = wxMax(maxWidth, nodeChild->GetCachedSize().x);
maxMinWidth = wxMax(maxMinWidth, nodeChild->GetMinSize().x);
maxMaxWidth = wxMax(maxMaxWidth, nodeChild->GetMaxSize().x);
}
node = node->GetNext();
@@ -2480,14 +2480,14 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& co
// This doesn't take into account floating objects, unfortunately.
if (yOffset != 0)
{
wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
while (node)
wxRichTextObjectList::compatibility_iterator childNode = m_children.GetFirst();
while (childNode)
{
wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph);
wxRichTextParagraph* child = wxDynamicCast(childNode->GetData(), wxRichTextParagraph);
if (child)
child->Move(wxPoint(child->GetPosition().x, child->GetPosition().y + yOffset));
node = node->GetNext();
childNode = childNode->GetNext();
}
}
}
@@ -2990,10 +2990,10 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
// If there was only one paragraph, we need to insert a new one.
while (i)
{
wxRichTextParagraph* para = wxDynamicCast(i->GetData(), wxRichTextParagraph);
wxASSERT( para != NULL );
wxRichTextParagraph* searchPara = wxDynamicCast(i->GetData(), wxRichTextParagraph);
wxASSERT( searchPara != NULL );
finalPara = (wxRichTextParagraph*) para->Clone();
finalPara = (wxRichTextParagraph*) searchPara->Clone();
if (nextParagraph)
InsertChild(finalPara, nextParagraph);
@@ -3051,10 +3051,10 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
wxRichTextObjectList::compatibility_iterator i = fragment.GetChildren().GetFirst();
while (i)
{
wxRichTextParagraph* para = wxDynamicCast(i->GetData(), wxRichTextParagraph);
wxASSERT( para != NULL );
wxRichTextParagraph* searchPara = wxDynamicCast(i->GetData(), wxRichTextParagraph);
wxASSERT( searchPara != NULL );
AppendChild(para->Clone());
AppendChild(searchPara->Clone());
i = i->GetNext();
}
@@ -3127,8 +3127,8 @@ bool wxRichTextParagraphLayoutBox::CopyFragment(const wxRichTextRange& range, wx
lastPara->DeleteRange(topTailRange);
// Make sure the numbering is correct
long end;
fragment.CalculateRange(0, end);
long unusedEnd;
fragment.CalculateRange(0, unusedEnd);
// We only have part of a paragraph at the end
fragment.SetPartialParagraph(true);
@@ -4431,10 +4431,10 @@ bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wx
if (styleSheet && !newPara->GetAttributes().GetParagraphStyleName().IsEmpty())
{
wxRichTextParagraphStyleDefinition* def = styleSheet->FindParagraphStyle(newPara->GetAttributes().GetParagraphStyleName());
if (def)
wxRichTextParagraphStyleDefinition* newParaDef = styleSheet->FindParagraphStyle(newPara->GetAttributes().GetParagraphStyleName());
if (newParaDef)
{
newPara->GetAttributes() = def->GetStyleMergedWithBase(styleSheet);
newPara->GetAttributes() = newParaDef->GetStyleMergedWithBase(styleSheet);
}
}
}
@@ -5657,14 +5657,14 @@ bool wxRichTextParagraph::InsertText(long pos, const wxString& text)
// Increment the end range of subsequent fragments in this paragraph.
// We'll set the paragraph range itself at a higher level.
wxRichTextObjectList::compatibility_iterator node = nodeToUse->GetNext();
while (node)
wxRichTextObjectList::compatibility_iterator childNode = nodeToUse->GetNext();
while (childNode)
{
wxRichTextObject* child = node->GetData();
wxRichTextObject* child = childNode->GetData();
child->SetRange(wxRichTextRange(textObject->GetRange().GetStart() + textLength,
textObject->GetRange().GetEnd() + textLength));
node = node->GetNext();
childNode = childNode->GetNext();
}
return true;
@@ -7192,13 +7192,13 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
wxFont textFont = font;
if (textFont.IsUsingSizeInPixels())
{
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(size)));
double textSize = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(textSize)));
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(size));
double textSize = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(textSize));
}
wxCheckSetFont(dc, textFont);
bScript = true;
@@ -10459,7 +10459,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
// Cell width percentages are for the overall cell width, so ignore margins and
// only take into account table margins and inter-cell padding.
int availableWidthForPercentageCellWidths = internalTableWidth - ((visibleCellCount-1) * paddingX);
wxTextAttrDimensionConverter converter(dc, scale, wxSize(availableWidthForPercentageCellWidths, 0));
wxTextAttrDimensionConverter cellConverter(dc, scale, wxSize(availableWidthForPercentageCellWidths, 0));
for (i = 0; i < m_colCount; i++)
{
@@ -10479,7 +10479,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
if (cell->GetAttributes().GetTextBoxAttr().GetWidth().IsValid())
{
int w = converter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
int w = cellConverter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
if (cell->GetAttributes().GetTextBoxAttr().GetWidth().GetUnits() == wxTEXT_ATTR_UNITS_PERCENTAGE)
{
percentageCellWidth = w;
@@ -10557,7 +10557,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
// Cell width percentages are for the overall cell width, so ignore margins and
// only take into account table margins and inter-cell padding.
int availableWidthForPercentageCellWidths = internalTableWidth - ((visibleCellCount-1) * paddingX);
wxTextAttrDimensionConverter converter(dc, scale, wxSize(availableWidthForPercentageCellWidths, 0));
wxTextAttrDimensionConverter cellConverter(dc, scale, wxSize(availableWidthForPercentageCellWidths, 0));
for (i = 0; i < m_colCount; i++)
{
@@ -10573,7 +10573,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
{
if (cell->GetAttributes().GetTextBoxAttr().GetWidth().IsValid())
{
cellWidth = converter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
cellWidth = cellConverter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetWidth(), wxHORIZONTAL);
// Override absolute width with minimum width if necessary
if (cell->GetMinSize().x > 0 && cellWidth != -1 && cell->GetMinSize().x > cellWidth)
cellWidth = cell->GetMinSize().x;
@@ -10819,7 +10819,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
wxArrayInt actualWidths;
actualWidths.Add(0, m_colCount);
wxTextAttrDimensionConverter converter(dc, scale);
wxTextAttrDimensionConverter cellConverter(dc, scale);
for (i = 0; i < m_colCount; i++)
{
wxRichTextCell* cell = GetCell(j, i);
@@ -10829,7 +10829,7 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const
// Don't handle percentages for height
if (cell->GetAttributes().GetTextBoxAttr().GetHeight().IsValid() && cell->GetAttributes().GetTextBoxAttr().GetHeight().GetUnits() != wxTEXT_ATTR_UNITS_PERCENTAGE)
{
int h = converter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetHeight());
int h = cellConverter.GetPixels(cell->GetAttributes().GetTextBoxAttr().GetHeight());
if (h > maxSpecifiedCellHeight)
maxSpecifiedCellHeight = h;
}
@@ -11819,10 +11819,10 @@ void wxRichTextAction::CalculateRefreshOptimizations(wxArrayInt& optimizationLin
// We will use a simple criterion - if any of the paragraphs following the
// modification point are affected by floats in other paragraphs,
// then we will simply update the rest of the screen.
wxRichTextObjectList::compatibility_iterator node = firstNode;
while (node)
wxRichTextObjectList::compatibility_iterator childNode = firstNode;
while (childNode)
{
wxRichTextParagraph* child = (wxRichTextParagraph*) node->GetData();
wxRichTextParagraph* child = (wxRichTextParagraph*) childNode->GetData();
if (child->GetRect().GetTop() > lastY)
break;
else if (child->GetImpactedByFloatingObjects() == 1)
@@ -11830,7 +11830,7 @@ void wxRichTextAction::CalculateRefreshOptimizations(wxArrayInt& optimizationLin
oldFloatRect = wxRect(0, 0, clientSize.x, lastY);
break;
}
node = node->GetNext();
childNode = childNode->GetNext();
}
}
}
@@ -12035,9 +12035,9 @@ bool wxRichTextAction::Do()
wxRichTextObjectList::compatibility_iterator node = parent->GetChildren().Find(obj);
if (node)
{
wxRichTextObject* obj = node->GetData();
wxRichTextObject* nodeObj = node->GetData();
node->SetData(m_object);
m_object = obj;
m_object = nodeObj;
}
}
}
@@ -12341,10 +12341,10 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
// which means the reformatting stopped at this point.
if (lastNode && (container->GetFloatingObjectCount() > 0) && (lastY < lastPossibleY))
{
wxRichTextObjectList::compatibility_iterator node = lastNode;
while (node)
wxRichTextObjectList::compatibility_iterator childNode = lastNode;
while (childNode)
{
wxRichTextParagraph* child = (wxRichTextParagraph*) node->GetData();
wxRichTextParagraph* child = (wxRichTextParagraph*) childNode->GetData();
if (child->GetImpactedByFloatingObjects() == 0)
{
wxRect childRect = child->GetRect();
@@ -12353,7 +12353,7 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
break;
}
node = node->GetNext();
childNode = childNode->GetNext();
}
}
}
@@ -12556,10 +12556,10 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
// Take away space used by the image's margins
{
// Find the actual space available when margin is taken into account
wxRect marginRect, borderRect, contentRect, paddingRect, outlineRect;
marginRect = wxRect(0, 0, 100, 100); // To force GetBoxRects to return content rect
GetBoxRects(dc, buffer, GetAttributes(), marginRect, borderRect, contentRect, paddingRect, outlineRect);
sz += (contentRect.GetSize() - wxSize(100, 100));
wxRect imgMarginRect, imgBorderRect, imgContentRect, imgPaddingRect, imgOutlineRect;
imgMarginRect = wxRect(0, 0, 100, 100); // To force GetBoxRects to return content rect
GetBoxRects(dc, buffer, GetAttributes(), imgMarginRect, imgBorderRect, imgContentRect, imgPaddingRect, imgOutlineRect);
sz += (imgContentRect.GetSize() - wxSize(100, 100));
}
// Use a minimum size to stop images becoming very small