本文整理汇总了C++中CPDF_FormControl类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_FormControl类的具体用法?C++ CPDF_FormControl怎么用?C++ CPDF_FormControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_FormControl类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
FX_DWORD dwFlags) {
ASSERT(pPageView != NULL);
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
CPDF_FormControl* pCtrl = pWidget->GetFormControl();
CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
if (eHM == CPDF_FormControl::Push) {
if (m_bMouseDown) {
if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
else
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal,
NULL);
} else if (m_bMouseIn) {
if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover))
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover,
NULL);
else
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal,
NULL);
} else {
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
} else
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
示例2: GetControlAtPoint
CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
const CFX_PointF& point,
int* z_order) const {
CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayFor("Annots");
if (!pAnnotList)
return nullptr;
for (size_t i = pAnnotList->GetCount(); i > 0; --i) {
size_t annot_index = i - 1;
CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index);
if (!pAnnot)
continue;
const auto it = m_ControlMap.find(pAnnot);
if (it == m_ControlMap.end())
continue;
CPDF_FormControl* pControl = it->second.get();
if (!pControl->GetRect().Contains(point))
continue;
if (z_order)
*z_order = static_cast<int>(annot_index);
return pControl;
}
return nullptr;
}
示例3: FPDPage_HasFormFieldAtPoint
DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,double page_x, double page_y)
{
if(!page || !hHandle)
return -1;
CPDF_Page * pPage = (CPDF_Page*) page;
CPDF_InterForm * pInterForm = NULL;
pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE);
if (!pInterForm)
return -1;
CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
if(!pFormCtrl)
{
delete pInterForm;
return -1;
}
CPDF_FormField* pFormField = pFormCtrl->GetField();
if(!pFormField)
{
delete pInterForm;
return -1;
}
int nType = pFormField->GetFieldType();
delete pInterForm;
return nType;
}
示例4: ASSERT
FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
FX_BOOL bDefault,
FX_BOOL bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
CFX_WideString csExport = pControl->GetExportValue();
if (csExport == value) {
if (bDefault) {
} else {
CheckControl(GetControlIndex(pControl), TRUE);
}
break;
} else {
if (bDefault) {
} else {
CheckControl(GetControlIndex(pControl), FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
m_pForm->m_bUpdated = TRUE;
return TRUE;
}
示例5: SaveCheckedFieldStatus
void SaveCheckedFieldStatus(CPDF_FormField* pField,
CFX_ByteArray& statusArray) {
int iCount = pField->CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = pField->GetControl(i);
if (!pControl) {
continue;
}
statusArray.Add(pControl->IsChecked() ? 1 : 0);
}
}
示例6: ASSERT
CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) const {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CFX_WideString csExport = L"Off";
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
FX_BOOL bChecked =
bDefault ? pControl->IsDefaultChecked() : pControl->IsChecked();
if (bChecked) {
csExport = pControl->GetExportValue();
break;
}
}
return csExport;
}
示例7: switch
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
int iCount = CountControls();
if (iCount) {
if (PDF_FormField_IsUnison(this)) {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
} else {
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
FX_BOOL bChecked = pControl->IsDefaultChecked();
CheckControl(i, bChecked, FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
} break;
case CPDF_FormField::ListBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterSelectionChange(this);
}
} break;
case CPDF_FormField::Text:
case CPDF_FormField::RichText:
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV");
CFX_WideString csDValue;
if (pDV) {
csDValue = pDV->GetUnicodeText();
}
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
CFX_WideString csValue;
if (pV) {
csValue = pV->GetUnicodeText();
}
CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV");
if (!pRV && (csDValue == csValue)) {
return FALSE;
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue);
if (iRet < 0) {
return FALSE;
}
}
if (pDV) {
CPDF_Object* pClone = pDV->Clone();
if (!pClone) {
return FALSE;
}
m_pDict->SetAt("V", pClone);
if (pRV) {
CPDF_Object* pCloneR = pDV->Clone();
m_pDict->SetAt("RV", pCloneR);
}
} else {
m_pDict->RemoveAt("V");
m_pDict->RemoveAt("RV");
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
m_pForm->m_bUpdated = TRUE;
//.........这里部分代码省略.........
示例8: FPDFPage_HasFormFieldAtPoint
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
double page_x,
double page_y) {
if (!hHandle)
return -1;
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (pPage) {
CPDF_InterForm interform(pPage->m_pDocument, FALSE);
CPDF_FormControl* pFormCtrl =
interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x),
static_cast<FX_FLOAT>(page_y), nullptr);
if (!pFormCtrl)
return -1;
CPDF_FormField* pFormField = pFormCtrl->GetField();
return pFormField ? pFormField->GetFieldType() : -1;
}
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page);
if (!pXFAPage)
return -1;
IXFA_PageView* pPageView = pXFAPage->GetXFAPageView();
if (!pPageView)
return -1;
IXFA_DocView* pDocView = pPageView->GetDocView();
if (!pDocView)
return -1;
IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
if (!pWidgetHandler)
return -1;
std::unique_ptr<IXFA_WidgetIterator, ReleaseDeleter<IXFA_WidgetIterator>>
pWidgetIterator(pPageView->CreateWidgetIterator(
XFA_TRAVERSEWAY_Form,
XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_AllType));
if (!pWidgetIterator)
return -1;
IXFA_Widget* pXFAAnnot = pWidgetIterator->MoveToNext();
while (pXFAAnnot) {
CFX_RectF rcBBox;
pWidgetHandler->GetBBox(pXFAAnnot, rcBBox, 0);
CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
rcBBox.top + rcBBox.height);
rcWidget.left -= 1.0f;
rcWidget.right += 1.0f;
rcWidget.bottom -= 1.0f;
rcWidget.top += 1.0f;
if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x),
static_cast<FX_FLOAT>(page_y))) {
return FPDF_FORMFIELD_XFA;
}
pXFAAnnot = pWidgetIterator->MoveToNext();
}
#endif // PDF_ENABLE_XFA
return -1;
}