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_edit.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_EDIT_H_
8#define XFA_FWL_CFWL_EDIT_H_
9
10#include <memory>
11#include <utility>
12
13#include "xfa/fde/cfde_texteditengine.h"
14#include "xfa/fgas/graphics/cfgas_gepath.h"
15#include "xfa/fwl/cfwl_event.h"
16#include "xfa/fwl/cfwl_scrollbar.h"
17#include "xfa/fwl/cfwl_widget.h"
18
20
21namespace pdfium {
22
23#define FWL_STYLEEXT_EDT_ReadOnly (1L << 0)
24#define FWL_STYLEEXT_EDT_MultiLine (1L << 1)
25#define FWL_STYLEEXT_EDT_WantReturn (1L << 2)
26#define FWL_STYLEEXT_EDT_AutoHScroll (1L << 4)
27#define FWL_STYLEEXT_EDT_AutoVScroll (1L << 5)
28#define FWL_STYLEEXT_EDT_Validate (1L << 7)
29#define FWL_STYLEEXT_EDT_Password (1L << 8)
30#define FWL_STYLEEXT_EDT_Number (1L << 9)
31#define FWL_STYLEEXT_EDT_CombText (1L << 17)
32#define FWL_STYLEEXT_EDT_HNear 0
33#define FWL_STYLEEXT_EDT_HCenter (1L << 18)
34#define FWL_STYLEEXT_EDT_HFar (2L << 18)
35#define FWL_STYLEEXT_EDT_VNear 0
36#define FWL_STYLEEXT_EDT_VCenter (1L << 20)
37#define FWL_STYLEEXT_EDT_VFar (2L << 20)
38#define FWL_STYLEEXT_EDT_Justified (1L << 22)
39#define FWL_STYLEEXT_EDT_HAlignMask (3L << 18)
40#define FWL_STYLEEXT_EDT_VAlignMask (3L << 20)
41#define FWL_STYLEEXT_EDT_HAlignModeMask (3L << 22)
42#define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25)
43#define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26)
44
45class CFWL_MessageKey;
46class CFWL_MessageMouse;
47class CFWL_Caret;
48
49class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate {
50 public:
52 ~CFWL_Edit() override;
53
54 // CFWL_Widget:
55 void PreFinalize() override;
56 void Trace(cppgc::Visitor* visitor) const override;
57 FWL_Type GetClassID() const override;
59 CFX_RectF GetWidgetRect() override;
60 void Update() override;
61 FWL_WidgetHit HitTest(const CFX_PointF& point) override;
62 void SetStates(uint32_t dwStates) override;
63 void DrawWidget(CFGAS_GEGraphics* pGraphics,
64 const CFX_Matrix& matrix) override;
65 void OnProcessMessage(CFWL_Message* pMessage) override;
66 void OnProcessEvent(CFWL_Event* pEvent) override;
67 void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
68 const CFX_Matrix& matrix) override;
69
70 virtual void SetText(const WideString& wsText);
71 virtual void SetTextSkipNotify(const WideString& wsText);
72
73 size_t GetTextLength() const;
74 WideString GetText() const;
75 void ClearText();
76
77 void SelectAll();
78 void ClearSelection();
79 bool HasSelection() const;
80 // Returns <start, count> of the selection.
82
83 int32_t GetLimit() const;
84 void SetLimit(int32_t nLimit);
85 void SetAliasChar(wchar_t wAlias);
86 std::optional<WideString> Copy();
87 std::optional<WideString> Cut();
88 bool Paste(const WideString& wsPaste);
89 bool Undo();
90 bool Redo();
91 bool CanUndo();
92 bool CanRedo();
93
94 // CFDE_TextEditEngine::Delegate
95 void NotifyTextFull() override;
96 void OnCaretChanged() override;
97 void OnTextWillChange(CFDE_TextEditEngine::TextChange* change) override;
98 void OnTextChanged() override;
99 void OnSelChanged() override;
100 bool OnValidate(const WideString& wsText) override;
101 void SetScrollOffset(float fScrollOffset) override;
102
103 protected:
104 CFWL_Edit(CFWL_App* app, const Properties& properties, CFWL_Widget* pOuter);
105
106 void ShowCaret(CFX_RectF* pRect);
107 void HideCaret(CFX_RectF* pRect);
108 const CFX_RectF& GetRTClient() const { return m_ClientRect; }
109 CFDE_TextEditEngine* GetTxtEdtEngine() { return m_pEditEngine.get(); }
110
111 private:
112 void RenderText(CFX_RenderDevice* pRenderDev,
113 const CFX_RectF& clipRect,
114 const CFX_Matrix& mt);
115 void DrawContent(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
116 void DrawContentNonComb(CFGAS_GEGraphics* pGraphics,
117 const CFX_Matrix& mtMatrix);
118
119 void UpdateEditEngine();
120 void UpdateEditParams();
121 void UpdateEditLayout();
122 bool UpdateOffset();
123 bool UpdateOffset(CFWL_ScrollBar* pScrollBar, float fPosChanged);
124 void UpdateVAlignment();
125 void UpdateCaret();
126 CFWL_ScrollBar* UpdateScroll();
127 void Layout();
128 void LayoutScrollBar();
129 CFX_PointF DeviceToEngine(const CFX_PointF& pt);
130 void InitVerticalScrollBar();
131 void InitEngine();
132 void InitCaret();
133 bool IsShowVertScrollBar() const;
134 bool IsContentHeightOverflow() const;
135 void SetCursorPosition(size_t position);
136 void UpdateCursorRect();
137
138 void DoRButtonDown(CFWL_MessageMouse* pMsg);
139 void OnFocusGained();
140 void OnFocusLost();
141 void OnLButtonDown(CFWL_MessageMouse* pMsg);
142 void OnLButtonUp(CFWL_MessageMouse* pMsg);
143 void OnButtonDoubleClick(CFWL_MessageMouse* pMsg);
144 void OnMouseMove(CFWL_MessageMouse* pMsg);
145 void OnKeyDown(CFWL_MessageKey* pMsg);
146 void OnChar(CFWL_MessageKey* pMsg);
147 bool OnScroll(CFWL_ScrollBar* pScrollBar,
148 CFWL_EventScroll::Code dwCode,
149 float fPos);
150
151 CFX_RectF m_ClientRect;
152 CFX_RectF m_EngineRect;
153 CFX_RectF m_StaticRect;
154 CFX_RectF m_CaretRect;
155 bool m_bLButtonDown = false;
156 int32_t m_nLimit = -1;
157 float m_fVAlignOffset = 0.0f;
158 float m_fScrollOffsetX = 0.0f;
159 float m_fScrollOffsetY = 0.0f;
160 float m_fFontSize = 0.0f;
161 size_t m_CursorPosition = 0;
162 std::unique_ptr<CFDE_TextEditEngine> const m_pEditEngine;
163 cppgc::Member<CFWL_ScrollBar> m_pVertScrollBar;
164 cppgc::Member<CFWL_Caret> m_pCaret;
165 WideString m_wsCache;
166 WideString m_wsFont;
167};
168
169} // namespace pdfium
170
171// TODO(crbug.com/42271761): Remove.
172using pdfium::CFWL_Edit;
173
174#endif // XFA_FWL_CFWL_EDIT_H_
BC_TEXT_LOC
Definition BC_Library.h:12
BC_TYPE
Definition BC_Library.h:20
@ kDataMatrix
Definition BC_Library.h:32
#define FWL_STATE_WGT_Focused
Definition cfwl_widget.h:44
void Concat(const CFX_Matrix &right)
void SetModuleWidth(int32_t width)
void SetModuleHeight(int32_t height)
void SetType(BC_TYPE type)
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void SetCalChecksum(bool calChecksum)
void SetErrorCorrectionLevel(int32_t ecLevel)
void OnProcessEvent(CFWL_Event *pEvent) override
void SetWideNarrowRatio(int8_t ratio)
void SetEndChar(char endChar)
void SetDataLength(int32_t dataLength)
void SetStartChar(char startChar)
void SetTextSkipNotify(const WideString &wsText) override
FWL_Type GetClassID() const override
void SetPrintChecksum(bool printChecksum)
void Update() override
void SetText(const WideString &wsText) override
bool IsProtectedType() const
void SetTextLocation(BC_TEXT_LOC location)
~CFWL_Barcode() override
void OnProcessMessage(CFWL_Message *pMessage) override
void SetAliasChar(wchar_t wAlias)
void SetScrollOffset(float fScrollOffset) override
void OnTextWillChange(CFDE_TextEditEngine::TextChange *change) override
FWL_WidgetHit HitTest(const CFX_PointF &point) override
WideString GetText() const
CFDE_TextEditEngine * GetTxtEdtEngine()
Definition cfwl_edit.h:109
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
CFX_RectF GetWidgetRect() override
Definition cfwl_edit.cpp:79
virtual void SetTextSkipNotify(const WideString &wsText)
bool OnValidate(const WideString &wsText) override
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
std::pair< size_t, size_t > GetSelection() const
void Trace(cppgc::Visitor *visitor) const override
Definition cfwl_edit.cpp:69
bool Paste(const WideString &wsPaste)
void NotifyTextFull() override
void Update() override
void OnTextChanged() override
CFWL_Edit(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
Definition cfwl_edit.cpp:52
void OnSelChanged() override
const CFX_RectF & GetRTClient() const
Definition cfwl_edit.h:108
~CFWL_Edit() override
int32_t GetLimit() const
std::optional< WideString > Copy()
size_t GetTextLength() const
bool HasSelection() const
std::optional< WideString > Cut()
void SetStates(uint32_t dwStates) override
FWL_Type GetClassID() const override
Definition cfwl_edit.cpp:75
void SetLimit(int32_t nLimit)
CFX_RectF GetAutosizedWidgetRect() override
Definition cfwl_edit.cpp:91
void ShowCaret(CFX_RectF *pRect)
void HideCaret(CFX_RectF *pRect)
void PreFinalize() override
Definition cfwl_edit.cpp:62
virtual void SetText(const WideString &wsText)
void OnCaretChanged() override
void OnProcessEvent(CFWL_Event *pEvent) override
Type GetType() const
Definition cfwl_event.h:41
IFWL_ThemeProvider * GetThemeProvider() const
bool IsLocked() const
Properties m_Properties
CFX_PTemplate< float > CFX_PointF
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32
fxcrt::WideString WideString
Definition widestring.h:207