LibreOffice Module svx (master)  1
dialcontrol.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_DIALCONTROL_HXX
21 #define INCLUDED_SVX_DIALCONTROL_HXX
22 
23 #include <memory>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/customweld.hxx>
26 #include <vcl/field.hxx>
27 #include <vcl/virdev.hxx>
28 #include <svx/svxdllapi.h>
29 
30 class Edit;
31 
32 namespace svx {
33 
34 
36 {
37 public:
38  explicit DialControlBmp(OutputDevice& rReference);
39 
40  void InitBitmap(const vcl::Font& rFont);
41  void SetSize(const Size& rSize);
42  void CopyBackground( const DialControlBmp& rSrc );
43  void DrawBackground( const Size& rSize, bool bEnabled );
44  void DrawBackground();
45  void DrawElements( const OUString& rText, sal_Int32 nAngle );
46  Color GetBackgroundColor() const override;
47 
48 private:
49  const Color& GetTextColor() const;
50  const Color& GetScaleLineColor() const;
51  const Color& GetButtonLineColor() const;
52  const Color& GetButtonFillColor( bool bMain ) const;
53 
54  void Init();
55 
57  bool mbEnabled;
59  long mnCenterX;
60  long mnCenterY;
61 };
62 
78 {
79 public:
80  explicit DialControl( vcl::Window* pParent, WinBits nBits );
81 
82  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
83 
84  virtual void StateChanged( StateChangedType nStateChange ) override;
85  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
86 
87  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
88  virtual void MouseMove( const MouseEvent& rMEvt ) override;
89  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
90  virtual void KeyInput( const KeyEvent& rKEvt ) override;
91  virtual void LoseFocus() override;
92 
93  virtual Size GetOptimalSize() const override;
94  virtual void Resize() override;
95 
97  sal_Int32 GetRotation() const;
99  void SetRotation( sal_Int32 nAngle );
100 
102  void SetModifyHdl( const Link<DialControl*,void>& rLink );
103 
104 protected:
106  {
115  sal_Int32 mnAngle;
116  sal_Int32 mnOldAngle;
117  long mnCenterX;
118  long mnCenterY;
119  bool mbNoRot;
120 
121  explicit DialControl_Impl( vcl::Window& rParent );
122  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
123  void SetSize( const Size& rWinSize );
124  };
125  std::unique_ptr< DialControl_Impl > mpImpl;
126 
127  virtual void HandleMouseEvent( const Point& rPos, bool bInitial );
128  void HandleEscapeEvent();
129 
130  void SetRotation( sal_Int32 nAngle, bool bBroadcast );
131 
132  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
133  void Init( const Size& rWinSize );
134 
135 private:
136  void InvalidateControl();
137 };
138 
140 {
141 public:
142  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
143 
144  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
145 
146  virtual void StyleUpdated() override;
147 
148  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
149  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
150  virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
151  virtual bool KeyInput(const KeyEvent& rKEvt) override;
152  virtual void LoseFocus() override;
153 
154  virtual void Resize() override;
155 
157  sal_Int32 GetRotation() const;
159  void SetRotation( sal_Int32 nAngle );
161  bool HasRotation() const;
163  void SetNoRotation();
164 
171  void SetLinkedField(weld::SpinButton* pField, sal_Int32 nDecimalPlaces = 0);
172 
174  void SaveValue();
175 
177  bool IsValueModified() const;
178 
179  const OUString& GetText() const { return mpImpl->maText; }
180  void SetText(const OUString& rText) { mpImpl->maText = rText; }
181 
182 private:
184  {
188  OUString maText;
193  sal_Int32 mnAngle;
194  sal_Int32 mnInitialAngle;
195  sal_Int32 mnOldAngle;
196  long mnCenterX;
197  long mnCenterY;
198  bool mbNoRot;
199 
200  explicit DialControl_Impl(OutputDevice& rReference);
201  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
202  void SetSize( const Size& rWinSize );
203  };
204  std::unique_ptr< DialControl_Impl > mpImpl;
205 
206  void HandleMouseEvent( const Point& rPos, bool bInitial );
207  void HandleEscapeEvent();
208 
209  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
210  void Init( const Size& rWinSize );
211 
212  void InvalidateControl();
213 
214  DECL_LINK(LinkedFieldModifyHdl, weld::SpinButton&, void);
215  void LinkedFieldModifyHdl();
216 };
217 
218 }
219 
220 #endif
221 
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Init()
ScopedVclPtr< DialControlBmp > mxBmpDisabled
This control allows to input a rotation angle, visualized by a dial.
Definition: dialcontrol.hxx:77
Link< DialControl *, void > maModifyHdl
tools::Rectangle maRect
Definition: dialcontrol.hxx:56
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
StateChangedType
sal_Int64 WinBits
std::unique_ptr< DialControl_Impl > mpImpl
OutputDevice & mrParent
Definition: dialcontrol.hxx:58
ScopedVclPtr< DialControlBmp > mxBmpEnabled
void SetText(const OUString &rText)
ScopedVclPtr< DialControlBmp > mxBmpBuffered
const OUString & GetText() const
ScopedVclPtr< DialControlBmp > mxBmpBuffered
ScopedVclPtr< DialControlBmp > mxBmpDisabled
#define SAL_WARN_UNUSED
std::unique_ptr< DialControl_Impl > mpImpl
VclPtr< NumericField > mpLinkField
ScopedVclPtr< DialControlBmp > mxBmpEnabled