bump product version to 4.2.0.1
[LibreOffice.git] / include / svx / dlgctl3d.hxx
blob7ba8fd355fc0f57ccccca92c527417551ab9470b
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 //////////////////////////////////////////////////////////////////////////////
32 class FmFormModel;
33 class FmFormPage;
34 class E3dView;
35 class E3dPolyScene;
36 class E3dObject;
38 //////////////////////////////////////////////////////////////////////////////
40 #define PREVIEW_OBJECTTYPE_SPHERE 0x0000
41 #define PREVIEW_OBJECTTYPE_CUBE 0x0001
43 //////////////////////////////////////////////////////////////////////////////
45 class SVX_DLLPUBLIC Svx3DPreviewControl : public Control
47 protected:
48 FmFormModel* mpModel;
49 FmFormPage* mpFmPage;
50 E3dView* mp3DView;
51 E3dPolyScene* mpScene;
52 E3dObject* mp3DObj;
53 sal_uInt16 mnObjectType;
55 void Construct();
57 public:
58 Svx3DPreviewControl(Window* pParent, const ResId& rResId);
59 Svx3DPreviewControl(Window* pParent, WinBits nStyle = 0);
60 ~Svx3DPreviewControl();
62 virtual void Paint( const Rectangle& rRect );
63 virtual void MouseButtonDown( const MouseEvent& rMEvt );
64 virtual void Resize();
66 void Reset();
67 virtual void SetObjectType(sal_uInt16 nType);
68 sal_uInt16 GetObjectType() const { return( mnObjectType ); }
69 SfxItemSet Get3DAttributes() const;
70 virtual void Set3DAttributes(const SfxItemSet& rAttr);
73 //////////////////////////////////////////////////////////////////////////////
75 class SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
77 // Callback for interactive changes
78 Link maUserInteractiveChangeCallback;
79 Link maUserSelectionChangeCallback;
80 Link maChangeCallback;
81 Link maSelectionChangeCallback;
83 // lights
84 sal_uInt32 maSelectedLight;
86 // extra objects for light control
87 E3dObject* mpExpansionObject;
88 E3dObject* mpLampBottomObject;
89 E3dObject* mpLampShaftObject;
90 std::vector< E3dObject* > maLightObjects;
92 // 3d rotations of object
93 double mfRotateX;
94 double mfRotateY;
95 double mfRotateZ;
97 // interaction parameters
98 Point maActionStartPoint;
99 sal_Int32 mnInteractionStartDistance;
100 double mfSaveActionStartHor;
101 double mfSaveActionStartVer;
102 double mfSaveActionStartRotZ;
104 // bitfield
105 unsigned mbMouseMoved : 1;
106 unsigned mbGeometrySelected : 1;
108 void Construct2();
109 void ConstructLightObjects();
110 void AdaptToSelectedLight();
111 void TrySelection(Point aPosPixel);
113 public:
114 Svx3DLightControl(Window* pParent, WinBits nStyle = 0);
115 ~Svx3DLightControl();
117 virtual void Paint(const Rectangle& rRect);
118 virtual void MouseButtonDown(const MouseEvent& rMEvt);
119 virtual void Tracking( const TrackingEvent& rTEvt );
120 virtual void Resize();
122 virtual void SetObjectType(sal_uInt16 nType);
124 // register user callback
125 void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
126 void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
127 void SetChangeCallback(Link aNew) { maChangeCallback = aNew; }
128 void SetSelectionChangeCallback(Link aNew) { maSelectionChangeCallback = aNew; }
130 // selection checks
131 bool IsSelectionValid();
132 bool IsGeometrySelected() { return mbGeometrySelected; }
134 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
135 void GetPosition(double& rHor, double& rVer);
136 void SetPosition(double fHor, double fVer);
138 // get/set rotation of 3D object
139 void SetRotation(double fRotX, double fRotY, double fRotZ);
140 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
142 void SelectLight(sal_uInt32 nLightNumber);
143 virtual void Set3DAttributes(const SfxItemSet& rAttr);
144 sal_uInt32 GetSelectedLight() { return maSelectedLight; }
146 // light data access
147 bool GetLightOnOff(sal_uInt32 nNum) const;
148 Color GetLightColor(sal_uInt32 nNum) const;
149 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
152 //////////////////////////////////////////////////////////////////////////////
154 class SVX_DLLPUBLIC SvxLightCtl3D : public Control
156 private:
157 // local controls
158 Svx3DLightControl maLightControl;
159 ScrollBar maHorScroller;
160 ScrollBar maVerScroller;
161 PushButton maSwitcher;
163 // callback for interactive changes
164 Link maUserInteractiveChangeCallback;
165 Link maUserSelectionChangeCallback;
167 public:
168 SvxLightCtl3D( Window* pParent, const ResId& rResId);
169 ~SvxLightCtl3D();
171 // react to size changes
172 virtual void Resize();
173 void NewLayout();
175 // check the selection for validity
176 void CheckSelection();
178 // bring further settings to the outside world
179 Svx3DLightControl& GetSvx3DLightControl() { return maLightControl; }
181 // register user callback
182 void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
183 void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
185 virtual void KeyInput( const KeyEvent& rKEvt );
186 virtual void GetFocus();
187 virtual void LoseFocus();
189 protected:
191 DECL_LINK( InternalInteractiveChange, void*);
192 DECL_LINK( InternalSelectionChange, void*);
193 DECL_LINK( ScrollBarMove, void*);
194 DECL_LINK( ButtonPress, void*);
196 // initialize local parameters
197 void Init();
199 void move( double fDeltaHor, double fDeltaVer );
202 #endif // _SCH_DLGCTL3D_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */