xref: /AOO41X/main/svx/source/sidebar/possize/PosSizePropertyPanel.hxx (revision 8f1fbbb1afe595bfe42e45111a275c4b01e370f1)
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 
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 
58     virtual void DataChanged(
59         const DataChangedEvent& rEvent);
60 
61     virtual void HandleContextChange(
62         const ::sfx2::sidebar::EnumContext aContext);
63 
64     virtual void NotifyItemUpdate(
65         const sal_uInt16 nSId,
66         const SfxItemState eState,
67         const SfxPoolItem* pState);
68 
69     SfxBindings* GetBindings();
70     void ShowMenu (void);
71 
72 private:
73     //Position
74     ::boost::scoped_ptr< FixedText >        mpFtPosX;
75     ::boost::scoped_ptr< MetricField >      mpMtrPosX;
76     ::boost::scoped_ptr< FixedText >        mpFtPosY;
77     ::boost::scoped_ptr< MetricField >      mpMtrPosY;
78 
79     // size
80     ::boost::scoped_ptr< FixedText >        mpFtWidth;
81     ::boost::scoped_ptr< MetricField >      mpMtrWidth;
82     ::boost::scoped_ptr< FixedText >        mpFtHeight;
83     ::boost::scoped_ptr< MetricField >      mpMtrHeight;
84     ::boost::scoped_ptr< CheckBox >         mpCbxScale;
85 
86     //rotation
87     ::boost::scoped_ptr< FixedText >        mpFtAngle;
88     ::boost::scoped_ptr< MetricBox >        mpMtrAngle;
89 
90     //rotation control
91     ::boost::scoped_ptr<SidebarDialControl> mpDial;
92 
93     //flip
94     ::boost::scoped_ptr< FixedText >        mpFtFlip;
95     ::boost::scoped_ptr< Window >           mpFlipTbxBackground;
96     ::boost::scoped_ptr< ToolBox >          mpFlipTbx;
97 
98     // Internal variables
99     Rectangle                               maRect;
100     const SdrView*                          mpView;
101     sal_uInt32                              mlOldWidth;
102     sal_uInt32                              mlOldHeight;
103     RECT_POINT                              meRP;
104     Point                                   maAnchorPos;    //anchor position
105     long                                    mlRotX;
106     long                                    mlRotY;
107     Fraction                                maUIScale;
108     SfxMapUnit                              mePoolUnit;
109     FieldUnit                               meDlgUnit;
110 
111     // Controller Items
112     ::sfx2::sidebar::ControllerItem         maTransfPosXControl;
113     ::sfx2::sidebar::ControllerItem         maTransfPosYControl;
114     ::sfx2::sidebar::ControllerItem         maTransfWidthControl;
115     ::sfx2::sidebar::ControllerItem         maTransfHeightControl;
116 
117     ::sfx2::sidebar::ControllerItem         maSvxAngleControl;
118     ::sfx2::sidebar::ControllerItem         maRotXControl;
119     ::sfx2::sidebar::ControllerItem         maRotYControl;
120     ::sfx2::sidebar::ControllerItem         maProPosControl;
121     ::sfx2::sidebar::ControllerItem         maProSizeControl;
122     ::sfx2::sidebar::ControllerItem         maAutoWidthControl;
123     ::sfx2::sidebar::ControllerItem         maAutoHeightControl;
124     ::sfx2::sidebar::ControllerItem         m_aMetricCtl;
125 
126     // images from ressource
127     Image                                   maImgFlipHori;
128     Image                                   maImgFlipVert;
129 
130     cssu::Reference< css::frame::XFrame >   mxFrame;
131     ::sfx2::sidebar::EnumContext            maContext;
132     SfxBindings*                            mpBindings;
133 
134     /// bitfield
135     bool                                    mbMtrPosXMirror : 1;
136     bool                                    mbSizeProtected : 1;
137     bool                                    mbPositionProtected : 1;
138     bool                                    mbAutoWidth : 1;
139     bool                                    mbAutoHeight : 1;
140     bool                                    mbAdjustEnabled : 1;
141     bool                                    mbIsFlip : 1;
142     bool                                    mbInDestructor : 1;
143 
144     DECL_LINK( ChangePosXHdl, void * );
145     DECL_LINK( ChangePosYHdl, void * );
146     DECL_LINK( ChangeWidthHdl, void * );
147     DECL_LINK( ChangeHeightHdl, void * );
148     DECL_LINK( ClickAutoHdl, void * );
149     DECL_LINK( AngleModifiedHdl, void * );
150     DECL_LINK( RotationHdl, void * );
151     DECL_LINK( FlipHdl, ToolBox * );
152 
153     void SetupIcons(void);
154     void Initialize();
155     void executePosX();
156     void executePosY();
157     void executeSize();
158 
159     // constructor/destuctor
160     PosSizePropertyPanel(
161         Window* pParent,
162         const cssu::Reference<css::frame::XFrame>& rxFrame,
163         SfxBindings* pBindings);
164     virtual ~PosSizePropertyPanel();
165 
166     void MetricState( SfxItemState eState, const SfxPoolItem* pState );
167     FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
168     void DisableControls();
169 };
170 
171 
172 } } // end of namespace svx::sidebar
173 
174 
175 
176 #endif // SVX_PROPERTYPANEL_POSIZEPAGE_HXX
177