bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / sidebar / line / LineWidthValueSet.cxx
blobffecfb29b9266bd49b5c6bd9b013eaba3e48c0e0
1 /*
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 ),
28 pVDev(NULL),
29 nSelItem(0),
30 bCusEnable(false)
32 strUnit = new XubString[9];
33 SetColCount( 1 );
34 SetLineCount( 9);
40 LineWidthValueSet::~LineWidthValueSet (void)
42 delete pVDev;
43 delete[] strUnit;
49 void LineWidthValueSet::SetUnit(XubString* str)
51 for(int i = 0; i < 9; i++)
53 strUnit[i] = str[i];
59 void LineWidthValueSet::SetSelItem(sal_uInt16 nSel)
61 nSelItem = nSel;
62 if(nSel == 0)
64 SelectItem(1); // ,false); // 'false' nut supported by AOO
65 SetNoSelection();
67 else
69 SelectItem(nSelItem);
70 GrabFocus();
77 sal_uInt16 LineWidthValueSet::GetSelItem()
79 return nSelItem;
85 void LineWidthValueSet::SetImage(Image img)
87 imgCus = img;
93 void LineWidthValueSet::SetCusEnable(bool bEnable)
95 bCusEnable = 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);
125 if(nItemId == 9)
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;
134 if(bCusEnable)
135 aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
136 else
137 aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
139 pDev->SetFont(aFont);
140 pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS);
142 else
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);
153 else
155 pDev->SetFillColor( COL_TRANSPARENT );
156 pDev->DrawRect(aRect);
159 //draw text
160 if(nSelItem == nItemId )
161 aFont.SetColor(COL_WHITE);
162 else
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
168 //draw line
169 if( nSelItem == nItemId )
170 pDev->SetLineColor(COL_WHITE);
171 else
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);
182 Invalidate( aRect );
183 pDev->SetLineColor(aOldColor);
184 pDev->SetFillColor(aOldFillColor);
185 pDev->SetFont(aOldFont);
190 } } // end of namespace svx::sidebar
192 // eof