void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { CPDF_Point ptHead(0, 0), ptFoot(0, 0); GetCaretInfo(ptHead, ptFoot); PWLtoWnd(ptHead, x, y); }
void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point) { if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { FX_INT32 x,y; PWLtoWnd(point, x, y); if (IFX_SystemHandler* pSH = GetSystemHandler()) pSH->ClientToScreen(GetAttachedHWnd(), x, y); pNotify->OnPopupMenu(this, x, y); } }
FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) { if (IPWL_NoteNotify* pNotify = this->GetNoteNotify()) { FX_INT32 x, y; PWLtoWnd(point, x, y); if (IFX_SystemHandler* pSH = GetSystemHandler()) pSH->ClientToScreen(GetAttachedHWnd(), x, y); this->KillFocus(); pNotify->OnPopupMenu(x, y); return TRUE; } } return CPWL_Wnd::OnLButtonDown(point,nFlag); }
void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) { if (IsValid()) { CFX_FloatRect rcRefresh = pRect ? *pRect : GetWindowRect(); if (!HasFlag(PWS_NOREFRESHCLIP)) { CFX_FloatRect rcClip = GetClipRect(); if (!rcClip.IsEmpty()) { rcRefresh.Intersect(rcClip); } } FX_RECT rcWin = PWLtoWnd(rcRefresh); rcWin.left -= PWL_INVALIDATE_INFLATE; rcWin.top -= PWL_INVALIDATE_INFLATE; rcWin.right += PWL_INVALIDATE_INFLATE; rcWin.bottom += PWL_INVALIDATE_INFLATE; if (CFX_SystemHandler* pSH = GetSystemHandler()) { if (FX_HWND hWnd = GetAttachedHWnd()) { pSH->InvalidateRect(hWnd, rcWin); } } } }
void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { CFX_FloatPoint ptHead; CFX_FloatPoint ptFoot; GetCaretInfo(ptHead, ptFoot); PWLtoWnd(ptHead, x, y); }
FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { if (m_bMouseDown) return FALSE; CPWL_Wnd::OnRButtonUp(point, nFlag); if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) return TRUE; IFX_SystemHandler* pSH = GetSystemHandler(); if (!pSH) return FALSE; SetFocus(); CPVT_WordRange wrLatin = GetLatinWordsRange(point); CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); FX_HMENU hPopup = pSH->CreatePopupMenu(); if (!hPopup) return FALSE; CFX_ByteStringArray sSuggestWords; CPDF_Point ptPopup = point; if (!IsReadOnly()) { if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { if (m_pSpellCheck) { CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); if (!m_pSpellCheck->CheckWord(sLatin)) { m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); int32_t nSuggest = sSuggestWords.GetSize(); for (int32_t nWord = 0; nWord < nSuggest; nWord++) { pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord, sSuggestWords[nWord].UTF8Decode()); } if (nSuggest > 0) pSH->AppendMenuItem(hPopup, 0, L""); ptPopup = GetWordRightBottomPoint(wrLatin.EndPos); } } } } IPWL_Provider* pProvider = GetProvider(); if (HasFlag(PES_UNDO)) { pSH->AppendMenuItem( hPopup, WM_PWLEDIT_UNDO, pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo"); pSH->AppendMenuItem( hPopup, WM_PWLEDIT_REDO, pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo"); pSH->AppendMenuItem(hPopup, 0, L""); if (!m_pEdit->CanUndo()) pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE); if (!m_pEdit->CanRedo()) pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE); } pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT, pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t"); pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY, pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy"); pSH->AppendMenuItem( hPopup, WM_PWLEDIT_PASTE, pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste"); pSH->AppendMenuItem( hPopup, WM_PWLEDIT_DELETE, pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete"); CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd()); if (swText.IsEmpty()) pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE); if (!m_pEdit->IsSelected()) { pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); } if (IsReadOnly()) { pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE); } if (HasFlag(PES_PASSWORD)) { pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); } if (HasFlag(PES_NOREAD)) { pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE); pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE); } pSH->AppendMenuItem(hPopup, 0, L""); pSH->AppendMenuItem( hPopup, WM_PWLEDIT_SELECTALL, pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All"); if (m_pEdit->GetTotalWords() == 0) { pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE); } int32_t x, y; PWLtoWnd(ptPopup, x, y); pSH->ClientToScreen(GetAttachedHWnd(), x, y); pSH->SetCursor(FXCT_ARROW); int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd()); switch (nCmd) { case WM_PWLEDIT_UNDO: Undo(); break; case WM_PWLEDIT_REDO: Redo(); break; case WM_PWLEDIT_CUT: CutText(); break; case WM_PWLEDIT_COPY: CopyText(); break; case WM_PWLEDIT_PASTE: PasteText(); break; case WM_PWLEDIT_DELETE: Clear(); break; case WM_PWLEDIT_SELECTALL: SelectAll(); break; case WM_PWLEDIT_SUGGEST + 0: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); ReplaceSel(sSuggestWords[0].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 1: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); ReplaceSel(sSuggestWords[1].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 2: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); ReplaceSel(sSuggestWords[2].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 3: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); ReplaceSel(sSuggestWords[3].UTF8Decode().c_str()); break; case WM_PWLEDIT_SUGGEST + 4: SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos), m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos)); ReplaceSel(sSuggestWords[4].UTF8Decode().c_str()); break; default: break; } pSH->DestroyMenu(hPopup); return TRUE; }