Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_ffpasswordedit.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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/fxfa/cxfa_ffpasswordedit.h"
8
9#include "third_party/base/check.h"
10#include "xfa/fwl/cfwl_edit.h"
11#include "xfa/fwl/cfwl_notedriver.h"
12#include "xfa/fxfa/cxfa_ffdoc.h"
13#include "xfa/fxfa/parser/cxfa_node.h"
14#include "xfa/fxfa/parser/cxfa_passwordedit.h"
15
16CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_Node* pNode,
17 CXFA_PasswordEdit* password_node)
18 : CXFA_FFTextEdit(pNode), password_node_(password_node) {}
19
20CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() = default;
21
22void CXFA_FFPasswordEdit::Trace(cppgc::Visitor* visitor) const {
23 CXFA_FFTextEdit::Trace(visitor);
24 visitor->Trace(password_node_);
25}
26
27bool CXFA_FFPasswordEdit::LoadWidget() {
28 DCHECK(!IsLoaded());
29
30 CFWL_Edit* pWidget = cppgc::MakeGarbageCollected<CFWL_Edit>(
31 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp(),
32 CFWL_Widget::Properties(), nullptr);
33 SetNormalWidget(pWidget);
34 pWidget->SetAdapterIface(this);
35
36 CFWL_NoteDriver* pNoteDriver = pWidget->GetFWLApp()->GetNoteDriver();
37 pNoteDriver->RegisterEventTarget(pWidget, pWidget);
38 m_pOldDelegate = pWidget->GetDelegate();
39 pWidget->SetDelegate(this);
40
41 {
42 CFWL_Widget::ScopedUpdateLock update_lock(pWidget);
43 pWidget->SetText(m_pNode->GetValue(XFA_ValuePicture::kDisplay));
45 }
46
48}
49
50void CXFA_FFPasswordEdit::UpdateWidgetProperty() {
51 CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(GetNormalWidget());
52 if (!pWidget)
53 return;
54
55 uint32_t dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus |
58 dwExtendedStyle |= UpdateUIProperty();
59
60 WideString password = password_node_->GetPasswordChar();
61 if (!password.IsEmpty())
62 pWidget->SetAliasChar(password[0]);
63 if (!m_pNode->IsHorizontalScrollPolicyOff())
64 dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll;
65 if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive())
66 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly;
67
68 dwExtendedStyle |= GetAlignment();
69 GetNormalWidget()->ModifyStyleExts(dwExtendedStyle, 0xFFFFFFFF);
70}
#define FWL_STYLEEXT_EDT_ShowScrollbarFocus
Definition cfwl_edit.h:38
#define FWL_STYLEEXT_EDT_OuterScrollbar
Definition cfwl_edit.h:39
#define FWL_STYLEEXT_EDT_AutoHScroll
Definition cfwl_edit.h:22
#define FWL_STYLEEXT_EDT_ReadOnly
Definition cfwl_edit.h:19
#define FWL_STYLEEXT_EDT_Password
Definition cfwl_edit.h:25
void SetAliasChar(wchar_t wAlias)
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
void SetDelegate(IFWL_WidgetDelegate *delegate)
void SetAdapterIface(AdapterIface *pItem)
CFWL_App * GetFWLApp() const
bool LoadWidget() override
void SetNormalWidget(CFWL_Widget *widget)
uint32_t UpdateUIProperty()
~CXFA_FFPasswordEdit() override
void UpdateWidgetProperty() override
void Trace(cppgc::Visitor *visitor) const override
CXFA_FFTextEdit(CXFA_Node *pNode)
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
Definition heap.h:12