Eliminate -Wcast-qual warnings with GCC and Clang
Use const_cast, mutable, and various other changes to avoid -Wcast-qual
This commit is contained in:
@@ -613,7 +613,7 @@ wxRect wxRichTextObject::GetAvailableContentArea(wxDC& dc, wxRichTextDrawingCont
|
||||
wxRect marginRect, borderRect, contentRect, paddingRect, outlineRect;
|
||||
marginRect = outerRect;
|
||||
wxRichTextAttr attr(GetAttributes());
|
||||
((wxRichTextObject*)this)->AdjustAttributes(attr, context);
|
||||
const_cast<wxRichTextObject*>(this)->AdjustAttributes(attr, context);
|
||||
GetBoxRects(dc, GetBuffer(), attr, marginRect, borderRect, contentRect, paddingRect, outlineRect);
|
||||
return contentRect;
|
||||
}
|
||||
@@ -7177,7 +7177,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
||||
int relativeX = position.x - GetParent()->GetPosition().x;
|
||||
|
||||
wxRichTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
|
||||
((wxRichTextObject*) this)->AdjustAttributes(textAttr, context);
|
||||
const_cast<wxRichTextPlainText*>(this)->AdjustAttributes(textAttr, context);
|
||||
|
||||
// Always assume unformatted text, since at this level we have no knowledge
|
||||
// of line breaks - and we don't need it, since we'll calculate size within
|
||||
@@ -7251,7 +7251,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
||||
for (int i = 0; i < tabCount; ++i)
|
||||
{
|
||||
int pos = tabArray[i];
|
||||
pos = ((wxRichTextPlainText*) this)->ConvertTenthsMMToPixels(dc, pos);
|
||||
pos = const_cast<wxRichTextPlainText*>(this)->ConvertTenthsMMToPixels(dc, pos);
|
||||
tabArray[i] = pos;
|
||||
}
|
||||
|
||||
@@ -7305,7 +7305,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
||||
{
|
||||
if (nextTabPos <= absoluteWidth)
|
||||
{
|
||||
int defaultTabWidth = ((wxRichTextPlainText*) this)->ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS);
|
||||
int defaultTabWidth = const_cast<wxRichTextPlainText*>(this)->ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS);
|
||||
nextTabPos = absoluteWidth + defaultTabWidth;
|
||||
}
|
||||
|
||||
@@ -7452,16 +7452,16 @@ bool wxRichTextPlainText::CanMerge(wxRichTextObject* object, wxRichTextDrawingCo
|
||||
// Check if differing virtual attributes makes it impossible to merge
|
||||
// these strings.
|
||||
|
||||
bool hasVirtualAttr1 = context.HasVirtualAttributes((wxRichTextObject*) this);
|
||||
bool hasVirtualAttr2 = context.HasVirtualAttributes((wxRichTextObject*) object);
|
||||
bool hasVirtualAttr1 = context.HasVirtualAttributes(const_cast<wxRichTextPlainText*>(this));
|
||||
bool hasVirtualAttr2 = context.HasVirtualAttributes(object);
|
||||
if (!hasVirtualAttr1 && !hasVirtualAttr2)
|
||||
return true;
|
||||
else if (hasVirtualAttr1 != hasVirtualAttr2)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
wxRichTextAttr virtualAttr1 = context.GetVirtualAttributes((wxRichTextObject*) this);
|
||||
wxRichTextAttr virtualAttr2 = context.GetVirtualAttributes((wxRichTextObject*) object);
|
||||
wxRichTextAttr virtualAttr1 = context.GetVirtualAttributes(const_cast<wxRichTextPlainText*>(this));
|
||||
wxRichTextAttr virtualAttr2 = context.GetVirtualAttributes(object);
|
||||
return virtualAttr1 == virtualAttr2;
|
||||
}
|
||||
}
|
||||
@@ -7489,7 +7489,7 @@ bool wxRichTextPlainText::CanSplit(wxRichTextDrawingContext& context) const
|
||||
// If this object has any virtual attributes at all, whether for the whole object
|
||||
// or individual ones, we should try splitting it by calling Split.
|
||||
// Must be more than one character in order to be able to split.
|
||||
return m_text.Length() > 1 && context.HasVirtualAttributes((wxRichTextObject*) this);
|
||||
return m_text.Length() > 1 && context.HasVirtualAttributes(const_cast<wxRichTextPlainText*>(this));
|
||||
}
|
||||
|
||||
wxRichTextObject* wxRichTextPlainText::Split(wxRichTextDrawingContext& context)
|
||||
@@ -9440,13 +9440,13 @@ bool wxRichTextField::GetRangeSize(const wxRichTextRange& range, wxSize& size, i
|
||||
{
|
||||
wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType());
|
||||
if (fieldType)
|
||||
return fieldType->GetRangeSize((wxRichTextField*) this, range, size, descent, dc, context, flags, position, parentSize, partialExtents);
|
||||
return fieldType->GetRangeSize(const_cast<wxRichTextField*>(this), range, size, descent, dc, context, flags, position, parentSize, partialExtents);
|
||||
|
||||
// Fallback so unknown fields don't become invisible.
|
||||
wxString fieldTypeStr(GetFieldType());
|
||||
wxRichTextFieldTypeStandard defaultFieldType;
|
||||
defaultFieldType.SetLabel(wxString::Format(wxT("unknown field %s"), fieldTypeStr.c_str()));
|
||||
return defaultFieldType.GetRangeSize((wxRichTextField*) this, range, size, descent, dc, context, flags, position, parentSize, partialExtents);
|
||||
return defaultFieldType.GetRangeSize(const_cast<wxRichTextField*>(this), range, size, descent, dc, context, flags, position, parentSize, partialExtents);
|
||||
}
|
||||
|
||||
/// Calculate range
|
||||
@@ -9480,7 +9480,7 @@ bool wxRichTextField::CanEditProperties() const
|
||||
{
|
||||
wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType());
|
||||
if (fieldType)
|
||||
return fieldType->CanEditProperties((wxRichTextField*) this);
|
||||
return fieldType->CanEditProperties(const_cast<wxRichTextField*>(this));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -9489,7 +9489,7 @@ wxString wxRichTextField::GetPropertiesMenuLabel() const
|
||||
{
|
||||
wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType());
|
||||
if (fieldType)
|
||||
return fieldType->GetPropertiesMenuLabel((wxRichTextField*) this);
|
||||
return fieldType->GetPropertiesMenuLabel(const_cast<wxRichTextField*>(this));
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
@@ -9507,7 +9507,7 @@ bool wxRichTextField::IsTopLevel() const
|
||||
{
|
||||
wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType());
|
||||
if (fieldType)
|
||||
return fieldType->IsTopLevel((wxRichTextField*) this);
|
||||
return fieldType->IsTopLevel(const_cast<wxRichTextField*>(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -11130,7 +11130,7 @@ wxRichTextCell* wxRichTextTable::GetCell(int row, int col) const
|
||||
wxRichTextSelection wxRichTextTable::GetSelection(long start, long end) const
|
||||
{
|
||||
wxRichTextSelection selection;
|
||||
selection.SetContainer((wxRichTextTable*) this);
|
||||
selection.SetContainer(const_cast<wxRichTextTable*>(this));
|
||||
|
||||
if (start > end)
|
||||
{
|
||||
@@ -12815,7 +12815,7 @@ bool wxRichTextImage::GetRangeSize(const wxRichTextRange& range, wxSize& size, i
|
||||
return false;
|
||||
|
||||
wxSize imageSize;
|
||||
if (!((wxRichTextImage*)this)->LoadImageCache(dc, context, imageSize, false, parentSize))
|
||||
if (!const_cast<wxRichTextImage*>(this)->LoadImageCache(dc, context, imageSize, false, parentSize))
|
||||
{
|
||||
size.x = 0; size.y = 0;
|
||||
if (partialExtents)
|
||||
@@ -12824,7 +12824,7 @@ bool wxRichTextImage::GetRangeSize(const wxRichTextRange& range, wxSize& size, i
|
||||
}
|
||||
|
||||
wxRichTextAttr attr(GetAttributes());
|
||||
((wxRichTextObject*)this)->AdjustAttributes(attr, context);
|
||||
const_cast<wxRichTextImage*>(this)->AdjustAttributes(attr, context);
|
||||
|
||||
wxRect marginRect, borderRect, contentRect, paddingRect, outlineRect;
|
||||
contentRect = wxRect(wxPoint(0,0), imageSize);
|
||||
|
||||
Reference in New Issue
Block a user