fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / cctrl / cbuttonw.cxx
blobd8a95bd56f5932d94be5055aaac0f58cbbfa36b9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/outdev.hxx>
21 #include <vcl/window.hxx>
22 #include <vcl/decoview.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include "cbutton.hxx"
27 // class ScDDComboBoxButton
29 ScDDComboBoxButton::ScDDComboBoxButton( OutputDevice* pOutputDevice )
30 : pOut( pOutputDevice )
32 SetOptSizePixel();
35 ScDDComboBoxButton::~ScDDComboBoxButton()
39 void ScDDComboBoxButton::SetOutputDevice( OutputDevice* pOutputDevice )
41 pOut = pOutputDevice;
44 void ScDDComboBoxButton::SetOptSizePixel()
46 aBtnSize = pOut->LogicToPixel( Size(0,11), MAP_APPFONT );
47 //aBtnSize.Width() = GetSystemMetrics( SM_CXVSCROLL ) - 1; // Win SDK-Funktion
48 aBtnSize.Width() = pOut->GetSettings().GetStyleSettings().GetScrollBarSize();
51 void ScDDComboBoxButton::Draw( const Point& rAt,
52 const Size& rSize,
53 bool bState,
54 bool bBtnIn /* = false */ )
56 if ( rSize.Width() == 0 || rSize.Height() == 0 )
57 return; // #i43092# rectangle with size 0 would have RECT_EMPTY as end position
59 // save old state
60 bool bHadFill = pOut->IsFillColor();
61 Color aOldFill = pOut->GetFillColor();
62 bool bHadLine = pOut->IsLineColor();
63 Color aOldLine = pOut->GetLineColor();
64 bool bOldEnable = pOut->IsMapModeEnabled();
66 Rectangle aBtnRect( rAt, rSize );
67 Rectangle aInnerRect = aBtnRect;
69 pOut->EnableMapMode( false );
71 DecorationView aDecoView( pOut);
73 DrawButtonFlags nButtonStyle = DrawButtonFlags::Default;
74 if( bBtnIn ) // gedrueckt?
76 nButtonStyle = DrawButtonFlags::Pressed;
79 aInnerRect=aDecoView.DrawButton( aBtnRect, nButtonStyle );
81 aInnerRect.Left() += 1;
82 aInnerRect.Top() += 1;
83 aInnerRect.Right() -= 1;
84 aInnerRect.Bottom() -= 1;
86 Size aInnerSize = aInnerRect.GetSize();
87 Point aInnerCenter = aInnerRect.Center();
89 aInnerRect.Top() = aInnerCenter.Y() - (aInnerSize.Width()>>1);
90 aInnerRect.Bottom()= aInnerCenter.Y() + (aInnerSize.Width()>>1);
92 ImpDrawArrow( aInnerRect, bState );
94 // restore old state
95 pOut->EnableMapMode( bOldEnable );
96 if (bHadLine)
97 pOut->SetLineColor(aOldLine);
98 else
99 pOut->SetLineColor();
100 if (bHadFill)
101 pOut->SetFillColor(aOldFill);
102 else
103 pOut->SetFillColor();
106 void ScDDComboBoxButton::ImpDrawArrow( const Rectangle& rRect,
107 bool bState )
109 // no need to save old line and fill color here (is restored after the call)
111 Rectangle aPixRect = rRect;
112 Point aCenter = aPixRect.Center();
113 Size aSize = aPixRect.GetSize();
115 Size aSize3;
116 aSize3.Width() = aSize.Width() >> 1;
117 aSize3.Height() = aSize.Height() >> 1;
119 Size aSize4;
120 aSize4.Width() = aSize.Width() >> 2;
121 aSize4.Height() = aSize.Height() >> 2;
123 Rectangle aTempRect = aPixRect;
125 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
126 Color aColor( bState ? COL_LIGHTBLUE : rSett.GetButtonTextColor().GetColor() );
127 pOut->SetFillColor( aColor );
128 pOut->SetLineColor( aColor );
130 aTempRect.Left() = aCenter.X() - aSize4.Width();
131 aTempRect.Right() = aCenter.X() + aSize4.Width();
132 aTempRect.Top() = aCenter.Y() - aSize3.Height();
133 aTempRect.Bottom() = aCenter.Y() - 1;
135 pOut->DrawRect( aTempRect );
137 Point aPos1( aCenter.X()-aSize3.Width(), aCenter.Y() );
138 Point aPos2( aCenter.X()+aSize3.Width(), aCenter.Y() );
139 while( aPos1.X() <= aPos2.X() )
141 pOut->DrawLine( aPos1, aPos2 );
142 aPos1.X()++; aPos2.X()--;
143 aPos1.Y()++; aPos2.Y()++;
146 pOut->DrawLine( Point( aCenter.X() - aSize3.Width(), aPos1.Y()+1 ),
147 Point( aCenter.X() + aSize3.Width(), aPos1.Y()+1 ) );
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */