| 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 "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
| 8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
| 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" | 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" |
| 10 #include "../../include/pdfwindow/PWL_Edit.h" | 10 #include "../../include/pdfwindow/PWL_Edit.h" |
| 11 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 11 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
| 12 #include "../../include/pdfwindow/PWL_Utils.h" | 12 #include "../../include/pdfwindow/PWL_Utils.h" |
| 13 #include "../../include/pdfwindow/PWL_Caret.h" | 13 #include "../../include/pdfwindow/PWL_Caret.h" |
| 14 #include "../../include/pdfwindow/PWL_FontMap.h" | 14 #include "../../include/pdfwindow/PWL_FontMap.h" |
| 15 | 15 |
| 16 /* ---------------------------- CPWL_Edit ------------------------------ */ | 16 /* ---------------------------- CPWL_Edit ------------------------------ */ |
| 17 | 17 |
| 18 CPWL_Edit::CPWL_Edit() : m_pFillerNotify(NULL), | 18 CPWL_Edit::CPWL_Edit() |
| 19 m_pSpellCheck(NULL), | 19 : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { |
| 20 m_bFocus(FALSE) | 20 m_pFormFiller = NULL; |
| 21 { | 21 } |
| 22 m_pFormFiller = NULL; | 22 |
| 23 } | 23 CPWL_Edit::~CPWL_Edit() { |
| 24 | 24 ASSERT(m_bFocus == FALSE); |
| 25 CPWL_Edit::~CPWL_Edit() | 25 } |
| 26 { | 26 |
| 27 ASSERT(m_bFocus == FALSE); | 27 CFX_ByteString CPWL_Edit::GetClassName() const { |
| 28 } | 28 return PWL_CLASSNAME_EDIT; |
| 29 | 29 } |
| 30 CFX_ByteString CPWL_Edit::GetClassName() const | 30 |
| 31 { | 31 void CPWL_Edit::OnDestroy() { |
| 32 return PWL_CLASSNAME_EDIT; | 32 } |
| 33 } | 33 |
| 34 | 34 void CPWL_Edit::SetText(FX_LPCWSTR csText) { |
| 35 void CPWL_Edit::OnDestroy() | 35 CFX_WideString swText = csText; |
| 36 { | 36 |
| 37 } | 37 if (HasFlag(PES_RICH)) { |
| 38 | 38 CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); |
| 39 void CPWL_Edit::SetText(FX_LPCWSTR csText) | 39 |
| 40 { | 40 if (CXML_Element* pXML = |
| 41 CFX_WideString swText = csText; | 41 CXML_Element::Parse((FX_LPCSTR)sValue, sValue.GetLength())) { |
| 42 | 42 FX_INT32 nCount = pXML->CountChildren(); |
| 43 if (HasFlag(PES_RICH)) | 43 FX_BOOL bFirst = TRUE; |
| 44 { | 44 |
| 45 CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); | 45 swText.Empty(); |
| 46 | 46 |
| 47 if (CXML_Element * pXML = CXML_Element::Parse((FX_LPCSTR)sValue,
sValue.GetLength())) | 47 for (FX_INT32 i = 0; i < nCount; i++) { |
| 48 { | 48 if (CXML_Element* pSubElement = pXML->GetElement(i)) { |
| 49 FX_INT32 nCount = pXML->CountChildren(); | 49 CFX_ByteString tag = pSubElement->GetTagName(); |
| 50 FX_BOOL bFirst = TRUE; | 50 if (tag.EqualNoCase("p")) { |
| 51 | 51 int nChild = pSubElement->CountChildren(); |
| 52 swText.Empty(); | 52 CFX_WideString swSection; |
| 53 | 53 for (FX_INT32 j = 0; j < nChild; j++) { |
| 54 for (FX_INT32 i=0; i<nCount; i++) | 54 swSection += pSubElement->GetContent(j); |
| 55 { | 55 } |
| 56 if (CXML_Element * pSubElement = pXML->GetElemen
t(i)) | 56 |
| 57 { | 57 if (bFirst) |
| 58 CFX_ByteString tag=pSubElement->GetTagNa
me(); | 58 bFirst = FALSE; |
| 59 if (tag.EqualNoCase("p")) | 59 else |
| 60 { | 60 swText += FWL_VKEY_Return; |
| 61 int nChild = pSubElement->CountC
hildren(); | 61 swText += swSection; |
| 62 CFX_WideString swSection; | 62 } |
| 63 for(FX_INT32 j=0; j<nChild; j++) | 63 } |
| 64 { | 64 } |
| 65 swSection += pSubElement
->GetContent(j); | 65 |
| 66 } | 66 delete pXML; |
| 67 | 67 } |
| 68 if (bFirst)bFirst = FALSE; | 68 } |
| 69 else | 69 |
| 70 swText += FWL_VKEY_Retur
n; | 70 m_pEdit->SetText(swText); |
| 71 swText += swSection; | 71 } |
| 72 } | 72 |
| 73 } | 73 void CPWL_Edit::RePosChildWnd() { |
| 74 } | 74 if (CPWL_ScrollBar* pVSB = this->GetVScrollBar()) { |
| 75 | 75 // if (pVSB->IsVisible()) |
| 76 delete pXML; | 76 { |
| 77 } | 77 CPDF_Rect rcWindow = m_rcOldWindow; |
| 78 } | 78 CPDF_Rect rcVScroll = CPDF_Rect(rcWindow.right, |
| 79 | 79 rcWindow.bottom, |
| 80 m_pEdit->SetText(swText); | 80 rcWindow.right + PWL_SCROLLBAR_WIDTH, |
| 81 } | 81 rcWindow.top); |
| 82 | 82 pVSB->Move(rcVScroll, TRUE, FALSE); |
| 83 void CPWL_Edit::RePosChildWnd() | 83 } |
| 84 { | 84 } |
| 85 if (CPWL_ScrollBar * pVSB = this->GetVScrollBar()) | 85 |
| 86 { | 86 if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) |
| 87 //if (pVSB->IsVisible()) | 87 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
| 88 { | 88 GetClientRect(), 1.0f)); //+1 for caret beside border |
| 89 CPDF_Rect rcWindow = m_rcOldWindow; | 89 |
| 90 CPDF_Rect rcVScroll = CPDF_Rect(rcWindow.right, | 90 CPWL_EditCtrl::RePosChildWnd(); |
| 91 rcWindow.bottom, | 91 } |
| 92 rcWindow.right +
PWL_SCROLLBAR_WIDTH, | 92 |
| 93 rcWindow.top); | 93 CPDF_Rect CPWL_Edit::GetClientRect() const { |
| 94 pVSB->Move(rcVScroll, TRUE, FALSE); | 94 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
| 95 } | 95 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 96 } | 96 |
| 97 | 97 if (CPWL_ScrollBar* pVSB = this->GetVScrollBar()) { |
| 98 if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) | 98 if (pVSB->IsVisible()) { |
| 99 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(GetClientRect(
),1.0f)); //+1 for caret beside border | 99 rcClient.right -= PWL_SCROLLBAR_WIDTH; |
| 100 | 100 } |
| 101 CPWL_EditCtrl::RePosChildWnd(); | 101 } |
| 102 } | 102 |
| 103 | 103 return rcClient; |
| 104 CPDF_Rect CPWL_Edit::GetClientRect() const | 104 } |
| 105 { | 105 |
| 106 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(
GetBorderWidth()+GetInnerBorderWidth())); | 106 void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, |
| 107 | 107 FX_BOOL bPaint /* = TRUE*/) { |
| 108 if (CPWL_ScrollBar * pVSB = this->GetVScrollBar()) | 108 m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint); |
| 109 { | 109 } |
| 110 if (pVSB->IsVisible()) | 110 |
| 111 { | 111 void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, |
| 112 rcClient.right -= PWL_SCROLLBAR_WIDTH; | 112 FX_BOOL bPaint /* = TRUE*/) { |
| 113 } | 113 m_pEdit->SetAlignmentV((FX_INT32)nFormat, bPaint); |
| 114 } | 114 } |
| 115 | 115 |
| 116 return rcClient; | 116 FX_BOOL CPWL_Edit::CanSelectAll() const { |
| 117 } | 117 return GetSelectWordRange() != m_pEdit->GetWholeWordRange(); |
| 118 | 118 } |
| 119 void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/*
= TRUE*/) | 119 |
| 120 { | 120 FX_BOOL CPWL_Edit::CanClear() const { |
| 121 m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint); | 121 return !IsReadOnly() && m_pEdit->IsSelected(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/*
= TRUE*/) | 124 FX_BOOL CPWL_Edit::CanCopy() const { |
| 125 { | 125 return !HasFlag(PES_PASSWORD) && !HasFlag(PES_NOREAD) && |
| 126 m_pEdit->SetAlignmentV((FX_INT32)nFormat, bPaint); | 126 m_pEdit->IsSelected(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 FX_BOOL CPWL_Edit::CanSelectAll() const | 129 FX_BOOL CPWL_Edit::CanCut() const { |
| 130 { | 130 return CanCopy() && !IsReadOnly(); |
| 131 return GetSelectWordRange() != m_pEdit->GetWholeWordRange(); | 131 } |
| 132 } | 132 |
| 133 | 133 FX_BOOL CPWL_Edit::CanPaste() const { |
| 134 FX_BOOL CPWL_Edit::CanClear() const | 134 if (IsReadOnly()) |
| 135 { | 135 return FALSE; |
| 136 return !IsReadOnly() && m_pEdit->IsSelected(); | 136 |
| 137 } | 137 CFX_WideString swClipboard; |
| 138 | 138 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 139 FX_BOOL CPWL_Edit::CanCopy() const | 139 swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); |
| 140 { | 140 |
| 141 return !HasFlag(PES_PASSWORD) && !HasFlag(PES_NOREAD) && m_pEdit->IsSel
ected(); | 141 return !swClipboard.IsEmpty(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 FX_BOOL CPWL_Edit::CanCut() const | 144 void CPWL_Edit::CopyText() { |
| 145 { | 145 if (!CanCopy()) |
| 146 return CanCopy() && !IsReadOnly(); | 146 return; |
| 147 } | 147 |
| 148 | 148 CFX_WideString str = m_pEdit->GetSelText(); |
| 149 FX_BOOL CPWL_Edit::CanPaste() const | 149 |
| 150 { | 150 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 151 if (IsReadOnly()) return FALSE; | 151 pSH->SetClipboardText(GetAttachedHWnd(), str); |
| 152 | 152 } |
| 153 CFX_WideString swClipboard; | 153 |
| 154 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 154 void CPWL_Edit::PasteText() { |
| 155 swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); | 155 if (!CanPaste()) |
| 156 | 156 return; |
| 157 return !swClipboard.IsEmpty(); | 157 |
| 158 } | 158 CFX_WideString swClipboard; |
| 159 | 159 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 160 void CPWL_Edit::CopyText() | 160 swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); |
| 161 { | 161 |
| 162 if (!CanCopy()) return; | 162 if (m_pFillerNotify) { |
| 163 | 163 FX_BOOL bRC = TRUE; |
| 164 CFX_WideString str = m_pEdit->GetSelText(); | 164 FX_BOOL bExit = FALSE; |
| 165 | 165 CFX_WideString strChangeEx; |
| 166 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 166 int nSelStart = 0; |
| 167 pSH->SetClipboardText(GetAttachedHWnd(), str); | 167 int nSelEnd = 0; |
| 168 } | 168 GetSel(nSelStart, nSelEnd); |
| 169 | 169 m_pFillerNotify->OnBeforeKeyStroke(TRUE, |
| 170 void CPWL_Edit::PasteText() | 170 GetAttachedData(), |
| 171 { | 171 0, |
| 172 if (!CanPaste()) return; | 172 swClipboard, |
| 173 | 173 strChangeEx, |
| 174 CFX_WideString swClipboard; | 174 nSelStart, |
| 175 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 175 nSelEnd, |
| 176 swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); | 176 TRUE, |
| 177 | 177 bRC, |
| 178 if (m_pFillerNotify) | 178 bExit, |
| 179 { | 179 0); |
| 180 FX_BOOL bRC = TRUE; | 180 if (!bRC) |
| 181 FX_BOOL bExit = FALSE; | 181 return; |
| 182 CFX_WideString strChangeEx; | 182 if (bExit) |
| 183 int nSelStart = 0; | 183 return; |
| 184 int nSelEnd = 0; | 184 } |
| 185 GetSel(nSelStart, nSelEnd); | 185 |
| 186 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), 0 ,
swClipboard, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, 0); | 186 if (swClipboard.GetLength() > 0) { |
| 187 if (!bRC) return; | 187 Clear(); |
| 188 if (bExit) return; | 188 InsertText(swClipboard); |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (swClipboard.GetLength() > 0) | 191 if (m_pFillerNotify) { |
| 192 { | 192 FX_BOOL bExit = FALSE; |
| 193 Clear(); | 193 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit, 0); |
| 194 InsertText(swClipboard); | 194 if (bExit) |
| 195 } | 195 return; |
| 196 | 196 } |
| 197 if (m_pFillerNotify) | 197 } |
| 198 { | 198 |
| 199 FX_BOOL bExit = FALSE; | 199 void CPWL_Edit::CutText() { |
| 200 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit
,0); | 200 if (!CanCut()) |
| 201 if (bExit) return; | 201 return; |
| 202 } | 202 |
| 203 } | 203 CFX_WideString str = m_pEdit->GetSelText(); |
| 204 | 204 |
| 205 void CPWL_Edit::CutText() | 205 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 206 { | 206 pSH->SetClipboardText(GetAttachedHWnd(), str); |
| 207 if (!CanCut()) return; | 207 |
| 208 | 208 m_pEdit->Clear(); |
| 209 CFX_WideString str = m_pEdit->GetSelText(); | 209 } |
| 210 | 210 |
| 211 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 211 void CPWL_Edit::OnCreated() { |
| 212 pSH->SetClipboardText(GetAttachedHWnd(), str); | 212 CPWL_EditCtrl::OnCreated(); |
| 213 | 213 |
| 214 m_pEdit->Clear(); | 214 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 215 } | 215 pScroll->RemoveFlag(PWS_AUTOTRANSPARENT); |
| 216 | 216 pScroll->SetTransparency(255); |
| 217 void CPWL_Edit::OnCreated() | 217 } |
| 218 { | 218 |
| 219 CPWL_EditCtrl::OnCreated(); | 219 SetParamByFlag(); |
| 220 | 220 |
| 221 if (CPWL_ScrollBar * pScroll = GetVScrollBar()) | 221 m_rcOldWindow = GetWindowRect(); |
| 222 { | 222 |
| 223 pScroll->RemoveFlag(PWS_AUTOTRANSPARENT); | 223 m_pEdit->SetOprNotify(this); |
| 224 pScroll->SetTransparency(255); | 224 m_pEdit->EnableOprNotify(TRUE); |
| 225 } | 225 } |
| 226 | 226 |
| 227 SetParamByFlag(); | 227 void CPWL_Edit::SetParamByFlag() { |
| 228 | 228 if (HasFlag(PES_RIGHT)) { |
| 229 m_rcOldWindow = GetWindowRect(); | 229 m_pEdit->SetAlignmentH(2, FALSE); |
| 230 | 230 } else if (HasFlag(PES_MIDDLE)) { |
| 231 m_pEdit->SetOprNotify(this); | 231 m_pEdit->SetAlignmentH(1, FALSE); |
| 232 m_pEdit->EnableOprNotify(TRUE); | 232 } else { |
| 233 } | 233 m_pEdit->SetAlignmentH(0, FALSE); |
| 234 | 234 } |
| 235 void CPWL_Edit::SetParamByFlag() | 235 |
| 236 { | 236 if (HasFlag(PES_BOTTOM)) { |
| 237 if (HasFlag(PES_RIGHT)) | 237 m_pEdit->SetAlignmentV(2, FALSE); |
| 238 { | 238 } else if (HasFlag(PES_CENTER)) { |
| 239 m_pEdit->SetAlignmentH(2, FALSE); | 239 m_pEdit->SetAlignmentV(1, FALSE); |
| 240 } | 240 } else { |
| 241 else if (HasFlag(PES_MIDDLE)) | 241 m_pEdit->SetAlignmentV(0, FALSE); |
| 242 { | 242 } |
| 243 m_pEdit->SetAlignmentH(1, FALSE); | 243 |
| 244 } | 244 if (HasFlag(PES_PASSWORD)) { |
| 245 else | 245 m_pEdit->SetPasswordChar('*', FALSE); |
| 246 { | 246 } |
| 247 m_pEdit->SetAlignmentH(0, FALSE); | 247 |
| 248 } | 248 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE); |
| 249 | 249 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE); |
| 250 if (HasFlag(PES_BOTTOM)) | 250 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE); |
| 251 { | 251 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE); |
| 252 m_pEdit->SetAlignmentV(2, FALSE); | 252 m_pEdit->EnableUndo(HasFlag(PES_UNDO)); |
| 253 } | 253 |
| 254 else if (HasFlag(PES_CENTER)) | 254 if (HasFlag(PES_TEXTOVERFLOW)) { |
| 255 { | 255 SetClipRect(CPDF_Rect(0.0f, 0.0f, 0.0f, 0.0f)); |
| 256 m_pEdit->SetAlignmentV(1, FALSE); | 256 m_pEdit->SetTextOverflow(TRUE, FALSE); |
| 257 } | 257 } else { |
| 258 else | 258 if (m_pEditCaret) { |
| 259 { | 259 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
| 260 m_pEdit->SetAlignmentV(0, FALSE); | 260 GetClientRect(), 1.0f)); //+1 for caret beside border |
| 261 } | 261 } |
| 262 | 262 } |
| 263 if (HasFlag(PES_PASSWORD)) | 263 |
| 264 { | 264 if (HasFlag(PES_SPELLCHECK)) { |
| 265 m_pEdit->SetPasswordChar('*', FALSE); | 265 m_pSpellCheck = GetCreationParam().pSpellCheck; |
| 266 } | 266 } |
| 267 | 267 } |
| 268 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE); | 268 |
| 269 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE); | 269 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 270 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE); | 270 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 271 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE); | 271 |
| 272 m_pEdit->EnableUndo(HasFlag(PES_UNDO)); | 272 CPDF_Rect rcClient = GetClientRect(); |
| 273 | 273 CFX_ByteTextBuf sLine; |
| 274 if (HasFlag(PES_TEXTOVERFLOW)) | 274 |
| 275 { | 275 FX_INT32 nCharArray = m_pEdit->GetCharArray(); |
| 276 SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f)); | 276 |
| 277 m_pEdit->SetTextOverflow(TRUE, FALSE); | 277 if (nCharArray > 0) { |
| 278 } | 278 switch (GetBorderStyle()) { |
| 279 else | 279 case PBS_SOLID: { |
| 280 { | 280 sLine << "q\n" << GetBorderWidth() << " w\n" |
| 281 if (m_pEditCaret) | 281 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 282 { | 282 << " 2 J 0 j\n"; |
| 283 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(GetCli
entRect(),1.0f)); //+1 for caret beside border | 283 |
| 284 } | 284 for (FX_INT32 i = 1; i < nCharArray; i++) { |
| 285 } | 285 sLine << rcClient.left + |
| 286 | 286 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 287 if (HasFlag(PES_SPELLCHECK)) | 287 << " " << rcClient.bottom << " m\n" |
| 288 { | 288 << rcClient.left + |
| 289 m_pSpellCheck = GetCreationParam().pSpellCheck; | 289 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 290 } | 290 << " " << rcClient.top << " l S\n"; |
| 291 } | 291 } |
| 292 | 292 |
| 293 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) | 293 sLine << "Q\n"; |
| 294 { | 294 } break; |
| 295 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 295 case PBS_DASH: { |
| 296 | 296 sLine << "q\n" << GetBorderWidth() << " w\n" |
| 297 CPDF_Rect rcClient = GetClientRect(); | 297 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 298 CFX_ByteTextBuf sLine; | 298 << " 2 J 0 j\n" |
| 299 | 299 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap |
| 300 FX_INT32 nCharArray = m_pEdit->GetCharArray(); | 300 << "] " << GetBorderDash().nPhase << " d\n"; |
| 301 | 301 |
| 302 if (nCharArray > 0) | 302 for (FX_INT32 i = 1; i < nCharArray; i++) { |
| 303 { | 303 sLine << rcClient.left + |
| 304 switch (GetBorderStyle()) | 304 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 305 { | 305 << " " << rcClient.bottom << " m\n" |
| 306 case PBS_SOLID: | 306 << rcClient.left + |
| 307 { | 307 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 308 sLine << "q\n" << GetBorderWidth() << " w\n" | 308 << " " << rcClient.top << " l S\n"; |
| 309 << CPWL_Utils::GetColorAppStream(GetBord
erColor(),FALSE) << " 2 J 0 j\n"; | 309 } |
| 310 | 310 |
| 311 for (FX_INT32 i=1;i<nCharArray;i++) | 311 sLine << "Q\n"; |
| 312 { | 312 } break; |
| 313 sLine << rcClient.left + ((rcClient.righ
t - rcClient.left)/nCharArray)*i << " " | 313 } |
| 314 << rcClient.bottom << " m\n" | 314 } |
| 315 << rcClient.left + ((rcClient.ri
ght - rcClient.left)/nCharArray)*i << " " | 315 |
| 316 << rcClient.top << " l S\n";
| 316 sAppStream << sLine; |
| 317 } | 317 |
| 318 | 318 CFX_ByteTextBuf sText; |
| 319 sLine << "Q\n"; | 319 |
| 320 } | 320 CPDF_Point ptOffset = CPDF_Point(0.0f, 0.0f); |
| 321 break; | 321 |
| 322 case PBS_DASH: | 322 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); |
| 323 { | 323 CPVT_WordRange wrSelect = GetSelectWordRange(); |
| 324 sLine << "q\n" << GetBorderWidth() << " w\n" | 324 CPVT_WordRange wrVisible = |
| 325 << CPWL_Utils::GetColorAppStream(GetBord
erColor(),FALSE) << " 2 J 0 j\n" | 325 (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); |
| 326 << "[" << GetBorderDash().nDash << " " | 326 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); |
| 327 << GetBorderDash().nGap << "] " | 327 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); |
| 328 << GetBorderDash().nPhase << " d\n"; | 328 |
| 329 | 329 CPVT_WordRange wrTemp = |
| 330 for (FX_INT32 i=1;i<nCharArray;i++)
| 330 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); |
| 331 { | 331 CFX_ByteString sEditSel = |
| 332 sLine << rcClient.left + ((rcClient.righ
t - rcClient.left)/nCharArray)*i << " " | 332 CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); |
| 333 << rcClient.bottom << " m\n" | 333 |
| 334 << rcClient.left + ((rcClient.ri
ght - rcClient.left)/nCharArray)*i << " " | 334 if (sEditSel.GetLength() > 0) |
| 335 << rcClient.top << " l S\n"; | 335 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) |
| 336 } | 336 << sEditSel; |
| 337 | 337 |
| 338 sLine << "Q\n"; | 338 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); |
| 339 } | 339 CFX_ByteString sEditBefore = |
| 340 break; | 340 CPWL_Utils::GetEditAppStream(m_pEdit, |
| 341 } | 341 ptOffset, |
| 342 } | 342 &wrTemp, |
| 343 | 343 !HasFlag(PES_CHARARRAY), |
| 344 sAppStream << sLine; | 344 m_pEdit->GetPasswordChar()); |
| 345 | 345 |
| 346 CFX_ByteTextBuf sText; | 346 if (sEditBefore.GetLength() > 0) |
| 347 | 347 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) |
| 348 CPDF_Point ptOffset = CPDF_Point(0.0f,0.0f); | 348 << sEditBefore << "ET\n"; |
| 349 | 349 |
| 350 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); | 350 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); |
| 351 CPVT_WordRange wrSelect = GetSelectWordRange(); | 351 CFX_ByteString sEditMid = |
| 352 CPVT_WordRange wrVisible = (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdi
t->GetVisibleWordRange()); | 352 CPWL_Utils::GetEditAppStream(m_pEdit, |
| 353 CPVT_WordRange wrSelBefore(wrWhole.BeginPos,wrSelect.BeginPos); | 353 ptOffset, |
| 354 CPVT_WordRange wrSelAfter(wrSelect.EndPos,wrWhole.EndPos); | 354 &wrTemp, |
| 355 | 355 !HasFlag(PES_CHARARRAY), |
| 356 CPVT_WordRange wrTemp = CPWL_Utils::OverlapWordRange(GetSelectWordRange(
),wrVisible); | 356 m_pEdit->GetPasswordChar()); |
| 357 CFX_ByteString sEditSel = CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOff
set, | 357 |
| 358 &wrTemp); | 358 if (sEditMid.GetLength() > 0) |
| 359 | 359 sText << "BT\n" |
| 360 if (sEditSel.GetLength() > 0) | 360 << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) |
| 361 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR)
<< sEditSel ; | 361 << sEditMid << "ET\n"; |
| 362 | 362 |
| 363 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelBefore); | 363 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); |
| 364 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(m_pEdit, ptOff
set, | 364 CFX_ByteString sEditAfter = |
| 365 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordCh
ar()); | 365 CPWL_Utils::GetEditAppStream(m_pEdit, |
| 366 | 366 ptOffset, |
| 367 if (sEditBefore.GetLength() > 0) | 367 &wrTemp, |
| 368 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
<< sEditBefore << "ET\n"; | 368 !HasFlag(PES_CHARARRAY), |
| 369 | 369 m_pEdit->GetPasswordChar()); |
| 370 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelect); | 370 |
| 371 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset
, | 371 if (sEditAfter.GetLength() > 0) |
| 372 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordCh
ar()); | 372 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) |
| 373 | 373 << sEditAfter << "ET\n"; |
| 374 if (sEditMid.GetLength() > 0) | 374 |
| 375 sText << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLO
RTYPE_GRAY,1)) << sEditMid << "ET\n"; | 375 if (HasFlag(PES_SPELLCHECK)) { |
| 376 | 376 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( |
| 377 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelAfter); | 377 m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); |
| 378 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffs
et, | 378 if (sSpellCheck.GetLength() > 0) |
| 379 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordCh
ar()); | 379 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), |
| 380 | 380 FALSE) << sSpellCheck; |
| 381 if (sEditAfter.GetLength() > 0) | 381 } |
| 382 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
<< sEditAfter<< "ET\n"; | 382 |
| 383 | 383 if (sText.GetLength() > 0) { |
| 384 if (HasFlag(PES_SPELLCHECK)) | 384 CPDF_Rect rcClient = this->GetClientRect(); |
| 385 { | 385 sAppStream << "q\n/Tx BMC\n"; |
| 386 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream(
m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); | 386 |
| 387 if (sSpellCheck.GetLength() > 0) | 387 if (!HasFlag(PES_TEXTOVERFLOW)) |
| 388 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORT
YPE_RGB,1,0,0),FALSE) << sSpellCheck; | 388 sAppStream << rcClient.left << " " << rcClient.bottom << " " |
| 389 } | 389 << rcClient.right - rcClient.left << " " |
| 390 | 390 << rcClient.top - rcClient.bottom << " re W n\n"; |
| 391 if (sText.GetLength() > 0) | 391 |
| 392 { | 392 sAppStream << sText; |
| 393 CPDF_Rect rcClient = this->GetClientRect(); | 393 |
| 394 sAppStream << "q\n/Tx BMC\n"; | 394 sAppStream << "EMC\nQ\n"; |
| 395 | 395 } |
| 396 if (!HasFlag(PES_TEXTOVERFLOW)) | 396 } |
| 397 sAppStream << rcClient.left << " " << rcClient.bottom <<
" " | 397 |
| 398 << rcClient.right - rcClient.left << " " << rcCl
ient.top - rcClient.bottom << " re W n\n"; | 398 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 399 | 399 CPDF_Matrix* pUser2Device) { |
| 400 sAppStream << sText; | 400 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 401 | 401 |
| 402 sAppStream << "EMC\nQ\n"; | 402 CPDF_Rect rcClient = GetClientRect(); |
| 403 } | 403 CFX_ByteTextBuf sLine; |
| 404 } | 404 |
| 405 | 405 FX_INT32 nCharArray = m_pEdit->GetCharArray(); |
| 406 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
2Device) | 406 |
| 407 { | 407 if (nCharArray > 0) { |
| 408 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); | 408 switch (GetBorderStyle()) { |
| 409 | 409 case PBS_SOLID: { |
| 410 CPDF_Rect rcClient = GetClientRect(); | 410 CFX_GraphStateData gsd; |
| 411 CFX_ByteTextBuf sLine; | 411 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 412 | 412 |
| 413 FX_INT32 nCharArray = m_pEdit->GetCharArray(); | 413 CFX_PathData path; |
| 414 | 414 path.SetPointCount((nCharArray - 1) * 2); |
| 415 if (nCharArray > 0) | 415 |
| 416 { | 416 for (FX_INT32 i = 0; i < nCharArray - 1; i++) { |
| 417 switch (GetBorderStyle()) | 417 path.SetPoint( |
| 418 { | 418 i * 2, |
| 419 case PBS_SOLID: | 419 rcClient.left + |
| 420 { | 420 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 421 CFX_GraphStateData gsd; | 421 rcClient.bottom, |
| 422 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 422 FXPT_MOVETO); |
| 423 | 423 path.SetPoint( |
| 424 CFX_PathData path; | 424 i * 2 + 1, |
| 425 path.SetPointCount((nCharArray-1)*2); | 425 rcClient.left + |
| 426 | 426 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 427 for (FX_INT32 i=0; i<nCharArray-1; i++) | 427 rcClient.top, |
| 428 { | 428 FXPT_LINETO); |
| 429 path.SetPoint(i*2, rcClient.left + ((rcC
lient.right - rcClient.left)/nCharArray)*(i+1), | 429 } |
| 430 rcClient.bottom, FXPT_MOVETO); | 430 if (path.GetPointCount() > 0) |
| 431 path.SetPoint(i*2+1, rcClient.left + ((r
cClient.right - rcClient.left)/nCharArray)*(i+1), | 431 pDevice->DrawPath( |
| 432 rcClient.top, FXPT_LINETO);
| 432 &path, |
| 433 } | 433 pUser2Device, |
| 434 if (path.GetPointCount() > 0) | 434 &gsd, |
| 435 pDevice->DrawPath(&path, pUser2Device, &
gsd,0, | 435 0, |
| 436 CPWL_Utils::PWLColorToFXColor(Ge
tBorderColor(),255), FXFILL_ALTERNATE); | 436 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 437 } | 437 FXFILL_ALTERNATE); |
| 438 break; | 438 } break; |
| 439 case PBS_DASH: | 439 case PBS_DASH: { |
| 440 { | 440 CFX_GraphStateData gsd; |
| 441 CFX_GraphStateData gsd; | 441 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 442 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 442 |
| 443 | 443 gsd.SetDashCount(2); |
| 444 gsd.SetDashCount(2); | 444 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; |
| 445 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().n
Dash; | 445 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; |
| 446 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().n
Gap; | 446 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; |
| 447 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPha
se; | 447 |
| 448 | 448 CFX_PathData path; |
| 449 CFX_PathData path; | 449 path.SetPointCount((nCharArray - 1) * 2); |
| 450 path.SetPointCount((nCharArray-1)*2); | 450 |
| 451 | 451 for (FX_INT32 i = 0; i < nCharArray - 1; i++) { |
| 452 for (FX_INT32 i=0; i<nCharArray-1; i++) | 452 path.SetPoint( |
| 453 { | 453 i * 2, |
| 454 path.SetPoint(i*2, rcClient.left + ((rcC
lient.right - rcClient.left)/nCharArray)*(i+1), | 454 rcClient.left + |
| 455 rcClient.bottom, FXPT_MOVETO); | 455 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 456 path.SetPoint(i*2+1, rcClient.left + ((r
cClient.right - rcClient.left)/nCharArray)*(i+1), | 456 rcClient.bottom, |
| 457 rcClient.top, FXPT_LINETO);
| 457 FXPT_MOVETO); |
| 458 } | 458 path.SetPoint( |
| 459 if (path.GetPointCount() > 0) | 459 i * 2 + 1, |
| 460 pDevice->DrawPath(&path, pUser2Device, &
gsd,0, | 460 rcClient.left + |
| 461 CPWL_Utils::PWLColorToFXColor(Ge
tBorderColor(),255), FXFILL_ALTERNATE); | 461 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 462 } | 462 rcClient.top, |
| 463 break; | 463 FXPT_LINETO); |
| 464 } | 464 } |
| 465 } | 465 if (path.GetPointCount() > 0) |
| 466 | 466 pDevice->DrawPath( |
| 467 CPDF_Rect rcClip; | 467 &path, |
| 468 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); | 468 pUser2Device, |
| 469 CPVT_WordRange* pRange = NULL; | 469 &gsd, |
| 470 | 470 0, |
| 471 if (!HasFlag(PES_TEXTOVERFLOW)) | 471 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 472 { | 472 FXFILL_ALTERNATE); |
| 473 rcClip = GetClientRect(); | 473 } break; |
| 474 pRange = &wrRange; | 474 } |
| 475 } | 475 } |
| 476 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 476 |
| 477 IFX_Edit::DrawEdit(pDevice,pUser2Device,m_pEdit, | 477 CPDF_Rect rcClip; |
| 478 CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTransparen
cy()), | 478 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); |
| 479 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(),this->GetTran
sparency()), | 479 CPVT_WordRange* pRange = NULL; |
| 480 rcClip,CPDF_Point(0.0f,0.0f),pRange, pSysHandler, m_pFormFiller)
; | 480 |
| 481 | 481 if (!HasFlag(PES_TEXTOVERFLOW)) { |
| 482 if (HasFlag(PES_SPELLCHECK)) | 482 rcClip = GetClientRect(); |
| 483 { | 483 pRange = &wrRange; |
| 484 CPWL_Utils::DrawEditSpellCheck(pDevice,pUser2Device,m_pEdit,rcCl
ip, | 484 } |
| 485 CPDF_Point(0.0f,0.0f),pRange, this->GetCreationParam().p
SpellCheck); | 485 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
| 486 } | 486 IFX_Edit::DrawEdit( |
| 487 } | 487 pDevice, |
| 488 | 488 pUser2Device, |
| 489 FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) | 489 m_pEdit, |
| 490 { | 490 CPWL_Utils::PWLColorToFXColor(GetTextColor(), this->GetTransparency()), |
| 491 CPWL_Wnd::OnLButtonDown(point,nFlag); | 491 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), |
| 492 | 492 this->GetTransparency()), |
| 493 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) | 493 rcClip, |
| 494 { | 494 CPDF_Point(0.0f, 0.0f), |
| 495 if (m_bMouseDown) | 495 pRange, |
| 496 this->InvalidateRect(); | 496 pSysHandler, |
| 497 | 497 m_pFormFiller); |
| 498 m_bMouseDown = TRUE; | 498 |
| 499 SetCapture(); | 499 if (HasFlag(PES_SPELLCHECK)) { |
| 500 | 500 CPWL_Utils::DrawEditSpellCheck(pDevice, |
| 501 m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(n
Flag)); | 501 pUser2Device, |
| 502 } | 502 m_pEdit, |
| 503 | 503 rcClip, |
| 504 return TRUE; | 504 CPDF_Point(0.0f, 0.0f), |
| 505 } | 505 pRange, |
| 506 | 506 this->GetCreationParam().pSpellCheck); |
| 507 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag) | 507 } |
| 508 { | 508 } |
| 509 CPWL_Wnd::OnLButtonDblClk(point, nFlag); | 509 |
| 510 | 510 FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
| 511 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) | 511 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 512 { | 512 |
| 513 m_pEdit->SelectAll(); | 513 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 514 } | 514 if (m_bMouseDown) |
| 515 | 515 this->InvalidateRect(); |
| 516 return TRUE; | 516 |
| 517 } | 517 m_bMouseDown = TRUE; |
| 518 | 518 SetCapture(); |
| 519 #define WM_PWLEDIT_UNDO 0x01 | 519 |
| 520 #define WM_PWLEDIT_REDO 0x02 | 520 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 521 #define WM_PWLEDIT_CUT 0x03 | 521 } |
| 522 #define WM_PWLEDIT_COPY 0x04 | 522 |
| 523 #define WM_PWLEDIT_PASTE 0x05 | 523 return TRUE; |
| 524 #define WM_PWLEDIT_DELETE 0x06 | 524 } |
| 525 #define WM_PWLEDIT_SELECTALL 0x07 | 525 |
| 526 #define WM_PWLEDIT_SUGGEST 0x08 | 526 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point& point, FX_DWORD nFlag) { |
| 527 | 527 CPWL_Wnd::OnLButtonDblClk(point, nFlag); |
| 528 FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | 528 |
| 529 { | 529 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 530 if (m_bMouseDown) return FALSE; | 530 m_pEdit->SelectAll(); |
| 531 | 531 } |
| 532 CPWL_Wnd::OnRButtonUp(point, nFlag); | 532 |
| 533 | 533 return TRUE; |
| 534 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) return TRUE; | 534 } |
| 535 | 535 |
| 536 IFX_SystemHandler* pSH = GetSystemHandler(); | 536 #define WM_PWLEDIT_UNDO 0x01 |
| 537 if (!pSH) return FALSE; | 537 #define WM_PWLEDIT_REDO 0x02 |
| 538 | 538 #define WM_PWLEDIT_CUT 0x03 |
| 539 this->SetFocus(); | 539 #define WM_PWLEDIT_COPY 0x04 |
| 540 | 540 #define WM_PWLEDIT_PASTE 0x05 |
| 541 CPVT_WordRange wrLatin = GetLatinWordsRange(point); | 541 #define WM_PWLEDIT_DELETE 0x06 |
| 542 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); | 542 #define WM_PWLEDIT_SELECTALL 0x07 |
| 543 | 543 #define WM_PWLEDIT_SUGGEST 0x08 |
| 544 FX_HMENU hPopup = pSH->CreatePopupMenu(); | 544 |
| 545 if (!hPopup) return FALSE; | 545 FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 546 | 546 if (m_bMouseDown) |
| 547 CFX_ByteStringArray sSuggestWords; | 547 return FALSE; |
| 548 CPDF_Point ptPopup = point; | 548 |
| 549 | 549 CPWL_Wnd::OnRButtonUp(point, nFlag); |
| 550 if (!IsReadOnly()) | 550 |
| 551 { | 551 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) |
| 552 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) | 552 return TRUE; |
| 553 { | 553 |
| 554 if (m_pSpellCheck) | 554 IFX_SystemHandler* pSH = GetSystemHandler(); |
| 555 { | 555 if (!pSH) |
| 556 CFX_ByteString sLatin = CFX_ByteString::FromUnic
ode(swLatin); | 556 return FALSE; |
| 557 | 557 |
| 558 if (!m_pSpellCheck->CheckWord(sLatin)) | 558 this->SetFocus(); |
| 559 { | 559 |
| 560 m_pSpellCheck->SuggestWords(sLatin,sSugg
estWords); | 560 CPVT_WordRange wrLatin = GetLatinWordsRange(point); |
| 561 | 561 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); |
| 562 FX_INT32 nSuggest = sSuggestWords.GetSiz
e(); | 562 |
| 563 | 563 FX_HMENU hPopup = pSH->CreatePopupMenu(); |
| 564 for (FX_INT32 nWord=0; nWord<nSuggest; n
Word++) | 564 if (!hPopup) |
| 565 { | 565 return FALSE; |
| 566 pSH->AppendMenuItem(hPopup, WM_P
WLEDIT_SUGGEST+nWord, sSuggestWords[nWord].UTF8Decode()); | 566 |
| 567 } | 567 CFX_ByteStringArray sSuggestWords; |
| 568 | 568 CPDF_Point ptPopup = point; |
| 569 if (nSuggest > 0) | 569 |
| 570 pSH->AppendMenuItem(hPopup, 0, L
""); | 570 if (!IsReadOnly()) { |
| 571 | 571 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { |
| 572 ptPopup = GetWordRightBottomPoint(wrLati
n.EndPos); | 572 if (m_pSpellCheck) { |
| 573 } | 573 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); |
| 574 } | 574 |
| 575 } | 575 if (!m_pSpellCheck->CheckWord(sLatin)) { |
| 576 } | 576 m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); |
| 577 | 577 |
| 578 IPWL_Provider* pProvider = this->GetProvider(); | 578 FX_INT32 nSuggest = sSuggestWords.GetSize(); |
| 579 | 579 |
| 580 if (HasFlag(PES_UNDO)) | 580 for (FX_INT32 nWord = 0; nWord < nSuggest; nWord++) { |
| 581 { | 581 pSH->AppendMenuItem(hPopup, |
| 582 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_UNDO, | 582 WM_PWLEDIT_SUGGEST + nWord, |
| 583 pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo"
); | 583 sSuggestWords[nWord].UTF8Decode()); |
| 584 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_REDO, | 584 } |
| 585 pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo"
); | 585 |
| 586 pSH->AppendMenuItem(hPopup, 0, L""); | 586 if (nSuggest > 0) |
| 587 | 587 pSH->AppendMenuItem(hPopup, 0, L""); |
| 588 if (!m_pEdit->CanUndo()) | 588 |
| 589 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE); | 589 ptPopup = GetWordRightBottomPoint(wrLatin.EndPos); |
| 590 if (!m_pEdit->CanRedo()) | 590 } |
| 591 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE); | 591 } |
| 592 } | 592 } |
| 593 | 593 } |
| 594 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT, | 594 |
| 595 pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t"); | 595 IPWL_Provider* pProvider = this->GetProvider(); |
| 596 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY, | 596 |
| 597 pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy"); | 597 if (HasFlag(PES_UNDO)) { |
| 598 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_PASTE, | 598 pSH->AppendMenuItem( |
| 599 pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste"); | 599 hPopup, |
| 600 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_DELETE, | 600 WM_PWLEDIT_UNDO, |
| 601 pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete"); | 601 pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo"); |
| 602 | 602 pSH->AppendMenuItem( |
| 603 CFX_WideString swText = pSH->GetClipboardText(this->GetAttachedHWnd()); | 603 hPopup, |
| 604 if (swText.IsEmpty()) | 604 WM_PWLEDIT_REDO, |
| 605 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE); | 605 pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo"); |
| 606 | 606 pSH->AppendMenuItem(hPopup, 0, L""); |
| 607 if (!m_pEdit->IsSelected()) | 607 |
| 608 { | 608 if (!m_pEdit->CanUndo()) |
| 609 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); | 609 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE); |
| 610 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); | 610 if (!m_pEdit->CanRedo()) |
| 611 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); | 611 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE); |
| 612 } | 612 } |
| 613 | 613 |
| 614 if (IsReadOnly()) | 614 pSH->AppendMenuItem(hPopup, |
| 615 { | 615 WM_PWLEDIT_CUT, |
| 616 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); | 616 pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t"); |
| 617 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); | 617 pSH->AppendMenuItem(hPopup, |
| 618 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
| 618 WM_PWLEDIT_COPY, |
| 619 } | 619 pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy"); |
| 620 | 620 pSH->AppendMenuItem( |
| 621 if (HasFlag(PES_PASSWORD)) | 621 hPopup, |
| 622 { | 622 WM_PWLEDIT_PASTE, |
| 623 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); | 623 pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste"); |
| 624 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); | 624 pSH->AppendMenuItem( |
| 625 } | 625 hPopup, |
| 626 | 626 WM_PWLEDIT_DELETE, |
| 627 if (HasFlag(PES_NOREAD)) | 627 pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete"); |
| 628 { | 628 |
| 629 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); | 629 CFX_WideString swText = pSH->GetClipboardText(this->GetAttachedHWnd()); |
| 630 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); | 630 if (swText.IsEmpty()) |
| 631 } | 631 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE); |
| 632 | 632 |
| 633 pSH->AppendMenuItem(hPopup, 0, L""); | 633 if (!m_pEdit->IsSelected()) { |
| 634 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SELECTALL, | 634 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); |
| 635 pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All"); | 635 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); |
| 636 | 636 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); |
| 637 if (m_pEdit->GetTotalWords() == 0) | 637 } |
| 638 { | 638 |
| 639 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE); | 639 if (IsReadOnly()) { |
| 640 } | 640 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); |
| 641 | 641 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); |
| 642 FX_INT32 x, y; | 642 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE); |
| 643 PWLtoWnd(ptPopup, x, y); | 643 } |
| 644 pSH->ClientToScreen(GetAttachedHWnd(), x, y); | 644 |
| 645 pSH->SetCursor(FXCT_ARROW); | 645 if (HasFlag(PES_PASSWORD)) { |
| 646 FX_INT32 nCmd = pSH->TrackPopupMenu(hPopup, | 646 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); |
| 647 x, | 647 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); |
| 648 y, | 648 } |
| 649 GetAttachedHWnd()); | 649 |
| 650 | 650 if (HasFlag(PES_NOREAD)) { |
| 651 | 651 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); |
| 652 switch (nCmd) | 652 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); |
| 653 { | 653 } |
| 654 case WM_PWLEDIT_UNDO: | 654 |
| 655 Undo(); | 655 pSH->AppendMenuItem(hPopup, 0, L""); |
| 656 break; | 656 pSH->AppendMenuItem( |
| 657 case WM_PWLEDIT_REDO: | 657 hPopup, |
| 658 Redo(); | 658 WM_PWLEDIT_SELECTALL, |
| 659 break; | 659 pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All"); |
| 660 case WM_PWLEDIT_CUT: | 660 |
| 661 this->CutText(); | 661 if (m_pEdit->GetTotalWords() == 0) { |
| 662 break; | 662 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE); |
| 663 case WM_PWLEDIT_COPY: | 663 } |
| 664 this->CopyText(); | 664 |
| 665 break; | 665 FX_INT32 x, y; |
| 666 case WM_PWLEDIT_PASTE: | 666 PWLtoWnd(ptPopup, x, y); |
| 667 this->PasteText(); | 667 pSH->ClientToScreen(GetAttachedHWnd(), x, y); |
| 668 break; | 668 pSH->SetCursor(FXCT_ARROW); |
| 669 case WM_PWLEDIT_DELETE: | 669 FX_INT32 nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd()); |
| 670 this->Clear(); | 670 |
| 671 break; | 671 switch (nCmd) { |
| 672 case WM_PWLEDIT_SELECTALL: | 672 case WM_PWLEDIT_UNDO: |
| 673 this->SelectAll(); | 673 Undo(); |
| 674 break; | 674 break; |
| 675 case WM_PWLEDIT_SUGGEST + 0: | 675 case WM_PWLEDIT_REDO: |
| 676 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->
WordPlaceToWordIndex(wrLatin.EndPos)); | 676 Redo(); |
| 677 ReplaceSel(sSuggestWords[0].UTF8Decode()); | 677 break; |
| 678 break; | 678 case WM_PWLEDIT_CUT: |
| 679 case WM_PWLEDIT_SUGGEST + 1: | 679 this->CutText(); |
| 680 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->
WordPlaceToWordIndex(wrLatin.EndPos)); | 680 break; |
| 681 ReplaceSel(sSuggestWords[1].UTF8Decode()); | 681 case WM_PWLEDIT_COPY: |
| 682 break; | 682 this->CopyText(); |
| 683 case WM_PWLEDIT_SUGGEST + 2: | 683 break; |
| 684 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->
WordPlaceToWordIndex(wrLatin.EndPos)); | 684 case WM_PWLEDIT_PASTE: |
| 685 ReplaceSel(sSuggestWords[2].UTF8Decode()); | 685 this->PasteText(); |
| 686 break; | 686 break; |
| 687 case WM_PWLEDIT_SUGGEST + 3: | 687 case WM_PWLEDIT_DELETE: |
| 688 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->
WordPlaceToWordIndex(wrLatin.EndPos)); | 688 this->Clear(); |
| 689 ReplaceSel(sSuggestWords[3].UTF8Decode()); | 689 break; |
| 690 break; | 690 case WM_PWLEDIT_SELECTALL: |
| 691 case WM_PWLEDIT_SUGGEST + 4: | 691 this->SelectAll(); |
| 692 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->
WordPlaceToWordIndex(wrLatin.EndPos)); | 692 break; |
| 693 ReplaceSel(sSuggestWords[4].UTF8Decode()); | 693 case WM_PWLEDIT_SUGGEST + 0: |
| 694 break; | 694 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), |
| 695 default: | 695 m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); |
| 696 break; | 696 ReplaceSel(sSuggestWords[0].UTF8Decode()); |
| 697 } | 697 break; |
| 698 | 698 case WM_PWLEDIT_SUGGEST + 1: |
| 699 pSH->DestroyMenu(hPopup); | 699 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), |
| 700 | 700 m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); |
| 701 return TRUE; | 701 ReplaceSel(sSuggestWords[1].UTF8Decode()); |
| 702 } | 702 break; |
| 703 | 703 case WM_PWLEDIT_SUGGEST + 2: |
| 704 void CPWL_Edit::OnSetFocus() | 704 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), |
| 705 { | 705 m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); |
| 706 SetEditCaret(TRUE); | 706 ReplaceSel(sSuggestWords[2].UTF8Decode()); |
| 707 | 707 break; |
| 708 if (!IsReadOnly()) | 708 case WM_PWLEDIT_SUGGEST + 3: |
| 709 { | 709 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), |
| 710 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) | 710 m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); |
| 711 pFocusHandler->OnSetFocus(this); | 711 ReplaceSel(sSuggestWords[3].UTF8Decode()); |
| 712 } | 712 break; |
| 713 | 713 case WM_PWLEDIT_SUGGEST + 4: |
| 714 m_bFocus = TRUE; | 714 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), |
| 715 } | 715 m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); |
| 716 | 716 ReplaceSel(sSuggestWords[4].UTF8Decode()); |
| 717 void CPWL_Edit::OnKillFocus() | 717 break; |
| 718 { | 718 default: |
| 719 ShowVScrollBar(FALSE); | 719 break; |
| 720 | 720 } |
| 721 m_pEdit->SelectNone(); | 721 |
| 722 SetCaret(FALSE, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f)); | 722 pSH->DestroyMenu(hPopup); |
| 723 | 723 |
| 724 SetCharSet(0); | 724 return TRUE; |
| 725 | 725 } |
| 726 if (!IsReadOnly()) | 726 |
| 727 { | 727 void CPWL_Edit::OnSetFocus() { |
| 728 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) | 728 SetEditCaret(TRUE); |
| 729 pFocusHandler->OnKillFocus(this); | 729 |
| 730 } | 730 if (!IsReadOnly()) { |
| 731 | 731 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) |
| 732 m_bFocus = FALSE; | 732 pFocusHandler->OnSetFocus(this); |
| 733 } | 733 } |
| 734 | 734 |
| 735 void CPWL_Edit::SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint/* = TRUE*/) | 735 m_bFocus = TRUE; |
| 736 { | 736 } |
| 737 m_pEdit->SetHorzScale(nHorzScale, bPaint); | 737 |
| 738 } | 738 void CPWL_Edit::OnKillFocus() { |
| 739 | 739 ShowVScrollBar(FALSE); |
| 740 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint/* = TRUE*/) | 740 |
| 741 { | 741 m_pEdit->SelectNone(); |
| 742 m_pEdit->SetCharSpace(fCharSpace, bPaint); | 742 SetCaret(FALSE, CPDF_Point(0.0f, 0.0f), CPDF_Point(0.0f, 0.0f)); |
| 743 } | 743 |
| 744 | 744 SetCharSet(0); |
| 745 void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint/* = TRUE*/) | 745 |
| 746 { | 746 if (!IsReadOnly()) { |
| 747 m_pEdit->SetLineLeading(fLineLeading, bPaint); | 747 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) |
| 748 } | 748 pFocusHandler->OnKillFocus(this); |
| 749 | 749 } |
| 750 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream(const CPDF_Point & ptOffset)
const | 750 |
| 751 { | 751 m_bFocus = FALSE; |
| 752 CPVT_WordRange wr = GetSelectWordRange(); | 752 } |
| 753 return CPWL_Utils::GetEditSelAppStream(m_pEdit,ptOffset,&wr); | 753 |
| 754 } | 754 void CPWL_Edit::SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint /* = TRUE*/) { |
| 755 | 755 m_pEdit->SetHorzScale(nHorzScale, bPaint); |
| 756 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const | 756 } |
| 757 { | 757 |
| 758 if (m_pEdit->IsSelected()) | 758 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) { |
| 759 { | 759 m_pEdit->SetCharSpace(fCharSpace, bPaint); |
| 760 FX_INT32 nStart = -1; | 760 } |
| 761 FX_INT32 nEnd = -1; | 761 |
| 762 | 762 void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, |
| 763 m_pEdit->GetSel(nStart, nEnd); | 763 FX_BOOL bPaint /* = TRUE*/) { |
| 764 | 764 m_pEdit->SetLineLeading(fLineLeading, bPaint); |
| 765 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart); | 765 } |
| 766 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd); | 766 |
| 767 | 767 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( |
| 768 return CPVT_WordRange(wpStart,wpEnd); | 768 const CPDF_Point& ptOffset) const { |
| 769 } | 769 CPVT_WordRange wr = GetSelectWordRange(); |
| 770 | 770 return CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wr); |
| 771 return CPVT_WordRange(); | 771 } |
| 772 } | 772 |
| 773 | 773 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { |
| 774 CFX_ByteString CPWL_Edit::GetTextAppearanceStream(const CPDF_Point & ptOffset) c
onst | 774 if (m_pEdit->IsSelected()) { |
| 775 { | 775 FX_INT32 nStart = -1; |
| 776 CFX_ByteTextBuf sRet; | 776 FX_INT32 nEnd = -1; |
| 777 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit,ptOffset); | 777 |
| 778 | 778 m_pEdit->GetSel(nStart, nEnd); |
| 779 if (sEdit.GetLength() > 0) | 779 |
| 780 { | 780 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart); |
| 781 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
<< sEdit << "ET\n"; | 781 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd); |
| 782 } | 782 |
| 783 | 783 return CPVT_WordRange(wpStart, wpEnd); |
| 784 return sRet.GetByteString(); | 784 } |
| 785 } | 785 |
| 786 | 786 return CPVT_WordRange(); |
| 787 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(const CPDF_Point & ptOffset)
const | 787 } |
| 788 { | 788 |
| 789 if (m_pEditCaret) | 789 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( |
| 790 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); | 790 const CPDF_Point& ptOffset) const { |
| 791 | 791 CFX_ByteTextBuf sRet; |
| 792 return CFX_ByteString(); | 792 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
| 793 } | 793 |
| 794 | 794 if (sEdit.GetLength() > 0) { |
| 795 CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord) | 795 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit |
| 796 { | 796 << "ET\n"; |
| 797 CPDF_Point pt(0.0f, 0.0f); | 797 } |
| 798 | 798 |
| 799 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) | 799 return sRet.GetByteString(); |
| 800 { | 800 } |
| 801 CPVT_WordPlace wpOld = pIterator->GetAt(); | 801 |
| 802 pIterator->SetAt(wpWord); | 802 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( |
| 803 CPVT_Word word; | 803 const CPDF_Point& ptOffset) const { |
| 804 if (pIterator->GetWord(word)) | 804 if (m_pEditCaret) |
| 805 { | 805 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
| 806 pt = CPDF_Point(word.ptWord.x + word.fWidth, word.ptWord
.y + word.fDescent); | 806 |
| 807 } | 807 return CFX_ByteString(); |
| 808 | 808 } |
| 809 pIterator->SetAt(wpOld); | 809 |
| 810 } | 810 CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord) { |
| 811 | 811 CPDF_Point pt(0.0f, 0.0f); |
| 812 return pt; | 812 |
| 813 } | 813 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
| 814 | 814 CPVT_WordPlace wpOld = pIterator->GetAt(); |
| 815 FX_BOOL CPWL_Edit::IsTextFull() const | 815 pIterator->SetAt(wpWord); |
| 816 { | 816 CPVT_Word word; |
| 817 return m_pEdit->IsTextFull(); | 817 if (pIterator->GetWord(word)) { |
| 818 } | 818 pt = CPDF_Point(word.ptWord.x + word.fWidth, |
| 819 | 819 word.ptWord.y + word.fDescent); |
| 820 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect&
rcPlate, FX_INT32 nCharArray) | 820 } |
| 821 { | 821 |
| 822 if (pFont && !pFont->IsStandardFont()) | 822 pIterator->SetAt(wpOld); |
| 823 { | 823 } |
| 824 FX_RECT rcBBox; | 824 |
| 825 pFont->GetFontBBox(rcBBox); | 825 return pt; |
| 826 | 826 } |
| 827 CPDF_Rect rcCell = rcPlate; | 827 |
| 828 FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.W
idth(); | 828 FX_BOOL CPWL_Edit::IsTextFull() const { |
| 829 FX_FLOAT ydiv = - rcCell.Height() * 1000.0f / rcBBox.Height(); | 829 return m_pEdit->IsTextFull(); |
| 830 | 830 } |
| 831 return xdiv < ydiv ? xdiv : ydiv; | 831 |
| 832 } | 832 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, |
| 833 | 833 const CPDF_Rect& rcPlate, |
| 834 return 0.0f; | 834 FX_INT32 nCharArray) { |
| 835 } | 835 if (pFont && !pFont->IsStandardFont()) { |
| 836 | 836 FX_RECT rcBBox; |
| 837 void CPWL_Edit::SetCharArray(FX_INT32 nCharArray) | 837 pFont->GetFontBBox(rcBBox); |
| 838 { | 838 |
| 839 if (HasFlag(PES_CHARARRAY) && nCharArray > 0) | 839 CPDF_Rect rcCell = rcPlate; |
| 840 { | 840 FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width(); |
| 841 m_pEdit->SetCharArray(nCharArray); | 841 FX_FLOAT ydiv = -rcCell.Height() * 1000.0f / rcBBox.Height(); |
| 842 m_pEdit->SetTextOverflow(TRUE); | 842 |
| 843 | 843 return xdiv < ydiv ? xdiv : ydiv; |
| 844 if (HasFlag(PWS_AUTOFONTSIZE)) | 844 } |
| 845 { | 845 |
| 846 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap()) | 846 return 0.0f; |
| 847 { | 847 } |
| 848 FX_FLOAT fFontSize = GetCharArrayAutoFontSize(pF
ontMap->GetPDFFont(0), GetClientRect(), nCharArray); | 848 |
| 849 if (fFontSize > 0.0f) | 849 void CPWL_Edit::SetCharArray(FX_INT32 nCharArray) { |
| 850 { | 850 if (HasFlag(PES_CHARARRAY) && nCharArray > 0) { |
| 851 m_pEdit->SetAutoFontSize(FALSE); | 851 m_pEdit->SetCharArray(nCharArray); |
| 852 m_pEdit->SetFontSize(fFontSize); | 852 m_pEdit->SetTextOverflow(TRUE); |
| 853 } | 853 |
| 854 } | 854 if (HasFlag(PWS_AUTOFONTSIZE)) { |
| 855 } | 855 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap()) { |
| 856 } | 856 FX_FLOAT fFontSize = GetCharArrayAutoFontSize( |
| 857 } | 857 pFontMap->GetPDFFont(0), GetClientRect(), nCharArray); |
| 858 | 858 if (fFontSize > 0.0f) { |
| 859 void CPWL_Edit::SetLimitChar(FX_INT32 nLimitChar) | 859 m_pEdit->SetAutoFontSize(FALSE); |
| 860 { | 860 m_pEdit->SetFontSize(fFontSize); |
| 861 m_pEdit->SetLimitChar(nLimitChar); | 861 } |
| 862 } | 862 } |
| 863 | 863 } |
| 864 void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText) | 864 } |
| 865 { | 865 } |
| 866 m_pEdit->Clear(); | 866 |
| 867 m_pEdit->InsertText(csText); | 867 void CPWL_Edit::SetLimitChar(FX_INT32 nLimitChar) { |
| 868 } | 868 m_pEdit->SetLimitChar(nLimitChar); |
| 869 | 869 } |
| 870 CPDF_Rect CPWL_Edit::GetFocusRect() const | 870 |
| 871 { | 871 void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText) { |
| 872 return CPDF_Rect(); | 872 m_pEdit->Clear(); |
| 873 } | 873 m_pEdit->InsertText(csText); |
| 874 | 874 } |
| 875 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) | 875 |
| 876 { | 876 CPDF_Rect CPWL_Edit::GetFocusRect() const { |
| 877 if (CPWL_ScrollBar * pScroll = GetVScrollBar()) | 877 return CPDF_Rect(); |
| 878 { | 878 } |
| 879 if (bShow) | 879 |
| 880 { | 880 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { |
| 881 if (!pScroll->IsVisible()) | 881 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 882 { | 882 if (bShow) { |
| 883 pScroll->SetVisible(TRUE); | 883 if (!pScroll->IsVisible()) { |
| 884 CPDF_Rect rcWindow = GetWindowRect(); | 884 pScroll->SetVisible(TRUE); |
| 885 m_rcOldWindow = rcWindow; | 885 CPDF_Rect rcWindow = GetWindowRect(); |
| 886 rcWindow.right += PWL_SCROLLBAR_WIDTH;
| 886 m_rcOldWindow = rcWindow; |
| 887 Move(rcWindow, TRUE, TRUE); | 887 rcWindow.right += PWL_SCROLLBAR_WIDTH; |
| 888 } | 888 Move(rcWindow, TRUE, TRUE); |
| 889 } | 889 } |
| 890 else | 890 } else { |
| 891 { | 891 if (pScroll->IsVisible()) { |
| 892 if (pScroll->IsVisible()) | 892 pScroll->SetVisible(FALSE); |
| 893 { | 893 Move(m_rcOldWindow, TRUE, TRUE); |
| 894 pScroll->SetVisible(FALSE); | 894 } |
| 895 Move(m_rcOldWindow, TRUE, TRUE); | 895 } |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 } | 898 |
| 899 } | 899 FX_BOOL CPWL_Edit::IsVScrollBarVisible() const { |
| 900 | 900 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 901 FX_BOOL CPWL_Edit::IsVScrollBarVisible() const | 901 return pScroll->IsVisible(); |
| 902 { | 902 } |
| 903 if (CPWL_ScrollBar * pScroll = GetVScrollBar()) | 903 |
| 904 { | 904 return FALSE; |
| 905 return pScroll->IsVisible(); | 905 } |
| 906 } | 906 |
| 907 | 907 void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) { |
| 908 return FALSE; | 908 if (bEnabled) |
| 909 } | 909 AddFlag(PES_SPELLCHECK); |
| 910 | 910 else |
| 911 void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) | 911 RemoveFlag(PES_SPELLCHECK); |
| 912 { | 912 } |
| 913 if (bEnabled) | 913 |
| 914 AddFlag(PES_SPELLCHECK); | 914 FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { |
| 915 else | 915 if (m_bMouseDown) |
| 916 RemoveFlag(PES_SPELLCHECK); | 916 return TRUE; |
| 917 } | 917 |
| 918 | 918 if (nChar == FWL_VKEY_Delete) { |
| 919 FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) | 919 if (m_pFillerNotify) { |
| 920 { | 920 FX_BOOL bRC = TRUE; |
| 921 if (m_bMouseDown) return TRUE; | 921 FX_BOOL bExit = FALSE; |
| 922 | 922 CFX_WideString strChange; |
| 923 if (nChar == FWL_VKEY_Delete) | 923 CFX_WideString strChangeEx; |
| 924 { | 924 |
| 925 if (m_pFillerNotify) | 925 int nSelStart = 0; |
| 926 { | 926 int nSelEnd = 0; |
| 927 FX_BOOL bRC = TRUE; | 927 GetSel(nSelStart, nSelEnd); |
| 928 FX_BOOL bExit = FALSE; | 928 |
| 929 CFX_WideString strChange; | 929 if (nSelStart == nSelEnd) |
| 930 CFX_WideString strChangeEx; | 930 nSelEnd = nSelStart + 1; |
| 931 | 931 m_pFillerNotify->OnBeforeKeyStroke(TRUE, |
| 932 int nSelStart = 0; | 932 GetAttachedData(), |
| 933 int nSelEnd = 0; | 933 FWL_VKEY_Delete, |
| 934 GetSel(nSelStart, nSelEnd); | 934 strChange, |
| 935 | 935 strChangeEx, |
| 936 if (nSelStart == nSelEnd) | 936 nSelStart, |
| 937 nSelEnd = nSelStart + 1; | 937 nSelEnd, |
| 938 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData
(), FWL_VKEY_Delete, strChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExi
t, nFlag); | 938 TRUE, |
| 939 if (!bRC) return FALSE; | 939 bRC, |
| 940 if (bExit) return FALSE; | 940 bExit, |
| 941 } | 941 nFlag); |
| 942 } | 942 if (!bRC) |
| 943 | 943 return FALSE; |
| 944 FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag); | 944 if (bExit) |
| 945 | 945 return FALSE; |
| 946 if (nChar == FWL_VKEY_Delete) | 946 } |
| 947 { | 947 } |
| 948 if (m_pFillerNotify) | 948 |
| 949 { | 949 FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag); |
| 950 FX_BOOL bExit = FALSE; | 950 |
| 951 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(
), bExit,nFlag); | 951 if (nChar == FWL_VKEY_Delete) { |
| 952 if (bExit) return FALSE; | 952 if (m_pFillerNotify) { |
| 953 } | 953 FX_BOOL bExit = FALSE; |
| 954 } | 954 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit, nFlag); |
| 955 | 955 if (bExit) |
| 956 //In case of implementation swallow the OnKeyDown event. | 956 return FALSE; |
| 957 if(IsProceedtoOnChar(nChar, nFlag)) | 957 } |
| 958 return TRUE; | 958 } |
| 959 | 959 |
| 960 return bRet; | 960 // In case of implementation swallow the OnKeyDown event. |
| 961 if (IsProceedtoOnChar(nChar, nFlag)) |
| 962 return TRUE; |
| 963 |
| 964 return bRet; |
| 961 } | 965 } |
| 962 | 966 |
| 963 /** | 967 /** |
| 964 *In case of implementation swallow the OnKeyDown event. | 968 *In case of implementation swallow the OnKeyDown event. |
| 965 *If the event is swallowed, implementation may do other unexpected things, which
is not the control means to do. | 969 *If the event is swallowed, implementation may do other unexpected things, which |
| 970 *is not the control means to do. |
| 966 */ | 971 */ |
| 967 FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag) | 972 FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag) { |
| 968 { | 973 FX_BOOL bCtrl = IsCTRLpressed(nFlag); |
| 969 | 974 FX_BOOL bAlt = IsALTpressed(nFlag); |
| 970 FX_BOOL bCtrl = IsCTRLpressed(nFlag); | 975 if (bCtrl && !bAlt) { |
| 971 FX_BOOL bAlt = IsALTpressed(nFlag); | 976 // hot keys for edit control. |
| 972 if(bCtrl && !bAlt) | 977 switch (nKeyCode) { |
| 973 { | 978 case 'C': |
| 974 //hot keys for edit control. | 979 case 'V': |
| 975 switch(nKeyCode) | 980 case 'X': |
| 976 { | 981 case 'A': |
| 977 case 'C': | 982 case 'Z': |
| 978 case 'V': | 983 return TRUE; |
| 979 case 'X': | 984 default: |
| 980 case 'A': | 985 break; |
| 981 case 'Z': | 986 } |
| 982 return TRUE; | 987 } |
| 983 default: | 988 // control characters. |
| 984 break; | 989 switch (nKeyCode) { |
| 985 } | 990 case FWL_VKEY_Escape: |
| 986 } | 991 case FWL_VKEY_Back: |
| 987 //control characters. | 992 case FWL_VKEY_Return: |
| 988 switch(nKeyCode) | 993 case FWL_VKEY_Space: |
| 989 { | 994 return TRUE; |
| 990 case FWL_VKEY_Escape: | 995 default: |
| 991 case FWL_VKEY_Back: | 996 break; |
| 992 case FWL_VKEY_Return: | 997 } |
| 993 case FWL_VKEY_Space: | 998 return FALSE; |
| 994 return TRUE; | 999 } |
| 995 default: | 1000 |
| 996 break; | 1001 FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
| 997 } | 1002 if (m_bMouseDown) |
| 998 return FALSE; | 1003 return TRUE; |
| 999 | 1004 |
| 1000 } | 1005 FX_BOOL bRC = TRUE; |
| 1001 | 1006 FX_BOOL bExit = FALSE; |
| 1002 FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag) | 1007 |
| 1003 { | 1008 FX_BOOL bCtrl = IsCTRLpressed(nFlag); |
| 1004 if (m_bMouseDown) return TRUE; | 1009 if (!bCtrl) { |
| 1005 | 1010 if (m_pFillerNotify) { |
| 1006 FX_BOOL bRC = TRUE; | 1011 CFX_WideString swChange; |
| 1007 FX_BOOL bExit = FALSE; | 1012 FX_INT32 nKeyCode; |
| 1008 | 1013 |
| 1009 FX_BOOL bCtrl = IsCTRLpressed(nFlag); | 1014 int nSelStart = 0; |
| 1010 if (!bCtrl) | 1015 int nSelEnd = 0; |
| 1011 { | 1016 GetSel(nSelStart, nSelEnd); |
| 1012 if (m_pFillerNotify) | 1017 |
| 1013 { | 1018 switch (nChar) { |
| 1014 CFX_WideString swChange; | 1019 case FWL_VKEY_Back: |
| 1015 FX_INT32 nKeyCode; | 1020 nKeyCode = nChar; |
| 1016 | 1021 if (nSelStart == nSelEnd) |
| 1017 int nSelStart = 0; | 1022 nSelStart = nSelEnd - 1; |
| 1018 int nSelEnd = 0; | 1023 break; |
| 1019 GetSel(nSelStart, nSelEnd); | 1024 case FWL_VKEY_Return: |
| 1020 | 1025 nKeyCode = nChar; |
| 1021 switch (nChar) | 1026 break; |
| 1022 { | 1027 default: |
| 1023 case FWL_VKEY_Back: | 1028 nKeyCode = 0; |
| 1024 nKeyCode = nChar; | 1029 swChange += nChar; |
| 1025 if (nSelStart == nSelEnd) | 1030 break; |
| 1026 nSelStart = nSelEnd - 1; | 1031 } |
| 1027 break; | 1032 |
| 1028 case FWL_VKEY_Return: | 1033 CFX_WideString strChangeEx; |
| 1029 nKeyCode = nChar; | 1034 m_pFillerNotify->OnBeforeKeyStroke(TRUE, |
| 1030 break; | 1035 GetAttachedData(), |
| 1031 default: | 1036 nKeyCode, |
| 1032 nKeyCode = 0; | 1037 swChange, |
| 1033 swChange += nChar; | 1038 strChangeEx, |
| 1034 break; | 1039 nSelStart, |
| 1035 } | 1040 nSelEnd, |
| 1036 | 1041 TRUE, |
| 1037 CFX_WideString strChangeEx; | 1042 bRC, |
| 1038 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData
(), nKeyCode, swChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag
); | 1043 bExit, |
| 1039 } | 1044 nFlag); |
| 1040 } | 1045 } |
| 1041 | 1046 } |
| 1042 if (!bRC) return TRUE; | 1047 |
| 1043 if (bExit) return FALSE; | 1048 if (!bRC) |
| 1044 | 1049 return TRUE; |
| 1045 if (IFX_Edit_FontMap * pFontMap = GetFontMap()) | 1050 if (bExit) |
| 1046 { | 1051 return FALSE; |
| 1047 FX_INT32 nOldCharSet = GetCharSet(); | 1052 |
| 1048 FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAU
LT_CHARSET); | 1053 if (IFX_Edit_FontMap* pFontMap = GetFontMap()) { |
| 1049 if(nOldCharSet != nNewCharSet) | 1054 FX_INT32 nOldCharSet = GetCharSet(); |
| 1050 { | 1055 FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET); |
| 1051 SetCharSet(nNewCharSet); | 1056 if (nOldCharSet != nNewCharSet) { |
| 1052 } | 1057 SetCharSet(nNewCharSet); |
| 1053 } | 1058 } |
| 1054 FX_BOOL bRet = CPWL_EditCtrl::OnChar(nChar,nFlag); | 1059 } |
| 1055 | 1060 FX_BOOL bRet = CPWL_EditCtrl::OnChar(nChar, nFlag); |
| 1056 if (!bCtrl) | 1061 |
| 1057 { | 1062 if (!bCtrl) { |
| 1058 if (m_pFillerNotify) | 1063 if (m_pFillerNotify) { |
| 1059 { | 1064 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit, nFlag); |
| 1060 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(
), bExit,nFlag); | 1065 if (bExit) |
| 1061 if (bExit) return FALSE; | 1066 return FALSE; |
| 1062 } | 1067 } |
| 1063 } | 1068 } |
| 1064 | 1069 |
| 1065 return bRet; | 1070 return bRet; |
| 1066 } | 1071 } |
| 1067 | 1072 |
| 1068 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD
nFlag) | 1073 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, |
| 1069 { | 1074 const CPDF_Point& point, |
| 1070 if (HasFlag(PES_MULTILINE)) | 1075 FX_DWORD nFlag) { |
| 1071 { | 1076 if (HasFlag(PES_MULTILINE)) { |
| 1072 CPDF_Point ptScroll = GetScrollPos(); | 1077 CPDF_Point ptScroll = GetScrollPos(); |
| 1073 | 1078 |
| 1074 if (zDelta > 0) | 1079 if (zDelta > 0) { |
| 1075 { | 1080 ptScroll.y += this->GetFontSize(); |
| 1076 ptScroll.y += this->GetFontSize(); | 1081 } else { |
| 1077 } | 1082 ptScroll.y -= this->GetFontSize(); |
| 1078 else | 1083 } |
| 1079 { | 1084 this->SetScrollPos(ptScroll); |
| 1080 ptScroll.y -= this->GetFontSize(); | 1085 |
| 1081 } | 1086 return TRUE; |
| 1082 this->SetScrollPos(ptScroll); | 1087 } |
| 1083 | 1088 |
| 1084 return TRUE; | 1089 return FALSE; |
| 1085 } | 1090 } |
| 1086 | 1091 |
| 1087 return FALSE; | 1092 void CPWL_Edit::OnInsertReturn(const CPVT_WordPlace& place, |
| 1088 } | 1093 const CPVT_WordPlace& oldplace) { |
| 1089 | 1094 if (HasFlag(PES_SPELLCHECK)) { |
| 1090 void CPWL_Edit::OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace
& oldplace) | 1095 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1091 { | 1096 GetLatinWordsRange(place))); |
| 1092 if (HasFlag(PES_SPELLCHECK)) | 1097 } |
| 1093 { | 1098 |
| 1094 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1099 if (m_pEditNotify) { |
| 1095 } | 1100 m_pEditNotify->OnInsertReturn(place, oldplace); |
| 1096 | 1101 } |
| 1097 if (m_pEditNotify) | 1102 } |
| 1098 { | 1103 |
| 1099 m_pEditNotify->OnInsertReturn(place, oldplace); | 1104 void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place, |
| 1100 } | 1105 const CPVT_WordPlace& oldplace) { |
| 1101 } | 1106 if (HasFlag(PES_SPELLCHECK)) { |
| 1102 | 1107 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1103 void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& o
ldplace) | 1108 GetLatinWordsRange(place))); |
| 1104 { | 1109 } |
| 1105 if (HasFlag(PES_SPELLCHECK)) | 1110 |
| 1106 { | 1111 if (m_pEditNotify) { |
| 1107 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1112 m_pEditNotify->OnBackSpace(place, oldplace); |
| 1108 } | 1113 } |
| 1109 | 1114 } |
| 1110 if (m_pEditNotify) | 1115 |
| 1111 { | 1116 void CPWL_Edit::OnDelete(const CPVT_WordPlace& place, |
| 1112 m_pEditNotify->OnBackSpace(place, oldplace); | 1117 const CPVT_WordPlace& oldplace) { |
| 1113 } | 1118 if (HasFlag(PES_SPELLCHECK)) { |
| 1114 } | 1119 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1115 | 1120 GetLatinWordsRange(place))); |
| 1116 void CPWL_Edit::OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldp
lace) | 1121 } |
| 1117 { | 1122 |
| 1118 if (HasFlag(PES_SPELLCHECK)) | 1123 if (m_pEditNotify) { |
| 1119 { | 1124 m_pEditNotify->OnDelete(place, oldplace); |
| 1120 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1125 } |
| 1121 } | 1126 } |
| 1122 | 1127 |
| 1123 if (m_pEditNotify) | 1128 void CPWL_Edit::OnClear(const CPVT_WordPlace& place, |
| 1124 { | 1129 const CPVT_WordPlace& oldplace) { |
| 1125 m_pEditNotify->OnDelete(place, oldplace); | 1130 if (HasFlag(PES_SPELLCHECK)) { |
| 1126 } | 1131 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1127 } | 1132 GetLatinWordsRange(place))); |
| 1128 | 1133 } |
| 1129 void CPWL_Edit::OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldpl
ace) | 1134 |
| 1130 { | 1135 if (m_pEditNotify) { |
| 1131 if (HasFlag(PES_SPELLCHECK)) | 1136 m_pEditNotify->OnClear(place, oldplace); |
| 1132 { | 1137 } |
| 1133 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1138 } |
| 1134 } | 1139 |
| 1135 | 1140 void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place, |
| 1136 if (m_pEditNotify) | 1141 const CPVT_WordPlace& oldplace) { |
| 1137 { | 1142 if (HasFlag(PES_SPELLCHECK)) { |
| 1138 m_pEditNotify->OnClear(place, oldplace); | 1143 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1139 } | 1144 GetLatinWordsRange(place))); |
| 1140 } | 1145 } |
| 1141 | 1146 |
| 1142 void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace&
oldplace) | 1147 if (m_pEditNotify) { |
| 1143 { | 1148 m_pEditNotify->OnInsertWord(place, oldplace); |
| 1144 if (HasFlag(PES_SPELLCHECK)) | 1149 } |
| 1145 { | 1150 } |
| 1146 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1151 |
| 1147 } | 1152 void CPWL_Edit::OnSetText(const CPVT_WordPlace& place, |
| 1148 | 1153 const CPVT_WordPlace& oldplace) { |
| 1149 if (m_pEditNotify) | 1154 } |
| 1150 { | 1155 |
| 1151 m_pEditNotify->OnInsertWord(place, oldplace); | 1156 void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place, |
| 1152 } | 1157 const CPVT_WordPlace& oldplace) { |
| 1153 } | 1158 if (HasFlag(PES_SPELLCHECK)) { |
| 1154 | 1159 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 1155 void CPWL_Edit::OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& old
place) | 1160 GetLatinWordsRange(place))); |
| 1156 { | 1161 } |
| 1157 } | 1162 |
| 1158 | 1163 if (m_pEditNotify) { |
| 1159 void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace&
oldplace) | 1164 m_pEditNotify->OnInsertText(place, oldplace); |
| 1160 { | 1165 } |
| 1161 if (HasFlag(PES_SPELLCHECK)) | 1166 } |
| 1162 { | 1167 |
| 1163 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(ol
dplace),GetLatinWordsRange(place))); | 1168 void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) { |
| 1164 } | 1169 if (m_pEditNotify) { |
| 1165 | 1170 m_pEditNotify->OnAddUndo(this); |
| 1166 if (m_pEditNotify) | 1171 } |
| 1167 { | 1172 } |
| 1168 m_pEditNotify->OnInsertText(place, oldplace); | 1173 |
| 1169 } | 1174 CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1, |
| 1170 } | 1175 const CPVT_WordRange& wr2) { |
| 1171 | 1176 CPVT_WordRange wrRet; |
| 1172 void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) | 1177 |
| 1173 { | 1178 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) { |
| 1174 if (m_pEditNotify) | 1179 wrRet.BeginPos = wr1.BeginPos; |
| 1175 { | 1180 } else { |
| 1176 m_pEditNotify->OnAddUndo(this); | 1181 wrRet.BeginPos = wr2.BeginPos; |
| 1177 } | 1182 } |
| 1178 } | 1183 |
| 1179 | 1184 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
| 1180 CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1, const CPVT
_WordRange& wr2) | 1185 wrRet.EndPos = wr2.EndPos; |
| 1181 { | 1186 } else { |
| 1182 CPVT_WordRange wrRet; | 1187 wrRet.EndPos = wr1.EndPos; |
| 1183 | 1188 } |
| 1184 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) | 1189 |
| 1185 { | 1190 return wrRet; |
| 1186 wrRet.BeginPos = wr1.BeginPos; | 1191 } |
| 1187 } | 1192 |
| 1188 else | 1193 CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const { |
| 1189 { | 1194 return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE); |
| 1190 wrRet.BeginPos = wr2.BeginPos; | 1195 } |
| 1191 } | 1196 |
| 1192 | 1197 CPVT_WordRange CPWL_Edit::GetLatinWordsRange( |
| 1193 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) | 1198 const CPVT_WordPlace& place) const { |
| 1194 { | 1199 return GetSameWordsRange(place, TRUE, FALSE); |
| 1195 wrRet.EndPos = wr2.EndPos; | 1200 } |
| 1196 } | 1201 |
| 1197 else | 1202 CPVT_WordRange CPWL_Edit::GetArabicWordsRange( |
| 1198 { | 1203 const CPVT_WordPlace& place) const { |
| 1199 wrRet.EndPos = wr1.EndPos; | 1204 return GetSameWordsRange(place, FALSE, TRUE); |
| 1200 } | 1205 } |
| 1201 | 1206 |
| 1202 return wrRet; | 1207 #define PWL_ISARABICWORD(word) \ |
| 1203 } | 1208 ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) |
| 1204 | 1209 |
| 1205 CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const | 1210 CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, |
| 1206 { | 1211 FX_BOOL bLatin, |
| 1207 return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE); | 1212 FX_BOOL bArabic) const { |
| 1208 } | 1213 CPVT_WordRange range; |
| 1209 | 1214 |
| 1210 CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPVT_WordPlace & place) const | 1215 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
| 1211 { | 1216 CPVT_Word wordinfo; |
| 1212 return GetSameWordsRange(place, TRUE, FALSE); | 1217 CPVT_WordPlace wpStart(place), wpEnd(place); |
| 1213 } | 1218 pIterator->SetAt(place); |
| 1214 | 1219 |
| 1215 CPVT_WordRange CPWL_Edit::GetArabicWordsRange(const CPVT_WordPlace & place) cons
t | 1220 if (bLatin) { |
| 1216 { | 1221 while (pIterator->NextWord()) { |
| 1217 return GetSameWordsRange(place, FALSE, TRUE); | 1222 if (pIterator->GetWord(wordinfo) && |
| 1218 } | 1223 FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 1219 | 1224 wpEnd = pIterator->GetAt(); |
| 1220 #define PWL_ISARABICWORD(word) ((word >= 0x0600 && word <= 0x06FF) || (word >= 0
xFB50 && word <= 0xFEFC)) | 1225 continue; |
| 1221 | 1226 } else |
| 1222 CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOO
L bLatin, FX_BOOL bArabic) const | 1227 break; |
| 1223 { | 1228 }; |
| 1224 CPVT_WordRange range; | 1229 } else if (bArabic) { |
| 1225 | 1230 while (pIterator->NextWord()) { |
| 1226 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) | 1231 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { |
| 1227 { | 1232 wpEnd = pIterator->GetAt(); |
| 1228 CPVT_Word wordinfo; | 1233 continue; |
| 1229 CPVT_WordPlace wpStart(place),wpEnd(place); | 1234 } else |
| 1230 pIterator->SetAt(place); | 1235 break; |
| 1231 | 1236 }; |
| 1232 if (bLatin) | 1237 } |
| 1233 { | 1238 |
| 1234 while (pIterator->NextWord()) | 1239 pIterator->SetAt(place); |
| 1235 { | 1240 |
| 1236 if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLA
TINWORD(wordinfo.Word)) | 1241 if (bLatin) { |
| 1237 { | 1242 do { |
| 1238 wpEnd = pIterator->GetAt(); | 1243 if (pIterator->GetWord(wordinfo) && |
| 1239 continue; | 1244 FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 1240 } | 1245 continue; |
| 1241 else | 1246 } else { |
| 1242 break; | 1247 wpStart = pIterator->GetAt(); |
| 1243 }; | 1248 break; |
| 1244 } | 1249 } |
| 1245 else if (bArabic) | 1250 } while (pIterator->PrevWord()); |
| 1246 { | 1251 } else if (bArabic) { |
| 1247 while (pIterator->NextWord()) | 1252 do { |
| 1248 { | 1253 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { |
| 1249 if (pIterator->GetWord(wordinfo) && PWL_ISARABIC
WORD(wordinfo.Word)) | 1254 continue; |
| 1250 { | 1255 } else { |
| 1251 wpEnd = pIterator->GetAt(); | 1256 wpStart = pIterator->GetAt(); |
| 1252 continue; | 1257 break; |
| 1253 } | 1258 } |
| 1254 else | 1259 } while (pIterator->PrevWord()); |
| 1255 break; | 1260 } |
| 1256 }; | 1261 |
| 1257 } | 1262 range.Set(wpStart, wpEnd); |
| 1258 | 1263 } |
| 1259 pIterator->SetAt(place); | 1264 |
| 1260 | 1265 return range; |
| 1261 if (bLatin) | 1266 } |
| 1262 { | 1267 |
| 1263 do | 1268 void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr) { |
| 1264 { | 1269 } |
| 1265 if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLA
TINWORD(wordinfo.Word)) | 1270 |
| 1266 { | 1271 void CPWL_Edit::GeneratePageObjects( |
| 1267 continue; | 1272 CPDF_PageObjects* pPageObjects, |
| 1268 } | 1273 const CPDF_Point& ptOffset, |
| 1269 else | 1274 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 1270 { | 1275 IFX_Edit::GeneratePageObjects( |
| 1271 wpStart = pIterator->GetAt(); | 1276 pPageObjects, |
| 1272 break; | 1277 m_pEdit, |
| 1273 } | 1278 ptOffset, |
| 1274 } | 1279 NULL, |
| 1275 while (pIterator->PrevWord()); | 1280 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 1276 } | 1281 ObjArray); |
| 1277 else if (bArabic) | 1282 } |
| 1278 { | 1283 |
| 1279 do | 1284 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, |
| 1280 { | 1285 const CPDF_Point& ptOffset) { |
| 1281 if (pIterator->GetWord(wordinfo) && PWL_ISARABIC
WORD(wordinfo.Word)) | 1286 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 1282 { | 1287 IFX_Edit::GeneratePageObjects( |
| 1283 continue; | 1288 pPageObjects, |
| 1284 } | 1289 m_pEdit, |
| 1285 else | 1290 ptOffset, |
| 1286 { | 1291 NULL, |
| 1287 wpStart = pIterator->GetAt(); | 1292 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 1288 break; | 1293 ObjArray); |
| 1289 } | 1294 } |
| 1290 } | |
| 1291 while (pIterator->PrevWord()); | |
| 1292 } | |
| 1293 | |
| 1294 range.Set(wpStart,wpEnd); | |
| 1295 } | |
| 1296 | |
| 1297 return range; | |
| 1298 } | |
| 1299 | |
| 1300 void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr) | |
| 1301 { | |
| 1302 } | |
| 1303 | |
| 1304 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, | |
| 1305
const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) | |
| 1306 { | |
| 1307 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW
L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); | |
| 1308 } | |
| 1309 | |
| 1310 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, | |
| 1311 const CP
DF_Point& ptOffset) | |
| 1312 { | |
| 1313 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | |
| 1314 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW
L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); | |
| 1315 } | |
| 1316 | |
| OLD | NEW |