1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
),
35 CellLineStyleValueSet::~CellLineStyleValueSet()
40 void CellLineStyleValueSet::dispose()
42 pVDev
.disposeAndClear();
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
)
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
;
96 aBackRect
.Bottom() -= 2;
97 pDev
->SetFillColor(aBackColor
);
98 pDev
->DrawRect(aBackRect
);
102 pDev
->SetFillColor( COL_TRANSPARENT
);
103 pDev
->DrawRect(aRect
);
107 if(nSelItem
== nItemId
)
108 aFont
.SetColor(COL_WHITE
);
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
117 if( nSelItem
== nItemId
)
119 pDev
->SetFillColor(COL_WHITE
);
120 pDev
->SetLineColor(COL_WHITE
);
124 pDev
->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
125 pDev
->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
134 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ nItemId
* 2 - 1 ));
137 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
138 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 4 ));
141 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
142 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
145 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
146 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 6 ));
149 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
150 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
153 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
154 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 8 ));
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: */