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 #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>
40 #define PREVIEW_OBJECTTYPE_SPHERE 0x0000
41 #define PREVIEW_OBJECTTYPE_CUBE 0x0001
45 class SVX_DLLPUBLIC Svx3DPreviewControl
: public Control
51 E3dPolyScene
* mpScene
;
53 sal_uInt16 mnObjectType
;
58 Svx3DPreviewControl(Window
* pParent
, const ResId
& rResId
);
59 Svx3DPreviewControl(Window
* pParent
, WinBits nStyle
= 0);
60 virtual ~Svx3DPreviewControl();
62 virtual void Paint( const Rectangle
& rRect
) SAL_OVERRIDE
;
63 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
64 virtual void Resize() SAL_OVERRIDE
;
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
);
75 class SVX_DLLPUBLIC Svx3DLightControl
: public Svx3DPreviewControl
77 // Callback for interactive changes
78 Link maUserInteractiveChangeCallback
;
79 Link maUserSelectionChangeCallback
;
80 Link maChangeCallback
;
81 Link maSelectionChangeCallback
;
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
97 // interaction parameters
98 Point maActionStartPoint
;
99 sal_Int32 mnInteractionStartDistance
;
100 double mfSaveActionStartHor
;
101 double mfSaveActionStartVer
;
102 double mfSaveActionStartRotZ
;
105 bool mbMouseMoved
: 1;
106 bool mbGeometrySelected
: 1;
109 void ConstructLightObjects();
110 void AdaptToSelectedLight();
111 void TrySelection(Point aPosPixel
);
114 Svx3DLightControl(Window
* pParent
, WinBits nStyle
= 0);
115 virtual ~Svx3DLightControl();
117 virtual void Paint(const Rectangle
& rRect
) SAL_OVERRIDE
;
118 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
119 virtual void Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
120 virtual void Resize() SAL_OVERRIDE
;
122 virtual void SetObjectType(sal_uInt16 nType
) SAL_OVERRIDE
;
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
; }
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
) SAL_OVERRIDE
;
144 sal_uInt32
GetSelectedLight() { return maSelectedLight
; }
147 bool GetLightOnOff(sal_uInt32 nNum
) const;
148 Color
GetLightColor(sal_uInt32 nNum
) const;
149 basegfx::B3DVector
GetLightDirection(sal_uInt32 nNum
) const;
154 class SVX_DLLPUBLIC SvxLightCtl3D
: public Control
158 Svx3DLightControl maLightControl
;
159 ScrollBar maHorScroller
;
160 ScrollBar maVerScroller
;
161 PushButton maSwitcher
;
163 // callback for interactive changes
164 Link maUserInteractiveChangeCallback
;
165 Link maUserSelectionChangeCallback
;
168 SvxLightCtl3D( Window
* pParent
, const ResId
& rResId
);
169 SvxLightCtl3D( Window
* pParent
);
170 virtual ~SvxLightCtl3D();
172 // react to size changes
173 virtual void Resize() SAL_OVERRIDE
;
176 // check the selection for validity
177 void CheckSelection();
179 // bring further settings to the outside world
180 Svx3DLightControl
& GetSvx3DLightControl() { return maLightControl
; }
182 // register user callback
183 void SetUserInteractiveChangeCallback(Link aNew
) { maUserInteractiveChangeCallback
= aNew
; }
184 void SetUserSelectionChangeCallback(Link aNew
) { maUserSelectionChangeCallback
= aNew
; }
186 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
187 virtual void GetFocus() SAL_OVERRIDE
;
188 virtual void LoseFocus() SAL_OVERRIDE
;
190 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
194 DECL_LINK( InternalInteractiveChange
, void*);
195 DECL_LINK( InternalSelectionChange
, void*);
196 DECL_LINK( ScrollBarMove
, void*);
197 DECL_LINK( ButtonPress
, void*);
199 // initialize local parameters
202 void move( double fDeltaHor
, double fDeltaVer
);
205 #endif // _SCH_DLGCTL3D_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */