diff options
Diffstat (limited to 'fpdfsdk/fxedit/include')
-rw-r--r-- | fpdfsdk/fxedit/include/DEPS | 3 | ||||
-rw-r--r-- | fpdfsdk/fxedit/include/fx_edit.h | 23 | ||||
-rw-r--r-- | fpdfsdk/fxedit/include/fxet_edit.h | 560 | ||||
-rw-r--r-- | fpdfsdk/fxedit/include/fxet_list.h | 304 |
4 files changed, 0 insertions, 890 deletions
diff --git a/fpdfsdk/fxedit/include/DEPS b/fpdfsdk/fxedit/include/DEPS deleted file mode 100644 index 0b00511fb2..0000000000 --- a/fpdfsdk/fxedit/include/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - '+core/fpdfdoc', -] diff --git a/fpdfsdk/fxedit/include/fx_edit.h b/fpdfsdk/fxedit/include/fx_edit.h deleted file mode 100644 index da93071f23..0000000000 --- a/fpdfsdk/fxedit/include/fx_edit.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_ -#define FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_ - -#include "core/fxcrt/fx_basic.h" - -class IPVT_FontMap; - -#define FX_EDIT_ISLATINWORD(u) \ - (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \ - (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0)) - -CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, - int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord); - -#endif // FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_ diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h deleted file mode 100644 index 652dbbf2ce..0000000000 --- a/fpdfsdk/fxedit/include/fxet_edit.h +++ /dev/null @@ -1,560 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ -#define FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ - -#include <memory> - -#include "core/fpdfdoc/cpvt_secprops.h" -#include "core/fpdfdoc/cpvt_wordprops.h" -#include "fpdfsdk/fxedit/include/fx_edit.h" - -class CFFL_FormFiller; -class CFX_Edit; -class CFX_Edit_Iterator; -class CFX_Edit_Provider; -class CFX_RenderDevice; -class CFX_SystemHandler; -class CPDF_PageObjectHolder; -class CPDF_TextObject; -class CPWL_Edit; -class CPWL_EditCtrl; - -class IFX_Edit_UndoItem; - -struct CFX_Edit_LineRect { - CFX_Edit_LineRect(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) - : m_wrLine(wrLine), m_rcLine(rcLine) {} - - CPVT_WordRange m_wrLine; - CFX_FloatRect m_rcLine; -}; - -class CFX_Edit_LineRectArray { - public: - CFX_Edit_LineRectArray(); - virtual ~CFX_Edit_LineRectArray(); - - void Empty(); - void RemoveAll(); - void operator=(CFX_Edit_LineRectArray& rects); - void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine); - - int32_t GetSize() const; - CFX_Edit_LineRect* GetAt(int32_t nIndex) const; - - private: - CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; -}; - -class CFX_Edit_RectArray { - public: - CFX_Edit_RectArray(); - virtual ~CFX_Edit_RectArray(); - - void Empty(); - void Add(const CFX_FloatRect& rect); - - int32_t GetSize() const; - CFX_FloatRect* GetAt(int32_t nIndex) const; - - private: - CFX_ArrayTemplate<CFX_FloatRect*> m_Rects; -}; - -class CFX_Edit_Refresh { - public: - CFX_Edit_Refresh(); - virtual ~CFX_Edit_Refresh(); - - void BeginRefresh(); - void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect); - void NoAnalyse(); - void AddRefresh(const CFX_FloatRect& rect); - const CFX_Edit_RectArray* GetRefreshRects() const; - void EndRefresh(); - - private: - CFX_Edit_LineRectArray m_NewLineRects; - CFX_Edit_LineRectArray m_OldLineRects; - CFX_Edit_RectArray m_RefreshRects; -}; - -class CFX_Edit_Select { - public: - CFX_Edit_Select(); - CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); - explicit CFX_Edit_Select(const CPVT_WordRange& range); - - void Default(); - void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); - void SetBeginPos(const CPVT_WordPlace& begin); - void SetEndPos(const CPVT_WordPlace& end); - - CPVT_WordRange ConvertToWordRange() const; - FX_BOOL IsExist() const; - - CPVT_WordPlace BeginPos, EndPos; -}; - -class CFX_Edit_Undo { - public: - explicit CFX_Edit_Undo(int32_t nBufsize); - virtual ~CFX_Edit_Undo(); - - void Undo(); - void Redo(); - - void AddItem(IFX_Edit_UndoItem* pItem); - - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - - void Reset(); - - private: - void RemoveHeads(); - void RemoveTails(); - - private: - CFX_ArrayTemplate<IFX_Edit_UndoItem*> m_UndoItemStack; - - int32_t m_nCurUndoPos; - int32_t m_nBufSize; - FX_BOOL m_bModified; - FX_BOOL m_bVirgin; - FX_BOOL m_bWorking; -}; - -class IFX_Edit_UndoItem { - public: - virtual ~IFX_Edit_UndoItem() {} - - virtual void Undo() = 0; - virtual void Redo() = 0; - virtual CFX_WideString GetUndoTitle() = 0; -}; - -class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { - public: - CFX_Edit_UndoItem(); - ~CFX_Edit_UndoItem() override; - - CFX_WideString GetUndoTitle() override; - - void SetFirst(FX_BOOL bFirst); - void SetLast(FX_BOOL bLast); - FX_BOOL IsLast(); - - private: - FX_BOOL m_bFirst; - FX_BOOL m_bLast; -}; - -class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { - public: - explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); - ~CFX_Edit_GroupUndoItem() override; - - // IFX_Edit_UndoItem - void Undo() override; - void Redo() override; - CFX_WideString GetUndoTitle() override; - - void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); - void UpdateItems(); - - private: - CFX_WideString m_sTitle; - CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items; -}; - -class CFXEU_InsertWord : public CFX_Edit_UndoItem { - public: - CFXEU_InsertWord(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_WordProps* pWordProps); - ~CFXEU_InsertWord() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_InsertReturn : public CFX_Edit_UndoItem { - public: - CFXEU_InsertReturn(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps); - ~CFXEU_InsertReturn() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Backspace : public CFX_Edit_UndoItem { - public: - CFXEU_Backspace(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_SecProps& SecProps, - const CPVT_WordProps& WordProps); - ~CFXEU_Backspace() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Delete : public CFX_Edit_UndoItem { - public: - CFXEU_Delete(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - uint16_t word, - int32_t charset, - const CPVT_SecProps& SecProps, - const CPVT_WordProps& WordProps, - FX_BOOL bSecEnd); - ~CFXEU_Delete() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - uint16_t m_Word; - int32_t m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; - FX_BOOL m_bSecEnd; -}; - -class CFXEU_Clear : public CFX_Edit_UndoItem { - public: - CFXEU_Clear(CFX_Edit* pEdit, - const CPVT_WordRange& wrSel, - const CFX_WideString& swText); - ~CFXEU_Clear() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordRange m_wrSel; - CFX_WideString m_swText; -}; - -class CFXEU_InsertText : public CFX_Edit_UndoItem { - public: - CFXEU_InsertText(CFX_Edit* pEdit, - const CPVT_WordPlace& wpOldPlace, - const CPVT_WordPlace& wpNewPlace, - const CFX_WideString& swText, - int32_t charset); - ~CFXEU_InsertText() override; - - // CFX_Edit_UndoItem - void Redo() override; - void Undo() override; - - private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CFX_WideString m_swText; - int32_t m_nCharset; -}; - -class CFX_Edit { - public: - static CFX_ByteString GetEditAppearanceStream(CFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - FX_BOOL bContinuous, - uint16_t SubWord); - static CFX_ByteString GetSelectAppearanceStream( - CFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange); - static void DrawEdit(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - CFX_Edit* pEdit, - FX_COLORREF crTextFill, - FX_COLORREF crTextStroke, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - CFX_SystemHandler* pSystemHandler, - CFFL_FormFiller* pFFLData); - static void GeneratePageObjects( - CPDF_PageObjectHolder* pObjectHolder, - CFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - FX_COLORREF crText, - CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray); - - CFX_Edit(); - ~CFX_Edit(); - - void SetFontMap(IPVT_FontMap* pFontMap); - void SetNotify(CPWL_EditCtrl* pNotify); - void SetOprNotify(CPWL_Edit* pOprNotify); - - // Returns an iterator for the contents. Should not be released. - CFX_Edit_Iterator* GetIterator(); - IPVT_FontMap* GetFontMap(); - void Initialize(); - - // Set the bounding box of the text area. - void SetPlateRect(const CFX_FloatRect& rect); - void SetScrollPos(const CFX_FloatPoint& point); - - // Set the horizontal text alignment. (nFormat [0:left, 1:middle, 2:right]) - void SetAlignmentH(int32_t nFormat, FX_BOOL bPaint); - // Set the vertical text alignment. (nFormat [0:left, 1:middle, 2:right]) - void SetAlignmentV(int32_t nFormat, FX_BOOL bPaint); - - // Set the substitution character for hidden text. - void SetPasswordChar(uint16_t wSubWord, FX_BOOL bPaint); - - // Set the maximum number of words in the text. - void SetLimitChar(int32_t nLimitChar); - void SetCharArray(int32_t nCharArray); - void SetCharSpace(FX_FLOAT fCharSpace); - void SetMultiLine(FX_BOOL bMultiLine, FX_BOOL bPaint); - void SetAutoReturn(FX_BOOL bAuto, FX_BOOL bPaint); - void SetAutoFontSize(FX_BOOL bAuto, FX_BOOL bPaint); - void SetAutoScroll(FX_BOOL bAuto, FX_BOOL bPaint); - void SetFontSize(FX_FLOAT fFontSize); - void SetTextOverflow(FX_BOOL bAllowed, FX_BOOL bPaint); - void OnMouseDown(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); - void OnMouseMove(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl); - void SetText(const CFX_WideString& sText); - FX_BOOL InsertWord(uint16_t word, int32_t charset); - FX_BOOL InsertReturn(); - FX_BOOL Backspace(); - FX_BOOL Delete(); - FX_BOOL Clear(); - FX_BOOL InsertText(const CFX_WideString& sText, int32_t charset); - FX_BOOL Redo(); - FX_BOOL Undo(); - int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; - CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; - CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const; - int32_t GetCaret() const; - CPVT_WordPlace GetCaretWordPlace() const; - CFX_WideString GetSelText() const; - CFX_WideString GetText() const; - FX_FLOAT GetFontSize() const; - uint16_t GetPasswordChar() const; - CFX_FloatPoint GetScrollPos() const; - int32_t GetCharArray() const; - CFX_FloatRect GetContentRect() const; - CFX_WideString GetRangeText(const CPVT_WordRange& range) const; - int32_t GetHorzScale() const; - FX_FLOAT GetCharSpace() const; - int32_t GetTotalWords() const; - void SetSel(int32_t nStartChar, int32_t nEndChar); - void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; - void SelectAll(); - void SelectNone(); - FX_BOOL IsSelected() const; - void Paint(); - void EnableRefresh(FX_BOOL bRefresh); - void RefreshWordRange(const CPVT_WordRange& wr); - void SetCaret(int32_t nPos); - CPVT_WordRange GetWholeWordRange() const; - CPVT_WordRange GetSelectWordRange() const; - void EnableUndo(FX_BOOL bUndo); - void EnableOprNotify(FX_BOOL bNotify); - FX_BOOL IsTextFull() const; - FX_BOOL IsTextOverflow() const; - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - CPVT_WordRange GetVisibleWordRange() const; - - FX_BOOL Empty(); - - CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place, - const CFX_WideString& sText, - int32_t charset); - int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset); - - int32_t GetTotalLines() const; - - private: - friend class CFX_Edit_Iterator; - friend class CFXEU_InsertWord; - friend class CFXEU_InsertReturn; - friend class CFXEU_Backspace; - friend class CFXEU_Delete; - friend class CFXEU_Clear; - friend class CFXEU_InsertText; - - void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); - - void RearrangeAll(); - void RearrangePart(const CPVT_WordRange& range); - void ScrollToCaret(); - void SetScrollInfo(); - void SetScrollPosX(FX_FLOAT fx); - void SetScrollPosY(FX_FLOAT fy); - void SetScrollLimit(); - void SetContentChanged(); - - FX_BOOL InsertWord(uint16_t word, - int32_t charset, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps, - const CPVT_WordProps* pWordProps, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL InsertText(const CFX_WideString& sText, - int32_t charset, - FX_BOOL bAddUndo, - FX_BOOL bPaint); - void PaintInsertText(const CPVT_WordPlace& wpOld, - const CPVT_WordPlace& wpNew); - - inline CFX_FloatPoint VTToEdit(const CFX_FloatPoint& point) const; - inline CFX_FloatPoint EditToVT(const CFX_FloatPoint& point) const; - inline CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const; - - void Refresh(); - void RefreshPushLineRects(const CPVT_WordRange& wr); - - void SetCaret(const CPVT_WordPlace& place); - void SetCaretInfo(); - void SetCaretOrigin(); - - void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem); - - private: - std::unique_ptr<CPDF_VariableText> m_pVT; - CPWL_EditCtrl* m_pNotify; - CPWL_Edit* m_pOprNotify; - std::unique_ptr<CFX_Edit_Provider> m_pVTProvider; - - CPVT_WordPlace m_wpCaret; - CPVT_WordPlace m_wpOldCaret; - CFX_Edit_Select m_SelState; - - CFX_FloatPoint m_ptScrollPos; - CFX_FloatPoint m_ptRefreshScrollPos; - FX_BOOL m_bEnableScroll; - std::unique_ptr<CFX_Edit_Iterator> m_pIterator; - CFX_Edit_Refresh m_Refresh; - CFX_FloatPoint m_ptCaret; - CFX_Edit_Undo m_Undo; - int32_t m_nAlignment; - FX_BOOL m_bNotifyFlag; - FX_BOOL m_bEnableOverflow; - FX_BOOL m_bEnableRefresh; - CFX_FloatRect m_rcOldContent; - FX_BOOL m_bEnableUndo; - FX_BOOL m_bOprNotify; - CFX_Edit_GroupUndoItem* m_pGroupUndoItem; -}; - -class CFX_Edit_Iterator { - public: - CFX_Edit_Iterator(CFX_Edit* pEdit, CPDF_VariableText::Iterator* pVTIterator); - ~CFX_Edit_Iterator(); - - FX_BOOL NextWord(); - FX_BOOL PrevWord(); - FX_BOOL GetWord(CPVT_Word& word) const; - FX_BOOL GetLine(CPVT_Line& line) const; - FX_BOOL GetSection(CPVT_Section& section) const; - void SetAt(int32_t nWordIndex); - void SetAt(const CPVT_WordPlace& place); - const CPVT_WordPlace& GetAt() const; - - private: - CFX_Edit* m_pEdit; - CPDF_VariableText::Iterator* m_pVTIterator; -}; - -class CFX_Edit_Provider : public CPDF_VariableText::Provider { - public: - explicit CFX_Edit_Provider(IPVT_FontMap* pFontMap); - ~CFX_Edit_Provider() override; - - IPVT_FontMap* GetFontMap(); - - // CPDF_VariableText::Provider: - int32_t GetCharWidth(int32_t nFontIndex, uint16_t word) override; - int32_t GetTypeAscent(int32_t nFontIndex) override; - int32_t GetTypeDescent(int32_t nFontIndex) override; - int32_t GetWordFontIndex(uint16_t word, - int32_t charset, - int32_t nFontIndex) override; - int32_t GetDefaultFontIndex() override; - FX_BOOL IsLatinWord(uint16_t word) override; - - private: - IPVT_FontMap* m_pFontMap; -}; - -#endif // FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ diff --git a/fpdfsdk/fxedit/include/fxet_list.h b/fpdfsdk/fxedit/include/fxet_list.h deleted file mode 100644 index 1d738c0dcc..0000000000 --- a/fpdfsdk/fxedit/include/fxet_list.h +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ -#define FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ - -#include "core/fxcrt/fx_coordinates.h" -#include "fpdfsdk/fxedit/include/fx_edit.h" - -class CFX_Edit; -class CFX_Edit_Iterator; -class CPWL_List_Notify; - -class CLST_Rect : public CFX_FloatRect { - public: - CLST_Rect() { left = top = right = bottom = 0.0f; } - - CLST_Rect(FX_FLOAT other_left, - FX_FLOAT other_top, - FX_FLOAT other_right, - FX_FLOAT other_bottom) { - left = other_left; - top = other_top; - right = other_right; - bottom = other_bottom; - } - - explicit CLST_Rect(const CFX_FloatRect& rect) { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - } - - ~CLST_Rect() {} - - void Default() { left = top = right = bottom = 0.0f; } - - const CLST_Rect operator=(const CFX_FloatRect& rect) { - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; - - return *this; - } - - bool operator==(const CLST_Rect& rect) const { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; - } - - bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); } - - FX_FLOAT Width() const { return right - left; } - - FX_FLOAT Height() const { - if (top > bottom) - return top - bottom; - return bottom - top; - } - - CFX_FloatPoint LeftTop() const { return CFX_FloatPoint(left, top); } - - CFX_FloatPoint RightBottom() const { return CFX_FloatPoint(right, bottom); } - - const CLST_Rect operator+=(const CFX_FloatPoint& point) { - left += point.x; - right += point.x; - top += point.y; - bottom += point.y; - - return *this; - } - - const CLST_Rect operator-=(const CFX_FloatPoint& point) { - left -= point.x; - right -= point.x; - top -= point.y; - bottom -= point.y; - - return *this; - } - - CLST_Rect operator+(const CFX_FloatPoint& point) const { - return CLST_Rect(left + point.x, top + point.y, right + point.x, - bottom + point.y); - } - - CLST_Rect operator-(const CFX_FloatPoint& point) const { - return CLST_Rect(left - point.x, top - point.y, right - point.x, - bottom - point.y); - } -}; - -class CFX_ListItem final { - public: - CFX_ListItem(); - ~CFX_ListItem(); - - void SetFontMap(IPVT_FontMap* pFontMap); - CFX_Edit* GetEdit() const; - - void SetRect(const CLST_Rect& rect); - void SetSelect(FX_BOOL bSelected); - void SetText(const CFX_WideString& text); - void SetFontSize(FX_FLOAT fFontSize); - CFX_WideString GetText() const; - - CLST_Rect GetRect() const; - FX_BOOL IsSelected() const; - FX_FLOAT GetItemHeight() const; - uint16_t GetFirstChar() const; - - private: - CFX_Edit_Iterator* GetIterator() const; - - std::unique_ptr<CFX_Edit> m_pEdit; - FX_BOOL m_bSelected; - CLST_Rect m_rcListItem; -}; - -class CFX_ListContainer { - public: - CFX_ListContainer(); - virtual ~CFX_ListContainer(); - - virtual void SetPlateRect(const CFX_FloatRect& rect); - - CFX_FloatRect GetPlateRect() const { return m_rcPlate; } - void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } - CLST_Rect GetContentRect() const { return m_rcContent; } - CFX_FloatPoint GetBTPoint() const { - return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); - } - CFX_FloatPoint GetETPoint() const { - return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); - } - - public: - CFX_FloatPoint InnerToOuter(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); - } - CFX_FloatPoint OuterToInner(const CFX_FloatPoint& point) const { - return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); - } - CFX_FloatRect InnerToOuter(const CLST_Rect& rect) const { - CFX_FloatPoint ptLeftTop = - InnerToOuter(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - InnerToOuter(CFX_FloatPoint(rect.right, rect.bottom)); - return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, - ptLeftTop.y); - } - CLST_Rect OuterToInner(const CFX_FloatRect& rect) const { - CFX_FloatPoint ptLeftTop = - OuterToInner(CFX_FloatPoint(rect.left, rect.top)); - CFX_FloatPoint ptRightBottom = - OuterToInner(CFX_FloatPoint(rect.right, rect.bottom)); - return CLST_Rect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, - ptRightBottom.y); - } - - private: - CFX_FloatRect m_rcPlate; - CLST_Rect m_rcContent; // positive forever! -}; - -template <class TYPE> -class CLST_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { - public: - FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } - TYPE GetAt(int32_t nIndex) const { - if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) - return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); - return nullptr; - } - void RemoveAt(int32_t nIndex) { - if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) - CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); - } -}; - -struct CPLST_Select_Item { - CPLST_Select_Item(int32_t other_nItemIndex, int32_t other_nState) { - nItemIndex = other_nItemIndex; - nState = other_nState; - } - - int32_t nItemIndex; - int32_t nState; // 0:normal select -1:to deselect 1: to select -}; - -class CPLST_Select { - public: - CPLST_Select(); - virtual ~CPLST_Select(); - - public: - void Add(int32_t nItemIndex); - void Add(int32_t nBeginIndex, int32_t nEndIndex); - void Sub(int32_t nItemIndex); - void Sub(int32_t nBeginIndex, int32_t nEndIndex); - FX_BOOL IsExist(int32_t nItemIndex) const; - int32_t Find(int32_t nItemIndex) const; - int32_t GetCount() const; - int32_t GetItemIndex(int32_t nIndex) const; - int32_t GetState(int32_t nIndex) const; - void Done(); - void DeselectAll(); - - private: - CFX_ArrayTemplate<CPLST_Select_Item*> m_aItems; -}; - -class CFX_ListCtrl : protected CFX_ListContainer { - public: - CFX_ListCtrl(); - ~CFX_ListCtrl() override; - - // CFX_ListContainer - void SetPlateRect(const CFX_FloatRect& rect) override; - - void SetNotify(CPWL_List_Notify* pNotify); - void OnMouseDown(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); - void OnMouseMove(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl); - void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl); - FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl); - - void SetScrollPos(const CFX_FloatPoint& point); - void ScrollToListItem(int32_t nItemIndex); - CFX_FloatRect GetItemRect(int32_t nIndex) const; - int32_t GetCaret() const; - int32_t GetSelect() const; - int32_t GetTopItem() const; - CFX_FloatRect GetContentRect() const; - int32_t GetItemIndex(const CFX_FloatPoint& point) const; - void AddString(const CFX_WideString& str); - void SetTopItem(int32_t nIndex); - void Select(int32_t nItemIndex); - void SetCaret(int32_t nItemIndex); - void Empty(); - void Cancel(); - CFX_WideString GetText() const; - - void SetFontMap(IPVT_FontMap* pFontMap); - void SetFontSize(FX_FLOAT fFontSize); - CFX_FloatRect GetPlateRect() const; - FX_FLOAT GetFontSize() const; - CFX_Edit* GetItemEdit(int32_t nIndex) const; - int32_t GetCount() const; - FX_BOOL IsItemSelected(int32_t nIndex) const; - FX_FLOAT GetFirstHeight() const; - void SetMultipleSel(FX_BOOL bMultiple); - FX_BOOL IsMultipleSel() const; - FX_BOOL IsValid(int32_t nItemIndex) const; - int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const; - int32_t GetFirstSelected() const; - - CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const; - CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const; - CFX_FloatRect InToOut(const CFX_FloatRect& rect) const; - CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const; - - private: - void ReArrange(int32_t nItemIndex); - CFX_FloatRect GetItemRectInternal(int32_t nIndex) const; - CFX_FloatRect GetContentRectInternal() const; - void SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected); - void SetSingleSelect(int32_t nItemIndex); - void InvalidateItem(int32_t nItemIndex); - void SelectItems(); - FX_BOOL IsItemVisible(int32_t nItemIndex) const; - void SetScrollInfo(); - void SetScrollPosY(FX_FLOAT fy); - void AddItem(const CFX_WideString& str); - CFX_WideString GetItemText(int32_t nIndex) const; - void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); - int32_t GetLastSelected() const; - FX_WCHAR Toupper(FX_WCHAR c) const; - - CPWL_List_Notify* m_pNotify; - FX_BOOL m_bNotifyFlag; - CFX_FloatPoint m_ptScrollPos; - CPLST_Select m_aSelItems; // for multiple - int32_t m_nSelItem; // for single - int32_t m_nFootIndex; // for multiple - FX_BOOL m_bCtrlSel; // for multiple - int32_t m_nCaretIndex; // for multiple - CLST_ArrayTemplate<CFX_ListItem*> m_aListItems; - FX_FLOAT m_fFontSize; - IPVT_FontMap* m_pFontMap; - FX_BOOL m_bMultiple; -}; - -#endif // FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ |