2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <CellLineStyleValueSet.hxx>
20 #include <i18nlangtag/mslangid.hxx>
22 namespace sc
{ namespace sidebar
{
24 CellLineStyleValueSet::CellLineStyleValueSet( Window
* pParent
, const ResId
& rResId
)
25 : ValueSet( pParent
, rResId
),
30 strUnit
= new XubString
[9];
35 CellLineStyleValueSet::~CellLineStyleValueSet()
41 void CellLineStyleValueSet::SetUnit(XubString
* str
)
43 for(int i
= 0; i
< 9; i
++)
49 void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel
)
64 sal_uInt16
CellLineStyleValueSet::GetSelItem()
69 void CellLineStyleValueSet::SetImage(Image img
)
74 void CellLineStyleValueSet::SetCusEnable(bool bEnable
)
79 void CellLineStyleValueSet::UserDraw( const UserDrawEvent
& rUDEvt
)
81 Rectangle aRect
= rUDEvt
.GetRect();
82 OutputDevice
* pDev
= rUDEvt
.GetDevice();
83 sal_uInt16 nItemId
= rUDEvt
.GetItemId();
85 long nRectHeight
= aRect
.GetHeight();
86 long nRectWidth
= aRect
.GetWidth();
87 Point aBLPos
= aRect
.TopLeft();
89 Font aOldFont
= pDev
->GetFont();
90 Color aOldColor
= pDev
->GetLineColor();
91 Color aOldFillColor
= pDev
->GetFillColor();
93 Font
aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS
, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE
));
94 Size aSize
= aFont
.GetSize();
95 aSize
.Height() = nRectHeight
*3/5;
96 aFont
.SetSize( aSize
);
98 long nTLX
= aBLPos
.X() + 5, nTLY
= aBLPos
.Y() + ( nRectHeight
- nItemId
)/2;
99 long nTRX
= aBLPos
.X() + nRectWidth
* 7 / 9 - 15, nTRY
= aBLPos
.Y() + ( nRectHeight
- nItemId
)/2;
101 if( nSelItem
== nItemId
)
103 Color
aBackColor(50,107,197);
104 Rectangle aBackRect
= aRect
;
105 aBackRect
.Top() += 3;
106 aBackRect
.Bottom() -= 2;
107 pDev
->SetFillColor(aBackColor
);
108 pDev
->DrawRect(aBackRect
);
112 pDev
->SetFillColor( COL_TRANSPARENT
);
113 pDev
->DrawRect(aRect
);
117 if(nSelItem
== nItemId
)
118 aFont
.SetColor(COL_WHITE
);
120 aFont
.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
122 pDev
->SetFont(aFont
);
123 Point
aStart(aBLPos
.X() + nRectWidth
* 7 / 9 - 5 , aBLPos
.Y() + nRectHeight
/6);
124 pDev
->DrawText(aStart
, strUnit
[ nItemId
- 1 ]); //can't set TEXT_DRAW_ENDELLIPSIS here, or the text will disapear
127 if( nSelItem
== nItemId
)
129 pDev
->SetFillColor(COL_WHITE
);
130 pDev
->SetLineColor(COL_WHITE
);
134 pDev
->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
135 pDev
->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
144 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ nItemId
* 2 - 1 ));
147 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
148 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 4 ));
151 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
152 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
155 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
156 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 6 ));
159 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
160 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
163 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
164 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 8 ));
169 pDev
->SetLineColor(aOldColor
);
170 pDev
->SetFillColor(aOldFillColor
);
171 pDev
->SetFont(aOldFont
);
175 } } // end of namespace svx::sidebar