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
cpwl_list_ctrl.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 FPDFSDK_PWL_CPWL_LIST_CTRL_H_
8#define FPDFSDK_PWL_CPWL_LIST_CTRL_H_
9
10#include <map>
11#include <memory>
12#include <vector>
13
14#include "core/fxcrt/fx_coordinates.h"
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/widestring.h"
17#include "fpdfsdk/pwl/cpwl_edit_impl.h"
18
19class IPVT_FontMap;
20
22 public:
24 public:
25 virtual ~NotifyIface();
26
27 virtual void OnSetScrollInfoY(float fPlateMin,
28 float fPlateMax,
29 float fContentMin,
30 float fContentMax,
31 float fSmallStep,
32 float fBigStep) = 0;
33 virtual void OnSetScrollPosY(float fy) = 0;
34
35 // Returns true if `this` is still allocated.
36 [[nodiscard]] virtual bool OnInvalidateRect(const CFX_FloatRect& rect) = 0;
37 };
38
41
42 void SetNotify(NotifyIface* pNotify) { m_pNotify = pNotify; }
43 void OnMouseDown(const CFX_PointF& point, bool bShift, bool bCtrl);
44 void OnMouseMove(const CFX_PointF& point, bool bShift, bool bCtrl);
45 void OnVK_UP(bool bShift, bool bCtrl);
46 void OnVK_DOWN(bool bShift, bool bCtrl);
47 void OnVK_LEFT(bool bShift, bool bCtrl);
48 void OnVK_RIGHT(bool bShift, bool bCtrl);
49 void OnVK_HOME(bool bShift, bool bCtrl);
50 void OnVK_END(bool bShift, bool bCtrl);
51 bool OnChar(uint16_t nChar, bool bShift, bool bCtrl);
52
53 void SetScrollPos(const CFX_PointF& point);
54 void ScrollToListItem(int32_t nItemIndex);
55 CFX_FloatRect GetItemRect(int32_t nIndex) const;
56 int32_t GetCaret() const { return m_nCaretIndex; }
57 int32_t GetSelect() const { return m_nSelItem; }
58 int32_t GetTopItem() const;
60
61 int32_t GetItemIndex(const CFX_PointF& point) const;
62 void AddString(const WideString& str);
63 void SetTopItem(int32_t nIndex);
64 void Select(int32_t nItemIndex);
65 void Deselect(int32_t nItemIndex);
66 void SetCaret(int32_t nItemIndex);
67 WideString GetText() const;
68
69 void SetFontMap(IPVT_FontMap* pFontMap) { m_pFontMap = pFontMap; }
70 void SetFontSize(float fFontSize) { m_fFontSize = fFontSize; }
71 CFX_FloatRect GetPlateRect() const { return m_rcPlate; }
72 void SetPlateRect(const CFX_FloatRect& rect);
73
74 float GetFontSize() const { return m_fFontSize; }
75 CPWL_EditImpl* GetItemEdit(int32_t nIndex) const;
76 int32_t GetCount() const;
77 bool IsItemSelected(int32_t nIndex) const;
78 float GetFirstHeight() const;
79 void SetMultipleSel(bool bMultiple) { m_bMultiple = bMultiple; }
80 bool IsMultipleSel() const { return m_bMultiple; }
81 int32_t FindNext(int32_t nIndex, wchar_t nChar) const;
82 int32_t GetFirstSelected() const;
83
84 private:
85 class Item {
86 public:
87 Item();
88 ~Item();
89
90 void SetFontMap(IPVT_FontMap* pFontMap);
91 CPWL_EditImpl* GetEdit() const { return m_pEdit.get(); }
92
93 void SetRect(const CFX_FloatRect& rect) { m_rcListItem = rect; }
94 void SetSelect(bool bSelected) { m_bSelected = bSelected; }
95 void SetText(const WideString& text);
96 void SetFontSize(float fFontSize);
97 WideString GetText() const;
98
99 CFX_FloatRect GetRect() const { return m_rcListItem; }
100 bool IsSelected() const { return m_bSelected; }
101 float GetItemHeight() const;
102 uint16_t GetFirstChar() const;
103
104 private:
105 CPWL_EditImpl::Iterator* GetIterator() const;
106
107 bool m_bSelected = false;
108 CFX_FloatRect m_rcListItem;
109 std::unique_ptr<CPWL_EditImpl> const m_pEdit;
110 };
111
112 class SelectState {
113 public:
114 enum State { DESELECTING = -1, NORMAL = 0, SELECTING = 1 };
115 using const_iterator = std::map<int32_t, State>::const_iterator;
116
117 SelectState();
118 ~SelectState();
119
120 void Add(int32_t nItemIndex);
121 void Add(int32_t nBeginIndex, int32_t nEndIndex);
122 void Sub(int32_t nItemIndex);
123 void Sub(int32_t nBeginIndex, int32_t nEndIndex);
124 void DeselectAll();
125 void Done();
126
127 const_iterator begin() const { return m_Items.begin(); }
128 const_iterator end() const { return m_Items.end(); }
129
130 private:
131 std::map<int32_t, State> m_Items;
132 };
133
134 CFX_PointF InToOut(const CFX_PointF& point) const;
135 CFX_PointF OutToIn(const CFX_PointF& point) const;
136 CFX_FloatRect InToOut(const CFX_FloatRect& rect) const;
137 CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const;
138
139 CFX_PointF InnerToOuter(const CFX_PointF& point) const;
140 CFX_PointF OuterToInner(const CFX_PointF& point) const;
141 CFX_FloatRect InnerToOuter(const CFX_FloatRect& rect) const;
142 CFX_FloatRect OuterToInner(const CFX_FloatRect& rect) const;
143
144 void OnVK(int32_t nItemIndex, bool bShift, bool bCtrl);
145 bool IsValid(int32_t nItemIndex) const;
146
147 void ReArrange(int32_t nItemIndex);
148 CFX_FloatRect GetItemRectInternal(int32_t nIndex) const;
149 CFX_FloatRect GetContentRectInternal() const;
150 void SetMultipleSelect(int32_t nItemIndex, bool bSelected);
151 void SetSingleSelect(int32_t nItemIndex);
152 void InvalidateItem(int32_t nItemIndex);
153 void SelectItems();
154 bool IsItemVisible(int32_t nItemIndex) const;
155 void SetScrollInfo();
156 void SetScrollPosY(float fy);
157 void AddItem(const WideString& str);
158 WideString GetItemText(int32_t nIndex) const;
159 void SetItemSelect(int32_t nIndex, bool bSelected);
160 int32_t GetLastSelected() const;
161 CFX_PointF GetBTPoint() const {
162 return CFX_PointF(m_rcPlate.left, m_rcPlate.top);
163 }
164
165 CFX_FloatRect m_rcPlate;
166 CFX_FloatRect m_rcContent;
167 CFX_PointF m_ptScrollPos;
168 float m_fFontSize = 0.0f;
169
170 // For single:
171 int32_t m_nSelItem = -1;
172
173 // For multiple:
174 SelectState m_SelectState;
175 int32_t m_nFootIndex = -1;
176 int32_t m_nCaretIndex = -1;
177 bool m_bCtrlSel = false;
178
179 bool m_bMultiple = false;
180 bool m_bNotifyFlag = false;
181 UnownedPtr<NotifyIface> m_pNotify;
182 std::vector<std::unique_ptr<Item>> m_ListItems;
183 UnownedPtr<IPVT_FontMap> m_pFontMap;
184};
185
186#endif // FPDFSDK_PWL_CPWL_LIST_CTRL_H_
virtual bool OnChar(CPDFSDK_Widget *pAnnot, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)
CPWL_Wnd * GetPWLWindow(const CPDFSDK_PageView *pPageView) const
CPWL_Wnd * CreateOrUpdatePWLWindow(const CPDFSDK_PageView *pPageView)
virtual CPWL_Wnd::CreateParams GetCreateParam()
CPDFSDK_PageView * GetCurPageView()
bool IsValid() const
bool IsDataChanged(const CPDFSDK_PageView *pPageView) override
CFFL_ListBox(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
void GetActionData(const CPDFSDK_PageView *pPageView, CPDF_AAction::AActionType type, CFFL_FieldAction &fa) override
bool SetIndexSelected(int index, bool selected) override
void SavePWLWindowState(const CPDFSDK_PageView *pPageView) override
std::unique_ptr< CPWL_Wnd > NewPWLWindow(const CPWL_Wnd::CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData) override
void SaveData(const CPDFSDK_PageView *pPageView) override
~CFFL_ListBox() override
bool IsIndexSelected(int index) override
bool OnChar(CPDFSDK_Widget *pWidget, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
void RecreatePWLWindowFromSavedState(const CPDFSDK_PageView *pPageView) override
CPWL_Wnd::CreateParams GetCreateParam() override
void SetFormField(CFFL_FormField *pFormField)
CPDF_BAFontMap * GetOrCreateFontMap()
CFFL_TextObject(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
void SetScrollPosition(float pos) override
void AddString(const WideString &str)
~CPWL_ListBox() override
void SetTopVisibleIndex(int32_t nItemIndex)
void SetScrollInfo(const PWL_SCROLL_INFO &info) override
void SetHoverSel(bool bHoverSel)
void SetFontSize(float fFontSize) override
void ScrollToListItem(int32_t nItemIndex)
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag) override
void OnDestroy() override
void ScrollWindowVertically(float pos) override
std::unique_ptr< CPWL_ListCtrl > m_pListCtrl
int32_t GetCurSel() const
float GetFirstHeight() const
bool OnNotifySelectionChanged(bool bKeyDown, Mask< FWL_EVENTFLAG > nFlag)
CFX_FloatRect GetListRect() const
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point, const CFX_Vector &delta) override
void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
void Deselect(int32_t nItemIndex)
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
CFX_FloatRect GetContentRect() const
WideString GetText() override
CPWL_ListBox(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
void Select(int32_t nItemIndex)
void OnCreated() override
int32_t GetTopVisibleIndex() const
CFX_FloatRect GetFocusRect() const override
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnSetScrollPosY(float fy) override
float GetFontSize() const override
bool OnInvalidateRect(const CFX_FloatRect &pRect) override
void SetCaret(int32_t nItemIndex)
void OnSetScrollInfoY(float fPlateMin, float fPlateMax, float fContentMin, float fContentMax, float fSmallStep, float fBigStep) override
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
int32_t GetCaretIndex() const
int32_t GetCount() const
bool IsMultipleSel() const
bool IsItemSelected(int32_t nItemIndex) const
bool RepositionChildWnd() override
bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag) override
virtual void OnSetScrollPosY(float fy)=0
virtual void OnSetScrollInfoY(float fPlateMin, float fPlateMax, float fContentMin, float fContentMax, float fSmallStep, float fBigStep)=0
virtual bool OnInvalidateRect(const CFX_FloatRect &rect)=0
void SetFontSize(float fFontSize)
void SetNotify(NotifyIface *pNotify)
void OnVK_LEFT(bool bShift, bool bCtrl)
void SetMultipleSel(bool bMultiple)
bool OnChar(uint16_t nChar, bool bShift, bool bCtrl)
float GetFontSize() const
void SetCaret(int32_t nItemIndex)
void OnVK_UP(bool bShift, bool bCtrl)
void Select(int32_t nItemIndex)
CPWL_EditImpl * GetItemEdit(int32_t nIndex) const
void AddString(const WideString &str)
CFX_FloatRect GetContentRect() const
int32_t GetCaret() const
void Deselect(int32_t nItemIndex)
WideString GetText() const
void SetFontMap(IPVT_FontMap *pFontMap)
void SetScrollPos(const CFX_PointF &point)
int32_t FindNext(int32_t nIndex, wchar_t nChar) const
bool IsItemSelected(int32_t nIndex) const
void OnVK_END(bool bShift, bool bCtrl)
void OnVK_DOWN(bool bShift, bool bCtrl)
void ScrollToListItem(int32_t nItemIndex)
CFX_FloatRect GetItemRect(int32_t nIndex) const
void SetTopItem(int32_t nIndex)
bool IsMultipleSel() const
int32_t GetItemIndex(const CFX_PointF &point) const
CFX_FloatRect GetPlateRect() const
int32_t GetCount() const
float GetFirstHeight() const
void OnVK_RIGHT(bool bShift, bool bCtrl)
int32_t GetSelect() const
int32_t GetTopItem() const
int32_t GetFirstSelected() const
void OnVK_HOME(bool bShift, bool bCtrl)
void OnMouseMove(const CFX_PointF &point, bool bShift, bool bCtrl)
void SetPlateRect(const CFX_FloatRect &rect)
void OnMouseDown(const CFX_PointF &point, bool bShift, bool bCtrl)
#define PWS_VSCROLL
Definition cpwl_wnd.h:32
#define PWS_AUTOFONTSIZE
Definition cpwl_wnd.h:35
#define PLBS_MULTIPLESEL
Definition cpwl_wnd.h:55
constexpr uint32_t kChoiceMultiSelect
Definition form_flags.h:39