Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / orienthelper.hxx
bloba830c1bed9eb29d5ae0ea68f1400816e27062d74
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <memory>
24 #include <vcl/window.hxx>
25 #include <sfx2/itemconnect.hxx>
26 #include <svx/svxdllapi.h>
28 class NumericField;
29 class CheckBox;
31 namespace svx {
33 class DialControl;
37 struct OrientationHelper_Impl;
39 /** A helper class that manages a DialControl and a "Stacked text" check box.
41 This helper remembers a DialControl for entering a rotation angle, and a
42 check box for stacked text, that enables/disables other controls dependent
43 on its state.
45 It is possible to register more controls that have to be enabled/disabled
46 together with this helper object (optionally dependent on the stacked text
47 check box), using the function AddDependentWindow(). All registered windows
48 are handled on a call of Enable(), or Show(), or on changing the state of
49 the "Stacked text" check box.
51 Note: The member function SetStackedState() should be used instead of
52 direct modifications of the "Stacked text" check box. Otherwise the update
53 mechanism of registered controls will not work.
55 class SVX_DLLPUBLIC OrientationHelper
57 public:
58 /** @param rNfRotation A numeric field that will be connected to the DialControl. */
59 explicit OrientationHelper(
60 DialControl& rCtrlDial,
61 NumericField& rNfRotation,
62 CheckBox& rCbStacked );
64 virtual ~OrientationHelper();
66 /** Registers the passed window to be enabled/disabled on call of Enable().
67 @param eDisableIfStacked
68 TRISTATE_TRUE: Window always disabled, if stacked text is turned on.
69 TRISTATE_FALSE: Window always disabled, if stacked text is turned off.
70 TRISTATE_INDET: Window will be enabled/disabled independent from stacked text. */
71 void AddDependentWindow( vcl::Window& rWindow, TriState eDisableIfStacked = TRISTATE_INDET );
73 /** Enables or disables the dial control and all dependent windows. */
74 void Enable( bool bEnable = true );
75 /** Disables the dial control and all dependent windows. */
76 inline void Disable() { Enable( false ); }
78 /** Shows or hides the dial control and all dependent windows. */
79 void Show( bool bShow = true );
80 /** Hides the dial control and all dependent windows. */
81 inline void Hide() { Show( false ); }
83 /** Sets the "stacked" check box to the passed state and updates dependent controls. */
84 void SetStackedState( TriState eState );
85 /** Returns the state of the "stacked" check box. */
86 TriState GetStackedState() const;
88 /** Enables/disables the "don't know" state of the "Stacked text" check box. */
89 void EnableStackedTriState( bool bEnable = true );
91 private:
92 std::unique_ptr< OrientationHelper_Impl > mpImpl;
97 /** Wrapper for usage of the stacked attribute of an OrientationHelper in item connections. */
98 class SVX_DLLPUBLIC OrientStackedWrapper : public sfx::SingleControlWrapper< OrientationHelper, bool >
100 public:
101 explicit OrientStackedWrapper( OrientationHelper& rOrientHlp );
103 virtual bool IsControlDontKnow() const SAL_OVERRIDE;
104 virtual void SetControlDontKnow( bool bSet ) SAL_OVERRIDE;
106 virtual bool GetControlValue() const SAL_OVERRIDE;
107 virtual void SetControlValue( bool bValue ) SAL_OVERRIDE;
112 /** An item<->control connection for the stacked attribute of an OrientationHelper. */
113 typedef sfx::ItemControlConnection< sfx::BoolItemWrapper, OrientStackedWrapper > OrientStackedConnection;
117 } // namespace
119 #endif
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */