- /** Constructor.
- @param prev pointer to previous line or NULL
- @param next pointer to following line or NULL
- @param llist pointer to layout list
- */
- wxLayoutLine(wxLayoutLine *prev, wxLayoutList *llist);
- /** This function inserts a new object at cursor position xpos.
- @param xpos where to insert new object
- @param obj the object to insert
- @return true if that xpos existed and the object was inserted
- */
- bool Insert(CoordType xpos, wxLayoutObject *obj);
-
- /** This function inserts text at cursor position xpos.
- @param xpos where to insert
- @param text the text to insert
- @return true if that xpos existed and the object was inserted
- */
- bool Insert(CoordType xpos, const wxString& text);
-
- /** This function appends an object to the line.
- @param obj the object to insert
- */
- void Append(wxLayoutObject * obj)
- {
- wxASSERT(obj);
-
- m_ObjectList.push_back(obj);
- m_Length += obj->GetLength();
- }
-
- /** This function appens the next line to this, i.e. joins the two
- lines into one.
- */
- void MergeNextLine(wxLayoutList *llist);
-
- /** This function deletes npos cursor positions from position xpos.
- @param xpos where to delete
- @param npos how many positions
- @return number of positions still to be deleted
- */
- CoordType Delete(CoordType xpos, CoordType npos);
-
- /** 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 llist the layout list to which this line belongs
- @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,
- wxLayoutList *llist,
- CoordType xpos,
- CoordType *offset,
- bool *found = NULL) const ;
-
- /** 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 FindText(const wxString &needle, CoordType xpos = 0) 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) const
- {
- return m_ObjectList.begin();
- }
-
- /** Get the last object in the list.
- */
- wxLayoutObjectList::iterator GetLastObject(void) const
- {
- return m_ObjectList.tail();
- }
-
- /** 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
- */
- inline CoordType GetLineNumber(void) const { return m_LineNumber; }
- /** Return the length of the line.
- @return line lenght in cursor positions
- */
- inline 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 cursorStyle if non NULL where to store styleinfo for cursor pos
- @param cx if cursorPos != NULL, the cursor x position
- @param suppressStyleUpdate FALSe normally, only to suppress updating of m_StyleInfo
- */
- void Layout(wxDC &dc,
- wxLayoutList *llist,
- wxPoint *cursorPos = NULL,
- wxPoint *cursorSize = NULL,
- wxLayoutStyleInfo *cursorStyle = NULL,
- int cx = 0,
- bool suppressStyleUpdate = FALSE);
- /** 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
- @param found if non-NULL set to false if we return the last
- object before the cursor, to true if we really have an object
- for that position
- @return pointer to the object
- */
- wxLayoutObject * FindObjectScreen(wxDC &dc,
- CoordType xpos,
- bool *found = NULL);
- /** This sets the style info for the beginning of this line.
- @param si styleinfo structure
- */
- void ApplyStyle(const wxLayoutStyleInfo &si)
- { m_StyleInfo = si; }
-
- //@}
-
- /**@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; }
- /// Recalculates the position of this line on the canvas.
- wxPoint RecalculatePosition(wxLayoutList *llist);
-
- /** Copies the contents of this line to another wxLayoutList
- @param llist the wxLayoutList destination
- @param from x cursor coordinate where to start
- @param to x cursor coordinate where to stop, -1 for end of line
- */
- void Copy(wxLayoutList *llist,
- CoordType from = 0,
- CoordType to = -1);
+ /** Constructor.
+ @param prev pointer to previous line or NULL
+ @param next pointer to following line or NULL
+ @param llist pointer to layout list
+ */
+ wxLayoutLine(wxLayoutLine *prev, wxLayoutList *llist);
+ /** This function inserts a new object at cursor position xpos.
+ @param xpos where to insert new object
+ @param obj the object to insert
+ @return true if that xpos existed and the object was inserted
+ */
+ bool Insert(CoordType xpos, wxLayoutObject *obj);
+
+ /** This function inserts text at cursor position xpos.
+ @param xpos where to insert
+ @param text the text to insert
+ @return true if that xpos existed and the object was inserted
+ */
+ bool Insert(CoordType xpos, const wxString& text);
+
+ /** This function appends an object to the line.
+ @param obj the object to insert
+ */
+ void Append(wxLayoutObject * obj)
+ {
+ wxASSERT(obj);
+ m_ObjectList.push_back(obj);
+ m_Length += obj->GetLength();
+ }
+
+ /** This function prepends an object to the line. */
+ void Prepend(wxLayoutObject * obj)
+ {
+ wxASSERT(obj);
+ m_ObjectList.push_front(obj);
+ m_Length += obj->GetLength();
+ }
+
+ /** This function appens the next line to this, i.e. joins the two
+ lines into one.
+ */
+ void MergeNextLine(wxLayoutList *llist);
+
+ /** This function deletes npos cursor positions from position xpos.
+ @param xpos where to delete
+ @param npos how many positions
+ @return number of positions still to be deleted
+ */
+ CoordType Delete(CoordType xpos, CoordType npos);
+
+ /** 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);
+
+ /** This function wraps the line: breaks it at a suitable point
+ and merges it with the next.
+ @param wrapmargin
+ @return true if broken
+ */
+ bool Wrap(CoordType wrapmargin, 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 iterator to NULL
+ */
+ 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 llist the layout list to which this line belongs
+ @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 iterator to NULL
+ */
+ wxLayoutObjectList::iterator FindObjectScreen(wxDC &dc,
+ wxLayoutList *llist,
+ CoordType xpos,
+ CoordType *offset,
+ bool *found = NULL) const ;
+
+ /** 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 FindText(const wxString &needle, CoordType xpos = 0) 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() const
+ {
+ return m_ObjectList.begin();
+ }
+
+ /// Get the last object in the list.
+ wxLayoutObjectList::iterator GetLastObject() const
+ {
+ return m_ObjectList.tail();
+ }
+
+ /** 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
+ */
+ inline CoordType GetLineNumber() const { return m_LineNumber; }
+
+ /** Return the length of the line.
+ @return line length in cursor positions
+ */
+ inline CoordType GetLength() 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 cursorStyle if non NULL where to store styleinfo for cursor pos
+ @param cx if cursorPos != NULL, the cursor x position
+ @param suppressStyleUpdate FALSe normally, only to suppress updating of m_StyleInfo
+ */
+ void Layout(wxDC &dc,
+ wxLayoutList *llist,
+ wxPoint *cursorPos = NULL,
+ wxPoint *cursorSize = NULL,
+ wxLayoutStyleInfo *cursorStyle = NULL,
+ int cx = 0,
+ bool suppressStyleUpdate = false);
+
+ /** 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
+ @param found if non-NULL set to false if we return the last
+ object before the cursor, to true if we really have an object
+ for that position
+ @return pointer to the object
+ */
+ wxLayoutObject * FindObjectScreen(wxDC &dc,
+ CoordType xpos,
+ bool *found = NULL);
+
+ /** This sets the style info for the beginning of this line.
+ @param si styleinfo structure
+ */
+ void ApplyStyle(const wxLayoutStyleInfo &si)
+ { m_StyleInfo = si; }
+
+ //@}
+
+ /**@name List traversal */
+ //@{
+ /// Returns pointer to next line.
+ wxLayoutLine *GetNextLine() const { return m_Next; }
+
+ /// Returns pointer to previous line.
+ wxLayoutLine *GetPreviousLine() 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() const { return m_Position; }
+
+ /// Returns the height of this line.
+ CoordType GetHeight() const { return m_Height; }
+
+ /// Returns the width of this line.
+ CoordType GetWidth() const { return m_Width; }
+
+ /// Recalculates the position of this line on the canvas.
+ wxPoint RecalculatePosition(wxLayoutList *llist);
+
+ /** Copies the contents of this line to another wxLayoutList
+ @param llist the wxLayoutList destination
+ @param from x cursor coordinate where to start
+ @param to x cursor coordinate where to stop, -1 for end of line
+ */
+ void Copy(wxLayoutList *llist,
+ CoordType from = 0,
+ CoordType to = -1);