| 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/fwl/core/cfwl_combobox.h" | 7 #include "xfa/fwl/core/cfwl_combobox.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) { | 125 FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) { |
| 126 return GetWidget() ? ToComboBox(GetWidget())->SetEditLimit(nLimit) | 126 return GetWidget() ? ToComboBox(GetWidget())->SetEditLimit(nLimit) |
| 127 : FWL_Error::Indefinite; | 127 : FWL_Error::Indefinite; |
| 128 } | 128 } |
| 129 | 129 |
| 130 FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { | 130 FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { |
| 131 return GetWidget() ? ToComboBox(GetWidget())->EditDoClipboard(iCmd) | 131 return GetWidget() ? ToComboBox(GetWidget())->EditDoClipboard(iCmd) |
| 132 : FWL_Error::Indefinite; | 132 : FWL_Error::Indefinite; |
| 133 } | 133 } |
| 134 | 134 |
| 135 FX_BOOL CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { | 135 bool CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 136 return GetWidget() ? ToComboBox(GetWidget())->EditRedo(pRecord) : FALSE; | 136 return GetWidget() ? ToComboBox(GetWidget())->EditRedo(pRecord) : false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 FX_BOOL CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { | 139 bool CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 140 return GetWidget() ? ToComboBox(GetWidget())->EditUndo(pRecord) : FALSE; | 140 return GetWidget() ? ToComboBox(GetWidget())->EditUndo(pRecord) : false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { | 143 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { |
| 144 m_comboBoxData.m_fMaxListHeight = fMaxHeight; | 144 m_comboBoxData.m_fMaxListHeight = fMaxHeight; |
| 145 return FWL_Error::Succeeded; | 145 return FWL_Error::Succeeded; |
| 146 } | 146 } |
| 147 | 147 |
| 148 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { | 148 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { |
| 149 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>( | 149 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>( |
| 150 m_comboBoxData.GetItem(m_pIface.get(), iIndex)); | 150 m_comboBoxData.GetItem(m_pIface.get(), iIndex)); |
| 151 if (!pItem) | 151 if (!pItem) |
| 152 return FWL_Error::Indefinite; | 152 return FWL_Error::Indefinite; |
| 153 pItem->m_pData = pData; | 153 pItem->m_pData = pData; |
| 154 return FWL_Error::Succeeded; | 154 return FWL_Error::Succeeded; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void* CFWL_ComboBox::GetItemData(int32_t iIndex) { | 157 void* CFWL_ComboBox::GetItemData(int32_t iIndex) { |
| 158 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>( | 158 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>( |
| 159 m_comboBoxData.GetItem(m_pIface.get(), iIndex)); | 159 m_comboBoxData.GetItem(m_pIface.get(), iIndex)); |
| 160 return pItem ? pItem->m_pData : nullptr; | 160 return pItem ? pItem->m_pData : nullptr; |
| 161 } | 161 } |
| 162 | 162 |
| 163 FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { | 163 FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { |
| 164 return ToComboBox(GetWidget())->GetListBoxt()->SetThemeProvider(pTheme); | 164 return ToComboBox(GetWidget())->GetListBoxt()->SetThemeProvider(pTheme); |
| 165 } | 165 } |
| 166 | 166 |
| 167 FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() { | 167 bool CFWL_ComboBox::AfterFocusShowDropList() { |
| 168 return ToComboBox(GetWidget())->AfterFocusShowDropList(); | 168 return ToComboBox(GetWidget())->AfterFocusShowDropList(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 FWL_Error CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { | 171 FWL_Error CFWL_ComboBox::OpenDropDownList(bool bActivate) { |
| 172 return ToComboBox(GetWidget())->OpenDropDownList(bActivate); | 172 return ToComboBox(GetWidget())->OpenDropDownList(bActivate); |
| 173 } | 173 } |
| 174 | 174 |
| 175 FX_BOOL CFWL_ComboBox::EditCanUndo() { | 175 bool CFWL_ComboBox::EditCanUndo() { |
| 176 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : FALSE; | 176 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 FX_BOOL CFWL_ComboBox::EditCanRedo() { | 179 bool CFWL_ComboBox::EditCanRedo() { |
| 180 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : FALSE; | 180 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 FX_BOOL CFWL_ComboBox::EditUndo() { | 183 bool CFWL_ComboBox::EditUndo() { |
| 184 return GetWidget() ? ToComboBox(GetWidget())->EditUndo() : FALSE; | 184 return GetWidget() ? ToComboBox(GetWidget())->EditUndo() : false; |
| 185 } | 185 } |
| 186 | 186 |
| 187 FX_BOOL CFWL_ComboBox::EditRedo() { | 187 bool CFWL_ComboBox::EditRedo() { |
| 188 return GetWidget() ? ToComboBox(GetWidget())->EditRedo() : FALSE; | 188 return GetWidget() ? ToComboBox(GetWidget())->EditRedo() : false; |
| 189 } | 189 } |
| 190 | 190 |
| 191 FX_BOOL CFWL_ComboBox::EditCanCopy() { | 191 bool CFWL_ComboBox::EditCanCopy() { |
| 192 return GetWidget() ? ToComboBox(GetWidget())->EditCanCopy() : FALSE; | 192 return GetWidget() ? ToComboBox(GetWidget())->EditCanCopy() : false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 FX_BOOL CFWL_ComboBox::EditCanCut() { | 195 bool CFWL_ComboBox::EditCanCut() { |
| 196 return GetWidget() ? ToComboBox(GetWidget())->EditCanCut() : FALSE; | 196 return GetWidget() ? ToComboBox(GetWidget())->EditCanCut() : false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 FX_BOOL CFWL_ComboBox::EditCanSelectAll() { | 199 bool CFWL_ComboBox::EditCanSelectAll() { |
| 200 return GetWidget() ? ToComboBox(GetWidget())->EditCanSelectAll() : FALSE; | 200 return GetWidget() ? ToComboBox(GetWidget())->EditCanSelectAll() : false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { | 203 bool CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { |
| 204 return GetWidget() ? ToComboBox(GetWidget())->EditCopy(wsCopy) : FALSE; | 204 return GetWidget() ? ToComboBox(GetWidget())->EditCopy(wsCopy) : false; |
| 205 } | 205 } |
| 206 | 206 |
| 207 FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) { | 207 bool CFWL_ComboBox::EditCut(CFX_WideString& wsCut) { |
| 208 return GetWidget() ? ToComboBox(GetWidget())->EditCut(wsCut) : FALSE; | 208 return GetWidget() ? ToComboBox(GetWidget())->EditCut(wsCut) : false; |
| 209 } | 209 } |
| 210 | 210 |
| 211 FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { | 211 bool CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { |
| 212 return GetWidget() ? ToComboBox(GetWidget())->EditPaste(wsPaste) : FALSE; | 212 return GetWidget() ? ToComboBox(GetWidget())->EditPaste(wsPaste) : false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 FX_BOOL CFWL_ComboBox::EditSelectAll() { | 215 bool CFWL_ComboBox::EditSelectAll() { |
| 216 return GetWidget() ? ToComboBox(GetWidget())->EditSelectAll() : FALSE; | 216 return GetWidget() ? ToComboBox(GetWidget())->EditSelectAll() : false; |
| 217 } | 217 } |
| 218 | 218 |
| 219 FX_BOOL CFWL_ComboBox::EditDelete() { | 219 bool CFWL_ComboBox::EditDelete() { |
| 220 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : FALSE; | 220 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false; |
| 221 } | 221 } |
| 222 | 222 |
| 223 FX_BOOL CFWL_ComboBox::EditDeSelect() { | 223 bool CFWL_ComboBox::EditDeSelect() { |
| 224 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : FALSE; | 224 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false; |
| 225 } | 225 } |
| 226 | 226 |
| 227 FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) { | 227 FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) { |
| 228 return GetWidget() ? ToComboBox(GetWidget())->GetBBox(rect) | 228 return GetWidget() ? ToComboBox(GetWidget())->GetBBox(rect) |
| 229 : FWL_Error::Indefinite; | 229 : FWL_Error::Indefinite; |
| 230 } | 230 } |
| 231 | 231 |
| 232 FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 232 FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 233 uint32_t dwStylesExRemoved) { | 233 uint32_t dwStylesExRemoved) { |
| 234 return GetWidget() | 234 return GetWidget() |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, | 266 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, |
| 267 IFWL_ListItem* pItem) { | 267 IFWL_ListItem* pItem) { |
| 268 auto it = std::find_if( | 268 auto it = std::find_if( |
| 269 m_ItemArray.begin(), m_ItemArray.end(), | 269 m_ItemArray.begin(), m_ItemArray.end(), |
| 270 [pItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { | 270 [pItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { |
| 271 return candidate.get() == static_cast<CFWL_ComboBoxItem*>(pItem); | 271 return candidate.get() == static_cast<CFWL_ComboBoxItem*>(pItem); |
| 272 }); | 272 }); |
| 273 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; | 273 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; |
| 274 } | 274 } |
| 275 | 275 |
| 276 FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, | 276 bool CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, |
| 277 IFWL_ListItem* pItem, | 277 IFWL_ListItem* pItem, |
| 278 int32_t nIndex) { | 278 int32_t nIndex) { |
| 279 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) | 279 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) |
| 280 return FALSE; | 280 return false; |
| 281 | 281 |
| 282 m_ItemArray[nIndex].reset(static_cast<CFWL_ComboBoxItem*>(pItem)); | 282 m_ItemArray[nIndex].reset(static_cast<CFWL_ComboBoxItem*>(pItem)); |
| 283 return TRUE; | 283 return true; |
| 284 } | 284 } |
| 285 | 285 |
| 286 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, | 286 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, |
| 287 IFWL_ListItem* pItem) { | 287 IFWL_ListItem* pItem) { |
| 288 if (!pItem) | 288 if (!pItem) |
| 289 return 0; | 289 return 0; |
| 290 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles; | 290 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles; |
| 291 } | 291 } |
| 292 | 292 |
| 293 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, | 293 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 return FWL_Error::Succeeded; | 381 return FWL_Error::Succeeded; |
| 382 } | 382 } |
| 383 | 383 |
| 384 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { | 384 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { |
| 385 return m_fMaxListHeight; | 385 return m_fMaxListHeight; |
| 386 } | 386 } |
| 387 | 387 |
| 388 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} | 388 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} |
| 389 | 389 |
| 390 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} | 390 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} |
| OLD | NEW |