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