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_checkbox.h" | 7 #include "xfa/fwl/core/ifwl_checkbox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 textParam.m_matrix.Concat(*pMatrix); | 136 textParam.m_matrix.Concat(*pMatrix); |
137 } | 137 } |
138 textParam.m_rtPart = m_rtCaption; | 138 textParam.m_rtPart = m_rtCaption; |
139 textParam.m_wsText = wsCaption; | 139 textParam.m_wsText = wsCaption; |
140 textParam.m_dwTTOStyles = m_dwTTOStyles; | 140 textParam.m_dwTTOStyles = m_dwTTOStyles; |
141 textParam.m_iTTOAlign = m_iTTOAlign; | 141 textParam.m_iTTOAlign = m_iTTOAlign; |
142 pTheme->DrawText(&textParam); | 142 pTheme->DrawText(&textParam); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 int32_t IFWL_CheckBox::GetCheckState() { | 146 void IFWL_CheckBox::SetCheckState(int32_t iCheck) { |
147 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) && | |
148 ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | |
149 FWL_STATE_CKB_Neutral)) { | |
150 return 2; | |
151 } | |
152 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | |
153 FWL_STATE_CKB_Checked) { | |
154 return 1; | |
155 } | |
156 return 0; | |
157 } | |
158 | |
159 FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) { | |
160 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; | 147 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; |
161 switch (iCheck) { | 148 switch (iCheck) { |
162 case 0: { | 149 case 0: { |
npm
2016/11/14 15:19:30
nit: I think we don't use braces in switch cases?
dsinclair
2016/11/14 16:40:37
Done.
| |
163 break; | 150 break; |
164 } | 151 } |
npm
2016/11/14 15:19:30
nit: remove case 0
dsinclair
2016/11/14 16:40:37
Done.
| |
165 case 1: { | 152 case 1: { |
166 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; | 153 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; |
167 break; | 154 break; |
168 } | 155 } |
169 case 2: { | 156 case 2: { |
170 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { | 157 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { |
171 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; | 158 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; |
172 } | 159 } |
173 break; | 160 break; |
174 } | 161 } |
175 default: {} | 162 default: |
163 break; | |
176 } | 164 } |
177 Repaint(&m_rtClient); | 165 Repaint(&m_rtClient); |
178 return FWL_Error::Succeeded; | |
179 } | 166 } |
180 | 167 |
181 void IFWL_CheckBox::Layout() { | 168 void IFWL_CheckBox::Layout() { |
182 int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); | 169 int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); |
183 int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); | 170 int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); |
184 m_pProperties->m_rtWidget.width = (FX_FLOAT)width; | 171 m_pProperties->m_rtWidget.width = (FX_FLOAT)width; |
185 m_pProperties->m_rtWidget.height = (FX_FLOAT)height; | 172 m_pProperties->m_rtWidget.height = (FX_FLOAT)height; |
186 GetClientRect(m_rtClient); | 173 GetClientRect(m_rtClient); |
187 FX_FLOAT fBoxTop = m_rtClient.top; | 174 FX_FLOAT fBoxTop = m_rtClient.top; |
188 FX_FLOAT fBoxLeft = m_rtClient.left; | 175 FX_FLOAT fBoxLeft = m_rtClient.left; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 516 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
530 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 517 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
531 DispatchKeyEvent(pMsg); | 518 DispatchKeyEvent(pMsg); |
532 return; | 519 return; |
533 } | 520 } |
534 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 521 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
535 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 522 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
536 NextStates(); | 523 NextStates(); |
537 } | 524 } |
538 } | 525 } |
OLD | NEW |