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