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_DIALCONTROL_HXX
30 : : #define SVX_DIALCONTROL_HXX
31 : :
32 : : #include <memory>
33 : : #include <vcl/ctrl.hxx>
34 : : #include <sfx2/itemconnect.hxx>
35 : : #include "svx/svxdllapi.h"
36 : :
37 : : class NumericField;
38 : :
39 : : namespace svx {
40 : :
41 : : // ============================================================================
42 : :
43 : : struct DialControl_Impl;
44 : :
45 : : /** This control allows to input a rotation angle, visualized by a dial.
46 : :
47 : : Usage: A single click sets a rotation angle rounded to steps of 15 degrees.
48 : : Dragging with the left mouse button sets an exact rotation angle. Pressing
49 : : the ESCAPE key during mouse drag cancels the operation and restores the old
50 : : state of the control.
51 : :
52 : : It is possible to link a numeric field to this control using the function
53 : : SetLinkedField(). The DialControl will take full control of this numeric
54 : : field:
55 : : - Sets the rotation angle to the numeric field in mouse operations.
56 : : - Shows the value entered/modified in the numeric field.
57 : : - Enables/disables/shows/hides the field according to own state changes.
58 : : */
59 : : class SVX_DLLPUBLIC DialControl : public Control
60 : : {
61 : : public:
62 : : explicit DialControl( Window* pParent, const ResId& rResId );
63 : : virtual ~DialControl();
64 : :
65 : : virtual void Paint( const Rectangle& rRect );
66 : :
67 : : virtual void StateChanged( StateChangedType nStateChange );
68 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
69 : :
70 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
71 : : virtual void MouseMove( const MouseEvent& rMEvt );
72 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
73 : : virtual void KeyInput( const KeyEvent& rKEvt );
74 : : virtual void LoseFocus();
75 : :
76 : : /** Returns true, if the control is not in "don't care" state. */
77 : : bool HasRotation() const;
78 : : /** Sets the control to "don't care" state. */
79 : : void SetNoRotation();
80 : :
81 : : /** Returns the current rotation angle in 1/100 degrees. */
82 : : sal_Int32 GetRotation() const;
83 : : /** Sets the rotation to the passed value (in 1/100 degrees). */
84 : : void SetRotation( sal_Int32 nAngle );
85 : :
86 : : /** Links the passed numeric edit field to the control (bi-directional). */
87 : : void SetLinkedField( NumericField* pField );
88 : :
89 : : private:
90 : : void Init( const Size& rWinSize, const Font& rWinFont );
91 : : void Init( const Size& rWinSize );
92 : : void InvalidateControl();
93 : :
94 : : void ImplSetRotation( sal_Int32 nAngle, bool bBroadcast );
95 : : void ImplSetFieldLink( const Link& rLink );
96 : :
97 : : void HandleMouseEvent( const Point& rPos, bool bInitial );
98 : : void HandleEscapeEvent();
99 : :
100 : : DECL_LINK( LinkedFieldModifyHdl, NumericField* );
101 : :
102 : : std::auto_ptr< DialControl_Impl > mpImpl;
103 : : };
104 : :
105 : : // ============================================================================
106 : :
107 : : /** Wrapper for usage of a DialControl in item connections. */
108 [ # # ]: 0 : class SVX_DLLPUBLIC DialControlWrapper : public sfx::SingleControlWrapper< DialControl, sal_Int32 >
109 : : {
110 : : public:
111 : : explicit DialControlWrapper( DialControl& rDial );
112 : :
113 : : virtual bool IsControlDontKnow() const;
114 : : virtual void SetControlDontKnow( bool bSet );
115 : :
116 : : virtual sal_Int32 GetControlValue() const;
117 : : virtual void SetControlValue( sal_Int32 nValue );
118 : : };
119 : :
120 : : // ----------------------------------------------------------------------------
121 : :
122 : : /** An item<->control connection for a DialControl. */
123 : : typedef sfx::ItemControlConnection< sfx::Int32ItemWrapper, DialControlWrapper > DialControlConnection;
124 : :
125 : : // ============================================================================
126 : :
127 : : } // namespace svx
128 : :
129 : : #endif
130 : :
131 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|