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 .
18 #include "LineWidthValueSet.hxx"
20 #include <i18nlangtag/mslangid.hxx>
22 namespace svx
{ namespace sidebar
{
25 LineWidthValueSet::LineWidthValueSet (
26 Window
* pParent
, const ResId
& rResId
)
27 : ValueSet( pParent
, rResId
),
32 strUnit
= new XubString
[9];
40 LineWidthValueSet::~LineWidthValueSet (void)
49 void LineWidthValueSet::SetUnit(XubString
* str
)
51 for(int i
= 0; i
< 9; i
++)
59 void LineWidthValueSet::SetSelItem(sal_uInt16 nSel
)
64 SelectItem(1); // ,false); // 'false' nut supported by AOO
77 sal_uInt16
LineWidthValueSet::GetSelItem()
85 void LineWidthValueSet::SetImage(Image img
)
93 void LineWidthValueSet::SetCusEnable(bool bEnable
)
101 void LineWidthValueSet::UserDraw( const UserDrawEvent
& rUDEvt
)
103 Rectangle aRect
= rUDEvt
.GetRect();
104 OutputDevice
* pDev
= rUDEvt
.GetDevice();
105 sal_uInt16 nItemId
= rUDEvt
.GetItemId();
107 long nRectHeight
= aRect
.GetHeight();
108 long nRectWidth
= aRect
.GetWidth();
109 Point aBLPos
= aRect
.TopLeft();
111 //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
112 //Color aBackColor(0,0,200);
113 //const Color aTextColor = rStyleSettings.GetFieldTextColor();
114 Font aOldFont
= pDev
->GetFont();
115 Color aOldColor
= pDev
->GetLineColor();
116 Color aOldFillColor
= pDev
->GetFillColor();
118 Font
aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS
, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE
));
119 Size aSize
= aFont
.GetSize();
120 aSize
.Height() = nRectHeight
*3/5;
121 aFont
.SetSize( aSize
);
123 Point
aLineStart(aBLPos
.X() + 5, aBLPos
.Y() + ( nRectHeight
- nItemId
)/2);
124 Point
aLineEnd(aBLPos
.X() + nRectWidth
* 7 / 9 - 10, aBLPos
.Y() + ( nRectHeight
- nItemId
)/2);
127 Point
aImgStart(aBLPos
.X() + 5, aBLPos
.Y() + ( nRectHeight
- 23 ) / 2);
128 pDev
->DrawImage(aImgStart
, imgCus
);
129 // Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6);
130 Rectangle aStrRect
= aRect
;
131 aStrRect
.Top() += nRectHeight
/6;
132 aStrRect
.Bottom() -= nRectHeight
/6;
133 aStrRect
.Left() += imgCus
.GetSizePixel().Width() + 20;
135 aFont
.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
137 aFont
.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
139 pDev
->SetFont(aFont
);
140 pDev
->DrawText(aStrRect
, strUnit
[ nItemId
- 1 ], TEXT_DRAW_ENDELLIPSIS
);
144 if( nSelItem
== nItemId
)
146 Color
aBackColor(50,107,197);
147 Rectangle aBackRect
= aRect
;
148 aBackRect
.Top() += 3;
149 aBackRect
.Bottom() -= 2;
150 pDev
->SetFillColor(aBackColor
);
151 pDev
->DrawRect(aBackRect
);
155 pDev
->SetFillColor( COL_TRANSPARENT
);
156 pDev
->DrawRect(aRect
);
160 if(nSelItem
== nItemId
)
161 aFont
.SetColor(COL_WHITE
);
163 aFont
.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
164 pDev
->SetFont(aFont
);
165 Point
aStart(aBLPos
.X() + nRectWidth
* 7 / 9 , aBLPos
.Y() + nRectHeight
/6);
166 pDev
->DrawText(aStart
, strUnit
[ nItemId
- 1 ]); //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear
169 if( nSelItem
== nItemId
)
170 pDev
->SetLineColor(COL_WHITE
);
172 pDev
->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor());
174 for(sal_uInt16 i
= 1; i
<= nItemId
; i
++)
176 pDev
->DrawLine(aLineStart
,aLineEnd
);
177 aLineStart
.setY(aLineStart
.getY() + 1);
178 aLineEnd
.setY (aLineEnd
.getY() + 1);
183 pDev
->SetLineColor(aOldColor
);
184 pDev
->SetFillColor(aOldFillColor
);
185 pDev
->SetFont(aOldFont
);
190 } } // end of namespace svx::sidebar