1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_ORIENTHELPER_HXX
21 #define INCLUDED_SVX_ORIENTHELPER_HXX
24 #include <vcl/window.hxx>
25 #include <sfx2/itemconnect.hxx>
26 #include <svx/svxdllapi.h>
36 struct OrientationHelper_Impl
;
38 /** A helper class that manages a DialControl and a "Stacked text" check box.
40 This helper remembers a DialControl for entering a rotation angle, and a
41 check box for stacked text, that enables/disables other controls dependent
44 It is possible to register more controls that have to be enabled/disabled
45 together with this helper object (optionally dependent on the stacked text
46 check box), using the function AddDependentWindow(). All registered windows
47 are handled on a call of Enable(), or Show(), or on changing the state of
48 the "Stacked text" check box.
50 Note: The member function SetStackedState() should be used instead of
51 direct modifications of the "Stacked text" check box. Otherwise the update
52 mechanism of registered controls will not work.
54 class SVX_DLLPUBLIC OrientationHelper final
57 /** @param rNfRotation A numeric field that will be connected to the DialControl. */
58 explicit OrientationHelper(
59 DialControl
& rCtrlDial
,
60 NumericField
& rNfRotation
,
61 CheckBox
& rCbStacked
);
65 /** Registers the passed window to be enabled/disabled on call of Enable().
66 @param eDisableIfStacked
67 TRISTATE_TRUE: Window always disabled, if stacked text is turned on.
68 TRISTATE_FALSE: Window always disabled, if stacked text is turned off.
69 TRISTATE_INDET: Window will be enabled/disabled independent from stacked text. */
70 void AddDependentWindow( vcl::Window
& rWindow
, TriState eDisableIfStacked
= TRISTATE_INDET
);
72 /** Enables or disables the dial control and all dependent windows. */
73 void Enable( bool bEnable
= true );
75 /** Shows or hides the dial control and all dependent windows. */
76 void Show( bool bShow
);
77 /** Hides the dial control and all dependent windows. */
78 void Hide() { Show( false ); }
80 /** Sets the "stacked" check box to the passed state and updates dependent controls. */
81 void SetStackedState( TriState eState
);
82 /** Returns the state of the "stacked" check box. */
83 TriState
GetStackedState() const;
85 /** Enables/disables the "don't know" state of the "Stacked text" check box. */
86 void EnableStackedTriState( bool bEnable
);
89 std::unique_ptr
< OrientationHelper_Impl
> mpImpl
;
93 /** Wrapper for usage of the stacked attribute of an OrientationHelper in item connections. */
94 class SVX_DLLPUBLIC OrientStackedWrapper
: public sfx::SingleControlWrapper
< OrientationHelper
, bool >
97 explicit OrientStackedWrapper( OrientationHelper
& rOrientHlp
);
99 virtual bool IsControlDontKnow() const override
;
100 virtual void SetControlDontKnow( bool bSet
) override
;
102 virtual bool GetControlValue() const override
;
103 virtual void SetControlValue( bool bValue
) override
;
107 /** An item<->control connection for the stacked attribute of an OrientationHelper. */
108 typedef sfx::ItemControlConnection
< sfx::BoolItemWrapper
, OrientStackedWrapper
> OrientStackedConnection
;
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */