F:/KPlato/koffice/libs/kformula/kformuladefs.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                       Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 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    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef FORMULADEFS_H
00022 #define FORMULADEFS_H
00023 
00024 #include <memory>
00025 
00026 #include <QPointF>
00027 #include <QSizeF>
00028 #include <QRectF>
00029 #include <QString>
00030 
00031 #define KFORMULA_NAMESPACE_BEGIN namespace KFormula {
00032 #define KFORMULA_NAMESPACE_END }
00033 
00034 KFORMULA_NAMESPACE_BEGIN
00035 
00036 const int DEBUGID = 40000;
00037 
00041 typedef double pt;
00042 typedef QPointF PtPoint;
00043 typedef QRectF PtRect;
00044 
00048 typedef double pixel;
00049 typedef QPointF PixelPoint;
00050 typedef QRectF PixelRect;
00051 typedef QSizeF PixelSize;
00052 
00057 typedef double luPt;
00058 typedef QPointF LuPtPoint;
00059 typedef QRectF LuPtRect;
00060 typedef QSizeF LuPtSize;
00061 
00062 typedef double luPixel;
00063 typedef QPointF LuPixelPoint;
00064 typedef QRectF LuPixelRect;
00065 typedef QSizeF LuPixelSize;
00066 
00067 
00071 enum SymbolType {
00072     LeftSquareBracket = '[',
00073     RightSquareBracket = ']',
00074     LeftCurlyBracket = '{',
00075     RightCurlyBracket = '}',
00076     LeftCornerBracket = '<',
00077     RightCornerBracket = '>',
00078     LeftRoundBracket = '(',
00079     RightRoundBracket = ')',
00080     SlashBracket = '/',
00081     BackSlashBracket = '\\',
00082     LeftLineBracket = 256,
00083     RightLineBracket,
00084     EmptyBracket = 1000,
00085     Integral,
00086     Sum,
00087     Product
00088 };
00089 
00090 
00096 enum MoveFlag { NormalMovement = 0, SelectMovement = 1, WordMovement = 2 };
00097 
00098 inline MoveFlag movementFlag( int state )
00099 {
00100     int flag = NormalMovement;
00101     if ( state & Qt::ControlModifier )
00102         flag |= WordMovement;
00103     if ( state & Qt::ShiftModifier )
00104         flag |= SelectMovement;
00105     return static_cast<MoveFlag>( flag );
00106 }
00107 
00108 
00109 
00113 enum CharClass {
00114     ORDINARY = 0,
00115     BINOP = 1,
00116     RELATION = 2,
00117     PUNCTUATION = 3,
00118 
00119     NUMBER, NAME, ELEMENT, INNER, BRACKET, SEQUENCE, SEPARATOR, END
00120 };
00121 
00122 typedef CharClass TokenType;
00123 
00124 
00125 // there are four bits needed to store this
00126 enum CharStyle {
00127     normalChar,
00128     boldChar,
00129     italicChar,
00130     boldItalicChar, // is required to be (boldChar | italicChar)!
00131     //slantChar,
00132     anyChar
00133 };
00134 
00135 
00136 enum CharFamily {
00137     normalFamily,
00138     scriptFamily,
00139     frakturFamily,
00140     doubleStruckFamily,
00141         sansSerifFamily, // TODO: Currently unsupported
00142         monospaceFamily, // TODO: Currently unsupported
00143     anyFamily
00144 };
00145 
00146 
00150 struct InternFontTable {
00151     short unicode;
00152     QChar pos;
00153     CharClass cl;
00154     CharStyle style;
00155 };
00156 
00157 
00163 enum Direction { beforeCursor, afterCursor };
00164 
00168 enum SpaceWidth { THIN, MEDIUM, THICK, QUAD, NEGTHIN };
00169 
00173 enum IndexPosition {
00174     upperLeftPos,
00175     lowerLeftPos,
00176     upperMiddlePos,
00177     contentPos,
00178     lowerMiddlePos,
00179     upperRightPos,
00180     lowerRightPos,
00181     parentPos
00182 };
00183 
00184 
00185 class BasicElement;
00186 class FormulaCursor;
00187 
00194 class ElementIndex {
00195 public:
00196 
00197     virtual ~ElementIndex() { /*cerr << "ElementIndex destroyed.\n";*/ }
00198 
00202     virtual void moveToIndex(FormulaCursor*, Direction) = 0;
00203 
00209     virtual void setToIndex(FormulaCursor*) = 0;
00210 
00214     virtual bool hasIndex() const = 0;
00215 
00219     virtual BasicElement* getElement() = 0;
00220 };
00221 
00222 typedef std::auto_ptr<ElementIndex> ElementIndexPtr;
00223 
00224 enum RequestID {
00225     req_addBracket,
00226     req_addOverline,
00227     req_addUnderline,
00228     req_addFraction,
00229     req_addIndex,
00230     req_addMatrix,
00231     req_addMultiline,
00232     req_addNameSequence,
00233     req_addNewline,
00234     req_addOneByTwoMatrix,
00235     req_addRoot,
00236     req_addSpace,
00237     req_addSymbol,
00238     req_addTabMark,
00239     req_addText,
00240     req_addTextChar,
00241     req_addEmptyBox,
00242     req_appendColumn,
00243     req_appendRow,
00244     req_compactExpression,
00245     req_copy,
00246     req_cut,
00247     req_insertColumn,
00248     req_insertRow,
00249     req_makeGreek,
00250     req_paste,
00251     req_remove,
00252     req_removeEnclosing,
00253     req_removeColumn,
00254     req_removeRow,
00255     req_formatBold,
00256     req_formatItalic,
00257     req_formatFamily
00258 };
00259 
00260 
00261 class Request {
00262     RequestID id;
00263 public:
00264     Request( RequestID _id ) : id( _id ) {}
00265     virtual ~Request() {}
00266     operator RequestID() const { return id;}
00267 };
00268 
00269 
00270 class BracketRequest : public Request {
00271     SymbolType m_left, m_right;
00272 public:
00273     BracketRequest( SymbolType l, SymbolType r ) : Request( req_addBracket ), m_left( l ), m_right( r ) {}
00274     SymbolType left() const { return m_left; }
00275     SymbolType right() const { return m_right; }
00276 };
00277 
00278 class SymbolRequest : public Request {
00279     SymbolType m_type;
00280 public:
00281     SymbolRequest( SymbolType t ) : Request( req_addSymbol ), m_type( t ) {}
00282     SymbolType type() const { return m_type; }
00283 };
00284 
00285 class IndexRequest : public Request {
00286     IndexPosition m_index;
00287 public:
00288     IndexRequest( IndexPosition i ) : Request( req_addIndex ), m_index( i ) {}
00289     IndexPosition index() const { return m_index; }
00290 };
00291 
00292 class SpaceRequest : public Request {
00293     SpaceWidth m_space;
00294 public:
00295     SpaceRequest( SpaceWidth s ) : Request( req_addSpace ), m_space( s ) {}
00296     SpaceWidth space() const { return m_space; }
00297 };
00298 
00299 class DirectedRemove : public Request {
00300     Direction m_direction;
00301 public:
00302     DirectedRemove( RequestID id, Direction d ) : Request( id ), m_direction( d ) {}
00303     Direction direction() const { return m_direction; }
00304 };
00305 
00306 class TextCharRequest : public Request {
00307     QChar m_ch;
00308     bool m_isSymbol;
00309 public:
00310     TextCharRequest( QChar ch, bool isSymbol=false ) : Request( req_addTextChar ), m_ch( ch ), m_isSymbol( isSymbol ) {}
00311     QChar ch() const { return m_ch; }
00312     bool isSymbol() const { return m_isSymbol; }
00313 };
00314 
00315 class TextRequest : public Request {
00316     QString m_text;
00317 public:
00318     TextRequest( QString text ) : Request( req_addText ), m_text( text ) {}
00319     QString text() const { return m_text; }
00320 };
00321 
00322 class MatrixRequest : public Request {
00323     uint m_rows, m_columns;
00324 public:
00325     MatrixRequest( uint rows, uint columns ) : Request( req_addMatrix ), m_rows( rows ), m_columns( columns ) {}
00326     uint rows() const { return m_rows; }
00327     uint columns() const { return m_columns; }
00328 };
00329 
00330 class CharStyleRequest : public Request {
00331     bool m_bold;
00332     bool m_italic;
00333 public:
00334     CharStyleRequest( RequestID id, bool bold, bool italic ) : Request( id ), m_bold( bold ), m_italic( italic ) {}
00335     bool bold() const { return m_bold; }
00336     bool italic() const { return m_italic; }
00337 };
00338 
00339 class CharFamilyRequest : public Request {
00340     CharFamily m_charFamily;
00341 public:
00342     CharFamilyRequest( CharFamily cf ) : Request( req_formatFamily ), m_charFamily( cf ) {}
00343     CharFamily charFamily() const { return m_charFamily; }
00344 };
00345 
00346 
00347 KFORMULA_NAMESPACE_END
00348 
00349 #endif // FORMULADEFS_H

Généré le Wed Nov 22 23:41:01 2006 pour KPlato par  doxygen 1.5.1-p1