• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

fp_ContainerObject.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  * Copyright (C) 2002 Martin Sevior
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA.
00019  *
00020  * Code for allocation/requisition:
00021  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
00022  *
00023  * This library is free software; you can redistribute it and/or
00024  * modify it under the terms of the GNU Library General Public
00025  * License as published by the Free Software Foundation; either
00026  * version 2 of the License, or (at your option) any later version.
00027  *
00028  * This library is distributed in the hope that it will be useful,
00029  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00030  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00031  * Library General Public License for more details.
00032  *
00033  * You should have received a copy of the GNU Library General Public
00034  * License along with this library; if not, write to the
00035  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00036  * Boston, MA 02111-1307, USA.
00037  */
00038 
00039 /*
00040  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
00041  * file for a list of people on the GTK+ Team.  See the ChangeLog
00042  * files for a list of changes.  These files are distributed with
00043  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
00044  */
00045 
00046 #ifndef CONTAINEROBJECT_H
00047 #define CONTAINEROBJECT_H
00048 
00049 #ifdef FMT_TEST
00050 #include <stdio.h>
00051 #endif
00052 
00053 #include "ut_misc.h"
00054 #include "ut_types.h"
00055 #include "gr_Graphics.h"
00056 #include "ut_vector.h"
00057 #include "pt_Types.h"
00058 #include "gr_Image.h"
00059 #include "pp_PropertyMap.h"
00060 
00061 class fp_ContainerObject;
00062 
00063 typedef enum {
00064     FG_FILL_TRANSPARENT,
00065     FG_FILL_COLOR,
00066     FG_FILL_IMAGE
00067 } FG_Fill_Type;
00068 
00069 #define INITIAL_OFFSET -99999999
00070 
00071 typedef struct _fp_Requisition    fp_Requisition;
00072 typedef struct _fp_Allocation    fp_Allocation;
00073 
00078 struct _fp_Requisition
00079 {
00080   UT_sint32 width;
00081   UT_sint32 height;
00082 };
00083 
00089 struct _fp_Allocation
00090 {
00091   UT_sint32 x;
00092   UT_sint32 y;
00093   UT_sint32 width;
00094   UT_sint32 height;
00095 };
00096 
00097 class GR_Graphics;
00098 class FG_Graphic;
00099 class fl_SectionLayout;
00100 class fl_DocSectionLayout;
00101 class FL_DocLayout;
00102 class fp_Page;
00103 class fp_Container;
00104 struct dg_DrawArgs;
00105 struct fp_Sliver;
00106 struct dg_DrawArgs;
00107 
00108 typedef enum {
00109     FP_CONTAINER_RUN,      //0
00110     FP_CONTAINER_LINE,     //1
00111     FP_CONTAINER_VERTICAL, //2
00112     FP_CONTAINER_ROW,      //3
00113     FP_CONTAINER_TABLE,    // 4
00114     FP_CONTAINER_CELL,     // 5
00115     FP_CONTAINER_COLUMN,   // 6
00116     FP_CONTAINER_HDRFTR,   // 7
00117     FP_CONTAINER_ENDNOTE,  // 8
00118     FP_CONTAINER_FOOTNOTE, // 9
00119     FP_CONTAINER_COLUMN_POSITIONED, // 10
00120     FP_CONTAINER_COLUMN_SHADOW, // 11
00121     FP_CONTAINER_FRAME, // 12
00122     FP_CONTAINER_TOC, // 13
00123     FP_CONTAINER_ANNOTATION // 14
00124 
00125 } FP_ContainerType;
00126 
00127 class ABI_EXPORT fg_FillType
00128 {
00129     friend class fp_Run;
00130 public:
00131     fg_FillType(fg_FillType *pParent, fp_ContainerObject * pContainer, FG_Fill_Type iType);
00132     virtual ~ fg_FillType(void);
00133     void           setParent(fg_FillType * pParent);
00134     void           setColor(UT_RGBColor & color);
00135     void           setColor(const char * pszColor);
00136     void           setTransColor(UT_RGBColor & color);
00137     void           setTransColor(const char * pszColor);
00138     void           setImage(FG_Graphic * pGraphic, GR_Image * pImage,GR_Graphics * pG, UT_sint32 width, UT_sint32 height);
00139     void           setTransparent(void);
00140     void           setWidthHeight(GR_Graphics * pG, UT_sint32 width, UT_sint32 height, bool doImage = false);
00141     void           setWidth(GR_Graphics * pG, UT_sint32 width);
00142     void           setHeight(GR_Graphics * pG, UT_sint32 height);
00143     void           setDocLayout(FL_DocLayout * pDocLayout);
00144     void           markTransparentForPrint(void);
00145     void           Fill(GR_Graphics * pG, UT_sint32 & srcX, UT_sint32 & srcY, UT_sint32 x, UT_sint32 y, UT_sint32 width, UT_sint32 height);
00146     fg_FillType *  getParent(void) const;
00147     FG_Fill_Type   getFillType(void) const;
00148     const FL_DocLayout * getDocLayout(void) const;
00149     const UT_RGBColor *  getColor(void) const;
00150     void           setImagePointer(FG_Graphic ** pDocGraphic, GR_Image ** pDocImage);
00151     void           setIgnoreLineLevel(bool b);
00152 private:
00153     void                 _regenerateImage(GR_Graphics * pG);
00154     fg_FillType *        m_pParent;
00155     fp_ContainerObject * m_pContainer;
00156     FL_DocLayout *       m_pDocLayout;
00157     FG_Fill_Type         m_FillType;
00158     GR_Image *           m_pImage;
00159     FG_Graphic *         m_pGraphic;
00160     UT_uint32            m_iGraphicTick;
00161     bool                 m_bTransparentForPrint;
00162     UT_RGBColor          m_color;
00163     UT_RGBColor          m_TransColor;
00164     bool                 m_bTransColorSet;
00165     bool                 m_bColorSet;
00166     UT_sint32            m_iWidth;
00167     UT_sint32            m_iHeight;
00168     GR_Image **          m_pDocImage;
00169     FG_Graphic **        m_pDocGraphic;
00170     bool                 m_bIgnoreLineLevel;
00171 };
00172 
00173 
00174 class ABI_EXPORT fp_ContainerObject
00175 {
00176 public:
00177     fp_ContainerObject(FP_ContainerType iType, fl_SectionLayout* pSectionLayout);
00178     virtual ~fp_ContainerObject();
00183     FP_ContainerType    getContainerType(void) const { return m_iConType; }
00184     bool                isColumnType(void) const;
00185     virtual void        setWidth(UT_sint32) = 0;
00186     virtual void        setHeight(UT_sint32) = 0 ;
00187     virtual void        setX(UT_sint32, bool bDontClearIfNeeded = false) = 0;
00188     virtual void        setY(UT_sint32) = 0;
00189     virtual UT_sint32   getWidth(void) const = 0;
00190 
00191     // all containers that may wish to draw stuff outwith the normal
00192     // drawing region, such as the pilcrow on a line, should overwrite this
00193     virtual UT_sint32   getDrawingWidth(void) const {return getWidth();}
00194 
00195     virtual UT_sint32   getX(void) const = 0;
00196     virtual UT_sint32   getY(void) const = 0;
00197     fl_SectionLayout*   getSectionLayout(void) const
00198         { return m_pSectionLayout; }
00199     fl_DocSectionLayout *   getDocSectionLayout(void);
00200     void         setSectionLayout(fl_SectionLayout * pSL)
00201         { m_pSectionLayout = pSL; }
00202     virtual inline UT_BidiCharType getDirection(void) const
00203         { return m_iDirection;}
00204     virtual inline void setDirection(UT_BidiCharType c) {m_iDirection = c;}
00205     virtual UT_sint32   getHeight(void) const = 0;
00206 
00207 
00208     virtual void        draw(dg_DrawArgs*) = 0;
00209     virtual void        draw(GR_Graphics*) = 0;
00210     virtual void        clearScreen(void) = 0;
00211     GR_Graphics*        getGraphics(void) const;
00212     virtual fp_ContainerObject * getNext(void) const = 0;
00213     virtual fp_ContainerObject * getPrev(void) const = 0;
00214     virtual void        setNext(fp_ContainerObject * pNext) = 0;
00215     virtual void        setPrev(fp_ContainerObject * pNext) = 0;
00216     virtual bool        isVBreakable(void) = 0;
00217     virtual bool        isHBreakable(void) = 0;
00218     virtual UT_sint32   wantVBreakAt(UT_sint32) = 0;
00219     virtual UT_sint32   wantHBreakAt(UT_sint32) = 0;
00220     virtual fp_ContainerObject * VBreakAt(UT_sint32) =0;
00221     virtual fp_ContainerObject * HBreakAt(UT_sint32) = 0;
00222     virtual void            mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, bool& bBOL, bool& bEOL, bool& isTOC) = 0;
00223     virtual fp_Container * getNextContainerInSection(void) const = 0;
00224     virtual fp_Container * getPrevContainerInSection(void) const = 0;
00225     virtual UT_Rect *      getScreenRect() = 0;
00226     virtual void           markDirtyOverlappingRuns(UT_Rect & recScreen) = 0;
00227     const char *           getContainerString(void);
00228     void                   setAllowDelete(bool bDelete)
00229     { m_bCanDelete = bDelete;}
00230     bool                   canDelete(void)
00231     { return m_bCanDelete;}
00232     UT_sint32   getBreakTick(void) const
00233         { return  m_iBreakTick;}
00234     void        setBreakTick(UT_sint32 iTick)
00235         { m_iBreakTick = iTick;}
00236         void                ref(void)
00237     { m_iRef++;}
00238     void                unref(void)
00239     { m_iRef--;}
00240     UT_sint32           getRefCount(void)
00241     { return m_iRef;}
00242 private:
00246     FP_ContainerType        m_iConType;
00250     fl_SectionLayout*       m_pSectionLayout;
00251     UT_BidiCharType         m_iDirection;
00252     UT_sint32               m_iBreakTick;
00253     UT_sint32               m_iRef;
00254     bool                    m_bCanDelete;
00255 };
00256 
00257 
00258 class ABI_EXPORT fp_Container : public fp_ContainerObject
00259 {
00260 public:
00261     fp_Container(FP_ContainerType iType, fl_SectionLayout* pSectionLayout);
00262     virtual ~fp_Container();
00263 
00264     virtual void           setContainer(fp_Container * pContainer);
00265     fp_Container *         getContainer(void) const;
00266     fp_Container *         getColumn(void) const;
00267     fp_Page *              getPage(void) const;
00268     virtual UT_sint32      getMarginBefore(void) const =0;
00269     virtual UT_sint32      getMarginAfter(void) const =0;
00270     virtual fp_ContainerObject * getNext(void) const {return m_pNext;}
00271     virtual fp_ContainerObject * getPrev(void) const {return m_pPrev;}
00272     virtual void        setNext(fp_ContainerObject * pNext);
00273     virtual void        setPrev(fp_ContainerObject * pPrev);
00274     void                   clearCons(void)
00275         { m_vecContainers.clear();}
00276     fp_ContainerObject *   getNthCon(UT_sint32 i) const;
00277     void                   addCon(fp_ContainerObject * pCon);
00278     UT_sint32              countCons(void) const;
00279     UT_sint32              findCon(fp_ContainerObject * pCon) const;
00280     void                   justRemoveNthCon(UT_sint32 i);
00281     void                   deleteNthCon(UT_sint32 i);
00282     void                   insertConAt(fp_ContainerObject * pCon, UT_sint32 i);
00283     bool                   isEmpty(void) const;
00284     virtual UT_uint32   distanceFromPoint(UT_sint32 x, UT_sint32 y) =0;
00285     virtual void        recalcMaxWidth(bool bDontClearIfNeeded = false) = 0;
00286     virtual void        setAssignedScreenHeight(UT_sint32 iY) =0;
00287     bool                getPageRelativeOffsets(UT_Rect &r) const;
00288     bool                isOnScreen() const;
00289     fp_Container *      getMyBrokenContainer(void) const;
00290     void                setMyBrokenContainer(fp_Container * pMyBroken);
00291     void                clearBrokenContainers(void);
00292     UT_uint32           binarysearchCons(const void* key,int (*compar)(const void *,
00293                                                                  const void *));
00294     UT_uint32           getBrokenCount(void) { return m_cBrokenContainers; }
00295     void                incBrokenCount(void) { m_cBrokenContainers += 1; }
00296     void                decBrokenCount(void) { if (m_cBrokenContainers > 0) {
00297             m_cBrokenContainers -= 1; }}
00298 
00299         fg_FillType &       getFillType(void);
00300     const fg_FillType & getFillType(void) const;
00301     void                drawLine(const PP_PropertyMap::Line & style,
00302                      UT_sint32 left, UT_sint32 top,
00303                      UT_sint32 right, UT_sint32 bot,
00304                      GR_Graphics * pGr);
00305 
00306 private:
00307     fp_Container*          m_pContainer;
00308     fp_ContainerObject *   m_pNext;
00309     fp_ContainerObject *   m_pPrev;
00310     UT_GenericVector<fp_ContainerObject *> m_vecContainers;
00311     fp_Container *         m_pMyBrokenContainer;
00312     UT_uint32              m_cBrokenContainers;
00313     fg_FillType            m_FillType;
00314 };
00315 
00316 
00317 #endif /*  CONTAINEROBJECT_H */
00318 
00319 
00320 
00321 
00322 
00323 

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1