]> git.lyx.org Git - features.git/commitdiff
Separate interface from implementation; make GraphicsImage's pure virtual
authorAngus Leeming <leeming@lyx.org>
Tue, 16 Sep 2003 15:34:39 +0000 (15:34 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 16 Sep 2003 15:34:39 +0000 (15:34 +0000)
functions private.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7775 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/QLImage.C
src/frontends/qt2/QLImage.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/xformsImage.C
src/frontends/xforms/xformsImage.h
src/graphics/ChangeLog
src/graphics/GraphicsImage.h

index 0b555dcc0a8514003aa8e1c392abbce1f09128e0..0e0bef6ceef0ab7bddcdc67fa265271628e9e988 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * QLImage.[Ch]: separate interface from implementation. Make all the virtual
+       functions private.
+
 2003-09-16  Angus Leeming  <leeming@lyx.org>
 
        * QCharacter.C, QPrefs.C, lyx_gui.C: add #include "LColor.h".
index 5ccb39d2ea722d827e1cab8a7813ccb479ad6e41..7b7d246f8bc742f304a9ab35f2312be53b9472bc 100644 (file)
@@ -113,25 +113,25 @@ QLImage::~QLImage()
 }
 
 
-Image * QLImage::clone() const
+Image * QLImage::clone_impl() const
 {
        return new QLImage(*this);
 }
 
 
-unsigned int QLImage::getWidth() const
+unsigned int QLImage::getWidth_impl() const
 {
        return xformed_pixmap_.width();
 }
 
 
-unsigned int QLImage::getHeight() const
+unsigned int QLImage::getHeight_impl() const
 {
        return xformed_pixmap_.height();
 }
 
 
