1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef SVX_PROPERTYPANEL_POSIZEPAGE_HXX
23 #define SVX_PROPERTYPANEL_POSIZEPAGE_HXX
24 
25 #include <vcl/ctrl.hxx>
26 #include <sfx2/sidebar/SidebarPanelBase.hxx>
27 #include <sfx2/sidebar/ControllerItem.hxx>
28 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
29 #include <boost/scoped_ptr.hpp>
30 #include <svx/rectenum.hxx>
31 #include <svl/poolitem.hxx>
32 #include <tools/fldunit.hxx>
33 #include <com/sun/star/ui/XSidebar.hpp>
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 Control,
49     public ::sfx2::sidebar::IContextChangeReceiver,
50     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
51 {
52 public:
53     static PosSizePropertyPanel* Create(
54         Window* pParent,
55         const cssu::Reference<css::frame::XFrame>& rxFrame,
56         SfxBindings* pBindings,
57         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
58 
59     virtual void DataChanged(
60         const DataChangedEvent& rEvent);
61 
62     virtual void HandleContextChange(
63         const ::sfx2::sidebar::EnumContext aContext);
64 
65     virtual void NotifyItemUpdate(
66         const sal_uInt16 nSId,
67         const SfxItemState eState,
68         const SfxPoolItem* pState,
69         const bool bIsEnabled);
70 
71     SfxBindings* GetBindings();
72     void ShowMenu (void);
73 
74 private:
75     //Position
76     ::boost::scoped_ptr< FixedText >        mpFtPosX;
77     ::boost::scoped_ptr< MetricField >      mpMtrPosX;
78     ::boost::scoped_ptr< FixedText >        mpFtPosY;
79     ::boost::scoped_ptr< MetricField >      mpMtrPosY;
80 
81     // size
82     ::boost::scoped_ptr< FixedText >        mpFtWidth;
83     ::boost::scoped_ptr< MetricField >      mpMtrWidth;
84     ::boost::scoped_ptr< FixedText >        mpFtHeight;
85     ::boost::scoped_ptr< MetricField >      mpMtrHeight;
86     ::boost::scoped_ptr< CheckBox >         mpCbxScale;
87 
88     //rotation
89     ::boost::scoped_ptr< FixedText >        mpFtAngle;
90     ::boost::scoped_ptr< MetricBox >        mpMtrAngle;
91 
92     //rotation control
93     ::boost::scoped_ptr<SidebarDialControl> mpDial;
94 
95     //flip
96     ::boost::scoped_ptr< FixedText >        mpFtFlip;
97     ::boost::scoped_ptr< Window >           mpFlipTbxBackground;
98     ::boost::scoped_ptr< ToolBox >          mpFlipTbx;
99 
100     // Internal variables
101     Rectangle                               maRect;
102     const SdrView*                          mpView;
103     sal_uInt32                              mlOldWidth;
104     sal_uInt32                              mlOldHeight;
105     RECT_POINT                              meRP;
106     Point                                   maAnchorPos;    //anchor position
107     long                                    mlRotX;
108     long                                    mlRotY;
109     Fraction                                maUIScale;
110     SfxMapUnit                              mePoolUnit;
111     FieldUnit                               meDlgUnit;
112 
113     // Controller Items
114     ::sfx2::sidebar::ControllerItem         maTransfPosXControl;
115     ::sfx2::sidebar::ControllerItem         maTransfPosYControl;
116     ::sfx2::sidebar::ControllerItem         maTransfWidthControl;
117     ::sfx2::sidebar::ControllerItem         maTransfHeightControl;
118 
119     ::sfx2::sidebar::ControllerItem         maSvxAngleControl;
120     ::sfx2::sidebar::ControllerItem         maRotXControl;
121     ::sfx2::sidebar::ControllerItem         maRotYControl;
122     ::sfx2::sidebar::ControllerItem         maProPosControl;
123     ::sfx2::sidebar::ControllerItem         maProSizeControl;
124     ::sfx2::sidebar::ControllerItem         maAutoWidthControl;
125     ::sfx2::sidebar::ControllerItem         maAutoHeightControl;
126     ::sfx2::sidebar::ControllerItem         m_aMetricCtl;
127 
128     cssu::Reference< css::frame::XFrame >   mxFrame;
129     ::sfx2::sidebar::EnumContext            maContext;
130     SfxBindings*                            mpBindings;
131 
132     // to remember original positions for restoring these for different layouts
133     Point                                   maFtWidthOrigPos;
134     Point                                   maMtrWidthOrigPos;
135     Point                                   maFtHeightOrigPos;
136     Point                                   maMtrHeightOrigPos;
137     Point                                   maCbxScaleOrigPos;
138     Point                                   maFtAngleOrigPos;
139     Point                                   maMtrAnglOrigPos;
140     Point                                   maFlipTbxOrigPos;
141     Point                                   maDialOrigPos;
142     Point                                   maFtFlipOrigPos;
143 
144     /// bitfield
145     bool                                    mbMtrPosXMirror : 1;
146     bool                                    mbSizeProtected : 1;
147     bool                                    mbPositionProtected : 1;
148     bool                                    mbAutoWidth : 1;
149     bool                                    mbAutoHeight : 1;
150     bool                                    mbAdjustEnabled : 1;
151     bool                                    mbIsFlip : 1;
152 
153     cssu::Reference<css::ui::XSidebar> mxSidebar;
154 
155     DECL_LINK( ChangePosXHdl, void * );
156     DECL_LINK( ChangePosYHdl, void * );
157     DECL_LINK( ChangeWidthHdl, void * );
158     DECL_LINK( ChangeHeightHdl, void * );
159     DECL_LINK( ClickAutoHdl, void * );
160     DECL_LINK( AngleModifiedHdl, void * );
161     DECL_LINK( RotationHdl, void * );
162     DECL_LINK( FlipHdl, ToolBox * );
163 
164     void SetupIcons(void);
165     void Initialize();
166     void executePosX();
167     void executePosY();
168     void executeSize();
169 
170     // constructor/destuctor
171     PosSizePropertyPanel(
172         Window* pParent,
173         const cssu::Reference<css::frame::XFrame>& rxFrame,
174         SfxBindings* pBindings,
175         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
176     virtual ~PosSizePropertyPanel();
177 
178     void MetricState( SfxItemState eState, const SfxPoolItem* pState );
179     FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
180     void DisableControls();
181     void AdaptWidthHeightScalePosition(bool bOriginal);
182     void AdaptAngleFlipDialPosition(bool bOriginal);
183 };
184 
185 
186 } } // end of namespace svx::sidebar
187 
188 
189 
190 #endif // SVX_PROPERTYPANEL_POSIZEPAGE_HXX
191 
192 // eof
193