X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c51506096423bd936452df1a521d05c9429005b..1a78a6290510473b40a3f222030de64939886753:/user/wxLayout/wxllist.h diff --git a/user/wxLayout/wxllist.h b/user/wxLayout/wxllist.h index 75019427ef..a3e4cb438f 100644 --- a/user/wxLayout/wxllist.h +++ b/user/wxLayout/wxllist.h @@ -29,7 +29,8 @@ # define WXMENU_LAYOUT_DBLCLICK 1113 #endif -#ifdef __WXDEBUG__ +// do not enable debug mode within Mahogany +#if defined(__WXDEBUG__) && ! defined(M_BASEDIR) # define WXLAYOUT_DEBUG #endif @@ -111,8 +112,15 @@ public: /** Draws an object. @param dc the wxDC to draw on @param coords where to draw the baseline of the object. + @param wxllist pointer to wxLayoutList + @param begin if !=-1, from which position on to highlight it + @param end if begin !=-1, how many positions to highlight it */ - virtual void Draw(wxDC & /* dc */, wxPoint const & /* coords */) { } + virtual void Draw(wxDC & /* dc */, + wxPoint const & /* coords */, + class wxLayoutList *wxllist, + CoordType begin = -1, + CoordType end = -1) { } /** Calculates and returns the size of the object. @param top where to store height above baseline @@ -187,7 +195,10 @@ public: virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; } virtual void Layout(wxDC &dc); - virtual void Draw(wxDC &dc, wxPoint const &coords); + virtual void Draw(wxDC &dc, wxPoint const &coords, + class wxLayoutList *wxllist, + CoordType begin = -1, + CoordType end = -1); /** Calculates and returns the size of the object. @param top where to store height above baseline @param bottom where to store height below baseline @@ -244,7 +255,10 @@ public: virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; } virtual void Layout(wxDC &dc); - virtual void Draw(wxDC &dc, wxPoint const &coords); + virtual void Draw(wxDC &dc, wxPoint const &coords, + class wxLayoutList *wxllist, + CoordType begin = -1, + CoordType end = -1); /** Calculates and returns the size of the object. @param top where to store height above baseline @@ -288,7 +302,10 @@ class wxLayoutObjectCmd : public wxLayoutObject public: virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; } virtual void Layout(wxDC &dc); - virtual void Draw(wxDC &dc, wxPoint const &coords); + virtual void Draw(wxDC &dc, wxPoint const &coords, + class wxLayoutList *wxllist, + CoordType begin = -1, + CoordType end = -1); wxLayoutObjectCmd(int size, int family, int style, int weight, bool underline, wxColour &fg, wxColour &bg); @@ -413,7 +430,8 @@ public: */ wxLayoutObjectList::iterator FindObjectScreen(wxDC &dc, CoordType xpos, - CoordType *offset) const ; + CoordType *offset, + bool *found = NULL) const ; /** Get the first object in the list. This is used by the wxlparser functions to export the list. @@ -434,11 +452,11 @@ public: /** Return the line number of this line. @return the line number */ - CoordType GetLineNumber(void) const { return m_LineNumber; } + inline 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; } + inline CoordType GetLength(void) const { return m_Length; } //@} /**@name Drawing and Layout */ @@ -469,9 +487,13 @@ public: 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); + wxLayoutObject * FindObjectScreen(wxDC &dc, CoordType xpos, bool + *found = NULL); //@} /**@name List traversal */ @@ -505,6 +527,20 @@ public: void RecalculatePositions(int recurse, wxLayoutList *llist); /// 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); + +#ifdef WXLAYOUT_DEBUG + void Debug(void); +#endif + private: /// Destructor is private. Use DeleteLine() to remove it. ~wxLayoutLine(); @@ -705,7 +741,16 @@ public: /// 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); } + 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); } + + + /// Used by wxLayoutObjectCmd only: + void SetColour_Internal(wxColour *fg, wxColour *bg) + { if(fg) m_ColourFG = *fg; if(bg) m_ColourBG = *bg; } /** Returns a pointer to the default settings. This is only valid temporarily and should not be stored @@ -723,7 +768,8 @@ public: @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), + 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 @@ -766,16 +812,25 @@ public: 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); + 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); + inline void SetUpdateRect(const wxPoint &p) + { SetUpdateRect(p.x,p.y); } /// Invalidates the update rectangle. void InvalidateUpdateRect(void) { m_UpdateRectValid = false; } /// Returns the update rectangle. @@ -792,10 +847,41 @@ public: } //@} + /// Begin selecting text. void StartSelection(void); + // Continue selecting text + void ContinueSelection(void); + /// End selecting text. void EndSelection(void); + /// Are we still selecting text? + bool IsSelecting(void); bool IsSelected(const wxPoint &cursor); + /// Return the selection as a wxLayoutList: + wxLayoutList *GetSelection(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); + + /** Tests whether this layout line is selected and needs + highlighting. + @param line to test for + @param from set to first cursorpos to be highlighted (for returncode == -1) + @param to set to last cursorpos to be highlighted (for returncode == -1) + @return 0 = not selected, 1 = fully selected, -1 = partially + selected + + */ + int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to); + +#ifdef WXLAYOUT_DEBUG + void Debug(void); +#endif private: /// Clear the list. void InternalClear(void); @@ -824,7 +910,9 @@ private: /// A structure for the selection. struct Selection { + Selection() { m_valid = false; m_selecting = false; } bool m_valid; + bool m_selecting; wxPoint m_CursorA, m_CursorB; } m_Selection; /** @name Font parameters. */ @@ -862,6 +950,9 @@ public: wxLayoutPrintout(wxLayoutList *llist, wxString const & title = "wxLayout Printout"); + /// Destructor. + ~wxLayoutPrintout(); + /** Function which prints the n-th page. @param page the page number to print @return bool true if we are not at end of document yet