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