# define Str(str) str
#endif
+#define WXLO_DEFAULTFONTSIZE 12
+
/// Types of currently supported layout objects.
enum wxLayoutObjectType
{ WXLO_TYPE_INVALID = 0, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK };
*/
virtual void Layout(wxDC & dc,
wxPoint position,
- CoordType baseLine) {}
+ CoordType baseLine)
+ { m_Position = position; }
/** Draws an object.
@param dc the wxDC to draw on
+ @param translation to be added to coordinates
*/
- virtual void Draw(wxDC & dc) {}
+ virtual void Draw(wxDC & dc, wxPoint const &translate) {}
/** Calculates and returns the size of the object.
@param baseLine pointer where to store the baseline position of
wxLayoutObjectText(const String &txt);
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; }
- virtual void Layout(wxDC &dc, wxPoint position, CoordType baseLine);
- virtual void Draw(wxDC &dc);
+ virtual void Layout(wxDC &dc, wxPoint position, CoordType
+ baseLine);
+
+ virtual void Draw(wxDC &dc, wxPoint const &translate);
/** This returns the height and in baseLine the position of the
text's baseline within it's box. This is needed to properly
align text objects.
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; }
virtual void Layout(wxDC &dc, wxPoint position, CoordType baseLine);
- virtual void Draw(wxDC &dc);
+ virtual void Draw(wxDC &dc, wxPoint const &translate);
virtual wxPoint GetSize(CoordType *baseLine = NULL) const;
virtual bool IsDirty(void) const { return m_IsDirty; }
{
public:
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; }
- virtual void Draw(wxDC &dc);
+ virtual void Draw(wxDC &dc, wxPoint const &translate);
virtual void Layout(wxDC &dc, wxPoint position, CoordType baseLine);
wxLayoutObjectCmd(int size, int family, int style, int weight,
bool underline,
class wxLayoutPrintout;
+class wxLayoutMargins
+{
+public:
+ wxLayoutMargins() { top = left = 0; bottom = right = -1; }
+ int top;
+ int left;
+ int bottom;
+ int right;
+};
+
/**
This class provides a high level abstraction to the wxFText
classes.
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_FontPtSize)/10); }
+ /// changes to the next smaller font size
+ inline void SetFontSmaller(void)
+ { SetFont(-1,(10*m_FontPtSize)/12); }
+
/// set font family
inline void SetFontFamily(int family) { SetFont(family); }
/// set font size
/** Re-layouts the list on a DC.
- @param findObject if true, return the object occupying the
- position specified by coords
- @param coords position where to find the object
- @param pageNo if > 0, print only that page of a document (for
- printing)
- @param reallyDraw set this to false if you don't want to draw but
- just calculate the coordinates
- @param hasDrawn set to true if a page has been printed
- @return if findObject == true, the object or NULL
+ @param dc the dc to layout for
+ @param margins if not NULL, use these top and left margins
*/
- void Layout(wxDC &dc);
+ void Layout(wxDC &dc, wxLayoutMargins *margins = NULL);
/** Draw the list on a given DC.
- @param pageNo if > 0, print only that page of a document (for
- printing)
+ @param dc the dc to layout for
+ @param fromLine the first graphics line from where to draw
+ @param toLine the last line at which to draw
+ @param start if != iterator(NULL) start drawing from here
*/
void Draw(wxDC &dc,
CoordType fromLine = -1,
CoordType toLine = -1,
- iterator start = iterator(NULL));
+ iterator start = iterator(NULL),
+ wxPoint const &translate = wxPoint(0,0));
/** Deletes at least to the end of line and redraws */
void EraseAndDraw(wxDC &dc, iterator start = iterator(NULL));
bool IsEditable(void) const { return m_Editable; }
/// move cursor, returns true if it could move to the desired position
bool MoveCursor(int dx = 0, int dy = 0);
- void SetCursor(wxPoint const &p) { m_CursorPosition = p; }
+ void SetCursor(wxPoint const &p) { m_CursorPos = p; }
void DrawCursor(wxDC &dc, bool erase = false);
/// Get current cursor position cursor coords
- wxPoint GetCursor(void) const { return m_CursorPosition; }
+ wxPoint GetCursor(void) const { return m_CursorPos; }
/// Gets graphical coordinates of cursor
wxPoint GetCursorCoords(void) const { return m_CursorCoords; }
void Delete(CoordType count = 1);
void Insert(String const &text);
void Insert(wxLayoutObjectBase *obj);
- void Clear(int family = wxROMAN, int size=12, int style=wxNORMAL, int weight=wxNORMAL,
+ void Clear(int family = wxROMAN, int size=WXLO_DEFAULTFONTSIZE, int style=wxNORMAL, int weight=wxNORMAL,
int underline=0, char const *fg="black", char const *bg="white");
- /// return a pointer to the default settings:
+ /// return a pointer to the default settings (dangerous, why?) FIXME:
wxLayoutObjectCmd const *GetDefaults(void) const { return m_DefaultSetting ; }
wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL);
//---- this is needed for editing:
/// where is the text cursor (column,line):
- wxPoint m_CursorPosition;
+ wxPoint m_CursorPos;
/// where to draw the cursor
wxPoint m_CursorCoords;
/// how large to draw it
wxPoint m_CursorSize;
-
+ /// object iterator for current cursor position:
+ iterator m_CursorObject;
+ /// position of cursor within m_CursorObject:
+ int m_CursorOffset;
+
/// to store content overwritten by cursor
wxMemoryDC m_CursorMemDC;
class wxLayoutPrintout: public wxPrintout
{
public:
- wxLayoutPrintout(wxLayoutList &llist, wxString const & title = "My printout")
- :wxPrintout(title)
- { m_llist = &llist; m_maxPage = 0; }
+ wxLayoutPrintout(wxLayoutList &llist, wxString const & title =
+ "wxLayout Printout");
bool OnPrintPage(int page);
bool HasPage(int page);
bool OnBeginDocument(int startPage, int endPage);
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int
*selPageTo);
void OnPreparePrinting(void);
+protected:
+ virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
+
private:
wxLayoutList *m_llist;
- int m_maxPage;
+ wxString m_title;
+ int m_PageHeight, m_PageWidth;
+ // how much we actually print per page
+ int m_PrintoutHeight;
+ wxLayoutMargins m_Margins;
+ int m_NumOfPages;
};
#endif // WXLLIST_H