lib Library API Documentation

kotextformatter.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef kotextformatter_h 00021 #define kotextformatter_h 00022 00023 #include "korichtext.h" 00024 class KoZoomHandler; 00025 class KoHyphenator; 00026 00034 class KoTextFormatter : public KoTextFormatterBase 00035 { 00036 public: 00037 KoTextFormatter(); 00038 virtual ~KoTextFormatter(); 00039 00040 virtual bool format( KoTextDocument *doc, KoTextParag *parag, int start, const QMap<int, KoTextParagLineStart*> &oldLineStarts, int& y, int& widthUsed ); 00041 00042 // Called after formatting a paragraph 00043 virtual void postFormat( KoTextParag* parag ); 00044 00045 KoHyphenator* hyphenator() { 00046 return m_hyphenator; 00047 } 00048 private: 00049 KoHyphenator* m_hyphenator; 00050 }; 00051 00052 // Internal class for KoTextFormatter, holds all the temporary data 00053 // KoTextFormatter is basically the settings and the algorithm being used 00054 // KoTextFormatterCore is where the formatting really happens 00055 class KoTextFormatterCore 00056 { 00057 public: 00058 KoTextFormatterCore( KoTextFormatter* settings, KoTextDocument *doc, KoTextParag *parag, int start ); 00059 00060 bool format(); 00061 00062 // widthUsed is the width of the wider line (with the current 00063 // word-breaking, margins included, but e.g. centering not included). 00064 // Unused in KWord currently, this is however used by KPresenter's 00065 // "resize object to fit contents" feature. 00066 int widthUsed() const { return wused; } 00067 int resultY() const { return y; } 00068 00069 protected: 00070 // Return ww (in LU) and pixelww (in pixels) 00071 // Should be called only once per char 00072 QPair<int, int> determineCharWidth(); 00073 00074 KoTextParagLineStart *koFormatLine( 00075 KoZoomHandler *zh, 00076 KoTextParag * /*parag*/, KoTextString *string, KoTextParagLineStart *line, 00077 KoTextStringChar *startChar, KoTextStringChar *lastChar, int align, int space ); 00078 00079 KoTextParagLineStart *koBidiReorderLine( 00080 KoZoomHandler *zh, 00081 KoTextParag * /*parag*/, KoTextString *text, KoTextParagLineStart *line, 00082 KoTextStringChar *startChar, KoTextStringChar *lastChar, int align, int space ); 00083 00084 void moveChar( KoTextStringChar& chr, KoZoomHandler *zh, 00085 int deltaX, int deltaPixelX ); 00086 00087 // Total left margin for a given line 00088 // Takes into account parag's leftmargin, firstlinemargin and counter, 00089 // but not adjustMargins (application hook) 00090 int leftMargin( bool firstLine ) const; 00091 int rightMargin( bool firstLine ) const; 00092 00093 00094 private: 00095 KoTextFormatter* settings; 00096 KoTextDocument* doc; 00097 KoTextParag* parag; 00098 int start; // always 0 currently 00099 int wused; // see widthUsed 00100 int y; 00101 int availableWidth; 00102 int maxY; 00103 00104 // When moving a big item down, we might want to rollback 00105 // to the 'best position for it' if we can't make it fit anywhere else. 00106 QPair<int,int> maxAvailableWidth; // first=y second=available width 00107 00108 // Information on current char 00109 KoTextStringChar *c; 00110 int i; // index number (in the paragraph) 00111 int x; // X position (in LU) 00112 }; 00113 00114 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:04:02 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003