LibreOffice Module sc (master) 1
cbuttonw.cxx
Go to the documentation of this file.
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
20#include <comphelper/lok.hxx>
21#include <vcl/outdev.hxx>
22#include <vcl/decoview.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/settings.hxx>
25#include <cbutton.hxx>
26
27
29 : pOut( pOutputDevice )
30{
32}
33
35{
36}
37
39{
40 pOut = pOutputDevice;
41}
42
44{
45 aBtnSize = pOut->LogicToPixel(Size(8, 11), MapMode(MapUnit::MapAppFont));
46 aBtnSize.setWidth( std::max(aBtnSize.Width(), static_cast<tools::Long>(pOut->GetSettings().GetStyleSettings().GetScrollBarSize())) );
47}
48
50 const Size& rSize )
51{
52 if ( rSize.IsEmpty() )
53 return;
54
55 // save old state
56 bool bHadFill = pOut->IsFillColor();
57 Color aOldFill = pOut->GetFillColor();
58 bool bHadLine = pOut->IsLineColor();
59 Color aOldLine = pOut->GetLineColor();
60 bool bOldEnable = pOut->IsMapModeEnabled();
61
62 tools::Rectangle aBtnRect( rAt, rSize );
63
65 pOut->EnableMapMode(false);
66
67 DecorationView aDecoView( pOut);
68
69 tools::Rectangle aInnerRect=aDecoView.DrawButton( aBtnRect, DrawButtonFlags::Default );
70
71 aInnerRect.AdjustLeft(1 );
72 aInnerRect.AdjustTop(1 );
73 aInnerRect.AdjustRight( -1 );
74 aInnerRect.AdjustBottom( -1 );
75
76 Size aInnerSize = aInnerRect.GetSize();
77 Point aInnerCenter = aInnerRect.Center();
78
79 aInnerRect.SetTop( aInnerCenter.Y() - (aInnerSize.Width()>>1) );
80 aInnerRect.SetBottom( aInnerCenter.Y() + (aInnerSize.Width()>>1) );
81
82 ImpDrawArrow( aInnerRect );
83
84 // restore old state
85 pOut->EnableMapMode( bOldEnable );
86 if (bHadLine)
87 pOut->SetLineColor(aOldLine);
88 else
89 pOut->SetLineColor();
90 if (bHadFill)
91 pOut->SetFillColor(aOldFill);
92 else
93 pOut->SetFillColor();
94}
95
97{
98 // no need to save old line and fill color here (is restored after the call)
99
100 tools::Rectangle aPixRect = rRect;
101 Point aCenter = aPixRect.Center();
102 Size aSize = aPixRect.GetSize();
103
104 Size aSize3;
105 aSize3.setWidth( aSize.Width() >> 1 );
106 aSize3.setHeight( aSize.Height() >> 1 );
107
108 Size aSize4;
109 aSize4.setWidth( aSize.Width() >> 2 );
110 aSize4.setHeight( aSize.Height() >> 2 );
111
112 tools::Rectangle aTempRect = aPixRect;
113
115 Color aColor( rSett.GetButtonTextColor() );
116 pOut->SetFillColor( aColor );
117 pOut->SetLineColor( aColor );
118
119 aTempRect.SetLeft( aCenter.X() - aSize4.Width() );
120 aTempRect.SetRight( aCenter.X() + aSize4.Width() );
121 aTempRect.SetTop( aCenter.Y() - aSize3.Height() );
122 aTempRect.SetBottom( aCenter.Y() - 1 );
123
124 pOut->DrawRect( aTempRect );
125
126 Point aPos1( aCenter.X()-aSize3.Width(), aCenter.Y() );
127 Point aPos2( aCenter.X()+aSize3.Width(), aCenter.Y() );
128 while( aPos1.X() <= aPos2.X() )
129 {
130 pOut->DrawLine( aPos1, aPos2 );
131 aPos1.AdjustX( 1 ); aPos2.AdjustX( -1 );
132 aPos1.AdjustY( 1 ); aPos2.AdjustY( 1 );
133 }
134
135 pOut->DrawLine( Point( aCenter.X() - aSize3.Width(), aPos1.Y()+1 ),
136 Point( aCenter.X() + aSize3.Width(), aPos1.Y()+1 ) );
137}
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
tools::Rectangle DrawButton(const tools::Rectangle &rRect, DrawButtonFlags nStyle)
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void ImpDrawArrow(const tools::Rectangle &rRect)
Definition: cbuttonw.cxx:96
ScDDComboBoxButton(OutputDevice *pOutputDevice)
Definition: cbuttonw.cxx:28
void SetOutputDevice(OutputDevice *pOutputDevice)
Definition: cbuttonw.cxx:38
void SetOptSizePixel()
Definition: cbuttonw.cxx:43
VclPtr< OutputDevice > pOut
Definition: cbutton.hxx:51
bool IsEmpty() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetButtonTextColor() const
constexpr Point Center() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
long Long
oslFileHandle & pOut