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 .
20 #include <ChartResourceGroups.hxx>
24 using namespace ::com::sun::star
;
25 using namespace ::com::sun::star::chart2
;
27 Dim3DLookResourceGroup::Dim3DLookResourceGroup(weld::Builder
* pBuilder
)
29 , m_xCB_3DLook(pBuilder
->weld_check_button("3dlook"))
30 , m_xLB_Scheme(pBuilder
->weld_combo_box("3dscheme"))
32 m_xCB_3DLook
->connect_toggled(LINK(this, Dim3DLookResourceGroup
, Dim3DLookCheckHdl
));
33 m_xLB_Scheme
->connect_changed(LINK(this, Dim3DLookResourceGroup
, SelectSchemeHdl
));
36 void Dim3DLookResourceGroup::showControls(bool bShow
)
38 m_xCB_3DLook
->set_visible(bShow
);
39 m_xLB_Scheme
->set_visible(bShow
);
42 void Dim3DLookResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
44 m_xCB_3DLook
->set_active(rParameter
.b3DLook
);
45 m_xLB_Scheme
->set_sensitive(rParameter
.b3DLook
);
47 if (rParameter
.eThreeDLookScheme
== ThreeDLookScheme_Simple
)
48 m_xLB_Scheme
->set_active(POS_3DSCHEME_SIMPLE
);
49 else if (rParameter
.eThreeDLookScheme
== ThreeDLookScheme_Realistic
)
50 m_xLB_Scheme
->set_active(POS_3DSCHEME_REALISTIC
);
52 m_xLB_Scheme
->set_active(-1);
55 void Dim3DLookResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
57 rParameter
.b3DLook
= m_xCB_3DLook
->get_active();
58 const int nPos
= m_xLB_Scheme
->get_active();
59 if (nPos
== POS_3DSCHEME_SIMPLE
)
60 rParameter
.eThreeDLookScheme
= ThreeDLookScheme_Simple
;
61 else if (nPos
== POS_3DSCHEME_REALISTIC
)
62 rParameter
.eThreeDLookScheme
= ThreeDLookScheme_Realistic
;
64 rParameter
.eThreeDLookScheme
= ThreeDLookScheme_Unknown
;
67 IMPL_LINK_NOARG(Dim3DLookResourceGroup
, Dim3DLookCheckHdl
, weld::ToggleButton
&, void)
69 if (m_pChangeListener
)
70 m_pChangeListener
->stateChanged();
73 IMPL_LINK_NOARG(Dim3DLookResourceGroup
, SelectSchemeHdl
, weld::ComboBox
&, void)
75 if (m_pChangeListener
)
76 m_pChangeListener
->stateChanged();
79 SortByXValuesResourceGroup::SortByXValuesResourceGroup(weld::Builder
* pBuilder
)
81 , m_xCB_XValueSorting(pBuilder
->weld_check_button("sort"))
83 m_xCB_XValueSorting
->connect_toggled(
84 LINK(this, SortByXValuesResourceGroup
, SortByXValuesCheckHdl
));
87 void SortByXValuesResourceGroup::showControls(bool bShow
)
89 m_xCB_XValueSorting
->set_visible(bShow
);
92 void SortByXValuesResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
94 m_xCB_XValueSorting
->set_active(rParameter
.bSortByXValues
);
97 void SortByXValuesResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
99 rParameter
.bSortByXValues
= m_xCB_XValueSorting
->get_active();
102 IMPL_LINK_NOARG(SortByXValuesResourceGroup
, SortByXValuesCheckHdl
, weld::ToggleButton
&, void)
104 if (m_pChangeListener
)
105 m_pChangeListener
->stateChanged();
108 StackingResourceGroup::StackingResourceGroup(weld::Builder
* pBuilder
)
110 , m_xCB_Stacked(pBuilder
->weld_check_button("stack"))
111 , m_xRB_Stack_Y(pBuilder
->weld_radio_button("ontop"))
112 , m_xRB_Stack_Y_Percent(pBuilder
->weld_radio_button("percent"))
113 , m_xRB_Stack_Z(pBuilder
->weld_radio_button("deep"))
115 m_xCB_Stacked
->connect_toggled(LINK(this, StackingResourceGroup
, StackingEnableHdl
));
116 m_xRB_Stack_Y
->connect_toggled(LINK(this, StackingResourceGroup
, StackingChangeHdl
));
117 m_xRB_Stack_Y_Percent
->connect_toggled(LINK(this, StackingResourceGroup
, StackingChangeHdl
));
118 m_xRB_Stack_Z
->connect_toggled(LINK(this, StackingResourceGroup
, StackingChangeHdl
));
121 void StackingResourceGroup::showControls(bool bShow
, bool bShowDeepStacking
)
123 m_xCB_Stacked
->set_visible(bShow
);
124 m_xRB_Stack_Y
->set_visible(bShow
);
125 m_xRB_Stack_Y_Percent
->set_visible(bShow
);
126 m_xRB_Stack_Z
->set_visible(bShow
&& bShowDeepStacking
);
129 void StackingResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
131 m_xCB_Stacked
->set_active(
132 rParameter
.eStackMode
!= GlobalStackMode_NONE
133 && rParameter
.eStackMode
134 != GlobalStackMode_STACK_Z
); //todo remove this condition if z stacking radio button is really used
135 switch (rParameter
.eStackMode
)
137 case GlobalStackMode_STACK_Y
:
138 m_xRB_Stack_Y
->set_active(true);
140 case GlobalStackMode_STACK_Y_PERCENT
:
141 m_xRB_Stack_Y_Percent
->set_active(true);
143 case GlobalStackMode_STACK_Z
:
144 //todo uncomment this condition if z stacking radio button is really used
146 if( rParameter.b3DLook )
147 m_xRB_Stack_Z->set_active(true);
150 m_xRB_Stack_Y
->set_active(true);
153 m_xRB_Stack_Y
->set_active(true);
157 m_xCB_Stacked
->set_sensitive(!rParameter
.bXAxisWithValues
);
158 m_xRB_Stack_Y
->set_sensitive(m_xCB_Stacked
->get_active() && !rParameter
.bXAxisWithValues
);
159 m_xRB_Stack_Y_Percent
->set_sensitive(m_xCB_Stacked
->get_active()
160 && !rParameter
.bXAxisWithValues
);
161 m_xRB_Stack_Z
->set_sensitive(m_xCB_Stacked
->get_active() && rParameter
.b3DLook
);
164 void StackingResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
166 if (!m_xCB_Stacked
->get_active())
167 rParameter
.eStackMode
= GlobalStackMode_NONE
;
168 else if (m_xRB_Stack_Y
->get_active())
169 rParameter
.eStackMode
= GlobalStackMode_STACK_Y
;
170 else if (m_xRB_Stack_Y_Percent
->get_active())
171 rParameter
.eStackMode
= GlobalStackMode_STACK_Y_PERCENT
;
172 else if (m_xRB_Stack_Z
->get_active())
173 rParameter
.eStackMode
= GlobalStackMode_STACK_Z
;
176 IMPL_LINK(StackingResourceGroup
, StackingChangeHdl
, weld::ToggleButton
&, rRadio
, void)
178 //for each radio click there are coming two change events
179 //first uncheck of previous button -> ignore that call
180 //the second call gives the check of the new button
181 if (m_pChangeListener
&& rRadio
.get_active())
182 m_pChangeListener
->stateChanged();
185 IMPL_LINK_NOARG(StackingResourceGroup
, StackingEnableHdl
, weld::ToggleButton
&, void)
187 if (m_pChangeListener
)
188 m_pChangeListener
->stateChanged();
191 SplinePropertiesDialog::SplinePropertiesDialog(weld::Window
* pParent
)
192 : GenericDialogController(pParent
, "modules/schart/ui/smoothlinesdlg.ui", "SmoothLinesDialog")
193 , m_xLB_Spline_Type(m_xBuilder
->weld_combo_box("SplineTypeComboBox"))
194 , m_xMF_SplineResolution(m_xBuilder
->weld_spin_button("ResolutionSpinbutton"))
195 , m_xFT_SplineOrder(m_xBuilder
->weld_label("PolynomialsLabel"))
196 , m_xMF_SplineOrder(m_xBuilder
->weld_spin_button("PolynomialsSpinButton"))
198 m_xDialog
->set_title(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES
));
200 m_xLB_Spline_Type
->connect_changed(LINK(this, SplinePropertiesDialog
, SplineTypeListBoxHdl
));
203 void SplinePropertiesDialog::fillControls(const ChartTypeParameter
& rParameter
)
205 switch (rParameter
.eCurveStyle
)
207 case CurveStyle_CUBIC_SPLINES
:
208 m_xLB_Spline_Type
->set_active(CUBIC_SPLINE_POS
);
210 case CurveStyle_B_SPLINES
:
211 m_xLB_Spline_Type
->set_active(B_SPLINE_POS
);
214 m_xLB_Spline_Type
->set_active(CUBIC_SPLINE_POS
);
217 m_xMF_SplineOrder
->set_value(rParameter
.nSplineOrder
);
218 m_xMF_SplineResolution
->set_value(rParameter
.nCurveResolution
);
221 m_xFT_SplineOrder
->set_sensitive(m_xLB_Spline_Type
->get_active() == B_SPLINE_POS
);
222 m_xMF_SplineOrder
->set_sensitive(m_xLB_Spline_Type
->get_active() == B_SPLINE_POS
);
225 void SplinePropertiesDialog::fillParameter(ChartTypeParameter
& rParameter
, bool bSmoothLines
)
228 rParameter
.eCurveStyle
= CurveStyle_LINES
;
229 else if (m_xLB_Spline_Type
->get_active() == CUBIC_SPLINE_POS
)
230 rParameter
.eCurveStyle
= CurveStyle_CUBIC_SPLINES
;
231 else if (m_xLB_Spline_Type
->get_active() == B_SPLINE_POS
)
232 rParameter
.eCurveStyle
= CurveStyle_B_SPLINES
;
234 rParameter
.nCurveResolution
= m_xMF_SplineResolution
->get_value();
235 rParameter
.nSplineOrder
= m_xMF_SplineOrder
->get_value();
238 IMPL_LINK_NOARG(SplinePropertiesDialog
, SplineTypeListBoxHdl
, weld::ComboBox
&, void)
240 m_xFT_SplineOrder
->set_sensitive(m_xLB_Spline_Type
->get_active() == B_SPLINE_POS
);
241 m_xMF_SplineOrder
->set_sensitive(m_xLB_Spline_Type
->get_active() == B_SPLINE_POS
);
244 SteppedPropertiesDialog::SteppedPropertiesDialog(weld::Window
* pParent
)
245 : GenericDialogController(pParent
, "modules/schart/ui/steppedlinesdlg.ui", "SteppedLinesDialog")
246 , m_xRB_Start(m_xBuilder
->weld_radio_button("step_start_rb"))
247 , m_xRB_End(m_xBuilder
->weld_radio_button("step_end_rb"))
248 , m_xRB_CenterX(m_xBuilder
->weld_radio_button("step_center_x_rb"))
249 , m_xRB_CenterY(m_xBuilder
->weld_radio_button("step_center_y_rb"))
251 m_xDialog
->set_title(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES
));
254 void SteppedPropertiesDialog::fillControls(const ChartTypeParameter
& rParameter
)
256 switch (rParameter
.eCurveStyle
)
258 case CurveStyle_STEP_END
:
259 m_xRB_End
->set_active(true);
261 case CurveStyle_STEP_CENTER_X
:
262 m_xRB_CenterX
->set_active(true);
264 case CurveStyle_STEP_CENTER_Y
:
265 m_xRB_CenterY
->set_active(true);
267 default: // includes CurveStyle_STEP_START
268 m_xRB_Start
->set_active(true);
272 void SteppedPropertiesDialog::fillParameter(ChartTypeParameter
& rParameter
, bool bSteppedLines
)
275 rParameter
.eCurveStyle
= CurveStyle_LINES
;
276 else if (m_xRB_CenterY
->get_active())
277 rParameter
.eCurveStyle
= CurveStyle_STEP_CENTER_Y
;
278 else if (m_xRB_Start
->get_active())
279 rParameter
.eCurveStyle
= CurveStyle_STEP_START
;
280 else if (m_xRB_End
->get_active())
281 rParameter
.eCurveStyle
= CurveStyle_STEP_END
;
282 else if (m_xRB_CenterX
->get_active())
283 rParameter
.eCurveStyle
= CurveStyle_STEP_CENTER_X
;
286 SplineResourceGroup::SplineResourceGroup(weld::Builder
* pBuilder
, weld::Window
* pParent
)
289 , m_xFT_LineType(pBuilder
->weld_label("linetypeft"))
290 , m_xLB_LineType(pBuilder
->weld_combo_box("linetype"))
291 , m_xPB_DetailsDialog(pBuilder
->weld_button("properties"))
293 m_xLB_LineType
->connect_changed(LINK(this, SplineResourceGroup
, LineTypeChangeHdl
));
296 SplinePropertiesDialog
& SplineResourceGroup::getSplinePropertiesDialog()
298 if (!m_xSplinePropertiesDialog
)
300 m_xSplinePropertiesDialog
.reset(new SplinePropertiesDialog(m_pParent
));
302 return *m_xSplinePropertiesDialog
;
305 SteppedPropertiesDialog
& SplineResourceGroup::getSteppedPropertiesDialog()
307 if (!m_xSteppedPropertiesDialog
)
309 m_xSteppedPropertiesDialog
.reset(new SteppedPropertiesDialog(m_pParent
));
311 return *m_xSteppedPropertiesDialog
;
314 void SplineResourceGroup::showControls(bool bShow
)
316 m_xFT_LineType
->set_visible(bShow
);
317 m_xLB_LineType
->set_visible(bShow
);
318 m_xPB_DetailsDialog
->set_visible(bShow
);
321 void SplineResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
323 switch (rParameter
.eCurveStyle
)
325 case CurveStyle_LINES
:
326 m_xLB_LineType
->set_active(POS_LINETYPE_STRAIGHT
);
327 m_xPB_DetailsDialog
->set_sensitive(false);
329 case CurveStyle_CUBIC_SPLINES
:
330 case CurveStyle_B_SPLINES
:
331 m_xLB_LineType
->set_active(POS_LINETYPE_SMOOTH
);
332 m_xPB_DetailsDialog
->set_sensitive(true);
333 m_xPB_DetailsDialog
->connect_clicked(
334 LINK(this, SplineResourceGroup
, SplineDetailsDialogHdl
));
335 m_xPB_DetailsDialog
->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES
));
336 getSplinePropertiesDialog().fillControls(rParameter
);
338 case CurveStyle_STEP_START
:
339 case CurveStyle_STEP_END
:
340 case CurveStyle_STEP_CENTER_X
:
341 case CurveStyle_STEP_CENTER_Y
:
342 m_xLB_LineType
->set_active(POS_LINETYPE_STEPPED
);
343 m_xPB_DetailsDialog
->set_sensitive(true);
344 m_xPB_DetailsDialog
->connect_clicked(
345 LINK(this, SplineResourceGroup
, SteppedDetailsDialogHdl
));
346 m_xPB_DetailsDialog
->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES
));
347 getSteppedPropertiesDialog().fillControls(rParameter
);
350 m_xLB_LineType
->set_active(-1);
351 m_xPB_DetailsDialog
->set_sensitive(false);
354 void SplineResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
356 switch (m_xLB_LineType
->get_active())
358 case POS_LINETYPE_SMOOTH
:
359 getSplinePropertiesDialog().fillParameter(rParameter
, true);
361 case POS_LINETYPE_STEPPED
:
362 getSteppedPropertiesDialog().fillParameter(rParameter
, true);
364 default: // includes POS_LINETYPE_STRAIGHT
365 rParameter
.eCurveStyle
= CurveStyle_LINES
;
370 IMPL_LINK_NOARG(SplineResourceGroup
, LineTypeChangeHdl
, weld::ComboBox
&, void)
372 if (m_pChangeListener
)
373 m_pChangeListener
->stateChanged();
376 IMPL_LINK_NOARG(SplineResourceGroup
, SplineDetailsDialogHdl
, weld::Button
&, void)
378 ChartTypeParameter aOldParameter
;
379 getSplinePropertiesDialog().fillParameter(aOldParameter
,
380 m_xLB_LineType
->get_active() == POS_LINETYPE_SMOOTH
);
382 const sal_Int32 iOldLineTypePos
= m_xLB_LineType
->get_active();
383 m_xLB_LineType
->set_active(POS_LINETYPE_SMOOTH
);
384 if (getSplinePropertiesDialog().run() == RET_OK
)
386 if (m_pChangeListener
)
387 m_pChangeListener
->stateChanged();
392 m_xLB_LineType
->set_active(iOldLineTypePos
);
393 getSplinePropertiesDialog().fillControls(aOldParameter
);
397 IMPL_LINK_NOARG(SplineResourceGroup
, SteppedDetailsDialogHdl
, weld::Button
&, void)
399 ChartTypeParameter aOldParameter
;
400 getSteppedPropertiesDialog().fillParameter(aOldParameter
, m_xLB_LineType
->get_active()
401 == POS_LINETYPE_STEPPED
);
403 const sal_Int32 iOldLineTypePos
= m_xLB_LineType
->get_active();
404 m_xLB_LineType
->set_active(POS_LINETYPE_STEPPED
);
405 if (getSteppedPropertiesDialog().run() == RET_OK
)
407 if (m_pChangeListener
)
408 m_pChangeListener
->stateChanged();
413 m_xLB_LineType
->set_active(iOldLineTypePos
);
414 getSteppedPropertiesDialog().fillControls(aOldParameter
);
418 GeometryResourceGroup::GeometryResourceGroup(weld::Builder
* pBuilder
)
420 , m_aGeometryResources(pBuilder
)
422 m_aGeometryResources
.connect_changed(LINK(this, GeometryResourceGroup
, GeometryChangeHdl
));
425 void GeometryResourceGroup::showControls(bool bShow
) { m_aGeometryResources
.set_visible(bShow
); }
427 void GeometryResourceGroup::fillControls(const ChartTypeParameter
& rParameter
)
429 sal_uInt16 nGeometry3D
= static_cast<sal_uInt16
>(rParameter
.nGeometry3D
);
430 m_aGeometryResources
.select(nGeometry3D
);
431 m_aGeometryResources
.set_sensitive(rParameter
.b3DLook
);
434 void GeometryResourceGroup::fillParameter(ChartTypeParameter
& rParameter
)
436 rParameter
.nGeometry3D
= 1;
437 int nSelected
= m_aGeometryResources
.get_selected_index();
439 rParameter
.nGeometry3D
= nSelected
;
442 IMPL_LINK_NOARG(GeometryResourceGroup
, GeometryChangeHdl
, weld::TreeView
&, void)
444 if (m_pChangeListener
)
445 m_pChangeListener
->stateChanged();
450 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */