Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Signature.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "fpdfsdk/include/pdfwindow/PWL_Signature.h"
8
9 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_Label.h"
11 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
12 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
13
14 CPWL_Signature_Image::CPWL_Signature_Image() : m_pImage(NULL) {}
15
16 CPWL_Signature_Image::~CPWL_Signature_Image() {}
17
18 void CPWL_Signature_Image::SetImage(CFX_DIBSource* pImage) {
19 m_pImage = pImage;
20 }
21
22 CFX_DIBSource* CPWL_Signature_Image::GetImage() {
23 return m_pImage;
24 }
25
26 void CPWL_Signature_Image::DrawThisAppearance(CFX_RenderDevice* pDevice,
27 CFX_Matrix* pUser2Device) {
28 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
29
30 if (m_pImage) {
31 CFX_FloatRect rcClient = GetClientRect();
32
33 FX_FLOAT x, y;
34 pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
35
36 pDevice->StretchDIBits(m_pImage, (int32_t)x, (int32_t)y,
37 (int32_t)rcClient.Width(),
38 (int32_t)rcClient.Height());
39 }
40 }
41
42 void CPWL_Signature_Image::GetThisAppearanceStream(
43 CFX_ByteTextBuf& sAppStream) {
44 sAppStream << CPWL_Image::GetImageAppStream();
45 }
46
47 void CPWL_Signature_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
48 FX_FLOAT fImageW, fImageH;
49
50 GetImageSize(fImageW, fImageH);
51
52 CFX_FloatRect rcClient = GetClientRect();
53
54 fHScale = rcClient.Width() / fImageW;
55 fVScale = rcClient.Height() / fImageH;
56 }
57
58 CPWL_Signature::CPWL_Signature()
59 : m_pText(NULL),
60 m_pDescription(NULL),
61 m_pImage(NULL),
62 m_bTextExist(TRUE),
63 m_bImageExist(FALSE),
64 m_bFlagExist(TRUE) {}
65
66 CPWL_Signature::~CPWL_Signature() {}
67
68 void CPWL_Signature::SetTextFlag(FX_BOOL bTextExist) {
69 m_bTextExist = bTextExist;
70
71 RePosChildWnd();
72 }
73
74 void CPWL_Signature::SetImageFlag(FX_BOOL bImageExist) {
75 m_bImageExist = bImageExist;
76
77 RePosChildWnd();
78 }
79
80 void CPWL_Signature::SetFoxitFlag(FX_BOOL bFlagExist) {
81 m_bFlagExist = bFlagExist;
82 }
83
84 void CPWL_Signature::SetText(const FX_WCHAR* sText) {
85 m_pText->SetText(sText);
86
87 RePosChildWnd();
88 }
89
90 void CPWL_Signature::SetDescription(const FX_WCHAR* str) {
91 m_pDescription->SetText(str);
92
93 RePosChildWnd();
94 }
95
96 void CPWL_Signature::SetImage(CFX_DIBSource* pImage) {
97 m_pImage->SetImage(pImage);
98
99 RePosChildWnd();
100 }
101
102 void CPWL_Signature::SetImageStream(CPDF_Stream* pStream,
103 const FX_CHAR* sImageAlias) {
104 m_pImage->SetPDFStream(pStream);
105 m_pImage->SetImageAlias(sImageAlias);
106
107 RePosChildWnd();
108 }
109
110 void CPWL_Signature::RePosChildWnd() {
111 CFX_FloatRect rcClient = GetClientRect();
112
113 CFX_FloatRect rcText = rcClient;
114 CFX_FloatRect rcDescription = rcClient;
115
116 FX_BOOL bTextVisible = m_bTextExist && m_pText->GetText().GetLength() > 0;
117
118 if ((bTextVisible || m_bImageExist) &&
119 m_pDescription->GetText().GetLength() > 0) {
120 if (rcClient.Width() >= rcClient.Height()) {
121 rcText.right = rcText.left + rcClient.Width() / 2.0f;
122 rcDescription.left = rcDescription.right - rcClient.Width() / 2.0f;
123 } else {
124 rcText.bottom = rcText.top - rcClient.Height() / 2.0f;
125 rcDescription.top = rcDescription.bottom + rcClient.Height() / 2.0f;
126 }
127 }
128
129 m_pText->SetVisible(bTextVisible);
130 m_pImage->SetVisible(m_bImageExist);
131
132 m_pText->Move(rcText, TRUE, FALSE);
133 m_pImage->Move(rcText, TRUE, FALSE);
134 m_pDescription->Move(rcDescription, TRUE, FALSE);
135 }
136
137 void CPWL_Signature::CreateChildWnd(const PWL_CREATEPARAM& cp) {
138 m_pImage = new CPWL_Signature_Image;
139 PWL_CREATEPARAM icp = cp;
140 icp.pParentWnd = this;
141 icp.dwFlags = PWS_CHILD | PWS_VISIBLE;
142 icp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
143 m_pImage->Create(icp);
144
145 m_pText = new CPWL_Label;
146 PWL_CREATEPARAM acp = cp;
147 acp.pParentWnd = this;
148 acp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_AUTOFONTSIZE | PES_MULTILINE |
149 PES_AUTORETURN | PES_MIDDLE | PES_CENTER;
150 acp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
151 m_pText->Create(acp);
152
153 m_pDescription = new CPWL_Label;
154 PWL_CREATEPARAM dcp = cp;
155 dcp.pParentWnd = this;
156 dcp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_AUTOFONTSIZE | PES_MULTILINE |
157 PES_AUTORETURN | PES_LEFT | PES_CENTER;
158 dcp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
159 m_pDescription->Create(dcp);
160 }
161
162 void CPWL_Signature::DrawThisAppearance(CFX_RenderDevice* pDevice,
163 CFX_Matrix* pUser2Device) {
164 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
165
166 if (m_bFlagExist) {
167 CPWL_Utils::DrawIconAppStream(
168 pDevice, pUser2Device, PWL_ICONTYPE_FOXIT,
169 CPWL_Utils::GetCenterSquare(GetClientRect()),
170 CPWL_Color(COLORTYPE_RGB, 0.91f, 0.855f, 0.92f),
171 CPWL_Color(COLORTYPE_TRANSPARENT), 255);
172 }
173 }
174
175 void CPWL_Signature::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
176 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
177 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698