Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 } | 39 } |
| 40 | 40 |
| 41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { | 41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { |
| 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); |
| 43 pItem->m_wsText = wsText; | 43 pItem->m_wsText = wsText; |
| 44 pItem->m_dwStyles = 0; | 44 pItem->m_dwStyles = 0; |
| 45 m_ItemArray.push_back(std::move(pItem)); | 45 m_ItemArray.push_back(std::move(pItem)); |
| 46 return m_ItemArray.size() - 1; | 46 return m_ItemArray.size() - 1; |
| 47 } | 47 } |
| 48 | 48 |
| 49 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText, | |
| 50 CFX_DIBitmap* pIcon) { | |
| 51 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | |
| 52 pItem->m_wsText = wsText; | |
| 53 pItem->m_dwStyles = 0; | |
| 54 pItem->m_pDIB = pIcon; | |
| 55 m_ItemArray.push_back(std::move(pItem)); | |
| 56 return m_ItemArray.size() - 1; | |
| 57 } | |
| 58 | |
| 59 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { | 49 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { |
| 60 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) { | 50 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) { |
| 61 return false; | 51 return false; |
| 62 } | 52 } |
| 63 m_ItemArray.erase(m_ItemArray.begin() + iIndex); | 53 m_ItemArray.erase(m_ItemArray.begin() + iIndex); |
| 64 return true; | 54 return true; |
| 65 } | 55 } |
| 66 | 56 |
| 67 void CFWL_ComboBox::RemoveAll() { | 57 void CFWL_ComboBox::RemoveAll() { |
| 68 m_ItemArray.clear(); | 58 m_ItemArray.clear(); |
| 69 } | 59 } |
| 70 | 60 |
| 71 int32_t CFWL_ComboBox::CountItems() { | 61 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) { |
|
npm
2016/11/10 19:42:38
Can we make these Get methods actually return what
| |
| 72 return CountItems(GetWidget()); | |
| 73 } | |
| 74 | |
| 75 FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | |
| 76 CFX_WideString& wsText) { | |
| 77 CFWL_ListItem* pItem = | 62 CFWL_ListItem* pItem = |
| 78 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); | 63 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); |
| 79 if (!pItem) | 64 if (pItem) |
| 80 return FWL_Error::Indefinite; | 65 wsText = pItem->m_wsText; |
| 81 wsText = pItem->m_wsText; | |
| 82 return FWL_Error::Succeeded; | |
| 83 } | 66 } |
| 84 | 67 |
| 85 int32_t CFWL_ComboBox::GetCurSel() { | 68 int32_t CFWL_ComboBox::GetCurSel() { |
| 86 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; | 69 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; |
| 87 } | 70 } |
| 88 | 71 |
| 89 FWL_Error CFWL_ComboBox::SetCurSel(int32_t iSel) { | 72 void CFWL_ComboBox::SetCurSel(int32_t iSel) { |
| 90 return GetWidget() ? ToComboBox(GetWidget())->SetCurSel(iSel) | 73 if (GetWidget()) |
| 91 : FWL_Error::Indefinite; | 74 ToComboBox(GetWidget())->SetCurSel(iSel); |
| 92 } | 75 } |
| 93 | 76 |
| 94 void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { | 77 void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { |
| 95 if (GetWidget()) | 78 if (GetWidget()) |
| 96 ToComboBox(GetWidget())->SetEditText(wsText); | 79 ToComboBox(GetWidget())->SetEditText(wsText); |
| 97 } | 80 } |
| 98 | 81 |
| 99 int32_t CFWL_ComboBox::GetEditTextLength() const { | 82 void CFWL_ComboBox::GetEditText(CFX_WideString& wsText, |
| 100 return GetWidget() ? ToComboBox(GetWidget())->GetEditTextLength() : 0; | 83 int32_t nStart, |
| 84 int32_t nCount) const { | |
| 85 if (GetWidget()) | |
| 86 ToComboBox(GetWidget())->GetEditText(wsText, nStart, nCount); | |
| 101 } | 87 } |
| 102 | 88 |
| 103 FWL_Error CFWL_ComboBox::GetEditText(CFX_WideString& wsText, | 89 void CFWL_ComboBox::OpenDropDownList(bool bActivate) { |
| 104 int32_t nStart, | 90 ToComboBox(GetWidget())->OpenDropDownList(bActivate); |
| 105 int32_t nCount) const { | |
| 106 return GetWidget() | |
| 107 ? ToComboBox(GetWidget())->GetEditText(wsText, nStart, nCount) | |
| 108 : FWL_Error::Indefinite; | |
| 109 } | |
| 110 | |
| 111 FWL_Error CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { | |
| 112 return GetWidget() ? ToComboBox(GetWidget())->SetEditSelRange(nStart, nCount) | |
| 113 : FWL_Error::Indefinite; | |
| 114 } | |
| 115 | |
| 116 int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { | |
| 117 return GetWidget() ? ToComboBox(GetWidget())->GetEditSelRange(nIndex, nStart) | |
| 118 : 0; | |
| 119 } | |
| 120 | |
| 121 int32_t CFWL_ComboBox::GetEditLimit() { | |
| 122 return GetWidget() ? ToComboBox(GetWidget())->GetEditLimit() : 0; | |
| 123 } | |
| 124 | |
| 125 FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) { | |
| 126 return GetWidget() ? ToComboBox(GetWidget())->SetEditLimit(nLimit) | |
| 127 : FWL_Error::Indefinite; | |
| 128 } | |
| 129 | |
| 130 bool CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { | |
| 131 return GetWidget() ? ToComboBox(GetWidget())->EditRedo(pRecord) : false; | |
| 132 } | |
| 133 | |
| 134 bool CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { | |
| 135 return GetWidget() ? ToComboBox(GetWidget())->EditUndo(pRecord) : false; | |
| 136 } | |
| 137 | |
| 138 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { | |
| 139 m_fMaxListHeight = fMaxHeight; | |
| 140 return FWL_Error::Succeeded; | |
| 141 } | |
| 142 | |
| 143 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { | |
| 144 CFWL_ListItem* pItem = | |
| 145 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); | |
| 146 if (!pItem) | |
| 147 return FWL_Error::Indefinite; | |
| 148 pItem->m_pData = pData; | |
| 149 return FWL_Error::Succeeded; | |
| 150 } | |
| 151 | |
| 152 void* CFWL_ComboBox::GetItemData(int32_t iIndex) { | |
| 153 CFWL_ListItem* pItem = | |
| 154 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); | |
| 155 return pItem ? pItem->m_pData : nullptr; | |
| 156 } | |
| 157 | |
| 158 void CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { | |
| 159 ToComboBox(GetWidget())->GetListBoxt()->SetThemeProvider(pTheme); | |
| 160 } | |
| 161 | |
| 162 bool CFWL_ComboBox::AfterFocusShowDropList() { | |
| 163 return ToComboBox(GetWidget())->AfterFocusShowDropList(); | |
| 164 } | |
| 165 | |
| 166 FWL_Error CFWL_ComboBox::OpenDropDownList(bool bActivate) { | |
| 167 return ToComboBox(GetWidget())->OpenDropDownList(bActivate); | |
| 168 } | 91 } |
| 169 | 92 |
| 170 bool CFWL_ComboBox::EditCanUndo() { | 93 bool CFWL_ComboBox::EditCanUndo() { |
| 171 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : false; | 94 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : false; |
| 172 } | 95 } |
| 173 | 96 |
| 174 bool CFWL_ComboBox::EditCanRedo() { | 97 bool CFWL_ComboBox::EditCanRedo() { |
| 175 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : false; | 98 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : false; |
| 176 } | 99 } |
| 177 | 100 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 } | 135 } |
| 213 | 136 |
| 214 bool CFWL_ComboBox::EditDelete() { | 137 bool CFWL_ComboBox::EditDelete() { |
| 215 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false; | 138 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false; |
| 216 } | 139 } |
| 217 | 140 |
| 218 bool CFWL_ComboBox::EditDeSelect() { | 141 bool CFWL_ComboBox::EditDeSelect() { |
| 219 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false; | 142 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false; |
| 220 } | 143 } |
| 221 | 144 |
| 222 FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) { | 145 void CFWL_ComboBox::GetBBox(CFX_RectF& rect) { |
| 223 return GetWidget() ? ToComboBox(GetWidget())->GetBBox(rect) | 146 if (GetWidget()) |
| 224 : FWL_Error::Indefinite; | 147 ToComboBox(GetWidget())->GetBBox(rect); |
| 225 } | 148 } |
| 226 | 149 |
| 227 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 150 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 228 uint32_t dwStylesExRemoved) { | 151 uint32_t dwStylesExRemoved) { |
| 229 if (GetWidget()) { | 152 if (GetWidget()) { |
| 230 ToComboBox(GetWidget()) | 153 ToComboBox(GetWidget()) |
| 231 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 154 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 232 } | 155 } |
| 233 } | 156 } |
| 234 | 157 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 267 |
| 345 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, | 268 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, |
| 346 CFWL_ListItem* pItem, | 269 CFWL_ListItem* pItem, |
| 347 uint32_t dwCheckState) { | 270 uint32_t dwCheckState) { |
| 348 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 271 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; |
| 349 } | 272 } |
| 350 | 273 |
| 351 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { | 274 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { |
| 352 return m_fMaxListHeight; | 275 return m_fMaxListHeight; |
| 353 } | 276 } |
| OLD | NEW |