bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / sidebar / CellLineStyleValueSet.cxx
blobfc8e5e58bbae99b7a08483e50e481f8bd586c5e5
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 .
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 ),
26 pVDev(NULL),
27 nSelItem(0),
28 bCusEnable(false)
30 strUnit = new XubString[9];
31 SetColCount( 1 );
32 SetLineCount( 9);
35 CellLineStyleValueSet::~CellLineStyleValueSet()
37 delete pVDev;
38 delete[] strUnit;
41 void CellLineStyleValueSet::SetUnit(XubString* str)
43 for(int i = 0; i < 9; i++)
45 strUnit[i] = str[i];
49 void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel)
51 nSelItem = nSel;
52 if(nSel == 0)
54 SelectItem(1);
55 SetNoSelection();
57 else
59 SelectItem(nSelItem);
60 GrabFocus();
64 sal_uInt16 CellLineStyleValueSet::GetSelItem()
66 return nSelItem;
69 void CellLineStyleValueSet::SetImage(Image img)
71 imgCus = img;
74 void CellLineStyleValueSet::SetCusEnable(bool bEnable)
76 bCusEnable = 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);
110 else
112 pDev->SetFillColor( COL_TRANSPARENT );
113 pDev->DrawRect(aRect);
116 //draw text
117 if(nSelItem == nItemId )
118 aFont.SetColor(COL_WHITE);
119 else
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
126 //draw line
127 if( nSelItem == nItemId )
129 pDev->SetFillColor(COL_WHITE);
130 pDev->SetLineColor(COL_WHITE);
132 else
134 pDev->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
135 pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
138 switch( nItemId )
140 case 1:
141 case 2:
142 case 3:
143 case 4:
144 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId * 2 - 1 ));
145 break;
146 case 5:
147 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
148 pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 ));
149 break;
150 case 6:
151 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
152 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
153 break;
154 case 7:
155 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
156 pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 ));
157 break;
158 case 8:
159 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
160 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
161 break;
162 case 9:
163 pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
164 pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 8 ));
165 break;
168 Invalidate( aRect );
169 pDev->SetLineColor(aOldColor);
170 pDev->SetFillColor(aOldFillColor);
171 pDev->SetFont(aOldFont);
175 } } // end of namespace svx::sidebar
177 // eof