]> Git trees. - libqmvoc.git/commitdiff
API changes:
authorPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 16:39:17 +0000 (16:39 +0000)
committerPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 16:39:17 +0000 (16:39 +0000)
- move the padding information to the Private class
- add a const overload for axis()

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634216

kdeeduplot/kplotwidget.cpp
kdeeduplot/kplotwidget.h

index 03eed6e674fec6c75304cb0842742d5c61068e1c..5670b50317891820ec0955dcb9b4c2e5e555d3dd 100644 (file)
@@ -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<KPlotPoint*> KPlotWidget::pointsUnderPoint( const QPoint& p ) const {
        QList<KPlotPoint*> 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;
+}
+
index cd16b299aa578176d2b59552cdd50c914aef9a3f..3b6a8fade8b87c7bd30947d70c30397c2ede25b4 100644 (file)
@@ -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<Axis, KPlotAxis*> 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];