lib Library API Documentation

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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, 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     anyFamily
00150 };
00151 
00152 
00156 struct InternFontTable {
00157     short unicode;
00158     uchar pos;
00159     CharClass cl;
00160     CharStyle style;
00161 };
00162 
00163 
00169 enum Direction { beforeCursor, afterCursor };
00170 
00174 enum SpaceWidth { THIN, MEDIUM, THICK, QUAD, NEGTHIN };
00175 
00179 enum IndexPosition {
00180     upperLeftPos,
00181     lowerLeftPos,
00182     upperMiddlePos,
00183     contentPos,
00184     lowerMiddlePos,
00185     upperRightPos,
00186     lowerRightPos,
00187     parentPos
00188 };
00189 
00190 
00191 class BasicElement;
00192 class FormulaCursor;
00193 
00200 class ElementIndex {
00201 public:
00202 
00203     virtual ~ElementIndex() { /*cerr << "ElementIndex destroyed.\n";*/ }
00204 
00208     virtual void moveToIndex(FormulaCursor*, Direction) = 0;
00209 
00215     virtual void setToIndex(FormulaCursor*) = 0;
00216 
00220     virtual bool hasIndex() const = 0;
00221 
00225     virtual BasicElement* getElement() = 0;
00226 };
00227 
00228 typedef std::auto_ptr<ElementIndex> ElementIndexPtr;
00229 
00230 enum RequestID {
00231     req_addBracket,
00232     req_addOverline,
00233     req_addUnderline,
00234     req_addFraction,
00235     req_addIndex,
00236     req_addMatrix,
00237     req_addMultiline,
00238     req_addNameSequence,
00239     req_addNewline,
00240     req_addOneByTwoMatrix,
00241     req_addRoot,
00242     req_addSpace,
00243     req_addSymbol,
00244     req_addTabMark,
00245     req_addText,
00246     req_addTextChar,
00247     req_addEmptyBox,
00248     req_appendColumn,
00249     req_appendRow,
00250     req_compactExpression,
00251     req_copy,
00252     req_cut,
00253     req_insertColumn,
00254     req_insertRow,
00255     req_makeGreek,
00256     req_paste,
00257     req_remove,
00258     req_removeEnclosing,
00259     req_removeColumn,
00260     req_removeRow,
00261     req_formatBold,
00262     req_formatItalic,
00263     req_formatFamily
00264 };
00265 
00266 
00267 class Request {
00268     RequestID id;
00269 public:
00270     Request( RequestID _id ) : id( _id ) {}
00271     virtual ~Request() {}
00272     operator RequestID() const { return id;}
00273 };
00274 
00275 
00276 class BracketRequest : public Request {
00277     SymbolType m_left, m_right;
00278 public:
00279     BracketRequest( SymbolType l, SymbolType r ) : Request( req_addBracket ), m_left( l ), m_right( r ) {}
00280     SymbolType left() const { return m_left; }
00281     SymbolType right() const { return m_right; }
00282 };
00283 
00284 class SymbolRequest : public Request {
00285     SymbolType m_type;
00286 public:
00287     SymbolRequest( SymbolType t ) : Request( req_addSymbol ), m_type( t ) {}
00288     SymbolType type() const { return m_type; }
00289 };
00290 
00291 class IndexRequest : public Request {
00292     IndexPosition m_index;
00293 public:
00294     IndexRequest( IndexPosition i ) : Request( req_addIndex ), m_index( i ) {}
00295     IndexPosition index() const { return m_index; }
00296 };
00297 
00298 class SpaceRequest : public Request {
00299     SpaceWidth m_space;
00300 public:
00301     SpaceRequest( SpaceWidth s ) : Request( req_addSpace ), m_space( s ) {}
00302     SpaceWidth space() const { return m_space; }
00303 };
00304 
00305 class DirectedRemove : public Request {
00306     Direction m_direction;
00307 public:
00308     DirectedRemove( RequestID id, Direction d ) : Request( id ), m_direction( d ) {}
00309     Direction direction() const { return m_direction; }
00310 };
00311 
00312 class TextCharRequest : public Request {
00313     QChar m_ch;
00314     bool m_isSymbol;
00315 public:
00316     TextCharRequest( QChar ch, bool isSymbol=false ) : Request( req_addTextChar ), m_ch( ch ), m_isSymbol( isSymbol ) {}
00317     QChar ch() const { return m_ch; }
00318     bool isSymbol() const { return m_isSymbol; }
00319 };
00320 
00321 class TextRequest : public Request {
00322     QString m_text;
00323 public:
00324     TextRequest( QString text ) : Request( req_addText ), m_text( text ) {}
00325     QString text() const { return m_text; }
00326 };
00327 
00328 class MatrixRequest : public Request {
00329     uint m_rows, m_columns;
00330 public:
00331     MatrixRequest( uint rows, uint columns ) : Request( req_addMatrix ), m_rows( rows ), m_columns( columns ) {}
00332     uint rows() const { return m_rows; }
00333     uint columns() const { return m_columns; }
00334 };
00335 
00336 class CharStyleRequest : public Request {
00337     bool m_bold;
00338     bool m_italic;
00339 public:
00340     CharStyleRequest( RequestID id, bool bold, bool italic ) : Request( id ), m_bold( bold ), m_italic( italic ) {}
00341     bool bold() const { return m_bold; }
00342     bool italic() const { return m_italic; }
00343 };
00344 
00345 class CharFamilyRequest : public Request {
00346     CharFamily m_charFamily;
00347 public:
00348     CharFamilyRequest( CharFamily cf ) : Request( req_formatFamily ), m_charFamily( cf ) {}
00349     CharFamily charFamily() const { return m_charFamily; }
00350 };
00351 
00352 
00353 KFORMULA_NAMESPACE_END
00354 
00355 #endif // FORMULADEFS_H
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 Sun Mar 20 14:25:23 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003