-void QLImage::load(string const & filename)
+void QLImage::load_impl(string const & filename)
 {
        if (!pixmap_.isNull()) {
                lyxerr[Debug::GRAPHICS]
@@ -151,7 +151,7 @@ void QLImage::load(string const & filename)
 }
 
 
-bool QLImage::setPixmap(Params const & params)
+bool QLImage::setPixmap_impl(Params const & params)
 {
        if (pixmap_.isNull() || params.display == NoDisplay)
                return false;
@@ -185,7 +185,7 @@ bool QLImage::setPixmap(Params const & params)
 }
 
 
-void QLImage::clip(Params const & params)
+void QLImage::clip_impl(Params const & params)
 {
        if (xformed_pixmap_.isNull())
                return;
@@ -219,7 +219,7 @@ void QLImage::clip(Params const & params)
 }
 
 
-void QLImage::rotate(Params const & params)
+void QLImage::rotate_impl(Params const & params)
 {
        if (xformed_pixmap_.isNull())
                return;
@@ -236,7 +236,7 @@ void QLImage::rotate(Params const & params)
 }
 
 
-void QLImage::scale(Params const & params)
+void QLImage::scale_impl(Params const & params)
 {
        if (xformed_pixmap_.isNull())
                return;
index 9885bbc8409b7ba7053b854307d3b5c7b127e9f3..b4d1a1684c988d4a0c9f3e22963f2bb676d4ae1a 100644 (file)
@@ -30,45 +30,37 @@ public:
        static FormatList loadableFormats();
 
        ~QLImage();
-
-       /// Create a copy
-       virtual Image * clone() const;
-
        QPixmap const & qpixmap() const { return xformed_pixmap_; }
 
+private:
+       /// Create a copy
+       virtual Image * clone_impl() const;
        /// Get the image width
-       virtual unsigned int getWidth() const;
-
+       virtual unsigned int getWidth_impl() const;
        /// Get the image height
-       virtual unsigned int getHeight() const;
-
-       // FIXME
-       virtual bool isDrawable() const { return true; }
-
+       virtual unsigned int getHeight_impl() const;
+       // FIXME Is the image drawable ?
+       virtual bool isDrawable_impl() const { return true; }
        /**
         * Load the image file into memory.
         * The process is asynchronous, so this method starts the loading.
         * When finished, the Image::finishedLoading signal is emitted.
         */
-       virtual void load(string const & filename);
-
+       virtual void load_impl(string const & filename);
        /**
         * Generate the pixmap, based on the current state of
         * image_ (clipped, rotated, scaled etc).
         * Uses the params to decide on color, grayscale etc.
         * Returns true if the pixmap is created.
         */
-       virtual bool setPixmap(Params const & params);
-
+       virtual bool setPixmap_impl(Params const & params);
        /// Clip the image using params.
-       virtual void clip(Params const & params);
-
+       virtual void clip_impl(Params const & params);
        /// Rotate the image using params.
-       virtual void rotate(Params const & params);
-
+       virtual void rotate_impl(Params const & params);
        /// Scale the image using params.
-       virtual void scale(Params const & params);
-private:
+       virtual void scale_impl(Params const & params);
+
        /// Access to the class is through newImage() and clone.
        QLImage();
        ///
index 957601669dde7cc89c2c3c4b567a2e7a0a1992d5..cb3b3440a8bbc21258a548f1af785df0506a64fa 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * xformsImage.[Ch]: separate interface from implementation. Make all the virtual
+       functions private.
+
 2003-09-16  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * lyx_gui.C: use namespace alias for lyx::support::os
index fb24938330e05c5716221fa3af4ce98de14d5ce5..1646ea034a2758d7674d6f8bc6f1b738a8d922af 100644 (file)
@@ -151,13 +151,21 @@ xformsImage::~xformsImage()
 }
 
 
-Image * xformsImage::clone() const
+Pixmap xformsImage::getPixmap() const
+{
+       if (!pixmap_status_ == PIXMAP_SUCCESS)
+               return 0;
+       return pixmap_;
+}
+
+
+Image * xformsImage::clone_impl() const
 {
        return new xformsImage(*this);
 }
 
 
-unsigned int xformsImage::getWidth() const
+unsigned int xformsImage::getWidth_impl() const
 {
        if (!image_)
                return 0;
@@ -166,7 +174,7 @@ unsigned int xformsImage::getWidth() const
 }
 
 
-unsigned int xformsImage::getHeight() const
+unsigned int xformsImage::getHeight_impl() const
 {
        if (!image_)
                return 0;
@@ -174,21 +182,13 @@ unsigned int xformsImage::getHeight() const
 }
 
 
-bool xformsImage::isDrawable() const
+bool xformsImage::isDrawable_impl() const
 {
        return pixmap_;
 }
 
 
-Pixmap xformsImage::getPixmap() const
-{
-       if (!pixmap_status_ == PIXMAP_SUCCESS)
-               return 0;
-       return pixmap_;
-}
-
-
-void xformsImage::load(string const & filename)
+void xformsImage::load_impl(string const & filename)
 {
        if (image_) {
                lyxerr[Debug::GRAPHICS]
@@ -216,7 +216,7 @@ void xformsImage::load(string const & filename)
 }
 
 
-bool xformsImage::setPixmap(Params const & params)
+bool xformsImage::setPixmap_impl(Params const & params)
 {
        if (!image_ || params.display == NoDisplay)
                return false;
@@ -263,7 +263,7 @@ bool xformsImage::setPixmap(Params const & params)
 }
 
 
-void xformsImage::clip(Params const & params)
+void xformsImage::clip_impl(Params const & params)
 {
        if (!image_)
                return;
@@ -301,7 +301,7 @@ void xformsImage::clip(Params const & params)
 }
 
 
-void xformsImage::rotate(Params const & params)
+void xformsImage::rotate_impl(Params const & params)
 {
        if (!image_)
                return ;
@@ -327,7 +327,7 @@ void xformsImage::rotate(Params const & params)
 }
 
 
-void xformsImage::scale(Params const & params)
+void xformsImage::scale_impl(Params const & params)
 {
        if (!image_)
                return;
index ebf3481ce39f58ed0a703ee94c655d6c3f1e1695..4ee651894fbf988e58c30fd491fcee83716bc7f5 100644 (file)
@@ -38,49 +38,42 @@ public:
 
        ///
        ~xformsImage();
-
-       /// Create a copy
-       Image * clone() const;
-
        ///
        Pixmap getPixmap() const;
 
-       /// Get the image width
-       unsigned int getWidth() const;
+       /// Internal callbacks.
+       void statusCB(string const &);
+       void errorCB(string const &);
 
+private:
+       /// Create a copy
+       virtual Image * clone_impl() const;
+       /// Get the image width
+       virtual unsigned int getWidth_impl() const;
        /// Get the image height
-       unsigned int getHeight() const;
-
-       virtual bool isDrawable() const;
-
+       virtual unsigned int getHeight_impl() const;
+       /// Is the image drawable ?
+       virtual bool isDrawable_impl() const;
        /** Load the image file into memory.
         *  The process is asynchronous, so this method starts the loading.
         *  When finished, the Image::finishedLoading signal is emitted.
         */
-       void load(string const & filename);
-
+       virtual void load_impl(string const & filename);
        /** Generate the pixmap, based on the current state of
         *  image_ (clipped, rotated, scaled etc).
         *  Uses the params to decide on color, grayscale etc.
         *  Returns true if the pixmap is created.
         */
-       bool setPixmap(Params const & params);
-
+       bool setPixmap_impl(Params const & params);
        /// Clip the image using params.
-       void clip(Params const & params);
+       virtual void clip_impl(Params const & params);
 
        /// Rotate the image using params.
-       void rotate(Params const & params);
+       virtual void rotate_impl(Params const & params);
 
        /// Scale the image using params.
-       void scale(Params const & params);
-
-       /// Internal callbacks.
-       void statusCB(string const &);
-       ///
-       void errorCB(string const &);
+       virtual void scale_impl(Params const & params);
 
-private:
        /// Access to the class is through newImage() and clone.
        xformsImage();
        ///
index 791b8fa5db813f34dc4dfb231f4de7850273ee2d..ca84c77669059aaa1441ccac11ade4ab638e90d1 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * GraphicsImage.h: separate interface from implementation. Make all the
+       pure virtual functions private.
+
 2003-09-16  Angus Leeming  <leeming@lyx.org>
 
        * PreviewLoader.C: add #include "LColor.h".
index ec39bc1b5aec732d66c905fe72bbf30f5acad684..7200a8ce341f0de70ffe7a67a36c3ecfcd414c08 100644 (file)
@@ -52,24 +52,20 @@ public:
        ///
        static boost::function0<FormatList> loadableFormats;
 
-       /// Must define default c-tor explicitly as we define a copy c-tor.
-       Image() {}
-       /// Don't copy the signal finishedLoading
-       Image(Image const &) {}
        ///
        virtual ~Image() {}
 
        /// Create a copy
-       virtual Image * clone() const = 0;
+       Image * clone() const;
 
        /// Get the image width
-       virtual unsigned int getWidth() const = 0;
+       unsigned int getWidth() const;
 
        /// Get the image height
-       virtual unsigned int getHeight() const = 0;
+       unsigned int getHeight() const;
 
-       /// is the image drawable ?
-       virtual bool isDrawable() const = 0;
+       /// Is the image drawable ?
+       bool isDrawable() const;
 
        /** At the end of the loading process inform the outside world
         *  by emitting a signal.
@@ -82,32 +78,133 @@ public:
         *  The caller should expect this process to be asynchronous and
         *  so should connect to the "finished" signal above.
         */
-       virtual void load(string const & filename) = 0;
+       void load(string const & filename);
 
        /** Generate the pixmap.
         *  Uses the params to decide on color, grayscale etc.
         *  Returns true if the pixmap is created.
         */
-       virtual bool setPixmap(Params const & params) = 0;
+       bool setPixmap(Params const & params);
 
        /// Clip the image using params.
-       virtual void clip(Params const & params) = 0;
+       void clip(Params const & params);
 
        /// Rotate the image using params.
-       virtual void rotate(Params const & params) = 0;
+       void rotate(Params const & params);
 
        /// Scale the image using params.
-       virtual void scale(Params const & params) = 0;
+       void scale(Params const & params);
 
 protected:
+       /// Must define default c-tor explicitly as we define a copy c-tor.
+       Image() {}
+       /// Don't copy the signal finishedLoading
+       Image(Image const &) {}
+
        /** Uses the params to ascertain the dimensions of the scaled image.
         *  Returned as make_pair(width, height).
         *  If something goes wrong, returns make_pair(getWidth(), getHeight())
         */
        std::pair<unsigned int, unsigned int>
        getScaledDimensions(Params const & params) const;
+
+private:
+       /// Create a copy
+       virtual Image * clone_impl() const = 0;
+       /// Get the image width
+       virtual unsigned int getWidth_impl() const = 0;
+
+       /// Get the image height
+       virtual unsigned int getHeight_impl() const = 0;
+
+       /// is the image drawable ?
+       virtual bool isDrawable_impl() const = 0;
+
+       /** Start loading the image file.
+        *  The caller should expect this process to be asynchronous and
+        *  so should connect to the "finished" signal above.
+        */
+       virtual void load_impl(string const & filename) = 0;
+
+       /** Generate the pixmap.
+        *  Uses the params to decide on color, grayscale etc.
+        *  Returns true if the pixmap is created.
+        */
+       virtual bool setPixmap_impl(Params const & params) = 0;
+
+       /// Clip the image using params.
+       virtual void clip_impl(Params const & params) = 0;
+
+       /// Rotate the image using params.
+       virtual void rotate_impl(Params const & params) = 0;
+
+       /// Scale the image using params.
+       virtual void scale_impl(Params const & params) = 0;
 };
 
+
+inline
+Image * Image::clone() const
+{
+       return clone_impl();
+}
+
+
+inline
+unsigned int Image::getWidth() const
+{
+       return getWidth_impl();
+}
+
+
+inline
+unsigned int Image::getHeight() const
+{
+       return getHeight_impl();
+}
+
+
+inline
+bool Image::isDrawable() const
+{
+       return isDrawable_impl();
+}
+
+
+inline
+void Image::load(string const & filename)
+{
+       return load_impl(filename);
+}
+
+
+inline
+bool Image::setPixmap(Params const & params)
+{
+       return setPixmap_impl(params);
+}
+
+
+inline
+void Image::clip(Params const & params)
+{
+       return clip_impl(params);
+}
+
+
+inline
+void Image::rotate(Params const & params)
+{
+       return rotate_impl(params);
+}
+
+
+inline
+void Image::scale(Params const & params)
+{
+       return scale_impl(params);
+}
+
 } // namespace graphics
 } // namespace lyx