OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/ifwl_pushbutton.h" | 7 #include "xfa/fwl/core/ifwl_pushbutton.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, | 84 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, |
85 const CFX_Matrix* pMatrix) { | 85 const CFX_Matrix* pMatrix) { |
86 if (!pGraphics) | 86 if (!pGraphics) |
87 return; | 87 return; |
88 if (!m_pProperties->m_pThemeProvider) | 88 if (!m_pProperties->m_pThemeProvider) |
89 return; | 89 return; |
90 IFWL_PushButtonDP* pData = | 90 IFWL_PushButtonDP* pData = |
91 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); | 91 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); |
92 CFX_DIBitmap* pPicture = nullptr; | |
93 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 92 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
94 if (HasBorder()) { | 93 if (HasBorder()) { |
95 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, | 94 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, |
96 pMatrix); | 95 pMatrix); |
97 } | 96 } |
98 if (HasEdge()) { | 97 if (HasEdge()) { |
99 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, | 98 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, |
100 pMatrix); | 99 pMatrix); |
101 } | 100 } |
102 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); | 101 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); |
103 CFX_Matrix matrix; | 102 CFX_Matrix matrix; |
104 matrix.Concat(*pMatrix); | 103 matrix.Concat(*pMatrix); |
105 FX_FLOAT iPicwidth = 0; | 104 |
106 FX_FLOAT ipicheight = 0; | |
107 CFX_WideString wsCaption; | 105 CFX_WideString wsCaption; |
108 if (pData) { | 106 if (pData) { |
109 pData->GetCaption(this, wsCaption); | 107 pData->GetCaption(this, wsCaption); |
110 } | 108 } |
111 CFX_RectF rtText; | 109 CFX_RectF rtText; |
112 rtText.Set(0, 0, 0, 0); | 110 rtText.Set(0, 0, 0, 0); |
113 if (!wsCaption.IsEmpty()) | 111 if (!wsCaption.IsEmpty()) |
114 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); | 112 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); |
115 | 113 |
116 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { | 114 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { |
117 case FWL_STYLEEXT_PSB_TextOnly: | 115 case FWL_STYLEEXT_PSB_TextOnly: |
118 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); | 116 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); |
119 break; | 117 break; |
120 case FWL_STYLEEXT_PSB_IconOnly: | 118 case FWL_STYLEEXT_PSB_IconOnly: |
121 if (pData) { | |
122 pPicture = pData->GetPicture(this); | |
123 } | |
124 if (pPicture) { | |
125 CFX_PointF point; | |
126 switch (m_iTTOAlign) { | |
127 case 0: { | |
128 point.x = m_rtClient.left; | |
129 point.y = m_rtClient.top; | |
130 break; | |
131 } | |
132 case 1: { | |
133 point.x = m_rtClient.left + | |
134 (m_rtClient.width / 2 - pPicture->GetWidth() / 2); | |
135 point.y = m_rtClient.top; | |
136 break; | |
137 } | |
138 case 2: | |
139 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); | |
140 point.y = m_rtClient.top; | |
141 break; | |
142 case 4: | |
143 point.x = m_rtClient.left; | |
144 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
145 pPicture->GetHeight() / 2; | |
146 break; | |
147 case 5: | |
148 point.x = m_rtClient.left + | |
149 (m_rtClient.width / 2 - pPicture->GetWidth() / 2); | |
150 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
151 pPicture->GetHeight() / 2; | |
152 break; | |
153 case 6: | |
154 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); | |
155 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
156 pPicture->GetHeight() / 2; | |
157 break; | |
158 case 8: | |
159 point.x = m_rtClient.left; | |
160 point.y = | |
161 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
162 break; | |
163 case 9: | |
164 point.x = m_rtClient.left + | |
165 (m_rtClient.width / 2 - pPicture->GetWidth() / 2); | |
166 point.y = | |
167 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
168 break; | |
169 case 10: | |
170 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); | |
171 point.y = | |
172 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
173 break; | |
174 } | |
175 pGraphics->DrawImage(pPicture, point, &matrix); | |
176 } | |
177 break; | |
178 case FWL_STYLEEXT_PSB_TextIcon: | 119 case FWL_STYLEEXT_PSB_TextIcon: |
179 if (pPicture) { | |
180 CFX_PointF point; | |
181 switch (m_iTTOAlign) { | |
182 case 0: { | |
183 point.x = m_rtClient.left; | |
184 point.y = m_rtClient.top; | |
185 iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); | |
186 ipicheight = | |
187 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; | |
188 break; | |
189 } | |
190 case 1: { | |
191 point.x = | |
192 m_rtClient.left + (m_rtClient.width / 2 - | |
193 (pPicture->GetWidth() + rtText.width) / 2); | |
194 point.y = m_rtClient.top; | |
195 iPicwidth = pPicture->GetWidth() - | |
196 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + | |
197 rtText.width / 2 - 7; | |
198 ipicheight = | |
199 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; | |
200 break; | |
201 } | |
202 case 2: | |
203 point.x = m_rtClient.left + m_rtClient.width - | |
204 pPicture->GetWidth() - rtText.width; | |
205 point.y = m_rtClient.top; | |
206 iPicwidth = m_rtClient.left + m_rtClient.width - point.x - | |
207 pPicture->GetWidth() - rtText.width + 7; | |
208 ipicheight = | |
209 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; | |
210 break; | |
211 case 4: | |
212 point.x = m_rtClient.left; | |
213 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
214 pPicture->GetHeight() / 2; | |
215 iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7; | |
216 break; | |
217 case 5: | |
218 point.x = | |
219 m_rtClient.left + (m_rtClient.width / 2 - | |
220 (pPicture->GetWidth() + rtText.width) / 2); | |
221 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
222 pPicture->GetHeight() / 2; | |
223 iPicwidth = pPicture->GetWidth() - | |
224 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + | |
225 rtText.width / 2 - 7; | |
226 break; | |
227 case 6: | |
228 point.x = m_rtClient.left + m_rtClient.width - | |
229 pPicture->GetWidth() - rtText.width; | |
230 point.y = m_rtClient.top + m_rtClient.height / 2 - | |
231 pPicture->GetHeight() / 2; | |
232 iPicwidth = m_rtClient.left + m_rtClient.width - point.x - | |
233 pPicture->GetWidth() - rtText.width + 7; | |
234 break; | |
235 case 8: | |
236 point.x = m_rtClient.left; | |
237 point.y = | |
238 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
239 iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); | |
240 ipicheight -= rtText.height / 2; | |
241 break; | |
242 case 9: | |
243 point.x = | |
244 m_rtClient.left + (m_rtClient.width / 2 - | |
245 (pPicture->GetWidth() + rtText.width) / 2); | |
246 point.y = | |
247 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
248 iPicwidth = pPicture->GetWidth() - | |
249 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + | |
250 rtText.width / 2 - 7; | |
251 ipicheight -= rtText.height / 2; | |
252 break; | |
253 case 10: | |
254 point.x = m_rtClient.left + m_rtClient.width - | |
255 pPicture->GetWidth() - rtText.width; | |
256 point.y = | |
257 m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); | |
258 iPicwidth = m_rtClient.left + m_rtClient.width - point.x - | |
259 pPicture->GetWidth() - rtText.width + 7; | |
260 ipicheight -= rtText.height / 2; | |
261 break; | |
262 } | |
263 pGraphics->DrawImage(pPicture, point, &matrix); | |
264 } | |
265 matrix.e += m_rtClient.left + iPicwidth; | |
266 matrix.f += m_rtClient.top + ipicheight; | |
267 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); | |
268 break; | 120 break; |
269 } | 121 } |
270 } | 122 } |
271 | 123 |
272 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, | 124 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, |
273 IFWL_ThemeProvider* pTheme, | 125 IFWL_ThemeProvider* pTheme, |
274 const CFX_Matrix* pMatrix) { | 126 const CFX_Matrix* pMatrix) { |
275 CFWL_ThemeBackground param; | 127 CFWL_ThemeBackground param; |
276 param.m_pWidget = this; | 128 param.m_pWidget = this; |
277 param.m_iPart = CFWL_Part::Background; | 129 param.m_iPart = CFWL_Part::Background; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 CFWL_EvtClick wmClick; | 367 CFWL_EvtClick wmClick; |
516 wmClick.m_pSrcTarget = this; | 368 wmClick.m_pSrcTarget = this; |
517 DispatchEvent(&wmClick); | 369 DispatchEvent(&wmClick); |
518 return; | 370 return; |
519 } | 371 } |
520 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) | 372 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) |
521 return; | 373 return; |
522 | 374 |
523 DispatchKeyEvent(pMsg); | 375 DispatchKeyEvent(pMsg); |
524 } | 376 } |
OLD | NEW |