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_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 FPDFSDK_PWL_CPWL_EDIT_H_
8#define FPDFSDK_PWL_CPWL_EDIT_H_
9
10#include <memory>
11#include <utility>
12
13#include "core/fpdfdoc/cpvt_wordrange.h"
14#include "core/fxcrt/fx_codepage.h"
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/widestring.h"
17#include "fpdfsdk/pwl/cpwl_wnd.h"
18#include "fpdfsdk/pwl/ipwl_fillernotify.h"
19
20class CPDF_Font;
21class CPWL_Caret;
22class CPWL_EditImpl;
24
26
28
29class CPWL_Edit final : public CPWL_Wnd {
30 public:
31 CPWL_Edit(const CreateParams& cp,
32 std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData);
33 ~CPWL_Edit() override;
34
35 // CPWL_Wnd:
36 bool RepositionChildWnd() override;
37 CFX_FloatRect GetClientRect() const override;
39 const CFX_Matrix& mtUser2Device) override;
40 bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
41 const CFX_PointF& point,
42 const CFX_Vector& delta) override;
43 bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) override;
44 bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
45 CFX_FloatRect GetFocusRect() const override;
46 void OnSetFocus() override;
47 void OnKillFocus() override;
48 void OnCreated() override;
49 void OnDestroy() override;
50 bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
51 const CFX_PointF& point) override;
52 bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
53 bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
54 const CFX_PointF& point) override;
55 bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
56 bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
57 void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
58 void SetScrollPosition(float pos) override;
59 void ScrollWindowVertically(float pos) override;
60 void CreateChildWnd(const CreateParams& cp) override;
61 void SetFontSize(float fFontSize) override;
62 float GetFontSize() const override;
63 void SetCursor() override;
64 WideString GetText() override;
65 WideString GetSelectedText() override;
66 void ReplaceAndKeepSelection(const WideString& text) override;
67 void ReplaceSelection(const WideString& text) override;
68 bool SelectAllText() override;
69 bool CanUndo() override;
70 bool CanRedo() override;
71 bool Undo() override;
72 bool Redo() override;
73
74 void SetSelection(int32_t nStartChar, int32_t nEndChar);
75 std::pair<int32_t, int32_t> GetSelection() const;
76 void ClearSelection();
77
78 CFX_PointF GetScrollPos() const;
79 void SetScrollPos(const CFX_PointF& point);
80
81 void SetCharSet(FX_Charset nCharSet) { m_nCharSet = nCharSet; }
82 FX_Charset GetCharSet() const { return m_nCharSet; }
83
84 void SetReadyToInput();
86 void SetCharArray(int32_t nCharArray);
87 void SetLimitChar(int32_t nLimitChar);
88 bool CanSelectAll() const;
89 bool CanCopy() const;
90 bool CanCut() const;
91 void CutText();
92 void SetText(const WideString& csText);
93 bool IsTextFull() const;
94
95 static float GetCharArrayAutoFontSize(const CPDF_Font* pFont,
96 const CFX_FloatRect& rcPlate,
97 int32_t nCharArray);
98
99 bool SetCaret(bool bVisible,
100 const CFX_PointF& ptHead,
101 const CFX_PointF& ptFoot);
102
103 private:
104 // In case of implementation swallow the OnKeyDown event. If the event is
105 // swallowed, implementation may do other unexpected things, which is not the
106 // control means to do.
107 static bool IsProceedtoOnChar(FWL_VKEYCODE nKeyCode,
108 Mask<FWL_EVENTFLAG> nFlag);
109
110 bool OnKeyDownInternal(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag);
111 bool OnCharInternal(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag);
112
113 void CopyText();
114 void PasteText();
115 void InsertWord(uint16_t word, FX_Charset nCharset);
116 void InsertReturn();
117 bool IsWndHorV() const;
118 void Delete();
119 void Backspace();
120 void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const;
121 void SetEditCaret(bool bVisible);
122
123 void CreateEditCaret(const CreateParams& cp);
124
125 CPVT_WordRange GetSelectWordRange() const;
126 bool IsVScrollBarVisible() const;
127 void SetParamByFlag();
128
129 bool m_bMouseDown = false;
130 bool m_bFocus = false;
131 FX_Charset m_nCharSet = FX_Charset::kDefault;
132 CFX_FloatRect m_rcOldWindow;
133 std::unique_ptr<CPWL_EditImpl> const m_pEditImpl;
134 UnownedPtr<CPWL_Caret> m_pCaret;
135};
136
137#endif // FPDFSDK_PWL_CPWL_EDIT_H_
BorderStyle
CFX_FloatRect GetCenterSquare() const
constexpr CFX_FloatRect(float l, float b, float r, float t)
float Width() const
bool IsEmpty() const
void ScaleFromCenterPoint(float fScale)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
float Height() const
CFX_FloatRect GetDeflated(float x, float y) const
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void SetAsTextField(absl::optional< WideString > sValue)
CPDFSDK_AppStream(CPDFSDK_Widget *widget, CPDF_Dictionary *dict)
void SetAsComboBox(absl::optional< WideString > sValue)
bool IsNeedHighLight(FormFieldType fieldType) const
std::vector< CPDF_FormField * > GetFieldFromObjects(const std::vector< RetainPtr< const CPDF_Object > > &objects) const
CPDFSDK_Widget * GetWidget(CPDF_FormControl *pControl) const
bool OnKeyStrokeCommit(CPDF_FormField *pFormField, const WideString &csValue)
~CPDFSDK_InteractiveForm() override
void SetHighlightColor(FX_COLORREF clr, FormFieldType fieldType)
void ResetFieldAppearance(CPDF_FormField *pFormField, absl::optional< WideString > sValue)
void SetAllHighlightColors(FX_COLORREF clr)
void GetWidgets(const WideString &sFieldName, std::vector< ObservedPtr< CPDFSDK_Widget > > *widgets) const
void GetWidgets(CPDF_FormField *pField, std::vector< ObservedPtr< CPDFSDK_Widget > > *widgets) const
void AfterFormReset(CPDF_InteractiveForm *pForm) override
FX_COLORREF GetHighlightColor(FormFieldType fieldType)
void AfterCheckedStatusChange(CPDF_FormField *pField) override
void AfterValueChange(CPDF_FormField *pField) override
bool DoAction_SubmitForm(const CPDF_Action &action)
bool BeforeValueChange(CPDF_FormField *pField, const WideString &csValue) override
ByteString ExportFieldsToFDFTextBuf(const std::vector< CPDF_FormField * > &fields, bool bIncludeOrExclude)
void RemoveMap(CPDF_FormControl *pControl)
bool DoAction_Hide(const CPDF_Action &action)
absl::optional< WideString > OnFormat(CPDF_FormField *pFormField)
void AfterSelectionChange(CPDF_FormField *pField) override
void UpdateField(CPDF_FormField *pFormField)
bool SubmitForm(const WideString &sDestination)
void DoAction_ResetForm(const CPDF_Action &action)
void AddMap(CPDF_FormControl *pControl, CPDFSDK_Widget *pWidget)
CPDFSDK_InteractiveForm(CPDFSDK_FormFillEnvironment *pFormFillEnv)
bool BeforeSelectionChange(CPDF_FormField *pField, const WideString &csValue) override
bool OnValidate(CPDF_FormField *pFormField, const WideString &csValue)
CPDF_InteractiveForm * GetInteractiveForm() const
void SetHighlightAlpha(uint8_t alpha)
bool SubmitFields(const WideString &csDestination, const std::vector< CPDF_FormField * > &fields, bool bIncludeOrExclude, bool bUrlEncoded)
void OnCalculate(CPDF_FormField *pFormField)
bool IsModifiedAPStream(const CPDF_Stream *stream) const
RetainPtr< CPDF_Stream > CreateModifiedAPStream()
bool HasMKEntry(const ByteString &csEntry) const
WideString GetDownCaption() const
HighlightingMode GetHighlightingMode() const
WideString GetRolloverCaption() const
CFX_Color GetOriginalBackgroundColor()
CPDF_FormField * GetField() const
WideString GetNormalCaption() const
ByteString GetCheckedAPState() const
CPDF_IconFit GetIconFit() const
CPDF_DefaultAppearance GetDefaultAppearance() const
CFX_Color GetOriginalBorderColor()
int GetTextPosition() const
int GetSelectedIndex(int index) const
int CountOptions() const
WideString GetOptionLabel(int index) const
int CountSelectedItems() const
int GetTopVisibleIndex() const
bool GetFittingBounds() const
uint16_t Word
Definition cpvt_word.h:19
int32_t nFontIndex
Definition cpvt_word.h:26
float fFontSize
Definition cpvt_word.h:27
void SetAt(int32_t nWordIndex)
bool GetWord(CPVT_Word &word) const
bool GetLine(CPVT_Line &line) const
const CPVT_WordPlace & GetAt() const
Iterator * GetIterator()
ByteString GetPDFWordString(int32_t nFontIndex, uint16_t Word, uint16_t SubWord)
IPVT_FontMap * GetFontMap()
bool CanCopy() const
Definition cpwl_edit.cpp:96
static float GetCharArrayAutoFontSize(const CPDF_Font *pFont, const CFX_FloatRect &rcPlate, int32_t nCharArray)
bool IsTextFull() const
void SetScrollInfo(const PWL_SCROLL_INFO &info) override
bool CanRedo() override
void SetFontSize(float fFontSize) override
bool SetCaret(bool bVisible, const CFX_PointF &ptHead, const CFX_PointF &ptFoot)
bool SelectAllText() override
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
bool CanUndo() override
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag) override
CPWL_Edit(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
Definition cpwl_edit.cpp:32
void CutText()
bool Undo() override
bool Redo() override
CFX_FloatRect GetFocusRect() const override
bool RepositionChildWnd() override
Definition cpwl_edit.cpp:49
void SetScrollPosition(float pos) override
void SetAlignFormatVerticalCenter()
Definition cpwl_edit.cpp:87
void SetCursor() override
WideString GetText() override
void SetCharSet(FX_Charset nCharSet)
Definition cpwl_edit.h:81
bool CanCut() const
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnSetFocus() override
void ReplaceAndKeepSelection(const WideString &text) override
void ScrollWindowVertically(float pos) override
void SetCharArray(int32_t nCharArray)
void SetSelection(int32_t nStartChar, int32_t nEndChar)
std::pair< int32_t, int32_t > GetSelection() const
void OnKillFocus() override
void SetScrollPos(const CFX_PointF &point)
void ClearSelection()
void SetText(const WideString &csText)
Definition cpwl_edit.cpp:44
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void ReplaceSelection(const WideString &text) override
CFX_FloatRect GetClientRect() const override
Definition cpwl_edit.cpp:78
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
~CPWL_Edit() override
Definition cpwl_edit.cpp:40
void SetReadyToInput()
bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag) override
void OnCreated() override
WideString GetSelectedText() override
float GetFontSize() const override
void SetLimitChar(int32_t nLimitChar)
FX_Charset GetCharSet() const
Definition cpwl_edit.h:82
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
CFX_PointF GetScrollPos() const
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void CreateChildWnd(const CreateParams &cp) override
void OnDestroy() override
bool CanSelectAll() const
Definition cpwl_edit.cpp:92
CreateParams(CFX_Timer::HandlerIface *timer_handler, IPWL_FillerNotify *filler_notify, ProviderIface *provider)
Definition cpwl_wnd.cpp:36
virtual ByteString GetPDFFontAlias(int32_t nFontIndex)=0
ByteString & operator+=(const ByteString &str)
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
bool IsEmpty() const
Definition bytestring.h:119
WideString & operator=(WideString &&that) noexcept
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
WideString & operator=(const WideString &that)
#define TEXTPOS_ICON
#define TEXTPOS_RIGHT
#define TEXTPOS_LEFT
#define TEXTPOS_BELOW
#define TEXTPOS_OVERLAID
#define TEXTPOS_ABOVE
FormFieldType
PWL_EDIT_ALIGNFORMAT_H
Definition cpwl_edit.h:25
@ PEAH_LEFT
Definition cpwl_edit.h:25
@ PEAH_RIGHT
Definition cpwl_edit.h:25
@ PEAH_MIDDLE
Definition cpwl_edit.h:25
PWL_EDIT_ALIGNFORMAT_V
Definition cpwl_edit.h:27
@ PEAV_CENTER
Definition cpwl_edit.h:27
@ PEAV_TOP
Definition cpwl_edit.h:27
@ PEAV_BOTTOM
Definition cpwl_edit.h:27
#define PWS_VISIBLE
Definition cpwl_wnd.h:33
FX_Charset
Definition fx_codepage.h:70
#define FXSYS_BEZIER
Definition fx_system.h:44
#define FXSYS_PI
Definition fx_system.h:43
#define FXSYS_IsFloatBigger(fa, fb)
Definition fx_system.h:36
#define FXSYS_IsFloatZero(f)
Definition fx_system.h:35
ByteString operator+(const ByteString &str1, const ByteString &str2)
Definition bytestring.h:270
const char kRC[]
const char kIX[]
const char kAC[]
const char kCA[]
const char kI[]
const char kRI[]
CFX_Color operator/(float fColorDivide) const
CFX_Color operator-(float fColorSub) const
float fColor4
Definition cfx_color.h:58
float fColor3
Definition cfx_color.h:57
Type nColorType
Definition cfx_color.h:54
CFX_Color & operator=(const CFX_Color &that)=default
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
Definition cfx_color.h:27
float fColor2
Definition cfx_color.h:56
float fColor1
Definition cfx_color.h:55
int32_t LineCmp(const CPVT_WordPlace &wp) const
CPWL_Dash(int32_t dash, int32_t gap, int32_t phase)
Definition cpwl_wnd.h:63
int32_t nPhase
Definition cpwl_wnd.h:74
int32_t nDash
Definition cpwl_wnd.h:72
int32_t nGap
Definition cpwl_wnd.h:73