wxPoint
wxLayoutLine::RecalculatePosition(wxLayoutList *llist)
{
+ wxASSERT(m_Previous || GetLineNumber() == 0);
+
if(m_Previous)
- m_Position = m_Previous->GetPosition() +
- wxPoint(0,m_Previous->GetHeight());
+ {
+ m_Position = m_Previous->GetPosition();
+ m_Position.y += m_Previous->GetHeight();
+ }
else
m_Position = wxPoint(0,0);
llist->SetUpdateRect(m_Position);
if( x <= xpos && xpos <= x + width )
{
*cxpos = cx + (**i).GetOffsetScreen(dc, xpos-x);
- WXLO_DEBUG(("wxLayoutLine::FindObjectScreen: cursor xpos = %ld", *cxpos));
+// WXLO_DEBUG(("wxLayoutLine::FindObjectScreen: cursor xpos = %ld", *cxpos));
if(found) *found = true;
return i;
}
return m_ObjectList.tail();
}
+/** Finds text in this line.
+ @param needle the text to find
+ @param xpos the position where to start the search
+ @return the cursoor coord where it was found or -1
+*/
+CoordType
+wxLayoutLine::FindText(const wxString &needle, CoordType xpos = 0) const
+{
+ int
+ cpos = 0,
+ relpos = -1;
+ wxString const *text;
+
+ for(wxLOiterator i = m_ObjectList.begin(); i != m_ObjectList.end(); i++)
+ {
+ if(cpos >= xpos) // search from here!
+ {
+ if((**i).GetType() == WXLO_TYPE_TEXT)
+ {
+ text = & ((wxLayoutObjectText*)(*i))->GetText();
+ relpos = text->Find(needle);
+ if(relpos >= cpos-xpos) // -1 if not found
+ {
+ return cpos+relpos;
+ }
+ }
+ cpos += (**i).GetLength();
+ }
+ }
+ return -1; // not found
+}
+
bool
wxLayoutLine::Insert(CoordType xpos, wxLayoutObject *obj)
{
CoordType from, to, tempto;
int highlight = llist->IsSelected(this, &from, &to);
- WXLO_DEBUG(("highlight=%d", highlight ));
+// WXLO_DEBUG(("highlight=%d", highlight ));
if(highlight == 1) // we need to draw the whole line inverted!
llist->StartHighlighting(dc);
else
WXLO_DEBUG(("Line %ld, Pos (%ld,%ld), Height %ld",
(long int) GetLineNumber(),
(long int) pos.x, (long int) pos.y,
- (long int) GetHeight()));
+ (long int) GetHeight()));
+ if(m_ObjectList.begin() != NULLIT)
+ (**m_ObjectList.begin()).Debug();
+
}
#endif
wxLayoutStyleInfo(family,size,style,weight,underline,fg,bg);
}
+wxPoint
+wxLayoutList::FindText(const wxString &needle, const wxPoint &cpos) const
+{
+ int xpos;
+
+ wxLayoutLine *line;
+ for(line = m_FirstLine;
+ line;
+ line = line->GetNextLine())
+ {
+ if(line->GetLineNumber() >= cpos.y)
+ {
+ xpos = line->FindText(needle,
+ (line->GetLineNumber() == cpos.y) ?
+ cpos.x : 0);
+ if(xpos != -1)
+ return wxPoint(xpos, line->GetLineNumber());
+ }
+ }
+ return wxPoint(-1,-1);
+}
bool
LineBreak();
Delete(1); // delete the space
m_CursorPos.x = newpos;
- m_CursorLine->RecalculatePositions(true, this); //FIXME needed?
+ m_CursorLine->RecalculatePositions(true, this); //FIXME needed?
return true;
}
}
{ // we cannot delete this line, but we can clear it
MoveCursorToBeginOfLine();
DeleteToEndOfLine();
+ m_CursorLine->RecalculatePositions(2, this);
return n-1;
}
//else:
if(bottom != -1 && line->GetPosition().y > bottom) break;
line = line->GetNextLine();
}
- // can only be 0 if we are on the first line and have no next line
- wxASSERT(m_CursorSize.x != 0 || (m_CursorLine &&
- m_CursorLine->GetNextLine() == NULL &&
- m_CursorLine == m_FirstLine));
InvalidateUpdateRect();
WXLO_DEBUG(("Selection is %s : l%d,%ld/%ld,%ld",
return maxPoint;
}
+
void
wxLayoutList::DrawCursor(wxDC &dc, bool active, wxPoint const &translate)
{