15d39f272SZheng Fan /************************************************************** 25d39f272SZheng Fan * 35d39f272SZheng Fan * Licensed to the Apache Software Foundation (ASF) under one 45d39f272SZheng Fan * or more contributor license agreements. See the NOTICE file 55d39f272SZheng Fan * distributed with this work for additional information 65d39f272SZheng Fan * regarding copyright ownership. The ASF licenses this file 75d39f272SZheng Fan * to you under the Apache License, Version 2.0 (the 85d39f272SZheng Fan * "License"); you may not use this file except in compliance 95d39f272SZheng Fan * with the License. You may obtain a copy of the License at 105d39f272SZheng Fan * 115d39f272SZheng Fan * http://www.apache.org/licenses/LICENSE-2.0 125d39f272SZheng Fan * 135d39f272SZheng Fan * Unless required by applicable law or agreed to in writing, 145d39f272SZheng Fan * software distributed under the License is distributed on an 155d39f272SZheng Fan * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165d39f272SZheng Fan * KIND, either express or implied. See the License for the 175d39f272SZheng Fan * specific language governing permissions and limitations 185d39f272SZheng Fan * under the License. 195d39f272SZheng Fan * 205d39f272SZheng Fan *************************************************************/ 215d39f272SZheng Fan 225d39f272SZheng Fan #ifndef SVX_PROPERTYPANEL_POSIZEPAGE_HXX 235d39f272SZheng Fan #define SVX_PROPERTYPANEL_POSIZEPAGE_HXX 245d39f272SZheng Fan 255d39f272SZheng Fan #include <vcl/ctrl.hxx> 265d39f272SZheng Fan #include <sfx2/sidebar/SidebarPanelBase.hxx> 275d39f272SZheng Fan #include <sfx2/sidebar/ControllerItem.hxx> 285d39f272SZheng Fan #include <sfx2/sidebar/IContextChangeReceiver.hxx> 296a606da0SAndre Fischer #include <sfx2/sidebar/GridLayouter.hxx> 305d39f272SZheng Fan #include <boost/scoped_ptr.hpp> 315d39f272SZheng Fan #include <svx/rectenum.hxx> 325d39f272SZheng Fan #include <svl/poolitem.hxx> 335d39f272SZheng Fan #include <tools/fldunit.hxx> 3437fee4fdSAndre Fischer #include <com/sun/star/ui/XSidebar.hpp> 355d39f272SZheng Fan 365d39f272SZheng Fan class DialControl; 375d39f272SZheng Fan class SdrView; 385d39f272SZheng Fan class FixedText; 395d39f272SZheng Fan class MetricField; 405d39f272SZheng Fan class CheckBox; 415d39f272SZheng Fan class MetricBox; 425d39f272SZheng Fan 435d39f272SZheng Fan 445d39f272SZheng Fan namespace svx { namespace sidebar { 455d39f272SZheng Fan 465d39f272SZheng Fan class SidebarDialControl; 475d39f272SZheng Fan 485d39f272SZheng Fan class PosSizePropertyPanel 495d39f272SZheng Fan : public Control, 505d39f272SZheng Fan public ::sfx2::sidebar::IContextChangeReceiver, 515d39f272SZheng Fan public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface 525d39f272SZheng Fan { 535d39f272SZheng Fan public: 545d39f272SZheng Fan static PosSizePropertyPanel* Create( 555d39f272SZheng Fan Window* pParent, 565d39f272SZheng Fan const cssu::Reference<css::frame::XFrame>& rxFrame, 5737fee4fdSAndre Fischer SfxBindings* pBindings, 5837fee4fdSAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar); 595d39f272SZheng Fan 605d39f272SZheng Fan virtual void DataChanged( 615d39f272SZheng Fan const DataChangedEvent& rEvent); 625d39f272SZheng Fan 635d39f272SZheng Fan virtual void HandleContextChange( 645d39f272SZheng Fan const ::sfx2::sidebar::EnumContext aContext); 655d39f272SZheng Fan 665d39f272SZheng Fan virtual void NotifyItemUpdate( 675d39f272SZheng Fan const sal_uInt16 nSId, 685d39f272SZheng Fan const SfxItemState eState, 6945da7d5eSAndre Fischer const SfxPoolItem* pState, 7045da7d5eSAndre Fischer const bool bIsEnabled); 715d39f272SZheng Fan 725d39f272SZheng Fan SfxBindings* GetBindings(); 735d39f272SZheng Fan void ShowMenu (void); 745d39f272SZheng Fan 756a606da0SAndre Fischer virtual void Resize (void); 766a606da0SAndre Fischer 775d39f272SZheng Fan private: 785d39f272SZheng Fan //Position 795d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtPosX; 805d39f272SZheng Fan ::boost::scoped_ptr< MetricField > mpMtrPosX; 815d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtPosY; 825d39f272SZheng Fan ::boost::scoped_ptr< MetricField > mpMtrPosY; 835d39f272SZheng Fan 845d39f272SZheng Fan // size 855d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtWidth; 865d39f272SZheng Fan ::boost::scoped_ptr< MetricField > mpMtrWidth; 875d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtHeight; 885d39f272SZheng Fan ::boost::scoped_ptr< MetricField > mpMtrHeight; 895d39f272SZheng Fan ::boost::scoped_ptr< CheckBox > mpCbxScale; 905d39f272SZheng Fan 915d39f272SZheng Fan //rotation 925d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtAngle; 935d39f272SZheng Fan ::boost::scoped_ptr< MetricBox > mpMtrAngle; 945d39f272SZheng Fan 955d39f272SZheng Fan //rotation control 965d39f272SZheng Fan ::boost::scoped_ptr<SidebarDialControl> mpDial; 975d39f272SZheng Fan 985d39f272SZheng Fan //flip 995d39f272SZheng Fan ::boost::scoped_ptr< FixedText > mpFtFlip; 1005d39f272SZheng Fan ::boost::scoped_ptr< Window > mpFlipTbxBackground; 1015d39f272SZheng Fan ::boost::scoped_ptr< ToolBox > mpFlipTbx; 1025d39f272SZheng Fan 1035d39f272SZheng Fan // Internal variables 1045d39f272SZheng Fan Rectangle maRect; 1055d39f272SZheng Fan const SdrView* mpView; 1065d39f272SZheng Fan sal_uInt32 mlOldWidth; 1075d39f272SZheng Fan sal_uInt32 mlOldHeight; 1085d39f272SZheng Fan RECT_POINT meRP; 1095d39f272SZheng Fan Point maAnchorPos; //anchor position 1105d39f272SZheng Fan long mlRotX; 1115d39f272SZheng Fan long mlRotY; 1125d39f272SZheng Fan Fraction maUIScale; 1135d39f272SZheng Fan SfxMapUnit mePoolUnit; 1145d39f272SZheng Fan FieldUnit meDlgUnit; 1155d39f272SZheng Fan 1165d39f272SZheng Fan // Controller Items 1175d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maTransfPosXControl; 1185d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maTransfPosYControl; 1195d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maTransfWidthControl; 1205d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maTransfHeightControl; 1215d39f272SZheng Fan 1225d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maSvxAngleControl; 1235d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maRotXControl; 1245d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maRotYControl; 1255d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maProPosControl; 1265d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maProSizeControl; 1275d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maAutoWidthControl; 1285d39f272SZheng Fan ::sfx2::sidebar::ControllerItem maAutoHeightControl; 1295d39f272SZheng Fan ::sfx2::sidebar::ControllerItem m_aMetricCtl; 1305d39f272SZheng Fan 1315d39f272SZheng Fan cssu::Reference< css::frame::XFrame > mxFrame; 1325d39f272SZheng Fan ::sfx2::sidebar::EnumContext maContext; 1335d39f272SZheng Fan SfxBindings* mpBindings; 1345d39f272SZheng Fan 135d74d90d6SArmin Le Grand // to remember original positions for restoring these for different layouts 136d74d90d6SArmin Le Grand Point maFtWidthOrigPos; 137d74d90d6SArmin Le Grand Point maMtrWidthOrigPos; 138d74d90d6SArmin Le Grand Point maFtHeightOrigPos; 139d74d90d6SArmin Le Grand Point maMtrHeightOrigPos; 140d74d90d6SArmin Le Grand Point maCbxScaleOrigPos; 141d74d90d6SArmin Le Grand Point maFtAngleOrigPos; 142d74d90d6SArmin Le Grand Point maMtrAnglOrigPos; 143d74d90d6SArmin Le Grand Point maFlipTbxOrigPos; 144d74d90d6SArmin Le Grand Point maDialOrigPos; 145d74d90d6SArmin Le Grand Point maFtFlipOrigPos; 146d74d90d6SArmin Le Grand 1475d39f272SZheng Fan /// bitfield 1485d39f272SZheng Fan bool mbMtrPosXMirror : 1; 1495d39f272SZheng Fan bool mbSizeProtected : 1; 1505d39f272SZheng Fan bool mbPositionProtected : 1; 1515d39f272SZheng Fan bool mbAutoWidth : 1; 1525d39f272SZheng Fan bool mbAutoHeight : 1; 1535d39f272SZheng Fan bool mbAdjustEnabled : 1; 1545d39f272SZheng Fan bool mbIsFlip : 1; 1555d39f272SZheng Fan 15637fee4fdSAndre Fischer cssu::Reference<css::ui::XSidebar> mxSidebar; 1576a606da0SAndre Fischer ::sfx2::sidebar::GridLayouter maLayouter; 15837fee4fdSAndre Fischer 1595d39f272SZheng Fan DECL_LINK( ChangePosXHdl, void * ); 1605d39f272SZheng Fan DECL_LINK( ChangePosYHdl, void * ); 1615d39f272SZheng Fan DECL_LINK( ChangeWidthHdl, void * ); 1625d39f272SZheng Fan DECL_LINK( ChangeHeightHdl, void * ); 1635d39f272SZheng Fan DECL_LINK( ClickAutoHdl, void * ); 1645d39f272SZheng Fan DECL_LINK( AngleModifiedHdl, void * ); 1655d39f272SZheng Fan DECL_LINK( RotationHdl, void * ); 1665d39f272SZheng Fan DECL_LINK( FlipHdl, ToolBox * ); 1675d39f272SZheng Fan 1685d39f272SZheng Fan void SetupIcons(void); 1695d39f272SZheng Fan void Initialize(); 1705d39f272SZheng Fan void executePosX(); 1715d39f272SZheng Fan void executePosY(); 1725d39f272SZheng Fan void executeSize(); 1735d39f272SZheng Fan 1745d39f272SZheng Fan // constructor/destuctor 1755d39f272SZheng Fan PosSizePropertyPanel( 1765d39f272SZheng Fan Window* pParent, 1775d39f272SZheng Fan const cssu::Reference<css::frame::XFrame>& rxFrame, 17837fee4fdSAndre Fischer SfxBindings* pBindings, 17937fee4fdSAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar); 1805d39f272SZheng Fan virtual ~PosSizePropertyPanel(); 1815d39f272SZheng Fan 1825d39f272SZheng Fan void MetricState( SfxItemState eState, const SfxPoolItem* pState ); 1835d39f272SZheng Fan FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState ); 1845d39f272SZheng Fan void DisableControls(); 185d74d90d6SArmin Le Grand void AdaptWidthHeightScalePosition(bool bOriginal); 186d74d90d6SArmin Le Grand void AdaptAngleFlipDialPosition(bool bOriginal); 187*5f79b2b9SAndre Fischer 188*5f79b2b9SAndre Fischer /** Check if the UI scale has changed and handle such a change. 189*5f79b2b9SAndre Fischer UI scale is an SD only feature. The UI scale is represented by items 190*5f79b2b9SAndre Fischer ATTR_OPTIONS_SCALE_X and 191*5f79b2b9SAndre Fischer ATTR_OPTIONS_SCALE_Y. 192*5f79b2b9SAndre Fischer As we have no direct access (there is no dependency of svx on sd) we have to 193*5f79b2b9SAndre Fischer use a small trick (aka hack): 194*5f79b2b9SAndre Fischer a) call this method whenever a change of the metric item is notified, 195*5f79b2b9SAndre Fischer b) check if the UI scale has changed (strangely, the UI scale value is available at the SdrModel. 196*5f79b2b9SAndre Fischer c) invalidate the items for position and size to trigger notifications of their current values. 197*5f79b2b9SAndre Fischer */ 198*5f79b2b9SAndre Fischer void UpdateUIScale (void); 1995d39f272SZheng Fan }; 2005d39f272SZheng Fan 2015d39f272SZheng Fan 2025d39f272SZheng Fan } } // end of namespace svx::sidebar 2035d39f272SZheng Fan 2045d39f272SZheng Fan 2055d39f272SZheng Fan 2065d39f272SZheng Fan #endif // SVX_PROPERTYPANEL_POSIZEPAGE_HXX 2074e8031e0SArmin Le Grand 2084e8031e0SArmin Le Grand // eof 209