1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include "LineStyleValueSet.hxx"
23
24 #include <i18npool/mslangid.hxx>
25
26
27 namespace svx { namespace sidebar {
28
LineStyleValueSet(Window * pParent,const ResId & rResId)29 LineStyleValueSet::LineStyleValueSet (
30 Window* pParent,
31 const ResId& rResId)
32 : ValueSet( pParent, rResId ),
33 pVDev(NULL),
34 mbSelectFirst(true)
35 {
36 SetColCount( 1 );
37 }
38
39
40
41
~LineStyleValueSet(void)42 LineStyleValueSet::~LineStyleValueSet (void)
43 {
44 delete pVDev;
45 }
46
47
48
49
SetFirstString(XubString str)50 void LineStyleValueSet::SetFirstString(XubString str)
51 {
52 strNone = str;
53 }
54
55
56
57
UserDraw(const UserDrawEvent & rUDEvt)58 void LineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
59 {
60 Rectangle aRect = rUDEvt.GetRect();
61 OutputDevice* pDev = rUDEvt.GetDevice();
62 sal_uInt16 nItemId = rUDEvt.GetItemId();
63
64 long nRectHeight = aRect.GetHeight();
65 // long nRectWidth = aRect.GetWidth();
66 Point aBLPos = aRect.TopLeft();
67 if(nItemId == 1)
68 {
69 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
70 Color aOldFillColor = pDev->GetFillColor();
71 const Color aTextColor = rStyleSettings.GetFieldTextColor();
72
73 //draw back
74 if( mbSelectFirst )
75 {
76 Color aBackColor(50,107,197);
77 Rectangle aBackRect = aRect;
78 aBackRect.Top() += 3;
79 aBackRect.Bottom() -= 2;
80 pDev->SetFillColor(aBackColor);
81 pDev->DrawRect(aBackRect);
82 }
83 else
84 {
85 pDev->SetFillColor( COL_TRANSPARENT );
86 pDev->DrawRect(aRect);
87 }
88 pDev->SetFillColor(aOldFillColor);
89
90 //draw text
91 Font aOldFont = pDev->GetFont();
92 Color aOldColor = pDev->GetLineColor();
93 Font aFont(OutputDevice::GetDefaultFont(
94 DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
95 Size aSize = aFont.GetSize();
96 aSize.Height() = nRectHeight*3/5;
97 if( mbSelectFirst )
98 aFont.SetColor(COL_WHITE);
99 else
100 //aFont.SetColor(COL_BLACK);
101 aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
102 aFont.SetFillColor(COL_BLUE);
103 aFont.SetSize( aSize );
104 pDev->SetFont(aFont);
105 // String sText("None", 9, RTL_TEXTENCODING_ASCII_US);
106
107 // Point aStart(aBLPos.X() + 8 , aBLPos.Y() + nRectHeight/6);
108 Rectangle aStrRect = aRect;
109 aStrRect.Top() += nRectHeight/6;
110 aStrRect.Bottom() -= nRectHeight/6;
111 aStrRect.Left() += 8;
112 pDev->DrawText(aStrRect, strNone, TEXT_DRAW_ENDELLIPSIS);
113
114 pDev->SetFont(aOldFont);
115 pDev->SetLineColor(aOldColor);
116
117
118 }
119 Invalidate( aRect );
120 }
121
122
123
124
SetFirstSelect(bool bSel)125 void LineStyleValueSet::SetFirstSelect(bool bSel)
126 {
127 mbSelectFirst = bSel;
128 }
129
130
131
132 } } // end of namespace svx::sidebar
133
134 // eof
135