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 "precompiled_svx.hxx"
20 #include "ColorPanel.hxx"
22 #include <vcl/image.hxx>
23 #include <vcl/svapp.hxx>
25 namespace svx
{ namespace sidebar
{
27 ColorPanel::ColorPanel (::Window
* pParent
)
29 mnPreferredColumnCount(2)
39 SetStyle(GetStyle() | aStyle
);
49 ColorPanel::~ColorPanel (void)
56 sal_Int32
ColorPanel::GetPreferredHeight (sal_Int32 nWidth
)
58 sal_Int32 nPreferredHeight
= 0;
61 Image aImage
= GetItemImage(GetItemId(0));
62 Size aItemSize
= CalcItemSizePixel (aImage
.GetSizePixel());
63 if (nWidth
>0 && aItemSize
.Width()>0)
65 int nColumnCount
= nWidth
/ aItemSize
.Width();
66 if (nColumnCount
<= 0)
68 else if (nColumnCount
> 4)
70 int nRowCount
= (GetItemCount() + nColumnCount
-1)
72 nPreferredHeight
= nRowCount
* aItemSize
.Height();
75 return nPreferredHeight
;
81 void ColorPanel::Resize (void)
84 Size aWindowSize
= GetOutputSizePixel();
85 SetPosSizePixel(Point(0,0), aWindowSize
);
86 if (IsVisible() && aWindowSize
.Width() > 0)
88 // Calculate the number of rows and columns.
89 if (GetItemCount() > 0)
91 Image aImage
= GetItemImage(GetItemId(0));
92 Size aItemSize
= CalcItemSizePixel (
93 aImage
.GetSizePixel());
94 int nColumnCount
= aWindowSize
.Width() / 30;
97 else if (nColumnCount
> 4)
100 sal_uInt16 nRowCount
= (sal_uInt16
)CalculateRowCount(aItemSize
, nColumnCount
);
102 SetColCount((sal_uInt16
)nColumnCount
);
103 SetLineCount(nRowCount
);
112 int ColorPanel::CalculateRowCount (const Size
&, int nColumnCount
)
116 if (GetItemCount()>0 && nColumnCount
>0)
118 nRowCount
= GetOutputSizePixel().Height() / 30;
129 void ColorPanel::DataChanged (const DataChangedEvent
& rEvent
)
137 void ColorPanel::Fill (void)
139 const StyleSettings
& rSettings (
140 Application::GetSettings().GetStyleSettings());
145 InsertItem (++i
, rSettings
.GetFaceColor());
146 SetItemText (i
, String::CreateFromAscii("FaceColor"));
147 InsertItem (++i
, rSettings
.GetCheckedColor());
148 SetItemText (i
, String::CreateFromAscii("CheckedColor"));
149 InsertItem (++i
, rSettings
.GetLightColor());
150 SetItemText (i
, String::CreateFromAscii("LightColor"));
151 InsertItem (++i
, rSettings
.GetLightBorderColor());
152 SetItemText (i
, String::CreateFromAscii("LightBorderColor"));
153 InsertItem (++i
, rSettings
.GetShadowColor());
154 SetItemText (i
, String::CreateFromAscii("ShadowColor"));
155 InsertItem (++i
, rSettings
.GetDarkShadowColor());
156 SetItemText (i
, String::CreateFromAscii("DarkShadowColor"));
157 InsertItem (++i
, rSettings
.GetButtonTextColor());
158 SetItemText (i
, String::CreateFromAscii("ButtonTextColor"));
159 InsertItem (++i
, rSettings
.GetRadioCheckTextColor());
160 SetItemText (i
, String::CreateFromAscii("RadioCheckTextColor"));
161 InsertItem (++i
, rSettings
.GetGroupTextColor());
162 SetItemText (i
, String::CreateFromAscii("GroupTextColor"));
163 InsertItem (++i
, rSettings
.GetLabelTextColor());
164 SetItemText (i
, String::CreateFromAscii("LabelTextColor"));
165 InsertItem (++i
, rSettings
.GetInfoTextColor());
166 SetItemText (i
, String::CreateFromAscii("InfoTextColor"));
167 InsertItem (++i
, rSettings
.GetWindowColor());
168 SetItemText (i
, String::CreateFromAscii("WindowColor"));
169 InsertItem (++i
, rSettings
.GetWindowTextColor());
170 SetItemText (i
, String::CreateFromAscii("WindowTextColor"));
171 InsertItem (++i
, rSettings
.GetDialogColor());
172 SetItemText (i
, String::CreateFromAscii("DialogColor"));
173 InsertItem (++i
, rSettings
.GetDialogTextColor());
174 SetItemText (i
, String::CreateFromAscii("DialogTextColor"));
175 InsertItem (++i
, rSettings
.GetWorkspaceColor());
176 SetItemText (i
, String::CreateFromAscii("WorkspaceColor"));
177 InsertItem (++i
, rSettings
.GetFieldColor());
178 SetItemText (i
, String::CreateFromAscii("FieldColor"));
179 InsertItem (++i
, rSettings
.GetFieldTextColor());
180 SetItemText (i
, String::CreateFromAscii("FieldTextColor"));
181 InsertItem (++i
, rSettings
.GetActiveColor());
182 SetItemText (i
, String::CreateFromAscii("ActiveColor"));
183 InsertItem (++i
, rSettings
.GetActiveColor2());
184 SetItemText (i
, String::CreateFromAscii("ActiveColor2"));
185 InsertItem (++i
, rSettings
.GetActiveTextColor());
186 SetItemText (i
, String::CreateFromAscii("ActiveTextColor"));
187 InsertItem (++i
, rSettings
.GetActiveBorderColor());
188 SetItemText (i
, String::CreateFromAscii("ActiveBorderColor"));
189 InsertItem (++i
, rSettings
.GetDeactiveColor());
190 SetItemText (i
, String::CreateFromAscii("DeactiveColor"));
191 InsertItem (++i
, rSettings
.GetDeactiveColor2());
192 SetItemText (i
, String::CreateFromAscii("DeactiveColor2"));
193 InsertItem (++i
, rSettings
.GetDeactiveTextColor());
194 SetItemText (i
, String::CreateFromAscii("DeactiveTextColor"));
195 InsertItem (++i
, rSettings
.GetDeactiveBorderColor());
196 SetItemText (i
, String::CreateFromAscii("DeactiveBorderColor"));
197 InsertItem (++i
, rSettings
.GetHighlightColor());
198 SetItemText (i
, String::CreateFromAscii("HighlightColor"));
199 InsertItem (++i
, rSettings
.GetHighlightTextColor());
200 SetItemText (i
, String::CreateFromAscii("HighlightTextColor"));
201 InsertItem (++i
, rSettings
.GetDisableColor());
202 SetItemText (i
, String::CreateFromAscii("DisableColor"));
203 InsertItem (++i
, rSettings
.GetHelpColor());
204 SetItemText (i
, String::CreateFromAscii("HelpColor"));
205 InsertItem (++i
, rSettings
.GetHelpTextColor());
206 SetItemText (i
, String::CreateFromAscii("HelpTextColor"));
207 InsertItem (++i
, rSettings
.GetMenuColor());
208 SetItemText (i
, String::CreateFromAscii("MenuColor"));
209 InsertItem (++i
, rSettings
.GetMenuBarColor());
210 SetItemText (i
, String::CreateFromAscii("MenuBarColor"));
211 InsertItem (++i
, rSettings
.GetMenuBorderColor());
212 SetItemText (i
, String::CreateFromAscii("MenuBorderColor"));
213 InsertItem (++i
, rSettings
.GetMenuTextColor());
214 SetItemText (i
, String::CreateFromAscii("MenuTextColor"));
215 InsertItem (++i
, rSettings
.GetMenuHighlightColor());
216 SetItemText (i
, String::CreateFromAscii("MenuHighlightColor"));
217 InsertItem (++i
, rSettings
.GetMenuHighlightTextColor());
218 SetItemText (i
, String::CreateFromAscii("MenuHighlightTextColor"));
219 InsertItem (++i
, rSettings
.GetLinkColor());
220 SetItemText (i
, String::CreateFromAscii("LinkColor"));
221 InsertItem (++i
, rSettings
.GetVisitedLinkColor());
222 SetItemText (i
, String::CreateFromAscii("VisitedLinkColor"));
223 InsertItem (++i
, rSettings
.GetHighlightLinkColor());
224 SetItemText (i
, String::CreateFromAscii("HighlightLinkColor"));
225 InsertItem (++i
, rSettings
.GetFontColor());
226 SetItemText (i
, String::CreateFromAscii("FontColor"));
229 } } // end of namespace ::svx::sidebar