Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / dlgctl3d.hxx
blobca77be777db13bbb93048ea2315cebdde30f3b10
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 E3dPolyScene;
34 class E3dObject;
36 enum class SvxPreviewObjectType { SPHERE, CUBE };
38 class SVX_DLLPUBLIC SAL_WARN_UNUSED Svx3DPreviewControl : public Control
40 protected:
41 FmFormModel* mpModel;
42 FmFormPage* mpFmPage;
43 E3dView* mp3DView;
44 E3dPolyScene* mpScene;
45 E3dObject* mp3DObj;
46 SvxPreviewObjectType mnObjectType;
48 void Construct();
50 public:
51 Svx3DPreviewControl(vcl::Window* pParent, WinBits nStyle = 0);
52 virtual ~Svx3DPreviewControl();
53 virtual void dispose() SAL_OVERRIDE;
55 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
56 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
57 virtual void Resize() SAL_OVERRIDE;
58 virtual Size GetOptimalSize() const SAL_OVERRIDE;
60 void Reset();
61 virtual void SetObjectType(SvxPreviewObjectType nType);
62 SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
63 SfxItemSet Get3DAttributes() const;
64 virtual void Set3DAttributes(const SfxItemSet& rAttr);
67 class SVX_DLLPUBLIC SAL_WARN_UNUSED Svx3DLightControl : public Svx3DPreviewControl
69 // Callback for interactive changes
70 Link<> maUserInteractiveChangeCallback;
71 Link<> maUserSelectionChangeCallback;
72 Link<> maChangeCallback;
73 Link<> maSelectionChangeCallback;
75 // lights
76 sal_uInt32 maSelectedLight;
78 // extra objects for light control
79 E3dObject* mpExpansionObject;
80 E3dObject* mpLampBottomObject;
81 E3dObject* mpLampShaftObject;
82 std::vector< E3dObject* > maLightObjects;
84 // 3d rotations of object
85 double mfRotateX;
86 double mfRotateY;
87 double mfRotateZ;
89 // interaction parameters
90 Point maActionStartPoint;
91 sal_Int32 mnInteractionStartDistance;
92 double mfSaveActionStartHor;
93 double mfSaveActionStartVer;
94 double mfSaveActionStartRotZ;
96 // bitfield
97 bool mbMouseMoved : 1;
98 bool mbGeometrySelected : 1;
100 void Construct2();
101 void ConstructLightObjects();
102 void AdaptToSelectedLight();
103 void TrySelection(Point aPosPixel);
105 public:
106 Svx3DLightControl(vcl::Window* pParent, WinBits nStyle = 0);
108 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
109 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
110 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
111 virtual void Resize() SAL_OVERRIDE;
113 virtual void SetObjectType(SvxPreviewObjectType nType) SAL_OVERRIDE;
115 // register user callback
116 void SetUserInteractiveChangeCallback(Link<> aNew) { maUserInteractiveChangeCallback = aNew; }
117 void SetUserSelectionChangeCallback(Link<> aNew) { maUserSelectionChangeCallback = aNew; }
118 void SetChangeCallback(Link<> aNew) { maChangeCallback = aNew; }
119 void SetSelectionChangeCallback(Link<> aNew) { maSelectionChangeCallback = aNew; }
121 // selection checks
122 bool IsSelectionValid();
123 bool IsGeometrySelected() { return mbGeometrySelected; }
125 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
126 void GetPosition(double& rHor, double& rVer);
127 void SetPosition(double fHor, double fVer);
129 // get/set rotation of 3D object
130 void SetRotation(double fRotX, double fRotY, double fRotZ);
131 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
133 void SelectLight(sal_uInt32 nLightNumber);
134 virtual void Set3DAttributes(const SfxItemSet& rAttr) SAL_OVERRIDE;
135 sal_uInt32 GetSelectedLight() { return maSelectedLight; }
137 // light data access
138 bool GetLightOnOff(sal_uInt32 nNum) const;
139 Color GetLightColor(sal_uInt32 nNum) const;
140 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
143 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxLightCtl3D : public Control
145 private:
146 // local controls
147 VclPtr<Svx3DLightControl> maLightControl;
148 VclPtr<ScrollBar> maHorScroller;
149 VclPtr<ScrollBar> maVerScroller;
150 VclPtr<PushButton> maSwitcher;
152 // callback for interactive changes
153 Link<> maUserInteractiveChangeCallback;
154 Link<> maUserSelectionChangeCallback;
156 public:
157 SvxLightCtl3D(vcl::Window* pParent);
158 virtual ~SvxLightCtl3D();
159 virtual void dispose() SAL_OVERRIDE;
161 // react to size changes
162 virtual void Resize() SAL_OVERRIDE;
163 void NewLayout();
165 // check the selection for validity
166 void CheckSelection();
168 // bring further settings to the outside world
169 Svx3DLightControl& GetSvx3DLightControl() { return *maLightControl.get(); }
171 // register user callback
172 void SetUserInteractiveChangeCallback(Link<> aNew) { maUserInteractiveChangeCallback = aNew; }
173 void SetUserSelectionChangeCallback(Link<> aNew) { maUserSelectionChangeCallback = aNew; }
175 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
176 virtual void GetFocus() SAL_OVERRIDE;
177 virtual void LoseFocus() SAL_OVERRIDE;
179 virtual Size GetOptimalSize() const SAL_OVERRIDE;
181 protected:
183 DECL_LINK( InternalInteractiveChange, void*);
184 DECL_LINK( InternalSelectionChange, void*);
185 DECL_LINK( ScrollBarMove, void*);
186 DECL_LINK( ButtonPress, void*);
188 // initialize local parameters
189 void Init();
191 void move( double fDeltaHor, double fDeltaVer );
194 #endif // _SCH_DLGCTL3D_HXX
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */