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