| 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 "fpdfsdk/pdfwindow/PWL_ComboBox.h" | 7 #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" |
| 8 | 8 |
| 9 #include "core/fxge/include/cfx_pathdata.h" | 9 #include "core/fxge/include/cfx_pathdata.h" |
| 10 #include "core/fxge/include/cfx_renderdevice.h" | 10 #include "core/fxge/include/cfx_renderdevice.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 CPWL_Wnd::KillFocus(); | 214 CPWL_Wnd::KillFocus(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 CFX_WideString CPWL_ComboBox::GetText() const { | 217 CFX_WideString CPWL_ComboBox::GetText() const { |
| 218 if (m_pEdit) { | 218 if (m_pEdit) { |
| 219 return m_pEdit->GetText(); | 219 return m_pEdit->GetText(); |
| 220 } | 220 } |
| 221 return CFX_WideString(); | 221 return CFX_WideString(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void CPWL_ComboBox::SetText(const FX_WCHAR* text) { | 224 void CPWL_ComboBox::SetText(const CFX_WideString& text) { |
| 225 if (m_pEdit) | 225 if (m_pEdit) |
| 226 m_pEdit->SetText(text); | 226 m_pEdit->SetText(text); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CPWL_ComboBox::AddString(const FX_WCHAR* str) { | 229 void CPWL_ComboBox::AddString(const CFX_WideString& str) { |
| 230 if (m_pList) | 230 if (m_pList) |
| 231 m_pList->AddString(str); | 231 m_pList->AddString(str); |
| 232 } | 232 } |
| 233 | 233 |
| 234 int32_t CPWL_ComboBox::GetSelect() const { | 234 int32_t CPWL_ComboBox::GetSelect() const { |
| 235 return m_nSelectItem; | 235 return m_nSelectItem; |
| 236 } | 236 } |
| 237 | 237 |
| 238 void CPWL_ComboBox::SetSelect(int32_t nItemIndex) { | 238 void CPWL_ComboBox::SetSelect(int32_t nItemIndex) { |
| 239 if (m_pList) | 239 if (m_pList) |
| 240 m_pList->Select(nItemIndex); | 240 m_pList->Select(nItemIndex); |
| 241 | 241 |
| 242 m_pEdit->SetText(m_pList->GetText().c_str()); | 242 m_pEdit->SetText(m_pList->GetText()); |
| 243 | |
| 244 m_nSelectItem = nItemIndex; | 243 m_nSelectItem = nItemIndex; |
| 245 } | 244 } |
| 246 | 245 |
| 247 void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) { | 246 void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) { |
| 248 if (m_pEdit) { | 247 if (m_pEdit) |
| 249 m_pEdit->SetSel(nStartChar, nEndChar); | 248 m_pEdit->SetSel(nStartChar, nEndChar); |
| 250 } | |
| 251 } | 249 } |
| 252 | 250 |
| 253 void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const { | 251 void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const { |
| 254 nStartChar = -1; | 252 nStartChar = -1; |
| 255 nEndChar = -1; | 253 nEndChar = -1; |
| 256 | 254 |
| 257 if (m_pEdit) { | 255 if (m_pEdit) |
| 258 m_pEdit->GetSel(nStartChar, nEndChar); | 256 m_pEdit->GetSel(nStartChar, nEndChar); |
| 259 } | |
| 260 } | 257 } |
| 261 | 258 |
| 262 void CPWL_ComboBox::Clear() { | 259 void CPWL_ComboBox::Clear() { |
| 263 if (m_pEdit) { | 260 if (m_pEdit) |
| 264 m_pEdit->Clear(); | 261 m_pEdit->Clear(); |
| 265 } | |
| 266 } | 262 } |
| 267 | 263 |
| 268 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) { | 264 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 269 CreateEdit(cp); | 265 CreateEdit(cp); |
| 270 CreateButton(cp); | 266 CreateButton(cp); |
| 271 CreateListBox(cp); | 267 CreateListBox(cp); |
| 272 } | 268 } |
| 273 | 269 |
| 274 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) { | 270 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) { |
| 275 if (!m_pEdit) { | 271 if (!m_pEdit) { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 } | 608 } |
| 613 | 609 |
| 614 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 610 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
| 615 } | 611 } |
| 616 | 612 |
| 617 FX_BOOL CPWL_ComboBox::IsPopup() const { | 613 FX_BOOL CPWL_ComboBox::IsPopup() const { |
| 618 return m_bPopup; | 614 return m_bPopup; |
| 619 } | 615 } |
| 620 | 616 |
| 621 void CPWL_ComboBox::SetSelectText() { | 617 void CPWL_ComboBox::SetSelectText() { |
| 622 CFX_WideString swText = m_pList->GetText(); | |
| 623 m_pEdit->SelectAll(); | 618 m_pEdit->SelectAll(); |
| 624 m_pEdit->ReplaceSel(m_pList->GetText().c_str()); | 619 m_pEdit->ReplaceSel(m_pList->GetText()); |
| 625 m_pEdit->SelectAll(); | 620 m_pEdit->SelectAll(); |
| 626 | |
| 627 m_nSelectItem = m_pList->GetCurSel(); | 621 m_nSelectItem = m_pList->GetCurSel(); |
| 628 } | 622 } |
| 629 | 623 |
| 630 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { | 624 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
| 631 m_pFillerNotify = pNotify; | 625 m_pFillerNotify = pNotify; |
| 632 | 626 |
| 633 if (m_pEdit) | 627 if (m_pEdit) |
| 634 m_pEdit->SetFillerNotify(pNotify); | 628 m_pEdit->SetFillerNotify(pNotify); |
| 635 | 629 |
| 636 if (m_pList) | 630 if (m_pList) |
| 637 m_pList->SetFillerNotify(pNotify); | 631 m_pList->SetFillerNotify(pNotify); |
| 638 } | 632 } |
| OLD | NEW |