fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / sidebar / CellLineStyleValueSet.cxx
blob7f3c6444d1a418fa2263ac3d006058d564e22ece
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 "CellLineStyleValueSet.hxx"
21 #include <i18nlangtag/mslangid.hxx>
22 #include <vcl/settings.hxx>
24 namespace sc { namespace sidebar {
26 CellLineStyleValueSet::CellLineStyleValueSet( vcl::Window* pParent, const ResId& rResId)
27 : ValueSet( pParent, rResId ),
28 pVDev(NULL),
29 nSelItem(0)
31 SetColCount( 1 );
32 SetLineCount( 9);
35 CellLineStyleValueSet::~CellLineStyleValueSet()
37 disposeOnce();
40 void CellLineStyleValueSet::dispose()
42 pVDev.disposeAndClear();
43 ValueSet::dispose();
46 void CellLineStyleValueSet::SetUnit(const OUString* str)
48 for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i)
50 maStrUnit[i] = str[i];
54 void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel)
56 nSelItem = nSel;
57 if(nSel == 0)
59 SelectItem(1);
60 SetNoSelection();
62 else
64 SelectItem(nSelItem);
65 GrabFocus();
69 void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
71 Rectangle aRect = rUDEvt.GetRect();
72 vcl::RenderContext* pDev = rUDEvt.GetRenderContext();
73 sal_uInt16 nItemId = rUDEvt.GetItemId();
75 long nRectHeight = aRect.GetHeight();
76 long nRectWidth = aRect.GetWidth();
77 Point aBLPos = aRect.TopLeft();
79 vcl::Font aOldFont = pDev->GetFont();
80 Color aOldColor = pDev->GetLineColor();
81 Color aOldFillColor = pDev->GetFillColor();
83 vcl::Font aFont(OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne));
84 Size aSize = aFont.GetSize();
85 aSize.Height() = nRectHeight*3/5;
86 aFont.SetSize( aSize );
88 long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
89 long nTRX = aBLPos.X() + nRectWidth * 7 / 9 - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
91 if( nSelItem == nItemId )
93 Color aBackColor(50,107,197);
94 Rectangle aBackRect = aRect;
95 aBackRect.Top() += 3;
96 aBackRect.Bottom() -= 2;
97 pDev->SetFillColor(aBackColor);
98 pDev->DrawRect(aBackRect);
100 else
102 pDev->SetFillColor( COL_TRANSPARENT );
103 pDev->DrawRect(aRect);
106 //draw text
107 if(nSelItem == nItemId )
108 aFont.SetColor(COL_WHITE);
109 else
110 aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
112 pDev->SetFont(aFont);
113 Point aStart(aBLPos.X() + nRectWidth * 7 / 9 - 5 , aBLPos.Y() + nRectHeight/6);
114 pDev->DrawText(aStart, maStrUnit[nItemId - 1]); //can't set DrawTextFlags::EndEllipsis here, or the text will disappear
116 //draw line
117 if( nSelItem == nItemId )
119 pDev->SetFillColor(COL_WHITE);
120 pDev->SetLineColor(COL_WHITE);
122 else
124 pDev->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
125 pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
128 switch( nItemId )
130 case 1:
131 case 2:
132 case 3:
133 case 4:
134 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId * 2 - 1 ));
135 break;
136 case 5:
137 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
138 pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 ));
139 break;
140 case 6:
141 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
142 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
143 break;
144 case 7:
145 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
146 pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 ));
147 break;
148 case 8:
149 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
150 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
151 break;
152 case 9:
153 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
154 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 8 ));
155 break;
158 Invalidate( aRect );
159 pDev->SetLineColor(aOldColor);
160 pDev->SetFillColor(aOldFillColor);
161 pDev->SetFont(aOldFont);
165 } } // end of namespace svx::sidebar
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */