summaryrefslogtreecommitdiff
path: root/xfa/fwl/basewidget/ifwl_combobox.h
blob: 826404f9aa7d854c09316bd03b76991776d7c49a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// 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 XFA_FWL_BASEWIDGET_IFWL_COMBOBOX_H_
#define XFA_FWL_BASEWIDGET_IFWL_COMBOBOX_H_

#include "xfa/fwl/basewidget/ifwl_listbox.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"

class CFWL_WidgetImpProperties;
class IFWL_ComboBox;

#define FWL_CLASS_ComboBox L"FWL_COMBOBOX"
#define FWL_CLASSHASH_ComboBox 602353697
#define FWL_STYLEEXT_CMB_DropList (0L << 0)
#define FWL_STYLEEXT_CMB_DropDown (1L << 0)
#define FWL_STYLEEXT_CMB_Sort (1L << 1)
#define FWL_STYLEEXT_CMB_ListDrag (1L << 2)
#define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3)
#define FWL_STYLEEXT_CMB_EditHNear (0L << 4)
#define FWL_STYLEEXT_CMB_EditHCenter (1L << 4)
#define FWL_STYLEEXT_CMB_EditHFar (2L << 4)
#define FWL_STYLEEXT_CMB_EditVNear (0L << 6)
#define FWL_STYLEEXT_CMB_EditVCenter (1L << 6)
#define FWL_STYLEEXT_CMB_EditVFar (2L << 6)
#define FWL_STYLEEXT_CMB_EditJustified (1L << 8)
#define FWL_STYLEEXT_CMB_EditDistributed (2L << 8)
#define FWL_STYLEEXT_CMB_EditHAlignMask (3L << 4)
#define FWL_STYLEEXT_CMB_EditVAlignMask (3L << 6)
#define FWL_STYLEEXT_CMB_EditHAlignModeMask (3L << 8)
#define FWL_STYLEEXT_CMB_ListItemLeftAlign (0L << 10)
#define FWL_STYLEEXT_CMB_ListItemCenterAlign (1L << 10)
#define FWL_STYLEEXT_CMB_ListItemRightAlign (2L << 10)
#define FWL_STYLEEXT_CMB_ListItemText (0L << 12)
#define FWL_STYLEEXT_CMB_ListItemIconText (1L << 12)
#define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 12)
#define FWL_STYLEEXT_CMB_ReadOnly (1L << 13)
// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474
#define FWL_EVTHASH_CMB_PreDropDown 1357646798
#define FWL_EVTHASH_CMB_PostDropDown 3677010285
#define FWL_EVTHASH_CMB_CloseUp 2871271190
#define FWL_EVTHASH_CMB_EditChanged 1527034762
#define FWL_EVTHASH_CMB_SelChanged 2923227784
#define FWL_EVTHASH_CMB_HoverChanged 944325448
#define FWL_EVTHASH_CMB_DrawItem 917354551

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, FWL_EVTHASH_CMB_PreDropDown)
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, FWL_EVTHASH_CMB_PostDropDown)
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, FWL_EVTHASH_CMB_CloseUp)
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, FWL_EVTHASH_CMB_EditChanged)
int32_t nChangeType;
CFX_WideString wsInsert;
CFX_WideString wsDelete;
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, FWL_EVTHASH_CMB_SelChanged)
CFX_Int32Array iArraySels;
FX_BOOL bLButtonUp;
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, FWL_EVTHASH_CMB_HoverChanged)
int32_t m_iCurHover;
END_FWL_EVENT_DEF

BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, FWL_EVTHASH_CMB_DrawItem)
CFX_Graphics* m_pGraphics;
CFX_Matrix m_matrix;
int32_t m_index;
CFX_RectF m_rtItem;
END_FWL_EVENT_DEF

class IFWL_ComboBoxDP : public IFWL_ListBoxDP {
 public:
  virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget) = 0;
};

class IFWL_ComboBox : public IFWL_Widget {
 public:
  static IFWL_ComboBox* Create(const CFWL_WidgetImpProperties& properties);

  int32_t GetCurSel();
  FWL_ERR SetCurSel(int32_t iSel);
  FWL_ERR SetEditText(const CFX_WideString& wsText);
  int32_t GetEditTextLength() const;
  FWL_ERR GetEditText(CFX_WideString& wsText,
                      int32_t nStart = 0,
                      int32_t nCount = -1) const;
  FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
  int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
  int32_t GetEditLimit();
  FWL_ERR SetEditLimit(int32_t nLimit);
  FWL_ERR EditDoClipboard(int32_t iCmd);
  FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
  FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
  IFWL_ListBox* GetListBoxt();
  FX_BOOL AfterFocusShowDropList();
  FX_ERR OpenDropDownList(FX_BOOL bActivate);
  FX_BOOL EditCanUndo();
  FX_BOOL EditCanRedo();
  FX_BOOL EditUndo();
  FX_BOOL EditRedo();
  FX_BOOL EditCanCopy();
  FX_BOOL EditCanCut();
  FX_BOOL EditCanSelectAll();
  FX_BOOL EditCopy(CFX_WideString& wsCopy);
  FX_BOOL EditCut(CFX_WideString& wsCut);
  FX_BOOL EditPaste(const CFX_WideString& wsPaste);
  FX_BOOL EditSelectAll();
  FX_BOOL EditDelete();
  FX_BOOL EditDeSelect();
  FWL_ERR GetBBox(CFX_RectF& rect);
  FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded,
                             uint32_t dwStylesExRemoved);

 protected:
  IFWL_ComboBox();
};

#endif  // XFA_FWL_BASEWIDGET_IFWL_COMBOBOX_H_