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 .
19 #include "precompiled_svx.hxx"
21 #include "ColorPanel.hxx"
23 #include <vcl/image.hxx>
24 #include <vcl/svapp.hxx>
26 namespace svx
{ namespace sidebar
{
28 ColorPanel::ColorPanel (::Window
* pParent
)
30 mnPreferredColumnCount(2)
40 SetStyle(GetStyle() | aStyle
);
50 ColorPanel::~ColorPanel (void)
54 void ColorPanel::Resize (void)
57 Size aWindowSize
= GetOutputSizePixel();
58 SetPosSizePixel(Point(0,0), aWindowSize
);
59 if (IsVisible() && aWindowSize
.Width() > 0)
61 // Calculate the number of rows and columns.
62 if (GetItemCount() > 0)
64 Image aImage
= GetItemImage(GetItemId(0));
65 Size aItemSize
= CalcItemSizePixel (
66 aImage
.GetSizePixel());
67 int nColumnCount
= aWindowSize
.Width() / 30;
70 else if (nColumnCount
> 4)
73 sal_uInt16 nRowCount
= (sal_uInt16
)CalculateRowCount(aItemSize
, nColumnCount
);
75 SetColCount((sal_uInt16
)nColumnCount
);
76 SetLineCount(nRowCount
);
85 int ColorPanel::CalculateRowCount (const Size
&, int nColumnCount
)
89 if (GetItemCount()>0 && nColumnCount
>0)
91 nRowCount
= GetOutputSizePixel().Height() / 30;
102 void ColorPanel::DataChanged (const DataChangedEvent
& rEvent
)
110 void ColorPanel::Fill (void)
112 const StyleSettings
& rSettings (
113 Application::GetSettings().GetStyleSettings());
118 InsertItem (++i
, rSettings
.GetFaceColor());
119 SetItemText (i
, String::CreateFromAscii("FaceColor"));
120 InsertItem (++i
, rSettings
.GetCheckedColor());
121 SetItemText (i
, String::CreateFromAscii("CheckedColor"));
122 InsertItem (++i
, rSettings
.GetLightColor());
123 SetItemText (i
, String::CreateFromAscii("LightColor"));
124 InsertItem (++i
, rSettings
.GetLightBorderColor());
125 SetItemText (i
, String::CreateFromAscii("LightBorderColor"));
126 InsertItem (++i
, rSettings
.GetShadowColor());
127 SetItemText (i
, String::CreateFromAscii("ShadowColor"));
128 InsertItem (++i
, rSettings
.GetDarkShadowColor());
129 SetItemText (i
, String::CreateFromAscii("DarkShadowColor"));
130 InsertItem (++i
, rSettings
.GetButtonTextColor());
131 SetItemText (i
, String::CreateFromAscii("ButtonTextColor"));
132 InsertItem (++i
, rSettings
.GetRadioCheckTextColor());
133 SetItemText (i
, String::CreateFromAscii("RadioCheckTextColor"));
134 InsertItem (++i
, rSettings
.GetGroupTextColor());
135 SetItemText (i
, String::CreateFromAscii("GroupTextColor"));
136 InsertItem (++i
, rSettings
.GetLabelTextColor());
137 SetItemText (i
, String::CreateFromAscii("LabelTextColor"));
138 InsertItem (++i
, rSettings
.GetInfoTextColor());
139 SetItemText (i
, String::CreateFromAscii("InfoTextColor"));
140 InsertItem (++i
, rSettings
.GetWindowColor());
141 SetItemText (i
, String::CreateFromAscii("WindowColor"));
142 InsertItem (++i
, rSettings
.GetWindowTextColor());
143 SetItemText (i
, String::CreateFromAscii("WindowTextColor"));
144 InsertItem (++i
, rSettings
.GetDialogColor());
145 SetItemText (i
, String::CreateFromAscii("DialogColor"));
146 InsertItem (++i
, rSettings
.GetDialogTextColor());
147 SetItemText (i
, String::CreateFromAscii("DialogTextColor"));
148 InsertItem (++i
, rSettings
.GetWorkspaceColor());
149 SetItemText (i
, String::CreateFromAscii("WorkspaceColor"));
150 InsertItem (++i
, rSettings
.GetFieldColor());
151 SetItemText (i
, String::CreateFromAscii("FieldColor"));
152 InsertItem (++i
, rSettings
.GetFieldTextColor());
153 SetItemText (i
, String::CreateFromAscii("FieldTextColor"));
154 InsertItem (++i
, rSettings
.GetActiveColor());
155 SetItemText (i
, String::CreateFromAscii("ActiveColor"));
156 InsertItem (++i
, rSettings
.GetActiveColor2());
157 SetItemText (i
, String::CreateFromAscii("ActiveColor2"));
158 InsertItem (++i
, rSettings
.GetActiveTextColor());
159 SetItemText (i
, String::CreateFromAscii("ActiveTextColor"));
160 InsertItem (++i
, rSettings
.GetActiveBorderColor());
161 SetItemText (i
, String::CreateFromAscii("ActiveBorderColor"));
162 InsertItem (++i
, rSettings
.GetDeactiveColor());
163 SetItemText (i
, String::CreateFromAscii("DeactiveColor"));
164 InsertItem (++i
, rSettings
.GetDeactiveColor2());
165 SetItemText (i
, String::CreateFromAscii("DeactiveColor2"));
166 InsertItem (++i
, rSettings
.GetDeactiveTextColor());
167 SetItemText (i
, String::CreateFromAscii("DeactiveTextColor"));
168 InsertItem (++i
, rSettings
.GetDeactiveBorderColor());
169 SetItemText (i
, String::CreateFromAscii("DeactiveBorderColor"));
170 InsertItem (++i
, rSettings
.GetHighlightColor());
171 SetItemText (i
, String::CreateFromAscii("HighlightColor"));
172 InsertItem (++i
, rSettings
.GetHighlightTextColor());
173 SetItemText (i
, String::CreateFromAscii("HighlightTextColor"));
174 InsertItem (++i
, rSettings
.GetDisableColor());
175 SetItemText (i
, String::CreateFromAscii("DisableColor"));
176 InsertItem (++i
, rSettings
.GetHelpColor());
177 SetItemText (i
, String::CreateFromAscii("HelpColor"));
178 InsertItem (++i
, rSettings
.GetHelpTextColor());
179 SetItemText (i
, String::CreateFromAscii("HelpTextColor"));
180 InsertItem (++i
, rSettings
.GetMenuColor());
181 SetItemText (i
, String::CreateFromAscii("MenuColor"));
182 InsertItem (++i
, rSettings
.GetMenuBarColor());
183 SetItemText (i
, String::CreateFromAscii("MenuBarColor"));
184 InsertItem (++i
, rSettings
.GetMenuBorderColor());
185 SetItemText (i
, String::CreateFromAscii("MenuBorderColor"));
186 InsertItem (++i
, rSettings
.GetMenuTextColor());
187 SetItemText (i
, String::CreateFromAscii("MenuTextColor"));
188 InsertItem (++i
, rSettings
.GetMenuHighlightColor());
189 SetItemText (i
, String::CreateFromAscii("MenuHighlightColor"));
190 InsertItem (++i
, rSettings
.GetMenuHighlightTextColor());
191 SetItemText (i
, String::CreateFromAscii("MenuHighlightTextColor"));
192 InsertItem (++i
, rSettings
.GetLinkColor());
193 SetItemText (i
, String::CreateFromAscii("LinkColor"));
194 InsertItem (++i
, rSettings
.GetVisitedLinkColor());
195 SetItemText (i
, String::CreateFromAscii("VisitedLinkColor"));
196 InsertItem (++i
, rSettings
.GetHighlightLinkColor());
197 SetItemText (i
, String::CreateFromAscii("HighlightLinkColor"));
198 InsertItem (++i
, rSettings
.GetFontColor());
199 SetItemText (i
, String::CreateFromAscii("FontColor"));
202 } } // end of namespace ::svx::sidebar
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */