summaryrefslogtreecommitdiff
path: root/xfa/fwl/core
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-05-04 13:51:51 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-04 13:51:51 -0700
commit8f4bf9a8ac211e150f7fa4d8ed061f264cb3aa9e (patch)
tree9ac5bb23a12623ea77ecb13e74a665733efedc8c /xfa/fwl/core
parent7d89e728a450c681c53d40d7f67ee2eef0400705 (diff)
downloadpdfium-8f4bf9a8ac211e150f7fa4d8ed061f264cb3aa9e.tar.xz
More define cleanup.
This CL converts defines into constants, enums, enum classes or removes them as needed. Review-Url: https://codereview.chromium.org/1938163002
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r--xfa/fwl/core/cfwl_event.h9
-rw-r--r--xfa/fwl/core/cfwl_message.h53
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp56
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp22
-rw-r--r--xfa/fwl/core/fwl_noteimp.h16
-rw-r--r--xfa/fwl/core/fwl_widgetmgrimp.cpp156
6 files changed, 154 insertions, 158 deletions
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(&param, 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<CFWL_MsgMouse*>(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<CFWL_EvtMouse*>(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<CFWL_WidgetMgr*>(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<CFWL_WidgetMgr*>(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<CFX_Matrix*>(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;
}