Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
20 : #define INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
21 :
22 : #include <vcl/ctrl.hxx>
23 : #include <sfx2/sidebar/SidebarPanelBase.hxx>
24 : #include <sfx2/sidebar/ControllerItem.hxx>
25 : #include <sfx2/sidebar/IContextChangeReceiver.hxx>
26 : #include <boost/scoped_ptr.hpp>
27 : #include <svx/rectenum.hxx>
28 : #include <svx/sidebar/PanelLayout.hxx>
29 : #include <svl/poolitem.hxx>
30 : #include <tools/fldunit.hxx>
31 : #include <tools/fract.hxx>
32 : #include <com/sun/star/ui/XSidebar.hpp>
33 : #include <basegfx/range/b2drange.hxx>
34 :
35 : class DialControl;
36 : class SdrView;
37 : class FixedText;
38 : class MetricField;
39 : class CheckBox;
40 : class MetricBox;
41 :
42 :
43 : namespace svx { namespace sidebar {
44 :
45 : class SidebarDialControl;
46 :
47 : class PosSizePropertyPanel
48 : : public PanelLayout,
49 : public ::sfx2::sidebar::IContextChangeReceiver,
50 : public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
51 : {
52 : public:
53 : virtual ~PosSizePropertyPanel();
54 : virtual void dispose() SAL_OVERRIDE;
55 :
56 : static VclPtr<vcl::Window> Create(
57 : vcl::Window* pParent,
58 : const css::uno::Reference<css::frame::XFrame>& rxFrame,
59 : SfxBindings* pBindings,
60 : const css::uno::Reference<css::ui::XSidebar>& rxSidebar);
61 :
62 : virtual void DataChanged(
63 : const DataChangedEvent& rEvent) SAL_OVERRIDE;
64 :
65 : virtual void HandleContextChange(
66 : const ::sfx2::sidebar::EnumContext& rContext) SAL_OVERRIDE;
67 :
68 : virtual void NotifyItemUpdate(
69 : const sal_uInt16 nSId,
70 : const SfxItemState eState,
71 : const SfxPoolItem* pState,
72 : const bool bIsEnabled) SAL_OVERRIDE;
73 :
74 0 : SfxBindings* GetBindings() { return mpBindings;}
75 :
76 : // constructor/destuctor
77 : PosSizePropertyPanel(
78 : vcl::Window* pParent,
79 : const css::uno::Reference<css::frame::XFrame>& rxFrame,
80 : SfxBindings* pBindings,
81 : const css::uno::Reference<css::ui::XSidebar>& rxSidebar);
82 :
83 : private:
84 : //Position
85 : VclPtr<FixedText> mpFtPosX;
86 : VclPtr<MetricField> mpMtrPosX;
87 : VclPtr<FixedText> mpFtPosY;
88 : VclPtr<MetricField> mpMtrPosY;
89 :
90 : // size
91 : VclPtr<FixedText> mpFtWidth;
92 : VclPtr<MetricField> mpMtrWidth;
93 : VclPtr<FixedText> mpFtHeight;
94 : VclPtr<MetricField> mpMtrHeight;
95 : VclPtr<CheckBox> mpCbxScale;
96 :
97 : //rotation
98 : VclPtr<FixedText> mpFtAngle;
99 : VclPtr<MetricBox> mpMtrAngle;
100 :
101 : //rotation control
102 : VclPtr<SidebarDialControl> mpDial;
103 :
104 : //flip
105 : VclPtr<FixedText> mpFtFlip;
106 : VclPtr<ToolBox> mpFlipTbx;
107 :
108 : // Internal variables
109 : basegfx::B2DRange maRect;
110 : basegfx::B2DRange maWorkArea;
111 : const SdrView* mpView;
112 : sal_uInt32 mlOldWidth;
113 : sal_uInt32 mlOldHeight;
114 : RECT_POINT meRP;
115 : Point maAnchorPos; //anchor position
116 : long mlRotX;
117 : long mlRotY;
118 : Fraction maUIScale;
119 : SfxMapUnit mePoolUnit;
120 : FieldUnit meDlgUnit;
121 :
122 : // Controller Items
123 : ::sfx2::sidebar::ControllerItem maTransfPosXControl;
124 : ::sfx2::sidebar::ControllerItem maTransfPosYControl;
125 : ::sfx2::sidebar::ControllerItem maTransfWidthControl;
126 : ::sfx2::sidebar::ControllerItem maTransfHeightControl;
127 :
128 : ::sfx2::sidebar::ControllerItem maSvxAngleControl;
129 : ::sfx2::sidebar::ControllerItem maRotXControl;
130 : ::sfx2::sidebar::ControllerItem maRotYControl;
131 : ::sfx2::sidebar::ControllerItem maProPosControl;
132 : ::sfx2::sidebar::ControllerItem maProSizeControl;
133 : ::sfx2::sidebar::ControllerItem maAutoWidthControl;
134 : ::sfx2::sidebar::ControllerItem maAutoHeightControl;
135 : ::sfx2::sidebar::ControllerItem m_aMetricCtl;
136 :
137 : css::uno::Reference< css::frame::XFrame > mxFrame;
138 : ::sfx2::sidebar::EnumContext maContext;
139 : SfxBindings* mpBindings;
140 :
141 : /// bitfield
142 : bool mbMtrPosXMirror : 1;
143 : bool mbSizeProtected : 1;
144 : bool mbPositionProtected : 1;
145 : bool mbAutoWidth : 1;
146 : bool mbAutoHeight : 1;
147 : bool mbAdjustEnabled : 1;
148 : bool mbIsFlip : 1;
149 :
150 : css::uno::Reference<css::ui::XSidebar> mxSidebar;
151 :
152 : DECL_LINK( ChangePosXHdl, void * );
153 : DECL_LINK( ChangePosYHdl, void * );
154 : DECL_LINK( ChangeWidthHdl, void * );
155 : DECL_LINK( ChangeHeightHdl, void * );
156 : DECL_LINK( ClickAutoHdl, void * );
157 : DECL_LINK( AngleModifiedHdl, void * );
158 : DECL_LINK( RotationHdl, void * );
159 : DECL_LINK_TYPED( FlipHdl, ToolBox *, void );
160 :
161 : static void SetupIcons();
162 : void Initialize();
163 : void executePosX();
164 : void executePosY();
165 : void executeSize();
166 :
167 : void MetricState( SfxItemState eState, const SfxPoolItem* pState );
168 : static FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
169 : void DisableControls();
170 : void SetPosXYMinMax();
171 :
172 : /** Check if the UI scale has changed and handle such a change.
173 : UI scale is an SD only feature. The UI scale is represented by items
174 : ATTR_OPTIONS_SCALE_X and
175 : ATTR_OPTIONS_SCALE_Y.
176 : As we have no direct access (there is no dependency of svx on sd) we have to
177 : use a small trick (aka hack):
178 : a) call this method whenever a change of the metric item is notified,
179 : b) check if the UI scale has changed (strangely, the UI scale value is available at the SdrModel.
180 : c) invalidate the items for position and size to trigger notifications of their current values.
181 : */
182 : void UpdateUIScale();
183 : };
184 :
185 :
186 : } } // end of namespace svx::sidebar
187 :
188 :
189 :
190 : #endif // INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
191 :
192 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|