| 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/core/ifwl_edit.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "third_party/base/stl_util.h" | 13 #include "third_party/base/stl_util.h" |
| 14 #include "xfa/fde/cfde_txtedtengine.h" | 14 #include "xfa/fde/cfde_txtedtengine.h" |
| 15 #include "xfa/fde/fde_gedevice.h" | 15 #include "xfa/fde/fde_gedevice.h" |
| 16 #include "xfa/fde/fde_render.h" | 16 #include "xfa/fde/fde_render.h" |
| 17 #include "xfa/fde/ifde_txtedtpage.h" | 17 #include "xfa/fde/ifde_txtedtpage.h" |
| 18 #include "xfa/fgas/font/fgas_gefont.h" | 18 #include "xfa/fgas/font/fgas_gefont.h" |
| 19 #include "xfa/fwl/basewidget/fwl_caretimp.h" | |
| 20 #include "xfa/fwl/basewidget/fwl_comboboximp.h" | |
| 21 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" | |
| 22 #include "xfa/fwl/basewidget/ifwl_caret.h" | |
| 23 #include "xfa/fwl/core/cfwl_message.h" | 19 #include "xfa/fwl/core/cfwl_message.h" |
| 24 #include "xfa/fwl/core/cfwl_themebackground.h" | 20 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 25 #include "xfa/fwl/core/cfwl_themepart.h" | 21 #include "xfa/fwl/core/cfwl_themepart.h" |
| 26 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 22 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 27 #include "xfa/fwl/core/fwl_widgetimp.h" | |
| 28 #include "xfa/fwl/core/ifwl_app.h" | 23 #include "xfa/fwl/core/ifwl_app.h" |
| 24 #include "xfa/fwl/core/ifwl_caret.h" |
| 29 #include "xfa/fwl/core/ifwl_themeprovider.h" | 25 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 30 #include "xfa/fxfa/xfa_ffdoc.h" | 26 #include "xfa/fxfa/xfa_ffdoc.h" |
| 31 #include "xfa/fxfa/xfa_ffwidget.h" | 27 #include "xfa/fxfa/xfa_ffwidget.h" |
| 32 #include "xfa/fxgraphics/cfx_path.h" | 28 #include "xfa/fxgraphics/cfx_path.h" |
| 33 | 29 |
| 34 namespace { | 30 namespace { |
| 35 | 31 |
| 36 const int kEditMargin = 3; | 32 const int kEditMargin = 3; |
| 37 | 33 |
| 38 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) { | 34 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 51 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { | 47 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { |
| 52 pPathData->LineTo(fx, fY + (i & 1) * fStep); | 48 pPathData->LineTo(fx, fY + (i & 1) * fStep); |
| 53 } | 49 } |
| 54 } | 50 } |
| 55 | 51 |
| 56 } // namespace | 52 } // namespace |
| 57 | 53 |
| 58 // static | 54 // static |
| 59 IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, | 55 IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, |
| 60 IFWL_Widget* pOuter) { | 56 IFWL_Widget* pOuter) { |
| 61 IFWL_Edit* pEdit = new IFWL_Edit; | 57 return new IFWL_Edit(properties, pOuter); |
| 62 CFWL_EditImp* pEditImpl = new CFWL_EditImp(properties, pOuter); | |
| 63 pEdit->SetImpl(pEditImpl); | |
| 64 pEditImpl->SetInterface(pEdit); | |
| 65 return pEdit; | |
| 66 } | |
| 67 // static | |
| 68 IFWL_Edit* IFWL_Edit::CreateComboEdit( | |
| 69 const CFWL_WidgetImpProperties& properties, | |
| 70 IFWL_Widget* pOuter) { | |
| 71 IFWL_Edit* pEdit = new IFWL_Edit; | |
| 72 CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); | |
| 73 pEdit->SetImpl(pComboEditImpl); | |
| 74 pComboEditImpl->SetInterface(pEdit); | |
| 75 return pEdit; | |
| 76 } | |
| 77 IFWL_Edit::IFWL_Edit() {} | |
| 78 FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { | |
| 79 return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText); | |
| 80 } | |
| 81 int32_t IFWL_Edit::GetTextLength() const { | |
| 82 return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength(); | |
| 83 } | |
| 84 FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, | |
| 85 int32_t nStart, | |
| 86 int32_t nCount) const { | |
| 87 return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); | |
| 88 } | |
| 89 FWL_Error IFWL_Edit::ClearText() { | |
| 90 return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); | |
| 91 } | |
| 92 int32_t IFWL_Edit::GetCaretPos() const { | |
| 93 return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); | |
| 94 } | |
| 95 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | |
| 96 return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore); | |
| 97 } | |
| 98 FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { | |
| 99 return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); | |
| 100 } | |
| 101 int32_t IFWL_Edit::CountSelRanges() { | |
| 102 return static_cast<CFWL_EditImp*>(GetImpl())->CountSelRanges(); | |
| 103 } | |
| 104 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { | |
| 105 return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart); | |
| 106 } | |
| 107 FWL_Error IFWL_Edit::ClearSelections() { | |
| 108 return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections(); | |
| 109 } | |
| 110 int32_t IFWL_Edit::GetLimit() { | |
| 111 return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit(); | |
| 112 } | |
| 113 FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { | |
| 114 return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); | |
| 115 } | |
| 116 FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { | |
| 117 return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias); | |
| 118 } | |
| 119 FWL_Error IFWL_Edit::Insert(int32_t nStart, | |
| 120 const FX_WCHAR* lpText, | |
| 121 int32_t nLen) { | |
| 122 return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); | |
| 123 } | |
| 124 FWL_Error IFWL_Edit::DeleteSelections() { | |
| 125 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); | |
| 126 } | |
| 127 FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { | |
| 128 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount); | |
| 129 } | |
| 130 FWL_Error IFWL_Edit::Replace(int32_t nStart, | |
| 131 int32_t nLen, | |
| 132 const CFX_WideStringC& wsReplace) { | |
| 133 return static_cast<CFWL_EditImp*>(GetImpl()) | |
| 134 ->Replace(nStart, nLen, wsReplace); | |
| 135 } | |
| 136 FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { | |
| 137 return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); | |
| 138 } | |
| 139 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { | |
| 140 return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); | |
| 141 } | |
| 142 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { | |
| 143 return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); | |
| 144 } | |
| 145 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { | |
| 146 return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); | |
| 147 } | |
| 148 FX_BOOL IFWL_Edit::Delete() { | |
| 149 return static_cast<CFWL_EditImp*>(GetImpl())->Delete(); | |
| 150 } | |
| 151 FX_BOOL IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { | |
| 152 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(pRecord); | |
| 153 } | |
| 154 FX_BOOL IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { | |
| 155 return static_cast<CFWL_EditImp*>(GetImpl())->Undo(pRecord); | |
| 156 } | |
| 157 FX_BOOL IFWL_Edit::Undo() { | |
| 158 return static_cast<CFWL_EditImp*>(GetImpl())->Undo(); | |
| 159 } | |
| 160 FX_BOOL IFWL_Edit::Redo() { | |
| 161 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); | |
| 162 } | |
| 163 FX_BOOL IFWL_Edit::CanUndo() { | |
| 164 return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); | |
| 165 } | |
| 166 FX_BOOL IFWL_Edit::CanRedo() { | |
| 167 return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); | |
| 168 } | |
| 169 FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | |
| 170 return static_cast<CFWL_EditImp*>(GetImpl()) | |
| 171 ->SetTabWidth(fTabWidth, bEquidistant); | |
| 172 } | |
| 173 FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { | |
| 174 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); | |
| 175 } | |
| 176 FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | |
| 177 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); | |
| 178 } | |
| 179 FWL_Error IFWL_Edit::SetBackColor(uint32_t dwColor) { | |
| 180 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); | |
| 181 } | |
| 182 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | |
| 183 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); | |
| 184 } | |
| 185 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | |
| 186 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); | |
| 187 } | |
| 188 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, | |
| 189 std::vector<CFX_ByteString>& sSuggest) { | |
| 190 return static_cast<CFWL_EditImp*>(GetImpl()) | |
| 191 ->GetSuggestWords(pointf, sSuggest); | |
| 192 } | |
| 193 FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, | |
| 194 const CFX_ByteStringC& bsReplace) { | |
| 195 return static_cast<CFWL_EditImp*>(GetImpl()) | |
| 196 ->ReplaceSpellCheckWord(pointf, bsReplace); | |
| 197 } | 58 } |
| 198 | 59 |
| 199 CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, | 60 IFWL_Edit::IFWL_Edit(const CFWL_WidgetImpProperties& properties, |
| 200 IFWL_Widget* pOuter) | 61 IFWL_Widget* pOuter) |
| 201 : CFWL_WidgetImp(properties, pOuter), | 62 : IFWL_Widget(properties, pOuter), |
| 202 m_fVAlignOffset(0.0f), | 63 m_fVAlignOffset(0.0f), |
| 203 m_fScrollOffsetX(0.0f), | 64 m_fScrollOffsetX(0.0f), |
| 204 m_fScrollOffsetY(0.0f), | 65 m_fScrollOffsetY(0.0f), |
| 205 m_bLButtonDown(FALSE), | 66 m_bLButtonDown(FALSE), |
| 206 m_nSelStart(0), | 67 m_nSelStart(0), |
| 207 m_nLimit(-1), | 68 m_nLimit(-1), |
| 208 m_fSpaceAbove(0), | 69 m_fSpaceAbove(0), |
| 209 m_fSpaceBelow(0), | 70 m_fSpaceBelow(0), |
| 210 m_fFontSize(0), | 71 m_fFontSize(0), |
| 211 m_bSetRange(FALSE), | 72 m_bSetRange(FALSE), |
| 212 m_iMin(-1), | 73 m_iMin(-1), |
| 213 m_iMax(0xFFFFFFF), | 74 m_iMax(0xFFFFFFF), |
| 214 m_backColor(0), | 75 m_backColor(0), |
| 215 m_updateBackColor(FALSE), | 76 m_updateBackColor(FALSE), |
| 216 m_iCurRecord(-1), | 77 m_iCurRecord(-1), |
| 217 m_iMaxRecord(128) { | 78 m_iMaxRecord(128) { |
| 218 m_rtClient.Reset(); | 79 m_rtClient.Reset(); |
| 219 m_rtEngine.Reset(); | 80 m_rtEngine.Reset(); |
| 220 m_rtStatic.Reset(); | 81 m_rtStatic.Reset(); |
| 221 } | 82 } |
| 222 | 83 |
| 223 CFWL_EditImp::~CFWL_EditImp() { | 84 IFWL_Edit::~IFWL_Edit() { |
| 224 ClearRecord(); | 85 ClearRecord(); |
| 225 } | 86 } |
| 226 | 87 |
| 227 FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { | 88 FWL_Error IFWL_Edit::GetClassName(CFX_WideString& wsClass) const { |
| 228 wsClass = FWL_CLASS_Edit; | 89 wsClass = FWL_CLASS_Edit; |
| 229 return FWL_Error::Succeeded; | 90 return FWL_Error::Succeeded; |
| 230 } | 91 } |
| 231 | 92 |
| 232 FWL_Type CFWL_EditImp::GetClassID() const { | 93 FWL_Type IFWL_Edit::GetClassID() const { |
| 233 return FWL_Type::Edit; | 94 return FWL_Type::Edit; |
| 234 } | 95 } |
| 235 | 96 |
| 236 FWL_Error CFWL_EditImp::Initialize() { | 97 FWL_Error IFWL_Edit::Initialize() { |
| 237 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) | 98 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) |
| 238 return FWL_Error::Indefinite; | 99 return FWL_Error::Indefinite; |
| 239 if (!m_pDelegate) | 100 if (!m_pDelegate) |
| 240 m_pDelegate = new CFWL_EditImpDelegate(this); | 101 m_pDelegate = new CFWL_EditImpDelegate(this); |
| 241 | 102 |
| 242 InitCaret(); | 103 InitCaret(); |
| 243 if (!m_pEdtEngine) | 104 if (!m_pEdtEngine) |
| 244 InitEngine(); | 105 InitEngine(); |
| 245 | 106 |
| 246 return FWL_Error::Succeeded; | 107 return FWL_Error::Succeeded; |
| 247 } | 108 } |
| 248 | 109 |
| 249 FWL_Error CFWL_EditImp::Finalize() { | 110 FWL_Error IFWL_Edit::Finalize() { |
| 250 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 111 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
| 251 ShowCaret(FALSE); | 112 ShowCaret(FALSE); |
| 252 } | 113 } |
| 253 if (m_pHorzScrollBar) { | 114 if (m_pHorzScrollBar) { |
| 254 m_pHorzScrollBar->Finalize(); | 115 m_pHorzScrollBar->Finalize(); |
| 255 } | 116 } |
| 256 if (m_pVertScrollBar) { | 117 if (m_pVertScrollBar) { |
| 257 m_pVertScrollBar->Finalize(); | 118 m_pVertScrollBar->Finalize(); |
| 258 } | 119 } |
| 259 delete m_pDelegate; | 120 delete m_pDelegate; |
| 260 m_pDelegate = nullptr; | 121 m_pDelegate = nullptr; |
| 261 return CFWL_WidgetImp::Finalize(); | 122 return IFWL_Widget::Finalize(); |
| 262 } | 123 } |
| 263 FWL_Error CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 124 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 264 if (bAutoSize) { | 125 if (bAutoSize) { |
| 265 rect.Set(0, 0, 0, 0); | 126 rect.Set(0, 0, 0, 0); |
| 266 if (m_pEdtEngine) { | 127 if (m_pEdtEngine) { |
| 267 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 128 int32_t iTextLen = m_pEdtEngine->GetTextLength(); |
| 268 if (iTextLen > 0) { | 129 if (iTextLen > 0) { |
| 269 CFX_WideString wsText; | 130 CFX_WideString wsText; |
| 270 m_pEdtEngine->GetText(wsText, 0); | 131 m_pEdtEngine->GetText(wsText, 0); |
| 271 CFX_SizeF sz = CalcTextSize( | 132 CFX_SizeF sz = CalcTextSize( |
| 272 wsText, m_pProperties->m_pThemeProvider, | 133 wsText, m_pProperties->m_pThemeProvider, |
| 273 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); | 134 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); |
| 274 rect.Set(0, 0, sz.x, sz.y); | 135 rect.Set(0, 0, sz.x, sz.y); |
| 275 } | 136 } |
| 276 } | 137 } |
| 277 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 138 IFWL_Widget::GetWidgetRect(rect, TRUE); |
| 278 } else { | 139 } else { |
| 279 rect = m_pProperties->m_rtWidget; | 140 rect = m_pProperties->m_rtWidget; |
| 280 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 141 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| 281 if (IsShowScrollBar(TRUE)) { | 142 if (IsShowScrollBar(TRUE)) { |
| 282 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 143 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 283 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 144 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 284 rect.width += *pfWidth; | 145 rect.width += *pfWidth; |
| 285 rect.width += kEditMargin; | 146 rect.width += kEditMargin; |
| 286 } | 147 } |
| 287 if (IsShowScrollBar(FALSE)) { | 148 if (IsShowScrollBar(FALSE)) { |
| 288 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 149 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 289 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 150 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 290 rect.height += *pfWidth; | 151 rect.height += *pfWidth; |
| 291 rect.height += kEditMargin; | 152 rect.height += kEditMargin; |
| 292 } | 153 } |
| 293 } | 154 } |
| 294 } | 155 } |
| 295 return FWL_Error::Succeeded; | 156 return FWL_Error::Succeeded; |
| 296 } | 157 } |
| 297 | 158 |
| 298 void CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 159 void IFWL_Edit::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
| 299 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || | 160 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || |
| 300 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 161 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 301 ShowCaret(FALSE); | 162 ShowCaret(FALSE); |
| 302 } | 163 } |
| 303 CFWL_WidgetImp::SetStates(dwStates, bSet); | 164 IFWL_Widget::SetStates(dwStates, bSet); |
| 304 } | 165 } |
| 305 | 166 |
| 306 FWL_Error CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { | 167 FWL_Error IFWL_Edit::SetWidgetRect(const CFX_RectF& rect) { |
| 307 return CFWL_WidgetImp::SetWidgetRect(rect); | 168 return IFWL_Widget::SetWidgetRect(rect); |
| 308 } | 169 } |
| 309 FWL_Error CFWL_EditImp::Update() { | 170 FWL_Error IFWL_Edit::Update() { |
| 310 if (IsLocked()) { | 171 if (IsLocked()) { |
| 311 return FWL_Error::Indefinite; | 172 return FWL_Error::Indefinite; |
| 312 } | 173 } |
| 313 if (!m_pProperties->m_pThemeProvider) { | 174 if (!m_pProperties->m_pThemeProvider) { |
| 314 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 175 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 315 } | 176 } |
| 316 Layout(); | 177 Layout(); |
| 317 if (m_rtClient.IsEmpty()) { | 178 if (m_rtClient.IsEmpty()) { |
| 318 return FWL_Error::Indefinite; | 179 return FWL_Error::Indefinite; |
| 319 } | 180 } |
| 320 UpdateEditEngine(); | 181 UpdateEditEngine(); |
| 321 UpdateVAlignment(); | 182 UpdateVAlignment(); |
| 322 UpdateScroll(); | 183 UpdateScroll(); |
| 323 InitCaret(); | 184 InitCaret(); |
| 324 return FWL_Error::Succeeded; | 185 return FWL_Error::Succeeded; |
| 325 } | 186 } |
| 326 | 187 |
| 327 FWL_WidgetHit CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 188 FWL_WidgetHit IFWL_Edit::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 328 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 189 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| 329 if (IsShowScrollBar(TRUE)) { | 190 if (IsShowScrollBar(TRUE)) { |
| 330 CFX_RectF rect; | 191 CFX_RectF rect; |
| 331 m_pVertScrollBar->GetWidgetRect(rect); | 192 m_pVertScrollBar->GetWidgetRect(rect); |
| 332 if (rect.Contains(fx, fy)) | 193 if (rect.Contains(fx, fy)) |
| 333 return FWL_WidgetHit::VScrollBar; | 194 return FWL_WidgetHit::VScrollBar; |
| 334 } | 195 } |
| 335 if (IsShowScrollBar(FALSE)) { | 196 if (IsShowScrollBar(FALSE)) { |
| 336 CFX_RectF rect; | 197 CFX_RectF rect; |
| 337 m_pHorzScrollBar->GetWidgetRect(rect); | 198 m_pHorzScrollBar->GetWidgetRect(rect); |
| 338 if (rect.Contains(fx, fy)) | 199 if (rect.Contains(fx, fy)) |
| 339 return FWL_WidgetHit::HScrollBar; | 200 return FWL_WidgetHit::HScrollBar; |
| 340 } | 201 } |
| 341 } | 202 } |
| 342 if (m_rtClient.Contains(fx, fy)) | 203 if (m_rtClient.Contains(fx, fy)) |
| 343 return FWL_WidgetHit::Edit; | 204 return FWL_WidgetHit::Edit; |
| 344 return FWL_WidgetHit::Unknown; | 205 return FWL_WidgetHit::Unknown; |
| 345 } | 206 } |
| 346 | 207 |
| 347 void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData, | 208 void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, |
| 348 int32_t nStart, | 209 int32_t nStart, |
| 349 int32_t nCount, | 210 int32_t nCount, |
| 350 FX_FLOAT fOffSetX, | 211 FX_FLOAT fOffSetX, |
| 351 FX_FLOAT fOffSetY) { | 212 FX_FLOAT fOffSetY) { |
| 352 FX_FLOAT fStartX = 0.0f; | 213 FX_FLOAT fStartX = 0.0f; |
| 353 FX_FLOAT fEndX = 0.0f; | 214 FX_FLOAT fEndX = 0.0f; |
| 354 FX_FLOAT fY = 0.0f; | 215 FX_FLOAT fY = 0.0f; |
| 355 FX_FLOAT fStep = 0.0f; | 216 FX_FLOAT fStep = 0.0f; |
| 356 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 217 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 357 CFX_RectFArray rectArray; | 218 CFX_RectFArray rectArray; |
| 358 CFX_RectF rectText; | 219 CFX_RectF rectText; |
| 359 const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); | 220 const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); |
| 360 FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * | 221 FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * |
| 361 txtEdtParams->fFontSize / 1000; | 222 txtEdtParams->fFontSize / 1000; |
| 362 pPage->CalcRangeRectArray(nStart, nCount, rectArray); | 223 pPage->CalcRangeRectArray(nStart, nCount, rectArray); |
| 363 for (int i = 0; i < rectArray.GetSize(); i++) { | 224 for (int i = 0; i < rectArray.GetSize(); i++) { |
| 364 rectText = rectArray.GetAt(i); | 225 rectText = rectArray.GetAt(i); |
| 365 fY = rectText.top + fAsent + fOffSetY; | 226 fY = rectText.top + fAsent + fOffSetY; |
| 366 fStep = txtEdtParams->fFontSize / 16.0f; | 227 fStep = txtEdtParams->fFontSize / 16.0f; |
| 367 fStartX = rectText.left + fOffSetX; | 228 fStartX = rectText.left + fOffSetX; |
| 368 fEndX = fStartX + rectText.Width(); | 229 fEndX = fStartX + rectText.Width(); |
| 369 AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); | 230 AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); |
| 370 } | 231 } |
| 371 } | 232 } |
| 372 int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { | 233 int32_t IFWL_Edit::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { |
| 373 return 0; | 234 return 0; |
| 374 } | 235 } |
| 375 FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf, | 236 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, |
| 376 std::vector<CFX_ByteString>& sSuggest) { | 237 std::vector<CFX_ByteString>& sSuggest) { |
| 377 int32_t nWordCount = 0; | 238 int32_t nWordCount = 0; |
| 378 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); | 239 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); |
| 379 if (nWordCount < 1) { | 240 if (nWordCount < 1) { |
| 380 return FALSE; | 241 return FALSE; |
| 381 } | 242 } |
| 382 CFX_WideString wsSpell; | 243 CFX_WideString wsSpell; |
| 383 GetText(wsSpell, nWordStart, nWordCount); | 244 GetText(wsSpell, nWordStart, nWordCount); |
| 384 CFX_ByteString sLatinWord; | 245 CFX_ByteString sLatinWord; |
| 385 for (int i = 0; i < nWordCount; i++) { | 246 for (int i = 0; i < nWordCount; i++) { |
| 386 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { | 247 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { |
| 387 break; | 248 break; |
| 388 } | 249 } |
| 389 sLatinWord += (FX_CHAR)wsSpell[i]; | 250 sLatinWord += (FX_CHAR)wsSpell[i]; |
| 390 } | 251 } |
| 391 if (sLatinWord.IsEmpty()) { | 252 if (sLatinWord.IsEmpty()) { |
| 392 return FALSE; | 253 return FALSE; |
| 393 } | 254 } |
| 394 CFWL_EvtEdtCheckWord checkWordEvent; | 255 CFWL_EvtEdtCheckWord checkWordEvent; |
| 395 checkWordEvent.m_pSrcTarget = m_pInterface; | 256 checkWordEvent.m_pSrcTarget = this; |
| 396 checkWordEvent.bsWord = sLatinWord; | 257 checkWordEvent.bsWord = sLatinWord; |
| 397 checkWordEvent.bCheckWord = TRUE; | 258 checkWordEvent.bCheckWord = TRUE; |
| 398 DispatchEvent(&checkWordEvent); | 259 DispatchEvent(&checkWordEvent); |
| 399 if (checkWordEvent.bCheckWord) { | 260 if (checkWordEvent.bCheckWord) { |
| 400 return FALSE; | 261 return FALSE; |
| 401 } | 262 } |
| 402 CFWL_EvtEdtGetSuggestWords suggestWordsEvent; | 263 CFWL_EvtEdtGetSuggestWords suggestWordsEvent; |
| 403 suggestWordsEvent.m_pSrcTarget = m_pInterface; | 264 suggestWordsEvent.m_pSrcTarget = this; |
| 404 suggestWordsEvent.bsWord = sLatinWord; | 265 suggestWordsEvent.bsWord = sLatinWord; |
| 405 suggestWordsEvent.bsArraySuggestWords = sSuggest; | 266 suggestWordsEvent.bsArraySuggestWords = sSuggest; |
| 406 suggestWordsEvent.bSuggestWords = FALSE; | 267 suggestWordsEvent.bSuggestWords = FALSE; |
| 407 DispatchEvent(&checkWordEvent); | 268 DispatchEvent(&checkWordEvent); |
| 408 return suggestWordsEvent.bSuggestWords; | 269 return suggestWordsEvent.bSuggestWords; |
| 409 } | 270 } |
| 410 FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf, | 271 FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, |
| 411 const CFX_ByteStringC& bsReplace) { | 272 const CFX_ByteStringC& bsReplace) { |
| 412 int32_t nWordCount = 0; | 273 int32_t nWordCount = 0; |
| 413 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); | 274 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); |
| 414 if (nWordCount < 1) { | 275 if (nWordCount < 1) { |
| 415 return FALSE; | 276 return FALSE; |
| 416 } | 277 } |
| 417 CFX_WideString wsSpell; | 278 CFX_WideString wsSpell; |
| 418 GetText(wsSpell, nWordStart, nWordCount); | 279 GetText(wsSpell, nWordStart, nWordCount); |
| 419 for (int i = 0; i < nWordCount; i++) { | 280 for (int i = 0; i < nWordCount; i++) { |
| 420 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { | 281 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { |
| 421 nWordCount = i; | 282 nWordCount = i; |
| 422 break; | 283 break; |
| 423 } | 284 } |
| 424 } | 285 } |
| 425 int32_t nDestLen = bsReplace.GetLength(); | 286 int32_t nDestLen = bsReplace.GetLength(); |
| 426 CFX_WideString wsDest; | 287 CFX_WideString wsDest; |
| 427 FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); | 288 FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); |
| 428 for (int32_t i = 0; i < nDestLen; i++) { | 289 for (int32_t i = 0; i < nDestLen; i++) { |
| 429 pBuffer[i] = bsReplace[i]; | 290 pBuffer[i] = bsReplace[i]; |
| 430 } | 291 } |
| 431 wsDest.ReleaseBuffer(nDestLen); | 292 wsDest.ReleaseBuffer(nDestLen); |
| 432 Replace(nWordStart, nWordCount, wsDest.AsStringC()); | 293 Replace(nWordStart, nWordCount, wsDest.AsStringC()); |
| 433 return TRUE; | 294 return TRUE; |
| 434 } | 295 } |
| 435 void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics, | 296 void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, |
| 436 const CFX_Matrix* pMatrix) { | 297 const CFX_Matrix* pMatrix) { |
| 437 pGraphics->SaveGraphState(); | 298 pGraphics->SaveGraphState(); |
| 438 if (pMatrix) { | 299 if (pMatrix) { |
| 439 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); | 300 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); |
| 440 } | 301 } |
| 441 FX_ARGB cr = 0xFFFF0000; | 302 FX_ARGB cr = 0xFFFF0000; |
| 442 CFX_Color crLine(cr); | 303 CFX_Color crLine(cr); |
| 443 CFWL_EvtEdtCheckWord checkWordEvent; | 304 CFWL_EvtEdtCheckWord checkWordEvent; |
| 444 checkWordEvent.m_pSrcTarget = m_pInterface; | 305 checkWordEvent.m_pSrcTarget = this; |
| 445 CFX_ByteString sLatinWord; | 306 CFX_ByteString sLatinWord; |
| 446 CFX_Path pathSpell; | 307 CFX_Path pathSpell; |
| 447 pathSpell.Create(); | 308 pathSpell.Create(); |
| 448 int32_t nStart = 0; | 309 int32_t nStart = 0; |
| 449 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; | 310 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; |
| 450 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; | 311 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; |
| 451 CFX_WideString wsSpell; | 312 CFX_WideString wsSpell; |
| 452 GetText(wsSpell); | 313 GetText(wsSpell); |
| 453 int32_t nContentLen = wsSpell.GetLength(); | 314 int32_t nContentLen = wsSpell.GetLength(); |
| 454 for (int i = 0; i < nContentLen; i++) { | 315 for (int i = 0; i < nContentLen; i++) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 483 pMatrix->TransformRect(rtClip); | 344 pMatrix->TransformRect(rtClip); |
| 484 mt.Concat(*pMatrix); | 345 mt.Concat(*pMatrix); |
| 485 } | 346 } |
| 486 pGraphics->SetClipRect(rtClip); | 347 pGraphics->SetClipRect(rtClip); |
| 487 pGraphics->SetStrokeColor(&crLine); | 348 pGraphics->SetStrokeColor(&crLine); |
| 488 pGraphics->SetLineWidth(0); | 349 pGraphics->SetLineWidth(0); |
| 489 pGraphics->StrokePath(&pathSpell, nullptr); | 350 pGraphics->StrokePath(&pathSpell, nullptr); |
| 490 } | 351 } |
| 491 pGraphics->RestoreGraphState(); | 352 pGraphics->RestoreGraphState(); |
| 492 } | 353 } |
| 493 FWL_Error CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, | 354 FWL_Error IFWL_Edit::DrawWidget(CFX_Graphics* pGraphics, |
| 494 const CFX_Matrix* pMatrix) { | 355 const CFX_Matrix* pMatrix) { |
| 495 if (!pGraphics) | 356 if (!pGraphics) |
| 496 return FWL_Error::Indefinite; | 357 return FWL_Error::Indefinite; |
| 497 if (!m_pProperties->m_pThemeProvider) | 358 if (!m_pProperties->m_pThemeProvider) |
| 498 return FWL_Error::Indefinite; | 359 return FWL_Error::Indefinite; |
| 499 if (m_rtClient.IsEmpty()) { | 360 if (m_rtClient.IsEmpty()) { |
| 500 return FWL_Error::Indefinite; | 361 return FWL_Error::Indefinite; |
| 501 } | 362 } |
| 502 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 363 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 503 if (!m_pWidgetMgr->IsFormDisabled()) { | 364 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 504 DrawTextBk(pGraphics, pTheme, pMatrix); | 365 DrawTextBk(pGraphics, pTheme, pMatrix); |
| 505 } | 366 } |
| 506 if (m_pEdtEngine) { | 367 if (m_pEdtEngine) { |
| 507 DrawContent(pGraphics, pTheme, pMatrix); | 368 DrawContent(pGraphics, pTheme, pMatrix); |
| 508 } | 369 } |
| 509 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 370 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
| 510 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { | 371 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { |
| 511 DrawSpellCheck(pGraphics, pMatrix); | 372 DrawSpellCheck(pGraphics, pMatrix); |
| 512 } | 373 } |
| 513 if (HasBorder()) { | 374 if (HasBorder()) { |
| 514 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 375 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 515 } | 376 } |
| 516 if (HasEdge()) { | 377 if (HasEdge()) { |
| 517 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 378 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 518 } | 379 } |
| 519 return FWL_Error::Succeeded; | 380 return FWL_Error::Succeeded; |
| 520 } | 381 } |
| 521 FWL_Error CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 382 FWL_Error IFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 522 if (!pThemeProvider) | 383 if (!pThemeProvider) |
| 523 return FWL_Error::Indefinite; | 384 return FWL_Error::Indefinite; |
| 524 if (m_pHorzScrollBar) { | 385 if (m_pHorzScrollBar) { |
| 525 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); | 386 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); |
| 526 } | 387 } |
| 527 if (m_pVertScrollBar) { | 388 if (m_pVertScrollBar) { |
| 528 m_pVertScrollBar->SetThemeProvider(pThemeProvider); | 389 m_pVertScrollBar->SetThemeProvider(pThemeProvider); |
| 529 } | 390 } |
| 530 if (m_pCaret) { | 391 if (m_pCaret) { |
| 531 m_pCaret->SetThemeProvider(pThemeProvider); | 392 m_pCaret->SetThemeProvider(pThemeProvider); |
| 532 } | 393 } |
| 533 m_pProperties->m_pThemeProvider = pThemeProvider; | 394 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 534 return FWL_Error::Succeeded; | 395 return FWL_Error::Succeeded; |
| 535 } | 396 } |
| 536 | 397 |
| 537 FWL_Error CFWL_EditImp::SetText(const CFX_WideString& wsText) { | 398 FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { |
| 538 m_pEdtEngine->SetText(wsText); | 399 m_pEdtEngine->SetText(wsText); |
| 539 return FWL_Error::Succeeded; | 400 return FWL_Error::Succeeded; |
| 540 } | 401 } |
| 541 | 402 |
| 542 int32_t CFWL_EditImp::GetTextLength() const { | 403 int32_t IFWL_Edit::GetTextLength() const { |
| 543 if (!m_pEdtEngine) | 404 if (!m_pEdtEngine) |
| 544 return -1; | 405 return -1; |
| 545 return m_pEdtEngine->GetTextLength(); | 406 return m_pEdtEngine->GetTextLength(); |
| 546 } | 407 } |
| 547 | 408 |
| 548 FWL_Error CFWL_EditImp::GetText(CFX_WideString& wsText, | 409 FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, |
| 549 int32_t nStart, | 410 int32_t nStart, |
| 550 int32_t nCount) const { | 411 int32_t nCount) const { |
| 551 if (!m_pEdtEngine) | 412 if (!m_pEdtEngine) |
| 552 return FWL_Error::Indefinite; | 413 return FWL_Error::Indefinite; |
| 553 | 414 |
| 554 m_pEdtEngine->GetText(wsText, nStart, nCount); | 415 m_pEdtEngine->GetText(wsText, nStart, nCount); |
| 555 return FWL_Error::Succeeded; | 416 return FWL_Error::Succeeded; |
| 556 } | 417 } |
| 557 | 418 |
| 558 FWL_Error CFWL_EditImp::ClearText() { | 419 FWL_Error IFWL_Edit::ClearText() { |
| 559 if (!m_pEdtEngine) | 420 if (!m_pEdtEngine) |
| 560 return FWL_Error::Indefinite; | 421 return FWL_Error::Indefinite; |
| 561 | 422 |
| 562 m_pEdtEngine->ClearText(); | 423 m_pEdtEngine->ClearText(); |
| 563 return FWL_Error::Succeeded; | 424 return FWL_Error::Succeeded; |
| 564 } | 425 } |
| 565 | 426 |
| 566 int32_t CFWL_EditImp::GetCaretPos() const { | 427 int32_t IFWL_Edit::GetCaretPos() const { |
| 567 if (!m_pEdtEngine) | 428 if (!m_pEdtEngine) |
| 568 return -1; | 429 return -1; |
| 569 return m_pEdtEngine->GetCaretPos(); | 430 return m_pEdtEngine->GetCaretPos(); |
| 570 } | 431 } |
| 571 | 432 |
| 572 int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 433 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
| 573 if (!m_pEdtEngine) | 434 if (!m_pEdtEngine) |
| 574 return -1; | 435 return -1; |
| 575 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 436 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); |
| 576 } | 437 } |
| 577 | 438 |
| 578 FWL_Error CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) { | 439 FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
| 579 if (!m_pEdtEngine) | 440 if (!m_pEdtEngine) |
| 580 return FWL_Error::Indefinite; | 441 return FWL_Error::Indefinite; |
| 581 | 442 |
| 582 m_pEdtEngine->AddSelRange(nStart, nCount); | 443 m_pEdtEngine->AddSelRange(nStart, nCount); |
| 583 return FWL_Error::Succeeded; | 444 return FWL_Error::Succeeded; |
| 584 } | 445 } |
| 585 | 446 |
| 586 int32_t CFWL_EditImp::CountSelRanges() { | 447 int32_t IFWL_Edit::CountSelRanges() { |
| 587 if (!m_pEdtEngine) | 448 if (!m_pEdtEngine) |
| 588 return 0; | 449 return 0; |
| 589 return m_pEdtEngine->CountSelRanges(); | 450 return m_pEdtEngine->CountSelRanges(); |
| 590 } | 451 } |
| 591 | 452 |
| 592 int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) { | 453 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 593 if (!m_pEdtEngine) | 454 if (!m_pEdtEngine) |
| 594 return -1; | 455 return -1; |
| 595 return m_pEdtEngine->GetSelRange(nIndex, nStart); | 456 return m_pEdtEngine->GetSelRange(nIndex, nStart); |
| 596 } | 457 } |
| 597 | 458 |
| 598 FWL_Error CFWL_EditImp::ClearSelections() { | 459 FWL_Error IFWL_Edit::ClearSelections() { |
| 599 if (!m_pEdtEngine) | 460 if (!m_pEdtEngine) |
| 600 return FWL_Error::Indefinite; | 461 return FWL_Error::Indefinite; |
| 601 | 462 |
| 602 m_pEdtEngine->ClearSelection(); | 463 m_pEdtEngine->ClearSelection(); |
| 603 return FWL_Error::Succeeded; | 464 return FWL_Error::Succeeded; |
| 604 } | 465 } |
| 605 | 466 |
| 606 int32_t CFWL_EditImp::GetLimit() { | 467 int32_t IFWL_Edit::GetLimit() { |
| 607 return m_nLimit; | 468 return m_nLimit; |
| 608 } | 469 } |
| 609 | 470 |
| 610 FWL_Error CFWL_EditImp::SetLimit(int32_t nLimit) { | 471 FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { |
| 611 m_nLimit = nLimit; | 472 m_nLimit = nLimit; |
| 612 if (!m_pEdtEngine) | 473 if (!m_pEdtEngine) |
| 613 return FWL_Error::Indefinite; | 474 return FWL_Error::Indefinite; |
| 614 | 475 |
| 615 m_pEdtEngine->SetLimit(nLimit); | 476 m_pEdtEngine->SetLimit(nLimit); |
| 616 return FWL_Error::Succeeded; | 477 return FWL_Error::Succeeded; |
| 617 } | 478 } |
| 618 | 479 |
| 619 FWL_Error CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { | 480 FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
| 620 if (!m_pEdtEngine) | 481 if (!m_pEdtEngine) |
| 621 return FWL_Error::Indefinite; | 482 return FWL_Error::Indefinite; |
| 622 | 483 |
| 623 m_pEdtEngine->SetAliasChar(wAlias); | 484 m_pEdtEngine->SetAliasChar(wAlias); |
| 624 return FWL_Error::Succeeded; | 485 return FWL_Error::Succeeded; |
| 625 } | 486 } |
| 626 | 487 |
| 627 FWL_Error CFWL_EditImp::Insert(int32_t nStart, | 488 FWL_Error IFWL_Edit::Insert(int32_t nStart, |
| 628 const FX_WCHAR* lpText, | 489 const FX_WCHAR* lpText, |
| 629 int32_t nLen) { | 490 int32_t nLen) { |
| 630 if (!m_pEdtEngine) | 491 if (!m_pEdtEngine) |
| 631 return FWL_Error::Indefinite; | 492 return FWL_Error::Indefinite; |
| 632 | 493 |
| 633 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 494 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 634 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 495 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 635 return FWL_Error::Indefinite; | 496 return FWL_Error::Indefinite; |
| 636 } | 497 } |
| 637 m_pEdtEngine->Insert(nStart, lpText, nLen); | 498 m_pEdtEngine->Insert(nStart, lpText, nLen); |
| 638 return FWL_Error::Succeeded; | 499 return FWL_Error::Succeeded; |
| 639 } | 500 } |
| 640 | 501 |
| 641 FWL_Error CFWL_EditImp::DeleteSelections() { | 502 FWL_Error IFWL_Edit::DeleteSelections() { |
| 642 if (!m_pEdtEngine) | 503 if (!m_pEdtEngine) |
| 643 return FWL_Error::Indefinite; | 504 return FWL_Error::Indefinite; |
| 644 | 505 |
| 645 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 506 int32_t iCount = m_pEdtEngine->CountSelRanges(); |
| 646 if (iCount > 0) | 507 if (iCount > 0) |
| 647 m_pEdtEngine->Delete(-1); | 508 m_pEdtEngine->Delete(-1); |
| 648 return FWL_Error::Succeeded; | 509 return FWL_Error::Succeeded; |
| 649 } | 510 } |
| 650 | 511 |
| 651 FWL_Error CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { | 512 FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { |
| 652 if (!m_pEdtEngine) | 513 if (!m_pEdtEngine) |
| 653 return FWL_Error::Indefinite; | 514 return FWL_Error::Indefinite; |
| 654 | 515 |
| 655 m_pEdtEngine->DeleteRange(nStart, nCount); | 516 m_pEdtEngine->DeleteRange(nStart, nCount); |
| 656 return FWL_Error::Succeeded; | 517 return FWL_Error::Succeeded; |
| 657 } | 518 } |
| 658 | 519 |
| 659 FWL_Error CFWL_EditImp::Replace(int32_t nStart, | 520 FWL_Error IFWL_Edit::Replace(int32_t nStart, |
| 660 int32_t nLen, | 521 int32_t nLen, |
| 661 const CFX_WideStringC& wsReplace) { | 522 const CFX_WideStringC& wsReplace) { |
| 662 if (!m_pEdtEngine) | 523 if (!m_pEdtEngine) |
| 663 return FWL_Error::Indefinite; | 524 return FWL_Error::Indefinite; |
| 664 | 525 |
| 665 m_pEdtEngine->Replace(nStart, nLen, CFX_WideString(wsReplace)); | 526 m_pEdtEngine->Replace(nStart, nLen, CFX_WideString(wsReplace)); |
| 666 return FWL_Error::Succeeded; | 527 return FWL_Error::Succeeded; |
| 667 } | 528 } |
| 668 | 529 |
| 669 FWL_Error CFWL_EditImp::DoClipboard(int32_t iCmd) { | 530 FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { |
| 670 if (!m_pEdtEngine) | 531 if (!m_pEdtEngine) |
| 671 return FWL_Error::Indefinite; | 532 return FWL_Error::Indefinite; |
| 672 | 533 |
| 673 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 534 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 674 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 535 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 675 return FWL_Error::Succeeded; | 536 return FWL_Error::Succeeded; |
| 676 } | 537 } |
| 677 return FWL_Error::Indefinite; | 538 return FWL_Error::Indefinite; |
| 678 } | 539 } |
| 679 | 540 |
| 680 FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { | 541 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { |
| 681 if (!m_pEdtEngine) | 542 if (!m_pEdtEngine) |
| 682 return FALSE; | 543 return FALSE; |
| 683 | 544 |
| 684 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 545 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 685 if (nCount == 0) | 546 if (nCount == 0) |
| 686 return FALSE; | 547 return FALSE; |
| 687 | 548 |
| 688 wsCopy.clear(); | 549 wsCopy.clear(); |
| 689 CFX_WideString wsTemp; | 550 CFX_WideString wsTemp; |
| 690 int32_t nStart, nLength; | 551 int32_t nStart, nLength; |
| 691 for (int32_t i = 0; i < nCount; i++) { | 552 for (int32_t i = 0; i < nCount; i++) { |
| 692 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 553 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
| 693 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 554 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
| 694 wsCopy += wsTemp; | 555 wsCopy += wsTemp; |
| 695 wsTemp.clear(); | 556 wsTemp.clear(); |
| 696 } | 557 } |
| 697 return TRUE; | 558 return TRUE; |
| 698 } | 559 } |
| 699 | 560 |
| 700 FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { | 561 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { |
| 701 if (!m_pEdtEngine) | 562 if (!m_pEdtEngine) |
| 702 return FALSE; | 563 return FALSE; |
| 703 | 564 |
| 704 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 565 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 705 if (nCount == 0) | 566 if (nCount == 0) |
| 706 return FALSE; | 567 return FALSE; |
| 707 | 568 |
| 708 wsCut.clear(); | 569 wsCut.clear(); |
| 709 CFX_WideString wsTemp; | 570 CFX_WideString wsTemp; |
| 710 int32_t nStart, nLength; | 571 int32_t nStart, nLength; |
| 711 for (int32_t i = 0; i < nCount; i++) { | 572 for (int32_t i = 0; i < nCount; i++) { |
| 712 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 573 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
| 713 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 574 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
| 714 wsCut += wsTemp; | 575 wsCut += wsTemp; |
| 715 wsTemp.clear(); | 576 wsTemp.clear(); |
| 716 } | 577 } |
| 717 m_pEdtEngine->Delete(0); | 578 m_pEdtEngine->Delete(0); |
| 718 return TRUE; | 579 return TRUE; |
| 719 } | 580 } |
| 720 | 581 |
| 721 FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) { | 582 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { |
| 722 if (!m_pEdtEngine) | 583 if (!m_pEdtEngine) |
| 723 return FALSE; | 584 return FALSE; |
| 724 | 585 |
| 725 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | 586 int32_t nCaret = m_pEdtEngine->GetCaretPos(); |
| 726 int32_t iError = | 587 int32_t iError = |
| 727 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); | 588 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); |
| 728 if (iError < 0) { | 589 if (iError < 0) { |
| 729 ProcessInsertError(iError); | 590 ProcessInsertError(iError); |
| 730 return FALSE; | 591 return FALSE; |
| 731 } | 592 } |
| 732 return TRUE; | 593 return TRUE; |
| 733 } | 594 } |
| 734 | 595 |
| 735 FX_BOOL CFWL_EditImp::Delete() { | 596 FX_BOOL IFWL_Edit::Delete() { |
| 736 if (!m_pEdtEngine) | 597 if (!m_pEdtEngine) |
| 737 return FALSE; | 598 return FALSE; |
| 738 | 599 |
| 739 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 600 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
| 740 if (nCount < 1) | 601 if (nCount < 1) |
| 741 return FALSE; | 602 return FALSE; |
| 742 | 603 |
| 743 m_pEdtEngine->Delete(0); | 604 m_pEdtEngine->Delete(0); |
| 744 return TRUE; | 605 return TRUE; |
| 745 } | 606 } |
| 746 | 607 |
| 747 FX_BOOL CFWL_EditImp::Redo(const IFDE_TxtEdtDoRecord* pRecord) { | 608 FX_BOOL IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 748 if (!m_pEdtEngine) | 609 if (!m_pEdtEngine) |
| 749 return FALSE; | 610 return FALSE; |
| 750 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) | 611 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 751 return TRUE; | 612 return TRUE; |
| 752 return m_pEdtEngine->Redo(pRecord); | 613 return m_pEdtEngine->Redo(pRecord); |
| 753 } | 614 } |
| 754 | 615 |
| 755 FX_BOOL CFWL_EditImp::Undo(const IFDE_TxtEdtDoRecord* pRecord) { | 616 FX_BOOL IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 756 if (!m_pEdtEngine) | 617 if (!m_pEdtEngine) |
| 757 return FALSE; | 618 return FALSE; |
| 758 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) | 619 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 759 return TRUE; | 620 return TRUE; |
| 760 return m_pEdtEngine->Undo(pRecord); | 621 return m_pEdtEngine->Undo(pRecord); |
| 761 } | 622 } |
| 762 | 623 |
| 763 FX_BOOL CFWL_EditImp::Undo() { | 624 FX_BOOL IFWL_Edit::Undo() { |
| 764 if (!CanUndo()) | 625 if (!CanUndo()) |
| 765 return FALSE; | 626 return FALSE; |
| 766 return Undo(m_DoRecords[m_iCurRecord--].get()); | 627 return Undo(m_DoRecords[m_iCurRecord--].get()); |
| 767 } | 628 } |
| 768 | 629 |
| 769 FX_BOOL CFWL_EditImp::Redo() { | 630 FX_BOOL IFWL_Edit::Redo() { |
| 770 if (!CanRedo()) | 631 if (!CanRedo()) |
| 771 return FALSE; | 632 return FALSE; |
| 772 return Redo(m_DoRecords[++m_iCurRecord].get()); | 633 return Redo(m_DoRecords[++m_iCurRecord].get()); |
| 773 } | 634 } |
| 774 | 635 |
| 775 FX_BOOL CFWL_EditImp::CanUndo() { | 636 FX_BOOL IFWL_Edit::CanUndo() { |
| 776 return m_iCurRecord >= 0; | 637 return m_iCurRecord >= 0; |
| 777 } | 638 } |
| 778 | 639 |
| 779 FX_BOOL CFWL_EditImp::CanRedo() { | 640 FX_BOOL IFWL_Edit::CanRedo() { |
| 780 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; | 641 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; |
| 781 } | 642 } |
| 782 | 643 |
| 783 FWL_Error CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 644 FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 784 if (!m_pEdtEngine) | 645 if (!m_pEdtEngine) |
| 785 return FWL_Error::Indefinite; | 646 return FWL_Error::Indefinite; |
| 786 | 647 |
| 787 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); | 648 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); |
| 788 pParams->fTabWidth = fTabWidth; | 649 pParams->fTabWidth = fTabWidth; |
| 789 pParams->bTabEquidistant = bEquidistant; | 650 pParams->bTabEquidistant = bEquidistant; |
| 790 return FWL_Error::Succeeded; | 651 return FWL_Error::Succeeded; |
| 791 } | 652 } |
| 792 | 653 |
| 793 FWL_Error CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { | 654 FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { |
| 794 m_pOuter = pOuter; | 655 m_pOuter = pOuter; |
| 795 return FWL_Error::Succeeded; | 656 return FWL_Error::Succeeded; |
| 796 } | 657 } |
| 797 | 658 |
| 798 FWL_Error CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { | 659 FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
| 799 m_iMin = iMin; | 660 m_iMin = iMin; |
| 800 m_iMax = iMax; | 661 m_iMax = iMax; |
| 801 m_bSetRange = TRUE; | 662 m_bSetRange = TRUE; |
| 802 return FWL_Error::Succeeded; | 663 return FWL_Error::Succeeded; |
| 803 } | 664 } |
| 804 | 665 |
| 805 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 666 void IFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
| 806 int32_t nPage, | 667 int32_t nPage, |
| 807 FX_BOOL bVisible) { | 668 FX_BOOL bVisible) { |
| 808 if (m_rtEngine.IsEmpty()) | 669 if (m_rtEngine.IsEmpty()) |
| 809 return; | 670 return; |
| 810 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | 671 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 811 return; | 672 return; |
| 812 | 673 |
| 813 FX_BOOL bRepaintContent = UpdateOffset(); | 674 FX_BOOL bRepaintContent = UpdateOffset(); |
| 814 UpdateCaret(); | 675 UpdateCaret(); |
| 815 CFX_RectF rtInvalid; | 676 CFX_RectF rtInvalid; |
| 816 rtInvalid.Set(0, 0, 0, 0); | 677 rtInvalid.Set(0, 0, 0, 0); |
| 817 FX_BOOL bRepaintScroll = FALSE; | 678 FX_BOOL bRepaintScroll = FALSE; |
| 818 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { | 679 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { |
| 819 IFWL_ScrollBar* pScroll = UpdateScroll(); | 680 IFWL_ScrollBar* pScroll = UpdateScroll(); |
| 820 if (pScroll) { | 681 if (pScroll) { |
| 821 pScroll->GetWidgetRect(rtInvalid); | 682 pScroll->GetWidgetRect(rtInvalid); |
| 822 bRepaintScroll = TRUE; | 683 bRepaintScroll = TRUE; |
| 823 } | 684 } |
| 824 } | 685 } |
| 825 if (bRepaintContent || bRepaintScroll) { | 686 if (bRepaintContent || bRepaintScroll) { |
| 826 if (bRepaintContent) { | 687 if (bRepaintContent) { |
| 827 rtInvalid.Union(m_rtEngine); | 688 rtInvalid.Union(m_rtEngine); |
| 828 } | 689 } |
| 829 Repaint(&rtInvalid); | 690 Repaint(&rtInvalid); |
| 830 } | 691 } |
| 831 } | 692 } |
| 832 | 693 |
| 833 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 694 void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
| 834 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { | 695 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { |
| 835 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; | 696 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; |
| 836 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) | 697 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) |
| 837 UpdateVAlignment(); | 698 UpdateVAlignment(); |
| 838 | 699 |
| 839 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); | 700 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); |
| 840 FX_FLOAT fContentWidth = page->GetContentsBox().width; | 701 FX_FLOAT fContentWidth = page->GetContentsBox().width; |
| 841 FX_FLOAT fContentHeight = page->GetContentsBox().height; | 702 FX_FLOAT fContentHeight = page->GetContentsBox().height; |
| 842 CFX_RectF rtTemp; | 703 CFX_RectF rtTemp; |
| 843 GetClientRect(rtTemp); | 704 GetClientRect(rtTemp); |
| 844 FX_BOOL bHSelfAdaption = | 705 FX_BOOL bHSelfAdaption = |
| 845 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; | 706 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; |
| 846 FX_BOOL bVSelfAdaption = | 707 FX_BOOL bVSelfAdaption = |
| 847 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; | 708 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; |
| 848 FX_BOOL bNeedUpdate = FALSE; | 709 FX_BOOL bNeedUpdate = FALSE; |
| 849 if (bHSelfAdaption || bVSelfAdaption) { | 710 if (bHSelfAdaption || bVSelfAdaption) { |
| 850 CFWL_EvtEdtPreSelfAdaption evt; | 711 CFWL_EvtEdtPreSelfAdaption evt; |
| 851 evt.m_pSrcTarget = m_pInterface; | 712 evt.m_pSrcTarget = this; |
| 852 evt.bHSelfAdaption = TRUE; | 713 evt.bHSelfAdaption = TRUE; |
| 853 evt.bVSelfAdaption = TRUE; | 714 evt.bVSelfAdaption = TRUE; |
| 854 FX_FLOAT fWidth; | 715 FX_FLOAT fWidth; |
| 855 FX_FLOAT fHight; | 716 FX_FLOAT fHight; |
| 856 fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width; | 717 fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width; |
| 857 fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height; | 718 fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height; |
| 858 evt.rtAfterChange.Set(0, 0, fWidth, fHight); | 719 evt.rtAfterChange.Set(0, 0, fWidth, fHight); |
| 859 DispatchEvent(&evt); | 720 DispatchEvent(&evt); |
| 860 if (!evt.bHSelfAdaption) { | 721 if (!evt.bHSelfAdaption) { |
| 861 ModifyStylesEx( | 722 ModifyStylesEx( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 879 } | 740 } |
| 880 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { | 741 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { |
| 881 rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); | 742 rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); |
| 882 m_pProperties->m_rtWidget.width = fContentWidth1; | 743 m_pProperties->m_rtWidget.width = fContentWidth1; |
| 883 } | 744 } |
| 884 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { | 745 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { |
| 885 rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); | 746 rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); |
| 886 m_pProperties->m_rtWidget.height = fContentHeight1; | 747 m_pProperties->m_rtWidget.height = fContentHeight1; |
| 887 } | 748 } |
| 888 CFWL_EvtEdtTextChanged event; | 749 CFWL_EvtEdtTextChanged event; |
| 889 event.m_pSrcTarget = m_pInterface; | 750 event.m_pSrcTarget = this; |
| 890 event.nChangeType = ChangeInfo.nChangeType; | 751 event.nChangeType = ChangeInfo.nChangeType; |
| 891 event.wsInsert = ChangeInfo.wsInsert; | 752 event.wsInsert = ChangeInfo.wsInsert; |
| 892 event.wsDelete = ChangeInfo.wsDelete; | 753 event.wsDelete = ChangeInfo.wsDelete; |
| 893 event.wsPrevText = ChangeInfo.wsPrevText; | 754 event.wsPrevText = ChangeInfo.wsPrevText; |
| 894 DispatchEvent(&event); | 755 DispatchEvent(&event); |
| 895 LayoutScrollBar(); | 756 LayoutScrollBar(); |
| 896 Repaint(&rtTemp); | 757 Repaint(&rtTemp); |
| 897 } | 758 } |
| 898 | 759 |
| 899 void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { | 760 void IFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { |
| 900 CFX_RectF rtTemp; | 761 CFX_RectF rtTemp; |
| 901 GetClientRect(rtTemp); | 762 GetClientRect(rtTemp); |
| 902 Repaint(&rtTemp); | 763 Repaint(&rtTemp); |
| 903 } | 764 } |
| 904 | 765 |
| 905 FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit, | 766 FX_BOOL IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, |
| 906 int32_t nPageIndex, | 767 int32_t nPageIndex, |
| 907 int32_t nPurpose) { | 768 int32_t nPurpose) { |
| 908 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); | 769 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); |
| 909 if (!pPage) | 770 if (!pPage) |
| 910 return FALSE; | 771 return FALSE; |
| 911 pPage->LoadPage(nullptr, nullptr); | 772 pPage->LoadPage(nullptr, nullptr); |
| 912 return TRUE; | 773 return TRUE; |
| 913 } | 774 } |
| 914 | 775 |
| 915 FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit, | 776 FX_BOOL IFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, |
| 916 int32_t nPageIndex, | 777 int32_t nPageIndex, |
| 917 int32_t nPurpose) { | 778 int32_t nPurpose) { |
| 918 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); | 779 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); |
| 919 if (!pPage) | 780 if (!pPage) |
| 920 return FALSE; | 781 return FALSE; |
| 921 pPage->UnloadPage(nullptr); | 782 pPage->UnloadPage(nullptr); |
| 922 return TRUE; | 783 return TRUE; |
| 923 } | 784 } |
| 924 | 785 |
| 925 void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, | 786 void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, |
| 926 IFDE_TxtEdtDoRecord* pRecord) { | 787 IFDE_TxtEdtDoRecord* pRecord) { |
| 927 AddDoRecord(pRecord); | 788 AddDoRecord(pRecord); |
| 928 } | 789 } |
| 929 | 790 |
| 930 FX_BOOL CFWL_EditImp::On_Validate(CFDE_TxtEdtEngine* pEdit, | 791 FX_BOOL IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, |
| 931 CFX_WideString& wsText) { | 792 CFX_WideString& wsText) { |
| 932 IFWL_Widget* pDst = GetOuter(); | 793 IFWL_Widget* pDst = GetOuter(); |
| 933 if (!pDst) { | 794 if (!pDst) { |
| 934 pDst = m_pInterface; | 795 pDst = this; |
| 935 } | 796 } |
| 936 CFWL_EvtEdtValidate event; | 797 CFWL_EvtEdtValidate event; |
| 937 event.pDstWidget = pDst; | 798 event.pDstWidget = pDst; |
| 938 event.m_pSrcTarget = m_pInterface; | 799 event.m_pSrcTarget = this; |
| 939 event.wsInsert = wsText; | 800 event.wsInsert = wsText; |
| 940 event.bValidate = TRUE; | 801 event.bValidate = TRUE; |
| 941 DispatchEvent(&event); | 802 DispatchEvent(&event); |
| 942 return event.bValidate; | 803 return event.bValidate; |
| 943 } | 804 } |
| 944 FWL_Error CFWL_EditImp::SetBackgroundColor(uint32_t color) { | 805 FWL_Error IFWL_Edit::SetBackgroundColor(uint32_t color) { |
| 945 m_backColor = color; | 806 m_backColor = color; |
| 946 m_updateBackColor = TRUE; | 807 m_updateBackColor = TRUE; |
| 947 return FWL_Error::Succeeded; | 808 return FWL_Error::Succeeded; |
| 948 } | 809 } |
| 949 FWL_Error CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 810 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 950 m_wsFont = wsFont; | 811 m_wsFont = wsFont; |
| 951 m_fFontSize = fSize; | 812 m_fFontSize = fSize; |
| 952 return FWL_Error::Succeeded; | 813 return FWL_Error::Succeeded; |
| 953 } | 814 } |
| 954 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { | 815 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 955 m_fScrollOffsetY = fScrollOffset; | 816 m_fScrollOffsetY = fScrollOffset; |
| 956 } | 817 } |
| 957 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, | 818 void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, |
| 958 IFWL_ThemeProvider* pTheme, | 819 IFWL_ThemeProvider* pTheme, |
| 959 const CFX_Matrix* pMatrix) { | 820 const CFX_Matrix* pMatrix) { |
| 960 CFWL_ThemeBackground param; | 821 CFWL_ThemeBackground param; |
| 961 param.m_pWidget = m_pInterface; | 822 param.m_pWidget = this; |
| 962 param.m_iPart = CFWL_Part::Background; | 823 param.m_iPart = CFWL_Part::Background; |
| 963 param.m_bStaticBackground = false; | 824 param.m_bStaticBackground = false; |
| 964 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly | 825 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly |
| 965 ? CFWL_PartState_ReadOnly | 826 ? CFWL_PartState_ReadOnly |
| 966 : CFWL_PartState_Normal; | 827 : CFWL_PartState_Normal; |
| 967 uint32_t dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); | 828 uint32_t dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); |
| 968 if (dwStates) { | 829 if (dwStates) { |
| 969 param.m_dwStates = CFWL_PartState_Disabled; | 830 param.m_dwStates = CFWL_PartState_Disabled; |
| 970 } | 831 } |
| 971 param.m_pGraphics = pGraphics; | 832 param.m_pGraphics = pGraphics; |
| 972 param.m_matrix = *pMatrix; | 833 param.m_matrix = *pMatrix; |
| 973 param.m_rtPart = m_rtClient; | 834 param.m_rtPart = m_rtClient; |
| 974 pTheme->DrawBackground(¶m); | 835 pTheme->DrawBackground(¶m); |
| 975 if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { | 836 if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { |
| 976 return; | 837 return; |
| 977 } | 838 } |
| 978 CFX_RectF rtScorll; | 839 CFX_RectF rtScorll; |
| 979 m_pHorzScrollBar->GetWidgetRect(rtScorll); | 840 m_pHorzScrollBar->GetWidgetRect(rtScorll); |
| 980 CFX_RectF rtStatic; | 841 CFX_RectF rtStatic; |
| 981 rtStatic.Set(m_rtClient.right() - rtScorll.height, | 842 rtStatic.Set(m_rtClient.right() - rtScorll.height, |
| 982 m_rtClient.bottom() - rtScorll.height, rtScorll.height, | 843 m_rtClient.bottom() - rtScorll.height, rtScorll.height, |
| 983 rtScorll.height); | 844 rtScorll.height); |
| 984 param.m_bStaticBackground = true; | 845 param.m_bStaticBackground = true; |
| 985 param.m_bMaximize = true; | 846 param.m_bMaximize = true; |
| 986 param.m_rtPart = rtStatic; | 847 param.m_rtPart = rtStatic; |
| 987 pTheme->DrawBackground(¶m); | 848 pTheme->DrawBackground(¶m); |
| 988 } | 849 } |
| 989 void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics, | 850 void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, |
| 990 IFWL_ThemeProvider* pTheme, | 851 IFWL_ThemeProvider* pTheme, |
| 991 const CFX_Matrix* pMatrix) { | 852 const CFX_Matrix* pMatrix) { |
| 992 if (!m_pEdtEngine) | 853 if (!m_pEdtEngine) |
| 993 return; | 854 return; |
| 994 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 855 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 995 if (!pPage) | 856 if (!pPage) |
| 996 return; | 857 return; |
| 997 pGraphics->SaveGraphState(); | 858 pGraphics->SaveGraphState(); |
| 998 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { | 859 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { |
| 999 pGraphics->SaveGraphState(); | 860 pGraphics->SaveGraphState(); |
| 1000 } | 861 } |
| 1001 CFX_RectF rtClip = m_rtEngine; | 862 CFX_RectF rtClip = m_rtEngine; |
| 1002 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; | 863 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; |
| 1003 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; | 864 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; |
| 1004 CFX_Matrix mt; | 865 CFX_Matrix mt; |
| 1005 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); | 866 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); |
| 1006 if (pMatrix) { | 867 if (pMatrix) { |
| 1007 pMatrix->TransformRect(rtClip); | 868 pMatrix->TransformRect(rtClip); |
| 1008 mt.Concat(*pMatrix); | 869 mt.Concat(*pMatrix); |
| 1009 } | 870 } |
| 1010 FX_BOOL bShowSel = | 871 FX_BOOL bShowSel = |
| 1011 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || | 872 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || |
| 1012 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 873 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 1013 if (bShowSel) { | 874 if (bShowSel) { |
| 1014 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); | 875 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); |
| 1015 if (pForm) { | 876 if (pForm) { |
| 1016 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != | 877 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != |
| 1017 FWL_WGTSTATE_Deactivated; | 878 FWL_WGTSTATE_Deactivated; |
| 1018 } | 879 } |
| 1019 } | 880 } |
| 1020 int32_t nSelCount = m_pEdtEngine->CountSelRanges(); | 881 int32_t nSelCount = m_pEdtEngine->CountSelRanges(); |
| 1021 if (bShowSel && nSelCount > 0) { | 882 if (bShowSel && nSelCount > 0) { |
| 1022 int32_t nPageCharStart = pPage->GetCharStart(); | 883 int32_t nPageCharStart = pPage->GetCharStart(); |
| 1023 int32_t nPageCharCount = pPage->GetCharCount(); | 884 int32_t nPageCharCount = pPage->GetCharCount(); |
| 1024 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; | 885 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1043 for (i = 0; i < nCount; i++) { | 904 for (i = 0; i < nCount; i++) { |
| 1044 rectArr[i].left += fOffSetX; | 905 rectArr[i].left += fOffSetX; |
| 1045 rectArr[i].top += fOffSetY; | 906 rectArr[i].top += fOffSetY; |
| 1046 path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width, | 907 path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width, |
| 1047 rectArr[i].height); | 908 rectArr[i].height); |
| 1048 } | 909 } |
| 1049 pGraphics->SetClipRect(rtClip); | 910 pGraphics->SetClipRect(rtClip); |
| 1050 CFWL_ThemeBackground param; | 911 CFWL_ThemeBackground param; |
| 1051 param.m_pGraphics = pGraphics; | 912 param.m_pGraphics = pGraphics; |
| 1052 param.m_matrix = *pMatrix; | 913 param.m_matrix = *pMatrix; |
| 1053 param.m_pWidget = m_pInterface; | 914 param.m_pWidget = this; |
| 1054 param.m_iPart = CFWL_Part::Background; | 915 param.m_iPart = CFWL_Part::Background; |
| 1055 param.m_pPath = &path; | 916 param.m_pPath = &path; |
| 1056 pTheme->DrawBackground(¶m); | 917 pTheme->DrawBackground(¶m); |
| 1057 } | 918 } |
| 1058 CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice(); | 919 CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice(); |
| 1059 if (!pRenderDev) | 920 if (!pRenderDev) |
| 1060 return; | 921 return; |
| 1061 | 922 |
| 1062 std::unique_ptr<CFDE_RenderDevice> pRenderDevice( | 923 std::unique_ptr<CFDE_RenderDevice> pRenderDevice( |
| 1063 new CFDE_RenderDevice(pRenderDev, FALSE)); | 924 new CFDE_RenderDevice(pRenderDev, FALSE)); |
| 1064 std::unique_ptr<CFDE_RenderContext> pRenderContext(new CFDE_RenderContext); | 925 std::unique_ptr<CFDE_RenderContext> pRenderContext(new CFDE_RenderContext); |
| 1065 pRenderDevice->SetClipRect(rtClip); | 926 pRenderDevice->SetClipRect(rtClip); |
| 1066 pRenderContext->StartRender(pRenderDevice.get(), pPage, mt); | 927 pRenderContext->StartRender(pRenderDevice.get(), pPage, mt); |
| 1067 pRenderContext->DoRender(nullptr); | 928 pRenderContext->DoRender(nullptr); |
| 1068 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { | 929 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { |
| 1069 pGraphics->RestoreGraphState(); | 930 pGraphics->RestoreGraphState(); |
| 1070 CFX_Path path; | 931 CFX_Path path; |
| 1071 path.Create(); | 932 path.Create(); |
| 1072 int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1; | 933 int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1; |
| 1073 FX_FLOAT fStep = m_rtEngine.width / iLimit; | 934 FX_FLOAT fStep = m_rtEngine.width / iLimit; |
| 1074 FX_FLOAT fLeft = m_rtEngine.left + 1; | 935 FX_FLOAT fLeft = m_rtEngine.left + 1; |
| 1075 for (int32_t i = 1; i < iLimit; i++) { | 936 for (int32_t i = 1; i < iLimit; i++) { |
| 1076 fLeft += fStep; | 937 fLeft += fStep; |
| 1077 path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); | 938 path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); |
| 1078 } | 939 } |
| 1079 CFWL_ThemeBackground param; | 940 CFWL_ThemeBackground param; |
| 1080 param.m_pGraphics = pGraphics; | 941 param.m_pGraphics = pGraphics; |
| 1081 param.m_matrix = *pMatrix; | 942 param.m_matrix = *pMatrix; |
| 1082 param.m_pWidget = m_pInterface; | 943 param.m_pWidget = this; |
| 1083 param.m_iPart = CFWL_Part::CombTextLine; | 944 param.m_iPart = CFWL_Part::CombTextLine; |
| 1084 param.m_pPath = &path; | 945 param.m_pPath = &path; |
| 1085 pTheme->DrawBackground(¶m); | 946 pTheme->DrawBackground(¶m); |
| 1086 } | 947 } |
| 1087 pGraphics->RestoreGraphState(); | 948 pGraphics->RestoreGraphState(); |
| 1088 } | 949 } |
| 1089 | 950 |
| 1090 void CFWL_EditImp::UpdateEditEngine() { | 951 void IFWL_Edit::UpdateEditEngine() { |
| 1091 UpdateEditParams(); | 952 UpdateEditParams(); |
| 1092 UpdateEditLayout(); | 953 UpdateEditLayout(); |
| 1093 if (m_nLimit > -1) { | 954 if (m_nLimit > -1) { |
| 1094 m_pEdtEngine->SetLimit(m_nLimit); | 955 m_pEdtEngine->SetLimit(m_nLimit); |
| 1095 } | 956 } |
| 1096 } | 957 } |
| 1097 void CFWL_EditImp::UpdateEditParams() { | 958 void IFWL_Edit::UpdateEditParams() { |
| 1098 FDE_TXTEDTPARAMS params; | 959 FDE_TXTEDTPARAMS params; |
| 1099 params.nHorzScale = 100; | 960 params.nHorzScale = 100; |
| 1100 params.fPlateWidth = m_rtEngine.width; | 961 params.fPlateWidth = m_rtEngine.width; |
| 1101 params.fPlateHeight = m_rtEngine.height; | 962 params.fPlateHeight = m_rtEngine.height; |
| 1102 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { | 963 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { |
| 1103 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; | 964 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; |
| 1104 } | 965 } |
| 1105 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) { | 966 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) { |
| 1106 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical; | 967 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical; |
| 1107 } | 968 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 params.nLineCount = 1; | 1064 params.nLineCount = 1; |
| 1204 } | 1065 } |
| 1205 params.fTabWidth = params.fFontSize * 1; | 1066 params.fTabWidth = params.fFontSize * 1; |
| 1206 params.bTabEquidistant = TRUE; | 1067 params.bTabEquidistant = TRUE; |
| 1207 params.wLineBreakChar = L'\n'; | 1068 params.wLineBreakChar = L'\n'; |
| 1208 params.nCharRotation = 0; | 1069 params.nCharRotation = 0; |
| 1209 params.pEventSink = this; | 1070 params.pEventSink = this; |
| 1210 m_pEdtEngine->SetEditParams(params); | 1071 m_pEdtEngine->SetEditParams(params); |
| 1211 } | 1072 } |
| 1212 | 1073 |
| 1213 void CFWL_EditImp::UpdateEditLayout() { | 1074 void IFWL_Edit::UpdateEditLayout() { |
| 1214 if (m_pEdtEngine->GetTextLength() <= 0) | 1075 if (m_pEdtEngine->GetTextLength() <= 0) |
| 1215 m_pEdtEngine->SetTextByStream(nullptr); | 1076 m_pEdtEngine->SetTextByStream(nullptr); |
| 1216 | 1077 |
| 1217 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1078 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 1218 if (pPage) | 1079 if (pPage) |
| 1219 pPage->UnloadPage(nullptr); | 1080 pPage->UnloadPage(nullptr); |
| 1220 | 1081 |
| 1221 m_pEdtEngine->StartLayout(); | 1082 m_pEdtEngine->StartLayout(); |
| 1222 m_pEdtEngine->DoLayout(nullptr); | 1083 m_pEdtEngine->DoLayout(nullptr); |
| 1223 m_pEdtEngine->EndLayout(); | 1084 m_pEdtEngine->EndLayout(); |
| 1224 pPage = m_pEdtEngine->GetPage(0); | 1085 pPage = m_pEdtEngine->GetPage(0); |
| 1225 if (pPage) | 1086 if (pPage) |
| 1226 pPage->LoadPage(nullptr, nullptr); | 1087 pPage->LoadPage(nullptr, nullptr); |
| 1227 } | 1088 } |
| 1228 | 1089 |
| 1229 FX_BOOL CFWL_EditImp::UpdateOffset() { | 1090 FX_BOOL IFWL_Edit::UpdateOffset() { |
| 1230 CFX_RectF rtCaret; | 1091 CFX_RectF rtCaret; |
| 1231 m_pEdtEngine->GetCaretRect(rtCaret); | 1092 m_pEdtEngine->GetCaretRect(rtCaret); |
| 1232 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; | 1093 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; |
| 1233 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; | 1094 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; |
| 1234 rtCaret.Offset(fOffSetX, fOffSetY); | 1095 rtCaret.Offset(fOffSetX, fOffSetY); |
| 1235 const CFX_RectF& rtEidt = m_rtEngine; | 1096 const CFX_RectF& rtEidt = m_rtEngine; |
| 1236 if (rtEidt.Contains(rtCaret)) { | 1097 if (rtEidt.Contains(rtCaret)) { |
| 1237 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1098 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 1238 if (!pPage) | 1099 if (!pPage) |
| 1239 return FALSE; | 1100 return FALSE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1263 offsetY = rtCaret.bottom() - rtEidt.bottom(); | 1124 offsetY = rtCaret.bottom() - rtEidt.bottom(); |
| 1264 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) | 1125 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) |
| 1265 m_fScrollOffsetX += offsetX; | 1126 m_fScrollOffsetX += offsetX; |
| 1266 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) | 1127 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) |
| 1267 m_fScrollOffsetY += offsetY; | 1128 m_fScrollOffsetY += offsetY; |
| 1268 if (m_fFontSize > m_rtEngine.height) | 1129 if (m_fFontSize > m_rtEngine.height) |
| 1269 m_fScrollOffsetY = 0; | 1130 m_fScrollOffsetY = 0; |
| 1270 return TRUE; | 1131 return TRUE; |
| 1271 } | 1132 } |
| 1272 | 1133 |
| 1273 FX_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar, | 1134 FX_BOOL IFWL_Edit::UpdateOffset(IFWL_ScrollBar* pScrollBar, |
| 1274 FX_FLOAT fPosChanged) { | 1135 FX_FLOAT fPosChanged) { |
| 1275 if (pScrollBar == m_pHorzScrollBar.get()) | 1136 if (pScrollBar == m_pHorzScrollBar.get()) |
| 1276 m_fScrollOffsetX += fPosChanged; | 1137 m_fScrollOffsetX += fPosChanged; |
| 1277 else | 1138 else |
| 1278 m_fScrollOffsetY += fPosChanged; | 1139 m_fScrollOffsetY += fPosChanged; |
| 1279 return TRUE; | 1140 return TRUE; |
| 1280 } | 1141 } |
| 1281 | 1142 |
| 1282 void CFWL_EditImp::UpdateVAlignment() { | 1143 void IFWL_Edit::UpdateVAlignment() { |
| 1283 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1144 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 1284 if (!pPage) | 1145 if (!pPage) |
| 1285 return; | 1146 return; |
| 1286 const CFX_RectF& rtFDE = pPage->GetContentsBox(); | 1147 const CFX_RectF& rtFDE = pPage->GetContentsBox(); |
| 1287 FX_FLOAT fOffsetY = 0.0f; | 1148 FX_FLOAT fOffsetY = 0.0f; |
| 1288 FX_FLOAT fSpaceAbove = 0.0f; | 1149 FX_FLOAT fSpaceAbove = 0.0f; |
| 1289 FX_FLOAT fSpaceBelow = 0.0f; | 1150 FX_FLOAT fSpaceBelow = 0.0f; |
| 1290 CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( | 1151 CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( |
| 1291 GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow)); | 1152 GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow)); |
| 1292 if (pSpace) { | 1153 if (pSpace) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1310 fOffsetY = (m_rtEngine.height - rtFDE.height); | 1171 fOffsetY = (m_rtEngine.height - rtFDE.height); |
| 1311 fOffsetY -= fSpaceBelow; | 1172 fOffsetY -= fSpaceBelow; |
| 1312 } else { | 1173 } else { |
| 1313 fOffsetY += fSpaceAbove; | 1174 fOffsetY += fSpaceAbove; |
| 1314 } | 1175 } |
| 1315 m_fVAlignOffset = fOffsetY; | 1176 m_fVAlignOffset = fOffsetY; |
| 1316 if (m_fVAlignOffset < 0) { | 1177 if (m_fVAlignOffset < 0) { |
| 1317 m_fVAlignOffset = 0; | 1178 m_fVAlignOffset = 0; |
| 1318 } | 1179 } |
| 1319 } | 1180 } |
| 1320 void CFWL_EditImp::UpdateCaret() { | 1181 void IFWL_Edit::UpdateCaret() { |
| 1321 CFX_RectF rtFDE; | 1182 CFX_RectF rtFDE; |
| 1322 m_pEdtEngine->GetCaretRect(rtFDE); | 1183 m_pEdtEngine->GetCaretRect(rtFDE); |
| 1323 rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, | 1184 rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, |
| 1324 m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); | 1185 m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); |
| 1325 CFX_RectF rtCaret; | 1186 CFX_RectF rtCaret; |
| 1326 rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); | 1187 rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); |
| 1327 CFX_RectF temp = rtCaret; | 1188 CFX_RectF temp = rtCaret; |
| 1328 CFX_RectF rtClient; | 1189 CFX_RectF rtClient; |
| 1329 GetClientRect(rtClient); | 1190 GetClientRect(rtClient); |
| 1330 rtCaret.Intersect(rtClient); | 1191 rtCaret.Intersect(rtClient); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1347 temp.bottom() > m_rtEngine.bottom()) { | 1208 temp.bottom() > m_rtEngine.bottom()) { |
| 1348 bShowWhole = TRUE; | 1209 bShowWhole = TRUE; |
| 1349 } else { | 1210 } else { |
| 1350 bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect); | 1211 bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect); |
| 1351 } | 1212 } |
| 1352 if (bShowWhole) { | 1213 if (bShowWhole) { |
| 1353 rtCaret = temp; | 1214 rtCaret = temp; |
| 1354 } | 1215 } |
| 1355 ShowCaret(bShow, &rtCaret); | 1216 ShowCaret(bShow, &rtCaret); |
| 1356 } | 1217 } |
| 1357 IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() { | 1218 IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { |
| 1358 FX_BOOL bShowHorz = | 1219 FX_BOOL bShowHorz = |
| 1359 m_pHorzScrollBar && | 1220 m_pHorzScrollBar && |
| 1360 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); | 1221 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); |
| 1361 FX_BOOL bShowVert = | 1222 FX_BOOL bShowVert = |
| 1362 m_pVertScrollBar && | 1223 m_pVertScrollBar && |
| 1363 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); | 1224 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); |
| 1364 if (!bShowHorz && !bShowVert) { | 1225 if (!bShowHorz && !bShowVert) { |
| 1365 return nullptr; | 1226 return nullptr; |
| 1366 } | 1227 } |
| 1367 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1228 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 m_pVertScrollBar->LockUpdate(); | 1291 m_pVertScrollBar->LockUpdate(); |
| 1431 m_pVertScrollBar->SetRange(0, -1); | 1292 m_pVertScrollBar->SetRange(0, -1); |
| 1432 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); | 1293 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); |
| 1433 m_pVertScrollBar->UnlockUpdate(); | 1294 m_pVertScrollBar->UnlockUpdate(); |
| 1434 m_pVertScrollBar->Update(); | 1295 m_pVertScrollBar->Update(); |
| 1435 pRepaint = m_pVertScrollBar.get(); | 1296 pRepaint = m_pVertScrollBar.get(); |
| 1436 } | 1297 } |
| 1437 } | 1298 } |
| 1438 return pRepaint; | 1299 return pRepaint; |
| 1439 } | 1300 } |
| 1440 FX_BOOL CFWL_EditImp::IsShowScrollBar(FX_BOOL bVert) { | 1301 FX_BOOL IFWL_Edit::IsShowScrollBar(FX_BOOL bVert) { |
| 1441 FX_BOOL bShow = | 1302 FX_BOOL bShow = |
| 1442 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) | 1303 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) |
| 1443 ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == | 1304 ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == |
| 1444 FWL_WGTSTATE_Focused | 1305 FWL_WGTSTATE_Focused |
| 1445 : TRUE; | 1306 : TRUE; |
| 1446 if (bVert) { | 1307 if (bVert) { |
| 1447 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && | 1308 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && |
| 1448 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && | 1309 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && |
| 1449 IsContentHeightOverflow(); | 1310 IsContentHeightOverflow(); |
| 1450 } | 1311 } |
| 1451 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && | 1312 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && |
| 1452 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); | 1313 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); |
| 1453 } | 1314 } |
| 1454 FX_BOOL CFWL_EditImp::IsContentHeightOverflow() { | 1315 FX_BOOL IFWL_Edit::IsContentHeightOverflow() { |
| 1455 if (!m_pEdtEngine) | 1316 if (!m_pEdtEngine) |
| 1456 return FALSE; | 1317 return FALSE; |
| 1457 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1318 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); |
| 1458 if (!pPage) | 1319 if (!pPage) |
| 1459 return FALSE; | 1320 return FALSE; |
| 1460 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; | 1321 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; |
| 1461 } | 1322 } |
| 1462 int32_t CFWL_EditImp::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { | 1323 int32_t IFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { |
| 1463 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); | 1324 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); |
| 1464 if (m_iCurRecord == nCount - 1) { | 1325 if (m_iCurRecord == nCount - 1) { |
| 1465 if (nCount == m_iMaxRecord) { | 1326 if (nCount == m_iMaxRecord) { |
| 1466 m_DoRecords.pop_front(); | 1327 m_DoRecords.pop_front(); |
| 1467 m_iCurRecord--; | 1328 m_iCurRecord--; |
| 1468 } | 1329 } |
| 1469 } else { | 1330 } else { |
| 1470 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1, | 1331 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1, |
| 1471 m_DoRecords.end()); | 1332 m_DoRecords.end()); |
| 1472 } | 1333 } |
| 1473 | 1334 |
| 1474 m_DoRecords.push_back(std::unique_ptr<IFDE_TxtEdtDoRecord>(pRecord)); | 1335 m_DoRecords.push_back(std::unique_ptr<IFDE_TxtEdtDoRecord>(pRecord)); |
| 1475 m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; | 1336 m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; |
| 1476 return m_iCurRecord; | 1337 return m_iCurRecord; |
| 1477 } | 1338 } |
| 1478 void CFWL_EditImp::Layout() { | 1339 void IFWL_Edit::Layout() { |
| 1479 GetClientRect(m_rtClient); | 1340 GetClientRect(m_rtClient); |
| 1480 m_rtEngine = m_rtClient; | 1341 m_rtEngine = m_rtClient; |
| 1481 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 1342 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 1482 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 1343 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 1483 if (!pfWidth) | 1344 if (!pfWidth) |
| 1484 return; | 1345 return; |
| 1485 FX_FLOAT fWidth = *pfWidth; | 1346 FX_FLOAT fWidth = *pfWidth; |
| 1486 if (!m_pOuter) { | 1347 if (!m_pOuter) { |
| 1487 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( | 1348 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( |
| 1488 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); | 1349 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 } | 1398 } |
| 1538 m_rtEngine.height -= fWidth; | 1399 m_rtEngine.height -= fWidth; |
| 1539 } | 1400 } |
| 1540 m_pHorzScrollBar->SetWidgetRect(rtHoriScr); | 1401 m_pHorzScrollBar->SetWidgetRect(rtHoriScr); |
| 1541 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); | 1402 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); |
| 1542 m_pHorzScrollBar->Update(); | 1403 m_pHorzScrollBar->Update(); |
| 1543 } else if (m_pHorzScrollBar) { | 1404 } else if (m_pHorzScrollBar) { |
| 1544 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); | 1405 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); |
| 1545 } | 1406 } |
| 1546 } | 1407 } |
| 1547 void CFWL_EditImp::LayoutScrollBar() { | 1408 void IFWL_Edit::LayoutScrollBar() { |
| 1548 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == | 1409 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == |
| 1549 0) { | 1410 0) { |
| 1550 return; | 1411 return; |
| 1551 } | 1412 } |
| 1552 FX_FLOAT* pfWidth = nullptr; | 1413 FX_FLOAT* pfWidth = nullptr; |
| 1553 FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); | 1414 FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); |
| 1554 FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); | 1415 FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); |
| 1555 if (bShowVertScrollbar) { | 1416 if (bShowVertScrollbar) { |
| 1556 if (!m_pVertScrollBar) { | 1417 if (!m_pVertScrollBar) { |
| 1557 pfWidth = static_cast<FX_FLOAT*>( | 1418 pfWidth = static_cast<FX_FLOAT*>( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 } | 1461 } |
| 1601 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); | 1462 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); |
| 1602 } else if (m_pHorzScrollBar) { | 1463 } else if (m_pHorzScrollBar) { |
| 1603 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); | 1464 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); |
| 1604 } | 1465 } |
| 1605 if (bShowVertScrollbar || bShowHorzScrollbar) { | 1466 if (bShowVertScrollbar || bShowHorzScrollbar) { |
| 1606 UpdateScroll(); | 1467 UpdateScroll(); |
| 1607 } | 1468 } |
| 1608 } | 1469 } |
| 1609 | 1470 |
| 1610 void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) { | 1471 void IFWL_Edit::DeviceToEngine(CFX_PointF& pt) { |
| 1611 pt.x += m_fScrollOffsetX - m_rtEngine.left; | 1472 pt.x += m_fScrollOffsetX - m_rtEngine.left; |
| 1612 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; | 1473 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; |
| 1613 } | 1474 } |
| 1614 | 1475 |
| 1615 void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { | 1476 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { |
| 1616 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 1477 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 1617 return; | 1478 return; |
| 1618 } | 1479 } |
| 1619 CFWL_WidgetImpProperties prop; | 1480 CFWL_WidgetImpProperties prop; |
| 1620 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 1481 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 1621 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; | 1482 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; |
| 1622 prop.m_pParent = m_pInterface; | 1483 prop.m_pParent = this; |
| 1623 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1484 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 1624 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); | 1485 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, this); |
| 1625 pScrollBar->Initialize(); | 1486 pScrollBar->Initialize(); |
| 1626 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 1487 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
| 1627 } | 1488 } |
| 1628 | 1489 |
| 1629 void CFWL_EditImp::InitEngine() { | 1490 void IFWL_Edit::InitEngine() { |
| 1630 if (!m_pEdtEngine) | 1491 if (!m_pEdtEngine) |
| 1631 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); | 1492 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); |
| 1632 } | 1493 } |
| 1633 | 1494 |
| 1634 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, | 1495 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, |
| 1635 FX_BOOL bVisible, | 1496 FX_BOOL bVisible, |
| 1636 const CFX_RectF* pRtAnchor) { | 1497 const CFX_RectF* pRtAnchor) { |
| 1637 CXFA_FFWidget* pXFAWidget = | 1498 CXFA_FFWidget* pXFAWidget = |
| 1638 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); | 1499 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); |
| 1639 if (!pXFAWidget) | 1500 if (!pXFAWidget) |
| 1640 return FALSE; | 1501 return FALSE; |
| 1641 | 1502 |
| 1642 IXFA_DocEnvironment* pDocEnvironment = | 1503 IXFA_DocEnvironment* pDocEnvironment = |
| 1643 pXFAWidget->GetDoc()->GetDocEnvironment(); | 1504 pXFAWidget->GetDoc()->GetDocEnvironment(); |
| 1644 if (!pDocEnvironment) | 1505 if (!pDocEnvironment) |
| 1645 return FALSE; | 1506 return FALSE; |
| 1646 | 1507 |
| 1647 if (bVisible) { | 1508 if (bVisible) { |
| 1648 CFX_Matrix mt; | 1509 CFX_Matrix mt; |
| 1649 pXFAWidget->GetRotateMatrix(mt); | 1510 pXFAWidget->GetRotateMatrix(mt); |
| 1650 CFX_RectF rt(*pRtAnchor); | 1511 CFX_RectF rt(*pRtAnchor); |
| 1651 mt.TransformRect(rt); | 1512 mt.TransformRect(rt); |
| 1652 pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, &rt); | 1513 pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, &rt); |
| 1653 return TRUE; | 1514 return TRUE; |
| 1654 } | 1515 } |
| 1655 pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, pRtAnchor); | 1516 pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, pRtAnchor); |
| 1656 return TRUE; | 1517 return TRUE; |
| 1657 } | 1518 } |
| 1658 | 1519 |
| 1659 void CFWL_EditImp::ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect) { | 1520 void IFWL_Edit::ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect) { |
| 1660 if (m_pCaret) { | 1521 if (m_pCaret) { |
| 1661 m_pCaret->ShowCaret(bVisible); | 1522 m_pCaret->ShowCaret(bVisible); |
| 1662 if (bVisible && !pRect->IsEmpty()) { | 1523 if (bVisible && !pRect->IsEmpty()) { |
| 1663 m_pCaret->SetWidgetRect(*pRect); | 1524 m_pCaret->SetWidgetRect(*pRect); |
| 1664 } | 1525 } |
| 1665 Repaint(&m_rtEngine); | 1526 Repaint(&m_rtEngine); |
| 1666 } else { | 1527 } else { |
| 1667 IFWL_Widget* pOuter = m_pInterface; | 1528 IFWL_Widget* pOuter = this; |
| 1668 if (bVisible) { | 1529 if (bVisible) { |
| 1669 pRect->Offset(m_pProperties->m_rtWidget.left, | 1530 pRect->Offset(m_pProperties->m_rtWidget.left, |
| 1670 m_pProperties->m_rtWidget.top); | 1531 m_pProperties->m_rtWidget.top); |
| 1671 } | 1532 } |
| 1672 while (pOuter->GetOuter()) { | 1533 while (pOuter->GetOuter()) { |
| 1673 pOuter = pOuter->GetOuter(); | 1534 pOuter = pOuter->GetOuter(); |
| 1674 if (bVisible) { | 1535 if (bVisible) { |
| 1675 CFX_RectF rtOuter; | 1536 CFX_RectF rtOuter; |
| 1676 pOuter->GetWidgetRect(rtOuter); | 1537 pOuter->GetWidgetRect(rtOuter); |
| 1677 pRect->Offset(rtOuter.left, rtOuter.top); | 1538 pRect->Offset(rtOuter.left, rtOuter.top); |
| 1678 } | 1539 } |
| 1679 } | 1540 } |
| 1680 FWL_ShowCaret(pOuter, bVisible, pRect); | 1541 FWL_ShowCaret(pOuter, bVisible, pRect); |
| 1681 } | 1542 } |
| 1682 } | 1543 } |
| 1683 FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum) { | 1544 FX_BOOL IFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { |
| 1684 if (!m_pEdtEngine) { | 1545 if (!m_pEdtEngine) { |
| 1685 return FALSE; | 1546 return FALSE; |
| 1686 } | 1547 } |
| 1687 if (!m_bSetRange) { | 1548 if (!m_bSetRange) { |
| 1688 return TRUE; | 1549 return TRUE; |
| 1689 } | 1550 } |
| 1690 CFX_WideString wsOld, wsText; | 1551 CFX_WideString wsOld, wsText; |
| 1691 m_pEdtEngine->GetText(wsText, 0); | 1552 m_pEdtEngine->GetText(wsText, 0); |
| 1692 if (wsText.IsEmpty()) { | 1553 if (wsText.IsEmpty()) { |
| 1693 if (cNum == L'0') { | 1554 if (cNum == L'0') { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1708 if (wsNew.GetInteger() <= m_iMax) { | 1569 if (wsNew.GetInteger() <= m_iMax) { |
| 1709 return TRUE; | 1570 return TRUE; |
| 1710 } | 1571 } |
| 1711 } else { | 1572 } else { |
| 1712 if (wsText.GetInteger() <= m_iMax) { | 1573 if (wsText.GetInteger() <= m_iMax) { |
| 1713 return TRUE; | 1574 return TRUE; |
| 1714 } | 1575 } |
| 1715 } | 1576 } |
| 1716 return FALSE; | 1577 return FALSE; |
| 1717 } | 1578 } |
| 1718 void CFWL_EditImp::InitCaret() { | 1579 void IFWL_Edit::InitCaret() { |
| 1719 if (!m_pCaret) { | 1580 if (!m_pCaret) { |
| 1720 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { | 1581 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { |
| 1721 CFWL_WidgetImpProperties prop; | 1582 CFWL_WidgetImpProperties prop; |
| 1722 m_pCaret.reset(IFWL_Caret::Create(prop, m_pInterface)); | 1583 m_pCaret.reset(IFWL_Caret::Create(prop, this)); |
| 1723 m_pCaret->Initialize(); | 1584 m_pCaret->Initialize(); |
| 1724 m_pCaret->SetParent(m_pInterface); | 1585 m_pCaret->SetParent(this); |
| 1725 m_pCaret->SetStates(m_pProperties->m_dwStates); | 1586 m_pCaret->SetStates(m_pProperties->m_dwStates); |
| 1726 } | 1587 } |
| 1727 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == | 1588 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == |
| 1728 0) { | 1589 0) { |
| 1729 m_pCaret.reset(); | 1590 m_pCaret.reset(); |
| 1730 } | 1591 } |
| 1731 } | 1592 } |
| 1732 | 1593 |
| 1733 void CFWL_EditImp::ClearRecord() { | 1594 void IFWL_Edit::ClearRecord() { |
| 1734 m_iCurRecord = -1; | 1595 m_iCurRecord = -1; |
| 1735 m_DoRecords.clear(); | 1596 m_DoRecords.clear(); |
| 1736 } | 1597 } |
| 1737 | 1598 |
| 1738 void CFWL_EditImp::ProcessInsertError(int32_t iError) { | 1599 void IFWL_Edit::ProcessInsertError(int32_t iError) { |
| 1739 switch (iError) { | 1600 switch (iError) { |
| 1740 case -2: { | 1601 case -2: { |
| 1741 CFWL_EvtEdtTextFull textFullEvent; | 1602 CFWL_EvtEdtTextFull textFullEvent; |
| 1742 textFullEvent.m_pSrcTarget = m_pInterface; | 1603 textFullEvent.m_pSrcTarget = this; |
| 1743 DispatchEvent(&textFullEvent); | 1604 DispatchEvent(&textFullEvent); |
| 1744 break; | 1605 break; |
| 1745 } | 1606 } |
| 1746 default: {} | 1607 default: {} |
| 1747 } | 1608 } |
| 1748 } | 1609 } |
| 1749 | 1610 |
| 1750 CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) | 1611 CFWL_EditImpDelegate::CFWL_EditImpDelegate(IFWL_Edit* pOwner) |
| 1751 : m_pOwner(pOwner) {} | 1612 : m_pOwner(pOwner) {} |
| 1752 | 1613 |
| 1753 void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 1614 void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 1754 if (!pMessage) | 1615 if (!pMessage) |
| 1755 return; | 1616 return; |
| 1756 | 1617 |
| 1757 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 1618 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 1758 switch (dwMsgCode) { | 1619 switch (dwMsgCode) { |
| 1759 case CFWL_MessageType::Activate: { | 1620 case CFWL_MessageType::Activate: { |
| 1760 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); | 1621 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 break; | 1659 break; |
| 1799 } | 1660 } |
| 1800 case CFWL_MessageType::Key: { | 1661 case CFWL_MessageType::Key: { |
| 1801 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1662 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 1802 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) | 1663 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 1803 OnKeyDown(pKey); | 1664 OnKeyDown(pKey); |
| 1804 else if (pKey->m_dwCmd == FWL_KeyCommand::Char) | 1665 else if (pKey->m_dwCmd == FWL_KeyCommand::Char) |
| 1805 OnChar(pKey); | 1666 OnChar(pKey); |
| 1806 break; | 1667 break; |
| 1807 } | 1668 } |
| 1808 default: { | 1669 default: { break; } |
| 1809 break; | |
| 1810 } | |
| 1811 } | 1670 } |
| 1812 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1671 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1813 } | 1672 } |
| 1814 | 1673 |
| 1815 void CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1674 void CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1816 if (!pEvent) | 1675 if (!pEvent) |
| 1817 return; | 1676 return; |
| 1818 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1677 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 1819 return; | 1678 return; |
| 1820 | 1679 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 } | 2044 } |
| 2186 CFX_RectF rect; | 2045 CFX_RectF rect; |
| 2187 m_pOwner->GetWidgetRect(rect); | 2046 m_pOwner->GetWidgetRect(rect); |
| 2188 CFX_RectF rtInvalidate; | 2047 CFX_RectF rtInvalidate; |
| 2189 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2048 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2190 m_pOwner->Repaint(&rtInvalidate); | 2049 m_pOwner->Repaint(&rtInvalidate); |
| 2191 } | 2050 } |
| 2192 return TRUE; | 2051 return TRUE; |
| 2193 } | 2052 } |
| 2194 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2053 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |