1 /*-*- c++ -*-********************************************************
2 * wxLayoutList.h - a formatted text rendering engine for wxWindows *
4 * (C) 1999 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
14 # pragma interface "wxllist.h"
21 #include "wx/printdlg.h"
22 #include "wx/generic/printps.h"
23 #include "wx/generic/prntdlgg.h"
25 // skip the following defines if embedded in M application
27 # define WXMENU_LAYOUT_LCLICK 1111
28 # define WXMENU_LAYOUT_RCLICK 1112
29 # define WXMENU_LAYOUT_DBLCLICK 1113
32 // do not enable debug mode within Mahogany
33 #if defined(__WXDEBUG__) && ! defined(M_BASEDIR)
34 # define WXLAYOUT_DEBUG
38 # define WXLO_TRACE(x) wxLogDebug(x)
40 # define WXLO_TRACE(x)
45 #ifndef WXLO_DEFAULTFONTSIZE
46 # define WXLO_DEFAULTFONTSIZE 12
50 /// Types of currently supported layout objects.
51 enum wxLayoutObjectType
53 /// illegal object type, should never appear
54 WXLO_TYPE_INVALID
= 0,
55 /// text object, containing normal text
57 /// command object, containing font or colour changes
59 /// icon object, any kind of image
63 /// Type used for coordinates in drawing. Must be signed.
64 typedef long CoordType
;
66 // Forward declarations.
74 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
76 The wxLayout objects which make up the lines.
78 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
80 /** The base class defining the interface to each object which can be
81 part of the layout. Each object needs to draw itself and calculate
87 /** This structure can be used to contain data associated with the
89 It is refcounted, so the caller has to do a DecRef() on it
94 UserData() { m_refcount
= 1; }
95 void IncRef(void) { m_refcount
++; }
96 void DecRef(void) { m_refcount
--; if(m_refcount
== 0) delete this;}
100 virtual ~UserData() { wxASSERT(m_refcount
== 0); }
101 /// prevents gcc from generating stupid warnings
102 friend class dummy_UserData
;
105 /// return the type of this object
106 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_INVALID
; }
107 /** Calculates the size of an object.
108 @param dc the wxDC to draw on
110 virtual void Layout(wxDC
&) = 0;
113 @param dc the wxDC to draw on
114 @param coords where to draw the baseline of the object.
115 @param wxllist pointer to wxLayoutList
116 @param begin if !=-1, from which position on to highlight it
117 @param end if begin !=-1, how many positions to highlight it
119 virtual void Draw(wxDC
& /* dc */,
120 wxPoint
const & /* coords */,
121 class wxLayoutList
*wxllist
,
122 CoordType begin
= -1,
123 CoordType end
= -1) { }
125 /** Calculates and returns the size of the object.
126 @param top where to store height above baseline
127 @param bottom where to store height below baseline
128 @return the size of the object's box in pixels
130 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const
131 { *top
= 0; *bottom
= 0; return wxPoint(0,0); }
133 /// Return just the width of the object on the screen.
134 virtual CoordType
GetWidth(void) const { return 0; }
135 /// returns the number of cursor positions occupied by this object
136 virtual CoordType
GetLength(void) const { return 1; }
137 /** Returns the cursor offset relating to the screen x position
138 relative to begin of object.
139 @param dc the wxDC to use for calculations
140 @param xpos relative x position from head of object
141 @return cursor coordinate offset
143 virtual CoordType
GetOffsetScreen(wxDC
&dc
, CoordType xpos
) const { return 0; }
146 wxLayoutObject() { m_UserData
= NULL
; }
147 /// delete the user data
148 virtual ~wxLayoutObject() { if(m_UserData
) m_UserData
->DecRef(); }
150 #ifdef WXLAYOUT_DEBUG
151 virtual void Debug(void);
154 /** Tells the object about some user data. This data is associated
155 with the object and will be deleted at destruction time.
157 void SetUserData(UserData
*data
)
160 m_UserData
->DecRef();
162 m_UserData
->IncRef();
165 /** Return the user data. */
166 void * GetUserData(void) const { if(m_UserData
) m_UserData
->IncRef(); return m_UserData
; }
168 /** Makes a copy of this object.
170 virtual wxLayoutObject
*Copy(void) = 0;
172 /// optional data for application's use
173 UserData
*m_UserData
;
176 /// Define a list type of wxLayoutObject pointers.
177 KBLIST_DEFINE(wxLayoutObjectList
, wxLayoutObject
);
179 /// An illegal iterator to save typing.
180 #define NULLIT (wxLayoutObjectList::iterator(NULL))
181 /// The iterator type.
182 #define wxLOiterator wxLayoutObjectList::iterator
184 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
189 /** This class implements a wxLayoutObject holding plain text.
191 class wxLayoutObjectText
: public wxLayoutObject
194 wxLayoutObjectText(const wxString
&txt
);
196 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_TEXT
; }
197 virtual void Layout(wxDC
&dc
);
198 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
199 class wxLayoutList
*wxllist
,
200 CoordType begin
= -1,
202 /** Calculates and returns the size of the object.
203 @param top where to store height above baseline
204 @param bottom where to store height below baseline
205 @return the size of the object's box in pixels
207 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const;
208 /// Return just the width of the object on the screen.
209 virtual CoordType
GetWidth(void) const { return m_Width
; }
210 /** Returns the cursor offset relating to the screen x position
211 relative to begin of object.
212 @param dc the wxDC to use for calculations
213 @param xpos relative x position from head of object
214 @return cursor coordinate offset
216 virtual CoordType
GetOffsetScreen(wxDC
&dc
, CoordType xpos
) const;
219 #ifdef WXLAYOUT_DEBUG
220 virtual void Debug(void);
223 virtual CoordType
GetLength(void) const { return strlen(m_Text
.c_str()); }
226 wxString
& GetText(void) { return m_Text
; }
227 void SetText(wxString
const &text
) { m_Text
= text
; }
228 /** Makes a copy of this object.
230 virtual wxLayoutObject
*Copy(void);
233 /// size of the box containing text
234 long m_Width
, m_Height
;
235 /// Height above baseline.
237 /// Height below baseline.
241 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
245 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
246 /** This class implements a wxLayoutObject holding a graphic.
248 class wxLayoutObjectIcon
: public wxLayoutObject
251 wxLayoutObjectIcon(wxBitmap
*icon
);
252 wxLayoutObjectIcon(wxBitmap
const &icon
);
254 ~wxLayoutObjectIcon() { delete m_Icon
; }
256 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_ICON
; }
257 virtual void Layout(wxDC
&dc
);
258 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
259 class wxLayoutList
*wxllist
,
260 CoordType begin
= -1,
263 /** Calculates and returns the size of the object.
264 @param top where to store height above baseline
265 @param bottom where to store height below baseline
266 @return the size of the object's box in pixels
268 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const;
269 /// Return just the width of the object on the screen.
270 virtual CoordType
GetWidth(void) const { return m_Icon
->GetWidth(); }
271 // return a pointer to the icon
272 wxBitmap
*GetIcon(void) const { return m_Icon
; }
273 /** Makes a copy of this object.
275 virtual wxLayoutObject
*Copy(void);
280 /// for export to html:
281 struct wxLayoutStyleInfo
285 family
= -1; // this marks the styleinfo as uninitialised
287 int size
, family
, style
, weight
;
289 unsigned fg_red
, fg_green
, fg_blue
;
290 unsigned bg_red
, bg_green
, bg_blue
;
293 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
297 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
298 /** This class implements a wxLayoutObject holding style change commands.
300 class wxLayoutObjectCmd
: public wxLayoutObject
303 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_CMD
; }
304 virtual void Layout(wxDC
&dc
);
305 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
306 class wxLayoutList
*wxllist
,
307 CoordType begin
= -1,
309 wxLayoutObjectCmd(int size
, int family
, int style
, int weight
,
311 wxColour
&fg
, wxColour
&bg
);
312 ~wxLayoutObjectCmd();
313 /** Stores the current style in the styleinfo structure */
314 void GetStyle(wxLayoutStyleInfo
*si
) const;
315 /// return the background colour for setting colour of window
316 wxColour
&GetBGColour(void) { return m_ColourBG
; }
317 /** Makes a copy of this object.
319 virtual wxLayoutObject
*Copy(void);
323 /// foreground colour
325 /// background colour
329 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
331 The wxLayoutLine object
333 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
335 /// forward declaration
338 /** This class represents a single line of objects to be displayed.
339 It knows its height and total size and whether it needs to be
341 It has pointers to its first and next line so it can automatically
342 update them as needed.
348 @param prev pointer to previous line or NULL
349 @param next pointer to following line or NULL
350 @param llist pointer to layout list
352 wxLayoutLine(wxLayoutLine
*prev
, wxLayoutList
*llist
);
353 /** This function inserts a new object at cursor position xpos.
354 @param xpos where to insert new object
355 @param obj the object to insert
356 @return true if that xpos existed and the object was inserted
358 bool Insert(CoordType xpos
, wxLayoutObject
*obj
);
360 /** This function inserts text at cursor position xpos.
361 @param xpos where to insert
362 @param text the text to insert
363 @return true if that xpos existed and the object was inserted
365 bool Insert(CoordType xpos
, wxString text
);
367 /** This function appends an object to the line.
368 @param obj the object to insert
370 void Append(wxLayoutObject
* obj
)
373 m_ObjectList
.push_back(obj
);
374 m_Length
+= obj
->GetLength();
377 /** This function appens the next line to this, i.e. joins the two
380 void MergeNextLine(wxLayoutList
*llist
);
382 /** This function deletes npos cursor positions from position xpos.
383 @param xpos where to delete
384 @param npos how many positions
385 @return number of positions still to be deleted
387 CoordType
Delete(CoordType xpos
, CoordType npos
);
389 /** This function breaks the line at a given cursor position.
390 @param xpos where to break it
391 @return pointer to the new line object replacing the old one
393 wxLayoutLine
*Break(CoordType xpos
, wxLayoutList
*llist
);
395 /** Deletes the next word from this position, including leading
397 This function does not delete over font changes, i.e. a word
398 with formatting instructions in the middle of it is treated as
399 two (three actually!) words. In fact, if the cursor is on a non-text object, that
400 one is treated as a word.
401 @param xpos from where to delete
402 @return true if a word was deleted
404 bool DeleteWord(CoordType npos
);
406 /** Finds a suitable position left to the given column to break the
408 @param column we want to break the line to the left of this
409 @return column for breaking line or -1 if no suitable location found
411 CoordType
GetWrapPosition(CoordType column
);
413 /** Finds the object which covers the cursor position xpos in this
415 @param xpos the column number
416 @param offset where to store the difference between xpos and
418 @return iterator to the object or NULLIT
420 wxLayoutObjectList::iterator
FindObject(CoordType xpos
, CoordType
423 /** Finds the object which covers the screen position xpos in this
425 @param dc the wxDC to use for calculations
426 @param xpos the screen x coordinate
427 @param offset where to store the difference between xpos and
429 @return iterator to the object or NULLIT
431 wxLayoutObjectList::iterator
FindObjectScreen(wxDC
&dc
,
434 bool *found
= NULL
) const ;
436 /** Get the first object in the list. This is used by the wxlparser
437 functions to export the list.
438 @return iterator to the first object
440 wxLayoutObjectList::iterator
GetFirstObject(void)
442 return m_ObjectList
.begin();
445 /** Deletes this line, returns pointer to next line.
446 @param update If true, update all following lines.
448 wxLayoutLine
*DeleteLine(bool update
, wxLayoutList
*llist
);
450 /**@name Cursor Management */
452 /** Return the line number of this line.
453 @return the line number
455 inline CoordType
GetLineNumber(void) const { return m_LineNumber
; }
456 /** Return the length of the line.
457 @return line lenght in cursor positions
459 inline CoordType
GetLength(void) const { return m_Length
; }
462 /**@name Drawing and Layout */
464 /** Draws the line on a wxDC.
465 @param dc the wxDC to draw on
466 @param llist the wxLayoutList
467 @param offset an optional offset to shift printout
471 const wxPoint
&offset
= wxPoint(0,0)) const;
473 /** Recalculates the positions of objects and the height of the
475 @param dc the wxDC to draw on
476 @param llist th e wxLayoutList
477 @param cursorPos if not NULL, set cursor screen position in there
478 @param cursorSize if not cursorPos != NULL, set cursor size in there
479 @param cx if cursorPos != NULL, the cursor x position
481 void Layout(wxDC
&dc
,
483 wxPoint
*cursorPos
= NULL
,
484 wxPoint
*cursorSize
= NULL
,
486 /** This function finds an object belonging to a given cursor
487 position. It assumes that Layout() has been called before.
488 @param dc the wxDC to use for calculations
489 @param xpos screen x position
490 @param found if non-NULL set to false if we return the last
491 object before the cursor, to true if we really have an object
493 @return pointer to the object
495 wxLayoutObject
* FindObjectScreen(wxDC
&dc
, CoordType xpos
, bool
499 /**@name List traversal */
501 /// Returns pointer to next line.
502 wxLayoutLine
*GetNextLine(void) const { return m_Next
; }
503 /// Returns pointer to previous line.
504 wxLayoutLine
*GetPreviousLine(void) const { return m_Previous
; }
505 /// Sets the link to the next line.
506 void SetNext(wxLayoutLine
*next
)
507 { m_Next
= next
; if(next
) next
->m_Previous
= this; }
508 /// Sets the link to the previous line.
509 void SetPrevious(wxLayoutLine
*previous
)
510 { m_Previous
= previous
; if(previous
) previous
->m_Next
= this; }
513 /// Returns the position of this line on the canvas.
514 wxPoint
GetPosition(void) const { return m_Position
; }
515 /// Returns the height of this line.
516 CoordType
GetHeight(void) const { return m_Height
; }
517 /// Returns the width of this line.
518 CoordType
GetWidth(void) const { return m_Width
; }
519 /** This will recalculate the position and size of this line.
520 If called recursively it will abort if the position of an
521 object is unchanged, assuming that none of the following
522 objects need to move.
523 @param recurse if greater 0 then it will be used as the
524 minimum(!) recursion level, continue with all lines till the end of
525 the list or until the coordinates no longer changed.
527 void RecalculatePositions(int recurse
, wxLayoutList
*llist
);
528 /// Recalculates the position of this line on the canvas.
529 wxPoint
RecalculatePosition(wxLayoutList
*llist
);
531 /** Copies the contents of this line to another wxLayoutList
532 @param llist the wxLayoutList destination
533 @param from x cursor coordinate where to start
534 @param to x cursor coordinate where to stop, -1 for end of line
536 void Copy(wxLayoutList
*llist
,
540 #ifdef WXLAYOUT_DEBUG
545 /// Destructor is private. Use DeleteLine() to remove it.
548 /**@name Functions to let the lines synchronise with each other. */
550 /** Sets the height of this line. Will mark following lines as
552 @param height new height
554 void SetHeight(CoordType height
, wxLayoutList
*llist
)
555 { m_Height
= height
; RecalculatePositions(true, llist
); }
557 /** Moves the linenumbers one on, because a line has been inserted
559 @param delta either +1 or -1
561 void MoveLines(int delta
)
563 m_LineNumber
+= delta
;
564 if(m_Next
) m_Next
->MoveLines(delta
);
569 CoordType m_LineNumber
;
570 /// The line length in cursor positions.
572 /// The total height of the line.
574 /// The total width of the line on screen.
576 /// The baseline for drawing objects
577 CoordType m_BaseLine
;
578 /// The position on the canvas.
580 /// The list of objects
581 wxLayoutObjectList m_ObjectList
;
582 /// Have we been changed since the last layout?
584 /// Pointer to previous line if it exists.
585 wxLayoutLine
*m_Previous
;
586 /// Pointer to next line if it exists.
587 wxLayoutLine
*m_Next
;
588 /// Just to suppress gcc compiler warnings.
591 wxLayoutLine(const wxLayoutLine
&);
595 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
597 The wxLayoutList object
599 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
600 /** The wxLayoutList is a list of wxLayoutLine objects. It provides a
601 higher level of abstraction for the text and can generally be considered
602 as representing "the text".
613 void Clear(int family
= wxROMAN
,
614 int size
=WXLO_DEFAULTFONTSIZE
,
620 /// Empty: clear the list but leave font settings.
623 /**@name Cursor Management */
625 /** Set new cursor position.
626 @param p new position
627 @return bool if it could be set
629 bool MoveCursorTo(wxPoint
const &p
);
630 /** Move cursor up or down.
632 @return bool if it could be moved
634 bool MoveCursorVertically(int n
);
635 /** Move cursor left or right.
637 @return bool if it could be moved
639 bool MoveCursorHorizontally(int n
);
641 /// Move cursor to end of line.
642 void MoveCursorToEndOfLine(void)
644 wxASSERT(m_CursorLine
);
645 MoveCursorHorizontally(m_CursorLine
->GetLength()-m_CursorPos
.x
);
648 /// Move cursor to begin of line.
649 void MoveCursorToBeginOfLine(void)
650 { MoveCursorHorizontally(-m_CursorPos
.x
); }
652 /// Returns current cursor position.
653 wxPoint
GetCursorPos(wxDC
&dc
) const { return m_CursorPos
; }
656 /**@name Editing functions.
657 All of these functions return true on success and false on
660 /// Insert text at current cursor position.
661 bool Insert(wxString
const &text
);
662 /// Insert some other object at current cursor position.
663 bool Insert(wxLayoutObject
*obj
);
664 /// Inserts a linebreak at current cursor position.
665 bool LineBreak(void);
666 /** Wraps the current line. Searches to the left of the cursor to
667 break the line. Does nothing if the cursor position is before
668 the break position parameter.
669 @param column the break position for the line, maximum length
670 @return true if line got broken
672 bool WrapLine(CoordType column
);
673 /** This function deletes npos cursor positions.
674 @param npos how many positions
675 @return true if everything got deleted
677 bool Delete(CoordType npos
);
679 /** Delete the next n lines.
680 @param n how many lines to delete
681 @return how many it could not delete
683 int DeleteLines(int n
);
685 /// Delete to end of line.
686 void DeleteToEndOfLine(void)
688 wxASSERT(m_CursorLine
);
689 Delete(m_CursorLine
->GetLength()-m_CursorPos
.x
);
691 /// Delete to begin of line.
692 void DeleteToBeginOfLine(void)
694 wxASSERT(m_CursorLine
);
695 CoordType n
= m_CursorPos
.x
;
696 #ifdef WXLAYOUT_DEBUG
697 wxASSERT(MoveCursorHorizontally(-n
));
699 MoveCursorHorizontally(-n
);
704 /** Delete the next word.
706 void DeleteWord(void)
708 wxASSERT(m_CursorLine
);
709 m_CursorLine
->DeleteWord(m_CursorPos
.x
);
714 /**@name Formatting options */
716 /// sets font parameters
717 void SetFont(int family
, int size
, int style
,
718 int weight
, int underline
,
721 /// sets font parameters, colours by name
722 void SetFont(int family
=-1, int size
= -1, int style
=-1,
723 int weight
=-1, int underline
= -1,
724 char const *fg
= NULL
,
725 char const *bg
= NULL
);
726 /// changes to the next larger font size
727 inline void SetFontLarger(void)
728 { SetFont(-1,(12*m_FontPtSize
)/10); }
729 /// changes to the next smaller font size
730 inline void SetFontSmaller(void)
731 { SetFont(-1,(10*m_FontPtSize
)/12); }
734 inline void SetFontFamily(int family
) { SetFont(family
); }
736 inline void SetFontSize(int size
) { SetFont(-1,size
); }
738 inline void SetFontStyle(int style
) { SetFont(-1,-1,style
); }
740 inline void SetFontWeight(int weight
) { SetFont(-1,-1,-1,weight
); }
741 /// toggle underline flag
742 inline void SetFontUnderline(bool ul
) { SetFont(-1,-1,-1,-1,(int)ul
); }
743 /// set font colours by name
744 inline void SetFontColour(char const *fg
, char const *bg
= NULL
)
745 { SetFont(-1,-1,-1,-1,-1,fg
,bg
); }
746 /// set font colours by colour
747 inline void SetFontColour(wxColour
*fg
, wxColour
*bg
= NULL
)
748 { SetFont(-1,-1,-1,-1,-1,fg
,bg
); }
751 /// Used by wxLayoutObjectCmd only:
752 void SetColour_Internal(wxColour
*fg
, wxColour
*bg
)
753 { if(fg
) m_ColourFG
= *fg
; if(bg
) m_ColourBG
= *bg
; }
755 Returns a pointer to the default settings.
756 This is only valid temporarily and should not be stored
758 @return the default settings of the list
760 wxLayoutObjectCmd
*GetDefaults(void) { return m_DefaultSetting
; }
765 /** Draws the complete list on a wxDC.
766 @param dc the wxDC to draw on
767 @param offset an optional offset to shift printout
768 @param top optional y coordinate where to start drawing
769 @param bottom optional y coordinate where to stop drawing
772 const wxPoint
&offset
= wxPoint(0,0),
773 CoordType top
= -1, CoordType bottom
= -1);
775 /** Calculates new layout for the list, like Draw() but does not
777 @param dc the wxDC to draw on
778 @param bottom optional y coordinate where to stop calculating
780 void Layout(wxDC
&dc
, CoordType bottom
= -1);
782 /** Calculates new sizes for everything in the list, like Layout()
783 but this is needed after the list got changed.
784 @param dc the wxDC to draw on
785 @param bottom optional y coordinate where to stop calculating
787 void Recalculate(wxDC
&dc
, CoordType bottom
= -1);
789 /** Returns the size of the list in screen coordinates.
790 The return value only makes sense after the list has been
792 @return a wxPoint holding the maximal x/y coordinates used for
795 wxPoint
GetSize(void) const;
797 /** Returns the cursor position on the screen.
798 @return cursor position in pixels
800 wxPoint
GetCursorScreenPos(wxDC
&dc
);
802 /** Draws the cursor.
803 @param active If true, draw a bold cursor to mark window as
805 @param translate optional translation of cursor coords on screen
807 void DrawCursor(wxDC
&dc
,
809 const wxPoint
& translate
= wxPoint(0,0));
811 /** This function finds an object belonging to a given screen
812 position. It assumes that Layout() has been called before.
813 @param pos screen position
814 @param cursorPos if non NULL, store cursor position in there
815 @param found if used, set this to true if we really found an
816 object, to false if we had to take the object near to it
817 @return pointer to the object
819 wxLayoutObject
* FindObjectScreen(wxDC
&dc
,
821 wxPoint
*cursorPos
= NULL
,
824 /** Called by the objects to update the update rectangle.
825 @param x horizontal coordinate to include in rectangle
826 @param y vertical coordinate to include in rectangle
828 void SetUpdateRect(CoordType x
, CoordType y
);
829 /** Called by the objects to update the update rectangle.
830 @param p a point to include in it
832 inline void SetUpdateRect(const wxPoint
&p
)
833 { SetUpdateRect(p
.x
,p
.y
); }
834 /// Invalidates the update rectangle.
835 void InvalidateUpdateRect(void) { m_UpdateRectValid
= false; }
836 /// Returns the update rectangle.
837 const wxRect
*GetUpdateRect(void) const { return &m_UpdateRect
; }
840 /**@name For exporting one object after another. */
842 /** Returns a pointer to the first line in the list. */
843 wxLayoutLine
*GetFirstLine(void)
845 wxASSERT(m_FirstLine
);
850 /// Begin selecting text.
851 void StartSelection(void);
852 // Continue selecting text
853 void ContinueSelection(void);
854 /// End selecting text.
855 void EndSelection(void);
856 /// Are we still selecting text?
857 bool IsSelecting(void);
858 bool IsSelected(const wxPoint
&cursor
);
860 /// Return the selection as a wxLayoutList:
861 wxLayoutList
*GetSelection(void);
863 wxLayoutList
*Copy(const wxPoint
&from
= wxPoint(0,0),
864 const wxPoint
&to
= wxPoint(-1,-1));
866 /// starts highlighting of text for selections
867 void StartHighlighting(wxDC
&dc
);
868 /// ends highlighting of text for selections
869 void EndHighlighting(wxDC
&dc
);
871 /** Tests whether this layout line is selected and needs
873 @param line to test for
874 @param from set to first cursorpos to be highlighted (for returncode == -1)
875 @param to set to last cursorpos to be highlighted (for returncode == -1)
876 @return 0 = not selected, 1 = fully selected, -1 = partially
880 int IsSelected(const wxLayoutLine
*line
, CoordType
*from
, CoordType
*to
);
882 #ifdef WXLAYOUT_DEBUG
887 void InternalClear(void);
888 /** Calculates the cursor position on the screen.
890 void UpdateCursorScreenPos(wxDC
&dc
);
892 /// The list of lines.
893 wxLayoutLine
*m_FirstLine
;
894 /// The update rectangle which needs to be refreshed:
896 /// Is the update rectangle valid?
897 bool m_UpdateRectValid
;
898 /**@name Cursor Management */
900 /// Where the text cursor (column,line) is.
902 /// The size of the cursor.
903 wxPoint m_CursorSize
;
904 /// Where the cursor should be drawn.
905 wxPoint m_CursorScreenPos
;
906 /// The line where the cursor is.
907 wxLayoutLine
*m_CursorLine
;
910 /// A structure for the selection.
913 Selection() { m_valid
= false; m_selecting
= false; }
916 wxPoint m_CursorA
, m_CursorB
;
918 /** @name Font parameters. */
920 int m_FontFamily
, m_FontStyle
, m_FontWeight
;
922 bool m_FontUnderline
;
926 /// the default setting:
927 wxLayoutObjectCmd
*m_DefaultSetting
;
934 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
936 The wxLayoutPrintout object for printing within the wxWindows print
939 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
940 /** This class implements a wxPrintout for printing a wxLayoutList within
941 the wxWindows printing framework.
943 class wxLayoutPrintout
: public wxPrintout
947 @param llist pointer to the wxLayoutList to be printed
948 @param title title for PS file or windows
950 wxLayoutPrintout(wxLayoutList
*llist
,
951 wxString
const & title
=
952 "wxLayout Printout");
956 /** Function which prints the n-th page.
957 @param page the page number to print
958 @return bool true if we are not at end of document yet
960 bool OnPrintPage(int page
);
961 /** Checks whether page exists in document.
962 @param page number of page
963 @return true if page exists
965 bool HasPage(int page
);
967 /** Gets called from wxWindows to find out which pages are existing.
968 I'm not totally sure about the parameters though.
969 @param minPage the first page in the document
970 @param maxPage the last page in the document
971 @param selPageFrom the first page to be printed
972 @param selPageTo the last page to be printed
974 void GetPageInfo(int *minPage
, int *maxPage
,
975 int *selPageFrom
, int *selPageTo
);
977 /** This little function scales the DC so that the printout has
978 roughly the same size as the output on screen.
979 @param dc the wxDC to scale
980 @return the scale that was applied
982 float ScaleDC(wxDC
*dc
);
985 virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
988 /// The list to print.
989 wxLayoutList
*m_llist
;
990 /// Title for PS file or window.
992 /// The real paper size.
993 int m_PageHeight
, m_PageWidth
;
994 /// How much we actually print per page.
995 int m_PrintoutHeight
;
996 /// How many pages we need to print.
998 /// Top left corner where we start printing.