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