Home | History | Annotate | Download | only in basewidget
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      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 _FWL_EDIT_H
      8 #define _FWL_EDIT_H
      9 class CFWL_WidgetImpProperties;
     10 class IFWL_Widget;
     11 class IFWL_EditDP;
     12 class IFWL_Edit;
     13 #define FWL_CLASS_Edit L"FWL_EDIT"
     14 #define FWL_CLASSHASH_Edit 2893987822
     15 #define FWL_STYLEEXT_EDT_ReadOnly (1L << 0)
     16 #define FWL_STYLEEXT_EDT_MultiLine (1L << 1)
     17 #define FWL_STYLEEXT_EDT_WantReturn (1L << 2)
     18 #define FWL_STYLEEXT_EDT_NoHideSel (1L << 3)
     19 #define FWL_STYLEEXT_EDT_AutoHScroll (1L << 4)
     20 #define FWL_STYLEEXT_EDT_AutoVScroll (1L << 5)
     21 #define FWL_STYLEEXT_EDT_NoRedoUndo (1L << 6)
     22 #define FWL_STYLEEXT_EDT_Validate (1L << 7)
     23 #define FWL_STYLEEXT_EDT_Password (1L << 8)
     24 #define FWL_STYLEEXT_EDT_Number (1L << 9)
     25 #define FWL_STYLEEXT_EDT_HSelfAdaption (1L << 10)
     26 #define FWL_STYLEEXT_EDT_VSelfAdaption (1L << 11)
     27 #define FWL_STYLEEXT_EDT_VerticalLayout (1L << 12)
     28 #define FWL_STYLEEXT_EDT_VerticalChars (1L << 13)
     29 #define FWL_STYLEEXT_EDT_ReverseLine (1L << 14)
     30 #define FWL_STYLEEXT_EDT_ArabicShapes (1L << 15)
     31 #define FWL_STYLEEXT_EDT_ExpandTab (1L << 16)
     32 #define FWL_STYLEEXT_EDT_CombText (1L << 17)
     33 #define FWL_STYLEEXT_EDT_HNear (0L << 18)
     34 #define FWL_STYLEEXT_EDT_HCenter (1L << 18)
     35 #define FWL_STYLEEXT_EDT_HFar (2L << 18)
     36 #define FWL_STYLEEXT_EDT_VNear (0L << 20)
     37 #define FWL_STYLEEXT_EDT_VCenter (1L << 20)
     38 #define FWL_STYLEEXT_EDT_VFar (2L << 20)
     39 #define FWL_STYLEEXT_EDT_Justified (1L << 22)
     40 #define FWL_STYLEEXT_EDT_Distributed (2L << 22)
     41 #define FWL_STYLEEXT_EDT_HAlignMask (3L << 18)
     42 #define FWL_STYLEEXT_EDT_VAlignMask (3L << 20)
     43 #define FWL_STYLEEXT_EDT_HAlignModeMask (3L << 22)
     44 #define FWL_STYLEEXT_EDT_InnerCaret (1L << 24)
     45 #define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25)
     46 #define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26)
     47 #define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27)
     48 #define FWL_STATE_EDT_Editing (1 << FWL_WGTSTATE_MAX)
     49 #define FWL_PART_EDT_Border 1
     50 #define FWL_PART_EDT_Edge 2
     51 #define FWL_PART_EDT_Background 3
     52 #define FWL_PART_EDT_CombTextLine 4
     53 #define FWL_PARTDATA_EDT_Background 0
     54 #define FWL_PARTDATA_EDT_StaticBackground 1
     55 #define FWL_PARTSTATE_EDT_Normal (0L << 0)
     56 #define FWL_PARTSTATE_EDT_ReadOnly (1L << 0)
     57 #define FWL_PARTSTATE_EDT_Disable (2L << 0)
     58 enum FWL_EDT_TEXTCHANGED {
     59   FWL_EDT_TEXTCHANGED_Insert = 0,
     60   FWL_EDT_TEXTCHANGED_Delete,
     61   FWL_EDT_TEXTCHANGED_Replace,
     62 };
     63 #define FWL_EVT_EDT_AddDoRecord L"FWL_EVENT_EDT_AddDoRecord"
     64 #define FWL_EVTHASH_EDT_AddDoRecord 3701672224
     65 #define FWL_EVT_EDT_TextChanged L"FWL_EVENT_EDT_TextChanged"
     66 #define FWL_EVTHASH_EDT_TextChanged 1064022132
     67 #define FWL_EVT_EDT_PreSelfAdaption L"FWL_EVENT_PreSelfAdaption"
     68 #define FWL_EVTHASH_EDT_PreSelfAdaption 1001979178
     69 #define FWL_EVT_EDT_Validate L"FWL_EVTHASH_EDT_Validate"
     70 #define FWL_EVTHASH_EDT_Validate 3373308608
     71 #define FWL_EVT_EDT_CheckWord L"FWL_EVTHASH_EDT_CheckWord"
     72 #define FWL_EVTHASH_EDT_CheckWord 2897181520
     73 #define FWL_EVT_EDT_GetSuggestWords L"FWL_EVTHASH_EDT_GetSuggestWords"
     74 #define FWL_EVTHASH_EDT_GetSuggestWords 315782791
     75 #define FWL_EVT_EDT_TextFull L"FWL_EVTHASH_EDT_TextFull"
     76 #define FWL_EVTHASH_EDT_TextFull 2158580174
     77 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtAddDoRecord, FWL_EVTHASH_EDT_AddDoRecord)
     78 CFX_ByteString m_wsDoRecord;
     79 END_FWL_EVENT_DEF
     80 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, FWL_EVTHASH_EDT_TextChanged)
     81 int32_t nChangeType;
     82 CFX_WideString wsInsert;
     83 CFX_WideString wsDelete;
     84 CFX_WideString wsPrevText;
     85 END_FWL_EVENT_DEF
     86 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextFull, FWL_EVTHASH_EDT_TextFull)
     87 END_FWL_EVENT_DEF
     88 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, FWL_EVTHASH_EDT_PreSelfAdaption)
     89 FX_BOOL bHSelfAdaption;
     90 FX_BOOL bVSelfAdaption;
     91 CFX_RectF rtAfterChange;
     92 END_FWL_EVENT_DEF
     93 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtValidate, FWL_EVTHASH_EDT_Validate)
     94 IFWL_Widget* pDstWidget;
     95 CFX_WideString wsInsert;
     96 FX_BOOL bValidate;
     97 END_FWL_EVENT_DEF
     98 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, FWL_EVTHASH_EDT_CheckWord)
     99 CFX_ByteString bsWord;
    100 FX_BOOL bCheckWord;
    101 END_FWL_EVENT_DEF
    102 BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, FWL_EVTHASH_EDT_GetSuggestWords)
    103 FX_BOOL bSuggestWords;
    104 CFX_ByteString bsWord;
    105 CFX_ByteStringArray bsArraySuggestWords;
    106 END_FWL_EVENT_DEF
    107 class IFWL_EditDP : public IFWL_DataProvider {};
    108 #define FWL_EDT_FIND_FLAGS_Prev (0L << 0)
    109 #define FWL_EDT_FIND_FLAGS_Next (1L << 0)
    110 #define FWL_EDT_FIND_FLAGS_WholeWord (1L << 1)
    111 #define FWL_EDT_FIND_FLAGS_NoCase (1L << 2)
    112 typedef struct _FWL_HEDTFIND { void* pData; } * FWL_HEDTFIND;
    113 class IFWL_Edit : public IFWL_Widget {
    114  public:
    115   static IFWL_Edit* Create(const CFWL_WidgetImpProperties& properties,
    116                            IFWL_Widget* pOuter);
    117   static IFWL_Edit* CreateComboEdit(const CFWL_WidgetImpProperties& properties,
    118                                     IFWL_Widget* pOuter);
    119 
    120   FWL_ERR SetText(const CFX_WideString& wsText);
    121   int32_t GetTextLength() const;
    122   FWL_ERR GetText(CFX_WideString& wsText,
    123                   int32_t nStart = 0,
    124                   int32_t nCount = -1) const;
    125   FWL_ERR ClearText();
    126   int32_t GetCaretPos() const;
    127   int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
    128   FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
    129   int32_t CountSelRanges();
    130   int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
    131   FWL_ERR ClearSelections();
    132   int32_t GetLimit();
    133   FWL_ERR SetLimit(int32_t nLimit);
    134   FWL_ERR SetAliasChar(FX_WCHAR wAlias);
    135   FWL_ERR SetFormatString(const CFX_WideString& wsFormat);
    136   FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
    137   FWL_ERR DeleteSelections();
    138   FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
    139   FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace);
    140   FWL_ERR Replace(int32_t nStart,
    141                   int32_t nLen,
    142                   const CFX_WideStringC& wsReplace);
    143   FWL_ERR DoClipboard(int32_t iCmd);
    144   FX_BOOL Copy(CFX_WideString& wsCopy);
    145   FX_BOOL Cut(CFX_WideString& wsCut);
    146   FX_BOOL Paste(const CFX_WideString& wsPaste);
    147   FX_BOOL Delete();
    148   FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
    149   FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
    150   FX_BOOL Undo();
    151   FX_BOOL Redo();
    152   FX_BOOL CanUndo();
    153   FX_BOOL CanRedo();
    154   FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
    155   FWL_ERR SetOuter(IFWL_Widget* pOuter);
    156   FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
    157   FWL_ERR SetBackColor(FX_DWORD dwColor);
    158   FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
    159   void SetScrollOffset(FX_FLOAT fScrollOffset);
    160   FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
    161   FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
    162                                 const CFX_ByteStringC& bsReplace);
    163 
    164  protected:
    165   IFWL_Edit();
    166 };
    167 #endif
    168