diff options
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.cpp | 64 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.h | 100 |
2 files changed, 49 insertions, 115 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index b10a0854a7..14024dd5d4 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -420,7 +420,6 @@ void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) { } PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) -PWL_IMPLEMENT_KEY_METHOD(OnKeyUp) PWL_IMPLEMENT_KEY_METHOD(OnChar) #undef PWL_IMPLEMENT_KEY_METHOD @@ -451,9 +450,6 @@ PWL_IMPLEMENT_KEY_METHOD(OnChar) PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk) PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown) PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp) -PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk) -PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown) -PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp) PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown) PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp) PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove) @@ -844,21 +840,6 @@ FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const { (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5)); } -CFX_PointF CPWL_Wnd::ChildToParent(const CFX_PointF& point) const { - CFX_Matrix mt = GetChildMatrix(); - return mt.IsIdentity() ? point : mt.Transform(point); -} - -CFX_FloatRect CPWL_Wnd::ChildToParent(const CFX_FloatRect& rect) const { - CFX_Matrix mt = GetChildMatrix(); - if (mt.IsIdentity()) - return rect; - - CFX_FloatRect rc = rect; - mt.TransformRect(rc); - return rc; -} - CFX_PointF CPWL_Wnd::ParentToChild(const CFX_PointF& point) const { CFX_Matrix mt = GetChildMatrix(); if (mt.IsIdentity()) @@ -879,18 +860,6 @@ CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const { return rc; } -FX_FLOAT CPWL_Wnd::GetItemHeight(FX_FLOAT fLimitWidth) { - return 0; -} - -FX_FLOAT CPWL_Wnd::GetItemLeftMargin() { - return 0; -} - -FX_FLOAT CPWL_Wnd::GetItemRightMargin() { - return 0; -} - CFX_Matrix CPWL_Wnd::GetChildToRoot() const { CFX_Matrix mt(1, 0, 0, 1, 0, 0); if (HasFlag(PWS_CHILD)) { @@ -928,40 +897,19 @@ void CPWL_Wnd::EnableWindow(bool bEnable) { pChild->EnableWindow(bEnable); } m_bEnabled = bEnable; - if (bEnable) - OnEnabled(); - else - OnDisabled(); } -bool CPWL_Wnd::IsEnabled() { - return m_bEnabled; -} - -void CPWL_Wnd::OnEnabled() {} - -void CPWL_Wnd::OnDisabled() {} - bool CPWL_Wnd::IsCTRLpressed(uint32_t nFlag) const { - if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { - return pSystemHandler->IsCTRLKeyDown(nFlag); - } - - return false; + CFX_SystemHandler* pSystemHandler = GetSystemHandler(); + return pSystemHandler && pSystemHandler->IsCTRLKeyDown(nFlag); } bool CPWL_Wnd::IsSHIFTpressed(uint32_t nFlag) const { - if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { - return pSystemHandler->IsSHIFTKeyDown(nFlag); - } - - return false; + CFX_SystemHandler* pSystemHandler = GetSystemHandler(); + return pSystemHandler && pSystemHandler->IsSHIFTKeyDown(nFlag); } bool CPWL_Wnd::IsALTpressed(uint32_t nFlag) const { - if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { - return pSystemHandler->IsALTKeyDown(nFlag); - } - - return false; + CFX_SystemHandler* pSystemHandler = GetSystemHandler(); + return pSystemHandler && pSystemHandler->IsALTKeyDown(nFlag); } diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index e6400efd26..55836d43a2 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -243,82 +243,83 @@ class CPWL_TimerHandler { }; class CPWL_Wnd : public CPWL_TimerHandler { - friend class CPWL_MsgControl; - public: CPWL_Wnd(); ~CPWL_Wnd() override; - void Create(const PWL_CREATEPARAM& cp); virtual CFX_ByteString GetClassName() const; - void InvalidateFocusHandler(IPWL_FocusHandler* handler); - void InvalidateProvider(IPWL_Provider* provider); - void Destroy(); - void Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh); virtual void InvalidateRect(CFX_FloatRect* pRect = nullptr); - void DrawAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device); - virtual bool OnKeyDown(uint16_t nChar, uint32_t nFlag); - virtual bool OnKeyUp(uint16_t nChar, uint32_t nFlag); virtual bool OnChar(uint16_t nChar, uint32_t nFlag); virtual bool OnLButtonDblClk(const CFX_PointF& point, uint32_t nFlag); virtual bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag); virtual bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag); - virtual bool OnMButtonDblClk(const CFX_PointF& point, uint32_t nFlag); - virtual bool OnMButtonDown(const CFX_PointF& point, uint32_t nFlag); - virtual bool OnMButtonUp(const CFX_PointF& point, uint32_t nFlag); virtual bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag); virtual bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag); virtual bool OnMouseMove(const CFX_PointF& point, uint32_t nFlag); virtual bool OnMouseWheel(short zDelta, const CFX_PointF& point, uint32_t nFlag); - - virtual void SetFocus(); - virtual void KillFocus(); - void SetCapture(); - void ReleaseCapture(); - virtual void OnNotify(CPWL_Wnd* pWnd, uint32_t msg, intptr_t wParam = 0, intptr_t lParam = 0); + virtual void SetFocus(); + virtual void KillFocus(); + virtual void SetCursor(); virtual void SetVisible(bool bVisible); + virtual void SetFontSize(FX_FLOAT fFontSize); + virtual FX_FLOAT GetFontSize() const; virtual CFX_FloatRect GetFocusRect() const; - virtual CPWL_Color GetBackgroundColor() const; - virtual CPWL_Color GetBorderColor() const; - virtual CPWL_Color GetTextColor() const; - virtual FX_FLOAT GetFontSize() const; - virtual int32_t GetInnerBorderWidth() const; - virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; - virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; + virtual CFX_FloatRect GetClientRect() const; - virtual void SetFontSize(FX_FLOAT fFontSize); + void InvalidateFocusHandler(IPWL_FocusHandler* handler); + void InvalidateProvider(IPWL_Provider* provider); + void Create(const PWL_CREATEPARAM& cp); + void Destroy(); + void Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh); + + void SetCapture(); + void ReleaseCapture(); + void DrawAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device); + + CPWL_Color GetBackgroundColor() const; void SetBackgroundColor(const CPWL_Color& color); - void SetClipRect(const CFX_FloatRect& rect); + CPWL_Color GetBorderColor() const; + CPWL_Color GetTextColor() const; + void SetTextColor(const CPWL_Color& color); + CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; + CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; + void SetBorderStyle(BorderStyle eBorderStyle); + BorderStyle GetBorderStyle() const; + const CPWL_Dash& GetBorderDash() const; - virtual CFX_FloatRect GetWindowRect() const; - virtual CFX_FloatRect GetClientRect() const; - CFX_PointF GetCenterPoint() const; int32_t GetBorderWidth() const; + int32_t GetInnerBorderWidth() const; + CFX_FloatRect GetWindowRect() const; + CFX_PointF GetCenterPoint() const; + bool IsVisible() const { return m_bVisible; } bool HasFlag(uint32_t dwFlags) const; void AddFlag(uint32_t dwFlags); void RemoveFlag(uint32_t dwFlags); + + void SetClipRect(const CFX_FloatRect& rect); const CFX_FloatRect& GetClipRect() const; + CPWL_Wnd* GetParentWindow() const; - BorderStyle GetBorderStyle() const; - const CPWL_Dash& GetBorderDash() const; void* GetAttachedData() const; bool WndHitTest(const CFX_PointF& point) const; bool ClientHitTest(const CFX_PointF& point) const; bool IsCaptureMouse() const; + void EnableWindow(bool bEnable); + bool IsEnabled() const { return m_bEnabled; } const CPWL_Wnd* GetFocused() const; bool IsFocused() const; bool IsReadOnly() const; @@ -336,34 +337,18 @@ class CPWL_Wnd : public CPWL_TimerHandler { void SetChildMatrix(const CFX_Matrix& mt); CFX_Matrix GetWindowMatrix() const; - virtual CFX_PointF ChildToParent(const CFX_PointF& point) const; - virtual CFX_FloatRect ChildToParent(const CFX_FloatRect& rect) const; - virtual CFX_PointF ParentToChild(const CFX_PointF& point) const; - virtual CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const; - - // those methods only implemented by listctrl item - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - virtual FX_FLOAT GetItemLeftMargin(); - virtual FX_FLOAT GetItemRightMargin(); - - void EnableWindow(bool bEnable); - bool IsEnabled(); - virtual void SetCursor(); - protected: + friend class CPWL_MsgControl; + // CPWL_TimerHandler CFX_SystemHandler* GetSystemHandler() const override; virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); virtual void RePosChildWnd(); - void GetAppearanceStream(CFX_ByteTextBuf& sAppStream); virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream); - virtual void GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream); virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device); - virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device); virtual void OnCreate(PWL_CREATEPARAM& cp); virtual void OnCreated(); @@ -372,9 +357,7 @@ class CPWL_Wnd : public CPWL_TimerHandler { virtual void OnSetFocus(); virtual void OnKillFocus(); - virtual void OnEnabled(); - virtual void OnDisabled(); - + void GetAppearanceStream(CFX_ByteTextBuf& sAppStream); void SetNotifyFlag(bool bNotifying = true) { m_bNotifying = bNotifying; } bool IsValid() const; @@ -393,6 +376,12 @@ class CPWL_Wnd : public CPWL_TimerHandler { bool IsALTpressed(uint32_t nFlag) const; private: + CFX_PointF ParentToChild(const CFX_PointF& point) const; + CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const; + + void GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream); + void DrawChildAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device); + FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const; void AddChild(CPWL_Wnd* pWnd); @@ -407,10 +396,7 @@ class CPWL_Wnd : public CPWL_TimerHandler { CPWL_MsgControl* GetMsgControl() const; - protected: std::vector<CPWL_Wnd*> m_Children; - - private: PWL_CREATEPARAM m_sPrivateParam; CPWL_ScrollBar* m_pVScrollBar; CFX_FloatRect m_rcWindow; |