Fill.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libmspub project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __FILL_H__
00011 #define __FILL_H__
00012 
00013 #include <cstddef>
00014 
00015 #include <vector>
00016 
00017 #include <librevenge/librevenge.h>
00018 
00019 #include "ColorReference.h"
00020 
00021 namespace libmspub
00022 {
00023 class MSPUBCollector;
00024 class Fill
00025 {
00026 protected:
00027   const MSPUBCollector *m_owner;
00028 public:
00029   Fill(const MSPUBCollector *owner);
00030   virtual void getProperties(librevenge::RVNGPropertyList *out) const = 0;
00031   virtual ~Fill() { }
00032 private:
00033   Fill(const Fill &) : m_owner(NULL) { }
00034   Fill &operator=(const Fill &);
00035 };
00036 
00037 class ImgFill : public Fill
00038 {
00039 protected:
00040   unsigned m_imgIndex;
00041 private:
00042   bool m_isTexture;
00043 protected:
00044   int m_rotation;
00045 public:
00046   ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int rotation);
00047   virtual void getProperties(librevenge::RVNGPropertyList *out) const;
00048 private:
00049   ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false), m_rotation(0) { }
00050   ImgFill &operator=(const ImgFill &);
00051 };
00052 
00053 class PatternFill : public ImgFill
00054 {
00055   ColorReference m_fg;
00056   ColorReference m_bg;
00057 public:
00058   PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference fg, ColorReference bg);
00059   void getProperties(librevenge::RVNGPropertyList *out) const;
00060 private:
00061   PatternFill(const PatternFill &) : ImgFill(0, NULL, true, 0), m_fg(0x08000000), m_bg(0x08000000) { }
00062   PatternFill &operator=(const ImgFill &);
00063 };
00064 
00065 class SolidFill : public Fill
00066 {
00067   ColorReference m_color;
00068   double m_opacity;
00069 public:
00070   SolidFill(ColorReference color, double opacity, const MSPUBCollector *owner);
00071   void getProperties(librevenge::RVNGPropertyList *out) const;
00072 private:
00073   SolidFill(const SolidFill &) : Fill(NULL), m_color(0x08000000), m_opacity(1) { }
00074   SolidFill &operator=(const SolidFill &);
00075 };
00076 
00077 class GradientFill : public Fill
00078 {
00079   struct StopInfo
00080   {
00081     ColorReference m_colorReference;
00082     unsigned m_offsetPercent;
00083     double m_opacity;
00084     StopInfo(ColorReference colorReference, unsigned offsetPercent, double opacity) : m_colorReference(colorReference), m_offsetPercent(offsetPercent), m_opacity(opacity) { }
00085   };
00086   std::vector<StopInfo> m_stops;
00087   double m_angle;
00088   int m_type;
00089   double m_fillLeftVal;
00090   double m_fillTopVal;
00091   double m_fillRightVal;
00092   double m_fillBottomVal;
00093 public:
00094   GradientFill(const MSPUBCollector *owner, double angle = 0, int type = 7);
00095   void setFillCenter(double left, double top, double right, double bottom);
00096   void addColor(ColorReference c, unsigned offsetPercent, double opacity);
00097   void addColorReverse(ColorReference c, unsigned offsetPercent, double opacity);
00098   void completeComplexFill();
00099   void getProperties(librevenge::RVNGPropertyList *out) const;
00100 private:
00101   GradientFill(const GradientFill &) : Fill(NULL), m_stops(), m_angle(0), m_type(7), m_fillLeftVal(0.0), m_fillTopVal(0.0), m_fillRightVal(0.0), m_fillBottomVal(0.0) { }
00102   GradientFill &operator=(const GradientFill &);
00103 };
00104 }
00105 
00106 #endif /* __FILL_H__ */
00107 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */