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