xref: /AOO41X/main/svx/source/sidebar/possize/PosSizePropertyPanel.hxx (revision 1076d7f73c4ccb73c6199b08a0bce9e55e3f77fa)
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     // images from ressource
129     Image                                   maImgFlipHori;
130     Image                                   maImgFlipVert;
131 
132     cssu::Reference< css::frame::XFrame >   mxFrame;
133     ::sfx2::sidebar::EnumContext            maContext;
134     SfxBindings*                            mpBindings;
135 
136     /// bitfield
137     bool                                    mbMtrPosXMirror : 1;
138     bool                                    mbSizeProtected : 1;
139     bool                                    mbPositionProtected : 1;
140     bool                                    mbAutoWidth : 1;
141     bool                                    mbAutoHeight : 1;
142     bool                                    mbAdjustEnabled : 1;
143     bool                                    mbIsFlip : 1;
144     bool                                    mbInDestructor : 1;
145 
146     cssu::Reference<css::ui::XSidebar> mxSidebar;
147 
148     DECL_LINK( ChangePosXHdl, void * );
149     DECL_LINK( ChangePosYHdl, void * );
150     DECL_LINK( ChangeWidthHdl, void * );
151     DECL_LINK( ChangeHeightHdl, void * );
152     DECL_LINK( ClickAutoHdl, void * );
153     DECL_LINK( AngleModifiedHdl, void * );
154     DECL_LINK( RotationHdl, void * );
155     DECL_LINK( FlipHdl, ToolBox * );
156 
157     void SetupIcons(void);
158     void Initialize();
159     void executePosX();
160     void executePosY();
161     void executeSize();
162 
163     // constructor/destuctor
164     PosSizePropertyPanel(
165         Window* pParent,
166         const cssu::Reference<css::frame::XFrame>& rxFrame,
167         SfxBindings* pBindings,
168         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
169     virtual ~PosSizePropertyPanel();
170 
171     void MetricState( SfxItemState eState, const SfxPoolItem* pState );
172     FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
173     void DisableControls();
174 };
175 
176 
177 } } // end of namespace svx::sidebar
178 
179 
180 
181 #endif // SVX_PROPERTYPANEL_POSIZEPAGE_HXX
182 
183 // eof
184