Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / dlgctl3d.hxx
blob589bd33b9ac23327dd2e0b5abefe561d3fe78a30
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_SVX_DLGCTL3D_HXX
21 #define INCLUDED_SVX_DLGCTL3D_HXX
23 #include <vcl/ctrl.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/button.hxx>
26 #include <svl/itemset.hxx>
27 #include <svx/svxdllapi.h>
28 #include <basegfx/vector/b3dvector.hxx>
30 class FmFormModel;
31 class FmFormPage;
32 class E3dView;
33 class E3dObject;
34 class E3dScene;
36 enum class SvxPreviewObjectType { SPHERE, CUBE };
38 class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DPreviewControl : public Control
40 protected:
41 FmFormModel* mpModel;
42 FmFormPage* mpFmPage;
43 E3dView* mp3DView;
44 E3dScene* mpScene;
45 E3dObject* mp3DObj;
46 SvxPreviewObjectType mnObjectType;
48 void Construct();
50 public:
51 Svx3DPreviewControl(vcl::Window* pParent, WinBits nStyle = 0);
52 virtual ~Svx3DPreviewControl() override;
53 virtual void dispose() override;
55 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
56 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
57 virtual void Resize() override;
58 virtual Size GetOptimalSize() const override;
60 virtual void SetObjectType(SvxPreviewObjectType nType);
61 SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
62 SfxItemSet Get3DAttributes() const;
63 virtual void Set3DAttributes(const SfxItemSet& rAttr);
66 class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
68 // Callback for interactive changes
69 Link<Svx3DLightControl*,void> maChangeCallback;
70 Link<Svx3DLightControl*,void> maSelectionChangeCallback;
72 // lights
73 sal_uInt32 maSelectedLight;
75 // extra objects for light control
76 E3dObject* mpExpansionObject;
77 E3dObject* mpLampBottomObject;
78 E3dObject* mpLampShaftObject;
79 std::vector< E3dObject* > maLightObjects;
81 // 3d rotations of object
82 double mfRotateX;
83 double mfRotateY;
84 double mfRotateZ;
86 // interaction parameters
87 Point maActionStartPoint;
88 double mfSaveActionStartHor;
89 double mfSaveActionStartVer;
90 double mfSaveActionStartRotZ;
92 bool mbMouseMoved : 1;
93 bool mbGeometrySelected : 1;
95 void Construct2();
96 void ConstructLightObjects();
97 void AdaptToSelectedLight();
98 void TrySelection(Point aPosPixel);
100 public:
101 Svx3DLightControl(vcl::Window* pParent, WinBits nStyle);
103 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
104 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
105 virtual void Tracking( const TrackingEvent& rTEvt ) override;
106 virtual void Resize() override;
108 virtual void SetObjectType(SvxPreviewObjectType nType) override;
110 // register user callback
111 void SetChangeCallback(Link<Svx3DLightControl*,void> aNew) { maChangeCallback = aNew; }
112 void SetSelectionChangeCallback(Link<Svx3DLightControl*,void> aNew) { maSelectionChangeCallback = aNew; }
114 // selection checks
115 bool IsSelectionValid();
116 bool IsGeometrySelected() { return mbGeometrySelected; }
118 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
119 void GetPosition(double& rHor, double& rVer);
120 void SetPosition(double fHor, double fVer);
122 // get/set rotation of 3D object
123 void SetRotation(double fRotX, double fRotY, double fRotZ);
124 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
126 void SelectLight(sal_uInt32 nLightNumber);
127 virtual void Set3DAttributes(const SfxItemSet& rAttr) override;
128 sal_uInt32 GetSelectedLight() { return maSelectedLight; }
130 // light data access
131 bool GetLightOnOff(sal_uInt32 nNum) const;
132 Color GetLightColor(sal_uInt32 nNum) const;
133 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
136 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLightCtl3D : public Control
138 private:
139 // local controls
140 VclPtr<Svx3DLightControl> maLightControl;
141 VclPtr<ScrollBar> maHorScroller;
142 VclPtr<ScrollBar> maVerScroller;
143 VclPtr<PushButton> maSwitcher;
145 // callback for interactive changes
146 Link<SvxLightCtl3D*,void> maUserInteractiveChangeCallback;
147 Link<SvxLightCtl3D*,void> maUserSelectionChangeCallback;
149 public:
150 SvxLightCtl3D(vcl::Window* pParent);
151 virtual ~SvxLightCtl3D() override;
152 virtual void dispose() override;
154 // react to size changes
155 virtual void Resize() override;
156 void NewLayout();
158 // check the selection for validity
159 void CheckSelection();
161 // bring further settings to the outside world
162 Svx3DLightControl& GetSvx3DLightControl() { return *maLightControl.get(); }
164 // register user callback
165 void SetUserInteractiveChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; }
166 void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
168 virtual void KeyInput( const KeyEvent& rKEvt ) override;
169 virtual void GetFocus() override;
170 virtual void LoseFocus() override;
172 virtual Size GetOptimalSize() const override;
174 protected:
176 DECL_LINK( InternalInteractiveChange, Svx3DLightControl*, void);
177 DECL_LINK( InternalSelectionChange, Svx3DLightControl*, void);
178 DECL_LINK( ScrollBarMove, ScrollBar*, void);
179 DECL_LINK( ButtonPress, Button*, void);
181 // initialize local parameters
182 void Init();
184 void move( double fDeltaHor, double fDeltaVer );
187 #endif // _SCH_DLGCTL3D_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */