#include <KDChartLayoutItems.h>
Inheritance diagram for KDChart::AutoSpacerLayoutItem:
Public Member Functions | |
| AutoSpacerLayoutItem (bool layoutIsAtTopPosition, QHBoxLayout *rightLeftLayout, bool layoutIsAtLeftPosition, QVBoxLayout *topBottomLayout) | |
| virtual Qt::Orientations | expandingDirections () const |
| virtual QRect | geometry () const |
| virtual bool | isEmpty () const |
| virtual QSize | maximumSize () const |
| virtual QSize | minimumSize () const |
| virtual void | paint (QPainter *) |
| virtual void | paintAll (QPainter &painter) |
| Default impl: just call paint. | |
| virtual void | paintCtx (PaintContext *context) |
| Default impl: Paint the complete item using its layouted position and size. | |
| QLayout * | parentLayout () |
| void | removeFromParentLayout () |
| virtual void | setGeometry (const QRect &r) |
| void | setParentLayout (QLayout *lay) |
| virtual void | setParentWidget (QWidget *widget) |
| Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed. | |
| virtual QSize | sizeHint () const |
| virtual void | sizeHintChanged () const |
| Report changed size hint: ask the parent widget to recalculate the layout. | |
Protected Attributes | |
| QWidget * | mParent |
| QLayout * | mParentLayout |
|
||||||||||||||||||||
|
Definition at line 756 of file KDChartLayoutItems.cpp.
00759 : AbstractLayoutItem( Qt::AlignCenter ) 00760 , mLayoutIsAtTopPosition( layoutIsAtTopPosition ) 00761 , mRightLeftLayout( rightLeftLayout ) 00762 , mLayoutIsAtLeftPosition( layoutIsAtLeftPosition ) 00763 , mTopBottomLayout( topBottomLayout ) 00764 { 00765 } |
|
|
Definition at line 767 of file KDChartLayoutItems.cpp.
00768 {
00769 return 0; // Grow neither vertically nor horizontally
00770 }
|
|
|
Definition at line 772 of file KDChartLayoutItems.cpp.
00773 {
00774 return mRect;
00775 }
|
|
|
Definition at line 777 of file KDChartLayoutItems.cpp.
00778 {
00779 return true; // never empty, otherwise the layout item would not exist
00780 }
|
|
|
Definition at line 782 of file KDChartLayoutItems.cpp. References sizeHint().
00783 {
00784 return sizeHint();
00785 }
|
|
|
Definition at line 787 of file KDChartLayoutItems.cpp. References sizeHint().
00788 {
00789 return sizeHint();
00790 }
|
|
|
Implements KDChart::AbstractLayoutItem. Definition at line 861 of file KDChartLayoutItems.cpp.
00862 {
00863 if( mParentLayout && mRect.isValid() && mCachedSize.isValid() &&
00864 mCommonBrush.style() != Qt::NoBrush )
00865 {
00866 QPoint p1( mRect.topLeft() );
00867 QPoint p2( mRect.bottomRight() );
00868 if( mLayoutIsAtLeftPosition )
00869 p1.rx() += mCachedSize.width() - mParentLayout->spacing();
00870 else
00871 p2.rx() -= mCachedSize.width() - mParentLayout->spacing();
00872 if( mLayoutIsAtTopPosition ){
00873 p1.ry() += mCachedSize.height() - mParentLayout->spacing() - 1;
00874 p2.ry() -= 1;
00875 }else
00876 p2.ry() -= mCachedSize.height() - mParentLayout->spacing() - 1;
00877 //qDebug() << mLayoutIsAtTopPosition << mLayoutIsAtLeftPosition;
00878 //qDebug() << mRect;
00879 //qDebug() << mParentLayout->margin();
00880 //qDebug() << QRect( p1, p2 );
00881 const QPoint oldBrushOrigin( painter->brushOrigin() );
00882 const QBrush oldBrush( painter->brush() );
00883 const QPen oldPen( painter->pen() );
00884 const QPointF newTopLeft( painter->deviceMatrix().map( p1 ) );
00885 painter->setBrushOrigin( newTopLeft );
00886 painter->setBrush( mCommonBrush );
00887 painter->setPen( Qt::NoPen );
00888 painter->drawRect( QRect( p1, p2 ) );
00889 painter->setBrushOrigin( oldBrushOrigin );
00890 painter->setBrush( oldBrush );
00891 painter->setPen( oldPen );
00892 }
00893 // debug code:
00894 #if 0
00895 //qDebug() << "KDChart::AutoSpacerLayoutItem::paint()";
00896 if( !mRect.isValid() )
00897 return;
00898
00899 painter->drawRect( mRect );
00900 painter->drawLine( QPointF( mRect.x(), mRect.top() ),
00901 QPointF( mRect.right(), mRect.bottom() ) );
00902 painter->drawLine( QPointF( mRect.right(), mRect.top() ),
00903 QPointF( mRect.x(), mRect.bottom() ) );
00904 #endif
00905 }
|
|
|
Default impl: just call paint. Derived classes like KDChart::AbstractArea are providing additional action here. Reimplemented in KDChart::AbstractArea, and KDChart::TextArea. Definition at line 69 of file KDChartLayoutItems.cpp. References KDChart::AbstractLayoutItem::paint().
00070 {
00071 paint( &painter );
00072 }
|
|
|
Default impl: Paint the complete item using its layouted position and size.
Reimplemented in KDChart::CartesianAxis. Definition at line 77 of file KDChartLayoutItems.cpp. References KDChart::AbstractLayoutItem::paint(), and KDChart::PaintContext::painter().
00078 {
00079 if( context )
00080 paint( context->painter() );
00081 }
|
|
|
Definition at line 74 of file KDChartLayoutItems.h.
00075 {
00076 return mParentLayout;
00077 }
|
|
|
Definition at line 78 of file KDChartLayoutItems.h. Referenced by KDChart::Chart::takeCoordinatePlane().
00079 {
00080 if( mParentLayout ){
00081 if( widget() )
00082 mParentLayout->removeWidget( widget() );
00083 else
00084 mParentLayout->removeItem( this );
00085 }
00086 }
|
|
|
Definition at line 792 of file KDChartLayoutItems.cpp.
00793 {
00794 mRect = r;
00795 }
|
|
|
Definition at line 70 of file KDChartLayoutItems.h.
00071 {
00072 mParentLayout = lay;
00073 }
|
|
|
Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed. Thus, you need to call setParentWidget on every item, that has a non-fixed size. Definition at line 64 of file KDChartLayoutItems.cpp. References KDChart::AbstractLayoutItem::mParent. Referenced by KDChart::Legend::buildLegend(), and KDChart::AbstractCartesianDiagram::takeAxis().
00065 {
00066 mParent = widget;
00067 }
|
|
|
Definition at line 817 of file KDChartLayoutItems.cpp. References KDChart::AbstractArea::bottomOverlap(), KDChart::AbstractArea::leftOverlap(), KDChart::AbstractArea::rightOverlap(), KDChart::AbstractArea::topOverlap(), and updateCommonBrush(). Referenced by maximumSize(), and minimumSize().
00818 {
00819 QBrush commonBrush;
00820 bool bStart=true;
00821 // calculate the maximal overlap of the top/bottom axes:
00822 int topBottomOverlap = 0;
00823 if( mTopBottomLayout ){
00824 for (int i = 0; i < mTopBottomLayout->count(); ++i){
00825 AbstractArea* area = dynamic_cast<AbstractArea*>(mTopBottomLayout->itemAt(i));
00826 if( area ){
00827 //qDebug() << "AutoSpacerLayoutItem testing" << area;
00828 topBottomOverlap =
00829 mLayoutIsAtLeftPosition
00830 ? qMax( topBottomOverlap, area->rightOverlap() )
00831 : qMax( topBottomOverlap, area->leftOverlap() );
00832 updateCommonBrush( commonBrush, bStart, *area );
00833 }
00834 }
00835 }
00836 // calculate the maximal overlap of the left/right axes:
00837 int leftRightOverlap = 0;
00838 if( mRightLeftLayout ){
00839 for (int i = 0; i < mRightLeftLayout->count(); ++i){
00840 AbstractArea* area = dynamic_cast<AbstractArea*>(mRightLeftLayout->itemAt(i));
00841 if( area ){
00842 //qDebug() << "AutoSpacerLayoutItem testing" << area;
00843 leftRightOverlap =
00844 mLayoutIsAtTopPosition
00845 ? qMax( leftRightOverlap, area->bottomOverlap() )
00846 : qMax( leftRightOverlap, area->topOverlap() );
00847 updateCommonBrush( commonBrush, bStart, *area );
00848 }
00849 }
00850 }
00851 if( topBottomOverlap > 0 && leftRightOverlap > 0 )
00852 mCommonBrush = commonBrush;
00853 else
00854 mCommonBrush = QBrush();
00855 mCachedSize = QSize( topBottomOverlap, leftRightOverlap );
00856 //qDebug() << mCachedSize;
00857 return mCachedSize;
00858 }
|
|
|
Report changed size hint: ask the parent widget to recalculate the layout.
Definition at line 86 of file KDChartLayoutItems.cpp. Referenced by KDChart::TextLayoutItem::sizeHint().
00087 {
00088 // This is exactly like what QWidget::updateGeometry does.
00089 // qDebug("KDChart::AbstractLayoutItem::sizeHintChanged() called");
00090 if( mParent ) {
00091 if ( mParent->layout() )
00092 mParent->layout()->invalidate();
00093 else
00094 QApplication::postEvent( mParent, new QEvent( QEvent::LayoutRequest ) );
00095 }
00096 }
|
|
|
Definition at line 88 of file KDChartLayoutItems.h. Referenced by KDChart::AbstractLayoutItem::setParentWidget(). |
|
|
Definition at line 89 of file KDChartLayoutItems.h. |
1.3.6