Added extra hit test style for more accurate reporting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-01-28 16:57:07 +00:00
parent c0623ba670
commit 4ea7392787
4 changed files with 123 additions and 120 deletions

View File

@@ -606,6 +606,8 @@ The function returns one of the following values:
#define wxRICHTEXT_HITTEST_AFTER 0x04 #define wxRICHTEXT_HITTEST_AFTER 0x04
// The point was on the position returned from HitTest // The point was on the position returned from HitTest
#define wxRICHTEXT_HITTEST_ON 0x08 #define wxRICHTEXT_HITTEST_ON 0x08
// The point was on space outside content
#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
\end{verbatim} \end{verbatim}
} }

View File

@@ -139,6 +139,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
#define wxRICHTEXT_HITTEST_AFTER 0x04 #define wxRICHTEXT_HITTEST_AFTER 0x04
// The point was on the position returned from HitTest // The point was on the position returned from HitTest
#define wxRICHTEXT_HITTEST_ON 0x08 #define wxRICHTEXT_HITTEST_ON 0x08
// The point was on space outside content
#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
/*! /*!
* Flags for GetRangeSize * Flags for GetRangeSize

View File

@@ -906,7 +906,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
// Don't use the base style, just the default style, and the base style will // Don't use the base style, just the default style, and the base style will
// be combined at display time. // be combined at display time.
// Divide into paragraph and character styles. // Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle; wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle; wxTextAttrEx defaultParaStyle;
@@ -930,7 +930,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
// Don't use the base style, just the default style, and the base style will // Don't use the base style, just the default style, and the base style will
// be combined at display time. // be combined at display time.
// Divide into paragraph and character styles. // Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle; wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle; wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle); wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
@@ -993,7 +993,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxT
// Don't use the base style, just the default style, and the base style will // Don't use the base style, just the default style, and the base style will
// be combined at display time. // be combined at display time.
// Divide into paragraph and character styles. // Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle; wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle; wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle); wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
@@ -2221,7 +2221,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
{ {
// We need to find the bits in the new style that are different: // We need to find the bits in the new style that are different:
// just look at those bits that are specified by the new style. // just look at those bits that are specified by the new style.
int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags(); int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags(); int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
@@ -2229,7 +2229,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
{ {
// Find the text effects that were different, using XOR // Find the text effects that were different, using XOR
int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects; int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects;
// Clash of style - mark as such // Clash of style - mark as such
multipleTextEffectAttributes |= differentEffects; multipleTextEffectAttributes |= differentEffects;
currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects); currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects);
@@ -2271,7 +2271,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
// The attributes that aren't valid because of multiple styles within the range // The attributes that aren't valid because of multiple styles within the range
long multipleStyleAttributes = 0; long multipleStyleAttributes = 0;
int multipleTextEffectAttributes = 0; int multipleTextEffectAttributes = 0;
wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst(); wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
while (node) while (node)
{ {
@@ -2433,7 +2433,7 @@ void wxRichTextParagraphLayoutBox::Reset()
Clear(); Clear();
AddParagraph(wxEmptyString); AddParagraph(wxEmptyString);
Invalidate(wxRICHTEXT_ALL); Invalidate(wxRICHTEXT_ALL);
} }
@@ -2565,7 +2565,7 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel) bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel)
{ {
wxRichTextStyleSheet* styleSheet = GetStyleSheet(); wxRichTextStyleSheet* styleSheet = GetStyleSheet();
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0); bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0); // bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0); bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
@@ -2923,7 +2923,7 @@ bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph*
{ {
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE) if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
return false; return false;
wxRichTextStyleSheet* styleSheet = GetStyleSheet(); wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (styleSheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty()) if (styleSheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty())
{ {
@@ -2932,7 +2932,7 @@ bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph*
{ {
// int thisIndent = previousParagraph->GetAttributes().GetLeftIndent(); // int thisIndent = previousParagraph->GetAttributes().GetLeftIndent();
// int thisLevel = def->FindLevelForIndent(thisIndent); // int thisLevel = def->FindLevelForIndent(thisIndent);
bool isOutline = (previousParagraph->GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) != 0; bool isOutline = (previousParagraph->GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) != 0;
attr.SetFlags(previousParagraph->GetAttributes().GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME)); attr.SetFlags(previousParagraph->GetAttributes().GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME));
@@ -2940,10 +2940,10 @@ bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph*
attr.SetBulletName(previousParagraph->GetAttributes().GetBulletName()); attr.SetBulletName(previousParagraph->GetAttributes().GetBulletName());
attr.SetBulletStyle(previousParagraph->GetAttributes().GetBulletStyle()); attr.SetBulletStyle(previousParagraph->GetAttributes().GetBulletStyle());
attr.SetListStyleName(previousParagraph->GetAttributes().GetListStyleName()); attr.SetListStyleName(previousParagraph->GetAttributes().GetListStyleName());
int nextNumber = previousParagraph->GetAttributes().GetBulletNumber() + 1; int nextNumber = previousParagraph->GetAttributes().GetBulletNumber() + 1;
attr.SetBulletNumber(nextNumber); attr.SetBulletNumber(nextNumber);
if (isOutline) if (isOutline)
{ {
wxString text = previousParagraph->GetAttributes().GetBulletText(); wxString text = previousParagraph->GetAttributes().GetBulletText();
@@ -2962,7 +2962,7 @@ bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph*
attr.SetBulletText(text); attr.SetBulletText(text);
} }
} }
return true; return true;
} }
else else
@@ -3059,15 +3059,15 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
if (wxRichTextBuffer::GetRenderer()) if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawBitmapBullet(this, dc, bulletAttr, bulletRect); wxRichTextBuffer::GetRenderer()->DrawBitmapBullet(this, dc, bulletAttr, bulletRect);
} }
else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD) else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD)
{ {
if (wxRichTextBuffer::GetRenderer()) if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawStandardBullet(this, dc, bulletAttr, bulletRect); wxRichTextBuffer::GetRenderer()->DrawStandardBullet(this, dc, bulletAttr, bulletRect);
} }
else else
{ {
wxString bulletText = GetBulletText(); wxString bulletText = GetBulletText();
if (!bulletText.empty() && wxRichTextBuffer::GetRenderer()) if (!bulletText.empty() && wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawTextBullet(this, dc, bulletAttr, bulletRect, bulletText); wxRichTextBuffer::GetRenderer()->DrawTextBullet(this, dc, bulletAttr, bulletRect, bulletText);
} }
@@ -3094,7 +3094,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
while (node2) while (node2)
{ {
wxRichTextObject* child = node2->GetData(); wxRichTextObject* child = node2->GetData();
if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range)) if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
{ {
// Draw this part of the line at the correct position // Draw this part of the line at the correct position
@@ -3207,17 +3207,17 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
// We may only be looking at part of a child, if we searched back for wrapping // We may only be looking at part of a child, if we searched back for wrapping
// and found a suitable point some way into the child. So get the size for the fragment // and found a suitable point some way into the child. So get the size for the fragment
// if necessary. // if necessary.
long nextBreakPos = GetFirstLineBreakPosition(lastEndPos+1); long nextBreakPos = GetFirstLineBreakPosition(lastEndPos+1);
long lastPosToUse = child->GetRange().GetEnd(); long lastPosToUse = child->GetRange().GetEnd();
bool lineBreakInThisObject = (nextBreakPos > -1 && nextBreakPos <= child->GetRange().GetEnd()); bool lineBreakInThisObject = (nextBreakPos > -1 && nextBreakPos <= child->GetRange().GetEnd());
if (lineBreakInThisObject) if (lineBreakInThisObject)
lastPosToUse = nextBreakPos; lastPosToUse = nextBreakPos;
wxSize childSize; wxSize childSize;
int childDescent = 0; int childDescent = 0;
if ((nextBreakPos == -1) && (lastEndPos == child->GetRange().GetStart() - 1)) // i.e. we want to get the whole thing if ((nextBreakPos == -1) && (lastEndPos == child->GetRange().GetStart() - 1)) // i.e. we want to get the whole thing
{ {
childSize = child->GetCachedSize(); childSize = child->GetCachedSize();
@@ -3668,12 +3668,12 @@ int wxRichTextParagraph::HitTest(wxDC& dc, const wxPoint& pt, long& textPosition
if (pt.x < linePos.x) if (pt.x < linePos.x)
{ {
textPosition = lineRange.GetStart(); textPosition = lineRange.GetStart();
return wxRICHTEXT_HITTEST_BEFORE; return wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_OUTSIDE;
} }
else if (pt.x >= (linePos.x + lineSize.x)) else if (pt.x >= (linePos.x + lineSize.x))
{ {
textPosition = lineRange.GetEnd(); textPosition = lineRange.GetEnd();
return wxRICHTEXT_HITTEST_AFTER; return wxRICHTEXT_HITTEST_AFTER|wxRICHTEXT_HITTEST_OUTSIDE;
} }
else else
{ {
@@ -3960,7 +3960,7 @@ wxString wxRichTextParagraph::GetBulletText()
{ {
text = GetAttributes().GetBulletText(); text = GetAttributes().GetBulletText();
} }
if (GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) if (GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE)
{ {
// The outline style relies on the text being computed statically, // The outline style relies on the text being computed statically,
@@ -4168,7 +4168,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
wxString str = m_text; wxString str = m_text;
wxString toRemove = wxRichTextLineBreakChar; wxString toRemove = wxRichTextLineBreakChar;
str.Replace(toRemove, wxT(" ")); str.Replace(toRemove, wxT(" "));
long len = range.GetLength(); long len = range.GetLength();
wxString stringChunk = str.Mid(range.GetStart() - offset, (size_t) len); wxString stringChunk = str.Mid(range.GetStart() - offset, (size_t) len);
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS)) if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS))
@@ -4395,7 +4395,7 @@ bool wxRichTextPlainText::Layout(wxDC& dc, const wxRect& WXUNUSED(rect), int WXU
if (textAttr.GetFont().Ok()) if (textAttr.GetFont().Ok())
dc.SetFont(textAttr.GetFont()); dc.SetFont(textAttr.GetFont());
wxString str = m_text; wxString str = m_text;
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS)) if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS))
str.MakeUpper(); str.MakeUpper();
@@ -4438,7 +4438,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
int startPos = range.GetStart() - GetRange().GetStart(); int startPos = range.GetStart() - GetRange().GetStart();
long len = range.GetLength(); long len = range.GetLength();
wxString str(m_text); wxString str(m_text);
wxString toReplace = wxRichTextLineBreakChar; wxString toReplace = wxRichTextLineBreakChar;
str.Replace(toReplace, wxT(" ")); str.Replace(toReplace, wxT(" "));
@@ -4503,7 +4503,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
wxRichTextObject* wxRichTextPlainText::DoSplit(long pos) wxRichTextObject* wxRichTextPlainText::DoSplit(long pos)
{ {
long index = pos - GetRange().GetStart(); long index = pos - GetRange().GetStart();
if (index < 0 || index >= (int) m_text.length()) if (index < 0 || index >= (int) m_text.length())
return NULL; return NULL;
@@ -4517,7 +4517,7 @@ wxRichTextObject* wxRichTextPlainText::DoSplit(long pos)
newObject->SetRange(wxRichTextRange(pos, GetRange().GetEnd())); newObject->SetRange(wxRichTextRange(pos, GetRange().GetEnd()));
GetRange().SetEnd(pos-1); GetRange().SetEnd(pos-1);
return newObject; return newObject;
} }
@@ -4646,7 +4646,7 @@ wxRichTextBuffer::~wxRichTextBuffer()
void wxRichTextBuffer::ResetAndClearCommands() void wxRichTextBuffer::ResetAndClearCommands()
{ {
Reset(); Reset();
GetCommandProcessor()->ClearCommands(); GetCommandProcessor()->ClearCommands();
Modify(false); Modify(false);
@@ -4849,7 +4849,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
{ {
wxRichTextAttr attr; wxRichTextAttr attr;
bool foundAttributes = false; bool foundAttributes = false;
// Look for a matching paragraph style // Look for a matching paragraph style
if (lookUpNewParaStyle && !para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet()) if (lookUpNewParaStyle && !para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet())
{ {
@@ -4865,7 +4865,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
attr = nextParaDef->GetStyleMergedWithBase(GetStyleSheet()); attr = nextParaDef->GetStyleMergedWithBase(GetStyleSheet());
} }
} }
// If we didn't find the 'next style', use this style instead. // If we didn't find the 'next style', use this style instead.
if (!foundAttributes) if (!foundAttributes)
{ {
@@ -4885,7 +4885,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
(~ wxTEXT_ATTR_BACKGROUND_COLOUR) ); (~ wxTEXT_ATTR_BACKGROUND_COLOUR) );
attr.SetFlags(flags); attr.SetFlags(flags);
} }
// Now see if we need to number the paragraph. // Now see if we need to number the paragraph.
if (attr.HasBulletStyle()) if (attr.HasBulletStyle())
{ {
@@ -5650,7 +5650,7 @@ bool wxRichTextBuffer::RemoveEventHandler(wxEvtHandler* handler, bool deleteHand
m_eventHandlers.Erase(node); m_eventHandlers.Erase(node);
if (deleteHandler) if (deleteHandler)
delete handler; delete handler;
return true; return true;
} }
else else
@@ -5685,17 +5685,17 @@ bool wxRichTextBuffer::SendEvent(wxEvent& event, bool sendToAll)
bool wxRichTextBuffer::SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet) bool wxRichTextBuffer::SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet)
{ {
wxRichTextStyleSheet* oldSheet = GetStyleSheet(); wxRichTextStyleSheet* oldSheet = GetStyleSheet();
wxWindowID id = wxID_ANY; wxWindowID id = wxID_ANY;
if (GetRichTextCtrl()) if (GetRichTextCtrl())
id = GetRichTextCtrl()->GetId(); id = GetRichTextCtrl()->GetId();
wxRichTextEvent event(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id); wxRichTextEvent event(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id);
event.SetEventObject(GetRichTextCtrl()); event.SetEventObject(GetRichTextCtrl());
event.SetOldStyleSheet(oldSheet); event.SetOldStyleSheet(oldSheet);
event.SetNewStyleSheet(sheet); event.SetNewStyleSheet(sheet);
event.Allow(); event.Allow();
if (SendEvent(event) && !event.IsAllowed()) if (SendEvent(event) && !event.IsAllowed())
{ {
if (sheet != oldSheet) if (sheet != oldSheet)
@@ -5746,26 +5746,26 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w
dc.SetFont(font); dc.SetFont(font);
int charHeight = dc.GetCharHeight(); int charHeight = dc.GetCharHeight();
int bulletWidth = (int) (((float) charHeight) * wxRichTextBuffer::GetBulletProportion()); int bulletWidth = (int) (((float) charHeight) * wxRichTextBuffer::GetBulletProportion());
int bulletHeight = bulletWidth; int bulletHeight = bulletWidth;
int x = rect.x; int x = rect.x;
// Calculate the top position of the character (as opposed to the whole line height) // Calculate the top position of the character (as opposed to the whole line height)
int y = rect.y + (rect.height - charHeight); int y = rect.y + (rect.height - charHeight);
// Calculate where the bullet should be positioned // Calculate where the bullet should be positioned
y = y + (charHeight+1)/2 - (bulletHeight+1)/2; y = y + (charHeight+1)/2 - (bulletHeight+1)/2;
// The margin between a bullet and text. // The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin()); int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT) if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = rect.x + rect.width - bulletWidth - margin; x = rect.x + rect.width - bulletWidth - margin;
else if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE) else if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - bulletWidth/2; x = x + (rect.width)/2 - bulletWidth/2;
if (bulletAttr.GetBulletName() == wxT("standard/square")) if (bulletAttr.GetBulletName() == wxT("standard/square"))
{ {
dc.DrawRectangle(x, y, bulletWidth, bulletHeight); dc.DrawRectangle(x, y, bulletWidth, bulletHeight);
@@ -5777,7 +5777,7 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w
pts[1].x = x + bulletWidth/2; pts[1].y = y; pts[1].x = x + bulletWidth/2; pts[1].y = y;
pts[2].x = x + bulletWidth; pts[2].y = y + bulletHeight/2; pts[2].x = x + bulletWidth; pts[2].y = y + bulletHeight/2;
pts[3].x = x + bulletWidth/2; pts[3].y = y + bulletHeight; pts[3].x = x + bulletWidth/2; pts[3].y = y + bulletHeight;
dc.DrawPolygon(4, pts); dc.DrawPolygon(4, pts);
} }
else if (bulletAttr.GetBulletName() == wxT("standard/triangle")) else if (bulletAttr.GetBulletName() == wxT("standard/triangle"))
@@ -5786,14 +5786,14 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w
pts[0].x = x; pts[0].y = y; pts[0].x = x; pts[0].y = y;
pts[1].x = x + bulletWidth; pts[1].y = y + bulletHeight/2; pts[1].x = x + bulletWidth; pts[1].y = y + bulletHeight/2;
pts[2].x = x; pts[2].y = y + bulletHeight; pts[2].x = x; pts[2].y = y + bulletHeight;
dc.DrawPolygon(3, pts); dc.DrawPolygon(3, pts);
} }
else // "standard/circle", and catch-all else // "standard/circle", and catch-all
{ {
dc.DrawEllipse(x, y, bulletWidth, bulletHeight); dc.DrawEllipse(x, y, bulletWidth, bulletHeight);
} }
return true; return true;
} }
@@ -5827,18 +5827,18 @@ bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC&
int x = rect.x; int x = rect.x;
// Calculate the top position of the character (as opposed to the whole line height) // Calculate the top position of the character (as opposed to the whole line height)
int y = rect.y + (rect.height - charHeight); int y = rect.y + (rect.height - charHeight);
// The margin between a bullet and text. // The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin()); int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT) if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = (rect.x + rect.width) - tw - margin; x = (rect.x + rect.width) - tw - margin;
else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE) else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - tw/2; x = x + (rect.width)/2 - tw/2;
dc.DrawText(text, x, y); dc.DrawText(text, x, y);
return true; return true;
} }
else else
@@ -6005,7 +6005,7 @@ bool wxRichTextAction::Do()
wxSize clientSize = m_ctrl->GetClientSize(); wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint(); wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
int lastY = firstVisiblePt.y + clientSize.y; int lastY = firstVisiblePt.y + clientSize.y;
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition()); wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para); wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node) while (node)
@@ -6017,14 +6017,14 @@ bool wxRichTextAction::Do()
wxRichTextLine* line = node2->GetData(); wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition(); wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange(); wxRichTextRange range = line->GetAbsoluteRange();
if (pt.y > lastY) if (pt.y > lastY)
{ {
node2 = wxRichTextLineList::compatibility_iterator(); node2 = wxRichTextLineList::compatibility_iterator();
node = wxRichTextObjectList::compatibility_iterator(); node = wxRichTextObjectList::compatibility_iterator();
} }
else if (range.GetStart() > GetPosition() && pt.y >= firstVisiblePt.y) else if (range.GetStart() > GetPosition() && pt.y >= firstVisiblePt.y)
{ {
optimizationLineCharPositions.Add(range.GetStart()); optimizationLineCharPositions.Add(range.GetStart());
optimizationLineYPositions.Add(pt.y); optimizationLineYPositions.Add(pt.y);
} }
@@ -6032,11 +6032,11 @@ bool wxRichTextAction::Do()
if (node2) if (node2)
node2 = node2->GetNext(); node2 = node2->GetNext();
} }
if (node) if (node)
node = node->GetNext(); node = node->GetNext();
} }
} }
#endif #endif
m_buffer->InsertFragment(GetPosition(), m_newParagraphs); m_buffer->InsertFragment(GetPosition(), m_newParagraphs);
@@ -6059,20 +6059,20 @@ bool wxRichTextAction::Do()
newCaretPosition --; newCaretPosition --;
} }
newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1)); newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1));
if (optimizationLineCharPositions.GetCount() > 0) if (optimizationLineCharPositions.GetCount() > 0)
UpdateAppearance(newCaretPosition, true /* send update event */, & optimizationLineCharPositions, & optimizationLineYPositions); UpdateAppearance(newCaretPosition, true /* send update event */, & optimizationLineCharPositions, & optimizationLineYPositions);
else else
UpdateAppearance(newCaretPosition, true /* send update event */); UpdateAppearance(newCaretPosition, true /* send update event */);
wxRichTextEvent cmdEvent( wxRichTextEvent cmdEvent(
wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED,
m_ctrl ? m_ctrl->GetId() : -1); m_ctrl ? m_ctrl->GetId() : -1);
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6091,7 +6091,7 @@ bool wxRichTextAction::Do()
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6109,7 +6109,7 @@ bool wxRichTextAction::Do()
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6134,7 +6134,7 @@ bool wxRichTextAction::Undo()
m_buffer->Invalidate(wxRichTextRange(GetRange().GetStart(), GetRange().GetStart())); m_buffer->Invalidate(wxRichTextRange(GetRange().GetStart(), GetRange().GetStart()));
long newCaretPosition = GetPosition() - 1; long newCaretPosition = GetPosition() - 1;
UpdateAppearance(newCaretPosition, true /* send update event */); UpdateAppearance(newCaretPosition, true /* send update event */);
wxRichTextEvent cmdEvent( wxRichTextEvent cmdEvent(
@@ -6143,7 +6143,7 @@ bool wxRichTextAction::Undo()
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6162,7 +6162,7 @@ bool wxRichTextAction::Undo()
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6180,7 +6180,7 @@ bool wxRichTextAction::Undo()
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer); cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange()); cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart()); cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent); m_buffer->SendEvent(cmdEvent);
break; break;
@@ -6202,30 +6202,30 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
{ {
m_ctrl->LayoutContent(); m_ctrl->LayoutContent();
m_ctrl->PositionCaret(); m_ctrl->PositionCaret();
#if wxRICHTEXT_USE_OPTIMIZED_DRAWING #if wxRICHTEXT_USE_OPTIMIZED_DRAWING
// Find refresh rectangle if we are in a position to optimise refresh // Find refresh rectangle if we are in a position to optimise refresh
if (m_cmdId == wxRICHTEXT_INSERT && optimizationLineCharPositions && optimizationLineCharPositions->GetCount() > 0) if (m_cmdId == wxRICHTEXT_INSERT && optimizationLineCharPositions && optimizationLineCharPositions->GetCount() > 0)
{ {
size_t i; size_t i;
wxSize clientSize = m_ctrl->GetClientSize(); wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint(); wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
// Start/end positions // Start/end positions
int firstY = 0; int firstY = 0;
int lastY = firstVisiblePt.y + clientSize.y; int lastY = firstVisiblePt.y + clientSize.y;
bool foundStart = false; bool foundStart = false;
bool foundEnd = false; bool foundEnd = false;
// position offset - how many characters were inserted // position offset - how many characters were inserted
int positionOffset = GetRange().GetLength(); int positionOffset = GetRange().GetLength();
// find the first line which is being drawn at the same position as it was // find the first line which is being drawn at the same position as it was
// before. Since we're talking about a simple insertion, we can assume // before. Since we're talking about a simple insertion, we can assume
// that the rest of the window does not need to be redrawn. // that the rest of the window does not need to be redrawn.
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition()); wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para); wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node) while (node)
@@ -6237,10 +6237,10 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
wxRichTextLine* line = node2->GetData(); wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition(); wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange(); wxRichTextRange range = line->GetAbsoluteRange();
// we want to find the first line that is in the same position // we want to find the first line that is in the same position
// as before. This will mean we're at the end of the changed text. // as before. This will mean we're at the end of the changed text.
if (pt.y > lastY) // going past the end of the window, no more info if (pt.y > lastY) // going past the end of the window, no more info
{ {
node2 = wxRichTextLineList::compatibility_iterator(); node2 = wxRichTextLineList::compatibility_iterator();
@@ -6254,7 +6254,7 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
foundStart = true; foundStart = true;
} }
// search for this line being at the same position as before // search for this line being at the same position as before
for (i = 0; i < optimizationLineCharPositions->GetCount(); i++) for (i = 0; i < optimizationLineCharPositions->GetCount(); i++)
{ {
if (((*optimizationLineCharPositions)[i] + positionOffset == range.GetStart()) && if (((*optimizationLineCharPositions)[i] + positionOffset == range.GetStart()) &&
@@ -6268,18 +6268,18 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
node = wxRichTextObjectList::compatibility_iterator(); node = wxRichTextObjectList::compatibility_iterator();
break; break;
} }
} }
} }
if (node2) if (node2)
node2 = node2->GetNext(); node2 = node2->GetNext();
} }
if (node) if (node)
node = node->GetNext(); node = node->GetNext();
} }
if (!foundStart) if (!foundStart)
firstY = firstVisiblePt.y; firstY = firstVisiblePt.y;
if (!foundEnd) if (!foundEnd)
@@ -6287,12 +6287,12 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
wxRect rect(firstVisiblePt.x, firstY, firstVisiblePt.x + clientSize.x, lastY - firstY); wxRect rect(firstVisiblePt.x, firstY, firstVisiblePt.x + clientSize.x, lastY - firstY);
m_ctrl->RefreshRect(rect); m_ctrl->RefreshRect(rect);
// TODO: we need to make sure that lines are only drawn if in the update region. The rect // TODO: we need to make sure that lines are only drawn if in the update region. The rect
// passed to Draw is currently used in different ways (to pass the position the content should // passed to Draw is currently used in different ways (to pass the position the content should
// be drawn at as well as the relevant region). // be drawn at as well as the relevant region).
} }
else else
#endif #endif
m_ctrl->Refresh(false); m_ctrl->Refresh(false);
@@ -6846,9 +6846,9 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style)
int srcBits = style.GetTextEffects(); int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags(); int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits); destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags); destStyle.SetTextEffectFlags(destFlags);
} }
@@ -7082,9 +7082,9 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
int srcBits = style.GetTextEffects(); int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags(); int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits); destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags); destStyle.SetTextEffectFlags(destFlags);
} }
@@ -7105,17 +7105,17 @@ bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB)
// We want to apply B's bits to A, taking into account each's flags which indicate which bits // We want to apply B's bits to A, taking into account each's flags which indicate which bits
// are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags
// indicate it. // indicate it.
// First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero
// bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant. // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant.
int valueA2 = ~(~valueB & flagsB) & valueA; int valueA2 = ~(~valueB & flagsB) & valueA;
// Now combine the 1 bits. // Now combine the 1 bits.
int valueA3 = (valueB & flagsB) | valueA2; int valueA3 = (valueB & flagsB) | valueA2;
valueA = valueA3; valueA = valueA3;
flagsA = (flagsA | flagsB); flagsA = (flagsA | flagsB);
return true; return true;
} }
@@ -7137,7 +7137,7 @@ bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parS
wxRichTextApplyStyle(charStyle, defaultCharStyle1); wxRichTextApplyStyle(charStyle, defaultCharStyle1);
wxRichTextApplyStyle(parStyle, defaultParaStyle1); wxRichTextApplyStyle(parStyle, defaultParaStyle1);
return true; return true;
} }
@@ -7293,7 +7293,7 @@ void wxRichTextAttr::Copy(const wxRichTextAttr& attr)
// operators // operators
void wxRichTextAttr::operator= (const wxRichTextAttr& attr) void wxRichTextAttr::operator= (const wxRichTextAttr& attr)
{ {
Copy(attr); Copy(attr);
} }
@@ -7401,7 +7401,7 @@ bool wxRichTextAttr::operator== (const wxRichTextAttr& attr) const
GetFontWeight() == attr.GetFontWeight() && GetFontWeight() == attr.GetFontWeight() &&
GetFontUnderlined() == attr.GetFontUnderlined() && GetFontUnderlined() == attr.GetFontUnderlined() &&
GetFontFaceName() == attr.GetFontFaceName() && GetFontFaceName() == attr.GetFontFaceName() &&
GetURL() == attr.GetURL(); GetURL() == attr.GetURL();
} }
@@ -7434,14 +7434,14 @@ wxRichTextAttr wxRichTextAttr::Combine(const wxRichTextAttr& style, const wxRich
{ {
wxRichTextAttr destStyle = (*this); wxRichTextAttr destStyle = (*this);
destStyle.Apply(style, compareWith); destStyle.Apply(style, compareWith);
return destStyle; return destStyle;
} }
bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith) bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith)
{ {
wxRichTextAttr& destStyle = (*this); wxRichTextAttr& destStyle = (*this);
if (style.HasFontWeight()) if (style.HasFontWeight())
{ {
if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())) if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight()))
@@ -7593,9 +7593,9 @@ bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* co
int srcBits = style.GetTextEffects(); int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags(); int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits); destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags); destStyle.SetTextEffectFlags(destFlags);
} }
@@ -7942,7 +7942,7 @@ bool wxRichTextPlainTextHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputSt
wxString newLine = wxRichTextLineBreakChar; wxString newLine = wxRichTextLineBreakChar;
text.Replace(newLine, wxT("\n")); text.Replace(newLine, wxT("\n"));
wxCharBuffer buf = text.ToAscii(); wxCharBuffer buf = text.ToAscii();
stream.Write((const char*) buf, text.length()); stream.Write((const char*) buf, text.length());

