LibreOffice Module vcl (master)  1
spinfld.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 #pragma once
21 
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
25 
26 #include <vcl/dllapi.h>
27 #include <vcl/toolkit/edit.hxx>
28 #include <vcl/timer.hxx>
29 
31 {
32 public:
33  explicit SpinField( vcl::Window* pParent, WinBits nWinStyle, WindowType nType = WindowType::SPINFIELD );
34  virtual ~SpinField() override;
35  virtual void dispose() override;
36 
37  virtual bool ShowDropDown( bool bShow );
38 
39  virtual void Up();
40  virtual void Down();
41  virtual void First();
42  virtual void Last();
43 
44  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
45  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
46  virtual void MouseMove( const MouseEvent& rMEvt ) override;
47  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
48  virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override;
49  virtual void Resize() override;
50  virtual void StateChanged( StateChangedType nType ) override;
51  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
52  virtual bool PreNotify( NotifyEvent& rNEvt ) override;
53 
54  void SetUpHdl( const Link<SpinField&,void>& rLink ) { maUpHdlLink = rLink; }
55  void SetDownHdl( const Link<SpinField&,void>& rLink ) { maDownHdlLink = rLink; }
56 
57  virtual Size CalcMinimumSize() const override;
58  virtual Size CalcMinimumSizeForText(const OUString &rString) const override;
59  virtual Size GetOptimalSize() const override;
60  virtual Size CalcSize(sal_Int32 nChars) const override;
61 
62  virtual FactoryFunction GetUITestFactory() const override;
63 
64 protected:
67  tools::Rectangle maDropDownRect; // not yet attached ...
68 
69  using Window::ImplInit;
70  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
71 
72  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
73 
74  void EndDropDown();
75 
76  virtual void FillLayoutData() const override;
77  tools::Rectangle * ImplFindPartRect( const Point& rPt );
78 
79 private:
80  DECL_DLLPRIVATE_LINK( ImplTimeout, Timer*, void );
81  SAL_DLLPRIVATE void ImplInitSpinFieldData();
82  SAL_DLLPRIVATE void ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, tools::Rectangle& rDDArea, tools::Rectangle& rSpinUpArea, tools::Rectangle& rSpinDownArea );
83 
88  bool mbRepeat:1,
89  mbSpin:1,
90  mbInitialUp:1,
91  mbInitialDown:1,
92  mbUpperIn:1,
93  mbLowerIn:1,
94  mbInDropDown:1;
95 };
96 
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: edit.cxx:1722
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2667
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2914
virtual Size CalcMinimumSizeForText(const OUString &rString) const
Definition: edit.cxx:2617
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: edit.cxx:222
StateChangedType
Definition: window.hxx:317
sal_Int64 WinBits
virtual void FillLayoutData() const override
Definition: edit.cxx:1716
AutoTimer maRepeatTimer
Definition: spinfld.hxx:85
tools::Rectangle maDropDownRect
Definition: spinfld.hxx:67
tools::Rectangle maLowerRect
Definition: spinfld.hxx:66
Link< SpinField &, void > maDownHdlLink
Definition: spinfld.hxx:87
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: edit.cxx:1741
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: edit.cxx:1358
Definition: edit.hxx:55
An auto-timer is a multi-shot timer re-emitting itself at interval until destroyed or stopped...
Definition: timer.hxx:72
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
virtual Size GetOptimalSize() const override
Definition: edit.cxx:2672
DrawFlags
Definition: window.hxx:360
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2164
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
virtual void Resize() override
Definition: edit.cxx:1728
virtual Size CalcSize(sal_Int32 nChars) const
Definition: edit.cxx:2677
WindowType
Link< SpinField &, void > maUpHdlLink
Definition: spinfld.hxx:86
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2245
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: edit.cxx:1317
QPRO_FUNC_TYPE nType
void SetUpHdl(const Link< SpinField &, void > &rLink)
Definition: spinfld.hxx:54
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:408
void SetDownHdl(const Link< SpinField &, void > &rLink)
Definition: spinfld.hxx:55
Definition: timer.hxx:26
VclPtr< Edit > mpEdit
Definition: spinfld.hxx:84
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: edit.cxx:304
tools::Rectangle maUpperRect
Definition: spinfld.hxx:65
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:225