1 // 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 
7 #include <memory>
8 
9 #include "xfa/src/foxitlib.h"
10 #include "xfa/src/fwl/src/core/include/fwl_targetimp.h"
11 #include "xfa/src/fwl/src/core/include/fwl_noteimp.h"
12 #include "xfa/src/fwl/src/core/include/fwl_widgetimp.h"
13 #include "xfa/src/fwl/src/core/include/fwl_panelimp.h"
14 #include "xfa/src/fwl/src/core/include/fwl_formimp.h"
15 #include "xfa/src/fwl/src/core/include/fwl_threadimp.h"
16 
Create()17 CFWL_ToolTip* CFWL_ToolTip::Create() {
18   return new CFWL_ToolTip;
19 }
Initialize(const CFWL_WidgetProperties * pProperties)20 FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) {
21   if (m_pIface)
22     return FWL_ERR_Indefinite;
23   if (pProperties) {
24     *m_pProperties = *pProperties;
25   }
26   std::unique_ptr<IFWL_ToolTip> pToolTip(IFWL_ToolTip::Create(
27       m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr));
28   FWL_ERR ret = pToolTip->Initialize();
29   if (ret != FWL_ERR_Succeeded) {
30     return ret;
31   }
32   m_pIface = pToolTip.release();
33   CFWL_Widget::Initialize();
34   return FWL_ERR_Succeeded;
35 }
GetCaption(CFX_WideString & wsCaption)36 FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) {
37   wsCaption = m_tooltipData.m_wsCaption;
38   return FWL_ERR_Succeeded;
39 }
SetCaption(const CFX_WideStringC & wsCaption)40 FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) {
41   m_tooltipData.m_wsCaption = wsCaption;
42   return FWL_ERR_Succeeded;
43 }
GetInitialDelay()44 int32_t CFWL_ToolTip::GetInitialDelay() {
45   return m_tooltipData.m_nInitDelayTime;
46 }
SetInitialDelay(int32_t nDelayTime)47 int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) {
48   m_tooltipData.m_nInitDelayTime = nDelayTime;
49   return FWL_ERR_Succeeded;
50 }
GetAutoPopDelay()51 int32_t CFWL_ToolTip::GetAutoPopDelay() {
52   return m_tooltipData.m_nAutoPopDelayTime;
53 }
SetAutoPopDelay(int32_t nDelayTime)54 int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) {
55   m_tooltipData.m_nAutoPopDelayTime = nDelayTime;
56   return FWL_ERR_Succeeded;
57 }
GetToolTipIcon()58 CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() {
59   return m_tooltipData.m_pBitmap;
60 }
SetToolTipIcon(CFX_DIBitmap * pBitmap)61 FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) {
62   m_tooltipData.m_pBitmap = pBitmap;
63   return FWL_ERR_Succeeded;
64 }
GetToolTipIconSize()65 CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() {
66   return m_tooltipData.m_fIconSize;
67 }
SetToolTipIconSize(CFX_SizeF fSize)68 FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) {
69   m_tooltipData.m_fIconSize = fSize;
70   return FWL_ERR_Succeeded;
71 }
SetAnchor(const CFX_RectF & rtAnchor)72 FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
73   return static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor);
74 }
Show()75 FWL_ERR CFWL_ToolTip::Show() {
76   return static_cast<IFWL_ToolTip*>(m_pIface)->Show();
77 }
Hide()78 FWL_ERR CFWL_ToolTip::Hide() {
79   return static_cast<IFWL_ToolTip*>(m_pIface)->Hide();
80 }
CFWL_ToolTip()81 CFWL_ToolTip::CFWL_ToolTip() {}
~CFWL_ToolTip()82 CFWL_ToolTip::~CFWL_ToolTip() {}
CFWL_ToolTipDP()83 CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) {
84   m_wsCaption = L"";
85   m_nInitDelayTime = 500;
86   m_nAutoPopDelayTime = 50000;
87   m_fIconSize.Set(0.0, 0.0);
88   m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
89 }
GetCaption(IFWL_Widget * pWidget,CFX_WideString & wsCaption)90 FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget,
91                                                  CFX_WideString& wsCaption) {
92   wsCaption = m_wsCaption;
93   return FWL_ERR_Succeeded;
94 }
GetInitialDelay(IFWL_Widget * pWidget)95 int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
96   return m_nInitDelayTime;
97 }
GetAutoPopDelay(IFWL_Widget * pWidget)98 int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
99   return m_nAutoPopDelayTime;
100 }
GetToolTipIcon(IFWL_Widget * pWidget)101 CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon(
102     IFWL_Widget* pWidget) {
103   return m_pBitmap;
104 }
GetToolTipIconSize(IFWL_Widget * pWidget)105 CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize(
106     IFWL_Widget* pWidget) {
107   return m_fIconSize;
108 }
GetAnchor()109 CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() {
110   return m_fAnchor;
111 }
112