xref: /aoo41x/main/vcl/inc/vcl/gradient.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_GRADIENT_HXX
29 #define _SV_GRADIENT_HXX
30 
31 #include <vcl/dllapi.h>
32 #include <tools/color.hxx>
33 
34 #include <vcl/vclenum.hxx>
35 
36 // ------------------
37 // - Gradient-Types -
38 // ------------------
39 
40 /*
41 #ifndef ENUM_GRADIENTSTYLE_DECLARED
42 #define ENUM_GRADIENTSTYLE_DECLARED
43 enum GradientStyle { GRADIENT_LINEAR, GRADIENT_AXIAL, GRADIENT_RADIAL,
44                      GRADIENT_ELLIPTICAL, GRADIENT_SQUARE, GRADIENT_RECT };
45 #endif
46 */
47 
48 // ----------------
49 // - Impl_Gradient -
50 // ----------------
51 
52 class SvStream;
53 
54 class Impl_Gradient
55 {
56 public:
57     sal_uLong           mnRefCount;
58     GradientStyle   meStyle;
59     Color           maStartColor;
60     Color           maEndColor;
61     sal_uInt16          mnAngle;
62     sal_uInt16          mnBorder;
63     sal_uInt16          mnOfsX;
64     sal_uInt16          mnOfsY;
65     sal_uInt16          mnIntensityStart;
66     sal_uInt16          mnIntensityEnd;
67     sal_uInt16          mnStepCount;
68 
69     friend SvStream& operator>>( SvStream& rIStm, Impl_Gradient& rImplGradient );
70     friend SvStream& operator<<( SvStream& rOStm, const Impl_Gradient& rImplGradient );
71 
72                     Impl_Gradient();
73                     Impl_Gradient( const Impl_Gradient& rImplGradient );
74 };
75 
76 // ------------
77 // - Gradient -
78 // ------------
79 
80 class VCL_DLLPUBLIC Gradient
81 {
82 private:
83     Impl_Gradient*	mpImplGradient;
84 	void			MakeUnique();
85 
86 public:
87                     Gradient();
88                     Gradient( const Gradient& rGradient );
89                     Gradient( GradientStyle eStyle );
90                     Gradient( GradientStyle eStyle,
91                               const Color& rStartColor,
92                               const Color& rEndColor );
93                     ~Gradient();
94 
95     void            SetStyle( GradientStyle eStyle );
96     GradientStyle   GetStyle() const { return mpImplGradient->meStyle; }
97 
98     void            SetStartColor( const Color& rColor );
99     const Color&    GetStartColor() const { return mpImplGradient->maStartColor; }
100     void            SetEndColor( const Color& rColor );
101     const Color&    GetEndColor() const { return mpImplGradient->maEndColor; }
102 
103     void            SetAngle( sal_uInt16 nAngle );
104     sal_uInt16          GetAngle() const { return mpImplGradient->mnAngle; }
105 
106     void            SetBorder( sal_uInt16 nBorder );
107     sal_uInt16          GetBorder() const { return mpImplGradient->mnBorder; }
108     void            SetOfsX( sal_uInt16 nOfsX );
109     sal_uInt16          GetOfsX() const { return mpImplGradient->mnOfsX; }
110     void            SetOfsY( sal_uInt16 nOfsY );
111     sal_uInt16          GetOfsY() const { return mpImplGradient->mnOfsY; }
112 
113     void            SetStartIntensity( sal_uInt16 nIntens );
114     sal_uInt16          GetStartIntensity() const { return mpImplGradient->mnIntensityStart; }
115     void            SetEndIntensity( sal_uInt16 nIntens );
116     sal_uInt16          GetEndIntensity() const { return mpImplGradient->mnIntensityEnd; }
117 
118     void            SetSteps( sal_uInt16 nSteps );
119     sal_uInt16          GetSteps() const { return mpImplGradient->mnStepCount; }
120 
121     Gradient&       operator=( const Gradient& rGradient );
122     sal_Bool            operator==( const Gradient& rGradient ) const;
123     sal_Bool            operator!=( const Gradient& rGradient ) const
124                         { return !(Gradient::operator==( rGradient )); }
125     sal_Bool            IsSameInstance( const Gradient& rGradient ) const
126                         { return (mpImplGradient == rGradient.mpImplGradient); }
127 
128     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Gradient& rGradient );
129     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Gradient& rGradient );
130 };
131 
132 #endif  // _SV_GRADIENT_HXX
133