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 1: |
163 break; | |
164 } | |
165 case 1: { | |
166 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; | 150 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; |
167 break; | 151 break; |
168 } | 152 case 2: |
169 case 2: { | 153 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) |
170 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { | |
171 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; | 154 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; |
172 } | |
173 break; | 155 break; |
174 } | 156 default: |
175 default: {} | 157 break; |
176 } | 158 } |
177 Repaint(&m_rtClient); | 159 Repaint(&m_rtClient); |
178 return FWL_Error::Succeeded; | |
179 } | 160 } |
180 | 161 |
181 void IFWL_CheckBox::Layout() { | 162 void IFWL_CheckBox::Layout() { |
182 int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); | 163 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); | 164 int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); |
184 m_pProperties->m_rtWidget.width = (FX_FLOAT)width; | 165 m_pProperties->m_rtWidget.width = (FX_FLOAT)width; |
185 m_pProperties->m_rtWidget.height = (FX_FLOAT)height; | 166 m_pProperties->m_rtWidget.height = (FX_FLOAT)height; |
186 GetClientRect(m_rtClient); | 167 GetClientRect(m_rtClient); |
187 FX_FLOAT fBoxTop = m_rtClient.top; | 168 FX_FLOAT fBoxTop = m_rtClient.top; |
188 FX_FLOAT fBoxLeft = m_rtClient.left; | 169 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) { | 510 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
530 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 511 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
531 DispatchKeyEvent(pMsg); | 512 DispatchKeyEvent(pMsg); |
532 return; | 513 return; |
533 } | 514 } |
534 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 515 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
535 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 516 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
536 NextStates(); | 517 NextStates(); |
537 } | 518 } |
538 } | 519 } |
OLD | NEW |