Source Code (Use browser search to find items of interest.)

Class Index

kformula'FractionElement (./koffice/kformula/FractionElement.h:20)

class FractionElement : public BasicElement
{
 public:
    /*
     * Normal constructor, Get font from prev element
     */
    FractionElement(KFormulaContainer *Formula,
		    BasicElement *Prev=0,
		    int Relation=-1,
		    BasicElement *Next=0,
		    QString Content="");
       
    /*
     * Link Next & Prev removing itself
     */
    virtual   ~FractionElement();
     
    /*
     * each derived class must implement its own Draw()
     * "prev" is responsable for x,y
     * 
     */
    virtual void draw(QPoint drawPoint,int resolution);

    /*
     * each derived class must implement its own CheckSize()
     * void because autostore size in Data
     */ 
    virtual void checkSize(); 
      
    /*
     * Change font size
     */
    virtual void setNumericFont(int newValue); 
      
    /*
     * usually call by keyPressEvent()
     * if input is delete,backspace,arrows,home,end....
     * return cursor position (-1 if no cursor is need)
     */
    
//    virtual int takeActionFromKeyb(int action);
    /*
     * do nothing
     */
//    virtual int takeAsciiFromKeyb(int action);
   
    /*
     * In  the future....
     */
    /*   virtual void save(int file);
	 virtual void load(int file);
    */
 protected:
        
    /*
     * Note for "content" meaning:
     * content[0]  'F'=with line 'V'= no-line
     * content[1](vertAlign) 'U'=up 'M'=mid 'L'=low
     * content[2]( HorizAlign) 'L'=left 'C'=center 'R'=right
     * content+3 space between num & den
     */
    int offsetY;
    int offsetX;   
};

kformula'FractionElement::FractionElement() (./koffice/kformula/FractionElement.cc:18)

FractionElement::FractionElement(KFormulaContainer *Formula,
				 BasicElement *Prev,
				 int Relation,
				 BasicElement *Next,
				 QString Content) :
    BasicElement(Formula,Prev,Relation,Next,Content)
{
    /*
      Central alligned fraction
    */
    content="FMC5";
    childrenNumber=2;
    minChildren=2;
    child.resize(childrenNumber);
    child[0]=0L;
    child[1]=0L;

}


kformula'FractionElement::~FractionElement() (./koffice/kformula/FractionElement.cc:37)

FractionElement::~FractionElement()
{
}


kformula'FractionElement::draw() (./koffice/kformula/FractionElement.cc:41)

void FractionElement::draw(QPoint drawPoint,int resolution)
{

    QPainter *pen;
    pen=formula->painter();
    //QRect globalArea;
    int x,y;
    x=drawPoint.x();
    y=drawPoint.y();
    int space=atoi(content.right(content.length()-3));
    warning("Sapce %i",space);
    space+=numericFont/24;


    if( beActive )
	pen->setPen(Qt::red);


    int ofs=(numericFont/24);
    warning("Array");

    if (content[0]=='F') {
	QPointArray points(5);
	points.setPoint(1,x+familySize.x()+1,y+offsetY-ofs/2);
	points.setPoint(2,x+familySize.right()-2,y+offsetY-ofs/2);
	points.setPoint(3,x+familySize.right()-2,y+offsetY+ofs/2);
	points.setPoint(4,x+familySize.x()+1,y+offsetY+ofs/2);
	pen->setBrush(pen->pen().color());
	pen->drawPolygon(points,FALSE,1,9);
    }

    if( beActive )
	pen->setPen(Qt::blue);
    int y0=-child[0]->getSize().bottom()-space/2;
    int y1=-child[1]->getSize().top()+space/2;
    int x0=0,x1=0;
    y0+=offsetY;
    y1+=offsetY;
    if(offsetX>0) x0=offsetX;
    if(offsetX<0) x1=-offsetX;

    child[0]->draw(QPoint(x+x0+3,y+y0),resolution);
    child[1]->draw(QPoint(x+x1+3,y+y1),resolution);
    myArea=globalSize;
    myArea.moveBy(x,y);

#ifdef RECT
    pen->drawRect(myArea);
    // pen->drawRect(globalArea);
#endif

    drawIndexes(pen,resolution);
    if( beActive )
	pen->setPen(Qt::black);
    if(next!=0L) next->draw(drawPoint+QPoint(localSize.width(),0),resolution);


}


kformula'FractionElement::checkSize() (./koffice/kformula/FractionElement.cc:100)

void FractionElement::checkSize()
{
    //warning("R %p",this);
    QRect nextDimension;

    if (next!=0L)
	{
	    next->checkSize();
	    nextDimension=next->getSize();
	}
    child[0]->checkSize();
    child[1]->checkSize();
    int space=atoi(content.right(content.length()-3));
    warning("Space %i",space);
    space+=numericFont/24;
    QRect child0Size=child[0]->getSize();
    QRect child1Size=child[1]->getSize();
    if(content[1]=='U')
	offsetY=child0Size.bottom()+space/2;
    if(content[1]=='D')
	offsetY=child1Size.top()-space/2;
    if(content[1]=='M')
	offsetY=0;
    offsetX=child1Size.width()-child0Size.width();
    if(content[2]=='L')
	offsetX=0;
    if(content[2]=='C')
	offsetX/=2;
    if(content[2]=='R')
	warning("R");

    child0Size.moveBy(0,-space/2-child0Size.bottom());
    child1Size.moveBy(0,space/2-child1Size.top());
    familySize=child0Size.unite(child1Size);

    familySize.moveBy(0,offsetY);
    familySize.setLeft(familySize.left()-3);
    familySize.setRight(familySize.right()+3);
    localSize=familySize;
    checkIndexesSize();  //This will change localSize adding Indexes Size
    familySize.moveBy(-localSize.left(),0);
    localSize.moveBy(-localSize.left(),0);
    globalSize=localSize;
    nextDimension.moveBy(localSize.width(),0);
    globalSize=globalSize.unite(nextDimension);
}

/*int FractionElement::takeAsciiFromKeyb(int)
{
    return 2;
}
*/

/*int FractionElement::takeActionFromKeyb(int)
{
    return -1;
}*/


kformula'FractionElement::setNumericFont() (./koffice/kformula/FractionElement.cc:158)

void FractionElement::setNumericFont(int value)
{
    numericFont=value;
    /*
      We can use differnt pixmap:
      numericFont < 20   tinyFraction.xpm
      20 < numericFont < 50 normalFraction.xpm
      numericFont < 20   bigFraction.xpm
    */
}