void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); if (m_pList) { CFX_FloatRect rcPlate = m_pList->GetPlateRect(); CFX_FloatRect rcList = GetListRect(); CFX_FloatRect rcClient = GetClientRect(); for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { CFX_FloatRect rcItem = m_pList->GetItemRect(i); if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) continue; CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) { CFX_FloatRect rcContent = pEdit->GetContentRect(); if (rcContent.Width() > rcClient.Width()) rcItem.Intersect(rcList); else rcItem.Intersect(rcClient); } if (m_pList->IsItemSelected(i)) { CFX_SystemHandler* pSysHandler = GetSystemHandler(); if (pSysHandler && pSysHandler->IsSelectionImplemented()) { IFX_Edit::DrawEdit( pDevice, pUser2Device, m_pList->GetItemEdit(i), CPWL_Utils::PWLColorToFXColor(GetTextColor()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList, ptOffset, nullptr, pSysHandler, m_pFormFiller); pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem); } else { CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, ArgbEncode(255, 0, 51, 113)); IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i), ArgbEncode(255, 255, 255, 255), 0, rcList, ptOffset, nullptr, pSysHandler, m_pFormFiller); } } else { CFX_SystemHandler* pSysHandler = GetSystemHandler(); IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i), CPWL_Utils::PWLColorToFXColor(GetTextColor()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList, ptOffset, nullptr, pSysHandler, nullptr); } } } }
void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { if (!m_pTimer) m_pTimer = new CPWL_Timer(this, GetSystemHandler()); if (m_pTimer) m_pTimer->SetPWLTimer(nElapse); }
FX_BOOL CPWL_Wnd::IsALTpressed(uint32_t nFlag) const { if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { return pSystemHandler->IsALTKeyDown(nFlag); } return FALSE; }
void CPWL_Edit::PasteText() { if (!CanPaste()) return; CFX_WideString swClipboard; if (IFX_SystemHandler* pSH = GetSystemHandler()) swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); if (m_pFillerNotify) { FX_BOOL bRC = TRUE; FX_BOOL bExit = FALSE; CFX_WideString strChangeEx; int nSelStart = 0; int nSelEnd = 0; GetSel(nSelStart, nSelEnd); m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swClipboard, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, 0); if (!bRC) return; if (bExit) return; } if (swClipboard.GetLength() > 0) { Clear(); InsertText(swClipboard.c_str()); } }
PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() { PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); ASSERT(m_pWidget != NULL); int nFlags = m_pWidget->GetFieldFlags(); if (nFlags & FIELDFLAG_EDIT) { cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; } /* if (nFlags & FIELDFLAG_COMMITONSELCHANGE) { m_bCommitOnSelectChange = TRUE; } */ if (!m_pFontMap) { ASSERT(this->m_pApp != NULL); m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); m_pFontMap->Initial(); } cp.pFontMap = m_pFontMap; cp.pFocusHandler = this; return cp; }
void CPWL_Wnd::SetCursor() { if (IsValid()) { if (CFX_SystemHandler* pSH = GetSystemHandler()) { int32_t nCursorType = GetCreationParam().eCursorType; pSH->SetCursor(nCursorType); } } }
void CPWL_Edit::CopyText() { if (!CanCopy()) return; CFX_WideString str = m_pEdit->GetSelText(); if (IFX_SystemHandler* pSH = GetSystemHandler()) pSH->SetClipboardText(GetAttachedHWnd(), str); }
void CPWL_EditCtrl::SetCursor() { if (IsValid()) { if (CFX_SystemHandler* pSH = GetSystemHandler()) { if (IsWndHorV()) pSH->SetCursor(FXCT_VBEAM); else pSH->SetCursor(FXCT_HBEAM); } } }
FX_BOOL CPWL_Edit::CanPaste() const { if (IsReadOnly()) return FALSE; CFX_WideString swClipboard; if (IFX_SystemHandler* pSH = GetSystemHandler()) swClipboard = pSH->GetClipboardText(GetAttachedHWnd()); return !swClipboard.IsEmpty(); }
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); } }
PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() { PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); int nFlags = m_pWidget->GetFieldFlags(); if (nFlags & FIELDFLAG_EDIT) { cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; } if (!m_pFontMap) m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); cp.pFontMap = m_pFontMap; cp.pFocusHandler = this; return cp; }
bool CPWL_Edit::OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) { if (m_bMouseDown) return false; CPWL_Wnd::OnRButtonUp(point, nFlag); if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) return true; CFX_SystemHandler* pSH = GetSystemHandler(); if (!pSH) return false; SetFocus(); return false; }
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_Label::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); GetClientRect(); CFX_FloatRect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = NULL; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } IFX_SystemHandler* pSysHandler = GetSystemHandler(); IFX_Edit::DrawEdit( pDevice, pUser2Device, m_pEdit, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, NULL); }
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); } } } }
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; }
void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CPDF_Rect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); FX_SAFE_INT32 nCharArraySafe = nCharArray; nCharArraySafe -= 1; nCharArraySafe *= 2; if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { case PBS_SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; case PBS_DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); gsd.SetDashCount(2); gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; } } CPDF_Rect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = NULL; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } IFX_SystemHandler* pSysHandler = GetSystemHandler(); IFX_Edit::DrawEdit( pDevice, pUser2Device, m_pEdit, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); if (HasFlag(PES_SPELLCHECK)) { CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, CPDF_Point(0.0f, 0.0f), pRange, GetCreationParam().pSpellCheck); } }
void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CFX_FloatRect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); FX_SAFE_INT32 nCharArraySafe = nCharArray; nCharArraySafe -= 1; nCharArraySafe *= 2; if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { case BorderStyle::SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; for (int32_t i = 0; i < nCharArray - 1; i++) { path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom), FXPT_TYPE::MoveTo, false); path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top), FXPT_TYPE::LineTo, false); } if (!path.GetPoints().empty()) { pDevice->DrawPath(&path, pUser2Device, &gsd, 0, GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE); } break; } case BorderStyle::DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); gsd.SetDashCount(2); gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; for (int32_t i = 0; i < nCharArray - 1; i++) { path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom), FXPT_TYPE::MoveTo, false); path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top), FXPT_TYPE::LineTo, false); } if (!path.GetPoints().empty()) { pDevice->DrawPath(&path, pUser2Device, &gsd, 0, GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE); } break; } default: break; } } CFX_FloatRect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = nullptr; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } CFX_SystemHandler* pSysHandler = GetSystemHandler(); CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pEdit.get(), GetTextColor().ToFXColor(GetTransparency()), rcClip, CFX_PointF(), pRange, pSysHandler, m_pFormFiller); }