blob: ea176270638187d3ce0e2412d8922844e2679c1d [file] [log] [blame]
Tom Sepez99ffdb02016-01-26 14:51:21 -08001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dsinclair7f432a12016-03-29 12:38:01 -07007#ifndef XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_
8#define XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_
Tom Sepez99ffdb02016-01-26 14:51:21 -08009
Dan Sinclair398a43d2016-03-23 15:51:01 -040010#include "xfa/fwl/core/cfwl_event.h"
dsinclair7f432a12016-03-29 12:38:01 -070011#include "xfa/fwl/lightwidget/cfwl_widgetproperties.h"
Dan Sinclair398a43d2016-03-23 15:51:01 -040012#include "xfa/fwl/core/ifwl_widget.h"
Tom Sepez99ffdb02016-01-26 14:51:21 -080013
14class CFWL_Event;
15class CFWL_Message;
16class CFWL_Widget;
17class CFWL_WidgetDelegate;
18class CFWL_WidgetMgr;
19
Tom Sepez99ffdb02016-01-26 14:51:21 -080020class CFWL_Widget {
21 public:
22 virtual ~CFWL_Widget();
dsinclairb4d40ff2016-05-05 10:28:02 -070023
Tom Sepez99ffdb02016-01-26 14:51:21 -080024 IFWL_Widget* GetWidget();
dsinclairc777f482016-05-04 17:57:03 -070025 FWL_Error GetClassName(CFX_WideString& wsClass) const;
dsinclairb4d40ff2016-05-05 10:28:02 -070026 FWL_Type GetClassID() const;
Tom Sepez99ffdb02016-01-26 14:51:21 -080027 virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
28
dsinclairc777f482016-05-04 17:57:03 -070029 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
30 FWL_Error GetGlobalRect(CFX_RectF& rect);
31 FWL_Error SetWidgetRect(const CFX_RectF& rect);
32 FWL_Error GetClientRect(CFX_RectF& rtClient);
Tom Sepez99ffdb02016-01-26 14:51:21 -080033 CFWL_Widget* GetParent();
dsinclairc777f482016-05-04 17:57:03 -070034 FWL_Error SetParent(CFWL_Widget* pParent);
Tom Sepez99ffdb02016-01-26 14:51:21 -080035 CFWL_Widget* GetOwner();
dsinclairc777f482016-05-04 17:57:03 -070036 FWL_Error SetOwner(CFWL_Widget* pOwner);
tsepezdeee3d22016-03-25 14:38:58 -070037 uint32_t GetStyles();
dsinclairc777f482016-05-04 17:57:03 -070038 FWL_Error ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
tsepezdeee3d22016-03-25 14:38:58 -070039 uint32_t GetStylesEx();
dsinclairc777f482016-05-04 17:57:03 -070040 FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
41 uint32_t dwStylesExRemoved);
tsepezdeee3d22016-03-25 14:38:58 -070042 uint32_t GetStates();
dsinclair55fa3562016-05-04 14:24:53 -070043 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
tsepez54ab2342016-05-26 17:35:54 -070044 void* GetLayoutItem() const;
45 void SetLayoutItem(void* pItem);
46
dsinclairc777f482016-05-04 17:57:03 -070047 FWL_Error SetPrivateData(void* module_id,
48 void* pData,
49 PD_CALLBACK_FREEDATA callback);
Tom Sepez99ffdb02016-01-26 14:51:21 -080050 void* GetPrivateData(void* module_id);
dsinclairc777f482016-05-04 17:57:03 -070051 FWL_Error Update();
52 FWL_Error LockUpdate();
53 FWL_Error UnlockUpdate();
dsinclair89fcde82016-05-03 13:00:25 -070054 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
dsinclairc777f482016-05-04 17:57:03 -070055 FWL_Error TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
56 FWL_Error TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt);
57 FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
58 FWL_Error SetMatrix(const CFX_Matrix& matrix);
59 FWL_Error DrawWidget(CFX_Graphics* pGraphics,
60 const CFX_Matrix* pMatrix = NULL);
Tom Sepez99ffdb02016-01-26 14:51:21 -080061 IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
dsinclairc777f482016-05-04 17:57:03 -070062 FWL_Error Repaint(const CFX_RectF* pRect = NULL);
63 FWL_Error SetFocus(FX_BOOL bFocus);
64 FWL_Error SetGrab(FX_BOOL bSet);
Tom Sepez99ffdb02016-01-26 14:51:21 -080065 CFWL_Widget();
66
67 void RegisterEventTarget(CFWL_Widget* pEventSource = NULL,
tsepezdeee3d22016-03-25 14:38:58 -070068 uint32_t dwFilter = FWL_EVENT_ALL_MASK);
Tom Sepez99ffdb02016-01-26 14:51:21 -080069 void DispatchEvent(CFWL_Event* pEvent);
70 CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
71 FX_BOOL bMultiLine = FALSE,
72 int32_t iLineWidth = -1);
73 IFWL_Widget* m_pIface;
74 IFWL_WidgetDelegate* m_pDelegate;
75 CFWL_WidgetMgr* m_pWidgetMgr;
76 CFWL_WidgetProperties* m_pProperties;
dsinclair7f432a12016-03-29 12:38:01 -070077
78 protected:
dsinclairc777f482016-05-04 17:57:03 -070079 FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
Tom Sepez99ffdb02016-01-26 14:51:21 -080080};
Dan Sinclairc7cd8092016-02-18 15:02:55 -050081
dsinclair7f432a12016-03-29 12:38:01 -070082#endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_