• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 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., 51 Franklin Street, Fifth Floor,
00036  * Boston, MA 02110-1301 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 "ut_option.h"
00056 #include "gr_Graphics.h"
00057 #include "ut_vector.h"
00058 #include "pt_Types.h"
00059 #include "gr_Image.h"
00060 #include "fg_Graphic.h"
00061 #include "pp_PropertyMap.h"
00062 
00063 class fp_ContainerObject;
00064 
00065 typedef enum {
00066     FG_FILL_TRANSPARENT,
00067     FG_FILL_COLOR,
00068     FG_FILL_IMAGE
00069 } FG_Fill_Type;
00070 
00071 #define INITIAL_OFFSET -99999999
00072 
00073 typedef struct _fp_Requisition    fp_Requisition;
00074 typedef struct _fp_Allocation    fp_Allocation;
00075 
00080 struct _fp_Requisition
00081 {
00082   UT_sint32 width;
00083   UT_sint32 height;
00084 };
00085 
00091 struct _fp_Allocation
00092 {
00093   UT_sint32 x;
00094   UT_sint32 y;
00095   UT_sint32 width;
00096   UT_sint32 height;
00097 };
00098 
00099 class GR_Graphics;
00100 class fl_SectionLayout;
00101 class fl_DocSectionLayout;
00102 class FL_DocLayout;
00103 class fp_Page;
00104 class fp_Container;
00105 struct dg_DrawArgs;
00106 struct fp_Sliver;
00107 struct dg_DrawArgs;
00108 
00109 typedef enum {
00110     FP_CONTAINER_RUN,      //0
00111     FP_CONTAINER_LINE,     //1
00112     FP_CONTAINER_VERTICAL, //2
00113     FP_CONTAINER_ROW,      //3
00114     FP_CONTAINER_TABLE,    // 4
00115     FP_CONTAINER_CELL,     // 5
00116     FP_CONTAINER_COLUMN,   // 6
00117     FP_CONTAINER_HDRFTR,   // 7
00118     FP_CONTAINER_ENDNOTE,  // 8
00119     FP_CONTAINER_FOOTNOTE, // 9
00120     FP_CONTAINER_COLUMN_POSITIONED, // 10
00121     FP_CONTAINER_COLUMN_SHADOW, // 11
00122     FP_CONTAINER_FRAME, // 12
00123     FP_CONTAINER_TOC, // 13
00124     FP_CONTAINER_ANNOTATION // 14
00125 
00126 } FP_ContainerType;
00127 
00128 class ABI_EXPORT fg_FillType
00129 {
00130     friend class fp_Run;
00131 public:
00132     fg_FillType(fg_FillType *pParent, fp_ContainerObject * pContainer, FG_Fill_Type iType);
00133     virtual ~ fg_FillType(void);
00134     void           setParent(fg_FillType * pParent);
00135     void           setColor(UT_RGBColor & color);
00136     void           setColor(const char * pszColor);
00137     void           setTransColor(UT_RGBColor & color);
00138     void           setTransColor(const char * pszColor);
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(const FG_SharedGraphicPtr & 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     UT_uint32            m_iGraphicTick;
00160     bool                 m_bTransparentForPrint;
00161     UT_RGBColor          m_color;
00162     UT_RGBColor          m_TransColor;
00163     bool                 m_bTransColorSet;
00164     bool                 m_bColorSet;
00165     UT_sint32            m_iWidth;
00166     UT_sint32            m_iHeight;
00167     GR_Image **          m_pDocImage;
00168     FG_SharedGraphicPtr  m_pDocGraphic;
00169     bool                 m_bIgnoreLineLevel;
00170 };
00171 
00172 
00173 class ABI_EXPORT fp_ContainerObject
00174 {
00175 public:
00176     fp_ContainerObject(FP_ContainerType iType, fl_SectionLayout* pSectionLayout);
00177     virtual ~fp_ContainerObject();
00182     FP_ContainerType    getContainerType(void) const { return m_iConType; }
00183     bool                isColumnType(void) const;
00184     virtual void        setWidth(UT_sint32) = 0;
00185     virtual void        setHeight(UT_sint32) = 0 ;
00186     virtual void        setX(UT_sint32, bool bDontClearIfNeeded = false) = 0;
00187     virtual void        setY(UT_sint32) = 0;
00188     virtual UT_sint32   getWidth(void) const = 0;
00189 
00190     // all containers that may wish to draw stuff outwith the normal
00191     // drawing region, such as the pilcrow on a line, should overwrite this
00192     virtual UT_sint32   getDrawingWidth(void) const {return getWidth();}
00193 
00194     virtual UT_sint32   getX(void) const = 0;
00195     virtual UT_sint32   getY(void) const = 0;
00196     fl_SectionLayout*   getSectionLayout(void) const
00197         { return m_pSectionLayout; }
00198     fl_DocSectionLayout *   getDocSectionLayout(void);
00199     void         setSectionLayout(fl_SectionLayout * pSL)
00200         { m_pSectionLayout = pSL; }
00201     virtual inline UT_BidiCharType getDirection(void) const
00202         { return m_iDirection;}
00203     virtual inline void setDirection(UT_BidiCharType c) {m_iDirection = c;}
00204     virtual UT_sint32   getHeight(void) const = 0;
00205 
00206 
00207     virtual void        draw(dg_DrawArgs*) = 0;
00208     virtual void        draw(GR_Graphics*) = 0;
00209     virtual void        clearScreen(void) = 0;
00210     GR_Graphics*        getGraphics(void) const;
00211     virtual fp_ContainerObject * getNext(void) const = 0;
00212     virtual fp_ContainerObject * getPrev(void) const = 0;
00213     virtual void        setNext(fp_ContainerObject * pNext) = 0;
00214     virtual void        setPrev(fp_ContainerObject * pNext) = 0;
00215     virtual bool        isVBreakable(void) = 0;
00216     virtual bool        isHBreakable(void) = 0;
00217     virtual UT_sint32   wantVBreakAt(UT_sint32) = 0;
00218     virtual UT_sint32   wantHBreakAt(UT_sint32) = 0;
00219     virtual fp_ContainerObject * VBreakAt(UT_sint32) =0;
00220     virtual fp_ContainerObject * HBreakAt(UT_sint32) = 0;
00221     virtual void            mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, bool& bBOL, bool& bEOL, bool& isTOC) = 0;
00222     virtual fp_Container * getNextContainerInSection(void) const = 0;
00223     virtual fp_Container * getPrevContainerInSection(void) const = 0;
00224     virtual UT_Option<UT_Rect>        getScreenRect() const = 0;
00225     virtual void           markDirtyOverlappingRuns(const UT_Rect & recScreen) = 0;
00226     const char *           getContainerString(void);
00227     void                   setAllowDelete(bool bDelete)
00228     { m_bCanDelete = bDelete;}
00229     bool                   canDelete(void)
00230     { return m_bCanDelete;}
00231     UT_sint32   getBreakTick(void) const
00232         { return  m_iBreakTick;}
00233     void        setBreakTick(UT_sint32 iTick)
00234         { m_iBreakTick = iTick;}
00235         void                ref(void)
00236     { m_iRef++;}
00237     void                unref(void)
00238     { m_iRef--;}
00239     UT_sint32           getRefCount(void)
00240     { return m_iRef;}
00241 private:
00245     FP_ContainerType        m_iConType;
00249     fl_SectionLayout*       m_pSectionLayout;
00250     UT_BidiCharType         m_iDirection;
00251     UT_sint32               m_iBreakTick;
00252     UT_sint32               m_iRef;
00253     bool                    m_bCanDelete;
00254 };
00255 
00256 
00257 class ABI_EXPORT fp_Container : public fp_ContainerObject
00258 {
00259 public:
00260     fp_Container(FP_ContainerType iType, fl_SectionLayout* pSectionLayout);
00261     virtual ~fp_Container();
00262 
00263     virtual void           setContainer(fp_Container * pContainer);
00264     fp_Container *         getContainer(void) const;
00265     fp_Container *         getColumn(void) const;
00266     fp_Page *              getPage(void) const;
00267     virtual UT_sint32      getMarginBefore(void) const =0;
00268     virtual UT_sint32      getMarginAfter(void) const =0;
00269     virtual fp_ContainerObject * getNext(void) const {return m_pNext;}
00270     virtual fp_ContainerObject * getPrev(void) const {return m_pPrev;}
00271     virtual void        setNext(fp_ContainerObject * pNext);
00272     virtual void        setPrev(fp_ContainerObject * pPrev);
00273     void                   clearCons(void)
00274         { m_vecContainers.clear();}
00275     fp_ContainerObject *   getNthCon(UT_sint32 i) const;
00276     void                   addCon(fp_ContainerObject * pCon);
00277     UT_sint32              countCons(void) const;
00278     UT_sint32              findCon(fp_ContainerObject * pCon) const;
00279     void                   justRemoveNthCon(UT_sint32 i);
00280     void                   deleteNthCon(UT_sint32 i);
00281     void                   insertConAt(fp_ContainerObject * pCon, UT_sint32 i);
00282     bool                   isEmpty(void) const;
00283     virtual UT_uint32   distanceFromPoint(UT_sint32 x, UT_sint32 y) =0;
00284     virtual void        recalcMaxWidth(bool bDontClearIfNeeded = false) = 0;
00285     virtual void        setAssignedScreenHeight(UT_sint32 iY) =0;
00286     bool                getPageRelativeOffsets(UT_Rect &r) const;
00287     bool                isOnScreen() const;
00288     fp_Container *      getMyBrokenContainer(void) const;
00289     void                setMyBrokenContainer(fp_Container * pMyBroken);
00290     void                clearBrokenContainers(void);
00291     UT_uint32           binarysearchCons(const void* key,int (*compar)(const void *,
00292                                                                  const void *)) const;
00293     UT_uint32           getBrokenCount(void) { return m_cBrokenContainers; }
00294     void                incBrokenCount(void) { m_cBrokenContainers += 1; }
00295     void                decBrokenCount(void) { if (m_cBrokenContainers > 0) {
00296             m_cBrokenContainers -= 1; }}
00297 
00298         fg_FillType &       getFillType(void);
00299     const fg_FillType & getFillType(void) const;
00300     void                drawLine(const PP_PropertyMap::Line & style,
00301                      UT_sint32 left, UT_sint32 top,
00302                      UT_sint32 right, UT_sint32 bot,
00303                      GR_Graphics * pGr);
00304 
00305 private:
00306     fp_Container*          m_pContainer;
00307     fp_ContainerObject *   m_pNext;
00308     fp_ContainerObject *   m_pPrev;
00309     UT_GenericVector<fp_ContainerObject *> m_vecContainers;
00310     fp_Container *         m_pMyBrokenContainer;
00311     UT_uint32              m_cBrokenContainers;
00312     fg_FillType            m_FillType;
00313 };
00314 
00315 
00316 #endif /*  CONTAINEROBJECT_H */
00317 
00318 
00319 
00320 
00321 
00322 

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1