- Delete(n);
- }
-
- /** Delete the next word.
- */
- void DeleteWord(void)
- {
- wxASSERT(m_CursorLine);
- m_CursorLine->DeleteWord(m_CursorPos.x);
- }
-
- //@}
-
- /** Finds text in this list.
- @param needle the text to find
- @param cpos the position where to start the search
- @return the cursor coord where it was found or (-1,-1)
- */
- wxPoint FindText(const wxString &needle, const wxPoint &cpos = wxPoint(0,0)) const;
-
- /**@name Formatting options */
- //@{
- /// sets font parameters
- void SetFont(int family, int size, int style,
- int weight, int underline,
- wxColour *fg,
- wxColour *bg);
- /// sets font parameters, colours by name
- void SetFont(int family=-1, int size = -1, int style=-1,
- int weight=-1, int underline = -1,
- char const *fg = NULL,
- char const *bg = NULL);
- /// changes to the next larger font size
- inline void SetFontLarger(void)
- { SetFont(-1,(12*m_CurrentStyleInfo.size)/10); }
- /// changes to the next smaller font size
- inline void SetFontSmaller(void)
- { SetFont(-1,(10*m_CurrentStyleInfo.size)/12); }
-
- /// set font family
- inline void SetFontFamily(int family) { SetFont(family); }
- /// set font size
- inline void SetFontSize(int size) { SetFont(-1,size); }
- /// set font style
- inline void SetFontStyle(int style) { SetFont(-1,-1,style); }
- /// set font weight
- inline void SetFontWeight(int weight) { SetFont(-1,-1,-1,weight); }
- /// toggle underline flag
- inline void SetFontUnderline(bool ul) { SetFont(-1,-1,-1,-1,(int)ul); }
- /// set font colours by name
- inline void SetFontColour(char const *fg, char const *bg = NULL)
- { SetFont(-1,-1,-1,-1,-1,fg,bg); }
- /// set font colours by colour
- inline void SetFontColour(wxColour *fg, wxColour *bg = NULL)
- { SetFont(-1,-1,-1,-1,-1,fg,bg); }
-
- /**
- Returns a pointer to the default settings.
- This is only valid temporarily and should not be stored
- anywhere.
- @return the default settings of the list
- */
- wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; }
- wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; }
- const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; }
-
- /// is the current font underlined?
- bool IsFontUnderlined() const { return GetStyleInfo().underline != 0; }
- /// is the current font bold?
- bool IsFontBold() const { return GetStyleInfo().weight == wxBOLD; }
- /// is the current font italic?
- bool IsFontItalic() const { return GetStyleInfo().style == wxITALIC; }
-
- /// set underline if it was off, turn it off if it was on
- void ToggleFontUnderline()
- { SetFontUnderline(!IsFontUnderlined()); }
-
- /// make font bold if it was normal or make it normal if it was bold
- void ToggleFontWeight()
- { SetFontWeight(IsFontBold() ? wxNORMAL : wxBOLD); }
-
- /// make font italic if it was normal or make it normal if it was italic
- void ToggleFontItalics()
- { SetFontStyle(IsFontItalic() ? wxNORMAL : wxITALIC); }
-
- //@}
-
- /**@name Drawing */
- //@{
- /** Draws the complete list on a wxDC.
- @param dc the wxDC to draw on
- @param offset an optional offset to shift printout
- @param top optional y coordinate where to start drawing
- @param bottom optional y coordinate where to stop drawing
- */
- void Draw(wxDC &dc,
- const wxPoint &offset = wxPoint(0,0),
- CoordType top = -1, CoordType bottom = -1);
-
- /** Calculates new layout for the list, like Draw() but does not
- actually draw it.
- @param dc the wxDC to draw on
- @param bottom optional y coordinate where to stop calculating
- @param forceAll force re-layout of all lines
- @param cpos Can hold a cursorposition, and will be overwritten
- with the corresponding DC position.
- @param csize Will hold the cursor size relating to cpos.
- */
- void Layout(wxDC &dc, CoordType bottom = -1, bool forceAll = false,
- wxPoint *cpos = NULL,
- wxPoint *csize = NULL);
-
- /** Returns the screen coordinates relating to a given cursor
- position and the size of the cursor at that position.
- @param dc for which to calculate it
- @param cpos Cursor position to look for.
- @param csize If non-NULL, will be set to the cursor size.
- @return The cursor position on the DC.
- */
- wxPoint GetScreenPos(wxDC &dc, const wxPoint &cpos, wxPoint *csize = NULL);
-
- /** Calculates new sizes for everything in the list, like Layout()
- but this is needed after the list got changed.
- @param dc the wxDC to draw on
- @param bottom optional y coordinate where to stop calculating
- */
- void Recalculate(wxDC &dc, CoordType bottom = -1);
-
- /** Returns the size of the list in screen coordinates.
- The return value only makes sense after the list has been
- drawn.
- @return a wxPoint holding the maximal x/y coordinates used for
- drawing
- */
- wxPoint GetSize(void) const;
-
- /** Returns the cursor position on the screen.
- @return cursor position in pixels
- */
- wxPoint GetCursorScreenPos(wxDC &dc);
-
- /** Calculates the cursor position on the screen.
- @param dc the dc to use for cursor position calculations
- */
- void UpdateCursorScreenPos(wxDC &dc);
-
- /** Draws the cursor.
- @param active If true, draw a bold cursor to mark window as
- active.
- @param translate optional translation of cursor coords on screen
- */
- void DrawCursor(wxDC &dc,
- bool active = true,
- const wxPoint & translate = wxPoint(0,0));
-
- /** This function finds an object belonging to a given screen
- position. It assumes that Layout() has been called before.
- @param pos screen position
- @param cursorPos if non NULL, store cursor position in there
- @param found if used, set this to true if we really found an
- object, to false if we had to take the object near to it
- @return pointer to the object
- */
- wxLayoutObject * FindObjectScreen(wxDC &dc,
- wxPoint const pos,
- wxPoint *cursorPos = NULL,
- bool *found = NULL);
-
- /** Called by the objects to update the update rectangle.
- @param x horizontal coordinate to include in rectangle
- @param y vertical coordinate to include in rectangle
- */
- void SetUpdateRect(CoordType x, CoordType y);
- /** Called by the objects to update the update rectangle.
- @param p a point to include in it
- */
- void SetUpdateRect(const wxPoint &p)
- { SetUpdateRect(p.x,p.y); }
- /// adds the cursor position to the update rectangle
- void AddCursorPosToUpdateRect()
- {
- #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
- }
- /// Invalidates the update rectangle.
- void InvalidateUpdateRect(void) { m_UpdateRectValid = false; }
- /// Returns the update rectangle.
- const wxRect *GetUpdateRect(void) const { return &m_UpdateRect; }
- //@}
-
- /// get the current cursor size
- const wxPoint& GetCursorSize() const { return m_CursorSize; }
-
- /**@name For exporting one object after another. */
- //@{
- /** Returns a pointer to the first line in the list. */
- wxLayoutLine *GetFirstLine(void)
- {
- wxASSERT(m_FirstLine);
- return m_FirstLine;
- }
- //@}
-
- /// Begin selecting text
- void StartSelection(const wxPoint& cpos = wxPoint(-1,-1),
- const wxPoint& spos = wxPoint(-1,-1));
- // Continue selecting text
- void ContinueSelection(const wxPoint& cpos = wxPoint(-1,-1),
- const wxPoint& spos = wxPoint(-1,-1));
- /// End selecting text.
- void EndSelection(const wxPoint& cpos = wxPoint(-1,-1),
- const wxPoint& spos = wxPoint(-1,-1));
- /// Discard the current selection
- void DiscardSelection();
- /// Are we still selecting text?
- bool IsSelecting(void);
- /// Is the given point (text coords) selected?
- bool IsSelected(const wxPoint &cursor);
- /// Do we have a non null selection?
- bool HasSelection() const
- { return m_Selection.m_valid || m_Selection.m_selecting; }
-
- /** Return the selection as a wxLayoutList.
- @param invalidate if true, the selection will be invalidated after this and can no longer be used.
- @return Another layout list object holding the selection, must be freed by caller
- */
- wxLayoutList *GetSelection(class wxLayoutDataObject *wxldo = NULL, bool invalidate = TRUE);
- /// Delete selected bit
- void DeleteSelection(void);
-
- wxLayoutList *Copy(const wxPoint &from = wxPoint(0,0),
- const wxPoint &to = wxPoint(-1,-1));
-
- /// starts highlighting of text for selections
- void StartHighlighting(wxDC &dc);
- /// ends highlighting of text for selections
- void EndHighlighting(wxDC &dc);