Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfwl_datetimepicker.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef XFA_FWL_CFWL_DATETIMEPICKER_H_
8#define XFA_FWL_CFWL_DATETIMEPICKER_H_
9
10#include <utility>
11
12#include "v8/include/cppgc/member.h"
13#include "xfa/fwl/cfwl_datetimeedit.h"
14#include "xfa/fwl/cfwl_event.h"
15#include "xfa/fwl/cfwl_monthcalendar.h"
16#include "xfa/fwl/cfwl_widget.h"
17
18#define FWL_STYLEEXT_DTP_ShortDateFormat (1L << 1)
19#define FWL_STYLEEXT_DTP_EditHAlignMask (3L << 4)
20#define FWL_STYLEEXT_DTP_EditHNear (0L << 4)
21#define FWL_STYLEEXT_DTP_EditHCenter (1L << 4)
22#define FWL_STYLEEXT_DTP_EditHFar (2L << 4)
23#define FWL_STYLEEXT_DTP_EditVAlignMask (3L << 6)
24#define FWL_STYLEEXT_DTP_EditVNear (0L << 6)
25#define FWL_STYLEEXT_DTP_EditVCenter (1L << 6)
26#define FWL_STYLEEXT_DTP_EditVFar (2L << 6)
27#define FWL_STYLEEXT_DTP_EditJustified (1L << 8)
28
29class CFWL_DateTimeEdit;
30
31class CFWL_DateTimePicker final : public CFWL_Widget {
32 public:
35
36 // CFWL_Widget:
37 void PreFinalize() override;
38 void Trace(cppgc::Visitor* visitor) const override;
39 FWL_Type GetClassID() const override;
40 void Update() override;
41 FWL_WidgetHit HitTest(const CFX_PointF& point) override;
42 void DrawWidget(CFGAS_GEGraphics* pGraphics,
43 const CFX_Matrix& matrix) override;
44 void OnProcessMessage(CFWL_Message* pMessage) override;
45 void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
46 const CFX_Matrix& matrix) override;
47
48 void GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
49 void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
50
51 void SetEditText(const WideString& wsText);
53 WideString GetEditText() const;
54 void ClearText();
55
56 void SelectAll();
57 void ClearSelection();
58 bool HasSelection() const { return m_pEdit->HasSelection(); }
59 // Returns <start, count> of the selection.
61 return m_pEdit->GetSelection();
62 }
65 bool Paste(const WideString& wsPaste);
66 bool Undo();
67 bool Redo();
68 bool CanUndo();
69 bool CanRedo();
70
71 CFX_RectF GetBBox() const;
72 void SetEditLimit(int32_t nLimit) { m_pEdit->SetLimit(nLimit); }
73 void ModifyEditStyleExts(uint32_t dwStyleExtsAdded,
74 uint32_t dwStyleExtsRemoved);
75
76 bool IsMonthCalendarVisible() const;
77 void ShowMonthCalendar();
78 void HideMonthCalendar();
79 void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
80
81 private:
82 explicit CFWL_DateTimePicker(CFWL_App* pApp);
83
84 void DrawDropDownButton(CFGAS_GEGraphics* pGraphics,
85 const CFX_Matrix& mtMatrix);
86 WideString FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay);
87 void ResetEditAlignment();
88 void GetPopupPos(float fMinHeight,
89 float fMaxHeight,
90 const CFX_RectF& rtAnchor,
91 CFX_RectF* pPopupRect);
92 void OnFocusGained(CFWL_Message* pMsg);
93 void OnFocusLost(CFWL_Message* pMsg);
94 void OnLButtonDown(CFWL_MessageMouse* pMsg);
95 void OnLButtonUp(CFWL_MessageMouse* pMsg);
96 void OnMouseMove(CFWL_MessageMouse* pMsg);
97 void OnMouseLeave(CFWL_MessageMouse* pMsg);
98 bool NeedsToShowButton() const;
99 void RepaintInflatedMonthCalRect();
100
101 bool m_bLBtnDown = false;
102 Mask<CFWL_PartState> m_iBtnState = CFWL_PartState::kChecked;
103 int32_t m_iYear = -1;
104 int32_t m_iMonth = -1;
105 int32_t m_iDay = -1;
106 float m_fBtn = 0.0f;
107 CFX_RectF m_BtnRect;
108 CFX_RectF m_ClientRect;
109 cppgc::Member<CFWL_DateTimeEdit> const m_pEdit;
110 cppgc::Member<CFWL_MonthCalendar> const m_pMonthCal;
111};
112
113#endif // XFA_FWL_CFWL_DATETIMEPICKER_H_
CFWL_PartState
FWL_Type
Definition cfwl_widget.h:46
#define FWL_STATE_WGT_Focused
Definition cfwl_widget.h:42
void OnProcessMessage(CFWL_Message *pMessage) override
~CFWL_DateTimeEdit() override
void OnProcessMessage(CFWL_Message *pMessage) override
bool Paste(const WideString &wsPaste)
void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay)
~CFWL_DateTimePicker() override
absl::optional< WideString > Copy()
void SetEditLimit(int32_t nLimit)
void Trace(cppgc::Visitor *visitor) const override
std::pair< size_t, size_t > GetSelection() const
FWL_Type GetClassID() const override
absl::optional< WideString > Cut()
void GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
WideString GetEditText() const
void SetEditText(const WideString &wsText)
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay)
FWL_WidgetHit HitTest(const CFX_PointF &point) override
void ModifyEditStyleExts(uint32_t dwStyleExtsAdded, uint32_t dwStyleExtsRemoved)
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void OnProcessMessage(CFWL_Message *pMessage) override
CFWL_Edit(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
Definition cfwl_edit.cpp:50
const MouseCommand m_dwCmd
Type GetType() const
Properties m_Properties
CFWL_Widget * GetOuter() const
void RepaintRect(const CFX_RectF &pRect)
virtual CFX_RectF GetWidgetRect()
void Offset(float dx, float dy)
FWL_WidgetHit
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32