X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c131587cdb1a0aec71788ed605a17e05bf9731c5..1fd8a4504da7215d889e3e6234476581b0ba7adf:/samples/richedit/wxllist.h?ds=sidebyside diff --git a/samples/richedit/wxllist.h b/samples/richedit/wxllist.h index a8eaf78ec0..85c0f13336 100644 --- a/samples/richedit/wxllist.h +++ b/samples/richedit/wxllist.h @@ -16,12 +16,12 @@ #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 +#include +#include +#include +#include +#include // skip the following defines if embedded in M application #ifndef M_BASEDIR @@ -520,12 +520,14 @@ public: /** 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 ; @@ -541,11 +543,18 @@ public: 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. */ @@ -580,6 +589,7 @@ public: @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 */ @@ -587,6 +597,7 @@ public: 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 @@ -598,13 +609,14 @@ public: 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; } //@} @@ -796,14 +808,24 @@ public: 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. @@ -919,13 +941,14 @@ public: wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; } wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; } const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; } + const wxLayoutStyleInfo &GetCursorStyleInfo(void) const { return m_CursorStyleInfo ; } /// is the current font underlined? - bool IsFontUnderlined() const { return GetStyleInfo().underline != 0; } + bool IsFontUnderlined() const { return GetCursorStyleInfo().underline != 0; } /// is the current font bold? - bool IsFontBold() const { return GetStyleInfo().weight == wxBOLD; } + bool IsFontBold() const { return GetCursorStyleInfo().weight == wxBOLD; } /// is the current font italic? - bool IsFontItalic() const { return GetStyleInfo().style == wxITALIC; } + bool IsFontItalic() const { return GetCursorStyleInfo().style == wxITALIC; } /// set underline if it was off, turn it off if it was on void ToggleFontUnderline() @@ -1106,16 +1129,44 @@ public: 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. @@ -1162,6 +1213,8 @@ private: wxLayoutStyleInfo m_DefaultStyleInfo; /// the current setting: wxLayoutStyleInfo m_CurrentStyleInfo; + /// the current setting: + wxLayoutStyleInfo m_CursorStyleInfo; //@} };