Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Page.hh

Go to the documentation of this file.
00001 /*
00002     libpdf++: a C++ Free library to generate PDF file
00003     Copyright (C) 2002 Nestal Wan
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library 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 GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00026 #ifndef __PDF_PAGE_PAGE_HEADER_INCLUDED__
00027 #define __PDF_PAGE_PAGE_HEADER_INCLUDED__
00028 
00029 #ifndef __PDF_PAGE_NODE_BASE_HEADER_INCLUDED__
00030 #include "NodeBase.hh"
00031 #endif
00032 
00033 #include <iosfwd>
00034 #include <vector>
00035 #include <memory>
00036 #include <utility>
00037 #include <boost/smart_ptr.hpp>
00038 
00039 namespace pdf {
00040 
00041 namespace core
00042 {
00043     class CObject ;
00044     class CObjRef ;
00045     class CFile ;
00046 }
00047 
00048 namespace text
00049 {
00050     class CText ;
00051 }
00052 
00053 namespace graph
00054 {
00055     class CPath ;
00056 }
00057 
00058 namespace page {
00059 
00060 class CInfo ;
00061 class CXObjInst ;
00062 
00073 class CPage : public CNodeBase
00074 {
00075 private :
00077     std::vector<text::CText>    m_texts ;
00078 
00080     std::vector<graph::CPath>   m_paths ;
00081 
00083     std::vector<CXObjInst>      m_xobj_inst ;
00084 
00086     std::auto_ptr<CInfo>    m_info ;
00087 
00089     enum EElement { path_type, xobject_type, text_type } ;
00090     
00092     typedef std::pair<EElement, int>    CElement ;
00093     typedef std::vector<CElement>       CElementVec ;
00094     typedef CElementVec::const_iterator CElementIt ;
00095     CElementVec m_elements ;
00096 
00097 public :
00098     CPage( ) ;
00099     CPage( double width, double height ) ;
00100     CPage( const CPage& page ) ;
00101     ~CPage( ) ;
00102 
00103     // assignments and swapping
00104     CPage& operator=( const CPage& page ) ;
00105     void Swap( CPage& page ) ;
00106 
00107     // operations
00108     void DrawText( const text::CText& text ) ;
00109     void DrawPath( const graph::CPath& path ) ;
00110     void DrawXObj( const graph::CXObject *object,
00111                    double x, double y, double width, double height ) ;
00112 
00113     // write the page to a PDF file
00114     const core::CObjRef Write( const core::CObjRef& parent,
00115                                const CInfo& default_info,
00116                                core::CFile& file ) const ;
00117 
00118 private :
00119     const core::CObjRef WriteContent( core::CFile& file ) const ;
00120 
00121     // helpers to write the content
00122     CElementIt WriteText( std::ostream& os, CElementIt i ) const ;
00123     CElementIt WritePaths( std::ostream& os, CElementIt i ) const ;
00124     CElementIt WriteXObjs( std::ostream& os, CElementIt i ) const ;
00125 } ;
00126 
00127 } } // end of namespace
00128 
00129 namespace std
00130 {
00131     template <typename T>
00132     void swap( T& t1, T& t2 ) ;
00133     
00134     template <>
00135     inline void swap( pdf::page::CPage& p1, pdf::page::CPage& p2 )
00136     {
00137         p1.Swap( p2 ) ;
00138     }
00139 
00140 }
00141 
00142 #endif

Generated on Sun Feb 2 09:16:05 2003 for libpdf++ by doxygen1.2.16