Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "EndMarker.hxx"
20 : #include "ColorChanger.hxx"
21 : #include "SectionWindow.hxx"
22 : #include "helpids.hrc"
23 :
24 : #include <vcl/settings.hxx>
25 : #include <vcl/svapp.hxx>
26 : #include <vcl/gradient.hxx>
27 : #include <vcl/lineinfo.hxx>
28 :
29 :
30 : #define CORNER_SPACE 5
31 :
32 : namespace rptui
33 : {
34 :
35 0 : OEndMarker::OEndMarker(Window* _pParent ,const OUString& _sColorEntry)
36 0 : : OColorListener(_pParent,_sColorEntry)
37 : {
38 0 : SetUniqueId(HID_RPT_ENDMARKER);
39 0 : ImplInitSettings();
40 0 : }
41 :
42 0 : OEndMarker::~OEndMarker()
43 : {
44 0 : }
45 :
46 0 : void OEndMarker::Paint( const Rectangle& /*rRect*/ )
47 : {
48 0 : Fraction aCornerSpace(long(CORNER_SPACE));
49 0 : aCornerSpace *= GetMapMode().GetScaleX();
50 0 : const long nCornerSpace = aCornerSpace;
51 :
52 0 : Size aSize = GetSizePixel();
53 0 : aSize.Width() += nCornerSpace;
54 0 : Rectangle aWholeRect(Point(-nCornerSpace,0),aSize);
55 0 : PolyPolygon aPoly;
56 0 : aPoly.Insert(Polygon(aWholeRect,nCornerSpace,nCornerSpace));
57 :
58 0 : Color aStartColor(m_nColor);
59 0 : aStartColor.IncreaseLuminance(10);
60 0 : sal_uInt16 nHue = 0;
61 0 : sal_uInt16 nSat = 0;
62 0 : sal_uInt16 nBri = 0;
63 0 : aStartColor.RGBtoHSB(nHue, nSat, nBri);
64 0 : nSat += 40;
65 0 : Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri));
66 0 : Gradient aGradient(GradientStyle_LINEAR,aStartColor,aEndColor);
67 0 : aGradient.SetSteps(static_cast<sal_uInt16>(aSize.Height()));
68 :
69 0 : DrawGradient(PixelToLogic(aPoly) ,aGradient);
70 0 : if ( m_bMarked )
71 : {
72 : Rectangle aRect( Point(-nCornerSpace,nCornerSpace),
73 0 : Size(aSize.Width()- nCornerSpace,aSize.Height() - nCornerSpace- nCornerSpace));
74 0 : ColorChanger aColors( this, COL_WHITE, COL_WHITE );
75 0 : DrawPolyLine(Polygon(PixelToLogic(aRect)),LineInfo(LINE_SOLID,2));
76 0 : }
77 0 : }
78 :
79 0 : void OEndMarker::ImplInitSettings()
80 : {
81 0 : EnableChildTransparentMode( true );
82 0 : SetParentClipMode( PARENTCLIPMODE_NOCLIP );
83 0 : SetPaintTransparent( true );
84 :
85 0 : SetBackground( Wallpaper( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor) );
86 0 : SetFillColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
87 0 : }
88 :
89 0 : void OEndMarker::MouseButtonDown( const MouseEvent& rMEvt )
90 : {
91 0 : if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
92 0 : return;
93 0 : static_cast<OSectionWindow*>(GetParent())->showProperties();
94 : }
95 :
96 : }
97 :
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|