Fixed a problem with tabs when text spills over the end of the tab stops

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-02-20 12:54:44 +00:00
parent b5c3f53e15
commit 4794d69c84

View File

@@ -4165,6 +4165,9 @@ wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject*
#define USE_KERNING_FIX 1 #define USE_KERNING_FIX 1
// If insufficient tabs are defined, this is the tab width used
#define WIDTH_FOR_DEFAULT_TABS 50
/// Draw the item /// Draw the item
bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int WXUNUSED(style)) bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int WXUNUSED(style))
{ {
@@ -4346,8 +4349,18 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, c
for (int i = 0; i < tabCount && not_found; ++i) for (int i = 0; i < tabCount && not_found; ++i)
{ {
nextTabPos = tabArray.Item(i); nextTabPos = tabArray.Item(i);
if (nextTabPos > tabPos)
// Find the next tab position.
// Even if we're at the end of the tab array, we must still draw the chunk.
if (nextTabPos > tabPos || (i == (tabCount - 1)))
{ {
if (nextTabPos <= tabPos)
{
int defaultTabWidth = ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS);
nextTabPos = tabPos + defaultTabWidth;
}
not_found = false; not_found = false;
if (selected) if (selected)
{ {
@@ -4473,12 +4486,23 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
dc.GetTextExtent(stringFragment, & w, & h); dc.GetTextExtent(stringFragment, & w, & h);
width += w; width += w;
int absoluteWidth = width + position.x; int absoluteWidth = width + position.x;
bool notFound = true; bool notFound = true;
for (int i = 0; i < tabCount && notFound; ++i) for (int i = 0; i < tabCount && notFound; ++i)
{ {
nextTabPos = tabArray.Item(i); nextTabPos = tabArray.Item(i);
if (nextTabPos > absoluteWidth)
// Find the next tab position.
// Even if we're at the end of the tab array, we must still process the chunk.
if (nextTabPos > absoluteWidth || (i == (tabCount - 1)))
{ {
if (nextTabPos <= absoluteWidth)
{
int defaultTabWidth = ((wxRichTextPlainText*) this)->ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS);
nextTabPos = absoluteWidth + defaultTabWidth;
}
notFound = false; notFound = false;
width = nextTabPos - position.x; width = nextTabPos - position.x;
} }