inline void wxCheckSetFont(wxDC& dc, const wxFont& font)
{
+#if 0
const wxFont& font1 = dc.GetFont();
if (font1.IsOk() && font.IsOk())
{
font1.GetStyle() == font.GetStyle() &&
font1.GetWeight() == font.GetWeight() &&
font1.GetUnderlined() == font.GetUnderlined() &&
+ font1.GetFamily() == font.GetFamily() &&
font1.GetFaceName() == font.GetFaceName())
return;
}
+#endif
dc.SetFont(font);
}
while (node)
{
wxRichTextObject* child = node->GetData();
- if (!child->GetRange().IsOutside(range))
+ if (range == wxRICHTEXT_ALL || !child->GetRange().IsOutside(range))
{
wxRichTextCompositeObject* composite = wxDynamicCast(child, wxRichTextCompositeObject);
if (composite)
}
}
+ if (style.HasFontFamily() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FAMILY))
+ {
+ if (currentStyle.HasFontFamily())
+ {
+ if (currentStyle.GetFontFamily() != style.GetFontFamily())
+ {
+ // Clash of style - mark as such
+ multipleStyleAttributes |= wxTEXT_ATTR_FONT_FAMILY;
+ currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_FAMILY);
+ }
+ }
+ else
+ {
+ currentStyle.SetFontFamily(style.GetFontFamily());
+ }
+ }
+
if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
{
if (currentStyle.HasFontWeight())
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
#endif
}
// Get line height from first line, if any
- wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : (wxRichTextLine*) NULL;
+ wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : NULL;
wxPoint linePos;
int lineHeight wxDUMMY_INITIALIZE(0);
wxSize actualSize;
wxRichTextRange actualRange(lastCompletedEndPos+1, wrapPosition);
+ /// Use previous descent, not the wrapping descent we just found, since this may be too big
+ /// for the fragment we're about to add.
+ childDescent = maxDescent;
+
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
// Get height only, then the width using the partial extents
GetRangeSize(actualRange, actualSize, childDescent, dc, wxRICHTEXT_UNFORMATTED|wxRICHTEXT_HEIGHT_ONLY);
ClearUnusedLines(lineCount);
// Apply styles to wrapped lines
- ApplyParagraphStyle(attr, rect);
+ ApplyParagraphStyle(attr, rect, dc);
SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara));
}
/// Apply paragraph styles, such as centering, to wrapped lines
-void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect)
+void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc)
{
if (!attr.HasAlignment())
return;
// centering, right-justification
if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
{
- pos.x = (rect.GetWidth() - size.x)/2 + pos.x;
+ int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
+ pos.x = (rect.GetWidth() - (pos.x - rect.x) - rightIndent - size.x)/2 + pos.x;
+ // Lines are relative to the paragraph position
+ pos.x -= GetPosition().x;
line->SetPosition(pos);
}
else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
{
- pos.x = pos.x + rect.GetWidth() - size.x;
+ int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
+ pos.x = rect.x + rect.GetWidth() - size.x - rightIndent;
+ // Lines are relative to the paragraph position
+ pos.x -= GetPosition().x;
line->SetPosition(pos);
}
text += textObj->GetTextForRange(range);
}
else
- return true;
+ {
+ text += wxT(" ");
+ }
}
node = node->GetNext();
text = textObj->GetTextForRange(range) + text;
}
else
- return true;
+ {
+ text = wxT(" ") + text;
+ }
}
node = node->GetPrevious();
widthBefore = 0;
size_t i;
- for (i = (size_t) range.GetStart(); i < (size_t) range.GetEnd(); i++)
+ for (i = (size_t) range.GetStart(); i <= (size_t) range.GetEnd(); i++)
{
int widthFromStartOfThisRange = (*partialExtents)[i - GetRange().GetStart()] - widthBefore;
{
if (para && para->GetRange().GetEnd() == pos)
pos1 ++;
+
+ // Now see if we need to number the paragraph.
if (newPara->GetAttributes().HasBulletNumber())
- newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1);
+ {
+ wxRichTextAttr numberingAttr;
+ if (FindNextParagraphNumber(para, numberingAttr))
+ wxRichTextApplyStyle(newPara->GetAttributes(), (const wxRichTextAttr&) numberingAttr);
+ }
}
action->SetPosition(pos);
}
}
}
+
+ // Also apply list style if present
+ if (lookUpNewParaStyle && !para->GetAttributes().GetListStyleName().IsEmpty() && GetStyleSheet())
+ {
+ wxRichTextListStyleDefinition* listDef = GetStyleSheet()->FindListStyle(para->GetAttributes().GetListStyleName());
+ if (listDef)
+ {
+ int thisIndent = para->GetAttributes().GetLeftIndent();
+ int thisLevel = para->GetAttributes().HasOutlineLevel() ? para->GetAttributes().GetOutlineLevel() : listDef->FindLevelForIndent(thisIndent);
+
+ // Apply the overall list style, and item style for this level
+ wxRichTextAttr listStyle(listDef->GetCombinedStyleForLevel(thisLevel, GetStyleSheet()));
+ wxRichTextApplyStyle(attr, listStyle);
+ attr.SetOutlineLevel(thisLevel);
+ if (para->GetAttributes().HasBulletNumber())
+ attr.SetBulletNumber(para->GetAttributes().GetBulletNumber());
+ }
+ }
+
if (!foundAttributes)
{
attr = para->GetAttributes();
attr.SetFlags(flags);
}
- // Now see if we need to number the paragraph.
- if (attr.HasBulletStyle())
- {
- wxTextAttr numberingAttr;
- if (FindNextParagraphNumber(para, numberingAttr))
- wxRichTextApplyStyle(attr, (const wxTextAttr&) numberingAttr);
- }
-
return attr;
}
else
bool wxRichTextBuffer::BeginBold()
{
wxTextAttr attr;
- attr.SetFontWeight(wxBOLD);
+ attr.SetFontWeight(wxFONTWEIGHT_BOLD);
return BeginStyle(attr);
}
bool wxRichTextBuffer::BeginItalic()
{
wxTextAttr attr;
- attr.SetFontStyle(wxITALIC);
+ attr.SetFontStyle(wxFONTSTYLE_ITALIC);
return BeginStyle(attr);
}
else if (!filename.IsEmpty())
{
wxString path, file, ext;
- wxSplitPath(filename, & path, & file, & ext);
+ wxFileName::SplitPath(filename, & path, & file, & ext);
return FindHandler(ext, imageType);
}
else
/// Make block from the wxImage
bool wxRichTextImage::MakeBlock()
{
- if (m_imageBlock.GetImageType() == wxBITMAP_TYPE_ANY || m_imageBlock.GetImageType() == -1)
- m_imageBlock.SetImageType(wxBITMAP_TYPE_PNG);
+ wxBitmapType type = m_imageBlock.GetImageType();
+ if ( type == wxBITMAP_TYPE_ANY || type == wxBITMAP_TYPE_INVALID )
+ m_imageBlock.SetImageType(type = wxBITMAP_TYPE_PNG);
- m_imageBlock.MakeImageBlock(m_image, m_imageBlock.GetImageType());
+ m_imageBlock.MakeImageBlock(m_image, type);
return m_imageBlock.Ok();
}
bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
{
wxString path, file, ext;
- wxSplitPath(filename, & path, & file, & ext);
+ wxFileName::SplitPath(filename, & path, & file, & ext);
return (ext.Lower() == GetExtension());
}
wxString filenameToRead(filename);
bool removeFile = false;
- if (imageType == -1)
+ if (imageType == wxBITMAP_TYPE_INVALID)
return false; // Could not determine image type
if ((imageType != wxBITMAP_TYPE_JPEG) && convertToJPEG)
{
- wxString tempFile;
- bool success = wxGetTempFileName(_("image"), tempFile) ;
-
- wxASSERT(success);
+ wxString tempFile =
+ wxFileName::CreateTempFileName(_("image"));
- wxUnusedVar(success);
+ wxASSERT(!tempFile.IsEmpty());
image.SaveFile(tempFile, wxBITMAP_TYPE_JPEG);
filenameToRead = tempFile;
m_imageType = imageType;
image.SetOption(wxT("quality"), quality);
- if (imageType == -1)
+ if (imageType == wxBITMAP_TYPE_INVALID)
return false; // Could not determine image type
- wxString tempFile;
- bool success = wxGetTempFileName(_("image"), tempFile) ;
-
- wxASSERT(success);
- wxUnusedVar(success);
+ wxString tempFile = wxFileName::CreateTempFileName(_("image")) ;
+ wxASSERT(!tempFile.IsEmpty());
if (!image.SaveFile(tempFile, m_imageType))
{
wxMemoryInputStream mstream(m_data, m_dataSize);
bool success = image.LoadFile(mstream, GetImageType());
#else
- wxString tempFile;
- bool success = wxGetTempFileName(_("image"), tempFile) ;
- wxASSERT(success);
+ wxString tempFile = wxFileName::CreateTempFileName(_("image"));
+ wxASSERT(!tempFile.IsEmpty());
if (!WriteBlock(tempFile, m_data, m_dataSize))
{
if (m_data)
delete[] m_data;
- wxChar str[2];
+ // create a null terminated temporary string:
+ char str[3];
+ str[2] = '\0';
+
m_data = new unsigned char[dataSize];
int i;
for (i = 0; i < dataSize; i ++)