Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/toolkit/spinfld.hxx
Line
Count
Source
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
30
class VCL_DLLPUBLIC SpinField : public Edit
31
{
32
public:
33
    explicit        SpinField( vcl::Window* pParent, WinBits nWinStyle, WindowType eType = WindowType::SPINFIELD );
34
    virtual         ~SpinField() override;
35
    SAL_DLLPRIVATE virtual void dispose() override;
36
37
    SAL_DLLPRIVATE virtual bool ShowDropDown( bool bShow );
38
39
    SAL_DLLPRIVATE virtual void Up();
40
    SAL_DLLPRIVATE virtual void Down();
41
    SAL_DLLPRIVATE virtual void First();
42
    SAL_DLLPRIVATE virtual void Last();
43
44
    SAL_DLLPRIVATE virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
45
    SAL_DLLPRIVATE virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
46
    SAL_DLLPRIVATE virtual void MouseMove( const MouseEvent& rMEvt ) override;
47
    SAL_DLLPRIVATE virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
48
    SAL_DLLPRIVATE virtual void Draw( OutputDevice* pDev, const Point& rPos,SystemTextColorFlags nFlags ) override;
49
    SAL_DLLPRIVATE virtual void Resize() override;
50
    SAL_DLLPRIVATE virtual void StateChanged( StateChangedType nType ) override;
51
    SAL_DLLPRIVATE virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
52
    SAL_DLLPRIVATE virtual bool PreNotify( NotifyEvent& rNEvt ) override;
53
54
0
    void            SetUpHdl( const Link<SpinField&,void>& rLink ) { maUpHdlLink = rLink; }
55
0
    void            SetDownHdl( const Link<SpinField&,void>& rLink ) { maDownHdlLink = rLink; }
56
57
    SAL_DLLPRIVATE virtual Size CalcMinimumSize() const override;
58
    SAL_DLLPRIVATE virtual Size CalcMinimumSizeForText(const OUString &rString) const override;
59
    SAL_DLLPRIVATE virtual Size GetOptimalSize() const override;
60
    SAL_DLLPRIVATE virtual Size CalcSize(sal_Int32 nChars) const override;
61
62
    SAL_DLLPRIVATE virtual FactoryFunction GetUITestFactory() const override;
63
64
    SAL_DLLPRIVATE void SetUpperEnabled(bool bEnabled);
65
    SAL_DLLPRIVATE void SetLowerEnabled(bool bEnabled);
66
0
    SAL_DLLPRIVATE bool IsUpperEnabled() const { return mbUpperEnabled; }
67
0
    SAL_DLLPRIVATE bool IsLowerEnabled() const { return mbLowerEnabled; }
68
69
protected:
70
    using Window::ImplInit;
71
    SAL_DLLPRIVATE void   ImplInit( vcl::Window* pParent, WinBits nStyle );
72
73
    SAL_DLLPRIVATE virtual bool EventNotify( NotifyEvent& rNEvt ) override;
74
75
    SAL_DLLPRIVATE void EndDropDown();
76
77
    SAL_DLLPRIVATE virtual void FillLayoutData() const override;
78
    SAL_DLLPRIVATE tools::Rectangle * ImplFindPartRect( const Point& rPt );
79
80
private:
81
    DECL_DLLPRIVATE_LINK( ImplTimeout, Timer*, void );
82
    SAL_DLLPRIVATE void   ImplInitSpinFieldData();
83
    SAL_DLLPRIVATE void   ImplCalcButtonAreas( const OutputDevice* pDev, const Size& rOutSz, tools::Rectangle& rDDArea, tools::Rectangle& rSpinUpArea, tools::Rectangle& rSpinDownArea );
84
85
    tools::Rectangle       maUpperRect;
86
    tools::Rectangle       maLowerRect;
87
    tools::Rectangle       maDropDownRect; // not yet attached ...
88
89
    VclPtr<Edit>    mpEdit;
90
    AutoTimer       maRepeatTimer;
91
    Link<SpinField&,void>  maUpHdlLink;
92
    Link<SpinField&,void>  maDownHdlLink;
93
    bool            mbRepeat:1,
94
                    mbSpin:1,
95
                    mbInitialUp:1,
96
                    mbInitialDown:1,
97
                    mbUpperIn:1,
98
                    mbLowerIn:1,
99
                    mbInDropDown:1,
100
                    mbUpperEnabled:1,
101
                    mbLowerEnabled:1;
102
};
103
104
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */