From: Pino Toscano Date: Fri, 16 Feb 2007 16:39:17 +0000 (+0000) Subject: API changes: X-Git-Tag: v3.80.3~55 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=cb2c89f1b131c74d24362b2c8fdad256c541cd50;p=libqmvoc.git API changes: - move the padding information to the Private class - add a const overload for axis() svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634216 --- diff --git a/kdeeduplot/kplotwidget.cpp b/kdeeduplot/kplotwidget.cpp index 03eed6e..5670b50 100644 --- a/kdeeduplot/kplotwidget.cpp +++ b/kdeeduplot/kplotwidget.cpp @@ -54,6 +54,8 @@ class KPlotWidget::Private QColor cBackground, cForeground, cGrid; //draw options bool showGrid, showObjectToolTips, useAntialias; + //padding + int leftPadding, rightPadding, topPadding, bottomPadding; }; KPlotWidget::KPlotWidget( QWidget *parent, double x1, double x2, double y1, double y2 ) @@ -274,6 +276,11 @@ KPlotAxis* KPlotWidget::axis( Axis a ) { return mAxes.contains( a ) ? mAxes[a] : 0; } +const KPlotAxis* KPlotWidget::axis( Axis a ) const +{ + return mAxes.contains( a ) ? mAxes[a] : 0; +} + QList KPlotWidget::pointsUnderPoint( const QPoint& p ) const { QList pts; foreach ( KPlotObject *po, ObjectList ) { @@ -690,8 +697,9 @@ void KPlotWidget::drawAxes( QPainter *p ) { } //End of RightAxis } -int KPlotWidget::leftPadding() { - if ( LeftPadding >= 0 ) return LeftPadding; +int KPlotWidget::leftPadding() const +{ + if ( d->leftPadding >= 0 ) return d->leftPadding; if ( axis(LeftAxis)->isVisible() && axis(LeftAxis)->showTickLabels() ) { if ( ! axis(LeftAxis)->label().isEmpty() ) return 3*XPADDING; else return 2*XPADDING; @@ -699,8 +707,9 @@ int KPlotWidget::leftPadding() { return XPADDING; } -int KPlotWidget::rightPadding() { - if ( RightPadding >= 0 ) return RightPadding; +int KPlotWidget::rightPadding() const +{ + if ( d->rightPadding >= 0 ) return d->rightPadding; if ( axis(RightAxis)->isVisible() && axis(RightAxis)->showTickLabels() ) { if ( ! axis(RightAxis)->label().isEmpty() ) return 3*XPADDING; else return 2*XPADDING; @@ -708,8 +717,9 @@ int KPlotWidget::rightPadding() { return XPADDING; } -int KPlotWidget::topPadding() { - if ( TopPadding >= 0 ) return TopPadding; +int KPlotWidget::topPadding() const +{ + if ( d->topPadding >= 0 ) return d->topPadding; if ( axis(TopAxis)->isVisible() && axis(TopAxis)->showTickLabels() ) { if ( ! axis(TopAxis)->label().isEmpty() ) return 3*YPADDING; else return 2*YPADDING; @@ -717,11 +727,41 @@ int KPlotWidget::topPadding() { return YPADDING; } -int KPlotWidget::bottomPadding() { - if ( BottomPadding >= 0 ) return BottomPadding; +int KPlotWidget::bottomPadding() const +{ + if ( d->bottomPadding >= 0 ) return d->bottomPadding; if ( axis(BottomAxis)->isVisible() && axis(BottomAxis)->showTickLabels() ) { if ( ! axis(BottomAxis)->label().isEmpty() ) return 3*YPADDING; else return 2*YPADDING; } return YPADDING; } + +void KPlotWidget::setLeftPadding( int padding ) +{ + d->leftPadding = padding; +} + +void KPlotWidget::setRightPadding( int padding ) +{ + d->rightPadding = padding; +} + +void KPlotWidget::setTopPadding( int padding ) +{ + d->topPadding = padding; +} + +void KPlotWidget::setBottomPadding( int padding ) +{ + d->bottomPadding = padding; +} + +void KPlotWidget::setDefaultPaddings() +{ + d->leftPadding = -1; + d->rightPadding = -1; + d->topPadding = -1; + d->bottomPadding = -1; +} + diff --git a/kdeeduplot/kplotwidget.h b/kdeeduplot/kplotwidget.h index cd16b29..3b6a8fa 100644 --- a/kdeeduplot/kplotwidget.h +++ b/kdeeduplot/kplotwidget.h @@ -264,51 +264,51 @@ public: * Padding values are set to -1 by default; if unchanged, this function will try to guess * a good value, based on whether ticklabels and/or axis labels are to be drawn. */ - virtual int leftPadding(); + virtual int leftPadding() const; /** * @return the number of pixels to the right of the plot area. * Padding values are set to -1 by default; if unchanged, this function will try to guess * a good value, based on whether ticklabels and/or axis labels are to be drawn. */ - virtual int rightPadding(); + virtual int rightPadding() const; /** * @return the number of pixels above the plot area. * Padding values are set to -1 by default; if unchanged, this function will try to guess * a good value, based on whether ticklabels and/or axis labels are to be drawn. */ - virtual int topPadding(); + virtual int topPadding() const; /** * @return the number of pixels below the plot area. * Padding values are set to -1 by default; if unchanged, this function will try to guess * a good value, based on whether ticklabels and/or axis labels are to be drawn. */ - virtual int bottomPadding(); + virtual int bottomPadding() const; /** * Set the number of pixels to the left of the plot area. * Set this to -1 to revert to automatic determination of padding values. */ - virtual void setLeftPadding( int pad ) { LeftPadding = pad; } + virtual void setLeftPadding( int padding ); /** * Set the number of pixels to the right of the plot area. * Set this to -1 to revert to automatic determination of padding values. */ - virtual void setRightPadding( int pad ) { RightPadding = pad; } + virtual void setRightPadding( int padding ); /** * Set the number of pixels above the plot area. * Set this to -1 to revert to automatic determination of padding values. */ - virtual void setTopPadding( int pad ) { TopPadding = pad; } + virtual void setTopPadding( int padding ); /** * Set the number of pixels below the plot area. * Set this to -1 to revert to automatic determination of padding values. */ - virtual void setBottomPadding( int pad ) { BottomPadding = pad; } + virtual void setBottomPadding( int padding ); /** * Revert all four padding values to be automatically determined. */ - void setDefaultPaddings() { LeftPadding = -1; RightPadding = -1; TopPadding = -1; BottomPadding = -1; } + void setDefaultPaddings(); /** * Map a coordinate @p p from the data rect to the physical pixel rect. @@ -364,6 +364,8 @@ public: */ KPlotAxis* axis( Axis a ); + const KPlotAxis* axis( Axis a ) const; + inline QRect& pixRect() { return PixRect; } public slots: @@ -448,9 +450,6 @@ protected: */ QHash mAxes; - //padding - int LeftPadding, RightPadding, TopPadding, BottomPadding; - //Grid of bools to mask "used" regions of the plot float PlotMask[100][100]; double px[100], py[100];