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 23 24 #ifndef SVX_ORIENTHELPER_HXX 25 #define SVX_ORIENTHELPER_HXX 26 27 #include <memory> 28 #include <vcl/window.hxx> 29 #include <sfx2/itemconnect.hxx> 30 #include "svx/svxdllapi.h" 31 32 class NumericField; 33 class CheckBox; 34 35 namespace svx { 36 37 class DialControl; 38 39 // ============================================================================ 40 41 struct OrientationHelper_Impl; 42 43 /** A helper class that manages a DialControl and a "Stacked text" check box. 44 45 This helper remembers a DialControl for entering a rotation angle, and a 46 check box for stacked text, that enables/disables other controls dependent 47 on its state. 48 49 It is possible to register more controls that have to be enabled/disabled 50 together with this helper object (optionally dependent on the stacked text 51 check box), using the function AddDependentWindow(). All registered windows 52 are handled on a call of Enable(), or Show(), or on changing the state of 53 the "Stacked text" check box. 54 55 Note: The member function SetStackedState() should be used instead of 56 direct modifications of the "Stacked text" check box. Otherwise the update 57 mechanism of registered controls will not work. 58 */ 59 class SVX_DLLPUBLIC OrientationHelper 60 { 61 public: 62 explicit OrientationHelper( 63 DialControl& rCtrlDial, 64 CheckBox& rCbStacked ); 65 66 /** @param rNfRotation A numeric field that will be connected to the DialControl. */ 67 explicit OrientationHelper( 68 DialControl& rCtrlDial, 69 NumericField& rNfRotation, 70 CheckBox& rCbStacked ); 71 72 virtual ~OrientationHelper(); 73 74 /** Registers the passed window to be enabled/disabled on call of Enable(). 75 @param eDisableIfStacked 76 STATE_CHECK: Window always disabled, if stacked text is turned on. 77 STATE_NOCHECK: Window always disabled, if stacked text is turned off. 78 STATE_DONTKNOW: Window will be enabled/disabled independent from stacked text. */ 79 void AddDependentWindow( Window& rWindow, TriState eDisableIfStacked = STATE_DONTKNOW ); 80 81 /** Enables or disables the dial control and all dependent windows. */ 82 void Enable( bool bEnable = true ); 83 /** Disables the dial control and all dependent windows. */ Disable()84 inline void Disable() { Enable( false ); } 85 86 /** Shows or hides the dial control and all dependent windows. */ 87 void Show( bool bShow = true ); 88 /** Hides the dial control and all dependent windows. */ Hide()89 inline void Hide() { Show( false ); } 90 91 /** Sets the "stacked" check box to the passed state and updates dependent controls. */ 92 void SetStackedState( TriState eState ); 93 /** Returns the state of the "stacked" check box. */ 94 TriState GetStackedState() const; 95 96 /** Enables/disables the "don't know" state of the "Stacked text" check box. */ 97 void EnableStackedTriState( bool bEnable = true ); 98 99 private: 100 std::auto_ptr< OrientationHelper_Impl > mpImpl; 101 }; 102 103 // ============================================================================ 104 105 /** Wrapper for usage of the stacked attribute of an OrientationHelper in item connections. */ 106 class SVX_DLLPUBLIC OrientStackedWrapper : public sfx::SingleControlWrapper< OrientationHelper, bool > 107 { 108 public: 109 explicit OrientStackedWrapper( OrientationHelper& rOrientHlp ); 110 111 virtual bool IsControlDontKnow() const; 112 virtual void SetControlDontKnow( bool bSet ); 113 114 virtual bool GetControlValue() const; 115 virtual void SetControlValue( bool bValue ); 116 }; 117 118 // ---------------------------------------------------------------------------- 119 120 /** An item<->control connection for the stacked attribute of an OrientationHelper. */ 121 typedef sfx::ItemControlConnection< sfx::BoolItemWrapper, OrientStackedWrapper > OrientStackedConnection; 122 123 // ============================================================================ 124 125 } // namespace 126 127 #endif 128 129