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
33 # define WXLAYOUT_DEBUG
37 # define WXLO_TRACE(x) wxLogDebug(x)
39 # define WXLO_TRACE(x)
44 #ifndef WXLO_DEFAULTFONTSIZE
45 # define WXLO_DEFAULTFONTSIZE 12
49 /// Types of currently supported layout objects.
50 enum wxLayoutObjectType
52 /// illegal object type, should never appear
53 WXLO_TYPE_INVALID
= 0,
54 /// text object, containing normal text
56 /// command object, containing font or colour changes
58 /// icon object, any kind of image
62 /// Type used for coordinates in drawing. Must be signed.
63 typedef long CoordType
;
65 // Forward declarations.
73 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
75 The wxLayout objects which make up the lines.
77 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
79 /** The base class defining the interface to each object which can be
80 part of the layout. Each object needs to draw itself and calculate
86 /** This structure can be used to contain data associated with the
88 It is refcounted, so the caller has to do a DecRef() on it
93 UserData() { m_refcount
= 1; }
94 void IncRef(void) { m_refcount
++; }
95 void DecRef(void) { m_refcount
--; if(m_refcount
== 0) delete this;}
99 virtual ~UserData() { wxASSERT(m_refcount
== 0); }
100 /// prevents gcc from generating stupid warnings
101 friend class dummy_UserData
;
104 /// return the type of this object
105 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_INVALID
; }
106 /** Calculates the size of an object.
107 @param dc the wxDC to draw on
109 virtual void Layout(wxDC
&) = 0;
112 @param dc the wxDC to draw on
113 @param coords where to draw the baseline of the object.
114 @param wxllist pointer to wxLayoutList
115 @param begin if !=-1, from which position on to highlight it
116 @param end if begin !=-1, how many positions to highlight it
118 virtual void Draw(wxDC
& /* dc */,
119 wxPoint
const & /* coords */,
120 class wxLayoutList
*wxllist
,
121 CoordType begin
= -1,
122 CoordType end
= -1) { }
124 /** Calculates and returns the size of the object.
125 @param top where to store height above baseline
126 @param bottom where to store height below baseline
127 @return the size of the object's box in pixels
129 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const
130 { *top
= 0; *bottom
= 0; return wxPoint(0,0); }
132 /// Return just the width of the object on the screen.
133 virtual CoordType
GetWidth(void) const { return 0; }
134 /// returns the number of cursor positions occupied by this object
135 virtual CoordType
GetLength(void) const { return 1; }
136 /** Returns the cursor offset relating to the screen x position
137 relative to begin of object.
138 @param dc the wxDC to use for calculations
139 @param xpos relative x position from head of object
140 @return cursor coordinate offset
142 virtual CoordType
GetOffsetScreen(wxDC
&dc
, CoordType xpos
) const { return 0; }
145 wxLayoutObject() { m_UserData
= NULL
; }
146 /// delete the user data
147 virtual ~wxLayoutObject() { if(m_UserData
) m_UserData
->DecRef(); }
149 #ifdef WXLAYOUT_DEBUG
150 virtual void Debug(void);
153 /** Tells the object about some user data. This data is associated
154 with the object and will be deleted at destruction time.
156 void SetUserData(UserData
*data
)
159 m_UserData
->DecRef();
161 m_UserData
->IncRef();
164 /** Return the user data. */
165 void * GetUserData(void) const { if(m_UserData
) m_UserData
->IncRef(); return m_UserData
; }
167 /** Makes a copy of this object.
169 virtual wxLayoutObject
*Copy(void) = 0;
171 /// optional data for application's use
172 UserData
*m_UserData
;
175 /// Define a list type of wxLayoutObject pointers.
176 KBLIST_DEFINE(wxLayoutObjectList
, wxLayoutObject
);
178 /// An illegal iterator to save typing.
179 #define NULLIT (wxLayoutObjectList::iterator(NULL))
180 /// The iterator type.
181 #define wxLOiterator wxLayoutObjectList::iterator
183 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
187 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
188 /** This class implements a wxLayoutObject holding plain text.
190 class wxLayoutObjectText
: public wxLayoutObject
193 wxLayoutObjectText(const wxString
&txt
);
195 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_TEXT
; }
196 virtual void Layout(wxDC
&dc
);
197 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
198 class wxLayoutList
*wxllist
,
199 CoordType begin
= -1,
201 /** Calculates and returns the size of the object.
202 @param top where to store height above baseline
203 @param bottom where to store height below baseline
204 @return the size of the object's box in pixels
206 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const;
207 /// Return just the width of the object on the screen.
208 virtual CoordType
GetWidth(void) const { return m_Width
; }
209 /** Returns the cursor offset relating to the screen x position
210 relative to begin of object.
211 @param dc the wxDC to use for calculations
212 @param xpos relative x position from head of object
213 @return cursor coordinate offset
215 virtual CoordType
GetOffsetScreen(wxDC
&dc
, CoordType xpos
) const;
218 #ifdef WXLAYOUT_DEBUG
219 virtual void Debug(void);
222 virtual CoordType
GetLength(void) const { return strlen(m_Text
.c_str()); }
225 wxString
& GetText(void) { return m_Text
; }
226 void SetText(wxString
const &text
) { m_Text
= text
; }
227 /** Makes a copy of this object.
229 virtual wxLayoutObject
*Copy(void);
232 /// size of the box containing text
233 long m_Width
, m_Height
;
234 /// Height above baseline.
236 /// Height below baseline.
240 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
244 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
245 /** This class implements a wxLayoutObject holding a graphic.
247 class wxLayoutObjectIcon
: public wxLayoutObject
250 wxLayoutObjectIcon(wxBitmap
*icon
);
251 wxLayoutObjectIcon(wxBitmap
const &icon
);
253 ~wxLayoutObjectIcon() { delete m_Icon
; }
255 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_ICON
; }
256 virtual void Layout(wxDC
&dc
);
257 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
258 class wxLayoutList
*wxllist
,
259 CoordType begin
= -1,
262 /** Calculates and returns the size of the object.
263 @param top where to store height above baseline
264 @param bottom where to store height below baseline
265 @return the size of the object's box in pixels
267 virtual wxPoint
GetSize(CoordType
* top
, CoordType
*bottom
) const;
268 /// Return just the width of the object on the screen.
269 virtual CoordType
GetWidth(void) const { return m_Icon
->GetWidth(); }
270 // return a pointer to the icon
271 wxBitmap
*GetIcon(void) const { return m_Icon
; }
272 /** Makes a copy of this object.
274 virtual wxLayoutObject
*Copy(void);
279 /// for export to html:
280 struct wxLayoutStyleInfo
284 family
= -1; // this marks the styleinfo as uninitialised
286 int size
, family
, style
, weight
;
288 unsigned fg_red
, fg_green
, fg_blue
;
289 unsigned bg_red
, bg_green
, bg_blue
;
292 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
296 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
297 /** This class implements a wxLayoutObject holding style change commands.
299 class wxLayoutObjectCmd
: public wxLayoutObject
302 virtual wxLayoutObjectType
GetType(void) const { return WXLO_TYPE_CMD
; }
303 virtual void Layout(wxDC
&dc
);
304 virtual void Draw(wxDC
&dc
, wxPoint
const &coords
,
305 class wxLayoutList
*wxllist
,
306 CoordType begin
= -1,
308 wxLayoutObjectCmd(int size
, int family
, int style
, int weight
,
310 wxColour
&fg
, wxColour
&bg
);
311 ~wxLayoutObjectCmd();
312 /** Stores the current style in the styleinfo structure */
313 void GetStyle(wxLayoutStyleInfo
*si
) const;
314 /// return the background colour for setting colour of window
315 wxColour
&GetBGColour(void) { return m_ColourBG
; }
316 /** Makes a copy of this object.
318 virtual wxLayoutObject
*Copy(void);
322 /// foreground colour
324 /// background colour
328 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
330 The wxLayoutLine object
332 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
334 /// forward declaration
337 /** This class represents a single line of objects to be displayed.
338 It knows its height and total size and whether it needs to be
340 It has pointers to its first and next line so it can automatically
341 update them as needed.
347 @param prev pointer to previous line or NULL
348 @param next pointer to following line or NULL
349 @param llist pointer to layout list
351 wxLayoutLine(wxLayoutLine
*prev
, wxLayoutList
*llist
);
352 /** This function inserts a new object at cursor position xpos.
353 @param xpos where to insert new object
354 @param obj the object to insert
355 @return true if that xpos existed and the object was inserted
357 bool Insert(CoordType xpos
, wxLayoutObject
*obj
);
359 /** This function inserts text at cursor position xpos.
360 @param xpos where to insert
361 @param text the text to insert
362 @return true if that xpos existed and the object was inserted
364 bool Insert(CoordType xpos
, wxString text
);
366 /** This function appends an object to the line.
367 @param obj the object to insert
369 void Append(wxLayoutObject
* obj
)
372 m_ObjectList
.push_back(obj
);
373 m_Length
+= obj
->GetLength();
376 /** This function appens the next line to this, i.e. joins the two
379 void MergeNextLine(wxLayoutList
*llist
);
381 /** This function deletes npos cursor positions from position xpos.
382 @param xpos where to delete
383 @param npos how many positions
384 @return number of positions still to be deleted
386 CoordType
Delete(CoordType xpos
, CoordType npos
);
388 /** This function breaks the line at a given cursor position.
389 @param xpos where to break it
390 @return pointer to the new line object replacing the old one
392 wxLayoutLine
*Break(CoordType xpos
, wxLayoutList
*llist
);
394 /** Deletes the next word from this position, including leading
396 This function does not delete over font changes, i.e. a word
397 with formatting instructions in the middle of it is treated as
398 two (three actually!) words. In fact, if the cursor is on a non-text object, that
399 one is treated as a word.
400 @param xpos from where to delete
401 @return true if a word was deleted
403 bool DeleteWord(CoordType npos
);
405 /** Finds a suitable position left to the given column to break the
407 @param column we want to break the line to the left of this
408 @return column for breaking line or -1 if no suitable location found
410 CoordType
GetWrapPosition(CoordType column
);
412 /** Finds the object which covers the cursor position xpos in this
414 @param xpos the column number
415 @param offset where to store the difference between xpos and
417 @return iterator to the object or NULLIT
419 wxLayoutObjectList::iterator
FindObject(CoordType xpos
, CoordType
422 /** Finds the object which covers the screen position xpos in this
424 @param dc the wxDC to use for calculations
425 @param xpos the screen x coordinate
426 @param offset where to store the difference between xpos and
428 @return iterator to the object or NULLIT
430 wxLayoutObjectList::iterator
FindObjectScreen(wxDC
&dc
,
433 bool *found
= NULL
) const ;
435 /** Get the first object in the list. This is used by the wxlparser
436 functions to export the list.
437 @return iterator to the first object
439 wxLayoutObjectList::iterator
GetFirstObject(void)
441 return m_ObjectList
.begin();
444 /** Deletes this line, returns pointer to next line.
445 @param update If true, update all following lines.
447 wxLayoutLine
*DeleteLine(bool update
, wxLayoutList
*llist
);
449 /**@name Cursor Management */
451 /** Return the line number of this line.
452 @return the line number
454 inline CoordType
GetLineNumber(void) const { return m_LineNumber
; }
455 /** Return the length of the line.
456 @return line lenght in cursor positions
458 inline CoordType
GetLength(void) const { return m_Length
; }
461 /**@name Drawing and Layout */
463 /** Draws the line on a wxDC.
464 @param dc the wxDC to draw on
465 @param llist the wxLayoutList
466 @param offset an optional offset to shift printout
470 const wxPoint
&offset
= wxPoint(0,0)) const;
472 /** Recalculates the positions of objects and the height of the
474 @param dc the wxDC to draw on
475 @param llist th e wxLayoutList
476 @param cursorPos if not NULL, set cursor screen position in there
477 @param cursorSize if not cursorPos != NULL, set cursor size in there
478 @param cx if cursorPos != NULL, the cursor x position
480 void Layout(wxDC
&dc
,
482 wxPoint
*cursorPos
= NULL
,
483 wxPoint
*cursorSize
= NULL
,
485 /** This function finds an object belonging to a given cursor
486 position. It assumes that Layout() has been called before.
487 @param dc the wxDC to use for calculations
488 @param xpos screen x position
489 @param found if non-NULL set to false if we return the last
490 object before the cursor, to true if we really have an object
492 @return pointer to the object
494 wxLayoutObject
* FindObjectScreen(wxDC
&dc
, CoordType xpos
, bool
498 /**@name List traversal */
500 /// Returns pointer to next line.
501 wxLayoutLine
*GetNextLine(void) const { return m_Next
; }
502 /// Returns pointer to previous line.
503 wxLayoutLine
*GetPreviousLine(void) const { return m_Previous
; }
504 /// Sets the link to the next line.
505 void SetNext(wxLayoutLine
*next
)
506 { m_Next
= next
; if(next
) next
->m_Previous
= this; }
507 /// Sets the link to the previous line.
508 void SetPrevious(wxLayoutLine
*previous
)
509 { m_Previous
= previous
; if(previous
) previous
->m_Next
= this; }
512 /// Returns the position of this line on the canvas.
513 wxPoint
GetPosition(void) const { return m_Position
; }
514 /// Returns the height of this line.
515 CoordType
GetHeight(void) const { return m_Height
; }
516 /// Returns the width of this line.
517 CoordType
GetWidth(void) const { return m_Width
; }
518 /** This will recalculate the position and size of this line.
519 If called recursively it will abort if the position of an
520 object is unchanged, assuming that none of the following
521 objects need to move.
522 @param recurse if greater 0 then it will be used as the
523 minimum(!) recursion level, continue with all lines till the end of
524 the list or until the coordinates no longer changed.
526 void RecalculatePositions(int recurse
, wxLayoutList
*llist
);
527 /// Recalculates the position of this line on the canvas.
528 wxPoint
RecalculatePosition(wxLayoutList
*llist
);
530 #ifdef WXLAYOUT_DEBUG
535 /// Destructor is private. Use DeleteLine() to remove it.
538 /**@name Functions to let the lines synchronise with each other. */
540 /** Sets the height of this line. Will mark following lines as
542 @param height new height
544 void SetHeight(CoordType height
, wxLayoutList
*llist
)
545 { m_Height
= height
; RecalculatePositions(true, llist
); }
547 /** Moves the linenumbers one on, because a line has been inserted
549 @param delta either +1 or -1
551 void MoveLines(int delta
)
553 m_LineNumber
+= delta
;
554 if(m_Next
) m_Next
->MoveLines(delta
);
559 CoordType m_LineNumber
;
560 /// The line length in cursor positions.
562 /// The total height of the line.
564 /// The total width of the line on screen.
566 /// The baseline for drawing objects
567 CoordType m_BaseLine
;
568 /// The position on the canvas.
570 /// The list of objects
571 wxLayoutObjectList m_ObjectList
;
572 /// Have we been changed since the last layout?
574 /// Pointer to previous line if it exists.
575 wxLayoutLine
*m_Previous
;
576 /// Pointer to next line if it exists.
577 wxLayoutLine
*m_Next
;
578 /// Just to suppress gcc compiler warnings.
581 wxLayoutLine(const wxLayoutLine
&);
585 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
587 The wxLayoutList object
589 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
590 /** The wxLayoutList is a list of wxLayoutLine objects. It provides a
591 higher level of abstraction for the text and can generally be considered
592 as representing "the text".
603 void Clear(int family
= wxROMAN
,
604 int size
=WXLO_DEFAULTFONTSIZE
,
610 /// Empty: clear the list but leave font settings.
613 /**@name Cursor Management */
615 /** Set new cursor position.
616 @param p new position
617 @return bool if it could be set
619 bool MoveCursorTo(wxPoint
const &p
);
620 /** Move cursor up or down.
622 @return bool if it could be moved
624 bool MoveCursorVertically(int n
);
625 /** Move cursor left or right.
627 @return bool if it could be moved
629 bool MoveCursorHorizontally(int n
);
631 /// Move cursor to end of line.
632 void MoveCursorToEndOfLine(void)
634 wxASSERT(m_CursorLine
);
635 MoveCursorHorizontally(m_CursorLine
->GetLength()-m_CursorPos
.x
);
638 /// Move cursor to begin of line.
639 void MoveCursorToBeginOfLine(void)
640 { MoveCursorHorizontally(-m_CursorPos
.x
); }
642 /// Returns current cursor position.
643 wxPoint
GetCursorPos(wxDC
&dc
) const { return m_CursorPos
; }
646 /**@name Editing functions.
647 All of these functions return true on success and false on
650 /// Insert text at current cursor position.
651 bool Insert(wxString
const &text
);
652 /// Insert some other object at current cursor position.
653 bool Insert(wxLayoutObject
*obj
);
654 /// Inserts a linebreak at current cursor position.
655 bool LineBreak(void);
656 /** Wraps the current line. Searches to the left of the cursor to
657 break the line. Does nothing if the cursor position is before
658 the break position parameter.
659 @param column the break position for the line, maximum length
660 @return true if line got broken
662 bool WrapLine(CoordType column
);
663 /** This function deletes npos cursor positions.
664 @param npos how many positions
665 @return true if everything got deleted
667 bool Delete(CoordType npos
);
669 /** Delete the next n lines.
670 @param n how many lines to delete
671 @return how many it could not delete
673 int DeleteLines(int n
);
675 /// Delete to end of line.
676 void DeleteToEndOfLine(void)
678 wxASSERT(m_CursorLine
);
679 Delete(m_CursorLine
->GetLength()-m_CursorPos
.x
);
681 /// Delete to begin of line.
682 void DeleteToBeginOfLine(void)
684 wxASSERT(m_CursorLine
);
685 CoordType n
= m_CursorPos
.x
;
686 #ifdef WXLAYOUT_DEBUG
687 wxASSERT(MoveCursorHorizontally(-n
));
689 MoveCursorHorizontally(-n
);
694 /** Delete the next word.
696 void DeleteWord(void)
698 wxASSERT(m_CursorLine
);
699 m_CursorLine
->DeleteWord(m_CursorPos
.x
);
704 /**@name Formatting options */
706 /// sets font parameters
707 void SetFont(int family
, int size
, int style
,
708 int weight
, int underline
,
711 /// sets font parameters, colours by name
712 void SetFont(int family
=-1, int size
= -1, int style
=-1,
713 int weight
=-1, int underline
= -1,
714 char const *fg
= NULL
,
715 char const *bg
= NULL
);
716 /// changes to the next larger font size
717 inline void SetFontLarger(void)
718 { SetFont(-1,(12*m_FontPtSize
)/10); }
719 /// changes to the next smaller font size
720 inline void SetFontSmaller(void)
721 { SetFont(-1,(10*m_FontPtSize
)/12); }
724 inline void SetFontFamily(int family
) { SetFont(family
); }
726 inline void SetFontSize(int size
) { SetFont(-1,size
); }
728 inline void SetFontStyle(int style
) { SetFont(-1,-1,style
); }
730 inline void SetFontWeight(int weight
) { SetFont(-1,-1,-1,weight
); }
731 /// toggle underline flag
732 inline void SetFontUnderline(bool ul
) { SetFont(-1,-1,-1,-1,(int)ul
); }
733 /// set font colours by name
734 inline void SetFontColour(char const *fg
, char const *bg
= NULL
) { SetFont(-1,-1,-1,-1,-1,fg
,bg
); }
736 Returns a pointer to the default settings.
737 This is only valid temporarily and should not be stored
739 @return the default settings of the list
741 wxLayoutObjectCmd
*GetDefaults(void) { return m_DefaultSetting
; }
746 /** Draws the complete list on a wxDC.
747 @param dc the wxDC to draw on
748 @param offset an optional offset to shift printout
749 @param top optional y coordinate where to start drawing
750 @param bottom optional y coordinate where to stop drawing
753 const wxPoint
&offset
= wxPoint(0,0),
754 CoordType top
= -1, CoordType bottom
= -1);
756 /** Calculates new layout for the list, like Draw() but does not
758 @param dc the wxDC to draw on
759 @param bottom optional y coordinate where to stop calculating
761 void Layout(wxDC
&dc
, CoordType bottom
= -1);
763 /** Calculates new sizes for everything in the list, like Layout()
764 but this is needed after the list got changed.
765 @param dc the wxDC to draw on
766 @param bottom optional y coordinate where to stop calculating
768 void Recalculate(wxDC
&dc
, CoordType bottom
= -1);
770 /** Returns the size of the list in screen coordinates.
771 The return value only makes sense after the list has been
773 @return a wxPoint holding the maximal x/y coordinates used for
776 wxPoint
GetSize(void) const;
778 /** Returns the cursor position on the screen.
779 @return cursor position in pixels
781 wxPoint
GetCursorScreenPos(wxDC
&dc
);
783 /** Draws the cursor.
784 @param active If true, draw a bold cursor to mark window as
786 @param translate optional translation of cursor coords on screen
788 void DrawCursor(wxDC
&dc
,
790 const wxPoint
& translate
= wxPoint(0,0));
792 /** This function finds an object belonging to a given screen
793 position. It assumes that Layout() has been called before.
794 @param pos screen position
795 @param cursorPos if non NULL, store cursor position in there
796 @param found if used, set this to true if we really found an
797 object, to false if we had to take the object near to it
798 @return pointer to the object
800 wxLayoutObject
* FindObjectScreen(wxDC
&dc
,
802 wxPoint
*cursorPos
= NULL
,
805 /** Called by the objects to update the update rectangle.
806 @param x horizontal coordinate to include in rectangle
807 @param y vertical coordinate to include in rectangle
809 void SetUpdateRect(CoordType x
, CoordType y
);
810 /** Called by the objects to update the update rectangle.
811 @param p a point to include in it
813 inline void SetUpdateRect(const wxPoint
&p
)
814 { SetUpdateRect(p
.x
,p
.y
); }
815 /// Invalidates the update rectangle.
816 void InvalidateUpdateRect(void) { m_UpdateRectValid
= false; }
817 /// Returns the update rectangle.
818 const wxRect
*GetUpdateRect(void) const { return &m_UpdateRect
; }
821 /**@name For exporting one object after another. */
823 /** Returns a pointer to the first line in the list. */
824 wxLayoutLine
*GetFirstLine(void)
826 wxASSERT(m_FirstLine
);
831 /// Begin selecting text.
832 void StartSelection(void);
833 // Continue selecting text
834 void ContinueSelection(void);
835 /// End selecting text.
836 void EndSelection(void);
837 /// Are we still selecting text?
838 bool IsSelecting(void);
839 bool IsSelected(const wxPoint
&cursor
);
841 /// starts highlighting of text for selections
842 void StartHighlighting(wxDC
&dc
);
843 /// ends highlighting of text for selections
844 void EndHighlighting(wxDC
&dc
);
846 /** Tests whether this layout line is selected and needs
848 @param line to test for
849 @param from set to first cursorpos to be highlighted (for returncode == -1)
850 @param to set to last cursorpos to be highlighted (for returncode == -1)
851 @return 0 = not selected, 1 = fully selected, -1 = partially
855 int IsSelected(const wxLayoutLine
*line
, CoordType
*from
, CoordType
*to
);
857 #ifdef WXLAYOUT_DEBUG
862 void InternalClear(void);
863 /** Calculates the cursor position on the screen.
865 void UpdateCursorScreenPos(wxDC
&dc
);
867 /// The list of lines.
868 wxLayoutLine
*m_FirstLine
;
869 /// The update rectangle which needs to be refreshed:
871 /// Is the update rectangle valid?
872 bool m_UpdateRectValid
;
873 /**@name Cursor Management */
875 /// Where the text cursor (column,line) is.
877 /// The size of the cursor.
878 wxPoint m_CursorSize
;
879 /// Where the cursor should be drawn.
880 wxPoint m_CursorScreenPos
;
881 /// The line where the cursor is.
882 wxLayoutLine
*m_CursorLine
;
885 /// A structure for the selection.
890 wxPoint m_CursorA
, m_CursorB
;
891 Selection() { m_valid
= false; m_selecting
= true; }
893 /** @name Font parameters. */
895 int m_FontFamily
, m_FontStyle
, m_FontWeight
;
897 bool m_FontUnderline
;
901 /// the default setting:
902 wxLayoutObjectCmd
*m_DefaultSetting
;
909 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
911 The wxLayoutPrintout object for printing within the wxWindows print
914 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
915 /** This class implements a wxPrintout for printing a wxLayoutList within
916 the wxWindows printing framework.
918 class wxLayoutPrintout
: public wxPrintout
922 @param llist pointer to the wxLayoutList to be printed
923 @param title title for PS file or windows
925 wxLayoutPrintout(wxLayoutList
*llist
,
926 wxString
const & title
=
927 "wxLayout Printout");
931 /** Function which prints the n-th page.
932 @param page the page number to print
933 @return bool true if we are not at end of document yet
935 bool OnPrintPage(int page
);
936 /** Checks whether page exists in document.
937 @param page number of page
938 @return true if page exists
940 bool HasPage(int page
);
942 /** Gets called from wxWindows to find out which pages are existing.
943 I'm not totally sure about the parameters though.
944 @param minPage the first page in the document
945 @param maxPage the last page in the document
946 @param selPageFrom the first page to be printed
947 @param selPageTo the last page to be printed
949 void GetPageInfo(int *minPage
, int *maxPage
,
950 int *selPageFrom
, int *selPageTo
);
952 /** This little function scales the DC so that the printout has
953 roughly the same size as the output on screen.
954 @param dc the wxDC to scale
955 @return the scale that was applied
957 float ScaleDC(wxDC
*dc
);
960 virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
963 /// The list to print.
964 wxLayoutList
*m_llist
;
965 /// Title for PS file or window.
967 /// The real paper size.
968 int m_PageHeight
, m_PageWidth
;
969 /// How much we actually print per page.
970 int m_PrintoutHeight
;
971 /// How many pages we need to print.
973 /// Top left corner where we start printing.