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