summaryrefslogtreecommitdiff
path: root/xfa/fwl/core/ifwl_widget.h
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-11-02 14:51:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-02 14:51:25 -0700
commit3b3ce1a242f8445848d3f23d6c35ba01d7c645f4 (patch)
tree365d9ee7f8eec1103fb9fce0986e23d9f548ecae /xfa/fwl/core/ifwl_widget.h
parent4cf551577856f89103e162edc761def44ffb96fc (diff)
downloadpdfium-3b3ce1a242f8445848d3f23d6c35ba01d7c645f4.tar.xz
Merge delegates into IFWL_* classes.
This Cl removes ownership of the delgates from IFWL_Widget and puts it in the hand of the creating classes. In doing so, merge the delegates back into the IFWL_* classes to simplify logic. Review-Url: https://codereview.chromium.org/2467993003
Diffstat (limited to 'xfa/fwl/core/ifwl_widget.h')
-rw-r--r--xfa/fwl/core/ifwl_widget.h42
1 files changed, 19 insertions, 23 deletions
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index 264ff67513..0c8cef1adc 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -62,9 +62,9 @@ class IFWL_ThemeProvider;
class IFWL_Widget;
enum class FWL_Type;
-class IFWL_Widget {
+class IFWL_Widget : public IFWL_WidgetDelegate {
public:
- virtual ~IFWL_Widget();
+ ~IFWL_Widget() override;
virtual FWL_Type GetClassID() const = 0;
virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
@@ -112,8 +112,19 @@ class IFWL_Widget {
virtual IFWL_ThemeProvider* GetThemeProvider();
virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- IFWL_WidgetDelegate* GetCurrentDelegate();
- void SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate);
+ void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
+ IFWL_WidgetDelegate* GetDelegate() {
+ return m_pDelegate ? m_pDelegate : this;
+ }
+ const IFWL_WidgetDelegate* GetDelegate() const {
+ return m_pDelegate ? m_pDelegate : this;
+ }
+
+ // IFWL_WidgetDelegate.
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
const IFWL_App* GetOwnerApp() const;
@@ -127,6 +138,9 @@ class IFWL_Widget {
void SetAssociateWidget(CFWL_Widget* pAssociate);
+ void SetFocus(FX_BOOL bFocus);
+ void Repaint(const CFX_RectF* pRect = nullptr);
+
protected:
friend class CFWL_WidgetImpDelegate;
@@ -160,7 +174,6 @@ class IFWL_Widget {
uint32_t dwTTOStyles,
int32_t iTTOAlign,
CFX_RectF& rect);
- void SetFocus(FX_BOOL bFocus);
void SetGrab(FX_BOOL bSet);
FX_BOOL GetPopupPos(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
@@ -184,7 +197,6 @@ class IFWL_Widget {
void UnregisterEventTarget();
void DispatchKeyEvent(CFWL_MsgKey* pNote);
void DispatchEvent(CFWL_Event* pEvent);
- void Repaint(const CFX_RectF* pRect = nullptr);
void DrawBackground(CFX_Graphics* pGraphics,
CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,
@@ -201,15 +213,9 @@ class IFWL_Widget {
FX_BOOL IsParent(IFWL_Widget* pParent);
- void SetDelegate(std::unique_ptr<IFWL_WidgetDelegate> delegate) {
- m_pDelegate = std::move(delegate);
- }
- IFWL_WidgetDelegate* GetDelegate() const { return m_pDelegate.get(); }
-
const IFWL_App* const m_pOwnerApp;
CFWL_WidgetMgr* const m_pWidgetMgr;
std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
- IFWL_WidgetDelegate* m_pCurDelegate; // Not owned.
IFWL_Widget* m_pOuter;
void* m_pLayoutItem;
CFWL_Widget* m_pAssociate;
@@ -217,17 +223,7 @@ class IFWL_Widget {
uint32_t m_nEventKey;
private:
- std::unique_ptr<IFWL_WidgetDelegate> m_pDelegate;
-};
-
-class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate {
- public:
- CFWL_WidgetImpDelegate();
- ~CFWL_WidgetImpDelegate() override {}
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
+ IFWL_WidgetDelegate* m_pDelegate; // Not owned.
};
#endif // XFA_FWL_CORE_IFWL_WIDGET_H_