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