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 <config_options.h>
24 #include <memory>
25 #include <vcl/customweld.hxx>
26 #include <vcl/virdev.hxx>
27 #include <svx/svxdllapi.h>
28 
29 class Edit;
30 
31 namespace svx {
32 
33 
35 {
36 public:
37  explicit DialControlBmp(OutputDevice& rReference);
38 
39  void InitBitmap(const vcl::Font& rFont);
40  void SetSize(const Size& rSize);
41  void CopyBackground( const DialControlBmp& rSrc );
42  void DrawBackground( const Size& rSize, bool bEnabled );
43  void DrawBackground();
44  void DrawElements( const OUString& rText, sal_Int32 nAngle );
45  Color GetBackgroundColor() const override;
46 
47 private:
48  const Color& GetTextColor() const;
49  const Color& GetScaleLineColor() const;
50  const Color& GetButtonLineColor() const;
51  const Color& GetButtonFillColor( bool bMain ) const;
52 
53  void Init();
54 
56  bool mbEnabled;
58  long mnCenterX;
59  long mnCenterY;
60 };
61 
77 {
78 public:
79  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
80 
81  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
82 
83  virtual void StyleUpdated() override;
84 
85  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
86  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
87  virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
88  virtual bool KeyInput(const KeyEvent& rKEvt) override;
89  virtual void LoseFocus() override;
90 
91  virtual void Resize() override;
92 
94  sal_Int32 GetRotation() const;
96  void SetRotation( sal_Int32 nAngle );
98  bool HasRotation() const;
100  void SetNoRotation();
101 
108  void SetLinkedField(weld::MetricSpinButton* pField, sal_Int32 nDecimalPlaces = 0);
109 
111  void SaveValue();
112 
114  bool IsValueModified() const;
115 
116  const OUString& GetText() const { return mpImpl->maText; }
117  void SetText(const OUString& rText) { mpImpl->maText = rText; }
118 
119  void SetModifyHdl( const Link<DialControl&,void>& rLink );
120 
121  void Init( const Size& rWinSize );
122 
123  void set_visible(bool bVisible)
124  {
125  if (bVisible)
126  Show();
127  else
128  Hide();
129  }
130 private:
131  struct SAL_DLLPRIVATE DialControl_Impl
132  {
137  OUString maText;
142  sal_Int32 mnAngle;
143  sal_Int32 mnInitialAngle;
144  sal_Int32 mnOldAngle;
145  long mnCenterX;
146  long mnCenterY;
147  bool mbNoRot;
148 
149  explicit DialControl_Impl(OutputDevice& rReference);
150  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
151  void SetSize( const Size& rWinSize );
152  };
153  std::unique_ptr< DialControl_Impl > mpImpl;
154 
155  void HandleMouseEvent( const Point& rPos, bool bInitial );
156  void HandleEscapeEvent();
157 
158  void SetRotation( sal_Int32 nAngle, bool bBroadcast );
159 
160  void Init( const Size& rWinSize, const vcl::Font& rWinFont );
161 
162  void InvalidateControl();
163 
164  DECL_LINK(LinkedFieldModifyHdl, weld::MetricSpinButton&, void);
165 };
166 
167 }
168 
169 #endif
170 
171 /* 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:76
weld::MetricSpinButton * mpLinkField
void SetText(const OUString &rText)
tools::Rectangle maRect
Definition: dialcontrol.hxx:55
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
Frame border has a visible style.
std::unique_ptr< DialControl_Impl > mpImpl
OutputDevice & mrParent
Definition: dialcontrol.hxx:57
ScopedVclPtr< DialControlBmp > mxBmpEnabled
ScopedVclPtr< DialControlBmp > mxBmpBuffered
#define SAL_WARN_UNUSED
Link< DialControl &, void > maModifyHdl
const OUString & GetText() const
void set_visible(bool bVisible)