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

Side by Side Diff: xfa/fwl/core/ifwl_checkbox.cpp

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 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 | « xfa/fwl/core/ifwl_checkbox.h ('k') | xfa/fwl/core/ifwl_combobox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basewidget/fwl_checkboximp.h" 7 #include "xfa/fwl/core/ifwl_checkbox.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "xfa/fde/tto/fde_textout.h" 11 #include "xfa/fde/tto/fde_textout.h"
12 #include "xfa/fwl/basewidget/ifwl_checkbox.h"
13 #include "xfa/fwl/core/cfwl_message.h" 12 #include "xfa/fwl/core/cfwl_message.h"
14 #include "xfa/fwl/core/cfwl_themebackground.h" 13 #include "xfa/fwl/core/cfwl_themebackground.h"
15 #include "xfa/fwl/core/cfwl_themetext.h" 14 #include "xfa/fwl/core/cfwl_themetext.h"
16 #include "xfa/fwl/core/cfwl_widgetmgr.h" 15 #include "xfa/fwl/core/cfwl_widgetmgr.h"
17 #include "xfa/fwl/core/fwl_noteimp.h" 16 #include "xfa/fwl/core/fwl_noteimp.h"
18 #include "xfa/fwl/core/fwl_widgetimp.h" 17 #include "xfa/fwl/core/ifwl_checkbox.h"
19 #include "xfa/fwl/core/ifwl_themeprovider.h" 18 #include "xfa/fwl/core/ifwl_themeprovider.h"
20 19
21 namespace { 20 namespace {
22 21
23 const int kCaptionMargin = 5; 22 const int kCaptionMargin = 5;
24 23
25 } // namespace 24 } // namespace
26 25
27 // static 26 // static
28 IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, 27 IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties,
29 IFWL_Widget* pOuter) { 28 IFWL_Widget* pOuter) {
30 IFWL_CheckBox* pCheckBox = new IFWL_CheckBox; 29 return new IFWL_CheckBox(properties, pOuter);
31 CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter);
32 pCheckBox->SetImpl(pCheckBoxImpl);
33 pCheckBoxImpl->SetInterface(pCheckBox);
34 return pCheckBox;
35 }
36 IFWL_CheckBox::IFWL_CheckBox() {}
37 int32_t IFWL_CheckBox::GetCheckState() {
38 return static_cast<CFWL_CheckBoxImp*>(GetImpl())->GetCheckState();
39 }
40 FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) {
41 return static_cast<CFWL_CheckBoxImp*>(GetImpl())->SetCheckState(iCheck);
42 } 30 }
43 31
44 CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties, 32 IFWL_CheckBox::IFWL_CheckBox(const CFWL_WidgetImpProperties& properties,
45 IFWL_Widget* pOuter) 33 IFWL_Widget* pOuter)
46 : CFWL_WidgetImp(properties, pOuter), 34 : IFWL_Widget(properties, pOuter),
47 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), 35 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
48 m_iTTOAlign(FDE_TTOALIGNMENT_Center), 36 m_iTTOAlign(FDE_TTOALIGNMENT_Center),
49 m_bBtnDown(FALSE) { 37 m_bBtnDown(FALSE) {
50 m_rtClient.Reset(); 38 m_rtClient.Reset();
51 m_rtBox.Reset(); 39 m_rtBox.Reset();
52 m_rtCaption.Reset(); 40 m_rtCaption.Reset();
53 m_rtFocus.Reset(); 41 m_rtFocus.Reset();
54 } 42 }
55 43
56 CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {} 44 IFWL_CheckBox::~IFWL_CheckBox() {}
57 45
58 FWL_Error CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const { 46 FWL_Error IFWL_CheckBox::GetClassName(CFX_WideString& wsClass) const {
59 wsClass = FWL_CLASS_CheckBox; 47 wsClass = FWL_CLASS_CheckBox;
60 return FWL_Error::Succeeded; 48 return FWL_Error::Succeeded;
61 } 49 }
62 50
63 FWL_Type CFWL_CheckBoxImp::GetClassID() const { 51 FWL_Type IFWL_CheckBox::GetClassID() const {
64 return FWL_Type::CheckBox; 52 return FWL_Type::CheckBox;
65 } 53 }
66 54
67 FWL_Error CFWL_CheckBoxImp::Initialize() { 55 FWL_Error IFWL_CheckBox::Initialize() {
68 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 56 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
69 return FWL_Error::Indefinite; 57 return FWL_Error::Indefinite;
70 58
71 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); 59 m_pDelegate = new CFWL_CheckBoxImpDelegate(this);
72 return FWL_Error::Succeeded; 60 return FWL_Error::Succeeded;
73 } 61 }
74 62
75 FWL_Error CFWL_CheckBoxImp::Finalize() { 63 FWL_Error IFWL_CheckBox::Finalize() {
76 delete m_pDelegate; 64 delete m_pDelegate;
77 m_pDelegate = nullptr; 65 m_pDelegate = nullptr;
78 return CFWL_WidgetImp::Finalize(); 66 return IFWL_Widget::Finalize();
79 } 67 }
80 FWL_Error CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 68
69 FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
81 if (bAutoSize) { 70 if (bAutoSize) {
82 rect.Set(0, 0, 0, 0); 71 rect.Set(0, 0, 0, 0);
83 if (!m_pProperties->m_pThemeProvider) 72 if (!m_pProperties->m_pThemeProvider)
84 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 73 m_pProperties->m_pThemeProvider = GetAvailableTheme();
85 if (!m_pProperties->m_pThemeProvider) 74 if (!m_pProperties->m_pThemeProvider)
86 return FWL_Error::Indefinite; 75 return FWL_Error::Indefinite;
87 if (!m_pProperties->m_pDataProvider) 76 if (!m_pProperties->m_pDataProvider)
88 return FWL_Error::Indefinite; 77 return FWL_Error::Indefinite;
89 CFX_WideString wsCaption; 78 CFX_WideString wsCaption;
90 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); 79 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
91 if (wsCaption.GetLength() > 0) { 80 if (wsCaption.GetLength() > 0) {
92 CFX_SizeF sz = CalcTextSize( 81 CFX_SizeF sz = CalcTextSize(
93 wsCaption, m_pProperties->m_pThemeProvider, 82 wsCaption, m_pProperties->m_pThemeProvider,
94 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); 83 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine);
95 rect.Set(0, 0, sz.x, sz.y); 84 rect.Set(0, 0, sz.x, sz.y);
96 } 85 }
97 rect.Inflate(kCaptionMargin, kCaptionMargin); 86 rect.Inflate(kCaptionMargin, kCaptionMargin);
98 IFWL_CheckBoxDP* pData = 87 IFWL_CheckBoxDP* pData =
99 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); 88 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider);
100 FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); 89 FX_FLOAT fCheckBox = pData->GetBoxSize(this);
101 rect.width += fCheckBox; 90 rect.width += fCheckBox;
102 if (rect.height < fCheckBox) { 91 if (rect.height < fCheckBox) {
103 rect.height = fCheckBox; 92 rect.height = fCheckBox;
104 } 93 }
105 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 94 IFWL_Widget::GetWidgetRect(rect, TRUE);
106 } else { 95 } else {
107 rect = m_pProperties->m_rtWidget; 96 rect = m_pProperties->m_rtWidget;
108 } 97 }
109 return FWL_Error::Succeeded; 98 return FWL_Error::Succeeded;
110 } 99 }
111 FWL_Error CFWL_CheckBoxImp::Update() { 100
101 FWL_Error IFWL_CheckBox::Update() {
112 if (IsLocked()) { 102 if (IsLocked()) {
113 return FWL_Error::Indefinite; 103 return FWL_Error::Indefinite;
114 } 104 }
115 if (!m_pProperties->m_pThemeProvider) { 105 if (!m_pProperties->m_pThemeProvider) {
116 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 106 m_pProperties->m_pThemeProvider = GetAvailableTheme();
117 } 107 }
118 UpdateTextOutStyles(); 108 UpdateTextOutStyles();
119 Layout(); 109 Layout();
120 return FWL_Error::Succeeded; 110 return FWL_Error::Succeeded;
121 } 111 }
122 FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics, 112
123 const CFX_Matrix* pMatrix) { 113 FWL_Error IFWL_CheckBox::DrawWidget(CFX_Graphics* pGraphics,
114 const CFX_Matrix* pMatrix) {
124 if (!pGraphics) 115 if (!pGraphics)
125 return FWL_Error::Indefinite; 116 return FWL_Error::Indefinite;
126 if (!m_pProperties->m_pThemeProvider) 117 if (!m_pProperties->m_pThemeProvider)
127 return FWL_Error::Indefinite; 118 return FWL_Error::Indefinite;
128 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 119 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
129 if (HasBorder()) { 120 if (HasBorder()) {
130 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, 121 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
131 pMatrix); 122 pMatrix);
132 } 123 }
133 if (HasEdge()) { 124 if (HasEdge()) {
134 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 125 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
135 } 126 }
136 int32_t dwStates = GetPartStates(); 127 int32_t dwStates = GetPartStates();
137 { 128 {
138 CFWL_ThemeBackground param; 129 CFWL_ThemeBackground param;
139 param.m_pWidget = m_pInterface; 130 param.m_pWidget = this;
140 param.m_iPart = CFWL_Part::Background; 131 param.m_iPart = CFWL_Part::Background;
141 param.m_dwStates = dwStates; 132 param.m_dwStates = dwStates;
142 param.m_pGraphics = pGraphics; 133 param.m_pGraphics = pGraphics;
143 if (pMatrix) { 134 if (pMatrix) {
144 param.m_matrix.Concat(*pMatrix); 135 param.m_matrix.Concat(*pMatrix);
145 } 136 }
146 param.m_rtPart = m_rtClient; 137 param.m_rtPart = m_rtClient;
147 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 138 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
148 param.m_pData = &m_rtFocus; 139 param.m_pData = &m_rtFocus;
149 } 140 }
150 pTheme->DrawBackground(&param); 141 pTheme->DrawBackground(&param);
151 param.m_iPart = CFWL_Part::CheckBox; 142 param.m_iPart = CFWL_Part::CheckBox;
152 param.m_rtPart = m_rtBox; 143 param.m_rtPart = m_rtBox;
153 pTheme->DrawBackground(&param); 144 pTheme->DrawBackground(&param);
154 } 145 }
155 if (!m_pProperties->m_pDataProvider) 146 if (!m_pProperties->m_pDataProvider)
156 return FWL_Error::Indefinite; 147 return FWL_Error::Indefinite;
157 { 148 {
158 CFX_WideString wsCaption; 149 CFX_WideString wsCaption;
159 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); 150 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
160 int32_t iLen = wsCaption.GetLength(); 151 int32_t iLen = wsCaption.GetLength();
161 if (iLen <= 0) 152 if (iLen <= 0)
162 return FWL_Error::Indefinite; 153 return FWL_Error::Indefinite;
163 CFWL_ThemeText textParam; 154 CFWL_ThemeText textParam;
164 textParam.m_pWidget = m_pInterface; 155 textParam.m_pWidget = this;
165 textParam.m_iPart = CFWL_Part::Caption; 156 textParam.m_iPart = CFWL_Part::Caption;
166 textParam.m_dwStates = dwStates; 157 textParam.m_dwStates = dwStates;
167 textParam.m_pGraphics = pGraphics; 158 textParam.m_pGraphics = pGraphics;
168 if (pMatrix) { 159 if (pMatrix) {
169 textParam.m_matrix.Concat(*pMatrix); 160 textParam.m_matrix.Concat(*pMatrix);
170 } 161 }
171 textParam.m_rtPart = m_rtCaption; 162 textParam.m_rtPart = m_rtCaption;
172 textParam.m_wsText = wsCaption; 163 textParam.m_wsText = wsCaption;
173 textParam.m_dwTTOStyles = m_dwTTOStyles; 164 textParam.m_dwTTOStyles = m_dwTTOStyles;
174 textParam.m_iTTOAlign = m_iTTOAlign; 165 textParam.m_iTTOAlign = m_iTTOAlign;
175 pTheme->DrawText(&textParam); 166 pTheme->DrawText(&textParam);
176 } 167 }
177 return FWL_Error::Succeeded; 168 return FWL_Error::Succeeded;
178 } 169 }
179 int32_t CFWL_CheckBoxImp::GetCheckState() { 170
171 int32_t IFWL_CheckBox::GetCheckState() {
180 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) && 172 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) &&
181 ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 173 ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
182 FWL_STATE_CKB_Neutral)) { 174 FWL_STATE_CKB_Neutral)) {
183 return 2; 175 return 2;
184 } 176 }
185 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 177 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
186 FWL_STATE_CKB_Checked) { 178 FWL_STATE_CKB_Checked) {
187 return 1; 179 return 1;
188 } 180 }
189 return 0; 181 return 0;
190 } 182 }
191 FWL_Error CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) { 183
184 FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) {
192 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; 185 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
193 switch (iCheck) { 186 switch (iCheck) {
194 case 0: { 187 case 0: {
195 break; 188 break;
196 } 189 }
197 case 1: { 190 case 1: {
198 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 191 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
199 break; 192 break;
200 } 193 }
201 case 2: { 194 case 2: {
202 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { 195 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
203 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; 196 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
204 } 197 }
205 break; 198 break;
206 } 199 }
207 default: {} 200 default: {}
208 } 201 }
209 Repaint(&m_rtClient); 202 Repaint(&m_rtClient);
210 return FWL_Error::Succeeded; 203 return FWL_Error::Succeeded;
211 } 204 }
212 void CFWL_CheckBoxImp::Layout() { 205
206 void IFWL_CheckBox::Layout() {
213 int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); 207 int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f);
214 int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); 208 int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f);
215 m_pProperties->m_rtWidget.width = (FX_FLOAT)width; 209 m_pProperties->m_rtWidget.width = (FX_FLOAT)width;
216 m_pProperties->m_rtWidget.height = (FX_FLOAT)height; 210 m_pProperties->m_rtWidget.height = (FX_FLOAT)height;
217 GetClientRect(m_rtClient); 211 GetClientRect(m_rtClient);
218 FX_FLOAT fBoxTop = m_rtClient.top; 212 FX_FLOAT fBoxTop = m_rtClient.top;
219 FX_FLOAT fBoxLeft = m_rtClient.left; 213 FX_FLOAT fBoxLeft = m_rtClient.left;
220 FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0; 214 FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0;
221 FX_FLOAT fClientRight = m_rtClient.right(); 215 FX_FLOAT fClientRight = m_rtClient.right();
222 FX_FLOAT fClientBottom = m_rtClient.bottom(); 216 FX_FLOAT fClientBottom = m_rtClient.bottom();
223 if (!m_pProperties->m_pDataProvider) 217 if (!m_pProperties->m_pDataProvider)
224 return; 218 return;
225 IFWL_CheckBoxDP* pData = 219 IFWL_CheckBoxDP* pData =
226 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); 220 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider);
227 FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); 221 FX_FLOAT fCheckBox = pData->GetBoxSize(this);
228 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { 222 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) {
229 case FWL_STYLEEXT_CKB_Top: { 223 case FWL_STYLEEXT_CKB_Top: {
230 fBoxTop = m_rtClient.top; 224 fBoxTop = m_rtClient.top;
231 break; 225 break;
232 } 226 }
233 case FWL_STYLEEXT_CKB_Bottom: { 227 case FWL_STYLEEXT_CKB_Bottom: {
234 fBoxTop = fClientBottom - fCheckBox; 228 fBoxTop = fClientBottom - fCheckBox;
235 break; 229 break;
236 } 230 }
237 case FWL_STYLEEXT_CKB_VCenter: 231 case FWL_STYLEEXT_CKB_VCenter:
(...skipping 11 matching lines...) Expand all
249 fTextRight = fClientRight; 243 fTextRight = fClientRight;
250 } 244 }
251 m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox); 245 m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox);
252 m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, 246 m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft,
253 m_rtClient.height); 247 m_rtClient.height);
254 m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin); 248 m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin);
255 CFX_RectF rtFocus; 249 CFX_RectF rtFocus;
256 rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, 250 rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width,
257 m_rtCaption.height); 251 m_rtCaption.height);
258 CFX_WideString wsCaption; 252 CFX_WideString wsCaption;
259 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); 253 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
260 if (wsCaption.IsEmpty()) { 254 if (wsCaption.IsEmpty()) {
261 m_rtFocus.Set(0, 0, 0, 0); 255 m_rtFocus.Set(0, 0, 0, 0);
262 } else { 256 } else {
263 CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, 257 CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles,
264 m_iTTOAlign, rtFocus); 258 m_iTTOAlign, rtFocus);
265 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) { 259 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) {
266 FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); 260 FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width);
267 FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height); 261 FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height);
268 FX_FLOAT fLeft = m_rtCaption.left; 262 FX_FLOAT fLeft = m_rtCaption.left;
269 FX_FLOAT fTop = m_rtCaption.top; 263 FX_FLOAT fTop = m_rtCaption.top;
(...skipping 11 matching lines...) Expand all
281 FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) { 275 FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) {
282 fTop = m_rtCaption.bottom() - fHeight; 276 fTop = m_rtCaption.bottom() - fHeight;
283 } 277 }
284 m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); 278 m_rtFocus.Set(fLeft, fTop, fWidth, fHeight);
285 } else { 279 } else {
286 m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height); 280 m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height);
287 } 281 }
288 m_rtFocus.Inflate(1, 1); 282 m_rtFocus.Inflate(1, 1);
289 } 283 }
290 } 284 }
291 uint32_t CFWL_CheckBoxImp::GetPartStates() { 285
286 uint32_t IFWL_CheckBox::GetPartStates() {
292 int32_t dwStates = CFWL_PartState_Normal; 287 int32_t dwStates = CFWL_PartState_Normal;
293 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 288 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
294 FWL_STATE_CKB_Neutral) { 289 FWL_STATE_CKB_Neutral) {
295 dwStates = CFWL_PartState_Neutral; 290 dwStates = CFWL_PartState_Neutral;
296 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 291 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
297 FWL_STATE_CKB_Checked) { 292 FWL_STATE_CKB_Checked) {
298 dwStates = CFWL_PartState_Checked; 293 dwStates = CFWL_PartState_Checked;
299 } 294 }
300 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 295 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
301 dwStates |= CFWL_PartState_Disabled; 296 dwStates |= CFWL_PartState_Disabled;
302 } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) { 297 } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) {
303 dwStates |= CFWL_PartState_Hovered; 298 dwStates |= CFWL_PartState_Hovered;
304 } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) { 299 } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
305 dwStates |= CFWL_PartState_Pressed; 300 dwStates |= CFWL_PartState_Pressed;
306 } else { 301 } else {
307 dwStates |= CFWL_PartState_Normal; 302 dwStates |= CFWL_PartState_Normal;
308 } 303 }
309 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 304 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
310 dwStates |= CFWL_PartState_Focused; 305 dwStates |= CFWL_PartState_Focused;
311 } 306 }
312 return dwStates; 307 return dwStates;
313 } 308 }
314 void CFWL_CheckBoxImp::UpdateTextOutStyles() { 309
310 void IFWL_CheckBox::UpdateTextOutStyles() {
315 m_iTTOAlign = FDE_TTOALIGNMENT_Center; 311 m_iTTOAlign = FDE_TTOALIGNMENT_Center;
316 switch (m_pProperties->m_dwStyleExes & 312 switch (m_pProperties->m_dwStyleExes &
317 (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) { 313 (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) {
318 case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: { 314 case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: {
319 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; 315 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
320 break; 316 break;
321 } 317 }
322 case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: { 318 case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: {
323 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; 319 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
324 break; 320 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 m_dwTTOStyles = 0; 352 m_dwTTOStyles = 0;
357 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 353 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
358 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 354 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
359 } 355 }
360 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) { 356 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) {
361 m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap; 357 m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap;
362 } else { 358 } else {
363 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; 359 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
364 } 360 }
365 } 361 }
366 void CFWL_CheckBoxImp::NextStates() { 362
363 void IFWL_CheckBox::NextStates() {
367 uint32_t dwFirststate = m_pProperties->m_dwStates; 364 uint32_t dwFirststate = m_pProperties->m_dwStates;
368 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { 365 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) {
369 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 366 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
370 FWL_STATE_CKB_Unchecked) { 367 FWL_STATE_CKB_Unchecked) {
371 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 368 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
372 if (!pWidgetMgr->IsFormDisabled()) { 369 if (!pWidgetMgr->IsFormDisabled()) {
373 CFX_ArrayTemplate<IFWL_Widget*> radioarr; 370 CFX_ArrayTemplate<IFWL_Widget*> radioarr;
374 pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); 371 pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
375 IFWL_CheckBox* pCheckBox = nullptr; 372 IFWL_CheckBox* pCheckBox = nullptr;
376 int32_t iCount = radioarr.GetSize(); 373 int32_t iCount = radioarr.GetSize();
377 for (int32_t i = 0; i < iCount; i++) { 374 for (int32_t i = 0; i < iCount; i++) {
378 pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); 375 pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]);
379 if (pCheckBox != m_pInterface && 376 if (pCheckBox != this &&
380 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { 377 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
381 pCheckBox->SetCheckState(0); 378 pCheckBox->SetCheckState(0);
382 CFX_RectF rt; 379 CFX_RectF rt;
383 pCheckBox->GetWidgetRect(rt); 380 pCheckBox->GetWidgetRect(rt);
384 rt.left = rt.top = 0; 381 rt.left = rt.top = 0;
385 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); 382 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt);
386 break; 383 break;
387 } 384 }
388 } 385 }
389 } 386 }
(...skipping 14 matching lines...) Expand all
404 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; 401 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
405 } else { 402 } else {
406 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 403 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
407 } 404 }
408 } 405 }
409 } 406 }
410 Repaint(&m_rtClient); 407 Repaint(&m_rtClient);
411 uint32_t dwLaststate = m_pProperties->m_dwStates; 408 uint32_t dwLaststate = m_pProperties->m_dwStates;
412 if (dwFirststate != dwLaststate) { 409 if (dwFirststate != dwLaststate) {
413 CFWL_EvtCkbCheckStateChanged wmCheckBoxState; 410 CFWL_EvtCkbCheckStateChanged wmCheckBoxState;
414 wmCheckBoxState.m_pSrcTarget = m_pInterface; 411 wmCheckBoxState.m_pSrcTarget = this;
415 DispatchEvent(&wmCheckBoxState); 412 DispatchEvent(&wmCheckBoxState);
416 } 413 }
417 } 414 }
418 CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) 415
416 CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(IFWL_CheckBox* pOwner)
419 : m_pOwner(pOwner) {} 417 : m_pOwner(pOwner) {}
420 418
421 void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 419 void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
422 if (!pMessage) 420 if (!pMessage)
423 return; 421 return;
424 422
425 switch (pMessage->GetClassID()) { 423 switch (pMessage->GetClassID()) {
426 case CFWL_MessageType::Activate: { 424 case CFWL_MessageType::Activate: {
427 OnActivate(pMessage); 425 OnActivate(pMessage);
428 break; 426 break;
(...skipping 29 matching lines...) Expand all
458 break; 456 break;
459 } 457 }
460 break; 458 break;
461 } 459 }
462 case CFWL_MessageType::Key: { 460 case CFWL_MessageType::Key: {
463 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 461 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
464 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 462 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
465 OnKeyDown(pKey); 463 OnKeyDown(pKey);
466 break; 464 break;
467 } 465 }
468 default: { 466 default: { break; }
469 break;
470 }
471 } 467 }
472 468
473 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 469 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
474 } 470 }
475 471
476 void CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 472 void CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
477 const CFX_Matrix* pMatrix) { 473 const CFX_Matrix* pMatrix) {
478 m_pOwner->DrawWidget(pGraphics, pMatrix); 474 m_pOwner->DrawWidget(pGraphics, pMatrix);
479 } 475 }
480 476
481 void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) { 477 void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) {
482 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; 478 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
483 m_pOwner->Repaint(&(m_pOwner->m_rtClient)); 479 m_pOwner->Repaint(&(m_pOwner->m_rtClient));
484 } 480 }
481
485 void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 482 void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
486 FX_BOOL bSet) { 483 FX_BOOL bSet) {
487 if (bSet) { 484 if (bSet) {
488 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 485 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
489 } else { 486 } else {
490 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 487 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
491 } 488 }
492 m_pOwner->Repaint(&(m_pOwner->m_rtClient)); 489 m_pOwner->Repaint(&(m_pOwner->m_rtClient));
493 } 490 }
491
494 void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 492 void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
495 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 493 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
496 return; 494 return;
497 } 495 }
498 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 496 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
499 m_pOwner->SetFocus(TRUE); 497 m_pOwner->SetFocus(TRUE);
500 } 498 }
501 m_pOwner->m_bBtnDown = TRUE; 499 m_pOwner->m_bBtnDown = TRUE;
502 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; 500 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
503 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; 501 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
504 m_pOwner->Repaint(&(m_pOwner->m_rtClient)); 502 m_pOwner->Repaint(&(m_pOwner->m_rtClient));
505 } 503 }
504
506 void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 505 void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
507 if (!m_pOwner->m_bBtnDown) { 506 if (!m_pOwner->m_bBtnDown) {
508 return; 507 return;
509 } 508 }
510 m_pOwner->m_bBtnDown = FALSE; 509 m_pOwner->m_bBtnDown = FALSE;
511 if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 510 if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
512 return; 511 return;
513 } 512 }
514 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; 513 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
515 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed; 514 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
516 m_pOwner->NextStates(); 515 m_pOwner->NextStates();
517 } 516 }
517
518 void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 518 void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
519 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 519 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
520 return; 520 return;
521 } 521 }
522 FX_BOOL bRepaint = FALSE; 522 FX_BOOL bRepaint = FALSE;
523 if (m_pOwner->m_bBtnDown) { 523 if (m_pOwner->m_bBtnDown) {
524 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 524 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
525 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) { 525 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) {
526 bRepaint = TRUE; 526 bRepaint = TRUE;
527 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; 527 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
(...skipping 17 matching lines...) Expand all
545 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { 545 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
546 bRepaint = TRUE; 546 bRepaint = TRUE;
547 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; 547 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
548 } 548 }
549 } 549 }
550 } 550 }
551 if (bRepaint) { 551 if (bRepaint) {
552 m_pOwner->Repaint(&(m_pOwner->m_rtBox)); 552 m_pOwner->Repaint(&(m_pOwner->m_rtBox));
553 } 553 }
554 } 554 }
555
555 void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 556 void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
556 if (m_pOwner->m_bBtnDown) { 557 if (m_pOwner->m_bBtnDown) {
557 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; 558 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
558 } else { 559 } else {
559 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; 560 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
560 } 561 }
561 m_pOwner->Repaint(&(m_pOwner->m_rtBox)); 562 m_pOwner->Repaint(&(m_pOwner->m_rtBox));
562 } 563 }
564
563 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { 565 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
564 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { 566 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
565 m_pOwner->DispatchKeyEvent(pMsg); 567 m_pOwner->DispatchKeyEvent(pMsg);
566 return; 568 return;
567 } 569 }
568 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || 570 if (pMsg->m_dwKeyCode == FWL_VKEY_Return ||
569 pMsg->m_dwKeyCode == FWL_VKEY_Space) { 571 pMsg->m_dwKeyCode == FWL_VKEY_Space) {
570 m_pOwner->NextStates(); 572 m_pOwner->NextStates();
571 } 573 }
572 } 574 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_checkbox.h ('k') | xfa/fwl/core/ifwl_combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698