View File

@@ -141,7 +141,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
GetBuffer().Reset(); GetBuffer().Reset();
GetBuffer().SetRichTextCtrl(this); GetBuffer().SetRichTextCtrl(this);
SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16)); SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16));
GetCaret()->Show(); GetCaret()->Show();
@@ -194,7 +194,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
wxRichTextCtrl::~wxRichTextCtrl() wxRichTextCtrl::~wxRichTextCtrl()
{ {
GetBuffer().RemoveEventHandler(this); GetBuffer().RemoveEventHandler(this);
delete m_contextMenu; delete m_contextMenu;
} }
@@ -328,7 +328,7 @@ void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event))
void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
{ {
m_dragging = false; m_dragging = false;
} }
/// Left-click /// Left-click
@@ -390,7 +390,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
long position = 0; long position = 0;
wxPoint logicalPt = event.GetLogicalPosition(dc); wxPoint logicalPt = event.GetLogicalPosition(dc);
int hit = GetBuffer().HitTest(dc, logicalPt, position); int hit = GetBuffer().HitTest(dc, logicalPt, position);
if (hit != wxRICHTEXT_HITTEST_NONE) if (hit != wxRICHTEXT_HITTEST_NONE)
{ {
wxTextAttrEx attr; wxTextAttrEx attr;
@@ -402,20 +402,20 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
if (!urlTarget.IsEmpty()) if (!urlTarget.IsEmpty())
{ {
wxMouseEvent mouseEvent(event); wxMouseEvent mouseEvent(event);
long startPos = 0, endPos = 0; long startPos = 0, endPos = 0;
wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position); wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position);
if (obj) if (obj)
{ {
startPos = obj->GetRange().GetStart(); startPos = obj->GetRange().GetStart();
endPos = obj->GetRange().GetEnd(); endPos = obj->GetRange().GetEnd();
} }
wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos); wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos);
InitCommandEvent(urlEvent); InitCommandEvent(urlEvent);
urlEvent.SetString(urlTarget); urlEvent.SetString(urlTarget);
GetEventHandler()->ProcessEvent(urlEvent); GetEventHandler()->ProcessEvent(urlEvent);
} }
} }
@@ -434,11 +434,11 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
long position = 0; long position = 0;
wxPoint logicalPt = event.GetLogicalPosition(dc); wxPoint logicalPt = event.GetLogicalPosition(dc);
int hit = GetBuffer().HitTest(dc, logicalPt, position); int hit = GetBuffer().HitTest(dc, logicalPt, position);
// See if we need to change the cursor // See if we need to change the cursor
{ {
if (hit != wxRICHTEXT_HITTEST_NONE) if (hit != wxRICHTEXT_HITTEST_NONE & !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
{ {
wxTextAttrEx attr; wxTextAttrEx attr;
if (GetStyle(position, attr)) if (GetStyle(position, attr))
@@ -453,6 +453,8 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
} }
} }
} }
else
SetCursor(m_textCursor);
} }
if (!event.Dragging()) if (!event.Dragging())
@@ -588,7 +590,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
// Generate conventional event // Generate conventional event
wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_ENTER, GetId()); wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_ENTER, GetId());
InitCommandEvent(textEvent); InitCommandEvent(textEvent);
GetEventHandler()->ProcessEvent(textEvent); GetEventHandler()->ProcessEvent(textEvent);
} }
Update(); Update();
@@ -596,7 +598,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
else if (event.GetKeyCode() == WXK_BACK) else if (event.GetKeyCode() == WXK_BACK)
{ {
BeginBatchUndo(_("Delete Text")); BeginBatchUndo(_("Delete Text"));
// Submit range in character positions, which are greater than caret positions, // Submit range in character positions, which are greater than caret positions,
// so subtract 1 for deleted character and add 1 for conversion to character position. // so subtract 1 for deleted character and add 1 for conversion to character position.
if (m_caretPosition > -1 && !HasSelection()) if (m_caretPosition > -1 && !HasSelection())
@@ -782,7 +784,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
cmdEvent.SetFlags(flags); cmdEvent.SetFlags(flags);
cmdEvent.SetCharacter((wxChar) keycode); cmdEvent.SetCharacter((wxChar) keycode);
cmdEvent.SetPosition(m_caretPosition+1); cmdEvent.SetPosition(m_caretPosition+1);
if (keycode == wxT('\t')) if (keycode == wxT('\t'))
{ {
// See if we need to promote or demote the selection or paragraph at the cursor // See if we need to promote or demote the selection or paragraph at the cursor
@@ -819,7 +821,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
SetDefaultStyleToCursorStyle(); SetDefaultStyleToCursorStyle();
ScrollIntoView(m_caretPosition, WXK_RIGHT); ScrollIntoView(m_caretPosition, WXK_RIGHT);
GetEventHandler()->ProcessEvent(cmdEvent); GetEventHandler()->ProcessEvent(cmdEvent);
Update(); Update();
@@ -1331,7 +1333,7 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags)
// we want to be at the end of the last line but with m_caretAtLineStart set to true, // we want to be at the end of the last line but with m_caretAtLineStart set to true,
// so we view the caret at the start of the line. // so we view the caret at the start of the line.
bool caretLineStart = false; bool caretLineStart = false;
if (hitTest == wxRICHTEXT_HITTEST_BEFORE) if (hitTest & wxRICHTEXT_HITTEST_BEFORE)
{ {
wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1); wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
wxRichTextRange lineRange; wxRichTextRange lineRange;
@@ -1975,17 +1977,14 @@ wxRichTextCtrl::HitTest(const wxPoint& pt,
int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos); int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
switch ( hit ) if ((hit & wxRICHTEXT_HITTEST_BEFORE) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
{ return wxTE_HT_BEFORE;
case wxRICHTEXT_HITTEST_BEFORE: else if ((hit & wxRICHTEXT_HITTEST_AFTER) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
return wxTE_HT_BEFORE; return wxTE_HT_BEYOND;
else if (hit & wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)
case wxRICHTEXT_HITTEST_AFTER: return wxTE_HT_ON_TEXT;
return wxTE_HT_BEYOND; else
return wxTE_HT_UNKNOWN;
case wxRICHTEXT_HITTEST_ON:
return wxTE_HT_ON_TEXT;
}
return wxTE_HT_UNKNOWN; return wxTE_HT_UNKNOWN;
} }