summaryrefslogtreecommitdiff
path: root/xfa/include/fwl/lightwidget/widget.h
blob: 38fe777fd2e05255565dbe2e67d5f049a2633cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_
#define XFA_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_

#include "xfa/fwl/core/cfwl_event.h"
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#include "xfa/fwl/core/ifwl_widget.h"

class CFWL_Event;
class CFWL_Message;
class CFWL_Widget;
class CFWL_WidgetDelegate;
class CFWL_WidgetMgr;

class CFWL_WidgetProperties {
 public:
  CFWL_WidgetProperties() {
    m_ctmOnParent.SetIdentity();
    m_rtWidget.Set(0, 0, 0, 0);
    m_dwStyles = FWL_WGTSTYLE_Child;
    m_dwStyleExes = 0;
    m_dwStates = 0;
    m_pParent = NULL;
    m_pOwner = NULL;
  }
  CFWL_WidgetImpProperties MakeWidgetImpProperties(
      IFWL_DataProvider* pDataProvider) const;

  CFX_WideString m_wsWindowclass;
  CFX_Matrix m_ctmOnParent;
  CFX_RectF m_rtWidget;
  uint32_t m_dwStyles;
  uint32_t m_dwStyleExes;
  uint32_t m_dwStates;
  CFWL_Widget* m_pParent;
  CFWL_Widget* m_pOwner;
};

class CFWL_Widget {
 public:
  virtual ~CFWL_Widget();
  IFWL_Widget* GetWidget();
  FWL_ERR GetClassName(CFX_WideString& wsClass) const;
  uint32_t GetClassID() const;
  virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;

 protected:
  FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);

 public:
  FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
  FWL_ERR GetGlobalRect(CFX_RectF& rect);
  FWL_ERR SetWidgetRect(const CFX_RectF& rect);
  FWL_ERR GetClientRect(CFX_RectF& rtClient);
  CFWL_Widget* GetParent();
  FWL_ERR SetParent(CFWL_Widget* pParent);
  CFWL_Widget* GetOwner();
  FWL_ERR SetOwner(CFWL_Widget* pOwner);
  uint32_t GetStyles();
  FWL_ERR ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
  uint32_t GetStylesEx();
  FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
  uint32_t GetStates();
  FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
  FWL_ERR SetPrivateData(void* module_id,
                         void* pData,
                         PD_CALLBACK_FREEDATA callback);
  void* GetPrivateData(void* module_id);
  FWL_ERR Update();
  FWL_ERR LockUpdate();
  FWL_ERR UnlockUpdate();
  uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
  FWL_ERR TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
  FWL_ERR TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt);
  FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
  FWL_ERR SetMatrix(const CFX_Matrix& matrix);
  FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL);
  IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
  FWL_ERR Repaint(const CFX_RectF* pRect = NULL);
  FWL_ERR SetFocus(FX_BOOL bFocus);
  FWL_ERR SetGrab(FX_BOOL bSet);
  CFWL_Widget();

  void RegisterEventTarget(CFWL_Widget* pEventSource = NULL,
                           uint32_t dwFilter = FWL_EVENT_ALL_MASK);
  void DispatchEvent(CFWL_Event* pEvent);
  CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
                         FX_BOOL bMultiLine = FALSE,
                         int32_t iLineWidth = -1);
  IFWL_Widget* m_pIface;
  IFWL_WidgetDelegate* m_pDelegate;
  CFWL_WidgetMgr* m_pWidgetMgr;
  CFWL_WidgetProperties* m_pProperties;
};
class CFWL_WidgetDelegate {
 public:
  CFWL_WidgetDelegate();
  virtual ~CFWL_WidgetDelegate();
  virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
  virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
  virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
                               const CFX_Matrix* pMatrix = NULL);
};

#endif  // XFA_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_