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_combobox.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_COMBOBOX_H_
8#define XFA_FWL_CFWL_COMBOBOX_H_
9
10#include "xfa/fgas/graphics/cfgas_gegraphics.h"
11#include "xfa/fwl/cfwl_comboedit.h"
12#include "xfa/fwl/cfwl_combolist.h"
13#include "xfa/fwl/cfwl_listbox.h"
14#include "xfa/fwl/cfwl_widget.h"
15
16namespace pdfium {
17
18#define FWL_STYLEEXT_CMB_DropDown (1L << 0)
19#define FWL_STYLEEXT_CMB_Sort (1L << 1)
20#define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3)
21#define FWL_STYLEEXT_CMB_EditHNear 0
22#define FWL_STYLEEXT_CMB_EditHCenter (1L << 4)
23#define FWL_STYLEEXT_CMB_EditVNear 0
24#define FWL_STYLEEXT_CMB_EditVCenter (1L << 6)
25#define FWL_STYLEEXT_CMB_EditVFar (2L << 6)
26#define FWL_STYLEEXT_CMB_EditJustified (1L << 8)
27#define FWL_STYLEEXT_CMB_EditHAlignMask (3L << 4)
28#define FWL_STYLEEXT_CMB_EditVAlignMask (3L << 6)
29#define FWL_STYLEEXT_CMB_ListItemLeftAlign 0
30#define FWL_STYLEEXT_CMB_ListItemCenterAlign (1L << 10)
31#define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 10)
32#define FWL_STYLEEXT_CMB_ReadOnly (1L << 13)
33
34class CFWL_ComboBox final : public CFWL_Widget {
35 public:
37 ~CFWL_ComboBox() override;
38
39 // CFWL_Widget
40 void Trace(cppgc::Visitor* visitor) const override;
41 FWL_Type GetClassID() const override;
42 void ModifyStyleExts(uint32_t dwStyleExtsAdded,
43 uint32_t dwStyleExtsRemoved) override;
44 void SetStates(uint32_t dwStates) override;
45 void RemoveStates(uint32_t dwStates) override;
46 void Update() override;
47 FWL_WidgetHit HitTest(const CFX_PointF& point) override;
48 void DrawWidget(CFGAS_GEGraphics* pGraphics,
49 const CFX_Matrix& matrix) override;
50 void OnProcessMessage(CFWL_Message* pMessage) override;
51 void OnProcessEvent(CFWL_Event* pEvent) override;
52 void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
53 const CFX_Matrix& matrix) override;
54
55 WideString GetTextByIndex(int32_t iIndex) const;
56 int32_t GetCurSel() const { return m_iCurSel; }
57 void SetCurSel(int32_t iSel);
58
59 void AddString(const WideString& wsText);
60 void RemoveAt(int32_t iIndex);
61 void RemoveAll();
62
63 void SetEditText(const WideString& wsText);
64 WideString GetEditText() const;
65
66 bool EditCanUndo() const { return m_pEdit->CanUndo(); }
67 bool EditCanRedo() const { return m_pEdit->CanRedo(); }
68 bool EditUndo() { return m_pEdit->Undo(); }
69 bool EditRedo() { return m_pEdit->Redo(); }
70 bool EditCanCopy() const { return m_pEdit->HasSelection(); }
71 bool EditCanCut() const {
72 if (m_pEdit->GetStyleExts() & FWL_STYLEEXT_EDT_ReadOnly)
73 return false;
74 return EditCanCopy();
75 }
76 bool EditCanSelectAll() const { return m_pEdit->GetTextLength() > 0; }
77 std::optional<WideString> EditCopy() const { return m_pEdit->Copy(); }
78 std::optional<WideString> EditCut() { return m_pEdit->Cut(); }
79 bool EditPaste(const WideString& wsPaste) { return m_pEdit->Paste(wsPaste); }
80 void EditSelectAll() { m_pEdit->SelectAll(); }
81 void EditDelete() { m_pEdit->ClearText(); }
82 void EditDeSelect() { m_pEdit->ClearSelection(); }
83
84 CFX_RectF GetBBox() const;
85 void EditModifyStyleExts(uint32_t dwStyleExtsAdded,
86 uint32_t dwStyleExtsRemoved);
87 void ShowDropDownList();
88 void HideDropDownList();
89
90 CFWL_ComboEdit* GetComboEdit() const { return m_pEdit; }
91
92 void ProcessSelChanged(bool bLButtonUp);
93 int32_t GetCurrentSelection() const { return m_iCurSel; }
94
95 private:
96 explicit CFWL_ComboBox(CFWL_App* pApp);
97
98 bool IsDropDownStyle() const {
100 }
101 void MatchEditText();
102 void SyncEditText(int32_t iListItem);
103 void Layout();
104 void ResetEditAlignment();
105 void ResetListItemAlignment();
106 void GetPopupPos(float fMinHeight,
107 float fMaxHeight,
108 const CFX_RectF& rtAnchor,
109 CFX_RectF* pPopupRect);
110 void OnLButtonUp(CFWL_MessageMouse* pMsg);
111 bool IsDropListVisible() const { return m_pListBox->IsVisible(); }
112 void OnLButtonDown(CFWL_MessageMouse* pMsg);
113 void OnFocusGained();
114 void OnFocusLost();
115 void OnKey(CFWL_MessageKey* pMsg);
116 void RepaintInflatedListBoxRect();
117
118 CFX_RectF m_ClientRect;
119 CFX_RectF m_ContentRect;
120 CFX_RectF m_BtnRect;
121 cppgc::Member<CFWL_ComboEdit> const m_pEdit;
122 cppgc::Member<CFWL_ComboList> const m_pListBox;
123 int32_t m_iCurSel = -1;
124 Mask<CFWL_PartState> m_iBtnState = CFWL_PartState::kNormal;
125};
126
127} // namespace pdfium
128
129// TODO(crbug.com/42271761): Remove.
130using pdfium::CFWL_ComboBox;
131
132#endif // XFA_FWL_CFWL_COMBOBOX_H_
#define FWL_STYLEEXT_CMB_ListItemAlignMask
#define FWL_STYLEEXT_CMB_EditHAlignMask
#define FWL_STYLEEXT_CMB_EditVCenter
#define FWL_STYLEEXT_CMB_EditVFar
#define FWL_STYLEEXT_CMB_DropDown
#define FWL_STYLEEXT_CMB_ListItemCenterAlign
#define FWL_STYLEEXT_CMB_EditHCenter
#define FWL_STYLEEXT_CMB_EditVAlignMask
#define FWL_STYLEEXT_CMB_ReadOnly
#define FWL_STYLEEXT_CMB_EditJustified
#define FWL_STYLEEXT_EDT_VAlignMask
Definition cfwl_edit.h:40
#define FWL_STYLEEXT_EDT_HAlignModeMask
Definition cfwl_edit.h:41
#define FWL_STYLEEXT_EDT_HAlignMask
Definition cfwl_edit.h:39
#define FWL_STYLEEXT_EDT_VNear
Definition cfwl_edit.h:35
#define FWL_STYLEEXT_EDT_VCenter
Definition cfwl_edit.h:36
#define FWL_STYLEEXT_EDT_ReadOnly
Definition cfwl_edit.h:23
#define FWL_STYLEEXT_EDT_VFar
Definition cfwl_edit.h:37
#define FWL_STYLEEXT_EDT_HNear
Definition cfwl_edit.h:32
#define FWL_STYLEEXT_EDT_Justified
Definition cfwl_edit.h:38
#define FWL_STYLEEXT_EDT_HCenter
Definition cfwl_edit.h:33
#define FWL_STYLEEXT_LTB_CenterAlign
#define FWL_STYLEEXT_LTB_LeftAlign
#define FWL_STATE_WGT_Invisible
Definition cfwl_widget.h:45
#define FWL_STYLE_WGT_VScroll
Definition cfwl_widget.h:39
#define FWL_STATE_WGT_Focused
Definition cfwl_widget.h:44
#define FWL_STYLE_WGT_Border
Definition cfwl_widget.h:38
StateRestorer(CFGAS_GEGraphics *graphics)
void ConcatMatrix(const CFX_Matrix &matrix)
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void Concat(const CFX_Matrix &right)
void Offset(float dx, float dy)
bool IsEmpty(float fEpsilon) const
void Deflate(float off_left, float off_top, float off_right, float off_bottom)
void Inflate(float x, float y)
CFX_RectF & operator=(const CFX_RectF &other)=default
bool Contains(const PointType &p) const
float right() const
constexpr CFX_RectF(float dst_left, float dst_top, float dst_width, float dst_height)
void Union(const CFX_RectF &rt)
bool operator==(const WideString &other) const
WideString()=default
void ProcessSelChanged(bool bLButtonUp)
void Trace(cppgc::Visitor *visitor) const override
std::optional< WideString > EditCut()
bool EditCanSelectAll() const
void SetCurSel(int32_t iSel)
void SetEditText(const WideString &wsText)
void SetStates(uint32_t dwStates) override
void OnProcessEvent(CFWL_Event *pEvent) override
void RemoveAt(int32_t iIndex)
void ModifyStyleExts(uint32_t dwStyleExtsAdded, uint32_t dwStyleExtsRemoved) override
bool EditCanRedo() const
bool EditCanCopy() const
WideString GetTextByIndex(int32_t iIndex) const
std::optional< WideString > EditCopy() const
bool EditPaste(const WideString &wsPaste)
CFX_RectF GetBBox() const
void Update() override
~CFWL_ComboBox() override
FWL_Type GetClassID() const override
void AddString(const WideString &wsText)
WideString GetEditText() const
bool EditCanCut() const
int32_t GetCurSel() const
bool EditCanUndo() const
int32_t GetCurrentSelection() const
void RemoveStates(uint32_t dwStates) override
void EditModifyStyleExts(uint32_t dwStyleExtsAdded, uint32_t dwStyleExtsRemoved)
CFWL_ComboEdit * GetComboEdit() const
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void OnProcessMessage(CFWL_Message *pMessage) override
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
FWL_WidgetHit HitTest(const CFX_PointF &point) override
int32_t MatchItem(WideStringView wsMatch)
void ChangeSelected(int32_t iSel)
Type GetType() const
Definition cfwl_event.h:41
CFWL_Widget * GetSrcTarget() const
Definition cfwl_event.h:42
WideString GetText() const
int32_t CountItems(const CFWL_Widget *pWidget) const
const uint32_t m_dwKeyCodeOrChar
const KeyCommand m_dwCmd
CFWL_MessageKillFocus(CFWL_Widget *pDstTarget)
Type GetType() const
CFWL_Widget * GetDstTarget() const
void OnProcessMessage(CFWL_Message *pMessage) override
void RepaintRect(const CFX_RectF &pRect)
virtual void RemoveStates(uint32_t dwStates)
void DispatchEvent(CFWL_Event *pEvent)
CFWL_Widget(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
float GetCXBorderSize() const
virtual void ModifyStyleExts(uint32_t dwStyleExtsAdded, uint32_t dwStyleExtsRemoved)
virtual CFX_RectF GetClientRect()
uint32_t GetStyleExts() const
IFWL_ThemeProvider * GetThemeProvider() const
bool IsLocked() const
CFWL_WidgetMgr * GetWidgetMgr() const
Properties m_Properties
virtual void SetStates(uint32_t dwStates)
virtual float GetScrollBarWidth() const =0
virtual CFX_RectF GetUIMargin(const CFWL_ThemePart &pThemePart) const =0
CFX_PTemplate< float > CFX_PointF
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32
@ XFA_FWL_VKEY_Up
@ XFA_FWL_VKEY_Return
@ XFA_FWL_VKEY_Escape
@ XFA_FWL_VKEY_Down
fxcrt::WideString WideString
Definition widestring.h:207