]> git.saurik.com Git - wxWidgets.git/blobdiff - user/wxLayout/wxllist.h
Added new wxBitmapButton implementation
[wxWidgets.git] / user / wxLayout / wxllist.h
index 512b9117df45e58a09cad99cd8c17468cc0f30ff..a172072a87b53bf28a530f3cab39068c1654f7cb 100644 (file)
@@ -44,6 +44,8 @@
 #   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 };
@@ -79,12 +81,14 @@ public:
    */
    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 
@@ -140,8 +144,10 @@ public:
    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.
@@ -180,7 +186,7 @@ public:
 
    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; }  
@@ -205,7 +211,7 @@ class wxLayoutObjectCmd : public wxLayoutObjectBase
 {
 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,
@@ -234,6 +240,16 @@ public:
 
 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.
@@ -265,6 +281,13 @@ public:
                 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
@@ -280,26 +303,22 @@ public:
       
    
    /** 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));
@@ -334,11 +353,11 @@ public:
    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; }
    
@@ -346,10 +365,10 @@ public:
    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);
@@ -393,12 +412,16 @@ protected:
 
    //---- 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;
 
@@ -423,18 +446,25 @@ private:
 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