void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); if (IsVisible() && !rectWnd.IsEmpty()) { CPDF_Point ptCenter = GetCenterPoint(); CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CPDF_Point pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); if (IsFloatBigger(rectWnd.right - rectWnd.left, PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) && IsFloatBigger(rectWnd.top - rectWnd.bottom, PWL_CBBUTTON_TRIANGLE_HALFLEN)) { CFX_PathData path; path.SetPointCount(4); path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); pDevice->DrawPath(&path, pUser2Device, NULL, CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, GetTransparency()), 0, FXFILL_ALTERNATE); } } }
void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect(); if (IsVisible() && !rectWnd.IsEmpty()) { CFX_PointF ptCenter = GetCenterPoint(); CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CFX_PointF pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); if (IsFloatBigger(rectWnd.right - rectWnd.left, PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) && IsFloatBigger(rectWnd.top - rectWnd.bottom, PWL_CBBUTTON_TRIANGLE_HALFLEN)) { CFX_PathData path; path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false); path.AppendPoint(pt2, FXPT_TYPE::LineTo, false); path.AppendPoint(pt3, FXPT_TYPE::LineTo, false); path.AppendPoint(pt1, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0, FXFILL_ALTERNATE); } } }
void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { CPWL_Wnd::GetThisAppearanceStream(sAppStream); CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); if (IsVisible() && !rectWnd.IsEmpty()) { CFX_ByteTextBuf sButton; CPDF_Point ptCenter = GetCenterPoint(); CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN, ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); CPDF_Point pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); if (IsFloatBigger(rectWnd.right - rectWnd.left, PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) && IsFloatBigger(rectWnd.top - rectWnd.bottom, PWL_CBBUTTON_TRIANGLE_HALFLEN)) { sButton << "0 g\n"; sButton << pt1.x << " " << pt1.y << " m\n"; sButton << pt2.x << " " << pt2.y << " l\n"; sButton << pt3.x << " " << pt3.y << " l\n"; sButton << pt1.x << " " << pt1.y << " l f\n"; sAppStream << "q\n" << sButton << "Q\n"; } } }
void CPWL_ComboBox::SetPopup(bool bPopup) { if (!m_pList) return; if (bPopup == m_bPopup) return; FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); if (!IsFloatBigger(fListHeight, 0.0f)) return; if (bPopup) { if (m_pFillerNotify) { #ifdef PDF_ENABLE_XFA bool bExit = false; m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0); if (bExit) return; #endif // PDF_ENABLE_XFA int32_t nWhere = 0; FX_FLOAT fPopupRet = 0.0f; FX_FLOAT fPopupMin = 0.0f; if (m_pList->GetCount() > 3) fPopupMin = m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2; m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax, nWhere, fPopupRet); if (IsFloatBigger(fPopupRet, 0.0f)) { m_bPopup = bPopup; CFX_FloatRect rcWindow = CPWL_Wnd::GetWindowRect(); m_rcOldWindow = rcWindow; switch (nWhere) { default: case 0: rcWindow.bottom -= fPopupRet; break; case 1: rcWindow.top += fPopupRet; break; } m_nPopupWhere = nWhere; Move(rcWindow, true, true); #ifdef PDF_ENABLE_XFA bExit = false; m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0); if (bExit) return; #endif // PDF_ENABLE_XFA } } } else { m_bPopup = bPopup; Move(m_rcOldWindow, true, true); } }
bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const { CFX_SizeF szTotal; for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { if (CSection* pSection = m_SectionArray.GetAt(s)) { CFX_SizeF size = pSection->GetSectionSize(fFontSize); szTotal.x = std::max(size.x, szTotal.x); szTotal.y += size.y; if (IsFloatBigger(szTotal.x, GetPlateWidth()) || IsFloatBigger(szTotal.y, GetPlateHeight())) { return true; } } } return false; }
void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) { if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { if (pScroll->IsVisible()) { pScroll->SetVisible(false); m_pList->RePosChildWnd(); } } else { if (!pScroll->IsVisible()) { pScroll->SetVisible(true); m_pList->RePosChildWnd(); } } } }
void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info); // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin) || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)) { this->ShowVScrollBar(FALSE); } else { this->ShowVScrollBar(TRUE); } }
void CPWL_List_Notify::IOnSetScrollInfoY(float fPlateMin, float fPlateMax, float fContentMin, float fContentMax, float fSmallStep, float fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; m_pList->SetScrollInfo(Info); CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar(); if (!pScroll) return; if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { if (pScroll->IsVisible()) { pScroll->SetVisible(false); m_pList->RePosChildWnd(); } } else { if (!pScroll->IsVisible()) { pScroll->SetVisible(true); m_pList->RePosChildWnd(); } } }
int32_t CFX_ListCtrl::GetItemIndex(const CFX_PointF& point) const { CFX_PointF pt = OuterToInner(OutToIn(point)); bool bFirst = true; bool bLast = true; for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) { if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) { CLST_Rect rcListItem = pListItem->GetRect(); if (IsFloatBigger(pt.y, rcListItem.top)) { bFirst = false; } if (IsFloatSmaller(pt.y, rcListItem.bottom)) { bLast = false; } if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) { return i; } } } if (bFirst) return 0; if (bLast) return m_aListItems.GetSize() - 1; return -1; }
void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { if (!IsFloatEqual(m_ptScrollPos.y, fy)) { CFX_FloatRect rcPlate = GetPlateRect(); CFX_FloatRect rcContent = GetContentRectInternal(); if (rcPlate.Height() > rcContent.Height()) { fy = rcPlate.top; } else { if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { fy = rcContent.bottom + rcPlate.Height(); } else if (IsFloatBigger(fy, rcContent.top)) { fy = rcContent.top; } } m_ptScrollPos.y = fy; InvalidateItem(-1); if (m_pNotify) { if (!m_bNotifyFlag) { m_bNotifyFlag = true; m_pNotify->IOnSetScrollPosY(fy); m_bNotifyFlag = false; } } } }
void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) { if (!m_pList) return; if (bPopup == m_bPopup) return; FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); if (!IsFloatBigger(fListHeight,0.0f)) return; if (bPopup) { if (m_pFillerNotify) { FX_INT32 nWhere = 0; FX_FLOAT fPopupRet = 0.0f; FX_FLOAT fPopupMin = 0.0f; if (m_pList->GetCount() > 3) fPopupMin = m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2; m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin,fPopupMax,nWhere,fPopupRet); if (IsFloatBigger(fPopupRet,0.0f)) { m_bPopup = bPopup; CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect(); m_rcOldWindow = rcWindow; switch (nWhere) { default: case 0: rcWindow.bottom -= fPopupRet; break; case 1: rcWindow.top += fPopupRet; break; } m_nPopupWhere = nWhere; Move(rcWindow, TRUE, TRUE); } } } else { m_bPopup = bPopup; Move(m_rcOldWindow, TRUE, TRUE); } }
CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const { ASSERT(m_pVT); CPVT_WordPlace place = GetBeginWordPlace(); bool bUp = true; bool bDown = true; int32_t nLeft = 0; int32_t nRight = m_LineArray.GetSize() - 1; int32_t nMid = m_LineArray.GetSize() / 2; FX_FLOAT fTop = 0; FX_FLOAT fBottom = 0; while (nLeft <= nRight) { if (CLine* pLine = m_LineArray.GetAt(nMid)) { fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_pVT->GetLineLeading(m_SecInfo); fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; if (IsFloatBigger(point.y, fTop)) { bUp = false; } if (IsFloatSmaller(point.y, fBottom)) { bDown = false; } if (IsFloatSmaller(point.y, fTop)) { nRight = nMid - 1; nMid = (nLeft + nRight) / 2; continue; } else if (IsFloatBigger(point.y, fBottom)) { nLeft = nMid + 1; nMid = (nLeft + nRight) / 2; continue; } else { place = SearchWordPlace( point.x, CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()), pLine->GetEndWordPlace())); place.nLineIndex = nMid; return place; } } } if (bUp) { place = GetBeginWordPlace(); } if (bDown) { place = GetEndWordPlace(); } return place; }
void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) { if (!IsValid(nItemIndex)) return; CFX_FloatRect rcPlate = GetPlateRect(); CFX_FloatRect rcItem = GetItemRectInternal(nItemIndex); CFX_FloatRect rcItemCtrl = GetItemRect(nItemIndex); if (IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) { if (IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) { SetScrollPosY(rcItem.bottom + rcPlate.Height()); } } else if (IsFloatBigger(rcItemCtrl.top, rcPlate.top)) { if (IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) { SetScrollPosY(rcItem.top); } } }
CPVT_WordPlace CPDF_VariableText::SearchWordPlace( const CFX_FloatPoint& point) const { CFX_FloatPoint pt = OutToIn(point); CPVT_WordPlace place = GetBeginWordPlace(); int32_t nLeft = 0; int32_t nRight = m_SectionArray.GetSize() - 1; int32_t nMid = m_SectionArray.GetSize() / 2; FX_BOOL bUp = TRUE; FX_BOOL bDown = TRUE; while (nLeft <= nRight) { if (CSection* pSection = m_SectionArray.GetAt(nMid)) { if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { bUp = FALSE; } if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { bDown = FALSE; } if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) { nRight = nMid - 1; nMid = (nLeft + nRight) / 2; continue; } else if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom)) { nLeft = nMid + 1; nMid = (nLeft + nRight) / 2; continue; } else { place = pSection->SearchWordPlace( CFX_FloatPoint(pt.x - pSection->m_SecInfo.rcSection.left, pt.y - pSection->m_SecInfo.rcSection.top)); place.nSecIndex = nMid; return place; } } else { break; } } if (bUp) place = GetBeginWordPlace(); if (bDown) place = GetEndWordPlace(); return place; }
void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { ShowVScrollBar(FALSE); } else { ShowVScrollBar(TRUE); } }