X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47908e25f992135fbc8c9573870784c62654e9e9..76810b8c97de5bf1086e1dc72efa0d9900ea0a58:/user/wxLayout/wxllist.h diff --git a/user/wxLayout/wxllist.h b/user/wxLayout/wxllist.h index fc5f5a619c..8c34fc1410 100644 --- a/user/wxLayout/wxllist.h +++ b/user/wxLayout/wxllist.h @@ -14,13 +14,22 @@ #include "kbList.h" -#include +#include "wx/wx.h" +#include "wx/print.h" +#include "wx/printdlg.h" +#include "wx/generic/printps.h" +#include "wx/generic/prntdlgg.h" // skip the following defines if embedded in M application -#ifndef MCONFIG_H -// for testing only: +#ifdef M_BASEDIR +# ifdef DEBUG +//# define WXLAYOUT_DEBUG +# endif +#else + // for testing only: # define WXLAYOUT_DEBUG -//# define USE_STD_STRING + // The wxLayout classes can be compiled with std::string instead of wxString + //# define USE_STD_STRING #endif #ifdef USE_STD_STRING @@ -34,7 +43,7 @@ /// Types of currently supported layout objects. enum wxLayoutObjectType -{ WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK }; +{ WXLO_TYPE_INVALID = 0, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK }; /// Type used for coordinates in drawing. typedef long CoordType; @@ -42,8 +51,9 @@ typedef long CoordType; class wxLayoutList; class wxLayoutObjectBase; -/// Define a list type of wxLayoutObjectBase pointers. -KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObjectBase); +class wxDC; +class wxColour; +class wxFont; /** The base class defining the interface to each object which can be part of the layout. Each object needs to draw itself and calculate @@ -60,8 +70,8 @@ public: @param baseLine the baseline for alignment, from top of box @draw if set to false, do not draw but just calculate sizes */ - virtual void Draw( wxDC &WXUNUSED(dc), wxPoint WXUNUSED(position), - CoordType WXUNUSED(baseLine), bool draw = true) {}; + virtual void Draw(wxDC &dc, wxPoint position, CoordType baseLine, + bool draw = true) {}; /** Calculates and returns the size of the object. May need to be called twice to work. @@ -70,9 +80,8 @@ public: baseline) @return the size of the object's box in pixels */ - virtual wxPoint GetSize( CoordType *WXUNUSED(baseLine) ) const - { return wxPoint(0,0); }; - + virtual wxPoint GetSize(CoordType *baseLine) const { return + wxPoint(0,0); }; /// returns the number of cursor positions occupied by this object virtual CoordType CountPositions(void) const { return 1; } @@ -95,6 +104,10 @@ private: void * m_UserData; }; +/// Define a list type of wxLayoutObjectBase pointers. +KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObjectBase); + + /// object for text block class wxLayoutObjectText : public wxLayoutObjectBase { @@ -134,8 +147,9 @@ public: bool draw = true); virtual wxPoint GetSize(CoordType *baseLine) const; wxLayoutObjectIcon(wxIcon *icon); + private: - wxIcon * m_Icon; + wxIcon *m_Icon; }; /// for export to html: @@ -179,6 +193,8 @@ public: }; +class wxLayoutPrintout; + /** This class provides a high level abstraction to the wxFText classes. @@ -219,13 +235,18 @@ public: @param findObject if true, return the object occupying the position specified by coords @param coords position where to find the object + @pageNo if > 0, print only that page of a document (for + printing) + @reallyDraw set this to false if you don't want to draw but just calculate the coordinates @return if findObject == true, the object or NULL */ wxLayoutObjectBase *Draw(wxDC &dc, bool findObject = false, - wxPoint const &coords = wxPoint(0,0)); + wxPoint const &coords = wxPoint(0,0), + int pageNo = -1, bool reallyDraw = true); #ifdef WXLAYOUT_DEBUG void Debug(void); + void ShowCurrentObject(); #endif @@ -233,13 +254,17 @@ public: void GetSize(CoordType *max_x, CoordType *max_y, CoordType *lineHeight); + /**@name Functionality for editing */ //@{ /// set list editable or read only - void SetEditable(bool editable = true) { m_Editable = true; } - /// move cursor - void MoveCursor(int dx = 0, int dy = 0); + void SetEditable(bool editable = true) { m_Editable = editable; } + /// return true if list is editable + 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; } + wxPoint GetCursor(void) const { return m_CursorPosition; } /// delete one or more cursor positions void Delete(CoordType count = 1); void Insert(String const &text); @@ -250,7 +275,14 @@ public: /// return a pointer to the default settings: wxLayoutObjectCmd const *GetDefaults(void) const { return m_DefaultSetting ; } - //@} + wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL); + // get the length of the line with the object pointed to by i, offs + // only used to decide whether we are before or after linebreak + CoordType GetLineLength(wxLayoutObjectList::iterator i, + CoordType offs = 0); + wxLayoutPrintout *MakePrintout(wxString const &name); + +//@} protected: /// font parameters: int m_FontFamily, m_FontStyle, m_FontWeight; @@ -284,11 +316,23 @@ protected: bool m_Editable; /// find the object to the cursor position and returns the offset /// in there - wxLayoutObjectList::iterator FindObjectCursor(wxPoint const &cpos, CoordType *offset = NULL); - wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL); - // get the length of the line with the object pointed to by i - CoordType GetLineLength(wxLayoutObjectList::iterator i); + wxLayoutObjectList::iterator FindObjectCursor(wxPoint *cpos, CoordType *offset = NULL); }; +class wxLayoutPrintout: public wxPrintout +{ + public: + wxLayoutPrintout(wxLayoutList &llist, wxString const & title = "My printout"):wxPrintout(title) + { m_llist = &llist; m_maxPage = 0; } + bool OnPrintPage(int page); + bool HasPage(int page); + bool OnBeginDocument(int startPage, int endPage); + void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int + *selPageTo); +private: + wxLayoutList *m_llist; + int m_maxPage; +}; + #endif // WXLLIST_H