Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/toolkit/calendar.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 <config_options.h>
27
#include <vcl/dllapi.h>
28
29
#include <vcl/toolkit/field.hxx>
30
#include <vcl/weld/Button.hxx>
31
#include <vcl/weld/Calendar.hxx>
32
33
class FloatingWindow;
34
struct ImplCFieldFloatWin;
35
36
/*************************************************************************
37
38
Description
39
============
40
41
class CalendarField
42
43
This class is a DateField with which one can select a date via a DropDownButton
44
and the CalendarControl.
45
46
--------------------------------------------------------------------------
47
48
WinBits
49
50
See DateField
51
52
The preferences for the CalendarControl can be set via SetCalendarStyle().
53
54
--------------------------------------------------------------------------
55
56
With EnableToday()/EnableNone() we can enable a TodayButton and a NoneButton.
57
58
--------------------------------------------------------------------------
59
60
Because we only take over the start date into the field, we should query
61
with GetCalendar() in the SelectHandler and with GetSelectDateCount()/GetSelectDate()
62
the selected range. We then can e.g. take over that value to another field.
63
64
--------------------------------------------------------------------------
65
66
If a derived Calendar should be used, we can override the CreateCalendar()
67
method in CalendarField and create an own calendar there ourselves.
68
69
*************************************************************************/
70
71
72
class VCL_DLLPUBLIC CalendarField final : public DateField
73
{
74
private:
75
    VclPtr<ImplCFieldFloatWin> mpFloatWin;
76
    weld::Button*       mpTodayBtn;
77
    weld::Button*       mpNoneBtn;
78
    bool                mbToday;
79
    bool                mbNone;
80
81
                        DECL_DLLPRIVATE_LINK( ImplSelectHdl, weld::Calendar&, void );
82
                        DECL_DLLPRIVATE_LINK( ImplClickHdl, weld::Button&, void );
83
                        DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, FloatingWindow*, void );
84
85
public:
86
                        CalendarField( vcl::Window* pParent, WinBits nWinStyle );
87
    virtual             ~CalendarField() override;
88
    virtual void        dispose() override;
89
90
    virtual bool        ShowDropDown( bool bShow ) override;
91
92
0
    void                EnableToday() { mbToday = true; }
93
0
    void                EnableNone() { mbNone = true; }
94
95
private:
96
    virtual void    StateChanged( StateChangedType nStateChange ) override;
97
    virtual bool    FocusWindowBelongsToControl(const vcl::Window* pFocusWin) const override;
98
};
99
100
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */