| 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/basewidget/fwl_editimp.h" | 7 #include "xfa/fwl/basewidget/fwl_editimp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 IFWL_Edit* IFWL_Edit::CreateComboEdit( | 67 IFWL_Edit* IFWL_Edit::CreateComboEdit( |
| 68 const CFWL_WidgetImpProperties& properties, | 68 const CFWL_WidgetImpProperties& properties, |
| 69 IFWL_Widget* pOuter) { | 69 IFWL_Widget* pOuter) { |
| 70 IFWL_Edit* pEdit = new IFWL_Edit; | 70 IFWL_Edit* pEdit = new IFWL_Edit; |
| 71 CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); | 71 CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); |
| 72 pEdit->SetImpl(pComboEditImpl); | 72 pEdit->SetImpl(pComboEditImpl); |
| 73 pComboEditImpl->SetInterface(pEdit); | 73 pComboEditImpl->SetInterface(pEdit); |
| 74 return pEdit; | 74 return pEdit; |
| 75 } | 75 } |
| 76 IFWL_Edit::IFWL_Edit() {} | 76 IFWL_Edit::IFWL_Edit() {} |
| 77 FWL_ERR IFWL_Edit::SetText(const CFX_WideString& wsText) { | 77 FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { |
| 78 return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText); | 78 return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText); |
| 79 } | 79 } |
| 80 int32_t IFWL_Edit::GetTextLength() const { | 80 int32_t IFWL_Edit::GetTextLength() const { |
| 81 return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength(); | 81 return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength(); |
| 82 } | 82 } |
| 83 FWL_ERR IFWL_Edit::GetText(CFX_WideString& wsText, | 83 FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, |
| 84 int32_t nStart, | 84 int32_t nStart, |
| 85 int32_t nCount) const { | 85 int32_t nCount) const { |
| 86 return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); | 86 return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); |
| 87 } | 87 } |
| 88 FWL_ERR IFWL_Edit::ClearText() { | 88 FWL_Error IFWL_Edit::ClearText() { |
| 89 return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); | 89 return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); |
| 90 } | 90 } |
| 91 int32_t IFWL_Edit::GetCaretPos() const { | 91 int32_t IFWL_Edit::GetCaretPos() const { |
| 92 return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); | 92 return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); |
| 93 } | 93 } |
| 94 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 94 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
| 95 return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore); | 95 return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore); |
| 96 } | 96 } |
| 97 FWL_ERR IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { | 97 FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
| 98 return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); | 98 return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); |
| 99 } | 99 } |
| 100 int32_t IFWL_Edit::CountSelRanges() { | 100 int32_t IFWL_Edit::CountSelRanges() { |
| 101 return static_cast<CFWL_EditImp*>(GetImpl())->CountSelRanges(); | 101 return static_cast<CFWL_EditImp*>(GetImpl())->CountSelRanges(); |
| 102 } | 102 } |
| 103 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { | 103 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 104 return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart); | 104 return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart); |
| 105 } | 105 } |
| 106 FWL_ERR IFWL_Edit::ClearSelections() { | 106 FWL_Error IFWL_Edit::ClearSelections() { |
| 107 return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections(); | 107 return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections(); |
| 108 } | 108 } |
| 109 int32_t IFWL_Edit::GetLimit() { | 109 int32_t IFWL_Edit::GetLimit() { |
| 110 return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit(); | 110 return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit(); |
| 111 } | 111 } |
| 112 FWL_ERR IFWL_Edit::SetLimit(int32_t nLimit) { | 112 FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { |
| 113 return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); | 113 return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); |
| 114 } | 114 } |
| 115 FWL_ERR IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { | 115 FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
| 116 return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias); | 116 return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias); |
| 117 } | 117 } |
| 118 FWL_ERR IFWL_Edit::Insert(int32_t nStart, | 118 FWL_Error IFWL_Edit::Insert(int32_t nStart, |
| 119 const FX_WCHAR* lpText, | 119 const FX_WCHAR* lpText, |
| 120 int32_t nLen) { | 120 int32_t nLen) { |
| 121 return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); | 121 return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); |
| 122 } | 122 } |
| 123 FWL_ERR IFWL_Edit::DeleteSelections() { | 123 FWL_Error IFWL_Edit::DeleteSelections() { |
| 124 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); | 124 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); |
| 125 } | 125 } |
| 126 FWL_ERR IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { | 126 FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { |
| 127 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount); | 127 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount); |
| 128 } | 128 } |
| 129 FWL_ERR IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { | 129 FWL_Error IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { |
| 130 return static_cast<CFWL_EditImp*>(GetImpl())->ReplaceSelections(wsReplace); | 130 return static_cast<CFWL_EditImp*>(GetImpl())->ReplaceSelections(wsReplace); |
| 131 } | 131 } |
| 132 FWL_ERR IFWL_Edit::Replace(int32_t nStart, | 132 FWL_Error IFWL_Edit::Replace(int32_t nStart, |
| 133 int32_t nLen, | 133 int32_t nLen, |
| 134 const CFX_WideStringC& wsReplace) { | 134 const CFX_WideStringC& wsReplace) { |
| 135 return static_cast<CFWL_EditImp*>(GetImpl()) | 135 return static_cast<CFWL_EditImp*>(GetImpl()) |
| 136 ->Replace(nStart, nLen, wsReplace); | 136 ->Replace(nStart, nLen, wsReplace); |
| 137 } | 137 } |
| 138 FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) { | 138 FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { |
| 139 return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); | 139 return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); |
| 140 } | 140 } |
| 141 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { | 141 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { |
| 142 return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); | 142 return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); |
| 143 } | 143 } |
| 144 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { | 144 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { |
| 145 return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); | 145 return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); |
| 146 } | 146 } |
| 147 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { | 147 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { |
| 148 return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); | 148 return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 161 } | 161 } |
| 162 FX_BOOL IFWL_Edit::Redo() { | 162 FX_BOOL IFWL_Edit::Redo() { |
| 163 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); | 163 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); |
| 164 } | 164 } |
| 165 FX_BOOL IFWL_Edit::CanUndo() { | 165 FX_BOOL IFWL_Edit::CanUndo() { |
| 166 return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); | 166 return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); |
| 167 } | 167 } |
| 168 FX_BOOL IFWL_Edit::CanRedo() { | 168 FX_BOOL IFWL_Edit::CanRedo() { |
| 169 return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); | 169 return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); |
| 170 } | 170 } |
| 171 FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 171 FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 172 return static_cast<CFWL_EditImp*>(GetImpl()) | 172 return static_cast<CFWL_EditImp*>(GetImpl()) |
| 173 ->SetTabWidth(fTabWidth, bEquidistant); | 173 ->SetTabWidth(fTabWidth, bEquidistant); |
| 174 } | 174 } |
| 175 FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { | 175 FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { |
| 176 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); | 176 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); |
| 177 } | 177 } |
| 178 FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | 178 FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
| 179 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); | 179 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); |
| 180 } | 180 } |
| 181 FWL_ERR IFWL_Edit::SetBackColor(uint32_t dwColor) { | 181 FWL_Error IFWL_Edit::SetBackColor(uint32_t dwColor) { |
| 182 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); | 182 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); |
| 183 } | 183 } |
| 184 FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 184 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 185 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); | 185 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); |
| 186 } | 186 } |
| 187 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | 187 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 188 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); | 188 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); |
| 189 } | 189 } |
| 190 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, | 190 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, |
| 191 std::vector<CFX_ByteString>& sSuggest) { | 191 std::vector<CFX_ByteString>& sSuggest) { |
| 192 return static_cast<CFWL_EditImp*>(GetImpl()) | 192 return static_cast<CFWL_EditImp*>(GetImpl()) |
| 193 ->GetSuggestWords(pointf, sSuggest); | 193 ->GetSuggestWords(pointf, sSuggest); |
| 194 } | 194 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 222 m_rtEngine.Reset(); | 222 m_rtEngine.Reset(); |
| 223 m_rtStatic.Reset(); | 223 m_rtStatic.Reset(); |
| 224 } | 224 } |
| 225 CFWL_EditImp::~CFWL_EditImp() { | 225 CFWL_EditImp::~CFWL_EditImp() { |
| 226 if (m_pEdtEngine) { | 226 if (m_pEdtEngine) { |
| 227 m_pEdtEngine->Release(); | 227 m_pEdtEngine->Release(); |
| 228 m_pEdtEngine = NULL; | 228 m_pEdtEngine = NULL; |
| 229 } | 229 } |
| 230 ClearRecord(); | 230 ClearRecord(); |
| 231 } | 231 } |
| 232 FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { | 232 FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { |
| 233 wsClass = FWL_CLASS_Edit; | 233 wsClass = FWL_CLASS_Edit; |
| 234 return FWL_ERR_Succeeded; | 234 return FWL_Error::Succeeded; |
| 235 } | 235 } |
| 236 uint32_t CFWL_EditImp::GetClassID() const { | 236 uint32_t CFWL_EditImp::GetClassID() const { |
| 237 return FWL_CLASSHASH_Edit; | 237 return FWL_CLASSHASH_Edit; |
| 238 } | 238 } |
| 239 FWL_ERR CFWL_EditImp::Initialize() { | 239 FWL_Error CFWL_EditImp::Initialize() { |
| 240 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 240 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 241 return FWL_ERR_Indefinite; | 241 return FWL_Error::Indefinite; |
| 242 if (!m_pDelegate) { | 242 if (!m_pDelegate) { |
| 243 m_pDelegate = new CFWL_EditImpDelegate(this); | 243 m_pDelegate = new CFWL_EditImpDelegate(this); |
| 244 } | 244 } |
| 245 InitCaret(); | 245 InitCaret(); |
| 246 if (!m_pEdtEngine) { | 246 if (!m_pEdtEngine) { |
| 247 InitEngine(); | 247 InitEngine(); |
| 248 } | 248 } |
| 249 return FWL_ERR_Succeeded; | 249 return FWL_Error::Succeeded; |
| 250 } | 250 } |
| 251 FWL_ERR CFWL_EditImp::Finalize() { | 251 FWL_Error CFWL_EditImp::Finalize() { |
| 252 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 252 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
| 253 ShowCaret(FALSE); | 253 ShowCaret(FALSE); |
| 254 } | 254 } |
| 255 if (m_pHorzScrollBar) { | 255 if (m_pHorzScrollBar) { |
| 256 m_pHorzScrollBar->Finalize(); | 256 m_pHorzScrollBar->Finalize(); |
| 257 } | 257 } |
| 258 if (m_pVertScrollBar) { | 258 if (m_pVertScrollBar) { |
| 259 m_pVertScrollBar->Finalize(); | 259 m_pVertScrollBar->Finalize(); |
| 260 } | 260 } |
| 261 delete m_pDelegate; | 261 delete m_pDelegate; |
| 262 m_pDelegate = nullptr; | 262 m_pDelegate = nullptr; |
| 263 return CFWL_WidgetImp::Finalize(); | 263 return CFWL_WidgetImp::Finalize(); |
| 264 } | 264 } |
| 265 FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 265 FWL_Error CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 266 if (bAutoSize) { | 266 if (bAutoSize) { |
| 267 rect.Set(0, 0, 0, 0); | 267 rect.Set(0, 0, 0, 0); |
| 268 if (m_pEdtEngine) { | 268 if (m_pEdtEngine) { |
| 269 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 269 int32_t iTextLen = m_pEdtEngine->GetTextLength(); |
| 270 if (iTextLen > 0) { | 270 if (iTextLen > 0) { |
| 271 CFX_WideString wsText; | 271 CFX_WideString wsText; |
| 272 m_pEdtEngine->GetText(wsText, 0); | 272 m_pEdtEngine->GetText(wsText, 0); |
| 273 CFX_SizeF sz = CalcTextSize( | 273 CFX_SizeF sz = CalcTextSize( |
| 274 wsText, m_pProperties->m_pThemeProvider, | 274 wsText, m_pProperties->m_pThemeProvider, |
| 275 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); | 275 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 287 rect.width += kEditMargin; | 287 rect.width += kEditMargin; |
| 288 } | 288 } |
| 289 if (IsShowScrollBar(FALSE)) { | 289 if (IsShowScrollBar(FALSE)) { |
| 290 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 290 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 291 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 291 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 292 rect.height += *pfWidth; | 292 rect.height += *pfWidth; |
| 293 rect.height += kEditMargin; | 293 rect.height += kEditMargin; |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 return FWL_ERR_Succeeded; | 297 return FWL_Error::Succeeded; |
| 298 } | 298 } |
| 299 FWL_ERR CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 299 FWL_Error CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
| 300 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || | 300 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || |
| 301 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 301 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 302 ShowCaret(FALSE); | 302 ShowCaret(FALSE); |
| 303 } | 303 } |
| 304 return CFWL_WidgetImp::SetStates(dwStates, bSet); | 304 return CFWL_WidgetImp::SetStates(dwStates, bSet); |
| 305 } | 305 } |
| 306 FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { | 306 FWL_Error CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { |
| 307 return CFWL_WidgetImp::SetWidgetRect(rect); | 307 return CFWL_WidgetImp::SetWidgetRect(rect); |
| 308 } | 308 } |
| 309 FWL_ERR CFWL_EditImp::Update() { | 309 FWL_Error CFWL_EditImp::Update() { |
| 310 if (IsLocked()) { | 310 if (IsLocked()) { |
| 311 return FWL_ERR_Indefinite; | 311 return FWL_Error::Indefinite; |
| 312 } | 312 } |
| 313 if (!m_pProperties->m_pThemeProvider) { | 313 if (!m_pProperties->m_pThemeProvider) { |
| 314 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 314 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 315 } | 315 } |
| 316 Layout(); | 316 Layout(); |
| 317 if (m_rtClient.IsEmpty()) { | 317 if (m_rtClient.IsEmpty()) { |
| 318 return FWL_ERR_Indefinite; | 318 return FWL_Error::Indefinite; |
| 319 } | 319 } |
| 320 UpdateEditEngine(); | 320 UpdateEditEngine(); |
| 321 UpdateVAlignment(); | 321 UpdateVAlignment(); |
| 322 UpdateScroll(); | 322 UpdateScroll(); |
| 323 InitCaret(); | 323 InitCaret(); |
| 324 return FWL_ERR_Succeeded; | 324 return FWL_Error::Succeeded; |
| 325 } | 325 } |
| 326 | 326 |
| 327 uint32_t CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 327 uint32_t CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 328 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 328 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| 329 if (IsShowScrollBar(TRUE)) { | 329 if (IsShowScrollBar(TRUE)) { |
| 330 CFX_RectF rect; | 330 CFX_RectF rect; |
| 331 m_pVertScrollBar->GetWidgetRect(rect); | 331 m_pVertScrollBar->GetWidgetRect(rect); |
| 332 if (rect.Contains(fx, fy)) | 332 if (rect.Contains(fx, fy)) |
| 333 return FWL_WGTHITTEST_VScrollBar; | 333 return FWL_WGTHITTEST_VScrollBar; |
| 334 } | 334 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 pMatrix->TransformRect(rtClip); | 483 pMatrix->TransformRect(rtClip); |
| 484 mt.Concat(*pMatrix); | 484 mt.Concat(*pMatrix); |
| 485 } | 485 } |
| 486 pGraphics->SetClipRect(rtClip); | 486 pGraphics->SetClipRect(rtClip); |
| 487 pGraphics->SetStrokeColor(&crLine); | 487 pGraphics->SetStrokeColor(&crLine); |
| 488 pGraphics->SetLineWidth(0); | 488 pGraphics->SetLineWidth(0); |
| 489 pGraphics->StrokePath(&pathSpell, NULL); | 489 pGraphics->StrokePath(&pathSpell, NULL); |
| 490 } | 490 } |
| 491 pGraphics->RestoreGraphState(); | 491 pGraphics->RestoreGraphState(); |
| 492 } | 492 } |
| 493 FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, | 493 FWL_Error CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, |
| 494 const CFX_Matrix* pMatrix) { | 494 const CFX_Matrix* pMatrix) { |
| 495 if (!pGraphics) | 495 if (!pGraphics) |
| 496 return FWL_ERR_Indefinite; | 496 return FWL_Error::Indefinite; |
| 497 if (!m_pProperties->m_pThemeProvider) | 497 if (!m_pProperties->m_pThemeProvider) |
| 498 return FWL_ERR_Indefinite; | 498 return FWL_Error::Indefinite; |
| 499 if (m_rtClient.IsEmpty()) { | 499 if (m_rtClient.IsEmpty()) { |
| 500 return FWL_ERR_Indefinite; | 500 return FWL_Error::Indefinite; |
| 501 } | 501 } |
| 502 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 502 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 503 if (!m_pWidgetMgr->IsFormDisabled()) { | 503 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 504 DrawTextBk(pGraphics, pTheme, pMatrix); | 504 DrawTextBk(pGraphics, pTheme, pMatrix); |
| 505 } | 505 } |
| 506 if (m_pEdtEngine) { | 506 if (m_pEdtEngine) { |
| 507 DrawContent(pGraphics, pTheme, pMatrix); | 507 DrawContent(pGraphics, pTheme, pMatrix); |
| 508 } | 508 } |
| 509 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 509 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
| 510 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { | 510 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { |
| 511 DrawSpellCheck(pGraphics, pMatrix); | 511 DrawSpellCheck(pGraphics, pMatrix); |
| 512 } | 512 } |
| 513 if (HasBorder()) { | 513 if (HasBorder()) { |
| 514 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 514 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 515 } | 515 } |
| 516 if (HasEdge()) { | 516 if (HasEdge()) { |
| 517 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 517 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 518 } | 518 } |
| 519 return FWL_ERR_Succeeded; | 519 return FWL_Error::Succeeded; |
| 520 } | 520 } |
| 521 FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 521 FWL_Error CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 522 if (!pThemeProvider) | 522 if (!pThemeProvider) |
| 523 return FWL_ERR_Indefinite; | 523 return FWL_Error::Indefinite; |
| 524 if (m_pHorzScrollBar) { | 524 if (m_pHorzScrollBar) { |
| 525 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); | 525 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); |
| 526 } | 526 } |
| 527 if (m_pVertScrollBar) { | 527 if (m_pVertScrollBar) { |
| 528 m_pVertScrollBar->SetThemeProvider(pThemeProvider); | 528 m_pVertScrollBar->SetThemeProvider(pThemeProvider); |
| 529 } | 529 } |
| 530 if (m_pCaret) { | 530 if (m_pCaret) { |
| 531 m_pCaret->SetThemeProvider(pThemeProvider); | 531 m_pCaret->SetThemeProvider(pThemeProvider); |
| 532 } | 532 } |
| 533 m_pProperties->m_pThemeProvider = pThemeProvider; | 533 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 534 return FWL_ERR_Succeeded; | 534 return FWL_Error::Succeeded; |
| 535 } | 535 } |
| 536 FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) { | 536 |
| 537 FWL_Error CFWL_EditImp::SetText(const CFX_WideString& wsText) { |
| 537 m_pEdtEngine->SetText(wsText); | 538 m_pEdtEngine->SetText(wsText); |
| 538 return FWL_ERR_Succeeded; | 539 return FWL_Error::Succeeded; |
| 539 } | 540 } |
| 541 |
| 540 int32_t CFWL_EditImp::GetTextLength() const { | 542 int32_t CFWL_EditImp::GetTextLength() const { |
| 541 if (!m_pEdtEngine) | 543 if (!m_pEdtEngine) |
| 542 return -1; | 544 return -1; |
| 543 return m_pEdtEngine->GetTextLength(); | 545 return m_pEdtEngine->GetTextLength(); |
| 544 } | 546 } |
| 545 FWL_ERR CFWL_EditImp::GetText(CFX_WideString& wsText, | 547 |
| 546 int32_t nStart, | 548 FWL_Error CFWL_EditImp::GetText(CFX_WideString& wsText, |
| 547 int32_t nCount) const { | 549 int32_t nStart, |
| 550 int32_t nCount) const { |
| 548 if (!m_pEdtEngine) | 551 if (!m_pEdtEngine) |
| 549 return FWL_ERR_Succeeded; | 552 return FWL_Error::Indefinite; |
| 553 |
| 550 m_pEdtEngine->GetText(wsText, nStart, nCount); | 554 m_pEdtEngine->GetText(wsText, nStart, nCount); |
| 551 return FWL_ERR_Succeeded; | 555 return FWL_Error::Succeeded; |
| 552 } | 556 } |
| 553 FWL_ERR CFWL_EditImp::ClearText() { | 557 |
| 558 FWL_Error CFWL_EditImp::ClearText() { |
| 554 if (!m_pEdtEngine) | 559 if (!m_pEdtEngine) |
| 555 return FWL_ERR_Succeeded; | 560 return FWL_Error::Indefinite; |
| 561 |
| 556 m_pEdtEngine->ClearText(); | 562 m_pEdtEngine->ClearText(); |
| 557 return FWL_ERR_Succeeded; | 563 return FWL_Error::Succeeded; |
| 558 } | 564 } |
| 565 |
| 559 int32_t CFWL_EditImp::GetCaretPos() const { | 566 int32_t CFWL_EditImp::GetCaretPos() const { |
| 560 if (!m_pEdtEngine) | 567 if (!m_pEdtEngine) |
| 561 return -1; | 568 return -1; |
| 562 return m_pEdtEngine->GetCaretPos(); | 569 return m_pEdtEngine->GetCaretPos(); |
| 563 } | 570 } |
| 571 |
| 564 int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 572 int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
| 565 if (!m_pEdtEngine) | 573 if (!m_pEdtEngine) |
| 566 return -1; | 574 return -1; |
| 567 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 575 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); |
| 568 } | 576 } |
| 569 FWL_ERR CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) { | 577 |
| 578 FWL_Error CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) { |
| 570 if (!m_pEdtEngine) | 579 if (!m_pEdtEngine) |
| 571 return FWL_ERR_Succeeded; | 580 return FWL_Error::Indefinite; |
| 581 |
| 572 m_pEdtEngine->AddSelRange(nStart, nCount); | 582 m_pEdtEngine->AddSelRange(nStart, nCount); |
| 573 return FWL_ERR_Succeeded; | 583 return FWL_Error::Succeeded; |
| 574 } | 584 } |
| 585 |
| 575 int32_t CFWL_EditImp::CountSelRanges() { | 586 int32_t CFWL_EditImp::CountSelRanges() { |
| 576 if (!m_pEdtEngine) | 587 if (!m_pEdtEngine) |
| 577 return 0; | 588 return 0; |
| 578 return m_pEdtEngine->CountSelRanges(); | 589 return m_pEdtEngine->CountSelRanges(); |
| 579 return FWL_ERR_Succeeded; | |
| 580 } | 590 } |
| 591 |
| 581 int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) { | 592 int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 582 if (!m_pEdtEngine) | 593 if (!m_pEdtEngine) |
| 583 return -1; | 594 return -1; |
| 584 return m_pEdtEngine->GetSelRange(nIndex, nStart); | 595 return m_pEdtEngine->GetSelRange(nIndex, nStart); |
| 585 } | 596 } |
| 586 FWL_ERR CFWL_EditImp::ClearSelections() { | 597 |
| 598 FWL_Error CFWL_EditImp::ClearSelections() { |
| 587 if (!m_pEdtEngine) | 599 if (!m_pEdtEngine) |
| 588 return FWL_ERR_Succeeded; | 600 return FWL_Error::Indefinite; |
| 601 |
| 589 m_pEdtEngine->ClearSelection(); | 602 m_pEdtEngine->ClearSelection(); |
| 590 return FWL_ERR_Succeeded; | 603 return FWL_Error::Succeeded; |
| 591 } | 604 } |
| 605 |
| 592 int32_t CFWL_EditImp::GetLimit() { | 606 int32_t CFWL_EditImp::GetLimit() { |
| 593 return m_nLimit; | 607 return m_nLimit; |
| 594 } | 608 } |
| 595 FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) { | 609 |
| 610 FWL_Error CFWL_EditImp::SetLimit(int32_t nLimit) { |
| 596 m_nLimit = nLimit; | 611 m_nLimit = nLimit; |
| 597 if (!m_pEdtEngine) | 612 if (!m_pEdtEngine) |
| 598 return FWL_ERR_Succeeded; | 613 return FWL_Error::Indefinite; |
| 614 |
| 599 m_pEdtEngine->SetLimit(nLimit); | 615 m_pEdtEngine->SetLimit(nLimit); |
| 600 return FWL_ERR_Succeeded; | 616 return FWL_Error::Succeeded; |
| 601 } | 617 } |
| 602 FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { | 618 |
| 619 FWL_Error CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { |
| 603 if (!m_pEdtEngine) | 620 if (!m_pEdtEngine) |
| 604 return FWL_ERR_Indefinite; | 621 return FWL_Error::Indefinite; |
| 622 |
| 605 m_pEdtEngine->SetAliasChar(wAlias); | 623 m_pEdtEngine->SetAliasChar(wAlias); |
| 606 return FWL_ERR_Succeeded; | 624 return FWL_Error::Succeeded; |
| 607 } | 625 } |
| 608 FWL_ERR CFWL_EditImp::Insert(int32_t nStart, | 626 |
| 609 const FX_WCHAR* lpText, | 627 FWL_Error CFWL_EditImp::Insert(int32_t nStart, |
| 610 int32_t nLen) { | 628 const FX_WCHAR* lpText, |
| 629 int32_t nLen) { |
| 611 if (!m_pEdtEngine) | 630 if (!m_pEdtEngine) |
| 612 return FWL_ERR_Succeeded; | 631 return FWL_Error::Indefinite; |
| 632 |
| 613 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 633 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 614 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 634 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 615 return FWL_ERR_Indefinite; | 635 return FWL_Error::Indefinite; |
| 616 } | 636 } |
| 617 m_pEdtEngine->Insert(nStart, lpText, nLen); | 637 m_pEdtEngine->Insert(nStart, lpText, nLen); |
| 618 return FWL_ERR_Succeeded; | 638 return FWL_Error::Succeeded; |
| 619 } | 639 } |
| 620 FWL_ERR CFWL_EditImp::DeleteSelections() { | 640 |
| 641 FWL_Error CFWL_EditImp::DeleteSelections() { |
| 621 if (!m_pEdtEngine) | 642 if (!m_pEdtEngine) |
| 622 return FWL_ERR_Succeeded; | 643 return FWL_Error::Indefinite; |
| 644 |
| 623 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 645 int32_t iCount = m_pEdtEngine->CountSelRanges(); |
| 624 if (iCount > 0) { | 646 if (iCount > 0) |
| 625 m_pEdtEngine->Delete(-1); | 647 m_pEdtEngine->Delete(-1); |
| 626 } | 648 return FWL_Error::Succeeded; |
| 627 return FWL_ERR_Succeeded; | |
| 628 } | 649 } |
| 629 FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { | 650 |
| 651 FWL_Error CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { |
| 630 if (!m_pEdtEngine) | 652 if (!m_pEdtEngine) |
| 631 return FWL_ERR_Succeeded; | 653 return FWL_Error::Indefinite; |
| 654 |
| 632 m_pEdtEngine->DeleteRange(nStart, nCount); | 655 m_pEdtEngine->DeleteRange(nStart, nCount); |
| 633 return FWL_ERR_Succeeded; | 656 return FWL_Error::Succeeded; |
| 634 } | 657 } |
| 635 FWL_ERR CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) { | 658 |
| 659 FWL_Error CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) { |
| 636 if (!m_pEdtEngine) | 660 if (!m_pEdtEngine) |
| 637 return FWL_ERR_Succeeded; | 661 return FWL_Error::Indefinite; |
| 662 |
| 638 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 663 int32_t iCount = m_pEdtEngine->CountSelRanges(); |
| 639 for (int i = 0; i < iCount; i++) { | 664 for (int i = 0; i < iCount; i++) { |
| 640 int32_t nStart; | 665 int32_t nStart; |
| 641 int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart); | 666 int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart); |
| 642 m_pEdtEngine->Replace(nStart, nCount, wsReplace); | 667 m_pEdtEngine->Replace(nStart, nCount, wsReplace); |
| 643 } | 668 } |
| 644 return FWL_ERR_Succeeded; | 669 return FWL_Error::Succeeded; |
| 645 } | 670 } |
| 646 FWL_ERR CFWL_EditImp::Replace(int32_t nStart, | 671 |
| 647 int32_t nLen, | 672 FWL_Error CFWL_EditImp::Replace(int32_t nStart, |
| 648 const CFX_WideStringC& wsReplace) { | 673 int32_t nLen, |
| 674 const CFX_WideStringC& wsReplace) { |
| 649 if (!m_pEdtEngine) | 675 if (!m_pEdtEngine) |
| 650 return FWL_ERR_Succeeded; | 676 return FWL_Error::Indefinite; |
| 677 |
| 651 m_pEdtEngine->Replace(nStart, nLen, wsReplace); | 678 m_pEdtEngine->Replace(nStart, nLen, wsReplace); |
| 652 return FWL_ERR_Succeeded; | 679 return FWL_Error::Succeeded; |
| 653 } | 680 } |
| 654 FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) { | 681 |
| 682 FWL_Error CFWL_EditImp::DoClipboard(int32_t iCmd) { |
| 655 if (!m_pEdtEngine) | 683 if (!m_pEdtEngine) |
| 656 return FWL_ERR_Succeeded; | 684 return FWL_Error::Indefinite; |
| 685 |
| 657 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 686 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 658 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 687 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 659 return FWL_ERR_Succeeded; | 688 return FWL_Error::Succeeded; |
| 660 } | 689 } |
| 661 return FWL_ERR_Indefinite; | 690 return FWL_Error::Indefinite; |
| 662 } | 691 } |
| 692 |
| 663 FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { | 693 FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { |
| 664 if (!m_pEdtEngine) | 694 if (!m_pEdtEngine) |
| 665 return FALSE; | 695 return FALSE; |
| 696 |
| 666 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 697 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 667 if (nCount == 0) { | 698 if (nCount == 0) |
| 668 return FALSE; | 699 return FALSE; |
| 669 } | 700 |
| 670 wsCopy.clear(); | 701 wsCopy.clear(); |
| 671 CFX_WideString wsTemp; | 702 CFX_WideString wsTemp; |
| 672 int32_t nStart, nLength; | 703 int32_t nStart, nLength; |
| 673 for (int32_t i = 0; i < nCount; i++) { | 704 for (int32_t i = 0; i < nCount; i++) { |
| 674 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 705 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
| 675 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 706 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
| 676 wsCopy += wsTemp; | 707 wsCopy += wsTemp; |
| 677 wsTemp.clear(); | 708 wsTemp.clear(); |
| 678 } | 709 } |
| 679 return TRUE; | 710 return TRUE; |
| 680 } | 711 } |
| 712 |
| 681 FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { | 713 FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { |
| 682 if (!m_pEdtEngine) | 714 if (!m_pEdtEngine) |
| 683 return FALSE; | 715 return FALSE; |
| 716 |
| 684 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 717 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 685 if (nCount == 0) { | 718 if (nCount == 0) |
| 686 return FALSE; | 719 return FALSE; |
| 687 } | 720 |
| 688 wsCut.clear(); | 721 wsCut.clear(); |
| 689 CFX_WideString wsTemp; | 722 CFX_WideString wsTemp; |
| 690 int32_t nStart, nLength; | 723 int32_t nStart, nLength; |
| 691 for (int32_t i = 0; i < nCount; i++) { | 724 for (int32_t i = 0; i < nCount; i++) { |
| 692 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 725 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
| 693 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 726 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
| 694 wsCut += wsTemp; | 727 wsCut += wsTemp; |
| 695 wsTemp.clear(); | 728 wsTemp.clear(); |
| 696 } | 729 } |
| 697 m_pEdtEngine->Delete(0); | 730 m_pEdtEngine->Delete(0); |
| 698 return TRUE; | 731 return TRUE; |
| 699 } | 732 } |
| 733 |
| 700 FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) { | 734 FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) { |
| 701 if (!m_pEdtEngine) | 735 if (!m_pEdtEngine) |
| 702 return FALSE; | 736 return FALSE; |
| 737 |
| 703 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | 738 int32_t nCaret = m_pEdtEngine->GetCaretPos(); |
| 704 int32_t iError = | 739 int32_t iError = |
| 705 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); | 740 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); |
| 706 if (iError < 0) { | 741 if (iError < 0) { |
| 707 ProcessInsertError(iError); | 742 ProcessInsertError(iError); |
| 708 return FALSE; | 743 return FALSE; |
| 709 } | 744 } |
| 710 return TRUE; | 745 return TRUE; |
| 711 } | 746 } |
| 747 |
| 712 FX_BOOL CFWL_EditImp::Delete() { | 748 FX_BOOL CFWL_EditImp::Delete() { |
| 713 if (!m_pEdtEngine) | 749 if (!m_pEdtEngine) |
| 714 return FALSE; | 750 return FALSE; |
| 751 |
| 715 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 752 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 716 if (nCount < 1) { | 753 if (nCount < 1) |
| 717 return FALSE; | 754 return FALSE; |
| 718 } | 755 |
| 719 m_pEdtEngine->Delete(0); | 756 m_pEdtEngine->Delete(0); |
| 720 return TRUE; | 757 return TRUE; |
| 721 } | 758 } |
| 759 |
| 722 FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) { | 760 FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) { |
| 723 if (!m_pEdtEngine) | 761 if (!m_pEdtEngine) |
| 724 return FALSE; | 762 return FALSE; |
| 725 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) { | 763 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 726 return TRUE; | 764 return TRUE; |
| 727 } | |
| 728 return m_pEdtEngine->Redo(bsRecord); | 765 return m_pEdtEngine->Redo(bsRecord); |
| 729 } | 766 } |
| 767 |
| 730 FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) { | 768 FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) { |
| 731 if (!m_pEdtEngine) | 769 if (!m_pEdtEngine) |
| 732 return FALSE; | 770 return FALSE; |
| 733 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) { | 771 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 734 return TRUE; | 772 return TRUE; |
| 735 } | |
| 736 return m_pEdtEngine->Undo(bsRecord); | 773 return m_pEdtEngine->Undo(bsRecord); |
| 737 } | 774 } |
| 775 |
| 738 FX_BOOL CFWL_EditImp::Undo() { | 776 FX_BOOL CFWL_EditImp::Undo() { |
| 739 if (!CanUndo()) { | 777 if (!CanUndo()) |
| 740 return FALSE; | 778 return FALSE; |
| 741 } | 779 |
| 742 CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; | 780 CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; |
| 743 return Undo(bsRecord.AsStringC()); | 781 return Undo(bsRecord.AsStringC()); |
| 744 } | 782 } |
| 783 |
| 745 FX_BOOL CFWL_EditImp::Redo() { | 784 FX_BOOL CFWL_EditImp::Redo() { |
| 746 if (!CanRedo()) { | 785 if (!CanRedo()) |
| 747 return FALSE; | 786 return FALSE; |
| 748 } | 787 |
| 749 CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; | 788 CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; |
| 750 return Redo(bsRecord.AsStringC()); | 789 return Redo(bsRecord.AsStringC()); |
| 751 } | 790 } |
| 791 |
| 752 FX_BOOL CFWL_EditImp::CanUndo() { | 792 FX_BOOL CFWL_EditImp::CanUndo() { |
| 753 return m_iCurRecord >= 0; | 793 return m_iCurRecord >= 0; |
| 754 } | 794 } |
| 795 |
| 755 FX_BOOL CFWL_EditImp::CanRedo() { | 796 FX_BOOL CFWL_EditImp::CanRedo() { |
| 756 return m_iCurRecord < m_RecordArr.GetSize() - 1; | 797 return m_iCurRecord < m_RecordArr.GetSize() - 1; |
| 757 } | 798 } |
| 758 FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 799 |
| 800 FWL_Error CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 759 if (!m_pEdtEngine) | 801 if (!m_pEdtEngine) |
| 760 return FWL_ERR_Succeeded; | 802 return FWL_Error::Indefinite; |
| 803 |
| 761 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); | 804 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); |
| 762 pParams->fTabWidth = fTabWidth; | 805 pParams->fTabWidth = fTabWidth; |
| 763 pParams->bTabEquidistant = bEquidistant; | 806 pParams->bTabEquidistant = bEquidistant; |
| 764 return FWL_ERR_Succeeded; | 807 return FWL_Error::Succeeded; |
| 765 } | 808 } |
| 766 FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { | 809 |
| 810 FWL_Error CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { |
| 767 m_pOuter = pOuter; | 811 m_pOuter = pOuter; |
| 768 return FWL_ERR_Succeeded; | 812 return FWL_Error::Succeeded; |
| 769 } | 813 } |
| 770 FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { | 814 |
| 815 FWL_Error CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { |
| 771 m_iMin = iMin; | 816 m_iMin = iMin; |
| 772 m_iMax = iMax; | 817 m_iMax = iMax; |
| 773 m_bSetRange = TRUE; | 818 m_bSetRange = TRUE; |
| 774 return FWL_ERR_Succeeded; | 819 return FWL_Error::Succeeded; |
| 775 } | 820 } |
| 821 |
| 776 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 822 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
| 777 int32_t nPage, | 823 int32_t nPage, |
| 778 FX_BOOL bVisible) { | 824 FX_BOOL bVisible) { |
| 779 if (m_rtEngine.IsEmpty()) { | 825 if (m_rtEngine.IsEmpty()) |
| 780 return; | 826 return; |
| 781 } | 827 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 782 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { | |
| 783 return; | 828 return; |
| 784 } | 829 |
| 785 FX_BOOL bRepaintContent = UpdateOffset(); | 830 FX_BOOL bRepaintContent = UpdateOffset(); |
| 786 UpdateCaret(); | 831 UpdateCaret(); |
| 787 CFX_RectF rtInvalid; | 832 CFX_RectF rtInvalid; |
| 788 rtInvalid.Set(0, 0, 0, 0); | 833 rtInvalid.Set(0, 0, 0, 0); |
| 789 FX_BOOL bRepaintScroll = FALSE; | 834 FX_BOOL bRepaintScroll = FALSE; |
| 790 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { | 835 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { |
| 791 IFWL_ScrollBar* pScroll = UpdateScroll(); | 836 IFWL_ScrollBar* pScroll = UpdateScroll(); |
| 792 if (pScroll) { | 837 if (pScroll) { |
| 793 pScroll->GetWidgetRect(rtInvalid); | 838 pScroll->GetWidgetRect(rtInvalid); |
| 794 bRepaintScroll = TRUE; | 839 bRepaintScroll = TRUE; |
| 795 } | 840 } |
| 796 } | 841 } |
| 797 if (bRepaintContent || bRepaintScroll) { | 842 if (bRepaintContent || bRepaintScroll) { |
| 798 if (bRepaintContent) { | 843 if (bRepaintContent) { |
| 799 rtInvalid.Union(m_rtEngine); | 844 rtInvalid.Union(m_rtEngine); |
| 800 } | 845 } |
| 801 Repaint(&rtInvalid); | 846 Repaint(&rtInvalid); |
| 802 } | 847 } |
| 803 } | 848 } |
| 849 |
| 804 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 850 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
| 805 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { | 851 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { |
| 806 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; | 852 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; |
| 807 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) { | 853 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) |
| 808 UpdateVAlignment(); | 854 UpdateVAlignment(); |
| 809 } | 855 |
| 810 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); | 856 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); |
| 811 FX_FLOAT fContentWidth = page->GetContentsBox().width; | 857 FX_FLOAT fContentWidth = page->GetContentsBox().width; |
| 812 FX_FLOAT fContentHeight = page->GetContentsBox().height; | 858 FX_FLOAT fContentHeight = page->GetContentsBox().height; |
| 813 CFX_RectF rtTemp; | 859 CFX_RectF rtTemp; |
| 814 GetClientRect(rtTemp); | 860 GetClientRect(rtTemp); |
| 815 FX_BOOL bHSelfAdaption = | 861 FX_BOOL bHSelfAdaption = |
| 816 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; | 862 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; |
| 817 FX_BOOL bVSelfAdaption = | 863 FX_BOOL bVSelfAdaption = |
| 818 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; | 864 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; |
| 819 FX_BOOL bNeedUpdate = FALSE; | 865 FX_BOOL bNeedUpdate = FALSE; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 pDst = m_pInterface; | 950 pDst = m_pInterface; |
| 905 } | 951 } |
| 906 CFWL_EvtEdtValidate event; | 952 CFWL_EvtEdtValidate event; |
| 907 event.pDstWidget = pDst; | 953 event.pDstWidget = pDst; |
| 908 event.m_pSrcTarget = m_pInterface; | 954 event.m_pSrcTarget = m_pInterface; |
| 909 event.wsInsert = wsText; | 955 event.wsInsert = wsText; |
| 910 event.bValidate = TRUE; | 956 event.bValidate = TRUE; |
| 911 DispatchEvent(&event); | 957 DispatchEvent(&event); |
| 912 return event.bValidate; | 958 return event.bValidate; |
| 913 } | 959 } |
| 914 FWL_ERR CFWL_EditImp::SetBackgroundColor(uint32_t color) { | 960 FWL_Error CFWL_EditImp::SetBackgroundColor(uint32_t color) { |
| 915 m_backColor = color; | 961 m_backColor = color; |
| 916 m_updateBackColor = TRUE; | 962 m_updateBackColor = TRUE; |
| 917 return FWL_ERR_Succeeded; | 963 return FWL_Error::Succeeded; |
| 918 } | 964 } |
| 919 FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 965 FWL_Error CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 920 m_wsFont = wsFont; | 966 m_wsFont = wsFont; |
| 921 m_fFontSize = fSize; | 967 m_fFontSize = fSize; |
| 922 return FWL_ERR_Succeeded; | 968 return FWL_Error::Succeeded; |
| 923 } | 969 } |
| 924 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { | 970 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 925 m_fScrollOffsetY = fScrollOffset; | 971 m_fScrollOffsetY = fScrollOffset; |
| 926 } | 972 } |
| 927 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, | 973 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, |
| 928 IFWL_ThemeProvider* pTheme, | 974 IFWL_ThemeProvider* pTheme, |
| 929 const CFX_Matrix* pMatrix) { | 975 const CFX_Matrix* pMatrix) { |
| 930 CFWL_ThemeBackground param; | 976 CFWL_ThemeBackground param; |
| 931 param.m_pWidget = m_pInterface; | 977 param.m_pWidget = m_pInterface; |
| 932 param.m_iPart = CFWL_Part::Background; | 978 param.m_iPart = CFWL_Part::Background; |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 } | 1819 } |
| 1774 default: { | 1820 default: { |
| 1775 iRet = 0; | 1821 iRet = 0; |
| 1776 break; | 1822 break; |
| 1777 } | 1823 } |
| 1778 } | 1824 } |
| 1779 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1825 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1780 return iRet; | 1826 return iRet; |
| 1781 } | 1827 } |
| 1782 | 1828 |
| 1783 FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1829 FWL_Error CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1784 if (!pEvent) | 1830 if (!pEvent) |
| 1785 return FWL_ERR_Indefinite; | 1831 return FWL_Error::Indefinite; |
| 1786 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1832 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 1787 return FWL_ERR_Succeeded; | 1833 return FWL_Error::Succeeded; |
| 1788 | 1834 |
| 1789 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1835 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 1790 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1836 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
| 1791 m_pOwner->m_pVertScrollBar) || | 1837 m_pOwner->m_pVertScrollBar) || |
| 1792 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1838 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
| 1793 m_pOwner->m_pHorzScrollBar)) { | 1839 m_pOwner->m_pHorzScrollBar)) { |
| 1794 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1840 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 1795 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1841 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
| 1796 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1842 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
| 1797 } | 1843 } |
| 1798 return FWL_ERR_Succeeded; | 1844 return FWL_Error::Succeeded; |
| 1799 } | 1845 } |
| 1800 | 1846 |
| 1801 FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1847 FWL_Error CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1802 const CFX_Matrix* pMatrix) { | 1848 const CFX_Matrix* pMatrix) { |
| 1803 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1849 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 1804 } | 1850 } |
| 1805 void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) { | 1851 void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) { |
| 1806 m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; | 1852 m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; |
| 1807 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1853 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1808 } | 1854 } |
| 1809 void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { | 1855 void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { |
| 1810 m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; | 1856 m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; |
| 1811 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1857 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1812 } | 1858 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 } | 2199 } |
| 2154 CFX_RectF rect; | 2200 CFX_RectF rect; |
| 2155 m_pOwner->GetWidgetRect(rect); | 2201 m_pOwner->GetWidgetRect(rect); |
| 2156 CFX_RectF rtInvalidate; | 2202 CFX_RectF rtInvalidate; |
| 2157 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2203 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2158 m_pOwner->Repaint(&rtInvalidate); | 2204 m_pOwner->Repaint(&rtInvalidate); |
| 2159 } | 2205 } |
| 2160 return TRUE; | 2206 return TRUE; |
| 2161 } | 2207 } |
| 2162 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2208 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |