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>
30 //////////////////////////////////////////////////////////////////////////////
38 //////////////////////////////////////////////////////////////////////////////
40 #define PREVIEW_OBJECTTYPE_SPHERE 0x0000
41 #define PREVIEW_OBJECTTYPE_CUBE 0x0001
43 //////////////////////////////////////////////////////////////////////////////
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 ~Svx3DPreviewControl();
62 virtual void Paint( const Rectangle
& rRect
);
63 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
64 virtual void Resize();
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
;
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 unsigned mbMouseMoved
: 1;
106 unsigned mbGeometrySelected
: 1;
109 void ConstructLightObjects();
110 void AdaptToSelectedLight();
111 void TrySelection(Point aPosPixel
);
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
; }
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
; }
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
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
);
171 // react to size changes
172 virtual void Resize();
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();
191 DECL_LINK( InternalInteractiveChange
, void*);
192 DECL_LINK( InternalSelectionChange
, void*);
193 DECL_LINK( ScrollBarMove
, void*);
194 DECL_LINK( ButtonPress
, void*);
196 // initialize local parameters
199 void move( double fDeltaHor
, double fDeltaVer
);
202 #endif // _SCH_DLGCTL3D_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */