lib Library API Documentation

kotextparag.h

00001 // -*- c++ -*-
00002 // File included by korichtext.h to add our own methods to KoTextParag
00003 // Method implementations are in kotextparag.cc
00004 
00005 /* This file is part of the KDE project
00006    Copyright (C) 2001 David Faure <faure@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.
00022 */
00023 
00024 // #include "koparaglayout.h"
00025 
00026 // #include <qstring.h>
00027 // #include <qcolor.h>
00028 // #include "kotextformat.h"
00029 
00030 // class KoTextDocument;
00031 // class KoParagCounter;
00032 // class KoStyle;
00033 // class KoTextCustomItem;
00034 
00040 public:
00041     KoTextDocument * textDocument() const { return document(); }
00042 
00043     KoTextFormat * paragraphFormat() const
00044     { return static_cast<KoTextFormat *>( paragFormat() ); }
00045 
00048     virtual void setParagLayout( const KoParagLayout &layout, int flags = KoParagLayout::All );
00049 
00050     const KoParagLayout & paragLayout() { return m_layout; }
00051 
00052     // Margins
00053     double margin( QStyleSheetItem::Margin m ) { return m_layout.margins[m]; }
00054     const double * margins() const { return m_layout.margins; }
00055     void setMargin( QStyleSheetItem::Margin m, double _i );
00056     void setMargins( const double * _i );
00057 
00059     double kwLineSpacing() const { return m_layout.lineSpacingValue(); }
00060 
00061     void setLineSpacing( double _i );
00062 
00063     KoParagLayout::SpacingType kwLineSpacingType() const { return m_layout.lineSpacingType; }
00064 
00065     void setLineSpacingType( KoParagLayout::SpacingType _type );
00066 
00067 
00069     void setAlign( int align );
00071     int resolveAlignment() const;
00072 
00075     int breakableTopMargin() const;
00076 
00077     // Borders
00078     KoBorder leftBorder() const { return m_layout.leftBorder; }
00079     KoBorder rightBorder() const { return m_layout.rightBorder; }
00080     KoBorder topBorder() const { return m_layout.topBorder; }
00081     KoBorder bottomBorder() const { return m_layout.bottomBorder; }
00082     bool hasBorder() const { return m_layout.hasBorder(); }
00083 
00084     void setLeftBorder( const KoBorder & _brd ) { m_layout.leftBorder = _brd; }
00085     void setRightBorder( const KoBorder & _brd ) { m_layout.rightBorder = _brd; }
00086     void setTopBorder( const KoBorder & _brd );
00087     void setBottomBorder( const KoBorder & _brd );
00088 
00089     // Counters are used to implement list and heading numbering/bullets.
00090     void setCounter( const KoParagCounter & counter );
00091     void setNoCounter();
00092     void setCounter( const KoParagCounter * pCounter )
00093     {
00094         if ( pCounter ) setCounter( *pCounter );
00095         else setNoCounter();
00096     }
00097     KoParagCounter *counter();
00098 
00102     int counterWidth() const;
00103 
00105     KoStyle *style() const { return m_layout.style; }
00107     void setStyle( KoStyle *style ) { m_layout.style = style; }
00109     void applyStyle( KoStyle *style );
00110 
00112     const KoTabulatorList& tabList() const { return m_layout.tabList(); }
00114     void setTabList( const KoTabulatorList &tabList );
00115 
00117     int shadowX( KoZoomHandler *zh ) const;
00119     int shadowY( KoZoomHandler *zh ) const;
00121     double shadowDistanceY() const;
00122 
00124     void setCustomItem( int index, KoTextCustomItem * custom, KoTextFormat * currentFormat );
00126     void removeCustomItem( int index );
00127 
00130     int findCustomItem( const KoTextCustomItem * custom ) const;
00131 
00133     QMap<int, int>& tabCache() { return m_tabCache; }
00134 
00136     QRect pixelRect( KoZoomHandler* zh ) const;
00137 
00141      static void drawFontEffects( QPainter * p, KoTextFormat *format, KoZoomHandler *zh, QFont font, const QColor & color, int startX, int baseLine, int bw, int y, int h, QChar firstChar );
00142 
00144     QString toString( int from = 0, int length = 0xffffffff ) const;
00145 
00147     void fixParagWidth( bool viewFormattingChars );
00148 
00149 #ifndef NDEBUG
00150     void printRTDebug( int );
00151 #endif
00152 
00153 protected:
00154     void invalidateCounters();
00155     bool lineHyphenated( int l ) const;
00156 
00157     void paintLines( QPainter &painter, const QColorGroup &cg, KoTextCursor *cursor, bool drawSelections,
00158                      int clipx, int clipy, int clipw, int cliph );
00159 
00160     void drawParagString( QPainter &painter, const QString &str, int start, int len, int startX,
00161                           int lastY, int baseLine, int bw, int h, bool drawSelections,
00162                           KoTextFormat *lastFormat, const QMemArray<int> &selectionStarts,
00163                           const QMemArray<int> &selectionEnds, const QColorGroup &cg, bool rightToLeft, int line );
00164     void drawParagStringInternal( QPainter &painter, const QString &s, int start, int len, int startX,
00165                                   int lastY, int baseLine, int bw, int h, bool drawSelections,
00166                                   KoTextFormat *lastFormat, const QMemArray<int> &selectionStarts,
00167                                   const QMemArray<int> &selectionEnds, const QColorGroup &cg, bool rightToLeft, int line, KoZoomHandler* zh, bool drawingShadow );
00168 
00170     enum { FormattingSpace = 1, FormattingBreak = 2, FormattingEndParag = 4, FormattingTabs = 8,
00171            AllFormattingChars = FormattingSpace | FormattingBreak | FormattingEndParag | FormattingTabs };
00172 
00177     virtual void drawFormattingChars( QPainter &painter, int start, int len,
00178                                       int lastY_pix, int baseLine_pix, int h_pix, // in pixels
00179                                       bool drawSelections,
00180                                       KoTextFormat *format, const QMemArray<int> &selectionStarts,
00181                                       const QMemArray<int> &selectionEnds, const QColorGroup &cg,
00182                                       bool rightToLeft, int line, KoZoomHandler* zh,
00183                                       int whichFormattingChars );
00184 
00185 protected:
00186     KoParagLayout m_layout;
00187     QMap<int, int> m_tabCache;
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:44 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003