From 8f4bf9a8ac211e150f7fa4d8ed061f264cb3aa9e Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 4 May 2016 13:51:51 -0700 Subject: More define cleanup. This CL converts defines into constants, enums, enum classes or removes them as needed. Review-Url: https://codereview.chromium.org/1938163002 --- core/fpdftext/fpdf_text_int.cpp | 150 +++------------- core/fpdftext/include/cpdf_textpage.h | 21 ++- fpdfsdk/fpdftext.cpp | 5 +- fpdfsdk/fxedit/fxet_edit.cpp | 8 +- fpdfsdk/fxedit/fxet_pageobjs.cpp | 3 - xfa/fwl/basewidget/fwl_checkboximp.cpp | 23 +-- xfa/fwl/basewidget/fwl_comboboximp.cpp | 40 ++--- xfa/fwl/basewidget/fwl_datetimepickerimp.cpp | 32 ++-- xfa/fwl/basewidget/fwl_editimp.cpp | 38 ++-- xfa/fwl/basewidget/fwl_listboximp.cpp | 18 +- xfa/fwl/basewidget/fwl_monthcalendarimp.cpp | 8 +- xfa/fwl/basewidget/fwl_pushbuttonimp.cpp | 12 +- xfa/fwl/basewidget/fwl_scrollbarimp.cpp | 11 +- xfa/fwl/basewidget/fwl_spinbuttonimp.cpp | 24 +-- xfa/fwl/basewidget/ifwl_barcode.h | 30 ++-- xfa/fwl/core/cfwl_event.h | 9 +- xfa/fwl/core/cfwl_message.h | 53 ++---- xfa/fwl/core/fwl_formimp.cpp | 56 +++--- xfa/fwl/core/fwl_noteimp.cpp | 22 +-- xfa/fwl/core/fwl_noteimp.h | 16 +- xfa/fwl/core/fwl_widgetmgrimp.cpp | 156 ++++++++-------- xfa/fwl/lightwidget/cfwl_barcode.h | 43 ++--- xfa/fwl/theme/cfwl_scrollbartp.cpp | 10 +- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 2 +- xfa/fxfa/app/xfa_fffield.cpp | 32 ++-- xfa/fxfa/app/xfa_ffimageedit.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 4 +- xfa/fxfa/include/fxfa.h | 228 ++++++++++++------------ xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp | 84 ++++----- xfa/fxfa/parser/xfa_script_eventpseudomodel.h | 38 ++-- 30 files changed, 554 insertions(+), 624 deletions(-) diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp index b3558ff2a8..8e5e75853e 100644 --- a/core/fpdftext/fpdf_text_int.cpp +++ b/core/fpdftext/fpdf_text_int.cpp @@ -28,10 +28,6 @@ #include "core/fxcrt/include/fx_ucd.h" #include "third_party/base/stl_util.h" -#define FPDFTEXT_RLTB 1 -#define FPDFTEXT_LEFT -1 -#define FPDFTEXT_RIGHT 1 - #define FPDFTEXT_MATCHCASE 0x00000001 #define FPDFTEXT_MATCHWHOLEWORD 0x00000002 #define FPDFTEXT_CONSECUTIVE 0x00000004 @@ -42,9 +38,15 @@ #define FPDFTEXT_CHAR_UNUNICODE 2 #define FPDFTEXT_CHAR_HYPHEN 3 #define FPDFTEXT_CHAR_PIECE 4 -#define FPDFTEXT_MC_PASS 0 -#define FPDFTEXT_MC_DONE 1 -#define FPDFTEXT_MC_DELAY 2 + +#define TEXT_BLANK_CHAR L' ' +#define TEXT_LINEFEED_CHAR L'\n' +#define TEXT_RETURN_CHAR L'\r' +#define TEXT_EMPTY L"" +#define TEXT_BLANK L" " +#define TEXT_RETURN_LINEFEED L"\r\n" +#define TEXT_LINEFEED L"\n" +#define TEXT_CHARRATIO_GAPDELTA 0.070 namespace { @@ -143,16 +145,7 @@ FX_STRSIZE Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) { } // namespace -#define TEXT_BLANK_CHAR L' ' -#define TEXT_LINEFEED_CHAR L'\n' -#define TEXT_RETURN_CHAR L'\r' -#define TEXT_EMPTY L"" -#define TEXT_BLANK L" " -#define TEXT_RETURN_LINEFEED L"\r\n" -#define TEXT_LINEFEED L"\n" -#define TEXT_CHARRATIO_GAPDELTA 0.070 - -CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) +CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags) : m_pPage(pPage), m_parserflag(flags), m_pPreTextObj(nullptr), @@ -613,42 +606,6 @@ void CPDF_TextPage::GetRect(int rectIndex, bottom = m_SelRects[rectIndex].bottom; } -FX_BOOL CPDF_TextPage::GetBaselineRotate(int start, int end, int& Rotate) { - if (end == start) { - return FALSE; - } - FPDF_CHAR_INFO info_start; - FPDF_CHAR_INFO info_end; - GetCharInfo(start, &info_start); - GetCharInfo(end, &info_end); - while (info_end.m_CharBox.Width() == 0 || info_end.m_CharBox.Height() == 0) { - if (--end <= start) - return FALSE; - - GetCharInfo(end, &info_end); - } - FX_FLOAT dx = (info_end.m_OriginX - info_start.m_OriginX); - FX_FLOAT dy = (info_end.m_OriginY - info_start.m_OriginY); - if (dx == 0) { - if (dy > 0) { - Rotate = 90; - } else if (dy < 0) { - Rotate = 270; - } else { - Rotate = 0; - } - } else { - float a = FXSYS_atan2(dy, dx); - Rotate = (int)(a * 180 / FX_PI + 0.5); - } - if (Rotate < 0) { - Rotate = -Rotate; - } else if (Rotate > 0) { - Rotate = 360 - Rotate; - } - return TRUE; -} - int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOAT right, @@ -727,38 +684,6 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, return m_Segments.GetSize(); } -int CPDF_TextPage::GetWordBreak(int index, int direction) const { - if (!m_bIsParsed) - return -1; - - if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT) - return -1; - - if (index < 0 || index >= pdfium::CollectionSize(m_CharList)) - return -1; - - const PAGECHAR_INFO& charinfo = m_CharList[index]; - if (charinfo.m_Index == -1 || charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { - return index; - } - if (!IsLetter(charinfo.m_Unicode)) { - return index; - } - int breakPos = index; - if (direction == FPDFTEXT_LEFT) { - while (--breakPos > 0) { - if (!IsLetter(m_CharList[breakPos].m_Unicode)) - break; - } - } else if (direction == FPDFTEXT_RIGHT) { - while (++breakPos < pdfium::CollectionSize(m_CharList)) { - if (!IsLetter(m_CharList[breakPos].m_Unicode)) - break; - } - } - return breakPos; -} - int32_t CPDF_TextPage::FindTextlineFlowDirection() { const int32_t nPageWidth = static_cast(m_pPage->GetPageWidth()); const int32_t nPageHeight = static_cast(m_pPage->GetPageHeight()); @@ -905,21 +830,6 @@ int CPDF_TextPage::GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const { return pFont->GetCharBBox(charCode).Width(); } -void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) { - CFX_BidiChar::Segment seg = pBidi->GetSegmentInfo(); - if (seg.direction == CFX_BidiChar::RIGHT) { - for (int i = seg.start + seg.count; i > seg.start; i--) { - m_TextBuf.AppendChar(str.GetAt(i - 1)); - m_CharList.push_back(m_TempCharList[i - 1]); - } - } else { - for (int i = seg.start; i < seg.start + seg.count; i++) { - m_TextBuf.AppendChar(str.GetAt(i)); - m_CharList.push_back(m_TempCharList[i]); - } - } -} - void CPDF_TextPage::AddCharInfoByLRDirection(FX_WCHAR wChar, PAGECHAR_INFO info) { if (!IsControlChar(info)) { @@ -996,7 +906,7 @@ void CPDF_TextPage::CloseTempLine() { bPrevSpace = TRUE; } CFX_BidiString bidi(str); - if (m_parserflag == FPDFTEXT_RLTB) + if (m_parserflag == FPDFText_Direction::Right) bidi.SetOverallDirectionRight(); CFX_BidiChar::Direction eCurrentDirection = bidi.OverallDirection(); for (const auto& segment : bidi) { @@ -1098,16 +1008,17 @@ void CPDF_TextPage::ProcessTextObject( } } -int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { +FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { CPDF_TextObject* pTextObj = Obj.m_pTextObj; CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); if (!pMarkData) - return FPDFTEXT_MC_PASS; + return FPDFText_MarkedContent::Pass; int nContentMark = pMarkData->CountItems(); if (nContentMark < 1) - return FPDFTEXT_MC_PASS; + return FPDFText_MarkedContent::Pass; + CFX_WideString actText; FX_BOOL bExist = FALSE; CPDF_Dictionary* pDict = NULL; @@ -1125,19 +1036,19 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { } } if (!bExist) - return FPDFTEXT_MC_PASS; + return FPDFText_MarkedContent::Pass; if (m_pPreTextObj) { CPDF_ContentMarkData* pPreMarkData = (CPDF_ContentMarkData*)m_pPreTextObj->m_ContentMark.GetObject(); if (pPreMarkData && pPreMarkData->CountItems() == n && pDict == pPreMarkData->GetItem(n - 1).GetParam()) { - return FPDFTEXT_MC_DONE; + return FPDFText_MarkedContent::Done; } } FX_STRSIZE nItems = actText.GetLength(); if (nItems < 1) - return FPDFTEXT_MC_PASS; + return FPDFText_MarkedContent::Pass; CPDF_Font* pFont = pTextObj->GetFont(); bExist = FALSE; @@ -1149,7 +1060,7 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { } } if (!bExist) - return FPDFTEXT_MC_PASS; + return FPDFText_MarkedContent::Pass; bExist = FALSE; for (FX_STRSIZE i = 0; i < nItems; i++) { @@ -1160,9 +1071,9 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { } } if (!bExist) - return FPDFTEXT_MC_DONE; + return FPDFText_MarkedContent::Done; - return FPDFTEXT_MC_DELAY; + return FPDFText_MarkedContent::Delay; } void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { @@ -1285,8 +1196,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { CFX_Matrix matrix; pTextObj->GetTextMatrix(&matrix); matrix.Concat(formMatrix); - int32_t bPreMKC = PreMarkedContent(Obj); - if (FPDFTEXT_MC_DONE == bPreMKC) { + FPDFText_MarkedContent ePreMKC = PreMarkedContent(Obj); + if (ePreMKC == FPDFText_MarkedContent::Done) { m_pPreTextObj = pTextObj; m_perMatrix.Copy(formMatrix); return; @@ -1362,7 +1273,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); } - if (FPDFTEXT_MC_DELAY == bPreMKC) { + if (ePreMKC == FPDFText_MarkedContent::Delay) { ProcessMarkedContent(Obj); m_pPreTextObj = pTextObj; m_perMatrix.Copy(formMatrix); @@ -1879,19 +1790,6 @@ FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, return !rect.IsEmpty(); } -FX_BOOL CPDF_TextPage::IsLetter(FX_WCHAR unicode) { - if (unicode < L'A') { - return FALSE; - } - if (unicode > L'Z' && unicode < L'a') { - return FALSE; - } - if (unicode > L'z') { - return FALSE; - } - return TRUE; -} - CPDF_TextPageFind::CPDF_TextPageFind(const CPDF_TextPage* pTextPage) : m_pTextPage(pTextPage), m_flags(0), diff --git a/core/fpdftext/include/cpdf_textpage.h b/core/fpdftext/include/cpdf_textpage.h index 1a60a2351d..c7c673c23e 100644 --- a/core/fpdftext/include/cpdf_textpage.h +++ b/core/fpdftext/include/cpdf_textpage.h @@ -21,6 +21,10 @@ class CPDF_FormObject; class CPDF_Page; class CPDF_TextObject; +enum class FPDFText_MarkedContent { Pass = 0, Done, Delay }; + +enum class FPDFText_Direction { Left = -1, Right = 1 }; + struct FPDF_CHAR_INFO { FX_WCHAR m_Unicode; FX_WCHAR m_Charcode; @@ -57,7 +61,10 @@ struct PDFTEXT_Obj { class CPDF_TextPage { public: - CPDF_TextPage(const CPDF_Page* pPage, int flags); + static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1, + const CFX_FloatRect& rect2); + + CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags); ~CPDF_TextPage() {} // IPDF_TextPage: @@ -91,16 +98,9 @@ class CPDF_TextPage { FX_FLOAT bottom, FX_BOOL bContains = FALSE); - int GetWordBreak(int index, int direction) const; - - static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1, - const CFX_FloatRect& rect2); - static FX_BOOL IsLetter(FX_WCHAR unicode); - private: FX_BOOL IsHyphen(FX_WCHAR curChar); bool IsControlChar(const PAGECHAR_INFO& charInfo); - FX_BOOL GetBaselineRotate(int start, int end, int& Rotate); void ProcessObject(); void ProcessFormObject(CPDF_FormObject* pFormObj, const CFX_Matrix& formMatrix); @@ -119,8 +119,7 @@ class CPDF_TextPage { CPDF_TextObject* pTextObj2); int GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const; void CloseTempLine(); - void OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str); - int32_t PreMarkedContent(PDFTEXT_Obj pObj); + FPDFText_MarkedContent PreMarkedContent(PDFTEXT_Obj pObj); void ProcessMarkedContent(PDFTEXT_Obj pObj); void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const; void FindPreviousTextObject(void); @@ -140,7 +139,7 @@ class CPDF_TextPage { std::deque m_TempCharList; CFX_WideTextBuf m_TextBuf; CFX_WideTextBuf m_TempTextBuf; - const int m_parserflag; + const FPDFText_Direction m_parserflag; CPDF_TextObject* m_pPreTextObj; CFX_Matrix m_perMatrix; bool m_bIsParsed; diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp index 4d521da8ed..1596fd2584 100644 --- a/fpdfsdk/fpdftext.cpp +++ b/fpdfsdk/fpdftext.cpp @@ -53,8 +53,9 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) { CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument); #endif // PDF_ENABLE_XFA - CPDF_TextPage* textpage = - new CPDF_TextPage(pPDFPage, viewRef.IsDirectionR2L()); + CPDF_TextPage* textpage = new CPDF_TextPage( + pPDFPage, viewRef.IsDirectionR2L() ? FPDFText_Direction::Right + : FPDFText_Direction::Left); textpage->ParseTextPage(); return textpage; } diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index bdd2c75325..f2ff300452 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -13,7 +13,11 @@ #include "core/fpdfdoc/include/cpvt_word.h" #include "core/fpdfdoc/include/ipvt_fontmap.h" -#define FX_EDIT_UNDO_MAXITEM 10000 +namespace { + +const int kEditUndoMaxItems = 10000; + +} // namespace CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, CPDF_VariableText::Iterator* pVTIterator) @@ -755,7 +759,7 @@ CFX_Edit::CFX_Edit(CPDF_VariableText* pVT) m_bEnableScroll(FALSE), m_pIterator(NULL), m_ptCaret(0.0f, 0.0f), - m_Undo(FX_EDIT_UNDO_MAXITEM), + m_Undo(kEditUndoMaxItems), m_nAlignment(0), m_bNotifyFlag(FALSE), m_bEnableOverflow(FALSE), diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp index b28cf84efd..b862e7396d 100644 --- a/fpdfsdk/fxedit/fxet_pageobjs.cpp +++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp @@ -17,9 +17,6 @@ #include "fpdfsdk/fxedit/include/fx_edit.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" -#define FX_EDIT_UNDERLINEHALFWIDTH 0.5f -#define FX_EDIT_CROSSOUTHALFWIDTH 0.5f - CFX_FloatRect GetUnderLineRect(const CPVT_Word& word) { return CFX_FloatRect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f, word.ptWord.x + word.fWidth, diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/basewidget/fwl_checkboximp.cpp index f11a917eb1..ba63e2f663 100644 --- a/xfa/fwl/basewidget/fwl_checkboximp.cpp +++ b/xfa/fwl/basewidget/fwl_checkboximp.cpp @@ -18,7 +18,11 @@ #include "xfa/fwl/core/fwl_widgetmgrimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" -#define FWL_CKB_CaptionMargin 5 +namespace { + +const int kCaptionMargin = 5; + +} // namespace // static IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, @@ -84,7 +88,7 @@ FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); rect.Set(0, 0, sz.x, sz.y); } - rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin); + rect.Inflate(kCaptionMargin, kCaptionMargin); IFWL_CheckBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); @@ -241,7 +245,7 @@ void CFWL_CheckBoxImp::Layout() { m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox); m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, m_rtClient.height); - m_rtCaption.Inflate(-FWL_CKB_CaptionMargin, -FWL_CKB_CaptionMargin); + m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin); CFX_RectF rtFocus; rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, m_rtCaption.height); @@ -429,21 +433,20 @@ int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + switch (pMsg->m_dwCmd) { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMsg); break; } @@ -454,7 +457,7 @@ int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) + if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) OnKeyDown(pKey); break; } diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp index 35ac5fa240..e86a52eaa0 100644 --- a/xfa/fwl/basewidget/fwl_comboboximp.cpp +++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp @@ -159,7 +159,7 @@ int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); - if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) && + if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) && ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { m_pOwner->SetSelected(); m_pOwner->SetComboBoxFocus(TRUE); @@ -308,24 +308,24 @@ int32_t CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { return pDelegate->OnProcessMessage(pMsg); } } - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_MouseMove: { + switch (pMsg->m_dwCmd) { + case FWL_MouseCommand::Move: { backDefault = FALSE; OnDropListMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { backDefault = FALSE; OnDropListLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { backDefault = FALSE; OnDropListLButtonUp(pMsg); break; } - default: {} + default: + break; } } else if (dwHashCode == CFWL_MessageType::Key) { backDefault = !OnDropListKey(static_cast(pMessage)); @@ -415,7 +415,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) { CFWL_ComboBoxImp* pOuter = static_cast(m_pOwner->m_pOuter->GetImpl()); FX_BOOL bPropagate = FALSE; - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { uint32_t dwKeyCode = pKey->m_dwKeyCode; switch (dwKeyCode) { case FWL_VKEY_Return: @@ -432,7 +432,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) { } default: { bPropagate = TRUE; } } - } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) { + } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) { bPropagate = TRUE; } if (bPropagate) { @@ -1381,19 +1381,19 @@ int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMsg); break; } @@ -1615,11 +1615,11 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( backDefault = FALSE; CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { DisForm_OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } @@ -1631,10 +1631,10 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( case CFWL_MessageType::Key: { backDefault = FALSE; CFWL_MsgKey* pKey = static_cast(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) + if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) break; if (m_pOwner->DisForm_IsDropListShowed() && - pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || pKey->m_dwKeyCode == FWL_VKEY_Down || pKey->m_dwKeyCode == FWL_VKEY_Return || @@ -1758,15 +1758,15 @@ int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp index 84a4437fff..7cefdc3477 100644 --- a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp +++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp @@ -18,8 +18,12 @@ #include "xfa/fwl/core/fwl_widgetmgrimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" -#define FWL_DTP_WIDTH 100 -#define FWL_DTP_HEIGHT 20 +namespace { + +const int kDateTimePickerWidth = 100; +const int kDateTimePickerHeight = 20; + +} // namespace // static IFWL_DateTimePicker* IFWL_DateTimePicker::Create( @@ -189,8 +193,8 @@ int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { if (dwHashCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMouse = static_cast(pMessage); - if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || - pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) { + if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || + pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; } @@ -244,10 +248,10 @@ int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( return pDelegate->OnProcessMessage(pMessage); } else if (dwCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast(pMessage); - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { + if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { OnLButtonDownEx(pMsg); return 1; - } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { + } else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { OnLButtonUpEx(pMsg); return 1; } @@ -375,7 +379,7 @@ int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( CFWL_Message* pMessage) { if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast(pMessage); - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { + if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { DisForm_OnLButtonUpEx(pMsg); return 1; } @@ -487,7 +491,7 @@ FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect, return DisForm_GetWidgetRect(rect, bAutoSize); } if (bAutoSize) { - rect.Set(0, 0, FWL_DTP_WIDTH, FWL_DTP_HEIGHT); + rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); CFWL_WidgetImp::GetWidgetRect(rect, TRUE); } else { rect = m_pProperties->m_rtWidget; @@ -531,7 +535,7 @@ FWL_ERR CFWL_DateTimePickerImp::Update() { CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, + rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, rtMonthCal.width, rtMonthCal.height); m_pMonthCal->SetWidgetRect(rtPopUp); m_pMonthCal->Update(); @@ -957,7 +961,7 @@ FWL_ERR CFWL_DateTimePickerImp::DisForm_Update() { CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, + rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, rtMonthCal.width, rtMonthCal.height); m_pMonthCal->SetWidgetRect(rtPopUp); m_pMonthCal->Update(); @@ -1033,19 +1037,19 @@ int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMouse = static_cast(pMessage); switch (pMouse->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMouse); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMouse); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMouse); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMouse); break; } diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index a80b89f9a7..8deec9beb2 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -32,6 +32,8 @@ namespace { +const int kEditMargin = 3; + bool FX_EDIT_ISLATINWORD(FX_WCHAR c) { return c == 0x2D || (c <= 0x005A && c >= 0x0041) || (c <= 0x007A && c >= 0x0061) || (c <= 0x02AF && c >= 0x00C0) || @@ -195,7 +197,7 @@ FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, return static_cast(GetImpl()) ->ReplaceSpellCheckWord(pointf, bsReplace); } -#define FWL_EDIT_Margin 3 + CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_WidgetImp(properties, pOuter), @@ -282,13 +284,13 @@ FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { FX_FLOAT* pfWidth = static_cast( GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); rect.width += *pfWidth; - rect.width += FWL_EDIT_Margin; + rect.width += kEditMargin; } if (IsShowScrollBar(FALSE)) { FX_FLOAT* pfWidth = static_cast( GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); rect.height += *pfWidth; - rect.height += FWL_EDIT_Margin; + rect.height += kEditMargin; } } } @@ -1473,8 +1475,8 @@ void CFWL_EditImp::Layout() { InitScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top, - fWidth, m_rtClient.height); + rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, + m_rtClient.height); } else { rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height); @@ -1493,7 +1495,7 @@ void CFWL_EditImp::Layout() { InitScrollBar(FALSE); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin, + rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, m_rtClient.width, fWidth); } else { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, @@ -1526,8 +1528,8 @@ void CFWL_EditImp::LayoutScrollBar() { InitScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top, - fWidth, m_rtClient.height); + rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, + m_rtClient.height); } else { rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height); @@ -1552,7 +1554,7 @@ void CFWL_EditImp::LayoutScrollBar() { InitScrollBar(FALSE); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin, + rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, m_rtClient.width, fWidth); } else { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, @@ -1735,25 +1737,24 @@ int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + switch (pMsg->m_dwCmd) { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonDblClk: { + case FWL_MouseCommand::LeftButtonDblClk: { OnButtonDblClk(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_RButtonDown: { + case FWL_MouseCommand::RightButtonDown: { DoButtonDown(pMsg); break; } @@ -1764,10 +1765,9 @@ int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast(pMessage); - uint32_t dwCmd = pKey->m_dwCmd; - if (dwCmd == FWL_MSGKEYCMD_KeyDown) + if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) OnKeyDown(pKey); - else if (dwCmd == FWL_MSGKEYCMD_Char) + else if (pKey->m_dwCmd == FWL_KeyCommand::Char) OnChar(pKey); break; } diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/basewidget/fwl_listboximp.cpp index d514f7e1e3..b2a4e2c20c 100644 --- a/xfa/fwl/basewidget/fwl_listboximp.cpp +++ b/xfa/fwl/basewidget/fwl_listboximp.cpp @@ -17,7 +17,11 @@ #include "xfa/fwl/core/fwl_widgetimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" -#define FWL_LISTBOX_ItemTextMargin 2 +namespace { + +const int kItemTextMargin = 2; + +} // namespace // static IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, @@ -699,7 +703,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, return; } CFX_RectF rtText(rtItem); - rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); + rtText.Deflate(kItemTextMargin, kItemTextMargin); if (bHasIcon || bHasCheck) { rtText.Deflate(rtItem.height, 0, 0, 0); } @@ -765,7 +769,7 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { } } else { fWidth = GetMaxTextWidth(); - fWidth += 2 * FWL_LISTBOX_ItemTextMargin; + fWidth += 2 * kItemTextMargin; if (!bAutoSize) { FX_FLOAT fActualWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; @@ -935,7 +939,7 @@ FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { static_cast(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); if (!pfFont) return 20; - return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin; + return *pfFont + 2 * kItemTextMargin; } void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { @@ -999,11 +1003,11 @@ int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } @@ -1018,7 +1022,7 @@ int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Key: { CFWL_MsgKey* pMsg = static_cast(pMessage); - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) + if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) OnKeyDown(pMsg); break; } diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp index 4b7f342bf7..3feb1122a7 100644 --- a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp +++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp @@ -1039,19 +1039,19 @@ int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMouse = static_cast(pMessage); switch (pMouse->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMouse); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMouse); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMouse); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMouse); break; } diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp index 9d6e3b19a9..b1e5f6bdb4 100644 --- a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp +++ b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp @@ -422,19 +422,19 @@ int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMsg); break; } @@ -445,7 +445,7 @@ int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) + if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) OnKeyDown(pKey); break; } @@ -544,7 +544,7 @@ void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { CFWL_EvtMouse wmMouse; wmMouse.m_pSrcTarget = m_pOwner->m_pInterface; - wmMouse.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; + wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; m_pOwner->DispatchEvent(&wmMouse); CFWL_EvtClick wmClick; wmClick.m_pSrcTarget = m_pOwner->m_pInterface; diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp index 69c28959d9..0db7c29e9d 100644 --- a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp @@ -636,21 +636,20 @@ int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { CFWL_MessageType dwMsgCode = pMessage->GetClassID(); if (dwMsgCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + switch (pMsg->m_dwCmd) { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(); break; } diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp index 5692087762..9a70d7187d 100644 --- a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp @@ -16,9 +16,13 @@ #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_timer.h" -#define FWL_SPN_MinWidth 18 -#define FWL_SPN_MinHeight 32 -#define FWL_SPIN_Elapse 200 +namespace { + +const int kMinWidth = 18; +const int kMinHeight = 32; +const int kElapseTime = 200; + +} // namespace // static IFWL_SpinButton* IFWL_SpinButton::Create( @@ -75,7 +79,7 @@ FWL_ERR CFWL_SpinButtonImp::Finalize() { } FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { if (bAutoSize) { - rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight); + rect.Set(0, 0, kMinWidth, kMinHeight); CFWL_WidgetImp::GetWidgetRect(rect, TRUE); } else { rect = m_pProperties->m_rtWidget; @@ -218,19 +222,19 @@ int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMsg); break; } @@ -241,7 +245,7 @@ int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) + if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) OnKeyDown(pKey); break; } @@ -297,7 +301,7 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { m_pOwner->DispatchEvent(&wmPosChanged); m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton); - m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SPIN_Elapse); + m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, kElapseTime); } void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { diff --git a/xfa/fwl/basewidget/ifwl_barcode.h b/xfa/fwl/basewidget/ifwl_barcode.h index 4263177994..6cc4c59112 100644 --- a/xfa/fwl/basewidget/ifwl_barcode.h +++ b/xfa/fwl/basewidget/ifwl_barcode.h @@ -14,19 +14,23 @@ class CFWL_WidgetImpProperties; #define FWL_CLASS_Barcode L"FWL_BARCODE" #define FWL_CLASSHASH_Barcode 366886968 -#define FWL_BCDATTRIBUTE_CHARENCODING (1L << 0) -#define FWL_BCDATTRIBUTE_MODULEHEIGHT (1L << 1) -#define FWL_BCDATTRIBUTE_MODULEWIDTH (1L << 2) -#define FWL_BCDATTRIBUTE_DATALENGTH (1L << 3) -#define FWL_BCDATTRIBUTE_CALCHECKSUM (1L << 4) -#define FWL_BCDATTRIBUTE_PRINTCHECKSUM (1L << 5) -#define FWL_BCDATTRIBUTE_TEXTLOCATION (1L << 6) -#define FWL_BCDATTRIBUTE_WIDENARROWRATIO (1L << 7) -#define FWL_BCDATTRIBUTE_STARTCHAR (1L << 8) -#define FWL_BCDATTRIBUTE_ENDCHAR (1L << 9) -#define FWL_BCDATTRIBUTE_VERSION (1L << 10) -#define FWL_BCDATTRIBUTE_ECLEVEL (1L << 11) -#define FWL_BCDATTRIBUTE_TRUNCATED (1L << 12) + +enum FWL_BCDAttribute { + FWL_BCDATTRIBUTE_NONE = 0, + FWL_BCDATTRIBUTE_CHARENCODING = 1 << 0, + FWL_BCDATTRIBUTE_MODULEHEIGHT = 1 << 1, + FWL_BCDATTRIBUTE_MODULEWIDTH = 1 << 2, + FWL_BCDATTRIBUTE_DATALENGTH = 1 << 3, + FWL_BCDATTRIBUTE_CALCHECKSUM = 1 << 4, + FWL_BCDATTRIBUTE_PRINTCHECKSUM = 1 << 5, + FWL_BCDATTRIBUTE_TEXTLOCATION = 1 << 6, + FWL_BCDATTRIBUTE_WIDENARROWRATIO = 1 << 7, + FWL_BCDATTRIBUTE_STARTCHAR = 1 << 8, + FWL_BCDATTRIBUTE_ENDCHAR = 1 << 9, + FWL_BCDATTRIBUTE_VERSION = 1 << 10, + FWL_BCDATTRIBUTE_ECLEVEL = 1 << 11, + FWL_BCDATTRIBUTE_TRUNCATED = 1 << 12 +}; class IFWL_BarcodeDP : public IFWL_EditDP { public: diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h index d53fcb36dc..7af8cabbb2 100644 --- a/xfa/fwl/core/cfwl_event.h +++ b/xfa/fwl/core/cfwl_event.h @@ -10,6 +10,7 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" +#include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/fwl_error.h" enum class CFWL_EventType { @@ -47,7 +48,7 @@ enum class CFWL_EventType { Validate }; -typedef enum { +enum FWLEventMask { FWL_EVENT_MOUSE_MASK = 1 << 0, FWL_EVENT_MOUSEWHEEL_MASK = 1 << 1, FWL_EVENT_KEY_MASK = 1 << 2, @@ -58,7 +59,7 @@ typedef enum { FWL_EVENT_IDLE_MASK = 1 << 7, FWL_EVENT_CONTROL_MASK = 1 << 8, FWL_EVENT_ALL_MASK = 0xFF -} FWLEventMask; +}; class CFX_Graphics; class IFWL_Widget; @@ -107,7 +108,7 @@ BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, CFWL_EventType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; -uint32_t m_dwCmd; +FWL_MouseCommand m_dwCmd; END_FWL_EVENT_DEF BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, CFWL_EventType::MouseWheel) @@ -121,7 +122,7 @@ END_FWL_EVENT_DEF BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, CFWL_EventType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; -uint32_t m_dwCmd; +FWL_KeyCommand m_dwCmd; END_FWL_EVENT_DEF BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, CFWL_EventType::SetFocus) diff --git a/xfa/fwl/core/cfwl_message.h b/xfa/fwl/core/cfwl_message.h index e751824bc9..3a30c8fffd 100644 --- a/xfa/fwl/core/cfwl_message.h +++ b/xfa/fwl/core/cfwl_message.h @@ -31,38 +31,23 @@ enum class CFWL_MessageType { WindowWillMove }; -#define FWL_MSG_Activate L"FWL_MESSAGE_Activate" -#define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" -#define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus" -#define FWL_MSG_KillFocus L"FWL_MESSAGE_KillFocus" -#define FWL_MSG_Mouse L"FWL_MESSAGE_Mouse" -#define FWL_MSG_MouseWheel L"FWL_MESSAGE_MouseWheel" -#define FWL_MSG_Key L"FWL_MESSAGE_Key" -#define FWL_MSG_Cursor L"FWL_MESSAGE_Cursor" -#define FWL_MSG_Size L"FWL_MESSAGE_Size" -#define FWL_MSG_WindowMove L"FWL_MESSAGE_WindowMove" -#define FWL_MSG_DropFiles L"FWL_MESSAGE_DropFiles" -#define FWL_MSG_TaskClicked L"FWL_MESSAGE_TaskClicked" -#define FWL_MSG_Close L"FWL_MESSAGE_Close" -#define FWL_MSG_Post L"FWL_MESSAGE_Post" -#define FWL_MSG_WindowWillMove L"FWL_MESSAGE_WindowWillMove" - -#define FWL_MSGMOUSECMD_LButtonDown 1 -#define FWL_MSGMOUSECMD_LButtonUp 2 -#define FWL_MSGMOUSECMD_LButtonDblClk 3 -#define FWL_MSGMOUSECMD_RButtonDown 4 -#define FWL_MSGMOUSECMD_RButtonUp 5 -#define FWL_MSGMOUSECMD_RButtonDblClk 6 -#define FWL_MSGMOUSECMD_MButtonDown 7 -#define FWL_MSGMOUSECMD_MButtonUp 8 -#define FWL_MSGMOUSECMD_MButtonDblClk 9 -#define FWL_MSGMOUSECMD_MouseMove 10 -#define FWL_MSGMOUSECMD_MouseEnter 11 -#define FWL_MSGMOUSECMD_MouseLeave 12 -#define FWL_MSGMOUSECMD_MouseHover 13 -#define FWL_MSGKEYCMD_KeyDown 1 -#define FWL_MSGKEYCMD_KeyUp 2 -#define FWL_MSGKEYCMD_Char 3 +enum class FWL_MouseCommand { + LeftButtonDown, + LeftButtonUp, + LeftButtonDblClk, + RightButtonDown, + RightButtonUp, + RightButtonDblClk, + MiddleButtonDown, + MiddleButtonUp, + MiddleButtonDblClk, + Move, + Enter, + Leave, + Hover +}; + +enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; class IFWL_Widget; @@ -127,7 +112,7 @@ BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; -uint32_t m_dwCmd; +FWL_MouseCommand m_dwCmd; END_FWL_MESSAGE_DEF BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel) @@ -149,7 +134,7 @@ END_FWL_MESSAGE_DEF BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; -uint32_t m_dwCmd; +FWL_KeyCommand m_dwCmd; END_FWL_MESSAGE_DEF BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp index 9b91deb140..34663d7e0d 100644 --- a/xfa/fwl/core/fwl_formimp.cpp +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -21,9 +21,13 @@ #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/theme/cfwl_widgettp.h" -#define FWL_SYSBTNSIZE 21 -#define FWL_SYSBTNMARGIN 5 -#define FWL_SYSBTNSPAN 2 +namespace { + +const int kSystemButtonSize = 21; +const int kSystemButtonMargin = 5; +const int kSystemButtonSpan = 2; + +} // namespace namespace { @@ -207,7 +211,7 @@ FWL_WidgetHit CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { return FWL_WidgetHit::MinBox; CFX_RectF rtCap; rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, - m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder, + m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, m_rtCaption.height - m_fCXBorder); if (rtCap.Contains(fx, fy)) return FWL_WidgetHit::Titlebar; @@ -654,8 +658,8 @@ void CFWL_FormImp::ReSetSysBtn() { pTheme->GetPartRect(¶m, m_pCloseBox->m_rtBtn); } else { m_pCloseBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, + kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); } m_iSysBox++; } @@ -669,12 +673,12 @@ void CFWL_FormImp::ReSetSysBtn() { } else { if (m_pCloseBox) { m_pMaxBox->m_rtBtn.Set( - m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE, - m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, + m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); } else { m_pMaxBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, + kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); } } m_iSysBox++; @@ -689,16 +693,16 @@ void CFWL_FormImp::ReSetSysBtn() { } else { if (m_pMaxBox) { m_pMinBox->m_rtBtn.Set( - m_pMaxBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE, - m_pMaxBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_pMaxBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, + m_pMaxBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); } else if (m_pCloseBox) { m_pMinBox->m_rtBtn.Set( - m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE, - m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, + m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); } else { m_pMinBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, + kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); } } m_iSysBox++; @@ -912,30 +916,32 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { + case FWL_MouseCommand::LeftButtonDown: { OnLButtonDown(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonUp: { + case FWL_MouseCommand::LeftButtonUp: { OnLButtonUp(pMsg); break; } - case FWL_MSGMOUSECMD_MouseMove: { + case FWL_MouseCommand::Move: { OnMouseMove(pMsg); break; } - case FWL_MSGMOUSECMD_MouseHover: { + case FWL_MouseCommand::Hover: { OnMouseHover(pMsg); break; } - case FWL_MSGMOUSECMD_MouseLeave: { + case FWL_MouseCommand::Leave: { OnMouseLeave(pMsg); break; } - case FWL_MSGMOUSECMD_LButtonDblClk: { + case FWL_MouseCommand::LeftButtonDblClk: { OnLButtonDblClk(pMsg); break; } + default: + break; } break; } @@ -996,7 +1002,8 @@ void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { CFX_RectF rtCap; rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder, m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder, - m_pOwner->m_rtCaption.width - FWL_SYSBTNSIZE * m_pOwner->m_iSysBox - + m_pOwner->m_rtCaption.width - + kSystemButtonSize * m_pOwner->m_iSysBox - 2 * m_pOwner->m_fCYBorder, m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder); if (pPressBtn) { @@ -1121,8 +1128,7 @@ void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { pHover->SetNormal(); m_pOwner->Repaint(&pHover->m_rtBtn); } - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && - !m_pOwner->m_bLButtonDown) { + if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_pOwner->m_bLButtonDown) { m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); } } diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index 41e749fc9a..d73a49fa90 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -90,15 +90,15 @@ FX_BOOL CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { return TRUE; if (CFWL_EventType::Mouse == pNote->GetClassID()) { CFWL_EvtMouse* pMouse = static_cast(pNote); - if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) { + if (FWL_MouseCommand::Hover == pMouse->m_dwCmd) { if (m_pNoteLoop->GetForm() && CFWL_ToolTipContainer::getInstance()->ProcessEnter( pMouse, m_pNoteLoop->GetForm()->GetInterface())) { } - } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) { + } else if (FWL_MouseCommand::Leave == pMouse->m_dwCmd) { CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); - } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && - (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) { + } else if ((FWL_MouseCommand::LeftButtonDown <= pMouse->m_dwCmd) && + (FWL_MouseCommand::MiddleButtonDblClk >= pMouse->m_dwCmd)) { CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); } } @@ -536,7 +536,7 @@ FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, } FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { #if (_FX_OS_ != _FX_MACOSX_) - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && + if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Tab) { CFWL_WidgetMgr* pWidgetMgr = static_cast(FWL_GetWidgetMgr()); @@ -564,7 +564,7 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { } #endif if (!m_pFocus) { - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && + if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Return) { CFWL_WidgetMgr* pWidgetMgr = static_cast(FWL_GetWidgetMgr()); @@ -581,9 +581,9 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { } FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm) { - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave || - pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseHover || - pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) { + if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || + pMsg->m_dwCmd == FWL_MouseCommand::Hover || + pMsg->m_dwCmd == FWL_MouseCommand::Enter) { return pMsg->m_pDstTarget != NULL; } if (pMsg->m_pDstTarget != pMessageForm) { @@ -659,7 +659,7 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { msLeave.m_fy = pMsg->m_fy; pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); msLeave.m_dwFlags = 0; - msLeave.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave; + msLeave.m_dwCmd = FWL_MouseCommand::Leave; DispatchMessage(&msLeave, NULL); } if (pTarget->GetClassID() == FWL_CLASSHASH_Form) { @@ -672,7 +672,7 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { msHover.m_fx = pMsg->m_fx; msHover.m_fy = pMsg->m_fy; msHover.m_dwFlags = 0; - msHover.m_dwCmd = FWL_MSGMOUSECMD_MouseHover; + msHover.m_dwCmd = FWL_MouseCommand::Hover; DispatchMessage(&msHover, NULL); } FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h index 8607a334f1..723d2e5742 100644 --- a/xfa/fwl/core/fwl_noteimp.h +++ b/xfa/fwl/core/fwl_noteimp.h @@ -13,13 +13,15 @@ #include "xfa/fwl/core/ifwl_widget.h" #include "xfa/fxgraphics/include/cfx_graphics.h" -#define FWL_KEYFLAG_Ctrl (1 << 0) -#define FWL_KEYFLAG_Alt (1 << 1) -#define FWL_KEYFLAG_Shift (1 << 2) -#define FWL_KEYFLAG_Command (1 << 3) -#define FWL_KEYFLAG_LButton (1 << 4) -#define FWL_KEYFLAG_RButton (1 << 5) -#define FWL_KEYFLAG_MButton (1 << 6) +enum FWL_KeyFlag { + FWL_KEYFLAG_Ctrl = 1 << 0, + FWL_KEYFLAG_Alt = 1 << 1, + FWL_KEYFLAG_Shift = 1 << 2, + FWL_KEYFLAG_Command = 1 << 3, + FWL_KEYFLAG_LButton = 1 << 4, + FWL_KEYFLAG_RButton = 1 << 5, + FWL_KEYFLAG_MButton = 1 << 6 +}; class CFWL_CoreToolTipDP; class CFWL_MsgActivate; diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp index 1985cbdeaf..3548f9b7a9 100644 --- a/xfa/fwl/core/fwl_widgetmgrimp.cpp +++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp @@ -15,6 +15,19 @@ #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_form.h" +namespace { + +const int kNeedRepaintHitPoints = 12; +const int kNeedRepaintHitPiece = 3; + +struct FWL_NEEDREPAINTHITDATA { + CFX_PointF hitPoint; + bool bNotNeedRepaint; + bool bNotContainByDirty; +}; + +} // namespace + FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { #if (_FX_OS_ == _FX_MACOSX_) return FALSE; @@ -22,12 +35,14 @@ FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; #endif } + IFWL_WidgetMgr* FWL_GetWidgetMgr() { IFWL_App* pApp = FWL_GetApp(); if (!pApp) return NULL; return pApp->GetWidgetMgr(); } + CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) : m_dwCapability(0) { m_pDelegate = new CFWL_WidgetMgrDelegate(this); @@ -35,6 +50,7 @@ CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) ASSERT(m_pAdapter); CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; m_mapWidgetItem.SetAt(NULL, pRoot); + #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) m_rtScreen.Reset(); #endif @@ -725,6 +741,7 @@ int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { @@ -732,6 +749,7 @@ FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, return FWL_ERR_Indefinite; if (!pGraphics) return FWL_ERR_Indefinite; + CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); CFX_RectF clipCopy; pWidget->GetWidgetRect(clipCopy); @@ -741,6 +759,7 @@ FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, return FWL_ERR_Succeeded; } CFX_RectF clipBounds; + #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \ (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_) IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); @@ -756,61 +775,58 @@ FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, } else { clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); const_cast(pMatrix)->SetIdentity(); // FIXME: const cast. -#ifdef FWL_UseMacSystemBorder -#else -#endif - { - IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); - pDelegate->OnDrawWidget(pTemp, pMatrix); - } + IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); + pDelegate->OnDrawWidget(pTemp, pMatrix); } -#endif +#endif // _FX_OS_ == _FX_MACOSX_ + if (!m_pWidgetMgr->IsFormDisabled()) { CFX_RectF rtClient; pWidget->GetClientRect(rtClient); clipBounds.Intersect(rtClient); } - if (!clipBounds.IsEmpty()) { + if (!clipBounds.IsEmpty()) DrawChild(pWidget, clipBounds, pTemp, pMatrix); - } + DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); m_pWidgetMgr->ResetRedrawCounts(pWidget); return FWL_ERR_Succeeded; } + void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, const CFX_RectF& rtClip, CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!parent) return; + FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); IFWL_Widget* pNextChild = m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild); while (pNextChild) { IFWL_Widget* child = pNextChild; pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); - if (child->GetStates() & FWL_WGTSTATE_Invisible) { + if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; - } + CFX_RectF rtWidget; child->GetWidgetRect(rtWidget); - if (rtWidget.IsEmpty()) { + if (rtWidget.IsEmpty()) continue; - } + CFX_Matrix widgetMatrix; CFX_RectF clipBounds(rtWidget); - if (!bFormDisable) { + if (!bFormDisable) child->GetMatrix(widgetMatrix, TRUE); - } - if (pMatrix) { + if (pMatrix) widgetMatrix.Concat(*pMatrix); - } + if (!bFormDisable) { widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); clipBounds.Intersect(rtClip); - if (clipBounds.IsEmpty()) { + if (clipBounds.IsEmpty()) continue; - } + pGraphics->SaveGraphState(); pGraphics->SetClipRect(clipBounds); } @@ -822,21 +838,22 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); } } - if (!bFormDisable) { + if (!bFormDisable) pGraphics->RestoreGraphState(); - } + DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix); child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); } } + CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( IFWL_Widget* pWidget, CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { - if (!FWL_UseOffscreen(pWidget)) { + if (!FWL_UseOffscreen(pWidget)) return pGraphics; - } + CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); if (!pItem->pOffscreen) { pItem->pOffscreen = new CFX_Graphics; @@ -850,6 +867,7 @@ CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( pItem->pOffscreen->SetClipRect(rect); return pItem->pOffscreen; } + void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, CFX_Graphics* pGraphics, CFX_RectF& rtClip, @@ -866,14 +884,6 @@ void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, pItem->iRedrawCounter = 0; } -#define FWL_NEEDREPAINTHIT_Point 12 -#define FWL_NEEDREPAINTHIT_Piece 3 -struct FWL_NEEDREPAINTHITDATA { - CFX_PointF hitPoint; - FX_BOOL bNotNeedRepaint; - FX_BOOL bNotContainByDirty; -}; - FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, CFX_Matrix* pMatrix, const CFX_RectF& rtDirty) { @@ -886,23 +896,21 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, pWidget->GetWidgetRect(rtWidget); rtWidget.left = rtWidget.top = 0; pMatrix->TransformRect(rtWidget); - if (!rtWidget.IntersectWith(rtDirty)) { + if (!rtWidget.IntersectWith(rtDirty)) return FALSE; - } + IFWL_Widget* pChild = FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); - if (!pChild) { + if (!pChild) return TRUE; - } if (pChild->GetClassID() == 3150298670) { CFX_RectF rtTemp; pChild->GetWidgetRect(rtTemp); if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) { pChild = FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild); - if (!pChild) { + if (!pChild) return TRUE; - } } } CFX_RectF rtChilds; @@ -911,11 +919,11 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, FX_BOOL bOrginPtIntersectWidthChild = FALSE; FX_BOOL bOrginPtIntersectWidthDirty = rtDirty.Contains(rtWidget.left, rtWidget.top); - static FWL_NEEDREPAINTHITDATA hitPoint[FWL_NEEDREPAINTHIT_Point]; + static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA); FXSYS_memset(hitPoint, 0, iSize); - FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece; - FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece; + FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; + FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece; hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; @@ -936,77 +944,71 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, CFX_RectF r = rect; r.left += rtWidget.left; r.top += rtWidget.top; - if (r.IsEmpty()) { + if (r.IsEmpty()) continue; - } - if (r.Contains(rtDirty)) { + if (r.Contains(rtDirty)) return FALSE; - } - if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) { + if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) bChildIntersectWithDirty = TRUE; - } - if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { + if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) bOrginPtIntersectWidthChild = rect.Contains(0, 0); - } - if (rtChilds.IsEmpty()) { + + if (rtChilds.IsEmpty()) rtChilds = rect; - } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) { + else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) rtChilds.Union(rect); - } - for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) { - if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) { + + for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { + if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) continue; - } if (!rtDirty.Contains(hitPoint[i].hitPoint)) { - hitPoint[i].bNotContainByDirty = TRUE; + hitPoint[i].bNotContainByDirty = true; continue; } - if (r.Contains(hitPoint[i].hitPoint)) { - hitPoint[i].bNotNeedRepaint = TRUE; - } + if (r.Contains(hitPoint[i].hitPoint)) + hitPoint[i].bNotNeedRepaint = true; } } while ((pChild = FWL_GetWidgetMgr()->GetWidget( pChild, FWL_WGTRELATION_NextSibling)) != NULL); - if (!bChildIntersectWithDirty) { + + if (!bChildIntersectWithDirty) return TRUE; - } - if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { + if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) return TRUE; - } - if (rtChilds.IsEmpty()) { + if (rtChilds.IsEmpty()) return TRUE; - } - int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point; - for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) { - if (hitPoint[i].bNotNeedRepaint) { + + int32_t repaintPoint = kNeedRepaintHitPoints; + for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { + if (hitPoint[i].bNotNeedRepaint) repaintPoint--; - } } - if (repaintPoint > 0) { + if (repaintPoint > 0) return TRUE; - } + pMatrix->TransformRect(rtChilds); - if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) { + if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) return FALSE; - } return TRUE; } + FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); - if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) { + if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) return FALSE; - } + #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) if (pItem->bOutsideChanged) { CFX_RectF r; pWidget->GetWidgetRect(r); CFX_RectF temp(m_pWidgetMgr->m_rtScreen); temp.Deflate(50, 50); - if (!temp.Contains(r)) { + if (!temp.Contains(r)) return FALSE; - } + pItem->bOutsideChanged = FALSE; } #endif + return pItem->iRedrawCounter == 0; } diff --git a/xfa/fwl/lightwidget/cfwl_barcode.h b/xfa/fwl/lightwidget/cfwl_barcode.h index e1e7e658d5..f52b0eef9d 100644 --- a/xfa/fwl/lightwidget/cfwl_barcode.h +++ b/xfa/fwl/lightwidget/cfwl_barcode.h @@ -74,7 +74,9 @@ class CFWL_Barcode : public CFWL_Edit { m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TRUNCATED; m_barcodeData.m_bTruncated = truncated; } - void ResetBarcodeAttributes() { m_barcodeData.m_dwAttributeMask = 0; } + void ResetBarcodeAttributes() { + m_barcodeData.m_dwAttributeMask = FWL_BCDATTRIBUTE_NONE; + } protected: CFWL_Barcode(); @@ -82,38 +84,39 @@ class CFWL_Barcode : public CFWL_Edit { class CFWL_BarcodeDP : public IFWL_BarcodeDP { public: - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + CFWL_BarcodeDP() : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {} + + FWL_ERR GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) override; + BC_CHAR_ENCODING GetCharEncoding() override { return m_eCharEncoding; } + int32_t GetModuleHeight() override { return m_nModuleHeight; } + int32_t GetModuleWidth() override { return m_nModuleWidth; } + int32_t GetDataLength() override { return m_nDataLength; } + int32_t GetCalChecksum() override { return m_nCalChecksum; } + FX_BOOL GetPrintChecksum() override { return m_bPrintChecksum; } + BC_TEXT_LOC GetTextLocation() override { return m_eTextLocation; } + int32_t GetWideNarrowRatio() override { return m_nWideNarrowRatio; } + FX_CHAR GetStartChar() override { return m_cStartChar; } + FX_CHAR GetEndChar() override { return m_cEndChar; } + int32_t GetVersion() override { return m_nVersion; } + int32_t GetErrorCorrectionLevel() override { return m_nECLevel; } + FX_BOOL GetTruncated() override { return m_bTruncated; } + uint32_t GetBarcodeAttributeMask() override { return m_dwAttributeMask; } + BC_CHAR_ENCODING m_eCharEncoding; - virtual BC_CHAR_ENCODING GetCharEncoding() { return m_eCharEncoding; } int32_t m_nModuleHeight, m_nModuleWidth; - virtual int32_t GetModuleHeight() { return m_nModuleHeight; } - virtual int32_t GetModuleWidth() { return m_nModuleWidth; } int32_t m_nDataLength; - virtual int32_t GetDataLength() { return m_nDataLength; } int32_t m_nCalChecksum; - virtual int32_t GetCalChecksum() { return m_nCalChecksum; } FX_BOOL m_bPrintChecksum; - virtual FX_BOOL GetPrintChecksum() { return m_bPrintChecksum; } - BC_TEXT_LOC m_eTextLocation; - virtual BC_TEXT_LOC GetTextLocation() { return m_eTextLocation; } int32_t m_nWideNarrowRatio; - virtual int32_t GetWideNarrowRatio() { return m_nWideNarrowRatio; } FX_CHAR m_cStartChar, m_cEndChar; - virtual FX_CHAR GetStartChar() { return m_cStartChar; } - virtual FX_CHAR GetEndChar() { return m_cEndChar; } int32_t m_nVersion; - virtual int32_t GetVersion() { return m_nVersion; } int32_t m_nECLevel; - virtual int32_t GetErrorCorrectionLevel() { return m_nECLevel; } FX_BOOL m_bTruncated; - virtual FX_BOOL GetTruncated() { return m_bTruncated; } uint32_t m_dwAttributeMask; - virtual uint32_t GetBarcodeAttributeMask() { return m_dwAttributeMask; } - - public: - CFWL_BarcodeDP() : m_dwAttributeMask(0) {} }; + CFWL_BarcodeDP m_barcodeData; }; diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 0913a8daa2..b1acd21969 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -13,7 +13,11 @@ #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" -#define FWL_SCROLL_PawLen 12.5f +namespace { + +const float kPawLength = 12.5f; + +} // namespace CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { SetThemeData(0); @@ -150,7 +154,7 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, CFX_Path path; path.Create(); if (bVert) { - FX_FLOAT fPawLen = FWL_SCROLL_PawLen; + FX_FLOAT fPawLen = kPawLength; if (pRect->width / 2 <= fPawLen) { fPawLen = (pRect->width - 6) / 2; } @@ -183,7 +187,7 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, pGraphics->SetStrokeColor(&clrDark); pGraphics->StrokePath(&path, pMatrix); } else { - FX_FLOAT fPawLen = FWL_SCROLL_PawLen; + FX_FLOAT fPawLen = kPawLength; if (pRect->height / 2 <= fPawLen) { fPawLen = (pRect->height - 6) / 2; } diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 11deff1186..b75fcd5ab0 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -250,7 +250,7 @@ FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, } SetButtonDown(FALSE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index a0744def07..f56d5a1ece 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -349,7 +349,7 @@ FX_BOOL CXFA_FFField::OnMouseEnter() { return FALSE; } CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseEnter; + ms.m_dwCmd = FWL_MouseCommand::Enter; ms.m_pDstTarget = m_pNormalWidget->m_pIface; ms.m_pSrcTarget = NULL; TranslateFWLMessage(&ms); @@ -360,7 +360,7 @@ FX_BOOL CXFA_FFField::OnMouseExit() { return FALSE; } CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave; + ms.m_dwCmd = FWL_MouseCommand::Leave; ms.m_pDstTarget = m_pNormalWidget->m_pIface; TranslateFWLMessage(&ms); return TRUE; @@ -389,7 +389,7 @@ FX_BOOL CXFA_FFField::OnLButtonDown(uint32_t dwFlags, } SetButtonDown(TRUE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -407,7 +407,7 @@ FX_BOOL CXFA_FFField::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { } SetButtonDown(FALSE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -423,7 +423,7 @@ FX_BOOL CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, return FALSE; } CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDblClk; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -437,7 +437,7 @@ FX_BOOL CXFA_FFField::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { return FALSE; } CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseMove; + ms.m_dwCmd = FWL_MouseCommand::Move; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -480,7 +480,7 @@ FX_BOOL CXFA_FFField::OnRButtonDown(uint32_t dwFlags, } SetButtonDown(TRUE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; + ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -498,7 +498,7 @@ FX_BOOL CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { } SetButtonDown(FALSE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonUp; + ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -514,7 +514,7 @@ FX_BOOL CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, return FALSE; } CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDblClk; + ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -555,7 +555,7 @@ FX_BOOL CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { return FALSE; } CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_KeyDown; + ms.m_dwCmd = FWL_KeyCommand::KeyDown; ms.m_dwFlags = dwFlags; ms.m_dwKeyCode = dwKeyCode; ms.m_pDstTarget = m_pNormalWidget->m_pIface; @@ -568,7 +568,7 @@ FX_BOOL CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { return FALSE; } CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_KeyUp; + ms.m_dwCmd = FWL_KeyCommand::KeyUp; ms.m_dwFlags = dwFlags; ms.m_dwKeyCode = dwKeyCode; ms.m_pDstTarget = m_pNormalWidget->m_pIface; @@ -590,7 +590,7 @@ FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { return FALSE; } CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_Char; + ms.m_dwCmd = FWL_KeyCommand::Char; ms.m_dwFlags = dwFlags; ms.m_dwKeyCode = dwChar; ms.m_pDstTarget = m_pNormalWidget->m_pIface; @@ -793,22 +793,22 @@ FWL_ERR CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { switch (pEvent->GetClassID()) { case CFWL_EventType::Mouse: { CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent; - if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) { + if (event->m_dwCmd == FWL_MouseCommand::Enter) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseEnter; eParam.m_pTarget = m_pDataAcc; m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseEnter, &eParam); - } else if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave) { + } else if (event->m_dwCmd == FWL_MouseCommand::Leave) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseExit; eParam.m_pTarget = m_pDataAcc; m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseExit, &eParam); - } else if (event->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { + } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseDown; eParam.m_pTarget = m_pDataAcc; m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseDown, &eParam); - } else if (event->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { + } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseUp; eParam.m_pTarget = m_pDataAcc; diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 94cafba740..16fa0ef06a 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -94,7 +94,7 @@ FX_BOOL CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, SetButtonDown(TRUE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index e978e30bcf..07324cb358 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -107,7 +107,7 @@ FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, } SetButtonDown(TRUE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; @@ -132,7 +132,7 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, } SetButtonDown(TRUE); CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; + ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index e241139464..672ca302fd 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -137,6 +137,123 @@ class IXFA_WidgetIterator; #define XFA_IDS_ValidateError 98 #define XFA_IDS_ValidateNumberError 99 +#define XFA_DOCVIEW_View 0x00000000 +#define XFA_DOCVIEW_MasterPage 0x00000001 +#define XFA_DOCVIEW_Design 0x00000002 +#define XFA_DOCTYPE_Dynamic 0 +#define XFA_DOCTYPE_Static 1 +#define XFA_DOCTYPE_XDP 2 +#define XFA_PARSESTATUS_StatusErr -3 +#define XFA_PARSESTATUS_StreamErr -2 +#define XFA_PARSESTATUS_SyntaxErr -1 +#define XFA_PARSESTATUS_Ready 0 +#define XFA_PARSESTATUS_Done 100 +#define XFA_VALIDATE_preSubmit 1 +#define XFA_VALIDATE_prePrint 2 +#define XFA_VALIDATE_preExecute 3 +#define XFA_VALIDATE_preSave 4 + +#define XFA_INVALIDATE_AllPages 0x00000000 +#define XFA_INVALIDATE_CurrentPage 0x00000001 +#define XFA_PRINTOPT_ShowDialog 0x00000001 +#define XFA_PRINTOPT_CanCancel 0x00000002 +#define XFA_PRINTOPT_ShrinkPage 0x00000004 +#define XFA_PRINTOPT_AsImage 0x00000008 +#define XFA_PRINTOPT_ReverseOrder 0x00000010 +#define XFA_PRINTOPT_PrintAnnot 0x00000020 +#define XFA_PAGEVIEWEVENT_PostAdded 1 +#define XFA_PAGEVIEWEVENT_PostRemoved 3 +#define XFA_PAGEVIEWEVENT_StopLayout 4 +#define XFA_WIDGETEVENT_PostAdded 2 +#define XFA_WIDGETEVENT_PreRemoved 3 + +#define XFA_EVENTERROR_Success 1 +#define XFA_EVENTERROR_Error -1 +#define XFA_EVENTERROR_NotExist 0 +#define XFA_EVENTERROR_Disabled 2 + +#define XFA_RENDERSTATUS_Ready 1 +#define XFA_RENDERSTATUS_ToBeContinued 2 +#define XFA_RENDERSTATUS_Done 3 +#define XFA_RENDERSTATUS_Failed -1 + +#define XFA_TRAVERSEWAY_Tranvalse 0x0001 +#define XFA_TRAVERSEWAY_Form 0x0002 +#define XFA_WIDGETFILTER_Visible 0x0001 +#define XFA_WIDGETFILTER_Viewable 0x0010 +#define XFA_WIDGETFILTER_Printable 0x0020 +#define XFA_WIDGETFILTER_Field 0x0100 +#define XFA_WIDGETFILTER_AllType 0x0F00 + +#define XFA_WIDGETSTATUS_Visible 0x00000001 +#define XFA_WIDGETSTATUS_Invisible 0x00000002 +#define XFA_WIDGETSTATUS_Hidden 0x00000004 +#define XFA_WIDGETSTATUS_Viewable 0x00000010 +#define XFA_WIDGETSTATUS_Printable 0x00000020 +#define XFA_WIDGETSTATUS_Focused 0x00000100 + +enum XFA_EVENTTYPE { + XFA_EVENT_Click, + XFA_EVENT_Change, + XFA_EVENT_DocClose, + XFA_EVENT_DocReady, + XFA_EVENT_Enter, + XFA_EVENT_Exit, + XFA_EVENT_Full, + XFA_EVENT_IndexChange, + XFA_EVENT_Initialize, + XFA_EVENT_MouseDown, + XFA_EVENT_MouseEnter, + XFA_EVENT_MouseExit, + XFA_EVENT_MouseUp, + XFA_EVENT_PostExecute, + XFA_EVENT_PostOpen, + XFA_EVENT_PostPrint, + XFA_EVENT_PostSave, + XFA_EVENT_PostSign, + XFA_EVENT_PostSubmit, + XFA_EVENT_PreExecute, + XFA_EVENT_PreOpen, + XFA_EVENT_PrePrint, + XFA_EVENT_PreSave, + XFA_EVENT_PreSign, + XFA_EVENT_PreSubmit, + XFA_EVENT_Ready, + XFA_EVENT_InitCalculate, + XFA_EVENT_InitVariables, + XFA_EVENT_Calculate, + XFA_EVENT_Validate, + XFA_EVENT_Unknown, +}; + +enum XFA_WIDGETORDER { + XFA_WIDGETORDER_PreOrder, +}; + +enum XFA_WIDGETTYPE { + XFA_WIDGETTYPE_Barcode, + XFA_WIDGETTYPE_PushButton, + XFA_WIDGETTYPE_CheckButton, + XFA_WIDGETTYPE_RadioButton, + XFA_WIDGETTYPE_DatetimeEdit, + XFA_WIDGETTYPE_DecimalField, + XFA_WIDGETTYPE_NumericField, + XFA_WIDGETTYPE_Signature, + XFA_WIDGETTYPE_TextEdit, + XFA_WIDGETTYPE_DropdownList, + XFA_WIDGETTYPE_ListBox, + XFA_WIDGETTYPE_ImageField, + XFA_WIDGETTYPE_PasswordEdit, + XFA_WIDGETTYPE_Arc, + XFA_WIDGETTYPE_Rectangle, + XFA_WIDGETTYPE_Image, + XFA_WIDGETTYPE_Line, + XFA_WIDGETTYPE_Text, + XFA_WIDGETTYPE_ExcludeGroup, + XFA_WIDGETTYPE_Subform, + XFA_WIDGETTYPE_Unknown, +}; + // Probably should be called IXFA_AppDelegate. class IXFA_AppProvider { public: @@ -262,20 +379,6 @@ class IXFA_AppProvider { virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0; }; -#define XFA_INVALIDATE_AllPages 0x00000000 -#define XFA_INVALIDATE_CurrentPage 0x00000001 -#define XFA_PRINTOPT_ShowDialog 0x00000001 -#define XFA_PRINTOPT_CanCancel 0x00000002 -#define XFA_PRINTOPT_ShrinkPage 0x00000004 -#define XFA_PRINTOPT_AsImage 0x00000008 -#define XFA_PRINTOPT_ReverseOrder 0x00000010 -#define XFA_PRINTOPT_PrintAnnot 0x00000020 -#define XFA_PAGEVIEWEVENT_PostAdded 1 -#define XFA_PAGEVIEWEVENT_PostRemoved 3 -#define XFA_PAGEVIEWEVENT_StopLayout 4 -#define XFA_WIDGETEVENT_PostAdded 2 -#define XFA_WIDGETEVENT_PreRemoved 3 - class IXFA_DocProvider { public: virtual ~IXFA_DocProvider() {} @@ -373,55 +476,7 @@ class IXFA_DocProvider { virtual IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, const CFX_WideString& wsLink) = 0; }; -#define XFA_DOCVIEW_View 0x00000000 -#define XFA_DOCVIEW_MasterPage 0x00000001 -#define XFA_DOCVIEW_Design 0x00000002 -#define XFA_DOCTYPE_Dynamic 0 -#define XFA_DOCTYPE_Static 1 -#define XFA_DOCTYPE_XDP 2 -#define XFA_PARSESTATUS_StatusErr -3 -#define XFA_PARSESTATUS_StreamErr -2 -#define XFA_PARSESTATUS_SyntaxErr -1 -#define XFA_PARSESTATUS_Ready 0 -#define XFA_PARSESTATUS_Done 100 -enum XFA_EVENTTYPE { - XFA_EVENT_Click, - XFA_EVENT_Change, - XFA_EVENT_DocClose, - XFA_EVENT_DocReady, - XFA_EVENT_Enter, - XFA_EVENT_Exit, - XFA_EVENT_Full, - XFA_EVENT_IndexChange, - XFA_EVENT_Initialize, - XFA_EVENT_MouseDown, - XFA_EVENT_MouseEnter, - XFA_EVENT_MouseExit, - XFA_EVENT_MouseUp, - XFA_EVENT_PostExecute, - XFA_EVENT_PostOpen, - XFA_EVENT_PostPrint, - XFA_EVENT_PostSave, - XFA_EVENT_PostSign, - XFA_EVENT_PostSubmit, - XFA_EVENT_PreExecute, - XFA_EVENT_PreOpen, - XFA_EVENT_PrePrint, - XFA_EVENT_PreSave, - XFA_EVENT_PreSign, - XFA_EVENT_PreSubmit, - XFA_EVENT_Ready, - XFA_EVENT_InitCalculate, - XFA_EVENT_InitVariables, - XFA_EVENT_Calculate, - XFA_EVENT_Validate, - XFA_EVENT_Unknown, -}; -#define XFA_VALIDATE_preSubmit 1 -#define XFA_VALIDATE_prePrint 2 -#define XFA_VALIDATE_preExecute 3 -#define XFA_VALIDATE_preSave 4 class CXFA_EventParam { public: CXFA_EventParam() { @@ -471,21 +526,6 @@ class CXFA_EventParam { FX_BOOL m_bIsFormReady; int32_t m_iValidateActivities; }; -#define XFA_EVENTERROR_Success 1 -#define XFA_EVENTERROR_Error -1 -#define XFA_EVENTERROR_NotExist 0 -#define XFA_EVENTERROR_Disabled 2 -enum XFA_WIDGETORDER { - XFA_WIDGETORDER_PreOrder, -}; - -#define XFA_TRAVERSEWAY_Tranvalse 0x0001 -#define XFA_TRAVERSEWAY_Form 0x0002 -#define XFA_WIDGETFILTER_Visible 0x0001 -#define XFA_WIDGETFILTER_Viewable 0x0010 -#define XFA_WIDGETFILTER_Printable 0x0020 -#define XFA_WIDGETFILTER_Field 0x0100 -#define XFA_WIDGETFILTER_AllType 0x0F00 class CXFA_RenderOptions { public: @@ -493,40 +533,6 @@ class CXFA_RenderOptions { FX_BOOL m_bPrint; FX_BOOL m_bHighlight; }; -#define XFA_RENDERSTATUS_Ready 1 -#define XFA_RENDERSTATUS_ToBeContinued 2 -#define XFA_RENDERSTATUS_Done 3 -#define XFA_RENDERSTATUS_Failed -1 - -enum XFA_WIDGETTYPE { - XFA_WIDGETTYPE_Barcode, - XFA_WIDGETTYPE_PushButton, - XFA_WIDGETTYPE_CheckButton, - XFA_WIDGETTYPE_RadioButton, - XFA_WIDGETTYPE_DatetimeEdit, - XFA_WIDGETTYPE_DecimalField, - XFA_WIDGETTYPE_NumericField, - XFA_WIDGETTYPE_Signature, - XFA_WIDGETTYPE_TextEdit, - XFA_WIDGETTYPE_DropdownList, - XFA_WIDGETTYPE_ListBox, - XFA_WIDGETTYPE_ImageField, - XFA_WIDGETTYPE_PasswordEdit, - XFA_WIDGETTYPE_Arc, - XFA_WIDGETTYPE_Rectangle, - XFA_WIDGETTYPE_Image, - XFA_WIDGETTYPE_Line, - XFA_WIDGETTYPE_Text, - XFA_WIDGETTYPE_ExcludeGroup, - XFA_WIDGETTYPE_Subform, - XFA_WIDGETTYPE_Unknown, -}; -#define XFA_WIDGETSTATUS_Visible 0x00000001 -#define XFA_WIDGETSTATUS_Invisible 0x00000002 -#define XFA_WIDGETSTATUS_Hidden 0x00000004 -#define XFA_WIDGETSTATUS_Viewable 0x00000010 -#define XFA_WIDGETSTATUS_Printable 0x00000020 -#define XFA_WIDGETSTATUS_Focused 0x00000100 class IXFA_WidgetIterator { public: diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp index 2ddf0920d5..335df6a32e 100644 --- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp @@ -48,90 +48,90 @@ void Script_EventPseudoModel_InterProperty(FXJSE_HVALUE hValue, void Script_EventPseudoModel_BooleanProperty(FXJSE_HVALUE hValue, FX_BOOL& bValue, FX_BOOL bSetting) { - if (bSetting) { + if (bSetting) bValue = FXJSE_Value_ToBoolean(hValue); - } else { + else FXJSE_Value_SetBoolean(hValue, bValue); - } } + void CScript_EventPseudoModel::Script_EventPseudoModel_Property( FXJSE_HVALUE hValue, - uint32_t dwFlag, + XFA_Event dwFlag, FX_BOOL bSetting) { CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { + if (!pScriptContext) return; - } + CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { + if (!pEventParam) return; - } + switch (dwFlag) { - case XFA_EVENT_CANCELACTION: + case XFA_Event::CancelAction: Script_EventPseudoModel_BooleanProperty( hValue, pEventParam->m_bCancelAction, bSetting); break; - case XFA_EVENT_CHANGE: + case XFA_Event::Change: Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsChange, bSetting); break; - case XFA_EVENT_COMMITKEY: + case XFA_Event::CommitKey: Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iCommitKey, bSetting); break; - case XFA_EVENT_FULLTEXT: + case XFA_Event::FullText: Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsFullText, bSetting); break; - case XFA_EVENT_KEYDOWN: + case XFA_Event::Keydown: Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bKeyDown, bSetting); break; - case XFA_EVENT_MODIFIER: + case XFA_Event::Modifier: Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bModifier, bSetting); break; - case XFA_EVENT_NEWCONTENTTYPE: + case XFA_Event::NewContentType: Script_EventPseudoModel_StringProperty( hValue, pEventParam->m_wsNewContentType, bSetting); break; - case XFA_EVENT_NEWTEXT: + case XFA_Event::NewText: Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsNewText, bSetting); break; - case XFA_EVENT_PREVCONTENTTYPE: + case XFA_Event::PreviousContentType: Script_EventPseudoModel_StringProperty( hValue, pEventParam->m_wsPrevContentType, bSetting); break; - case XFA_EVENT_PREVTEXT: + case XFA_Event::PreviousText: Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsPrevText, bSetting); break; - case XFA_EVENT_REENTER: + case XFA_Event::Reenter: Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bReenter, bSetting); break; - case XFA_EVENT_SELEND: + case XFA_Event::SelectionEnd: Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelEnd, bSetting); break; - case XFA_EVENT_SELSTART: + case XFA_Event::SelectionStart: Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelStart, bSetting); break; - case XFA_EVENT_SHIFT: + case XFA_Event::Shift: Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bShift, bSetting); break; - case XFA_EVENT_SOAPFAULTCODE: + case XFA_Event::SoapFaultCode: Script_EventPseudoModel_StringProperty( hValue, pEventParam->m_wsSoapFaultCode, bSetting); break; - case XFA_EVENT_SOAPFAULTSTRING: + case XFA_Event::SoapFaultString: Script_EventPseudoModel_StringProperty( hValue, pEventParam->m_wsSoapFaultString, bSetting); break; - case XFA_EVENT_TARGET: + case XFA_Event::Target: break; default: break; @@ -141,97 +141,99 @@ void CScript_EventPseudoModel::Script_EventPseudoModel_Change( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_CHANGE, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Change, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_CommitKey( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_COMMITKEY, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::CommitKey, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_FullText( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_FULLTEXT, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::FullText, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_KeyDown( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_KEYDOWN, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Keydown, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_Modifier( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_MODIFIER, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Modifier, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_NewContentType( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_NEWCONTENTTYPE, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::NewContentType, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_NewText( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_NEWTEXT, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::NewText, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_PrevContentType( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVCONTENTTYPE, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::PreviousContentType, + bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_PrevText( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVTEXT, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::PreviousText, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_Reenter( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_REENTER, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Reenter, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_SelEnd( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELEND, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::SelectionEnd, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_SelStart( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELSTART, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::SelectionStart, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_Shift( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SHIFT, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Shift, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultCode( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SOAPFAULTCODE, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::SoapFaultCode, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultString( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SOAPFAULTSTRING, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::SoapFaultString, + bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_Target( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_TARGET, bSetting); + Script_EventPseudoModel_Property(hValue, XFA_Event::Target, bSetting); } void CScript_EventPseudoModel::Script_EventPseudoModel_Emit( CFXJSE_Arguments* pArguments) { diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.h b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h index f2a11357cb..d840329b4c 100644 --- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.h +++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h @@ -10,23 +10,25 @@ #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxjse/cfxjse_arguments.h" -#define XFA_EVENT_CHANGE 0 -#define XFA_EVENT_COMMITKEY 1 -#define XFA_EVENT_FULLTEXT 2 -#define XFA_EVENT_KEYDOWN 3 -#define XFA_EVENT_MODIFIER 4 -#define XFA_EVENT_NEWCONTENTTYPE 5 -#define XFA_EVENT_NEWTEXT 6 -#define XFA_EVENT_PREVCONTENTTYPE 7 -#define XFA_EVENT_PREVTEXT 8 -#define XFA_EVENT_REENTER 9 -#define XFA_EVENT_SELEND 10 -#define XFA_EVENT_SELSTART 11 -#define XFA_EVENT_SHIFT 12 -#define XFA_EVENT_SOAPFAULTCODE 13 -#define XFA_EVENT_SOAPFAULTSTRING 14 -#define XFA_EVENT_TARGET 15 -#define XFA_EVENT_CANCELACTION 16 +enum class XFA_Event { + Change = 0, + CommitKey, + FullText, + Keydown, + Modifier, + NewContentType, + NewText, + PreviousContentType, + PreviousText, + Reenter, + SelectionEnd, + SelectionStart, + Shift, + SoapFaultCode, + SoapFaultString, + Target, + CancelAction +}; class CScript_EventPseudoModel : public CXFA_OrdinaryObject { public: @@ -87,7 +89,7 @@ class CScript_EventPseudoModel : public CXFA_OrdinaryObject { protected: void Script_EventPseudoModel_Property(FXJSE_HVALUE hValue, - uint32_t dwFlag, + XFA_Event dwFlag, FX_BOOL bSetting); }; -- cgit v1.2.3