00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef SYMBOLELEMENT_H
00022
#define SYMBOLELEMENT_H
00023
00024
#include "fontstyle.h"
00025
#include "basicelement.h"
00026
#include "kformuladefs.h"
00027
00028 KFORMULA_NAMESPACE_BEGIN
00029
00033 class SymbolElement :
public BasicElement {
00034
SymbolElement operator=(
const SymbolElement& ) {
return *
this; }
00035
public:
00036
00037
00038
00039
SymbolElement(SymbolType type = EmptyBracket,
BasicElement* parent = 0);
00040 ~
SymbolElement();
00041
00042
SymbolElement(
const SymbolElement& );
00043
00044
virtual SymbolElement* clone() {
00045
return new SymbolElement( *
this );
00046 }
00047
00048
virtual bool accept(
ElementVisitor* visitor );
00049
00056
virtual BasicElement*
goToPos(
FormulaCursor*,
bool& handled,
00057
const LuPixelPoint& point,
const LuPixelPoint& parentOrigin );
00058
00059
00060
00061
00062
00063
00064
00065
00070
virtual void calcSizes(
const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00071
00077
virtual void draw(
QPainter& painter,
const LuPixelRect& r,
00078
const ContextStyle& context,
00079 ContextStyle::TextStyle tstyle,
00080 ContextStyle::IndexStyle istyle,
00081
const LuPixelPoint& parentOrigin );
00082
00086
virtual void dispatchFontCommand(
FontCommand* cmd );
00087
00088
00089
00090
00091
00092
00093
00094
00095
00101
virtual void moveLeft(
FormulaCursor* cursor,
BasicElement* from);
00102
00108
virtual void moveRight(
FormulaCursor* cursor,
BasicElement* from);
00109
00115
virtual void moveUp(
FormulaCursor* cursor,
BasicElement* from);
00116
00122
virtual void moveDown(
FormulaCursor* cursor,
BasicElement* from);
00123
00124
00125
00133
00134
00135
00136
00137
00138
00139
00140 virtual SequenceElement*
getMainChild() {
return content; }
00141
00142
00143
00154
virtual void insert(
FormulaCursor*,
QPtrList<BasicElement>&, Direction);
00155
00167
virtual void remove(
FormulaCursor*,
QPtrList<BasicElement>&, Direction);
00168
00173
virtual void normalize(
FormulaCursor*, Direction);
00174
00178
virtual BasicElement* getChild(
FormulaCursor*, Direction = beforeCursor);
00179
00184
virtual void selectChild(
FormulaCursor* cursor,
BasicElement* child);
00185
00190
00191
00192 bool hasUpper()
const {
return upper != 0; }
00193
bool hasLower()
const {
return lower != 0; }
00194
00195
00196
00197
void setToUpper(
FormulaCursor* cursor);
00198
void setToLower(
FormulaCursor* cursor);
00199
00200
00201
void moveToUpper(
FormulaCursor*, Direction);
00202
void moveToLower(
FormulaCursor*, Direction);
00203
00204
00205
00206 ElementIndexPtr getUpperIndex() {
return ElementIndexPtr(
new UpperIndex(
this ) ); }
00207 ElementIndexPtr getLowerIndex() {
return ElementIndexPtr(
new LowerIndex(
this ) ); }
00208
00212 ElementIndexPtr
getIndex(
int position );
00213
00214
00215
00216
00217
00222
virtual QString toLatex();
00223
00224
virtual QString formulaString();
00225
00226
virtual void writeMathML(
QDomDocument doc,
QDomNode parent );
00227
00228
protected:
00229
00230
00231
00235 virtual QString getTagName()
const {
return "SYMBOL"; }
00236
00240
virtual void writeDom(
QDomElement element);
00241
00246
virtual bool readAttributesFromDom(
QDomElement element);
00247
00253
virtual bool readContentFromDom(
QDomNode& node);
00254
00255
private:
00256
00260
class SymbolElementIndex :
public ElementIndex {
00261
public:
00262 SymbolElementIndex(
SymbolElement* p) : parent(p) {}
00263
virtual SymbolElement* getElement() {
return parent; }
00264
protected:
00265
SymbolElement* parent;
00266 };
00267
00268
00269
00270
class UpperIndex :
public SymbolElementIndex {
00271
public:
00272 UpperIndex(
SymbolElement* parent) : SymbolElementIndex(parent) {}
00273
virtual void moveToIndex(
FormulaCursor* cursor, Direction direction)
00274 { parent->moveToUpper(cursor, direction); }
00275
virtual void setToIndex(
FormulaCursor* cursor)
00276 { parent->setToUpper(cursor); }
00277
virtual bool hasIndex()
const
00278
{
return parent->hasUpper(); }
00279 };
00280
00281
class LowerIndex :
public SymbolElementIndex {
00282
public:
00283 LowerIndex(
SymbolElement* parent) : SymbolElementIndex(parent) {}
00284
virtual void moveToIndex(
FormulaCursor* cursor, Direction direction)
00285 { parent->moveToLower(cursor, direction); }
00286
virtual void setToIndex(
FormulaCursor* cursor)
00287 { parent->setToLower(cursor); }
00288
virtual bool hasIndex()
const
00289
{
return parent->hasLower(); }
00290 };
00291
00292
00293
void setToContent(
FormulaCursor* cursor);
00294
00295
SequenceElement* content;
00296
SequenceElement* upper;
00297
SequenceElement* lower;
00298
00302 Artwork* symbol;
00303
00304 SymbolType symbolType;
00305 };
00306
00307 KFORMULA_NAMESPACE_END
00308
00309
#endif // SYMBOLELEMENT_H