summaryrefslogtreecommitdiff
path: root/xfa/fwl/core/cfwl_datetimepicker.cpp
blob: cead9045d9320dd270f488167ce648e8852ee912 (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
// 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

#include "xfa/fwl/core/cfwl_datetimepicker.h"

#include <memory>

#include "third_party/base/ptr_util.h"
#include "xfa/fwl/core/fwl_error.h"
#include "xfa/fwl/core/ifwl_datetimepicker.h"
#include "xfa/fwl/core/ifwl_widget.h"

namespace {

IFWL_DateTimePicker* ToDateTimePicker(IFWL_Widget* widget) {
  return static_cast<IFWL_DateTimePicker*>(widget);
}

}  // namespace

CFWL_DateTimePicker::CFWL_DateTimePicker(const IFWL_App* app)
    : CFWL_Widget(app) {}

CFWL_DateTimePicker::~CFWL_DateTimePicker() {}

void CFWL_DateTimePicker::Initialize() {
  ASSERT(!m_pIface);

  m_pIface = pdfium::MakeUnique<IFWL_DateTimePicker>(
      m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this));

  CFWL_Widget::Initialize();
}

int32_t CFWL_DateTimePicker::CountSelRanges() {
  return ToDateTimePicker(GetWidget())->CountSelRanges();
}

int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
  return ToDateTimePicker(GetWidget())->GetSelRange(nIndex, nStart);
}

void CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) {
  ToDateTimePicker(GetWidget())->GetEditText(wsText);
}

void CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
  ToDateTimePicker(GetWidget())->SetEditText(wsText);
}

void CFWL_DateTimePicker::SetCurSel(int32_t iYear,
                                    int32_t iMonth,
                                    int32_t iDay) {
  ToDateTimePicker(GetWidget())->SetCurSel(iYear, iMonth, iDay);
}

void CFWL_DateTimePicker::GetCaption(IFWL_Widget* pWidget,
                                     CFX_WideString& wsCaption) {
  wsCaption = m_wsData;
}

void CFWL_DateTimePicker::GetToday(IFWL_Widget* pWidget,
                                   int32_t& iYear,
                                   int32_t& iMonth,
                                   int32_t& iDay) {
  iYear = 2011;
  iMonth = 1;
  iDay = 1;
}

void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
  ToDateTimePicker(GetWidget())->GetBBox(rect);
}

void CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
  ToDateTimePicker(GetWidget())->SetEditLimit(nLimit);
}

void CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
                                             uint32_t dwStylesExRemoved) {
  ToDateTimePicker(GetWidget())
      ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
}