Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 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 | |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 7 | #include "xfa/fwl/lightwidget/cfwl_combobox.h" |
Dan Sinclair | e73c5ce | 2016-02-25 13:38:37 -0500 | [diff] [blame] | 8 | |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 9 | #include <utility> |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 10 | |
Dan Sinclair | 398a43d | 2016-03-23 15:51:01 -0400 | [diff] [blame] | 11 | #include "xfa/fwl/core/fwl_error.h" |
| 12 | #include "xfa/fwl/core/ifwl_widget.h" |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 13 | |
| 14 | CFWL_ComboBox* CFWL_ComboBox::Create() { |
| 15 | return new CFWL_ComboBox; |
| 16 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 17 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 18 | FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 19 | if (m_pIface) |
| 20 | return FWL_ERR_Indefinite; |
| 21 | if (pProperties) { |
| 22 | *m_pProperties = *pProperties; |
| 23 | } |
| 24 | std::unique_ptr<IFWL_ComboBox> pComboBox(IFWL_ComboBox::Create( |
| 25 | m_pProperties->MakeWidgetImpProperties(&m_comboBoxData))); |
| 26 | FWL_ERR ret = pComboBox->Initialize(); |
| 27 | if (ret != FWL_ERR_Succeeded) { |
| 28 | return ret; |
| 29 | } |
| 30 | m_pIface = pComboBox.release(); |
| 31 | CFWL_Widget::Initialize(); |
| 32 | return FWL_ERR_Succeeded; |
| 33 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 34 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 35 | int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 36 | std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem); |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 37 | pItem->m_wsText = wsText; |
| 38 | pItem->m_dwStyles = 0; |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 39 | m_comboBoxData.m_ItemArray.push_back(std::move(pItem)); |
| 40 | return m_comboBoxData.m_ItemArray.size() - 1; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 41 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 42 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 43 | int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText, |
| 44 | CFX_DIBitmap* pIcon) { |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 45 | std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem); |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 46 | pItem->m_wsText = wsText; |
| 47 | pItem->m_dwStyles = 0; |
| 48 | pItem->m_pDIB = pIcon; |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 49 | m_comboBoxData.m_ItemArray.push_back(std::move(pItem)); |
| 50 | return m_comboBoxData.m_ItemArray.size() - 1; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 51 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 52 | |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 53 | bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { |
Tom Sepez | 9c98adb | 2016-02-05 12:45:58 -0800 | [diff] [blame] | 54 | if (iIndex < 0 || |
| 55 | static_cast<size_t>(iIndex) >= m_comboBoxData.m_ItemArray.size()) { |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 56 | return false; |
Tom Sepez | 9c98adb | 2016-02-05 12:45:58 -0800 | [diff] [blame] | 57 | } |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 58 | m_comboBoxData.m_ItemArray.erase(m_comboBoxData.m_ItemArray.begin() + iIndex); |
| 59 | return true; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 60 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 61 | |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 62 | void CFWL_ComboBox::RemoveAll() { |
| 63 | m_comboBoxData.m_ItemArray.clear(); |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 64 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 65 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 66 | int32_t CFWL_ComboBox::CountItems() { |
| 67 | return m_comboBoxData.CountItems(GetWidget()); |
| 68 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 69 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 70 | FWL_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) { |
| 71 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( |
| 72 | m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 73 | if (!pItem) |
| 74 | return FWL_ERR_Indefinite; |
| 75 | wsText = pItem->m_wsText; |
| 76 | return FWL_ERR_Succeeded; |
| 77 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 78 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 79 | int32_t CFWL_ComboBox::GetCurSel() { |
| 80 | if (!m_pIface) |
| 81 | return -1; |
| 82 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetCurSel(); |
| 83 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 84 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 85 | FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel) { |
| 86 | if (!m_pIface) |
| 87 | return FWL_ERR_Indefinite; |
| 88 | return static_cast<IFWL_ComboBox*>(m_pIface)->SetCurSel(iSel); |
| 89 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 90 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 91 | FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText) { |
| 92 | if (!m_pIface) |
| 93 | return FWL_ERR_Indefinite; |
| 94 | return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditText(wsText); |
| 95 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 96 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 97 | int32_t CFWL_ComboBox::GetEditTextLength() const { |
| 98 | if (!m_pIface) |
| 99 | return 0; |
| 100 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetEditTextLength(); |
| 101 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 102 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 103 | FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString& wsText, |
| 104 | int32_t nStart, |
| 105 | int32_t nCount) const { |
| 106 | if (!m_pIface) |
| 107 | return FWL_ERR_Indefinite; |
| 108 | return static_cast<IFWL_ComboBox*>(m_pIface) |
| 109 | ->GetEditText(wsText, nStart, nCount); |
| 110 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 111 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 112 | FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { |
| 113 | if (!m_pIface) |
| 114 | return FWL_ERR_Indefinite; |
| 115 | return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditSelRange(nStart, nCount); |
| 116 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 117 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 118 | int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { |
| 119 | if (!m_pIface) |
| 120 | return 0; |
| 121 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetEditSelRange(nIndex, nStart); |
| 122 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 123 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 124 | int32_t CFWL_ComboBox::GetEditLimit() { |
| 125 | if (!m_pIface) |
| 126 | return 0; |
| 127 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetEditLimit(); |
| 128 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 129 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 130 | FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit) { |
| 131 | if (!m_pIface) |
| 132 | return FWL_ERR_Indefinite; |
| 133 | return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditLimit(nLimit); |
| 134 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 135 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 136 | FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { |
| 137 | if (!m_pIface) |
| 138 | return FWL_ERR_Indefinite; |
| 139 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditDoClipboard(iCmd); |
| 140 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 141 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 142 | FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) { |
| 143 | if (!m_pIface) |
| 144 | return FALSE; |
| 145 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditRedo(bsRecord); |
| 146 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 147 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 148 | FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) { |
| 149 | if (!m_pIface) |
| 150 | return FALSE; |
| 151 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(bsRecord); |
| 152 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 153 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 154 | FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { |
| 155 | m_comboBoxData.m_fMaxListHeight = fMaxHeight; |
| 156 | return FWL_ERR_Succeeded; |
| 157 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 158 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 159 | FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { |
| 160 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( |
| 161 | m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 162 | if (!pItem) |
| 163 | return FWL_ERR_Indefinite; |
| 164 | pItem->m_pData = pData; |
| 165 | return FWL_ERR_Succeeded; |
| 166 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 167 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 168 | void* CFWL_ComboBox::GetItemData(int32_t iIndex) { |
| 169 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( |
| 170 | m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 171 | if (!pItem) |
| 172 | return NULL; |
| 173 | return pItem->m_pData; |
| 174 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 175 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 176 | FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { |
| 177 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetListBoxt()->SetThemeProvider( |
| 178 | pTheme); |
| 179 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 180 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 181 | FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() { |
| 182 | return static_cast<IFWL_ComboBox*>(m_pIface)->AfterFocusShowDropList(); |
| 183 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 184 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 185 | FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { |
| 186 | return static_cast<IFWL_ComboBox*>(m_pIface)->OpenDropDownList(bActivate); |
| 187 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 188 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 189 | FX_BOOL CFWL_ComboBox::EditCanUndo() { |
| 190 | if (!m_pIface) |
| 191 | return FALSE; |
| 192 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCanUndo(); |
| 193 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 194 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 195 | FX_BOOL CFWL_ComboBox::EditCanRedo() { |
| 196 | if (!m_pIface) |
| 197 | return FALSE; |
| 198 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCanRedo(); |
| 199 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 200 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 201 | FX_BOOL CFWL_ComboBox::EditUndo() { |
| 202 | if (!m_pIface) |
| 203 | return FALSE; |
| 204 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(); |
| 205 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 206 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 207 | FX_BOOL CFWL_ComboBox::EditRedo() { |
| 208 | if (!m_pIface) |
| 209 | return FALSE; |
| 210 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditRedo(); |
| 211 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 212 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 213 | FX_BOOL CFWL_ComboBox::EditCanCopy() { |
| 214 | if (!m_pIface) |
| 215 | return FALSE; |
| 216 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCanCopy(); |
| 217 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 218 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 219 | FX_BOOL CFWL_ComboBox::EditCanCut() { |
| 220 | if (!m_pIface) |
| 221 | return FALSE; |
| 222 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCanCut(); |
| 223 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 224 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 225 | FX_BOOL CFWL_ComboBox::EditCanSelectAll() { |
| 226 | if (!m_pIface) |
| 227 | return FALSE; |
| 228 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCanSelectAll(); |
| 229 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 230 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 231 | FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { |
| 232 | if (!m_pIface) |
| 233 | return FALSE; |
| 234 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCopy(wsCopy); |
| 235 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 236 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 237 | FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) { |
| 238 | if (!m_pIface) |
| 239 | return FALSE; |
| 240 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditCut(wsCut); |
| 241 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 242 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 243 | FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { |
| 244 | if (!m_pIface) |
| 245 | return FALSE; |
| 246 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditPaste(wsPaste); |
| 247 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 248 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 249 | FX_BOOL CFWL_ComboBox::EditSelectAll() { |
| 250 | if (!m_pIface) |
| 251 | return FALSE; |
| 252 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditSelectAll(); |
| 253 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 254 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 255 | FX_BOOL CFWL_ComboBox::EditDelete() { |
| 256 | if (!m_pIface) |
| 257 | return FALSE; |
| 258 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditDelete(); |
| 259 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 260 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 261 | FX_BOOL CFWL_ComboBox::EditDeSelect() { |
| 262 | if (!m_pIface) |
| 263 | return FALSE; |
| 264 | return static_cast<IFWL_ComboBox*>(m_pIface)->EditDeSelect(); |
| 265 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 266 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 267 | FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF& rect) { |
| 268 | if (!m_pIface) |
| 269 | return FALSE; |
| 270 | return static_cast<IFWL_ComboBox*>(m_pIface)->GetBBox(rect); |
| 271 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 272 | |
tsepez | 736f28a | 2016-03-25 14:19:51 -0700 | [diff] [blame] | 273 | FWL_ERR CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 274 | uint32_t dwStylesExRemoved) { |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 275 | if (!m_pIface) |
| 276 | return FALSE; |
| 277 | return static_cast<IFWL_ComboBox*>(m_pIface) |
| 278 | ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 279 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 280 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 281 | CFWL_ComboBox::CFWL_ComboBox() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 282 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 283 | CFWL_ComboBox::~CFWL_ComboBox() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 284 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 285 | CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() { |
| 286 | m_fItemHeight = 0; |
| 287 | m_fMaxListHeight = 0; |
| 288 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 289 | |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 290 | CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 291 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 292 | int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) { |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 293 | return m_ItemArray.size(); |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 294 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 295 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 296 | FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget, |
| 297 | int32_t nIndex) { |
Tom Sepez | 9c98adb | 2016-02-05 12:45:58 -0800 | [diff] [blame] | 298 | if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) |
| 299 | return nullptr; |
| 300 | |
| 301 | return reinterpret_cast<FWL_HLISTITEM>(m_ItemArray[nIndex].get()); |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 302 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 303 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 304 | int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, |
| 305 | FWL_HLISTITEM hItem) { |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 306 | auto it = std::find_if( |
| 307 | m_ItemArray.begin(), m_ItemArray.end(), |
| 308 | [hItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { |
| 309 | return candidate.get() == reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 310 | }); |
| 311 | return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 312 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 313 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 314 | FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, |
| 315 | FWL_HLISTITEM hItem, |
| 316 | int32_t nIndex) { |
Tom Sepez | 9c98adb | 2016-02-05 12:45:58 -0800 | [diff] [blame] | 317 | if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) |
Tom Sepez | e059b5b | 2016-02-05 11:49:27 -0800 | [diff] [blame] | 318 | return FALSE; |
| 319 | |
| 320 | m_ItemArray[nIndex].reset(reinterpret_cast<CFWL_ComboBoxItem*>(hItem)); |
| 321 | return TRUE; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 322 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 323 | |
tsepez | 736f28a | 2016-03-25 14:19:51 -0700 | [diff] [blame] | 324 | uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 325 | FWL_HLISTITEM hItem) { |
| 326 | if (!hItem) |
| 327 | return 0; |
| 328 | return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles; |
| 329 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 330 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 331 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, |
| 332 | FWL_HLISTITEM hItem, |
| 333 | CFX_WideString& wsText) { |
| 334 | if (!hItem) |
| 335 | return FWL_ERR_Indefinite; |
| 336 | wsText = reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText; |
| 337 | return FWL_ERR_Succeeded; |
| 338 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 339 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 340 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget, |
| 341 | FWL_HLISTITEM hItem, |
| 342 | CFX_RectF& rtItem) { |
| 343 | if (!hItem) |
| 344 | return FWL_ERR_Indefinite; |
| 345 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 346 | rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, |
| 347 | pItem->m_rtItem.height); |
| 348 | return FWL_ERR_Succeeded; |
| 349 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 350 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 351 | void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget, |
| 352 | FWL_HLISTITEM hItem) { |
| 353 | if (!hItem) |
| 354 | return NULL; |
| 355 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 356 | return pItem->m_pData; |
| 357 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 358 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 359 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| 360 | FWL_HLISTITEM hItem, |
tsepez | 736f28a | 2016-03-25 14:19:51 -0700 | [diff] [blame] | 361 | uint32_t dwStyle) { |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 362 | if (!hItem) |
| 363 | return FWL_ERR_Indefinite; |
| 364 | reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle; |
| 365 | return FWL_ERR_Succeeded; |
| 366 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 367 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 368 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, |
| 369 | FWL_HLISTITEM hItem, |
| 370 | const FX_WCHAR* pszText) { |
| 371 | if (!hItem) |
| 372 | return FWL_ERR_Indefinite; |
| 373 | reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText; |
| 374 | return FWL_ERR_Succeeded; |
| 375 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 376 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 377 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| 378 | FWL_HLISTITEM hItem, |
| 379 | const CFX_RectF& rtItem) { |
| 380 | if (!hItem) |
| 381 | return FWL_ERR_Indefinite; |
| 382 | reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem; |
| 383 | return FWL_ERR_Succeeded; |
| 384 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 385 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 386 | FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| 387 | return m_fItemHeight; |
| 388 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 389 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 390 | CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget, |
| 391 | FWL_HLISTITEM hItem) { |
| 392 | if (!hItem) |
| 393 | return NULL; |
| 394 | return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB; |
| 395 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 396 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 397 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, |
| 398 | FWL_HLISTITEM hItem, |
| 399 | CFX_RectF& rtCheck) { |
| 400 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 401 | rtCheck = pItem->m_rtCheckBox; |
| 402 | return FWL_ERR_Succeeded; |
| 403 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 404 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 405 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( |
| 406 | IFWL_Widget* pWidget, |
| 407 | FWL_HLISTITEM hItem, |
| 408 | const CFX_RectF& rtCheck) { |
| 409 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 410 | pItem->m_rtCheckBox = rtCheck; |
| 411 | return FWL_ERR_Succeeded; |
| 412 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 413 | |
tsepez | 736f28a | 2016-03-25 14:19:51 -0700 | [diff] [blame] | 414 | uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 415 | IFWL_Widget* pWidget, |
| 416 | FWL_HLISTITEM hItem) { |
| 417 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 418 | return pItem->m_dwCheckState; |
| 419 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 420 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 421 | FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( |
| 422 | IFWL_Widget* pWidget, |
| 423 | FWL_HLISTITEM hItem, |
tsepez | 736f28a | 2016-03-25 14:19:51 -0700 | [diff] [blame] | 424 | uint32_t dwCheckState) { |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 425 | CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); |
| 426 | pItem->m_dwCheckState = dwCheckState; |
| 427 | return FWL_ERR_Succeeded; |
| 428 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 429 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 430 | FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { |
| 431 | return m_fMaxListHeight; |
| 432 | } |