Update ooo320-m1
[ooovba.git] / svx / inc / orienthelper.hxx
blob3bbbaac77e9a45628e8950d1b89795e71f3cf06e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: orienthelper.hxx,v $
10 * $Revision: 1.5.274.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SVX_ORIENTHELPER_HXX
32 #define SVX_ORIENTHELPER_HXX
34 #include <memory>
35 #include <vcl/window.hxx>
36 #include <sfx2/itemconnect.hxx>
37 #include "svx/svxdllapi.h"
39 class NumericField;
40 class CheckBox;
42 namespace svx {
44 class DialControl;
46 // ============================================================================
48 struct OrientationHelper_Impl;
50 /** A helper class that manages a DialControl and a "Stacked text" check box.
52 This helper remembers a DialControl for entering a rotation angle, and a
53 check box for stacked text, that enables/disables other controls dependent
54 on its state.
56 It is possible to register more controls that have to be enabled/disabled
57 together with this helper object (optionally dependent on the stacked text
58 check box), using the function AddDependentWindow(). All registered windows
59 are handled on a call of Enable(), or Show(), or on changing the state of
60 the "Stacked text" check box.
62 Note: The member function SetStackedState() should be used instead of
63 direct modifications of the "Stacked text" check box. Otherwise the update
64 mechanism of registered controls will not work.
66 class SVX_DLLPUBLIC OrientationHelper
68 public:
69 explicit OrientationHelper(
70 DialControl& rCtrlDial,
71 CheckBox& rCbStacked );
73 /** @param rNfRotation A numeric field that will be connected to the DialControl. */
74 explicit OrientationHelper(
75 DialControl& rCtrlDial,
76 NumericField& rNfRotation,
77 CheckBox& rCbStacked );
79 virtual ~OrientationHelper();
81 /** Registers the passed window to be enabled/disabled on call of Enable().
82 @param eDisableIfStacked
83 STATE_CHECK: Window always disabled, if stacked text is turned on.
84 STATE_NOCHECK: Window always disabled, if stacked text is turned off.
85 STATE_DONTKNOW: Window will be enabled/disabled independent from stacked text. */
86 void AddDependentWindow( Window& rWindow, TriState eDisableIfStacked = STATE_DONTKNOW );
88 /** Enables or disables the dial control and all dependent windows. */
89 void Enable( bool bEnable = true );
90 /** Disables the dial control and all dependent windows. */
91 inline void Disable() { Enable( false ); }
93 /** Shows or hides the dial control and all dependent windows. */
94 void Show( bool bShow = true );
95 /** Hides the dial control and all dependent windows. */
96 inline void Hide() { Show( false ); }
98 /** Sets the "stacked" check box to the passed state and updates dependent controls. */
99 void SetStackedState( TriState eState );
100 /** Returns the state of the "stacked" check box. */
101 TriState GetStackedState() const;
103 /** Enables/disables the "don't know" state of the "Stacked text" check box. */
104 void EnableStackedTriState( bool bEnable = true );
106 private:
107 std::auto_ptr< OrientationHelper_Impl > mpImpl;
110 // ============================================================================
112 /** Wrapper for usage of the stacked attribute of an OrientationHelper in item connections. */
113 class SVX_DLLPUBLIC OrientStackedWrapper : public sfx::SingleControlWrapper< OrientationHelper, bool >
115 public:
116 explicit OrientStackedWrapper( OrientationHelper& rOrientHlp );
118 virtual bool IsControlDontKnow() const;
119 virtual void SetControlDontKnow( bool bSet );
121 virtual bool GetControlValue() const;
122 virtual void SetControlValue( bool bValue );
125 // ----------------------------------------------------------------------------
127 /** An item<->control connection for the stacked attribute of an OrientationHelper. */
128 typedef sfx::ItemControlConnection< sfx::BoolItemWrapper, OrientStackedWrapper > OrientStackedConnection;
130 // ============================================================================
132 } // namespace
134 #endif