Now allows space for a bullet even if no left subindent was specified; added a MeasureBullet function to support this.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2015-02-18 12:18:27 +00:00
parent ac1d0a3a9d
commit 8cf3e90650
3 changed files with 76 additions and 2 deletions

View File

@ -6965,6 +6965,11 @@ public:
Enumerate the standard bullet names currently supported. This function should be overridden.
*/
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0;
/**
Measure the bullet.
*/
virtual bool MeasureBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, wxSize& sz) = 0;
};
/**
@ -6997,6 +7002,9 @@ public:
// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames);
// Measure the bullet.
virtual bool MeasureBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, wxSize& sz);
};
/*!

View File

@ -6749,6 +6749,11 @@ public:
Enumerate the standard bullet names currently supported. This function should be overridden.
*/
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0;
/**
Measure the bullet.
*/
virtual bool MeasureBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, wxSize& sz) = 0;
};
/**
@ -6781,6 +6786,9 @@ public:
// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames);
// Measure the bullet.
virtual bool MeasureBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, wxSize& sz);
};
/*!

View File

@ -4821,9 +4821,8 @@ bool wxRichTextParagraph::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
DrawBoxAttributes(dc, GetBuffer(), attr, paraRect, 0);
// Draw the bullet, if any
if ((attr.GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE) == 0 && (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_CONTINUATION) == 0)
if ((attr.GetBulletStyle() != wxTEXT_ATTR_BULLET_STYLE_NONE) && (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_CONTINUATION) == 0)
{
if (attr.GetLeftSubIndent() != 0)
{
int spaceBeforePara = ConvertTenthsMMToPixels(dc, attr.GetParagraphSpacingBefore());
int leftIndent = ConvertTenthsMMToPixels(dc, attr.GetLeftIndent());
@ -5019,6 +5018,22 @@ bool wxRichTextParagraph::Layout(wxDC& dc, wxRichTextDrawingContext& context, co
}
}
// Make space for a bullet with no subindent.
if ((leftIndent == 0) && (attr.GetBulletStyle() != wxTEXT_ATTR_BULLET_STYLE_NONE))
{
wxSize bulletSize;
if (wxRichTextBuffer::GetRenderer() && wxRichTextBuffer::GetRenderer()->MeasureBullet(this, dc, attr, bulletSize))
{
wxFont font(buffer->GetFontTable().FindFont(attr));
if (font.IsOk())
{
wxCheckSetFont(dc, font);
wxCoord spaceW = 0, spaceH = 0, maxDescent = 0;
dc.GetTextExtent(wxT(" "), & spaceW, & spaceH, & maxDescent);
leftSubIndent = bulletSize.x + spaceW;
}
}
}
// Start position for each line relative to the paragraph
int startPositionFirstLine = leftIndent;
int startPositionSubsequentLines = leftIndent + leftSubIndent;
@ -9233,6 +9248,49 @@ bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(parag
return false;
}
// Measure the bullet.
bool wxRichTextStdRenderer::MeasureBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, wxSize& sz)
{
wxFont font;
if (attr.HasFont())
{
font = paragraph->GetBuffer()->GetFontTable().FindFont(attr);
}
else
font = (*wxNORMAL_FONT);
wxCheckSetFont(dc, font);
if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD)
{
sz.x = (int) (((float) dc.GetCharHeight()) * wxRichTextBuffer::GetBulletProportion());
sz.y = sz.y;
}
else if (attr.HasBulletText())
{
wxCoord w, h, maxDescent;
dc.GetTextExtent(attr.GetBulletText(), & w, &h, & maxDescent);
sz.x = w;
sz.y = h;
}
else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP)
{
// A guess, at present.
sz.x = 10;
sz.y = 10;
}
else
{
// Need to guess a size for a number bullet.
wxCoord w, h, maxDescent;
dc.GetTextExtent(wxT("8888."), & w, &h, & maxDescent);
sz.x = w;
sz.y = h;
}
return true;
}
/// Enumerate the standard bullet names currently supported
bool wxRichTextStdRenderer::EnumerateStandardBulletNames(wxArrayString& bulletNames)
{