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_COMBOBOX_H
      8 #define _FWL_COMBOBOX_H
      9 class CFWL_WidgetImpProperties;
     10 class IFWL_Widget;
     11 class IFWL_ListBox;
     12 class IFWL_ComboBoxDP;
     13 class IFWL_ComboBox;
     14 #define FWL_CLASS_ComboBox L"FWL_COMBOBOX"
     15 #define FWL_CLASSHASH_ComboBox 602353697
     16 #define FWL_STYLEEXT_CMB_DropList (0L << 0)
     17 #define FWL_STYLEEXT_CMB_DropDown (1L << 0)
     18 #define FWL_STYLEEXT_CMB_Sort (1L << 1)
     19 #define FWL_STYLEEXT_CMB_ListDrag (1L << 2)
     20 #define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3)
     21 #define FWL_STYLEEXT_CMB_EditHNear (0L << 4)
     22 #define FWL_STYLEEXT_CMB_EditHCenter (1L << 4)
     23 #define FWL_STYLEEXT_CMB_EditHFar (2L << 4)
     24 #define FWL_STYLEEXT_CMB_EditVNear (0L << 6)
     25 #define FWL_STYLEEXT_CMB_EditVCenter (1L << 6)
     26 #define FWL_STYLEEXT_CMB_EditVFar (2L << 6)
     27 #define FWL_STYLEEXT_CMB_EditJustified (1L << 8)
     28 #define FWL_STYLEEXT_CMB_EditDistributed (2L << 8)
     29 #define FWL_STYLEEXT_CMB_EditHAlignMask (3L << 4)
     30 #define FWL_STYLEEXT_CMB_EditVAlignMask (3L << 6)
     31 #define FWL_STYLEEXT_CMB_EditHAlignModeMask (3L << 8)
     32 #define FWL_STYLEEXT_CMB_ListItemLeftAlign (0L << 10)
     33 #define FWL_STYLEEXT_CMB_ListItemCenterAlign (1L << 10)
     34 #define FWL_STYLEEXT_CMB_ListItemRightAlign (2L << 10)
     35 #define FWL_STYLEEXT_CMB_ListItemText (0L << 12)
     36 #define FWL_STYLEEXT_CMB_ListItemIconText (1L << 12)
     37 #define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 12)
     38 #define FWL_STYLEEXT_CMB_ReadOnly (1L << 13)
     39 #define FWL_PART_CMB_Border 1
     40 #define FWL_PART_CMB_Edge 2
     41 #define FWL_PART_CMB_Background 3
     42 #define FWL_PART_CMB_DropDownButton 4
     43 #define FWL_PART_CMB_Caption 5
     44 #define FWL_PART_CMB_StretcgHandler 6
     45 #define FWL_PARTSTATE_CMB_Normal (0L << 0)
     46 #define FWL_PARTSTATE_CMB_Hovered (1L << 0)
     47 #define FWL_PARTSTATE_CMB_Pressed (2L << 0)
     48 #define FWL_PARTSTATE_CMB_Disabled (3L << 0)
     49 #define FWL_PARTSTATE_CMB_Selected (1L << 2)
     50 #define FWL_WGTCAPACITY_CMB_ComboFormHandler (FWL_WGTCAPACITY_MAX + 7)
     51 enum FWL_CMB_TEXTCHANGED {
     52   FWL_CMB_TEXTCHANGED_Insert = 0,
     53   FWL_CMB_TEXTCHANGED_Delete,
     54   FWL_CMB_TEXTCHANGED_Replace,
     55 };
     56 #define FWL_EVT_CMB_DropDown L"FWL_EVENT_CMB_PreDropDown"
     57 #define FWL_EVT_CMB_PostDropDown L"FWL_EVENT_CMB_PostDropDown"
     58 #define FWL_EVT_CMB_CloseUp L"FWL_EVENT_CMB_CloseUp"
     59 #define FWL_EVT_CMB_EditChanged L"FWL_EVENT_CMB_EditChanged"
     60 #define FWL_EVT_CMB_SelChanged L"FWL_EVENT_CMB_SelChanged"
     61 #define FWL_EVT_CMB_HoverChanged L"FWL_EVENT_CMB_HoverChanged"
     62 #define FWL_EVT_CMB_DrawItem L"FWL_EVENT_CMB_DrawItem"
     63 #define FWL_EVTHASH_CMB_PreDropDown 1357646798
     64 #define FWL_EVTHASH_CMB_PostDropDown 3677010285
     65 #define FWL_EVTHASH_CMB_CloseUp 2871271190
     66 #define FWL_EVTHASH_CMB_EditChanged 1527034762
     67 #define FWL_EVTHASH_CMB_SelChanged 2923227784
     68 #define FWL_EVTHASH_CMB_HoverChanged 944325448
     69 #define FWL_EVTHASH_CMB_DrawItem 917354551
     70 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, FWL_EVTHASH_CMB_PreDropDown)
     71 END_FWL_EVENT_DEF
     72 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, FWL_EVTHASH_CMB_PostDropDown)
     73 END_FWL_EVENT_DEF
     74 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, FWL_EVTHASH_CMB_CloseUp)
     75 END_FWL_EVENT_DEF
     76 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, FWL_EVTHASH_CMB_EditChanged)
     77 int32_t nChangeType;
     78 CFX_WideString wsInsert;
     79 CFX_WideString wsDelete;
     80 END_FWL_EVENT_DEF
     81 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, FWL_EVTHASH_CMB_SelChanged)
     82 CFX_Int32Array iArraySels;
     83 FX_BOOL bLButtonUp;
     84 END_FWL_EVENT_DEF
     85 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, FWL_EVTHASH_CMB_HoverChanged)
     86 int32_t m_iCurHover;
     87 END_FWL_EVENT_DEF
     88 BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, FWL_EVTHASH_CMB_DrawItem)
     89 CFX_Graphics* m_pGraphics;
     90 CFX_Matrix m_matrix;
     91 int32_t m_index;
     92 CFX_RectF m_rtItem;
     93 END_FWL_EVENT_DEF
     94 class IFWL_ComboBoxDP : public IFWL_ListBoxDP {
     95  public:
     96   virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget) = 0;
     97 };
     98 class IFWL_ComboBox : public IFWL_Widget {
     99  public:
    100   static IFWL_ComboBox* Create(const CFWL_WidgetImpProperties& properties);
    101 
    102   int32_t GetCurSel();
    103   FWL_ERR SetCurSel(int32_t iSel);
    104   FWL_ERR SetEditText(const CFX_WideString& wsText);
    105   int32_t GetEditTextLength() const;
    106   FWL_ERR GetEditText(CFX_WideString& wsText,
    107                       int32_t nStart = 0,
    108                       int32_t nCount = -1) const;
    109   FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
    110   int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
    111   int32_t GetEditLimit();
    112   FWL_ERR SetEditLimit(int32_t nLimit);
    113   FWL_ERR EditDoClipboard(int32_t iCmd);
    114   FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
    115   FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
    116   IFWL_ListBox* GetListBoxt();
    117   FX_BOOL AfterFocusShowDropList();
    118   FX_ERR OpenDropDownList(FX_BOOL bActivate);
    119   FX_BOOL EditCanUndo();
    120   FX_BOOL EditCanRedo();
    121   FX_BOOL EditUndo();
    122   FX_BOOL EditRedo();
    123   FX_BOOL EditCanCopy();
    124   FX_BOOL EditCanCut();
    125   FX_BOOL EditCanSelectAll();
    126   FX_BOOL EditCopy(CFX_WideString& wsCopy);
    127   FX_BOOL EditCut(CFX_WideString& wsCut);
    128   FX_BOOL EditPaste(const CFX_WideString& wsPaste);
    129   FX_BOOL EditSelectAll();
    130   FX_BOOL EditDelete();
    131   FX_BOOL EditDeSelect();
    132   FWL_ERR GetBBox(CFX_RectF& rect);
    133   FWL_ERR EditModifyStylesEx(FX_DWORD dwStylesExAdded,
    134                              FX_DWORD dwStylesExRemoved);
    135 
    136  protected:
    137   IFWL_ComboBox();
    138 };
    139 #endif
    140