1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27*1cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlayrectangle.hxx>
28cdf0e10cSrcweir #include <vcl/outdev.hxx>
29cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
30cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
32cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
33cdf0e10cSrcweir #include <svx/sdr/overlay/overlaytools.hxx>
34*1cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlaymanager.hxx>
35*1cd65da9SArmin Le Grand #include <vcl/svapp.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace sdr
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	namespace overlay
42cdf0e10cSrcweir 	{
createOverlayObjectPrimitive2DSequence()43*1cd65da9SArmin Le Grand 		drawinglayer::primitive2d::Primitive2DSequence OverlayRectangle::createOverlayObjectPrimitive2DSequence()
44cdf0e10cSrcweir 		{
45cdf0e10cSrcweir             const basegfx::B2DRange aHatchRange(getBasePosition(), getSecondPosition());
46*1cd65da9SArmin Le Grand             basegfx::BColor aColor(getBaseColor().getBColor());
47*1cd65da9SArmin Le Grand             static double fChange(0.1); // just small optical change, do not make it annoying
48*1cd65da9SArmin Le Grand 
49*1cd65da9SArmin Le Grand             if(mbOverlayState)
50*1cd65da9SArmin Le Grand             {
51*1cd65da9SArmin Le Grand                 aColor += basegfx::B3DTuple(fChange, fChange, fChange);
52*1cd65da9SArmin Le Grand                 aColor.clamp();
53*1cd65da9SArmin Le Grand             }
54*1cd65da9SArmin Le Grand             else
55*1cd65da9SArmin Le Grand             {
56*1cd65da9SArmin Le Grand                 aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
57*1cd65da9SArmin Le Grand                 aColor.clamp();
58*1cd65da9SArmin Le Grand             }
59*1cd65da9SArmin Le Grand 
60cdf0e10cSrcweir             const drawinglayer::primitive2d::Primitive2DReference aReference(
61*1cd65da9SArmin Le Grand                 new drawinglayer::primitive2d::OverlayRectanglePrimitive(
62cdf0e10cSrcweir                     aHatchRange,
63*1cd65da9SArmin Le Grand                     aColor,
64*1cd65da9SArmin Le Grand                     getTransparence(),
65cdf0e10cSrcweir                     getDiscreteGrow(),
66cdf0e10cSrcweir                     getDiscreteShrink(),
67cdf0e10cSrcweir                     getRotation()));
68cdf0e10cSrcweir 
69cdf0e10cSrcweir             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
70cdf0e10cSrcweir 		}
71cdf0e10cSrcweir 
OverlayRectangle(const basegfx::B2DPoint & rBasePosition,const basegfx::B2DPoint & rSecondPosition,const Color & rHatchColor,double fTransparence,double fDiscreteGrow,double fDiscreteShrink,double fRotation,sal_uInt32 nBlinkTime,bool bAnimate)72*1cd65da9SArmin Le Grand         OverlayRectangle::OverlayRectangle(
73cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePosition,
74cdf0e10cSrcweir             const basegfx::B2DPoint& rSecondPosition,
75cdf0e10cSrcweir             const Color& rHatchColor,
76*1cd65da9SArmin Le Grand             double fTransparence,
77cdf0e10cSrcweir             double fDiscreteGrow,
78cdf0e10cSrcweir             double fDiscreteShrink,
79*1cd65da9SArmin Le Grand             double fRotation,
80*1cd65da9SArmin Le Grand             sal_uInt32 nBlinkTime,
81*1cd65da9SArmin Le Grand             bool bAnimate)
82cdf0e10cSrcweir 		:	OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
83cdf0e10cSrcweir             maSecondPosition(rSecondPosition),
84*1cd65da9SArmin Le Grand             mfTransparence(fTransparence),
85cdf0e10cSrcweir             mfDiscreteGrow(fDiscreteGrow),
86cdf0e10cSrcweir             mfDiscreteShrink(fDiscreteShrink),
87*1cd65da9SArmin Le Grand             mfRotation(fRotation),
88*1cd65da9SArmin Le Grand             mnBlinkTime(nBlinkTime),
89*1cd65da9SArmin Le Grand             mbOverlayState(false)
90cdf0e10cSrcweir 		{
91*1cd65da9SArmin Le Grand             if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
92*1cd65da9SArmin Le Grand             {
93*1cd65da9SArmin Le Grand                 // no animation in high contrast mode
94*1cd65da9SArmin Le Grand                 bAnimate = false;
95*1cd65da9SArmin Le Grand             }
96*1cd65da9SArmin Le Grand 
97*1cd65da9SArmin Le Grand             // set AllowsAnimation flag to mark this object as animation capable
98*1cd65da9SArmin Le Grand             mbAllowsAnimation = bAnimate;
99*1cd65da9SArmin Le Grand 
100*1cd65da9SArmin Le Grand             // #i53216# check blink time value range
101*1cd65da9SArmin Le Grand             mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
102cdf0e10cSrcweir 		}
103cdf0e10cSrcweir 
setSecondPosition(const basegfx::B2DPoint & rNew)104*1cd65da9SArmin Le Grand 		void OverlayRectangle::setSecondPosition(const basegfx::B2DPoint& rNew)
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			if(rNew != maSecondPosition)
107cdf0e10cSrcweir 			{
108cdf0e10cSrcweir 				// remember new value
109cdf0e10cSrcweir 				maSecondPosition = rNew;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 				// register change (after change)
112cdf0e10cSrcweir 				objectChange();
113cdf0e10cSrcweir 			}
114cdf0e10cSrcweir 		}
115*1cd65da9SArmin Le Grand 
setBlinkTime(sal_uInt32 nNew)116*1cd65da9SArmin Le Grand         void OverlayRectangle::setBlinkTime(sal_uInt32 nNew)
117*1cd65da9SArmin Le Grand 		{
118*1cd65da9SArmin Le Grand 			if(mnBlinkTime != nNew)
119*1cd65da9SArmin Le Grand 			{
120*1cd65da9SArmin Le Grand 				// remember new value
121*1cd65da9SArmin Le Grand 				mnBlinkTime = nNew;
122*1cd65da9SArmin Le Grand 
123*1cd65da9SArmin Le Grand 				// #i53216# check blink time value range
124*1cd65da9SArmin Le Grand 				mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
125*1cd65da9SArmin Le Grand 
126*1cd65da9SArmin Le Grand 				// register change (after change)
127*1cd65da9SArmin Le Grand 				objectChange();
128*1cd65da9SArmin Le Grand 			}
129*1cd65da9SArmin Le Grand 		}
130*1cd65da9SArmin Le Grand 
Trigger(sal_uInt32 nTime)131*1cd65da9SArmin Le Grand 		void OverlayRectangle::Trigger(sal_uInt32 nTime)
132*1cd65da9SArmin Le Grand 		{
133*1cd65da9SArmin Le Grand 			if(getOverlayManager())
134*1cd65da9SArmin Le Grand 			{
135*1cd65da9SArmin Le Grand 				// #i53216# produce event after nTime + x
136*1cd65da9SArmin Le Grand 				SetTime(nTime + mnBlinkTime);
137*1cd65da9SArmin Le Grand 
138*1cd65da9SArmin Le Grand 				// switch state
139*1cd65da9SArmin Le Grand 				if(mbOverlayState)
140*1cd65da9SArmin Le Grand 				{
141*1cd65da9SArmin Le Grand 					mbOverlayState = false;
142*1cd65da9SArmin Le Grand 				}
143*1cd65da9SArmin Le Grand 				else
144*1cd65da9SArmin Le Grand 				{
145*1cd65da9SArmin Le Grand 					mbOverlayState = true;
146*1cd65da9SArmin Le Grand 				}
147*1cd65da9SArmin Le Grand 
148*1cd65da9SArmin Le Grand 				// re-insert me as event
149*1cd65da9SArmin Le Grand 				getOverlayManager()->InsertEvent(this);
150*1cd65da9SArmin Le Grand 
151*1cd65da9SArmin Le Grand                 // register change (after change)
152*1cd65da9SArmin Le Grand 				objectChange();
153*1cd65da9SArmin Le Grand 			}
154*1cd65da9SArmin Le Grand 		}
155cdf0e10cSrcweir 	} // end of namespace overlay
156cdf0e10cSrcweir } // end of namespace sdr
157cdf0e10cSrcweir 
158cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
159cdf0e10cSrcweir // eof
160