Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
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/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
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 .
17 : */
18 :
19 : #include "ColorPanel.hxx"
20 :
21 : #include <vcl/image.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <vcl/settings.hxx>
24 :
25 : namespace svx { namespace sidebar {
26 :
27 0 : ColorPanel::ColorPanel (::Window* pParent)
28 0 : : ValueSet(pParent, WB_ITEMBORDER)
29 : {
30 : WinBits aStyle =
31 : WB_ITEMBORDER
32 : | WB_DOUBLEBORDER
33 : | WB_NAMEFIELD
34 : | WB_FLATVALUESET
35 : | WB_TABSTOP
36 0 : | WB_VSCROLL;
37 :
38 0 : SetStyle(GetStyle() | aStyle);
39 0 : SetExtraSpacing(2);
40 :
41 0 : Fill ();
42 0 : Show();
43 0 : }
44 :
45 :
46 :
47 :
48 0 : ColorPanel::~ColorPanel (void)
49 : {
50 0 : }
51 :
52 0 : void ColorPanel::Resize (void)
53 : {
54 0 : ::Window::Resize();
55 0 : Size aWindowSize = GetOutputSizePixel();
56 0 : SetPosSizePixel(Point(0,0), aWindowSize);
57 0 : if (IsVisible() && aWindowSize.Width() > 0)
58 : {
59 : // Calculate the number of rows and columns.
60 0 : if (GetItemCount() > 0)
61 : {
62 0 : Image aImage = GetItemImage(GetItemId(0));
63 : Size aItemSize = CalcItemSizePixel (
64 0 : aImage.GetSizePixel());
65 0 : int nColumnCount = aWindowSize.Width() / 30;
66 0 : if (nColumnCount < 1)
67 0 : nColumnCount = 1;
68 0 : else if (nColumnCount > 4)
69 0 : nColumnCount = 4;
70 :
71 0 : sal_uInt16 nRowCount = (sal_uInt16)CalculateRowCount(aItemSize, nColumnCount);
72 :
73 0 : SetColCount((sal_uInt16)nColumnCount);
74 0 : SetLineCount(nRowCount);
75 : }
76 : }
77 :
78 0 : }
79 :
80 :
81 :
82 :
83 0 : int ColorPanel::CalculateRowCount (const Size&, int nColumnCount)
84 : {
85 0 : int nRowCount = 0;
86 :
87 0 : if (GetItemCount()>0 && nColumnCount>0)
88 : {
89 0 : nRowCount = GetOutputSizePixel().Height() / 30;
90 0 : if (nRowCount < 1)
91 0 : nRowCount = 1;
92 : }
93 :
94 0 : return nRowCount;
95 : }
96 :
97 :
98 :
99 :
100 0 : void ColorPanel::DataChanged (const DataChangedEvent& /*rEvent*/)
101 : {
102 0 : Fill();
103 0 : }
104 :
105 :
106 :
107 :
108 0 : void ColorPanel::Fill (void)
109 : {
110 : const StyleSettings& rSettings (
111 0 : Application::GetSettings().GetStyleSettings());
112 0 : Clear();
113 0 : SetItemWidth (30);
114 0 : SetItemHeight (30);
115 0 : sal_uInt16 i = 0;
116 0 : InsertItem (++i, rSettings.GetFaceColor());
117 0 : SetItemText (i, OUString("FaceColor"));
118 0 : InsertItem (++i, rSettings.GetCheckedColor());
119 0 : SetItemText (i, OUString("CheckedColor"));
120 0 : InsertItem (++i, rSettings.GetLightColor());
121 0 : SetItemText (i, OUString("LightColor"));
122 0 : InsertItem (++i, rSettings.GetLightBorderColor());
123 0 : SetItemText (i, OUString("LightBorderColor"));
124 0 : InsertItem (++i, rSettings.GetShadowColor());
125 0 : SetItemText (i, OUString("ShadowColor"));
126 0 : InsertItem (++i, rSettings.GetDarkShadowColor());
127 0 : SetItemText (i, OUString("DarkShadowColor"));
128 0 : InsertItem (++i, rSettings.GetButtonTextColor());
129 0 : SetItemText (i, OUString("ButtonTextColor"));
130 0 : InsertItem (++i, rSettings.GetRadioCheckTextColor());
131 0 : SetItemText (i, OUString("RadioCheckTextColor"));
132 0 : InsertItem (++i, rSettings.GetGroupTextColor());
133 0 : SetItemText (i, OUString("GroupTextColor"));
134 0 : InsertItem (++i, rSettings.GetLabelTextColor());
135 0 : SetItemText (i, OUString("LabelTextColor"));
136 0 : InsertItem (++i, rSettings.GetInfoTextColor());
137 0 : SetItemText (i, OUString("InfoTextColor"));
138 0 : InsertItem (++i, rSettings.GetWindowColor());
139 0 : SetItemText (i, OUString("WindowColor"));
140 0 : InsertItem (++i, rSettings.GetWindowTextColor());
141 0 : SetItemText (i, OUString("WindowTextColor"));
142 0 : InsertItem (++i, rSettings.GetDialogColor());
143 0 : SetItemText (i, OUString("DialogColor"));
144 0 : InsertItem (++i, rSettings.GetDialogTextColor());
145 0 : SetItemText (i, OUString("DialogTextColor"));
146 0 : InsertItem (++i, rSettings.GetWorkspaceColor());
147 0 : SetItemText (i, OUString("WorkspaceColor"));
148 0 : InsertItem (++i, rSettings.GetFieldColor());
149 0 : SetItemText (i, OUString("FieldColor"));
150 0 : InsertItem (++i, rSettings.GetFieldTextColor());
151 0 : SetItemText (i, OUString("FieldTextColor"));
152 0 : InsertItem (++i, rSettings.GetActiveColor());
153 0 : SetItemText (i, OUString("ActiveColor"));
154 0 : InsertItem (++i, rSettings.GetActiveColor2());
155 0 : SetItemText (i, OUString("ActiveColor2"));
156 0 : InsertItem (++i, rSettings.GetActiveTextColor());
157 0 : SetItemText (i, OUString("ActiveTextColor"));
158 0 : InsertItem (++i, rSettings.GetActiveBorderColor());
159 0 : SetItemText (i, OUString("ActiveBorderColor"));
160 0 : InsertItem (++i, rSettings.GetDeactiveColor());
161 0 : SetItemText (i, OUString("DeactiveColor"));
162 0 : InsertItem (++i, rSettings.GetDeactiveColor2());
163 0 : SetItemText (i, OUString("DeactiveColor2"));
164 0 : InsertItem (++i, rSettings.GetDeactiveTextColor());
165 0 : SetItemText (i, OUString("DeactiveTextColor"));
166 0 : InsertItem (++i, rSettings.GetDeactiveBorderColor());
167 0 : SetItemText (i, OUString("DeactiveBorderColor"));
168 0 : InsertItem (++i, rSettings.GetHighlightColor());
169 0 : SetItemText (i, OUString("HighlightColor"));
170 0 : InsertItem (++i, rSettings.GetHighlightTextColor());
171 0 : SetItemText (i, OUString("HighlightTextColor"));
172 0 : InsertItem (++i, rSettings.GetDisableColor());
173 0 : SetItemText (i, OUString("DisableColor"));
174 0 : InsertItem (++i, rSettings.GetHelpColor());
175 0 : SetItemText (i, OUString("HelpColor"));
176 0 : InsertItem (++i, rSettings.GetHelpTextColor());
177 0 : SetItemText (i, OUString("HelpTextColor"));
178 0 : InsertItem (++i, rSettings.GetMenuColor());
179 0 : SetItemText (i, OUString("MenuColor"));
180 0 : InsertItem (++i, rSettings.GetMenuBarColor());
181 0 : SetItemText (i, OUString("MenuBarColor"));
182 0 : InsertItem (++i, rSettings.GetMenuBorderColor());
183 0 : SetItemText (i, OUString("MenuBorderColor"));
184 0 : InsertItem (++i, rSettings.GetMenuTextColor());
185 0 : SetItemText (i, OUString("MenuTextColor"));
186 0 : InsertItem (++i, rSettings.GetMenuHighlightColor());
187 0 : SetItemText (i, OUString("MenuHighlightColor"));
188 0 : InsertItem (++i, rSettings.GetMenuHighlightTextColor());
189 0 : SetItemText (i, OUString("MenuHighlightTextColor"));
190 0 : InsertItem (++i, rSettings.GetLinkColor());
191 0 : SetItemText (i, OUString("LinkColor"));
192 0 : InsertItem (++i, rSettings.GetVisitedLinkColor());
193 0 : SetItemText (i, OUString("VisitedLinkColor"));
194 0 : InsertItem (++i, rSettings.GetHighlightLinkColor());
195 0 : SetItemText (i, OUString("HighlightLinkColor"));
196 0 : InsertItem (++i, rSettings.GetFontColor());
197 0 : SetItemText (i, OUString("FontColor"));
198 0 : }
199 :
200 : } } // end of namespace ::svx::sidebar
|