xref: /AOO41X/main/svx/source/sdr/overlay/overlayrectangle.cxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
1*1cd65da9SArmin Le Grand /**************************************************************
2*1cd65da9SArmin Le Grand  *
3*1cd65da9SArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
4*1cd65da9SArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
5*1cd65da9SArmin Le Grand  * distributed with this work for additional information
6*1cd65da9SArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
7*1cd65da9SArmin Le Grand  * to you under the Apache License, Version 2.0 (the
8*1cd65da9SArmin Le Grand  * "License"); you may not use this file except in compliance
9*1cd65da9SArmin Le Grand  * with the License.  You may obtain a copy of the License at
10*1cd65da9SArmin Le Grand  *
11*1cd65da9SArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
12*1cd65da9SArmin Le Grand  *
13*1cd65da9SArmin Le Grand  * Unless required by applicable law or agreed to in writing,
14*1cd65da9SArmin Le Grand  * software distributed under the License is distributed on an
15*1cd65da9SArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1cd65da9SArmin Le Grand  * KIND, either express or implied.  See the License for the
17*1cd65da9SArmin Le Grand  * specific language governing permissions and limitations
18*1cd65da9SArmin Le Grand  * under the License.
19*1cd65da9SArmin Le Grand  *
20*1cd65da9SArmin Le Grand  *************************************************************/
21*1cd65da9SArmin Le Grand 
22*1cd65da9SArmin Le Grand 
23*1cd65da9SArmin Le Grand 
24*1cd65da9SArmin Le Grand // MARKER(update_precomp.py): autogen include statement, do not remove
25*1cd65da9SArmin Le Grand #include "precompiled_svx.hxx"
26*1cd65da9SArmin Le Grand 
27*1cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlayrectangle.hxx>
28*1cd65da9SArmin Le Grand #include <vcl/outdev.hxx>
29*1cd65da9SArmin Le Grand #include <basegfx/matrix/b2dhommatrix.hxx>
30*1cd65da9SArmin Le Grand #include <basegfx/polygon/b2dpolygontools.hxx>
31*1cd65da9SArmin Le Grand #include <basegfx/polygon/b2dpolygon.hxx>
32*1cd65da9SArmin Le Grand #include <basegfx/numeric/ftools.hxx>
33*1cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlaytools.hxx>
34*1cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlaymanager.hxx>
35*1cd65da9SArmin Le Grand #include <vcl/svapp.hxx>
36*1cd65da9SArmin Le Grand 
37*1cd65da9SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
38*1cd65da9SArmin Le Grand 
39*1cd65da9SArmin Le Grand namespace sdr
40*1cd65da9SArmin Le Grand {
41*1cd65da9SArmin Le Grand 	namespace overlay
42*1cd65da9SArmin Le Grand 	{
createOverlayObjectPrimitive2DSequence()43*1cd65da9SArmin Le Grand 		drawinglayer::primitive2d::Primitive2DSequence OverlayRectangle::createOverlayObjectPrimitive2DSequence()
44*1cd65da9SArmin Le Grand 		{
45*1cd65da9SArmin Le Grand             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 
60*1cd65da9SArmin Le Grand             const drawinglayer::primitive2d::Primitive2DReference aReference(
61*1cd65da9SArmin Le Grand                 new drawinglayer::primitive2d::OverlayRectanglePrimitive(
62*1cd65da9SArmin Le Grand                     aHatchRange,
63*1cd65da9SArmin Le Grand                     aColor,
64*1cd65da9SArmin Le Grand                     getTransparence(),
65*1cd65da9SArmin Le Grand                     getDiscreteGrow(),
66*1cd65da9SArmin Le Grand                     getDiscreteShrink(),
67*1cd65da9SArmin Le Grand                     getRotation()));
68*1cd65da9SArmin Le Grand 
69*1cd65da9SArmin Le Grand             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
70*1cd65da9SArmin Le Grand 		}
71*1cd65da9SArmin Le Grand 
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(
73*1cd65da9SArmin Le Grand             const basegfx::B2DPoint& rBasePosition,
74*1cd65da9SArmin Le Grand             const basegfx::B2DPoint& rSecondPosition,
75*1cd65da9SArmin Le Grand             const Color& rHatchColor,
76*1cd65da9SArmin Le Grand             double fTransparence,
77*1cd65da9SArmin Le Grand             double fDiscreteGrow,
78*1cd65da9SArmin Le Grand             double fDiscreteShrink,
79*1cd65da9SArmin Le Grand             double fRotation,
80*1cd65da9SArmin Le Grand             sal_uInt32 nBlinkTime,
81*1cd65da9SArmin Le Grand             bool bAnimate)
82*1cd65da9SArmin Le Grand 		:	OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
83*1cd65da9SArmin Le Grand             maSecondPosition(rSecondPosition),
84*1cd65da9SArmin Le Grand             mfTransparence(fTransparence),
85*1cd65da9SArmin Le Grand             mfDiscreteGrow(fDiscreteGrow),
86*1cd65da9SArmin Le Grand             mfDiscreteShrink(fDiscreteShrink),
87*1cd65da9SArmin Le Grand             mfRotation(fRotation),
88*1cd65da9SArmin Le Grand             mnBlinkTime(nBlinkTime),
89*1cd65da9SArmin Le Grand             mbOverlayState(false)
90*1cd65da9SArmin Le Grand 		{
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);
102*1cd65da9SArmin Le Grand 		}
103*1cd65da9SArmin Le Grand 
setSecondPosition(const basegfx::B2DPoint & rNew)104*1cd65da9SArmin Le Grand 		void OverlayRectangle::setSecondPosition(const basegfx::B2DPoint& rNew)
105*1cd65da9SArmin Le Grand 		{
106*1cd65da9SArmin Le Grand 			if(rNew != maSecondPosition)
107*1cd65da9SArmin Le Grand 			{
108*1cd65da9SArmin Le Grand 				// remember new value
109*1cd65da9SArmin Le Grand 				maSecondPosition = rNew;
110*1cd65da9SArmin Le Grand 
111*1cd65da9SArmin Le Grand 				// register change (after change)
112*1cd65da9SArmin Le Grand 				objectChange();
113*1cd65da9SArmin Le Grand 			}
114*1cd65da9SArmin Le Grand 		}
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 		}
155*1cd65da9SArmin Le Grand 	} // end of namespace overlay
156*1cd65da9SArmin Le Grand } // end of namespace sdr
157*1cd65da9SArmin Le Grand 
158*1cd65da9SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
159*1cd65da9SArmin Le Grand // eof
160