lib

kformuladefs.h

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 <qpoint.h>
00027 #include <qrect.h>
00028 #include <qstring.h>
00029 
00030 #include <KoPoint.h>
00031 #include <KoRect.h>
00032 
00033 
00034 #define KFORMULA_NAMESPACE_BEGIN namespace KFormula {
00035 #define KFORMULA_NAMESPACE_END }
00036 
00037 KFORMULA_NAMESPACE_BEGIN
00038 
00039 const int DEBUGID = 40000;
00040 
00041 // to make kdDebug a litte more interessting...
00042 //#define TERM_RESET ""
00043 //#define TERM_ERROR ""
00044 
00048 typedef double pt;
00049 typedef KoPoint PtPoint;
00050 typedef KoRect PtRect;
00051 //typedef KoSize PtSize;
00052 
00056 typedef int pixel;
00057 typedef QPoint PixelPoint;
00058 typedef QRect PixelRect;
00059 //typedef QSize PixelSize;
00060 
00065 typedef int luPt;
00066 typedef QPoint LuPtPoint;
00067 typedef QRect LuPtRect;
00068 typedef QSize LuPtSize;
00069 
00070 typedef int luPixel;
00071 typedef QPoint LuPixelPoint;
00072 typedef QRect LuPixelRect;
00073 typedef QSize LuPixelSize;
00074 
00075 
00079 enum SymbolType {
00080     LeftSquareBracket = '[',
00081     RightSquareBracket = ']',
00082     LeftCurlyBracket = '{',
00083     RightCurlyBracket = '}',
00084     LeftCornerBracket = '<',
00085     RightCornerBracket = '>',
00086     LeftRoundBracket = '(',
00087     RightRoundBracket = ')',
00088     SlashBracket = '/',
00089     BackSlashBracket = '\\',
00090     LeftLineBracket = 256,
00091     RightLineBracket,
00092     EmptyBracket = 1000,
00093     Integral,
00094     Sum,
00095     Product
00096 };
00097 
00098 
00104 enum MoveFlag { NormalMovement = 0, SelectMovement = 1, WordMovement = 2 };
00105 
00106 inline MoveFlag movementFlag( int state )
00107 {
00108     int flag = NormalMovement;
00109     if ( state & Qt::ControlButton )
00110         flag |= WordMovement;
00111     if ( state & Qt::ShiftButton )
00112         flag |= SelectMovement;
00113     return static_cast<MoveFlag>( flag );
00114 }
00115 
00116 
00117 
00121 enum CharClass {
00122     ORDINARY = 0,
00123     BINOP = 1,
00124     RELATION = 2,
00125     PUNCTUATION = 3,
00126 
00127     NUMBER, NAME, ELEMENT, INNER, BRACKET, SEQUENCE, SEPARATOR, END
00128 };
00129 
00130 typedef CharClass TokenType;
00131 
00132 
00133 // there are four bits needed to store this
00134 enum CharStyle {
00135     normalChar,
00136     boldChar,
00137     italicChar,
00138     boldItalicChar, // is required to be (boldChar | italicChar)!
00139     //slantChar,
00140     anyChar
00141 };
00142 
00143 
00144 enum CharFamily {
00145     normalFamily,
00146     scriptFamily,
00147     frakturFamily,
00148     doubleStruckFamily,
00149     sansSerifFamily, // TODO: Currently unsupported
00150     monospaceFamily,       // TODO: Currently unsupported
00151     anyFamily
00152 };
00153 
00154 enum TokenElementType {
00155     identifierElement,
00156     operatorElement,
00157     numberElement,
00158     textElement,
00159     anyElement
00160 };
00161 
00165 struct InternFontTable {
00166     short unicode;
00167     QChar pos;
00168     CharClass cl;
00169     CharStyle style;
00170 };
00171 
00172 
00178 enum Direction { beforeCursor, afterCursor };
00179 
00183 enum SpaceWidth { THIN, MEDIUM, THICK, QUAD, NEGTHIN };
00184 
00188 enum SizeType { 
00189     NoSize, 
00190     AutoSize, 
00191     FitSize,
00192     InfinitySize,
00193     RelativeSize, 
00194     AbsoluteSize, 
00195     PixelSize,
00196     NegativeVeryVeryThinMathSpace,
00197     NegativeVeryThinMathSpace,
00198     NegativeThinMathSpace,
00199     NegativeMediumMathSpace,
00200     NegativeThickMathSpace,
00201     NegativeVeryThickMathSpace,
00202     NegativeVeryVeryThickMathSpace,
00203     VeryVeryThinMathSpace,
00204     VeryThinMathSpace,
00205     ThinMathSpace,
00206     MediumMathSpace,
00207     ThickMathSpace,
00208     VeryThickMathSpace,
00209     VeryVeryThickMathSpace
00210 };
00211 
00215 enum HorizontalAlign { 
00216     NoHorizontalAlign, 
00217     LeftHorizontalAlign, 
00218     CenterHorizontalAlign, 
00219     RightHorizontalAlign 
00220 };
00221 
00225 enum FormType { NoForm, PrefixForm, InfixForm, PostfixForm };
00226 
00230 enum IndexPosition {
00231     upperLeftPos,
00232     lowerLeftPos,
00233     upperMiddlePos,
00234     contentPos,
00235     lowerMiddlePos,
00236     upperRightPos,
00237     lowerRightPos,
00238     parentPos
00239 };
00240 
00241 
00242 class BasicElement;
00243 class FormulaCursor;
00244 
00251 class ElementIndex {
00252 public:
00253 
00254     virtual ~ElementIndex() { /*cerr << "ElementIndex destroyed.\n";*/ }
00255 
00259     virtual void moveToIndex(FormulaCursor*, Direction) = 0;
00260 
00266     virtual void setToIndex(FormulaCursor*) = 0;
00267 
00271     virtual bool hasIndex() const = 0;
00272 
00276     virtual BasicElement* getElement() = 0;
00277 };
00278 
00279 typedef std::auto_ptr<ElementIndex> ElementIndexPtr;
00280 
00281 enum RequestID {
00282     req_addBracket,
00283     req_addOverline,
00284     req_addUnderline,
00285     req_addFraction,
00286     req_addIndex,
00287     req_addMatrix,
00288     req_addMultiline,
00289     req_addNameSequence,
00290     req_addNewline,
00291     req_addOneByTwoMatrix,
00292     req_addRoot,
00293     req_addSpace,
00294     req_addSymbol,
00295     req_addTabMark,
00296     req_addText,
00297     req_addTextChar,
00298     req_addOperator,
00299     req_addNumber,
00300     req_addEmptyBox,
00301     req_appendColumn,
00302     req_appendRow,
00303     req_compactExpression,
00304     req_copy,
00305     req_cut,
00306     req_insertColumn,
00307     req_insertRow,
00308     req_makeGreek,
00309     req_paste,
00310     req_remove,
00311     req_removeEnclosing,
00312     req_removeColumn,
00313     req_removeRow,
00314     req_formatBold,
00315     req_formatItalic,
00316     req_formatFamily,
00317     req_formatTokenElement
00318 };
00319 
00320 
00321 class Request {
00322     RequestID id;
00323 public:
00324     Request( RequestID _id ) : id( _id ) {}
00325     virtual ~Request() {}
00326     operator RequestID() const { return id;}
00327 };
00328 
00329 
00330 class BracketRequest : public Request {
00331     SymbolType m_left, m_right;
00332 public:
00333     BracketRequest( SymbolType l, SymbolType r ) : Request( req_addBracket ), m_left( l ), m_right( r ) {}
00334     SymbolType left() const { return m_left; }
00335     SymbolType right() const { return m_right; }
00336 };
00337 
00338 class SymbolRequest : public Request {
00339     SymbolType m_type;
00340 public:
00341     SymbolRequest( SymbolType t ) : Request( req_addSymbol ), m_type( t ) {}
00342     SymbolType type() const { return m_type; }
00343 };
00344 
00345 class IndexRequest : public Request {
00346     IndexPosition m_index;
00347 public:
00348     IndexRequest( IndexPosition i ) : Request( req_addIndex ), m_index( i ) {}
00349     IndexPosition index() const { return m_index; }
00350 };
00351 
00352 class SpaceRequest : public Request {
00353     SpaceWidth m_space;
00354 public:
00355     SpaceRequest( SpaceWidth s ) : Request( req_addSpace ), m_space( s ) {}
00356     SpaceWidth space() const { return m_space; }
00357 };
00358 
00359 class DirectedRemove : public Request {
00360     Direction m_direction;
00361 public:
00362     DirectedRemove( RequestID id, Direction d ) : Request( id ), m_direction( d ) {}
00363     Direction direction() const { return m_direction; }
00364 };
00365 
00366 class TextCharRequest : public Request {
00367     QChar m_ch;
00368     bool m_isSymbol;
00369 public:
00370     TextCharRequest( QChar ch, bool isSymbol=false ) : Request( req_addTextChar ), m_ch( ch ), m_isSymbol( isSymbol ) {}
00371     QChar ch() const { return m_ch; }
00372     bool isSymbol() const { return m_isSymbol; }
00373 };
00374 
00375 class OperatorRequest: public Request {
00376     QChar m_ch;
00377 public:
00378     OperatorRequest( QChar ch ) : Request( req_addOperator ), m_ch( ch ) {}
00379     QChar ch() const { return m_ch; }
00380 };
00381 
00382 class NumberRequest: public Request {
00383     QChar m_ch;
00384 public:
00385     NumberRequest( QChar ch ) : Request( req_addNumber ), m_ch( ch ) {}
00386     QChar ch() const { return m_ch; }
00387 };
00388 
00389 class TextRequest : public Request {
00390     QString m_text;
00391 public:
00392     TextRequest( QString text ) : Request( req_addText ), m_text( text ) {}
00393     QString text() const { return m_text; }
00394 };
00395 
00396 class MatrixRequest : public Request {
00397     uint m_rows, m_columns;
00398 public:
00399     MatrixRequest( uint rows, uint columns ) : Request( req_addMatrix ), m_rows( rows ), m_columns( columns ) {}
00400     uint rows() const { return m_rows; }
00401     uint columns() const { return m_columns; }
00402 };
00403 
00404 class CharStyleRequest : public Request {
00405     bool m_bold;
00406     bool m_italic;
00407 public:
00408     CharStyleRequest( RequestID id, bool bold, bool italic ) : Request( id ), m_bold( bold ), m_italic( italic ) {}
00409     bool bold() const { return m_bold; }
00410     bool italic() const { return m_italic; }
00411 };
00412 
00413 class CharFamilyRequest : public Request {
00414     CharFamily m_charFamily;
00415 public:
00416     CharFamilyRequest( CharFamily cf ) : Request( req_formatFamily ), m_charFamily( cf ) {}
00417     CharFamily charFamily() const { return m_charFamily; }
00418 };
00419 
00420 class TokenElementRequest : public Request {
00421     TokenElementType m_tokenElement;
00422 public:
00423     TokenElementRequest( TokenElementType te ) : Request( req_formatTokenElement ), m_tokenElement( te ) {}
00424     TokenElementType tokenElement() const { return m_tokenElement; }
00425 };
00426 
00427 
00428 KFORMULA_NAMESPACE_END
00429 
00430 #endif // FORMULADEFS_H
KDE Home | KDE Accessibility Home | Description of Access Keys