1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "precompiled_rptui.hxx"
24 #include "EndMarker.hxx"
25 #include "ColorChanger.hxx"
26 #include "SectionWindow.hxx"
27 #include "helpids.hrc"
28 #include <vcl/svapp.hxx>
29 #include <vcl/gradient.hxx>
30 #include <vcl/lineinfo.hxx>
31 
32 
33 #define CORNER_SPACE	5
34 //=====================================================================
35 namespace rptui
36 {
37 //=====================================================================
DBG_NAME(rpt_OEndMarker)38 	DBG_NAME( rpt_OEndMarker )
39 OEndMarker::OEndMarker(Window* _pParent	,const ::rtl::OUString& _sColorEntry)
40 : OColorListener(_pParent,_sColorEntry)
41 {
42 	DBG_CTOR( rpt_OEndMarker,NULL);
43 	SetUniqueId(HID_RPT_ENDMARKER);
44 	ImplInitSettings();
45 }
46 // -----------------------------------------------------------------------------
~OEndMarker()47 OEndMarker::~OEndMarker()
48 {
49 	DBG_DTOR( rpt_OEndMarker,NULL);
50 }
51 // -----------------------------------------------------------------------------
Paint(const Rectangle &)52 void OEndMarker::Paint( const Rectangle& /*rRect*/ )
53 {
54     Fraction aCornerSpace(long(CORNER_SPACE));
55     aCornerSpace *= GetMapMode().GetScaleX();
56     const long nCornerSpace = aCornerSpace;
57 
58 	Size aSize = GetSizePixel();
59     aSize.Width() += nCornerSpace;
60 	Rectangle aWholeRect(Point(-nCornerSpace,0),aSize);
61     PolyPolygon aPoly;
62     aPoly.Insert(Polygon(aWholeRect,nCornerSpace,nCornerSpace));
63 
64     Color aStartColor(m_nColor);
65     aStartColor.IncreaseLuminance(10);
66     sal_uInt16 nHue = 0;
67     sal_uInt16 nSat = 0;
68     sal_uInt16 nBri = 0;
69     aStartColor.RGBtoHSB(nHue, nSat, nBri);
70     nSat += 40;
71     Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri));
72     Gradient aGradient(GRADIENT_LINEAR,aStartColor,aEndColor);
73     aGradient.SetSteps(static_cast<sal_uInt16>(aSize.Height()));
74 
75     DrawGradient(PixelToLogic(aPoly) ,aGradient);
76 	if ( m_bMarked )
77 	{
78         Rectangle aRect( Point(-nCornerSpace,nCornerSpace),
79 		                 Size(aSize.Width()- nCornerSpace,aSize.Height() - nCornerSpace- nCornerSpace));
80         ColorChanger aColors( this, COL_WHITE, COL_WHITE );
81         DrawPolyLine(Polygon(PixelToLogic(aRect)),LineInfo(LINE_SOLID,2));
82 	}
83 }
84 // -----------------------------------------------------------------------
ImplInitSettings()85 void OEndMarker::ImplInitSettings()
86 {
87     EnableChildTransparentMode( sal_True );
88     SetParentClipMode( PARENTCLIPMODE_NOCLIP );
89     SetPaintTransparent( sal_True );
90 
91     SetBackground( Wallpaper( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor)  );
92 	SetFillColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
93 }
94 // -----------------------------------------------------------------------
MouseButtonDown(const MouseEvent & rMEvt)95 void OEndMarker::MouseButtonDown( const MouseEvent& rMEvt )
96 {
97 	if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
98 		return;
99     static_cast<OSectionWindow*>(GetParent())->showProperties();
100 }
101 // =======================================================================
102 }
103 // =======================================================================
104