kformula/flake
EncloseElement.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "EncloseElement.h"
00021 #include "AttributeManager.h"
00022 #include <QPainter>
00023 #include "kdebug.h"
00024
00025 EncloseElement::EncloseElement( BasicElement* parent ) : RowElement( parent )
00026 {
00027 }
00028
00029 void EncloseElement::paint( QPainter& painter, AttributeManager* )
00030 {
00031 painter.save();
00032 QPen pen;
00033 pen.setWidth( 1 );
00034 painter.setPen( pen );
00035 painter.drawPath( m_enclosePath );
00036 painter.restore();
00037 }
00038
00039 void EncloseElement::layout( const AttributeManager* am )
00040 {
00041
00042 m_enclosePath = QPainterPath();
00043 QString tmpstring = am->stringOf( "notation", this );
00044 QList<QString> tmp=tmpstring.split(" ");
00045 RowElement::layout( am );
00046 QRectF tmpRect = boundingRect();
00047
00048
00049
00050
00051 if( tmp.contains( "left" ) ) {
00052 m_enclosePath.moveTo( 0, 0 );
00053 m_enclosePath.lineTo( 0, tmpRect.height() );
00054 }
00055 if( tmp.contains( "right" ) ) {
00056 m_enclosePath.moveTo( tmpRect.width(), 0 );
00057 m_enclosePath.lineTo( tmpRect.width(), tmpRect.height() );
00058 }
00059 if( tmp.contains( "top" ) ) {
00060 m_enclosePath.moveTo( 0, 0 );
00061 m_enclosePath.lineTo( tmpRect.width(), 0 );
00062 }
00063 if( tmp.contains( "bottom" ) ) {
00064 m_enclosePath.moveTo( 0, tmpRect.height() );
00065 m_enclosePath.lineTo( tmpRect.width(), tmpRect.height());
00066 }
00067 if( tmp.contains( "box" ) ) {
00068 m_enclosePath.addRect( 0, 0, tmpRect.width(), tmpRect.height() );
00069 }
00070 if( tmp.contains( "roundedbox" ) ) {
00071 m_enclosePath.addRoundRect( 0, 0, tmpRect.width(), tmpRect.height(), 25 );
00072 }
00073 if( tmp.contains( "updiagonalstrike" ) ) {
00074 m_enclosePath.moveTo( 0, tmpRect.height() );
00075 m_enclosePath.lineTo( tmpRect.width(), 0 );
00076 }
00077 if( tmp.contains( "downdiagonalstrike" ) ) {
00078 m_enclosePath.moveTo( 0, 0 );
00079 m_enclosePath.lineTo( tmpRect.width(), tmpRect.height() );
00080 }
00081 if( tmp.contains( "verticalstrike" ) ) {
00082 m_enclosePath.moveTo( tmpRect.width()/2, 0 );
00083 m_enclosePath.lineTo( tmpRect.width()/2, tmpRect.height() );
00084 }
00085 if( tmp.contains( "horizontalstrike" ) ) {
00086 m_enclosePath.moveTo( 0, tmpRect.height()/2 );
00087 m_enclosePath.lineTo( tmpRect.width(), tmpRect.height()/2 );
00088 }
00089 setWidth( tmpRect.width() );
00090 setHeight( tmpRect.height() );
00091 }
00092
00093 ElementType EncloseElement::elementType() const
00094 {
00095 return Enclose;
00096 }
00097
|