#include "kbList.h"
-#include "wx/wx.h"
-#include "wx/print.h"
-#include "wx/printdlg.h"
-#include "wx/generic/printps.h"
-#include "wx/generic/prntdlgg.h"
-#include "wx/dataobj.h"
+#include <wx/wx.h>
+#include <wx/print.h>
+#include <wx/printdlg.h>
+#include <wx/generic/printps.h>
+#include <wx/generic/prntdlgg.h>
+#include <wx/dataobj.h>
// skip the following defines if embedded in M application
#ifndef M_BASEDIR
/** 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 ;
functions to export the list.
@return iterator to the first object
*/
- wxLayoutObjectList::iterator GetFirstObject(void)
+ 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.
*/
for that position
@return pointer to the object
*/
- wxLayoutObject * FindObjectScreen(wxDC &dc, CoordType xpos, bool
- *found = NULL);
+ 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; }
+ { m_StyleInfo = si; }
//@}
MoveCursorHorizontally(m_CursorLine->GetLength()-m_CursorPos.x);
}
- /// Move cursor to begin of line.
+ /// Move cursor to the start of line.
void MoveCursorToBeginOfLine(void)
{ MoveCursorHorizontally(-m_CursorPos.x); }
+ /// get the number of lines in the list
+ size_t GetNumLines() const { return m_numLines; }
+
/// Returns current cursor position.
const wxPoint &GetCursorPos(wxDC &dc) const { return m_CursorPos; }
const wxPoint &GetCursorPos() const { return m_CursorPos; }
+ /// move cursor to the end of text
+ void MoveCursorToEnd(void)
+ {
+ MoveCursorTo(wxPoint(0, GetNumLines() - 1));
+ MoveCursorToEndOfLine();
+ }
+
//@}
/**@name Editing functions.
/// adds the cursor position to the update rectangle
void AddCursorPosToUpdateRect()
{
- #ifndef WXLAYOUT_USE_CARET
- SetUpdateRect(m_CursorScreenPos);
- SetUpdateRect(m_CursorScreenPos+m_CursorSize);
+#ifndef WXLAYOUT_USE_CARET
+ SetUpdateRect(m_CursorScreenPos);
+ SetUpdateRect(m_CursorScreenPos+m_CursorSize);
//#else - the caret will take care of refreshing itself
- #endif // !WXLAYOUT_USE_CARET
+#endif // !WXLAYOUT_USE_CARET
}
/// Invalidates the update rectangle.
void InvalidateUpdateRect(void) { m_UpdateRectValid = false; }
void Debug(void);
#endif
+ // for wxLayoutLine usage only
+ void IncNumLines() { m_numLines++; }
+ void DecNumLines() { m_numLines--; }
+
+ /// get the line by number
+ wxLayoutLine *GetLine(CoordType index) const
+ {
+ wxASSERT_MSG( (0 <= index) && (index < (CoordType)m_numLines),
+ "invalid index" );
+
+ wxLayoutLine *line;
+ CoordType n = index;
+ for ( line = m_FirstLine; line && n-- > 0; line = line->GetNextLine() )
+ ;
+
+ if ( line )
+ {
+ // should be the right one
+ wxASSERT( line->GetLineNumber() == index );
+ }
+
+ return line;
+ }
+
private:
/// Clear the list.
void InternalClear(void);
/// The list of lines.
wxLayoutLine *m_FirstLine;
+ /// The number of lines in the list (store instead recalculating for speed)
+ size_t m_numLines;
+
/// The update rectangle which needs to be refreshed:
wxRect m_UpdateRect;
/// Is the update rectangle valid?
bool m_UpdateRectValid;
+
/**@name Cursor Management */
//@{
/// Where the text cursor (column,line) is.