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>
23 namespace sc
{ namespace sidebar
{
25 CellLineStyleValueSet::CellLineStyleValueSet( Window
* pParent
, const ResId
& rResId
)
26 : ValueSet( pParent
, rResId
),
34 CellLineStyleValueSet::~CellLineStyleValueSet()
39 void CellLineStyleValueSet::SetUnit(const OUString
* str
)
41 for (int i
= 0; i
< CELL_LINE_STYLE_ENTRIES
; ++i
)
43 maStrUnit
[i
] = str
[i
];
47 void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel
)
62 void CellLineStyleValueSet::SetImage(Image img
)
67 void CellLineStyleValueSet::UserDraw( const UserDrawEvent
& rUDEvt
)
69 Rectangle aRect
= rUDEvt
.GetRect();
70 OutputDevice
* pDev
= rUDEvt
.GetDevice();
71 sal_uInt16 nItemId
= rUDEvt
.GetItemId();
73 long nRectHeight
= aRect
.GetHeight();
74 long nRectWidth
= aRect
.GetWidth();
75 Point aBLPos
= aRect
.TopLeft();
77 Font aOldFont
= pDev
->GetFont();
78 Color aOldColor
= pDev
->GetLineColor();
79 Color aOldFillColor
= pDev
->GetFillColor();
81 Font
aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS
, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE
));
82 Size aSize
= aFont
.GetSize();
83 aSize
.Height() = nRectHeight
*3/5;
84 aFont
.SetSize( aSize
);
86 long nTLX
= aBLPos
.X() + 5, nTLY
= aBLPos
.Y() + ( nRectHeight
- nItemId
)/2;
87 long nTRX
= aBLPos
.X() + nRectWidth
* 7 / 9 - 15, nTRY
= aBLPos
.Y() + ( nRectHeight
- nItemId
)/2;
89 if( nSelItem
== nItemId
)
91 Color
aBackColor(50,107,197);
92 Rectangle aBackRect
= aRect
;
94 aBackRect
.Bottom() -= 2;
95 pDev
->SetFillColor(aBackColor
);
96 pDev
->DrawRect(aBackRect
);
100 pDev
->SetFillColor( COL_TRANSPARENT
);
101 pDev
->DrawRect(aRect
);
105 if(nSelItem
== nItemId
)
106 aFont
.SetColor(COL_WHITE
);
108 aFont
.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
110 pDev
->SetFont(aFont
);
111 Point
aStart(aBLPos
.X() + nRectWidth
* 7 / 9 - 5 , aBLPos
.Y() + nRectHeight
/6);
112 pDev
->DrawText(aStart
, maStrUnit
[nItemId
- 1]); //can't set TEXT_DRAW_ENDELLIPSIS here, or the text will disapear
115 if( nSelItem
== nItemId
)
117 pDev
->SetFillColor(COL_WHITE
);
118 pDev
->SetLineColor(COL_WHITE
);
122 pDev
->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
123 pDev
->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
132 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ nItemId
* 2 - 1 ));
135 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
136 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 4 ));
139 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
140 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
143 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 1 ));
144 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 3 , nTRX
, nTRY
+ 6 ));
147 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
148 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 6 ));
151 pDev
->DrawRect(Rectangle(nTLX
, nTLY
, nTRX
, nTRY
+ 3 ));
152 pDev
->DrawRect(Rectangle(nTLX
, nTLY
+ 5 , nTRX
, nTRY
+ 8 ));
157 pDev
->SetLineColor(aOldColor
);
158 pDev
->SetFillColor(aOldFillColor
);
159 pDev
->SetFont(aOldFont
);
163 } } // end of namespace svx::sidebar
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */