1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVX_ORIENTHELPER_HXX 25cdf0e10cSrcweir #define SVX_ORIENTHELPER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <memory> 28cdf0e10cSrcweir #include <vcl/window.hxx> 29cdf0e10cSrcweir #include <sfx2/itemconnect.hxx> 30cdf0e10cSrcweir #include "svx/svxdllapi.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir class NumericField; 33cdf0e10cSrcweir class CheckBox; 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace svx { 36cdf0e10cSrcweir 37cdf0e10cSrcweir class DialControl; 38cdf0e10cSrcweir 39cdf0e10cSrcweir // ============================================================================ 40cdf0e10cSrcweir 41cdf0e10cSrcweir struct OrientationHelper_Impl; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** A helper class that manages a DialControl and a "Stacked text" check box. 44cdf0e10cSrcweir 45cdf0e10cSrcweir This helper remembers a DialControl for entering a rotation angle, and a 46cdf0e10cSrcweir check box for stacked text, that enables/disables other controls dependent 47cdf0e10cSrcweir on its state. 48cdf0e10cSrcweir 49cdf0e10cSrcweir It is possible to register more controls that have to be enabled/disabled 50cdf0e10cSrcweir together with this helper object (optionally dependent on the stacked text 51cdf0e10cSrcweir check box), using the function AddDependentWindow(). All registered windows 52cdf0e10cSrcweir are handled on a call of Enable(), or Show(), or on changing the state of 53cdf0e10cSrcweir the "Stacked text" check box. 54cdf0e10cSrcweir 55cdf0e10cSrcweir Note: The member function SetStackedState() should be used instead of 56cdf0e10cSrcweir direct modifications of the "Stacked text" check box. Otherwise the update 57cdf0e10cSrcweir mechanism of registered controls will not work. 58cdf0e10cSrcweir */ 59cdf0e10cSrcweir class SVX_DLLPUBLIC OrientationHelper 60cdf0e10cSrcweir { 61cdf0e10cSrcweir public: 62cdf0e10cSrcweir explicit OrientationHelper( 63cdf0e10cSrcweir DialControl& rCtrlDial, 64cdf0e10cSrcweir CheckBox& rCbStacked ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** @param rNfRotation A numeric field that will be connected to the DialControl. */ 67cdf0e10cSrcweir explicit OrientationHelper( 68cdf0e10cSrcweir DialControl& rCtrlDial, 69cdf0e10cSrcweir NumericField& rNfRotation, 70cdf0e10cSrcweir CheckBox& rCbStacked ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir virtual ~OrientationHelper(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** Registers the passed window to be enabled/disabled on call of Enable(). 75cdf0e10cSrcweir @param eDisableIfStacked 76cdf0e10cSrcweir STATE_CHECK: Window always disabled, if stacked text is turned on. 77cdf0e10cSrcweir STATE_NOCHECK: Window always disabled, if stacked text is turned off. 78cdf0e10cSrcweir STATE_DONTKNOW: Window will be enabled/disabled independent from stacked text. */ 79cdf0e10cSrcweir void AddDependentWindow( Window& rWindow, TriState eDisableIfStacked = STATE_DONTKNOW ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir /** Enables or disables the dial control and all dependent windows. */ 82cdf0e10cSrcweir void Enable( bool bEnable = true ); 83cdf0e10cSrcweir /** Disables the dial control and all dependent windows. */ Disable()84cdf0e10cSrcweir inline void Disable() { Enable( false ); } 85cdf0e10cSrcweir 86cdf0e10cSrcweir /** Shows or hides the dial control and all dependent windows. */ 87cdf0e10cSrcweir void Show( bool bShow = true ); 88cdf0e10cSrcweir /** Hides the dial control and all dependent windows. */ Hide()89cdf0e10cSrcweir inline void Hide() { Show( false ); } 90cdf0e10cSrcweir 91cdf0e10cSrcweir /** Sets the "stacked" check box to the passed state and updates dependent controls. */ 92cdf0e10cSrcweir void SetStackedState( TriState eState ); 93cdf0e10cSrcweir /** Returns the state of the "stacked" check box. */ 94cdf0e10cSrcweir TriState GetStackedState() const; 95cdf0e10cSrcweir 96cdf0e10cSrcweir /** Enables/disables the "don't know" state of the "Stacked text" check box. */ 97cdf0e10cSrcweir void EnableStackedTriState( bool bEnable = true ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir private: 100cdf0e10cSrcweir std::auto_ptr< OrientationHelper_Impl > mpImpl; 101cdf0e10cSrcweir }; 102cdf0e10cSrcweir 103cdf0e10cSrcweir // ============================================================================ 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** Wrapper for usage of the stacked attribute of an OrientationHelper in item connections. */ 106cdf0e10cSrcweir class SVX_DLLPUBLIC OrientStackedWrapper : public sfx::SingleControlWrapper< OrientationHelper, bool > 107cdf0e10cSrcweir { 108cdf0e10cSrcweir public: 109cdf0e10cSrcweir explicit OrientStackedWrapper( OrientationHelper& rOrientHlp ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual bool IsControlDontKnow() const; 112cdf0e10cSrcweir virtual void SetControlDontKnow( bool bSet ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual bool GetControlValue() const; 115cdf0e10cSrcweir virtual void SetControlValue( bool bValue ); 116cdf0e10cSrcweir }; 117cdf0e10cSrcweir 118cdf0e10cSrcweir // ---------------------------------------------------------------------------- 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** An item<->control connection for the stacked attribute of an OrientationHelper. */ 121cdf0e10cSrcweir typedef sfx::ItemControlConnection< sfx::BoolItemWrapper, OrientStackedWrapper > OrientStackedConnection; 122cdf0e10cSrcweir 123cdf0e10cSrcweir // ============================================================================ 124cdf0e10cSrcweir 125cdf0e10cSrcweir } // namespace 126cdf0e10cSrcweir 127cdf0e10cSrcweir #endif 128cdf0e10cSrcweir 129