+ /** This function breaks the line at a given cursor position.
+ @param xpos where to break it
+ @return pointer to the new line object replacing the old one
+ */
+ wxLayoutLine *Break(CoordType xpos, wxLayoutList *llist);
+
+ /** Deletes the next word from this position, including leading
+ whitespace.
+ This function does not delete over font changes, i.e. a word
+ with formatting instructions in the middle of it is treated as
+ two (three actually!) words. In fact, if the cursor is on a non-text object, that
+ one is treated as a word.
+ @param xpos from where to delete
+ @return true if a word was deleted
+ */
+ bool DeleteWord(CoordType npos);
+
+ /** Finds a suitable position left to the given column to break the
+ line.
+ @param column we want to break the line to the left of this
+ @return column for breaking line or -1 if no suitable location found
+ */
+ CoordType GetWrapPosition(CoordType column);
+
+ /** Finds the object which covers the cursor position xpos in this
+ line.
+ @param xpos the column number
+ @param offset where to store the difference between xpos and
+ the object's head
+ @return iterator to the object or NULLIT
+ */
+ wxLayoutObjectList::iterator FindObject(CoordType xpos, CoordType
+ *offset) const ;
+
+ /** Finds the object which covers the screen position xpos in this
+ line.
+ @param dc the wxDC to use for calculations
+ @param xpos the screen x coordinate
+ @param offset where to store the difference between xpos and
+ the object's head
+ @return iterator to the object or NULLIT
+ */
+ wxLayoutObjectList::iterator FindObjectScreen(wxDC &dc,
+ CoordType xpos,
+ CoordType *offset) const ;
+
+ /** Get the first object in the list. This is used by the wxlparser
+ functions to export the list.
+ @return iterator to the first object
+ */
+ wxLayoutObjectList::iterator GetFirstObject(void)
+ {
+ return m_ObjectList.begin();
+ }
+
+ /** Deletes this line, returns pointer to next line.
+ @param update If true, update all following lines.
+ */
+ wxLayoutLine *DeleteLine(bool update, wxLayoutList *llist);
+
+ /**@name Cursor Management */
+ //@{
+ /** Return the line number of this line.
+ @return the line number
+ */
+ CoordType GetLineNumber(void) const { return m_LineNumber; }
+ /** Return the length of the line.
+ @return line lenght in cursor positions
+ */
+ CoordType GetLength(void) const { return m_Length; }
+ //@}
+
+ /**@name Drawing and Layout */
+ //@{
+ /** Draws the line on a wxDC.
+ @param dc the wxDC to draw on
+ @param llist the wxLayoutList
+ @param offset an optional offset to shift printout
+ */
+ void Draw(wxDC &dc,
+ wxLayoutList *llist,
+ const wxPoint &offset = wxPoint(0,0)) const;
+
+ /** Recalculates the positions of objects and the height of the
+ line.
+ @param dc the wxDC to draw on
+ @param llist th e wxLayoutList
+ @param cursorPos if not NULL, set cursor screen position in there
+ @param cursorSize if not cursorPos != NULL, set cursor size in there
+ @param cx if cursorPos != NULL, the cursor x position
+ */
+ void Layout(wxDC &dc,
+ wxLayoutList *llist,
+ wxPoint *cursorPos = NULL,
+ wxPoint *cursorSize = NULL,
+ int cx = 0);
+ /** This function finds an object belonging to a given cursor
+ position. It assumes that Layout() has been called before.
+ @param dc the wxDC to use for calculations
+ @param xpos screen x position
+ @return pointer to the object
+ */
+ wxLayoutObject * FindObjectScreen(wxDC &dc, CoordType xpos);
+ //@}
+
+ /**@name List traversal */
+ //@{
+ /// Returns pointer to next line.
+ wxLayoutLine *GetNextLine(void) const { return m_Next; }
+ /// Returns pointer to previous line.
+ wxLayoutLine *GetPreviousLine(void) const { return m_Previous; }
+ /// Sets the link to the next line.
+ void SetNext(wxLayoutLine *next)
+ { m_Next = next; if(next) next->m_Previous = this; }
+ /// Sets the link to the previous line.
+ void SetPrevious(wxLayoutLine *previous)
+ { m_Previous = previous; if(previous) previous->m_Next = this; }
+ //@}
+
+ /// Returns the position of this line on the canvas.
+ wxPoint GetPosition(void) const { return m_Position; }
+ /// Returns the height of this line.
+ CoordType GetHeight(void) const { return m_Height; }
+ /// Returns the width of this line.
+ CoordType GetWidth(void) const { return m_Width; }
+ /** This will recalculate the position and size of this line.
+ If called recursively it will abort if the position of an
+ object is unchanged, assuming that none of the following
+ objects need to move.
+ @param recurse if greater 0 then it will be used as the
+ minimum(!) recursion level, continue with all lines till the end of
+ the list or until the coordinates no longer changed.
+ */
+ void RecalculatePositions(int recurse, wxLayoutList *llist);
+ /// Recalculates the position of this line on the canvas.
+ wxPoint RecalculatePosition(wxLayoutList *llist);
+private:
+ /// Destructor is private. Use DeleteLine() to remove it.
+ ~wxLayoutLine();
+
+ /**@name Functions to let the lines synchronise with each other. */
+ //@{
+ /** Sets the height of this line. Will mark following lines as
+ dirty.
+ @param height new height
+ */
+ void SetHeight(CoordType height, wxLayoutList *llist)
+ { m_Height = height; RecalculatePositions(true, llist); }
+
+ /** Moves the linenumbers one on, because a line has been inserted
+ or deleted.
+ @param delta either +1 or -1
+ */
+ void MoveLines(int delta)
+ {
+ m_LineNumber += delta;
+ if(m_Next) m_Next->MoveLines(delta);
+ }
+ //@}
+private:
+ /// The line number.
+ CoordType m_LineNumber;
+ /// The line length in cursor positions.
+ CoordType m_Length;
+ /// The total height of the line.
+ CoordType m_Height;
+ /// The total width of the line on screen.
+ CoordType m_Width;
+ /// The baseline for drawing objects
+ CoordType m_BaseLine;
+ /// The position on the canvas.
+ wxPoint m_Position;
+ /// The list of objects
+ wxLayoutObjectList m_ObjectList;
+ /// Have we been changed since the last layout?
+ bool m_Dirty;
+ /// Pointer to previous line if it exists.
+ wxLayoutLine *m_Previous;
+ /// Pointer to next line if it exists.
+ wxLayoutLine *m_Next;
+ /// Just to suppress gcc compiler warnings.
+ friend class dummy;
+private:
+ wxLayoutLine(const wxLayoutLine &);
+};
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+
+ The wxLayoutList object
+
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/** The wxLayoutList is a list of wxLayoutLine objects. It provides a
+ higher level of abstraction for the text and can generally be considered
+ as representing "the text".
+ */
+class wxLayoutList