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

Side by Side Diff: xfa/fwl/core/ifwl_monthcalendar.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_monthcalendar.h ('k') | xfa/fwl/core/ifwl_picturebox.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_monthcalendarimp.h" 7 #include "xfa/fwl/core/ifwl_monthcalendar.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_monthcalendar.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/fwl_noteimp.h" 15 #include "xfa/fwl/core/fwl_noteimp.h"
17 #include "xfa/fwl/core/fwl_widgetimp.h" 16 #include "xfa/fwl/core/ifwl_monthcalendar.h"
18 #include "xfa/fwl/core/ifwl_themeprovider.h" 17 #include "xfa/fwl/core/ifwl_themeprovider.h"
19 18
20 #define MONTHCAL_HSEP_HEIGHT 1 19 #define MONTHCAL_HSEP_HEIGHT 1
21 #define MONTHCAL_VSEP_WIDTH 1 20 #define MONTHCAL_VSEP_WIDTH 1
22 #define MONTHCAL_HMARGIN 3 21 #define MONTHCAL_HMARGIN 3
23 #define MONTHCAL_VMARGIN 2 22 #define MONTHCAL_VMARGIN 2
24 #define MONTHCAL_ROWS 9 23 #define MONTHCAL_ROWS 9
25 #define MONTHCAL_COLUMNS 7 24 #define MONTHCAL_COLUMNS 7
26 #define MONTHCAL_HEADER_BTN_VMARGIN 7 25 #define MONTHCAL_HEADER_BTN_VMARGIN 7
27 #define MONTHCAL_HEADER_BTN_HMARGIN 5 26 #define MONTHCAL_HEADER_BTN_HMARGIN 5
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return static_cast<CFX_WideString*>( 114 return static_cast<CFX_WideString*>(
116 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December)); 115 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December));
117 } 116 }
118 117
119 } // namespace 118 } // namespace
120 119
121 // static 120 // static
122 IFWL_MonthCalendar* IFWL_MonthCalendar::Create( 121 IFWL_MonthCalendar* IFWL_MonthCalendar::Create(
123 const CFWL_WidgetImpProperties& properties, 122 const CFWL_WidgetImpProperties& properties,
124 IFWL_Widget* pOuter) { 123 IFWL_Widget* pOuter) {
125 IFWL_MonthCalendar* pMonthCalendar = new IFWL_MonthCalendar; 124 return new IFWL_MonthCalendar(properties, pOuter);
126 CFWL_MonthCalendarImp* pMonthCalendarImpl =
127 new CFWL_MonthCalendarImp(properties, pOuter);
128 pMonthCalendar->SetImpl(pMonthCalendarImpl);
129 pMonthCalendarImpl->SetInterface(pMonthCalendar);
130 return pMonthCalendar;
131 }
132 IFWL_MonthCalendar::IFWL_MonthCalendar() {}
133 int32_t IFWL_MonthCalendar::CountSelect() {
134 return static_cast<CFWL_MonthCalendarImp*>(GetImpl())->CountSelect();
135 }
136 FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear,
137 int32_t& iMonth,
138 int32_t& iDay,
139 int32_t nIndex) {
140 return static_cast<CFWL_MonthCalendarImp*>(GetImpl())
141 ->GetSelect(iYear, iMonth, iDay, nIndex);
142 }
143 FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear,
144 int32_t iMonth,
145 int32_t iDay) {
146 return static_cast<CFWL_MonthCalendarImp*>(GetImpl())
147 ->SetSelect(iYear, iMonth, iDay);
148 } 125 }
149 126
150 CFWL_MonthCalendarImp::CFWL_MonthCalendarImp( 127 IFWL_MonthCalendar::IFWL_MonthCalendar(
151 const CFWL_WidgetImpProperties& properties, 128 const CFWL_WidgetImpProperties& properties,
152 IFWL_Widget* pOuter) 129 IFWL_Widget* pOuter)
153 : CFWL_WidgetImp(properties, pOuter), 130 : IFWL_Widget(properties, pOuter),
154 m_bInit(FALSE), 131 m_bInit(FALSE),
155 m_pDateTime(new CFX_DateTime), 132 m_pDateTime(new CFX_DateTime),
156 m_iCurYear(2011), 133 m_iCurYear(2011),
157 m_iCurMonth(1), 134 m_iCurMonth(1),
158 m_iYear(2011), 135 m_iYear(2011),
159 m_iMonth(1), 136 m_iMonth(1),
160 m_iDay(1), 137 m_iDay(1),
161 m_iHovered(-1), 138 m_iHovered(-1),
162 m_iLBtnPartStates(CFWL_PartState_Normal), 139 m_iLBtnPartStates(CFWL_PartState_Normal),
163 m_iRBtnPartStates(CFWL_PartState_Normal), 140 m_iRBtnPartStates(CFWL_PartState_Normal),
164 m_iMaxSel(1) { 141 m_iMaxSel(1) {
165 m_rtHead.Reset(); 142 m_rtHead.Reset();
166 m_rtWeek.Reset(); 143 m_rtWeek.Reset();
167 m_rtLBtn.Reset(); 144 m_rtLBtn.Reset();
168 m_rtRBtn.Reset(); 145 m_rtRBtn.Reset();
169 m_rtDates.Reset(); 146 m_rtDates.Reset();
170 m_rtHSep.Reset(); 147 m_rtHSep.Reset();
171 m_rtHeadText.Reset(); 148 m_rtHeadText.Reset();
172 m_rtToday.Reset(); 149 m_rtToday.Reset();
173 m_rtTodayFlag.Reset(); 150 m_rtTodayFlag.Reset();
174 m_rtClient.Reset(); 151 m_rtClient.Reset();
175 m_rtWeekNum.Reset(); 152 m_rtWeekNum.Reset();
176 m_rtWeekNumSep.Reset(); 153 m_rtWeekNumSep.Reset();
177 } 154 }
178 155
179 CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() { 156 IFWL_MonthCalendar::~IFWL_MonthCalendar() {
180 ClearDateItem(); 157 ClearDateItem();
181 m_arrSelDays.RemoveAll(); 158 m_arrSelDays.RemoveAll();
182 } 159 }
183 160
184 FWL_Error CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const { 161 FWL_Error IFWL_MonthCalendar::GetClassName(CFX_WideString& wsClass) const {
185 wsClass = FWL_CLASS_MonthCalendar; 162 wsClass = FWL_CLASS_MonthCalendar;
186 return FWL_Error::Succeeded; 163 return FWL_Error::Succeeded;
187 } 164 }
188 165
189 FWL_Type CFWL_MonthCalendarImp::GetClassID() const { 166 FWL_Type IFWL_MonthCalendar::GetClassID() const {
190 return FWL_Type::MonthCalendar; 167 return FWL_Type::MonthCalendar;
191 } 168 }
192 169
193 FWL_Error CFWL_MonthCalendarImp::Initialize() { 170 FWL_Error IFWL_MonthCalendar::Initialize() {
194 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 171 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
195 return FWL_Error::Indefinite; 172 return FWL_Error::Indefinite;
196 173
197 m_pDelegate = new CFWL_MonthCalendarImpDelegate(this); 174 m_pDelegate = new CFWL_MonthCalendarImpDelegate(this);
198 return FWL_Error::Succeeded; 175 return FWL_Error::Succeeded;
199 } 176 }
200 177
201 FWL_Error CFWL_MonthCalendarImp::Finalize() { 178 FWL_Error IFWL_MonthCalendar::Finalize() {
202 delete m_pDelegate; 179 delete m_pDelegate;
203 m_pDelegate = nullptr; 180 m_pDelegate = nullptr;
204 return CFWL_WidgetImp::Finalize(); 181 return IFWL_Widget::Finalize();
205 } 182 }
206 FWL_Error CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect, 183
207 FX_BOOL bAutoSize) { 184 FWL_Error IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect,
185 FX_BOOL bAutoSize) {
208 if (bAutoSize) { 186 if (bAutoSize) {
209 CFX_SizeF fs = CalcSize(TRUE); 187 CFX_SizeF fs = CalcSize(TRUE);
210 rect.Set(0, 0, fs.x, fs.y); 188 rect.Set(0, 0, fs.x, fs.y);
211 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 189 IFWL_Widget::GetWidgetRect(rect, TRUE);
212 } else { 190 } else {
213 rect = m_pProperties->m_rtWidget; 191 rect = m_pProperties->m_rtWidget;
214 } 192 }
215 return FWL_Error::Succeeded; 193 return FWL_Error::Succeeded;
216 } 194 }
217 FWL_Error CFWL_MonthCalendarImp::Update() { 195
196 FWL_Error IFWL_MonthCalendar::Update() {
218 if (IsLocked()) { 197 if (IsLocked()) {
219 return FWL_Error::Indefinite; 198 return FWL_Error::Indefinite;
220 } 199 }
221 if (!m_pProperties->m_pThemeProvider) { 200 if (!m_pProperties->m_pThemeProvider) {
222 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 201 m_pProperties->m_pThemeProvider = GetAvailableTheme();
223 } 202 }
224 GetCapValue(); 203 GetCapValue();
225 if (!m_bInit) { 204 if (!m_bInit) {
226 m_bInit = InitDate(); 205 m_bInit = InitDate();
227 } 206 }
228 ClearDateItem(); 207 ClearDateItem();
229 ReSetDateItem(); 208 ReSetDateItem();
230 LayOut(); 209 LayOut();
231 return FWL_Error::Succeeded; 210 return FWL_Error::Succeeded;
232 } 211 }
233 FWL_Error CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics, 212
234 const CFX_Matrix* pMatrix) { 213 FWL_Error IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics,
214 const CFX_Matrix* pMatrix) {
235 if (!pGraphics) 215 if (!pGraphics)
236 return FWL_Error::Indefinite; 216 return FWL_Error::Indefinite;
237 if (!m_pProperties->m_pThemeProvider) { 217 if (!m_pProperties->m_pThemeProvider) {
238 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 218 m_pProperties->m_pThemeProvider = GetAvailableTheme();
239 } 219 }
240 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 220 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
241 if (HasBorder()) { 221 if (HasBorder()) {
242 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 222 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
243 } 223 }
244 if (HasEdge()) { 224 if (HasEdge()) {
(...skipping 10 matching lines...) Expand all
255 DrawWeek(pGraphics, pTheme, pMatrix); 235 DrawWeek(pGraphics, pTheme, pMatrix);
256 DrawDatesIn(pGraphics, pTheme, pMatrix); 236 DrawDatesIn(pGraphics, pTheme, pMatrix);
257 DrawDatesOut(pGraphics, pTheme, pMatrix); 237 DrawDatesOut(pGraphics, pTheme, pMatrix);
258 DrawToday(pGraphics, pTheme, pMatrix); 238 DrawToday(pGraphics, pTheme, pMatrix);
259 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 239 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
260 DrawWeekNumberSep(pGraphics, pTheme, pMatrix); 240 DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
261 DrawWeekNumber(pGraphics, pTheme, pMatrix); 241 DrawWeekNumber(pGraphics, pTheme, pMatrix);
262 } 242 }
263 return FWL_Error::Succeeded; 243 return FWL_Error::Succeeded;
264 } 244 }
265 int32_t CFWL_MonthCalendarImp::CountSelect() { 245
246 int32_t IFWL_MonthCalendar::CountSelect() {
266 return m_arrSelDays.GetSize(); 247 return m_arrSelDays.GetSize();
267 } 248 }
268 FX_BOOL CFWL_MonthCalendarImp::GetSelect(int32_t& iYear, 249
269 int32_t& iMonth, 250 FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear,
270 int32_t& iDay, 251 int32_t& iMonth,
271 int32_t nIndex) { 252 int32_t& iDay,
253 int32_t nIndex) {
272 if (nIndex >= m_arrSelDays.GetSize()) { 254 if (nIndex >= m_arrSelDays.GetSize()) {
273 return FALSE; 255 return FALSE;
274 } 256 }
275 iYear = m_iCurYear; 257 iYear = m_iCurYear;
276 iMonth = m_iCurMonth; 258 iMonth = m_iCurMonth;
277 iDay = m_arrSelDays[nIndex]; 259 iDay = m_arrSelDays[nIndex];
278 return TRUE; 260 return TRUE;
279 } 261 }
280 FX_BOOL CFWL_MonthCalendarImp::SetSelect(int32_t iYear, 262
281 int32_t iMonth, 263 FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear,
282 int32_t iDay) { 264 int32_t iMonth,
265 int32_t iDay) {
283 ChangeToMonth(iYear, iMonth); 266 ChangeToMonth(iYear, iMonth);
284 return AddSelDay(iDay); 267 return AddSelDay(iDay);
285 } 268 }
286 void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics* pGraphics, 269
287 IFWL_ThemeProvider* pTheme, 270 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics,
288 const CFX_Matrix* pMatrix) { 271 IFWL_ThemeProvider* pTheme,
272 const CFX_Matrix* pMatrix) {
289 CFWL_ThemeBackground params; 273 CFWL_ThemeBackground params;
290 params.m_pWidget = m_pInterface; 274 params.m_pWidget = this;
291 params.m_iPart = CFWL_Part::Background; 275 params.m_iPart = CFWL_Part::Background;
292 params.m_pGraphics = pGraphics; 276 params.m_pGraphics = pGraphics;
293 params.m_dwStates = CFWL_PartState_Normal; 277 params.m_dwStates = CFWL_PartState_Normal;
294 params.m_rtPart = m_rtClient; 278 params.m_rtPart = m_rtClient;
295 if (pMatrix) { 279 if (pMatrix) {
296 params.m_matrix.Concat(*pMatrix); 280 params.m_matrix.Concat(*pMatrix);
297 } 281 }
298 pTheme->DrawBackground(&params); 282 pTheme->DrawBackground(&params);
299 } 283 }
300 void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics* pGraphics, 284
301 IFWL_ThemeProvider* pTheme, 285 void IFWL_MonthCalendar::DrawHeadBK(CFX_Graphics* pGraphics,
302 const CFX_Matrix* pMatrix) { 286 IFWL_ThemeProvider* pTheme,
287 const CFX_Matrix* pMatrix) {
303 CFWL_ThemeBackground params; 288 CFWL_ThemeBackground params;
304 params.m_pWidget = m_pInterface; 289 params.m_pWidget = this;
305 params.m_iPart = CFWL_Part::Header; 290 params.m_iPart = CFWL_Part::Header;
306 params.m_pGraphics = pGraphics; 291 params.m_pGraphics = pGraphics;
307 params.m_dwStates = CFWL_PartState_Normal; 292 params.m_dwStates = CFWL_PartState_Normal;
308 params.m_rtPart = m_rtHead; 293 params.m_rtPart = m_rtHead;
309 if (pMatrix) { 294 if (pMatrix) {
310 params.m_matrix.Concat(*pMatrix); 295 params.m_matrix.Concat(*pMatrix);
311 } 296 }
312 pTheme->DrawBackground(&params); 297 pTheme->DrawBackground(&params);
313 } 298 }
314 void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics* pGraphics, 299
315 IFWL_ThemeProvider* pTheme, 300 void IFWL_MonthCalendar::DrawLButton(CFX_Graphics* pGraphics,
316 const CFX_Matrix* pMatrix) { 301 IFWL_ThemeProvider* pTheme,
302 const CFX_Matrix* pMatrix) {
317 CFWL_ThemeBackground params; 303 CFWL_ThemeBackground params;
318 params.m_pWidget = m_pInterface; 304 params.m_pWidget = this;
319 params.m_iPart = CFWL_Part::LBtn; 305 params.m_iPart = CFWL_Part::LBtn;
320 params.m_pGraphics = pGraphics; 306 params.m_pGraphics = pGraphics;
321 params.m_dwStates = m_iLBtnPartStates; 307 params.m_dwStates = m_iLBtnPartStates;
322 params.m_rtPart = m_rtLBtn; 308 params.m_rtPart = m_rtLBtn;
323 if (pMatrix) { 309 if (pMatrix) {
324 params.m_matrix.Concat(*pMatrix); 310 params.m_matrix.Concat(*pMatrix);
325 } 311 }
326 pTheme->DrawBackground(&params); 312 pTheme->DrawBackground(&params);
327 } 313 }
328 void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics* pGraphics, 314
329 IFWL_ThemeProvider* pTheme, 315 void IFWL_MonthCalendar::DrawRButton(CFX_Graphics* pGraphics,
330 const CFX_Matrix* pMatrix) { 316 IFWL_ThemeProvider* pTheme,
317 const CFX_Matrix* pMatrix) {
331 CFWL_ThemeBackground params; 318 CFWL_ThemeBackground params;
332 params.m_pWidget = m_pInterface; 319 params.m_pWidget = this;
333 params.m_iPart = CFWL_Part::RBtn; 320 params.m_iPart = CFWL_Part::RBtn;
334 params.m_pGraphics = pGraphics; 321 params.m_pGraphics = pGraphics;
335 params.m_dwStates = m_iRBtnPartStates; 322 params.m_dwStates = m_iRBtnPartStates;
336 params.m_rtPart = m_rtRBtn; 323 params.m_rtPart = m_rtRBtn;
337 if (pMatrix) { 324 if (pMatrix) {
338 params.m_matrix.Concat(*pMatrix); 325 params.m_matrix.Concat(*pMatrix);
339 } 326 }
340 pTheme->DrawBackground(&params); 327 pTheme->DrawBackground(&params);
341 } 328 }
342 void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics* pGraphics, 329
343 IFWL_ThemeProvider* pTheme, 330 void IFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics,
344 const CFX_Matrix* pMatrix) { 331 IFWL_ThemeProvider* pTheme,
332 const CFX_Matrix* pMatrix) {
345 CFWL_ThemeText textParam; 333 CFWL_ThemeText textParam;
346 textParam.m_pWidget = m_pInterface; 334 textParam.m_pWidget = this;
347 textParam.m_iPart = CFWL_Part::Caption; 335 textParam.m_iPart = CFWL_Part::Caption;
348 textParam.m_dwStates = CFWL_PartState_Normal; 336 textParam.m_dwStates = CFWL_PartState_Normal;
349 textParam.m_pGraphics = pGraphics; 337 textParam.m_pGraphics = pGraphics;
350 int32_t iYear; 338 int32_t iYear;
351 int32_t iMonth; 339 int32_t iMonth;
352 iYear = m_iCurYear; 340 iYear = m_iCurYear;
353 iMonth = m_iCurMonth; 341 iMonth = m_iCurMonth;
354 CFX_WideString wsCation; 342 CFX_WideString wsCation;
355 GetHeadText(iYear, iMonth, wsCation); 343 GetHeadText(iYear, iMonth, wsCation);
356 textParam.m_wsText = wsCation; 344 textParam.m_wsText = wsCation;
357 m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider); 345 m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider);
358 CalcHeadSize(); 346 CalcHeadSize();
359 textParam.m_rtPart = m_rtHeadText; 347 textParam.m_rtPart = m_rtHeadText;
360 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 348 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
361 textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 349 textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
362 if (pMatrix) { 350 if (pMatrix) {
363 textParam.m_matrix.Concat(*pMatrix); 351 textParam.m_matrix.Concat(*pMatrix);
364 } 352 }
365 pTheme->DrawText(&textParam); 353 pTheme->DrawText(&textParam);
366 } 354 }
367 void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics* pGraphics, 355
368 IFWL_ThemeProvider* pTheme, 356 void IFWL_MonthCalendar::DrawSeperator(CFX_Graphics* pGraphics,
369 const CFX_Matrix* pMatrix) { 357 IFWL_ThemeProvider* pTheme,
358 const CFX_Matrix* pMatrix) {
370 CFWL_ThemeBackground params; 359 CFWL_ThemeBackground params;
371 params.m_pWidget = m_pInterface; 360 params.m_pWidget = this;
372 params.m_iPart = CFWL_Part::HSeparator; 361 params.m_iPart = CFWL_Part::HSeparator;
373 params.m_pGraphics = pGraphics; 362 params.m_pGraphics = pGraphics;
374 params.m_dwStates = CFWL_PartState_Normal; 363 params.m_dwStates = CFWL_PartState_Normal;
375 params.m_rtPart = m_rtHSep; 364 params.m_rtPart = m_rtHSep;
376 if (pMatrix) { 365 if (pMatrix) {
377 params.m_matrix.Concat(*pMatrix); 366 params.m_matrix.Concat(*pMatrix);
378 } 367 }
379 pTheme->DrawBackground(&params); 368 pTheme->DrawBackground(&params);
380 } 369 }
381 void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics, 370
382 IFWL_ThemeProvider* pTheme, 371 void IFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics,
383 const CFX_Matrix* pMatrix) { 372 IFWL_ThemeProvider* pTheme,
373 const CFX_Matrix* pMatrix) {
384 CFWL_ThemeBackground params; 374 CFWL_ThemeBackground params;
385 params.m_pWidget = m_pInterface; 375 params.m_pWidget = this;
386 params.m_iPart = CFWL_Part::DateInBK; 376 params.m_iPart = CFWL_Part::DateInBK;
387 params.m_pGraphics = pGraphics; 377 params.m_pGraphics = pGraphics;
388 if (pMatrix) { 378 if (pMatrix) {
389 params.m_matrix.Concat(*pMatrix); 379 params.m_matrix.Concat(*pMatrix);
390 } 380 }
391 int32_t iCount = m_arrDates.GetSize(); 381 int32_t iCount = m_arrDates.GetSize();
392 for (int32_t j = 0; j < iCount; j++) { 382 for (int32_t j = 0; j < iCount; j++) {
393 FWL_DATEINFO* pDataInfo = m_arrDates.GetAt(j); 383 FWL_DATEINFO* pDataInfo = m_arrDates.GetAt(j);
394 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) { 384 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
395 params.m_dwStates |= CFWL_PartState_Selected; 385 params.m_dwStates |= CFWL_PartState_Selected;
396 if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) == 386 if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) ==
397 0) && 387 0) &&
398 pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { 388 pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
399 params.m_dwStates |= CFWL_PartState_Flagged; 389 params.m_dwStates |= CFWL_PartState_Flagged;
400 } 390 }
401 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) { 391 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) {
402 params.m_dwStates |= CFWL_PartState_Focused; 392 params.m_dwStates |= CFWL_PartState_Focused;
403 } 393 }
404 } else if (j == m_iHovered - 1) { 394 } else if (j == m_iHovered - 1) {
405 params.m_dwStates |= CFWL_PartState_Hovered; 395 params.m_dwStates |= CFWL_PartState_Hovered;
406 } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { 396 } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
407 params.m_dwStates = CFWL_PartState_Flagged; 397 params.m_dwStates = CFWL_PartState_Flagged;
408 pTheme->DrawBackground(&params); 398 pTheme->DrawBackground(&params);
409 } 399 }
410 params.m_rtPart = pDataInfo->rect; 400 params.m_rtPart = pDataInfo->rect;
411 pTheme->DrawBackground(&params); 401 pTheme->DrawBackground(&params);
412 params.m_dwStates = 0; 402 params.m_dwStates = 0;
413 } 403 }
414 } 404 }
415 void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics, 405
416 IFWL_ThemeProvider* pTheme, 406 void IFWL_MonthCalendar::DrawWeek(CFX_Graphics* pGraphics,
417 const CFX_Matrix* pMatrix) { 407 IFWL_ThemeProvider* pTheme,
408 const CFX_Matrix* pMatrix) {
418 CFWL_ThemeText params; 409 CFWL_ThemeText params;
419 params.m_pWidget = m_pInterface; 410 params.m_pWidget = this;
420 params.m_iPart = CFWL_Part::Week; 411 params.m_iPart = CFWL_Part::Week;
421 params.m_pGraphics = pGraphics; 412 params.m_pGraphics = pGraphics;
422 params.m_dwStates = CFWL_PartState_Normal; 413 params.m_dwStates = CFWL_PartState_Normal;
423 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 414 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
424 CFX_RectF rtDayOfWeek; 415 CFX_RectF rtDayOfWeek;
425 if (pMatrix) { 416 if (pMatrix) {
426 params.m_matrix.Concat(*pMatrix); 417 params.m_matrix.Concat(*pMatrix);
427 } 418 }
428 for (int32_t i = 0; i < 7; i++) { 419 for (int32_t i = 0; i < 7; i++) {
429 rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2), 420 rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2),
430 m_rtWeek.top, m_szCell.x, m_szCell.y); 421 m_rtWeek.top, m_szCell.x, m_szCell.y);
431 params.m_rtPart = rtDayOfWeek; 422 params.m_rtPart = rtDayOfWeek;
432 params.m_wsText = *GetCapacityForDay(pTheme, params, i); 423 params.m_wsText = *GetCapacityForDay(pTheme, params, i);
433 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 424 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
434 pTheme->DrawText(&params); 425 pTheme->DrawText(&params);
435 } 426 }
436 } 427 }
437 void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics* pGraphics, 428
438 IFWL_ThemeProvider* pTheme, 429 void IFWL_MonthCalendar::DrawWeekNumber(CFX_Graphics* pGraphics,
439 const CFX_Matrix* pMatrix) { 430 IFWL_ThemeProvider* pTheme,
431 const CFX_Matrix* pMatrix) {
440 CFWL_ThemeText params; 432 CFWL_ThemeText params;
441 params.m_pWidget = m_pInterface; 433 params.m_pWidget = this;
442 params.m_iPart = CFWL_Part::WeekNum; 434 params.m_iPart = CFWL_Part::WeekNum;
443 params.m_pGraphics = pGraphics; 435 params.m_pGraphics = pGraphics;
444 params.m_dwStates = CFWL_PartState_Normal; 436 params.m_dwStates = CFWL_PartState_Normal;
445 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 437 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
446 CFX_WideString wsWeekNum; 438 CFX_WideString wsWeekNum;
447 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 439 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
448 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 440 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
449 if (pMatrix) { 441 if (pMatrix) {
450 params.m_matrix.Concat(*pMatrix); 442 params.m_matrix.Concat(*pMatrix);
451 } 443 }
452 int32_t iWeekNum = 0; 444 int32_t iWeekNum = 0;
453 int32_t iMonthNum = m_pDateTime->GetMonth(); 445 int32_t iMonthNum = m_pDateTime->GetMonth();
454 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); 446 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum);
455 int32_t iTemp = 0; 447 int32_t iTemp = 0;
456 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei; 448 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei;
457 FX_FLOAT fHStartPos = m_rtClient.left; 449 FX_FLOAT fHStartPos = m_rtClient.left;
458 for (int32_t i = 1; i <= iDayNum; i += 7) { 450 for (int32_t i = 1; i <= iDayNum; i += 7) {
459 iTemp++; 451 iTemp++;
460 iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i); 452 iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i);
461 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, 453 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp,
462 m_fWeekNumWid, m_fDateCellHei); 454 m_fWeekNumWid, m_fDateCellHei);
463 wsWeekNum.Format(L"%d", iWeekNum); 455 wsWeekNum.Format(L"%d", iWeekNum);
464 params.m_wsText = wsWeekNum; 456 params.m_wsText = wsWeekNum;
465 params.m_rtPart = m_rtWeekNum; 457 params.m_rtPart = m_rtWeekNum;
466 pTheme->DrawText(&params); 458 pTheme->DrawText(&params);
467 } 459 }
468 } 460 }
469 void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics* pGraphics, 461
470 IFWL_ThemeProvider* pTheme, 462 void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics,
471 const CFX_Matrix* pMatrix) { 463 IFWL_ThemeProvider* pTheme,
464 const CFX_Matrix* pMatrix) {
472 CFWL_ThemeBackground params; 465 CFWL_ThemeBackground params;
473 params.m_pWidget = m_pInterface; 466 params.m_pWidget = this;
474 params.m_iPart = CFWL_Part::WeekNumSep; 467 params.m_iPart = CFWL_Part::WeekNumSep;
475 params.m_pGraphics = pGraphics; 468 params.m_pGraphics = pGraphics;
476 params.m_dwStates = CFWL_PartState_Normal; 469 params.m_dwStates = CFWL_PartState_Normal;
477 params.m_rtPart = m_rtWeekNumSep; 470 params.m_rtPart = m_rtWeekNumSep;
478 if (pMatrix) { 471 if (pMatrix) {
479 params.m_matrix.Concat(*pMatrix); 472 params.m_matrix.Concat(*pMatrix);
480 } 473 }
481 pTheme->DrawBackground(&params); 474 pTheme->DrawBackground(&params);
482 } 475 }
483 void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics* pGraphics, 476
484 IFWL_ThemeProvider* pTheme, 477 void IFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics,
485 const CFX_Matrix* pMatrix) { 478 IFWL_ThemeProvider* pTheme,
479 const CFX_Matrix* pMatrix) {
486 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { 480 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
487 return; 481 return;
488 } 482 }
489 CFWL_ThemeText params; 483 CFWL_ThemeText params;
490 params.m_pWidget = m_pInterface; 484 params.m_pWidget = this;
491 params.m_iPart = CFWL_Part::Today; 485 params.m_iPart = CFWL_Part::Today;
492 params.m_pGraphics = pGraphics; 486 params.m_pGraphics = pGraphics;
493 params.m_dwStates = CFWL_PartState_Normal; 487 params.m_dwStates = CFWL_PartState_Normal;
494 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 488 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
495 CFX_WideString* wsDay = static_cast<CFX_WideString*>( 489 CFX_WideString* wsDay = static_cast<CFX_WideString*>(
496 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today)); 490 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
497 CFX_WideString wsText; 491 CFX_WideString wsText;
498 GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); 492 GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
499 params.m_wsText = *wsDay + wsText; 493 params.m_wsText = *wsDay + wsText;
500 m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); 494 m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider);
501 CalcTodaySize(); 495 CalcTodaySize();
502 params.m_rtPart = m_rtToday; 496 params.m_rtPart = m_rtToday;
503 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 497 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
504 if (pMatrix) { 498 if (pMatrix) {
505 params.m_matrix.Concat(*pMatrix); 499 params.m_matrix.Concat(*pMatrix);
506 } 500 }
507 pTheme->DrawText(&params); 501 pTheme->DrawText(&params);
508 } 502 }
509 void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics, 503
510 IFWL_ThemeProvider* pTheme, 504 void IFWL_MonthCalendar::DrawDatesIn(CFX_Graphics* pGraphics,
511 const CFX_Matrix* pMatrix) { 505 IFWL_ThemeProvider* pTheme,
506 const CFX_Matrix* pMatrix) {
512 CFWL_ThemeText params; 507 CFWL_ThemeText params;
513 params.m_pWidget = m_pInterface; 508 params.m_pWidget = this;
514 params.m_iPart = CFWL_Part::DatesIn; 509 params.m_iPart = CFWL_Part::DatesIn;
515 params.m_pGraphics = pGraphics; 510 params.m_pGraphics = pGraphics;
516 params.m_dwStates = CFWL_PartState_Normal; 511 params.m_dwStates = CFWL_PartState_Normal;
517 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 512 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
518 if (pMatrix) { 513 if (pMatrix) {
519 params.m_matrix.Concat(*pMatrix); 514 params.m_matrix.Concat(*pMatrix);
520 } 515 }
521 int32_t iCount = m_arrDates.GetSize(); 516 int32_t iCount = m_arrDates.GetSize();
522 for (int32_t j = 0; j < iCount; j++) { 517 for (int32_t j = 0; j < iCount; j++) {
523 FWL_DATEINFO* pDataInfo = m_arrDates.GetAt(j); 518 FWL_DATEINFO* pDataInfo = m_arrDates.GetAt(j);
524 params.m_wsText = pDataInfo->wsDay; 519 params.m_wsText = pDataInfo->wsDay;
525 params.m_rtPart = pDataInfo->rect; 520 params.m_rtPart = pDataInfo->rect;
526 params.m_dwStates = pDataInfo->dwStates; 521 params.m_dwStates = pDataInfo->dwStates;
527 if (j + 1 == m_iHovered) { 522 if (j + 1 == m_iHovered) {
528 params.m_dwStates |= CFWL_PartState_Hovered; 523 params.m_dwStates |= CFWL_PartState_Hovered;
529 } 524 }
530 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 525 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
531 pTheme->DrawText(&params); 526 pTheme->DrawText(&params);
532 } 527 }
533 } 528 }
534 void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics* pGraphics, 529
535 IFWL_ThemeProvider* pTheme, 530 void IFWL_MonthCalendar::DrawDatesOut(CFX_Graphics* pGraphics,
536 const CFX_Matrix* pMatrix) { 531 IFWL_ThemeProvider* pTheme,
532 const CFX_Matrix* pMatrix) {
537 CFWL_ThemeText params; 533 CFWL_ThemeText params;
538 params.m_pWidget = m_pInterface; 534 params.m_pWidget = this;
539 params.m_iPart = CFWL_Part::DatesOut; 535 params.m_iPart = CFWL_Part::DatesOut;
540 params.m_pGraphics = pGraphics; 536 params.m_pGraphics = pGraphics;
541 params.m_dwStates = CFWL_PartState_Normal; 537 params.m_dwStates = CFWL_PartState_Normal;
542 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 538 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
543 if (pMatrix) { 539 if (pMatrix) {
544 params.m_matrix.Concat(*pMatrix); 540 params.m_matrix.Concat(*pMatrix);
545 } 541 }
546 pTheme->DrawText(&params); 542 pTheme->DrawText(&params);
547 } 543 }
548 void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics* pGraphics, 544
549 IFWL_ThemeProvider* pTheme, 545 void IFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics,
550 const CFX_Matrix* pMatrix) { 546 IFWL_ThemeProvider* pTheme,
547 const CFX_Matrix* pMatrix) {
551 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { 548 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
552 return; 549 return;
553 } 550 }
554 if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) { 551 if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) {
555 return; 552 return;
556 } 553 }
557 if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) { 554 if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) {
558 return; 555 return;
559 } 556 }
560 FWL_DATEINFO* pDate = m_arrDates[m_iDay - 1]; 557 FWL_DATEINFO* pDate = m_arrDates[m_iDay - 1];
561 if (!pDate) 558 if (!pDate)
562 return; 559 return;
563 CFWL_ThemeBackground params; 560 CFWL_ThemeBackground params;
564 params.m_pWidget = m_pInterface; 561 params.m_pWidget = this;
565 params.m_iPart = CFWL_Part::DateInCircle; 562 params.m_iPart = CFWL_Part::DateInCircle;
566 params.m_pGraphics = pGraphics; 563 params.m_pGraphics = pGraphics;
567 params.m_rtPart = pDate->rect; 564 params.m_rtPart = pDate->rect;
568 params.m_dwStates = CFWL_PartState_Normal; 565 params.m_dwStates = CFWL_PartState_Normal;
569 if (pMatrix) { 566 if (pMatrix) {
570 params.m_matrix.Concat(*pMatrix); 567 params.m_matrix.Concat(*pMatrix);
571 } 568 }
572 pTheme->DrawBackground(&params); 569 pTheme->DrawBackground(&params);
573 } 570 }
574 void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics* pGraphics, 571
575 IFWL_ThemeProvider* pTheme, 572 void IFWL_MonthCalendar::DrawTodayCircle(CFX_Graphics* pGraphics,
576 const CFX_Matrix* pMatrix) { 573 IFWL_ThemeProvider* pTheme,
574 const CFX_Matrix* pMatrix) {
577 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { 575 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
578 return; 576 return;
579 } 577 }
580 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { 578 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
581 return; 579 return;
582 } 580 }
583 CFWL_ThemeBackground params; 581 CFWL_ThemeBackground params;
584 params.m_pWidget = m_pInterface; 582 params.m_pWidget = this;
585 params.m_iPart = CFWL_Part::TodayCircle; 583 params.m_iPart = CFWL_Part::TodayCircle;
586 params.m_pGraphics = pGraphics; 584 params.m_pGraphics = pGraphics;
587 params.m_dwStates = CFWL_PartState_Normal; 585 params.m_dwStates = CFWL_PartState_Normal;
588 params.m_rtPart = m_rtTodayFlag; 586 params.m_rtPart = m_rtTodayFlag;
589 if (pMatrix) { 587 if (pMatrix) {
590 params.m_matrix.Concat(*pMatrix); 588 params.m_matrix.Concat(*pMatrix);
591 } 589 }
592 pTheme->DrawBackground(&params); 590 pTheme->DrawBackground(&params);
593 } 591 }
594 CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) { 592
593 CFX_SizeF IFWL_MonthCalendar::CalcSize(FX_BOOL bAutoSize) {
595 if (!m_pProperties->m_pThemeProvider) 594 if (!m_pProperties->m_pThemeProvider)
596 return CFX_SizeF(); 595 return CFX_SizeF();
597 596
598 if (!bAutoSize) { 597 if (!bAutoSize) {
599 GetClientRect(m_rtClient); 598 GetClientRect(m_rtClient);
600 return CFX_SizeF(m_rtClient.width, m_rtClient.height); 599 return CFX_SizeF(m_rtClient.width, m_rtClient.height);
601 } 600 }
602 601
603 CFX_SizeF fs; 602 CFX_SizeF fs;
604 CFWL_ThemePart params; 603 CFWL_ThemePart params;
605 params.m_pWidget = m_pInterface; 604 params.m_pWidget = this;
606 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 605 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
607 FX_FLOAT fMaxWeekW = 0.0f; 606 FX_FLOAT fMaxWeekW = 0.0f;
608 FX_FLOAT fMaxWeekH = 0.0f; 607 FX_FLOAT fMaxWeekH = 0.0f;
609 608
610 for (uint32_t i = 0; i < 7; ++i) { 609 for (uint32_t i = 0; i < 7; ++i) {
611 CFX_SizeF sz = CalcTextSize(*GetCapacityForDay(pTheme, params, i), 610 CFX_SizeF sz = CalcTextSize(*GetCapacityForDay(pTheme, params, i),
612 m_pProperties->m_pThemeProvider); 611 m_pProperties->m_pThemeProvider);
613 fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x; 612 fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x;
614 fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y; 613 fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y;
615 } 614 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 CFX_WideString* wsText = static_cast<CFX_WideString*>( 649 CFX_WideString* wsText = static_cast<CFX_WideString*>(
651 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today)); 650 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
652 m_wsToday = *wsText + wsToday; 651 m_wsToday = *wsText + wsToday;
653 m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider); 652 m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider);
654 m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y; 653 m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
655 fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + 654 fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y +
656 MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4; 655 MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4;
657 return fs; 656 return fs;
658 } 657 }
659 658
660 void CFWL_MonthCalendarImp::CalcHeadSize() { 659 void IFWL_MonthCalendar::CalcHeadSize() {
661 FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2; 660 FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2;
662 FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2; 661 FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2;
663 m_rtHeadText.Set(m_rtClient.left + fHeadHMargin, 662 m_rtHeadText.Set(m_rtClient.left + fHeadHMargin,
664 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + 663 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN +
665 MONTHCAL_VMARGIN + fHeadVMargin, 664 MONTHCAL_VMARGIN + fHeadVMargin,
666 m_szHead.x, m_szHead.y); 665 m_szHead.x, m_szHead.y);
667 } 666 }
668 void CFWL_MonthCalendarImp::CalcTodaySize() { 667
668 void IFWL_MonthCalendar::CalcTodaySize() {
669 m_rtTodayFlag.Set( 669 m_rtTodayFlag.Set(
670 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, 670 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
671 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, 671 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
672 m_szCell.x, m_szToday.y); 672 m_szCell.x, m_szToday.y);
673 m_rtToday.Set( 673 m_rtToday.Set(
674 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + 674 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x +
675 MONTHCAL_HMARGIN * 2, 675 MONTHCAL_HMARGIN * 2,
676 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, 676 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
677 m_szToday.x, m_szToday.y); 677 m_szToday.x, m_szToday.y);
678 } 678 }
679 void CFWL_MonthCalendarImp::LayOut() { 679
680 void IFWL_MonthCalendar::LayOut() {
680 GetClientRect(m_rtClient); 681 GetClientRect(m_rtClient);
681 { 682 {
682 m_rtHead.Set( 683 m_rtHead.Set(
683 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, 684 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top,
684 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 685 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
685 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); 686 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2);
686 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 687 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
687 m_rtHead.bottom(), 688 m_rtHead.bottom(),
688 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 689 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
689 m_szCell.y + MONTHCAL_VMARGIN * 2); 690 m_szCell.y + MONTHCAL_VMARGIN * 2);
(...skipping 10 matching lines...) Expand all
700 m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, 701 m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2,
701 MONTHCAL_HSEP_HEIGHT); 702 MONTHCAL_HSEP_HEIGHT);
702 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 703 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
703 m_rtWeek.bottom(), 704 m_rtWeek.bottom(),
704 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 705 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
705 m_szCell.y * (MONTHCAL_ROWS - 3) + 706 m_szCell.y * (MONTHCAL_ROWS - 3) +
706 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); 707 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2);
707 } 708 }
708 CalDateItem(); 709 CalDateItem();
709 } 710 }
710 void CFWL_MonthCalendarImp::CalDateItem() { 711
712 void IFWL_MonthCalendar::CalDateItem() {
711 FX_BOOL bNewWeek = FALSE; 713 FX_BOOL bNewWeek = FALSE;
712 int32_t iWeekOfMonth = 0; 714 int32_t iWeekOfMonth = 0;
713 FX_FLOAT fLeft = m_rtDates.left; 715 FX_FLOAT fLeft = m_rtDates.left;
714 FX_FLOAT fTop = m_rtDates.top; 716 FX_FLOAT fTop = m_rtDates.top;
715 int32_t iCount = m_arrDates.GetSize(); 717 int32_t iCount = m_arrDates.GetSize();
716 for (int32_t i = 0; i < iCount; i++) { 718 for (int32_t i = 0; i < iCount; i++) {
717 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i); 719 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i);
718 if (bNewWeek) { 720 if (bNewWeek) {
719 iWeekOfMonth++; 721 iWeekOfMonth++;
720 bNewWeek = FALSE; 722 bNewWeek = FALSE;
721 } 723 }
722 pDateInfo->rect.Set( 724 pDateInfo->rect.Set(
723 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), 725 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)),
724 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), 726 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)),
725 m_szCell.x + (MONTHCAL_HMARGIN * 2), 727 m_szCell.x + (MONTHCAL_HMARGIN * 2),
726 m_szCell.y + (MONTHCAL_VMARGIN * 2)); 728 m_szCell.y + (MONTHCAL_VMARGIN * 2));
727 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 729 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
728 pDateInfo->rect.Offset(m_fWeekNumWid, 0); 730 pDateInfo->rect.Offset(m_fWeekNumWid, 0);
729 } 731 }
730 if (pDateInfo->iDayOfWeek >= 6) { 732 if (pDateInfo->iDayOfWeek >= 6) {
731 bNewWeek = TRUE; 733 bNewWeek = TRUE;
732 } 734 }
733 } 735 }
734 } 736 }
735 void CFWL_MonthCalendarImp::GetCapValue() { 737
738 void IFWL_MonthCalendar::GetCapValue() {
736 if (!m_pProperties->m_pThemeProvider) { 739 if (!m_pProperties->m_pThemeProvider) {
737 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 740 m_pProperties->m_pThemeProvider = GetAvailableTheme();
738 } 741 }
739 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 742 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
740 CFWL_ThemePart part; 743 CFWL_ThemePart part;
741 part.m_pWidget = m_pInterface; 744 part.m_pWidget = this;
742 m_fHeadWid = *static_cast<FX_FLOAT*>( 745 m_fHeadWid = *static_cast<FX_FLOAT*>(
743 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth)); 746 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth));
744 m_fHeadHei = *static_cast<FX_FLOAT*>( 747 m_fHeadHei = *static_cast<FX_FLOAT*>(
745 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight)); 748 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight));
746 m_fHeadBtnWid = *static_cast<FX_FLOAT*>( 749 m_fHeadBtnWid = *static_cast<FX_FLOAT*>(
747 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth)); 750 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth));
748 m_fHeadBtnHei = *static_cast<FX_FLOAT*>( 751 m_fHeadBtnHei = *static_cast<FX_FLOAT*>(
749 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHeight)); 752 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHeight));
750 m_fHeadBtnHMargin = *static_cast<FX_FLOAT*>( 753 m_fHeadBtnHMargin = *static_cast<FX_FLOAT*>(
751 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHMargin)); 754 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHMargin));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 m_fTodayFlagWid = *static_cast<FX_FLOAT*>( 791 m_fTodayFlagWid = *static_cast<FX_FLOAT*>(
789 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth)); 792 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth));
790 m_fMCWid = *static_cast<FX_FLOAT*>( 793 m_fMCWid = *static_cast<FX_FLOAT*>(
791 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width)); 794 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width));
792 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 795 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
793 m_fMCWid += m_fWeekNumWid; 796 m_fMCWid += m_fWeekNumWid;
794 } 797 }
795 m_fMCHei = *static_cast<FX_FLOAT*>( 798 m_fMCHei = *static_cast<FX_FLOAT*>(
796 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); 799 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height));
797 } 800 }
798 int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear, 801
799 int32_t iMonth, 802 int32_t IFWL_MonthCalendar::CalWeekNumber(int32_t iYear,
800 int32_t iDay) { 803 int32_t iMonth,
804 int32_t iDay) {
801 return 0; 805 return 0;
802 } 806 }
803 FX_BOOL CFWL_MonthCalendarImp::GetMinDate(int32_t& iYear, 807
804 int32_t& iMonth, 808 FX_BOOL IFWL_MonthCalendar::GetMinDate(int32_t& iYear,
805 int32_t& iDay) { 809 int32_t& iMonth,
810 int32_t& iDay) {
806 iYear = m_dtMin.iYear; 811 iYear = m_dtMin.iYear;
807 iMonth = m_dtMin.iMonth; 812 iMonth = m_dtMin.iMonth;
808 iDay = m_dtMin.iDay; 813 iDay = m_dtMin.iDay;
809 return TRUE; 814 return TRUE;
810 } 815 }
811 FX_BOOL CFWL_MonthCalendarImp::SetMinDate(int32_t iYear, 816
812 int32_t iMonth, 817 FX_BOOL IFWL_MonthCalendar::SetMinDate(int32_t iYear,
813 int32_t iDay) { 818 int32_t iMonth,
819 int32_t iDay) {
814 m_dtMin = DATE(iYear, iMonth, iDay); 820 m_dtMin = DATE(iYear, iMonth, iDay);
815 return TRUE; 821 return TRUE;
816 } 822 }
817 FX_BOOL CFWL_MonthCalendarImp::GetMaxDate(int32_t& iYear, 823
818 int32_t& iMonth, 824 FX_BOOL IFWL_MonthCalendar::GetMaxDate(int32_t& iYear,
819 int32_t& iDay) { 825 int32_t& iMonth,
826 int32_t& iDay) {
820 iYear = m_dtMax.iYear; 827 iYear = m_dtMax.iYear;
821 iMonth = m_dtMax.iMonth; 828 iMonth = m_dtMax.iMonth;
822 iDay = m_dtMax.iDay; 829 iDay = m_dtMax.iDay;
823 return TRUE; 830 return TRUE;
824 } 831 }
825 FX_BOOL CFWL_MonthCalendarImp::SetMaxDate(int32_t iYear, 832
826 int32_t iMonth, 833 FX_BOOL IFWL_MonthCalendar::SetMaxDate(int32_t iYear,
827 int32_t iDay) { 834 int32_t iMonth,
835 int32_t iDay) {
828 m_dtMax = DATE(iYear, iMonth, iDay); 836 m_dtMax = DATE(iYear, iMonth, iDay);
829 return TRUE; 837 return TRUE;
830 } 838 }
831 FX_BOOL CFWL_MonthCalendarImp::InitDate() { 839
840 FX_BOOL IFWL_MonthCalendar::InitDate() {
832 if (m_pProperties->m_pDataProvider) { 841 if (m_pProperties->m_pDataProvider) {
833 IFWL_MonthCalendarDP* pDateProv = 842 IFWL_MonthCalendarDP* pDateProv =
834 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); 843 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider);
835 m_iYear = pDateProv->GetCurYear(m_pInterface); 844 m_iYear = pDateProv->GetCurYear(this);
836 m_iMonth = pDateProv->GetCurMonth(m_pInterface); 845 m_iMonth = pDateProv->GetCurMonth(this);
837 m_iDay = pDateProv->GetCurDay(m_pInterface); 846 m_iDay = pDateProv->GetCurDay(this);
838 m_iCurYear = m_iYear; 847 m_iCurYear = m_iYear;
839 m_iCurMonth = m_iMonth; 848 m_iCurMonth = m_iMonth;
840 } else { 849 } else {
841 m_iDay = 1; 850 m_iDay = 1;
842 m_iMonth = 1; 851 m_iMonth = 1;
843 m_iYear = 1; 852 m_iYear = 1;
844 m_iCurYear = m_iYear; 853 m_iCurYear = m_iYear;
845 m_iCurMonth = m_iMonth; 854 m_iCurMonth = m_iMonth;
846 } 855 }
847 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); 856 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
848 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 857 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
849 m_dtMin = DATE(1500, 12, 1); 858 m_dtMin = DATE(1500, 12, 1);
850 m_dtMax = DATE(2200, 1, 1); 859 m_dtMax = DATE(2200, 1, 1);
851 return TRUE; 860 return TRUE;
852 } 861 }
853 862
854 void CFWL_MonthCalendarImp::ClearDateItem() { 863 void IFWL_MonthCalendar::ClearDateItem() {
855 for (int32_t i = 0; i < m_arrDates.GetSize(); i++) 864 for (int32_t i = 0; i < m_arrDates.GetSize(); i++)
856 delete m_arrDates.GetAt(i); 865 delete m_arrDates.GetAt(i);
857 866
858 m_arrDates.RemoveAll(); 867 m_arrDates.RemoveAll();
859 } 868 }
860 869
861 void CFWL_MonthCalendarImp::ReSetDateItem() { 870 void IFWL_MonthCalendar::ReSetDateItem() {
862 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); 871 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1);
863 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); 872 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth);
864 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); 873 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek();
865 for (int32_t i = 0; i < iDays; i++) { 874 for (int32_t i = 0; i < iDays; i++) {
866 if (iDayOfWeek >= 7) { 875 if (iDayOfWeek >= 7) {
867 iDayOfWeek = 0; 876 iDayOfWeek = 0;
868 } 877 }
869 CFX_WideString wsDay; 878 CFX_WideString wsDay;
870 wsDay.Format(L"%d", i + 1); 879 wsDay.Format(L"%d", i + 1);
871 uint32_t dwStates = 0; 880 uint32_t dwStates = 0;
872 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { 881 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) {
873 dwStates |= FWL_ITEMSTATE_MCD_Flag; 882 dwStates |= FWL_ITEMSTATE_MCD_Flag;
874 } 883 }
875 if (m_arrSelDays.Find(i + 1) != -1) { 884 if (m_arrSelDays.Find(i + 1) != -1) {
876 dwStates |= FWL_ITEMSTATE_MCD_Selected; 885 dwStates |= FWL_ITEMSTATE_MCD_Selected;
877 } 886 }
878 CFX_RectF rtDate; 887 CFX_RectF rtDate;
879 rtDate.Set(0, 0, 0, 0); 888 rtDate.Set(0, 0, 0, 0);
880 m_arrDates.Add( 889 m_arrDates.Add(
881 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); 890 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay));
882 iDayOfWeek++; 891 iDayOfWeek++;
883 } 892 }
884 } 893 }
885 FX_BOOL CFWL_MonthCalendarImp::NextMonth() { 894
895 FX_BOOL IFWL_MonthCalendar::NextMonth() {
886 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 896 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
887 if (iMonth >= 12) { 897 if (iMonth >= 12) {
888 iMonth = 1; 898 iMonth = 1;
889 iYear++; 899 iYear++;
890 } else { 900 } else {
891 iMonth++; 901 iMonth++;
892 } 902 }
893 DATE dt(m_iCurYear, m_iCurMonth, 1); 903 DATE dt(m_iCurYear, m_iCurMonth, 1);
894 if (!(dt < m_dtMax)) { 904 if (!(dt < m_dtMax)) {
895 return FALSE; 905 return FALSE;
896 } 906 }
897 m_iCurYear = iYear, m_iCurMonth = iMonth; 907 m_iCurYear = iYear, m_iCurMonth = iMonth;
898 ChangeToMonth(m_iCurYear, m_iCurMonth); 908 ChangeToMonth(m_iCurYear, m_iCurMonth);
899 return TRUE; 909 return TRUE;
900 } 910 }
901 FX_BOOL CFWL_MonthCalendarImp::PrevMonth() { 911
912 FX_BOOL IFWL_MonthCalendar::PrevMonth() {
902 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 913 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
903 if (iMonth <= 1) { 914 if (iMonth <= 1) {
904 iMonth = 12; 915 iMonth = 12;
905 iYear--; 916 iYear--;
906 } else { 917 } else {
907 iMonth--; 918 iMonth--;
908 } 919 }
909 DATE dt(m_iCurYear, m_iCurMonth, 1); 920 DATE dt(m_iCurYear, m_iCurMonth, 1);
910 if (!(dt > m_dtMin)) { 921 if (!(dt > m_dtMin)) {
911 return FALSE; 922 return FALSE;
912 } 923 }
913 m_iCurYear = iYear, m_iCurMonth = iMonth; 924 m_iCurYear = iYear, m_iCurMonth = iMonth;
914 ChangeToMonth(m_iCurYear, m_iCurMonth); 925 ChangeToMonth(m_iCurYear, m_iCurMonth);
915 return TRUE; 926 return TRUE;
916 } 927 }
917 void CFWL_MonthCalendarImp::ChangeToMonth(int32_t iYear, int32_t iMonth) { 928
929 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
918 m_iCurYear = iYear; 930 m_iCurYear = iYear;
919 m_iCurMonth = iMonth; 931 m_iCurMonth = iMonth;
920 m_iHovered = -1; 932 m_iHovered = -1;
921 ClearDateItem(); 933 ClearDateItem();
922 ReSetDateItem(); 934 ReSetDateItem();
923 CalDateItem(); 935 CalDateItem();
924 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 936 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
925 } 937 }
926 FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll) { 938
939 FX_BOOL IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, FX_BOOL bAll) {
927 if (iDay == -1 && !bAll) { 940 if (iDay == -1 && !bAll) {
928 return FALSE; 941 return FALSE;
929 } 942 }
930 if (bAll) { 943 if (bAll) {
931 int32_t iCount = m_arrSelDays.GetSize(); 944 int32_t iCount = m_arrSelDays.GetSize();
932 int32_t iDatesCount = m_arrDates.GetSize(); 945 int32_t iDatesCount = m_arrDates.GetSize();
933 for (int32_t i = 0; i < iCount; i++) { 946 for (int32_t i = 0; i < iCount; i++) {
934 int32_t iSelDay = m_arrSelDays.GetAt(i); 947 int32_t iSelDay = m_arrSelDays.GetAt(i);
935 if (iSelDay <= iDatesCount) { 948 if (iSelDay <= iDatesCount) {
936 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 949 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
937 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 950 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
938 } 951 }
939 } 952 }
940 m_arrSelDays.RemoveAll(); 953 m_arrSelDays.RemoveAll();
941 } else { 954 } else {
942 int32_t index = m_arrSelDays.Find(iDay); 955 int32_t index = m_arrSelDays.Find(iDay);
943 if (index == -1) { 956 if (index == -1) {
944 return FALSE; 957 return FALSE;
945 } 958 }
946 int32_t iSelDay = m_arrSelDays.GetAt(iDay); 959 int32_t iSelDay = m_arrSelDays.GetAt(iDay);
947 int32_t iDatesCount = m_arrDates.GetSize(); 960 int32_t iDatesCount = m_arrDates.GetSize();
948 if (iSelDay <= iDatesCount) { 961 if (iSelDay <= iDatesCount) {
949 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 962 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
950 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 963 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
951 } 964 }
952 m_arrSelDays.RemoveAt(index); 965 m_arrSelDays.RemoveAt(index);
953 } 966 }
954 return TRUE; 967 return TRUE;
955 } 968 }
956 FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay) { 969
970 FX_BOOL IFWL_MonthCalendar::AddSelDay(int32_t iDay) {
957 ASSERT(iDay > 0); 971 ASSERT(iDay > 0);
958 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 972 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
959 } else { 973 } else {
960 if (m_arrSelDays.Find(iDay) == -1) { 974 if (m_arrSelDays.Find(iDay) == -1) {
961 RemoveSelDay(-1, TRUE); 975 RemoveSelDay(-1, TRUE);
962 if (iDay <= m_arrDates.GetSize()) { 976 if (iDay <= m_arrDates.GetSize()) {
963 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); 977 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1);
964 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; 978 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
965 } 979 }
966 m_arrSelDays.Add(iDay); 980 m_arrSelDays.Add(iDay);
967 } 981 }
968 } 982 }
969 return TRUE; 983 return TRUE;
970 } 984 }
971 FX_BOOL CFWL_MonthCalendarImp::JumpToToday() { 985
986 FX_BOOL IFWL_MonthCalendar::JumpToToday() {
972 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { 987 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
973 m_iCurYear = m_iYear; 988 m_iCurYear = m_iYear;
974 m_iCurMonth = m_iMonth; 989 m_iCurMonth = m_iMonth;
975 ChangeToMonth(m_iYear, m_iMonth); 990 ChangeToMonth(m_iYear, m_iMonth);
976 AddSelDay(m_iDay); 991 AddSelDay(m_iDay);
977 } else { 992 } else {
978 if (m_arrSelDays.Find(m_iDay) == -1) { 993 if (m_arrSelDays.Find(m_iDay) == -1) {
979 AddSelDay(m_iDay); 994 AddSelDay(m_iDay);
980 } 995 }
981 } 996 }
982 return TRUE; 997 return TRUE;
983 } 998 }
984 void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear, 999
985 int32_t iMonth, 1000 void IFWL_MonthCalendar::GetHeadText(int32_t iYear,
986 CFX_WideString& wsHead) { 1001 int32_t iMonth,
1002 CFX_WideString& wsHead) {
987 ASSERT(iMonth > 0 && iMonth < 13); 1003 ASSERT(iMonth > 0 && iMonth < 13);
988 static const FX_WCHAR* const pMonth[] = { 1004 static const FX_WCHAR* const pMonth[] = {
989 L"January", L"February", L"March", L"April", 1005 L"January", L"February", L"March", L"April",
990 L"May", L"June", L"July", L"August", 1006 L"May", L"June", L"July", L"August",
991 L"September", L"October", L"November", L"December"}; 1007 L"September", L"October", L"November", L"December"};
992 wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear); 1008 wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear);
993 } 1009 }
994 void CFWL_MonthCalendarImp::GetTodayText(int32_t iYear, 1010
995 int32_t iMonth, 1011 void IFWL_MonthCalendar::GetTodayText(int32_t iYear,
996 int32_t iDay, 1012 int32_t iMonth,
997 CFX_WideString& wsToday) { 1013 int32_t iDay,
1014 CFX_WideString& wsToday) {
998 wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear); 1015 wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear);
999 } 1016 }
1000 int32_t CFWL_MonthCalendarImp::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { 1017
1018 int32_t IFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
1001 int32_t iCount = m_arrDates.GetSize(); 1019 int32_t iCount = m_arrDates.GetSize();
1002 for (int32_t i = 0; i < iCount; i++) { 1020 for (int32_t i = 0; i < iCount; i++) {
1003 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i); 1021 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i);
1004 if (pDateInfo->rect.Contains(x, y)) { 1022 if (pDateInfo->rect.Contains(x, y)) {
1005 return ++i; 1023 return ++i;
1006 } 1024 }
1007 } 1025 }
1008 return -1; 1026 return -1;
1009 } 1027 }
1010 FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { 1028
1029 FX_BOOL IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
1011 if (iDay <= 0 || iDay > m_arrDates.GetSize()) { 1030 if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
1012 return FALSE; 1031 return FALSE;
1013 } 1032 }
1014 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1]; 1033 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1];
1015 if (!pDateInfo) 1034 if (!pDateInfo)
1016 return FALSE; 1035 return FALSE;
1017 rtDay = pDateInfo->rect; 1036 rtDay = pDateInfo->rect;
1018 return TRUE; 1037 return TRUE;
1019 } 1038 }
1020 1039
1021 CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( 1040 CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate(
1022 CFWL_MonthCalendarImp* pOwner) 1041 IFWL_MonthCalendar* pOwner)
1023 : m_pOwner(pOwner) {} 1042 : m_pOwner(pOwner) {}
1024 1043
1025 void CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 1044 void CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
1026 if (!pMessage) 1045 if (!pMessage)
1027 return; 1046 return;
1028 1047
1029 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 1048 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1030 switch (dwMsgCode) { 1049 switch (dwMsgCode) {
1031 case CFWL_MessageType::SetFocus: { 1050 case CFWL_MessageType::SetFocus: {
1032 OnFocusChanged(pMessage, TRUE); 1051 OnFocusChanged(pMessage, TRUE);
(...skipping 23 matching lines...) Expand all
1056 } 1075 }
1057 case FWL_MouseCommand::Leave: { 1076 case FWL_MouseCommand::Leave: {
1058 OnMouseLeave(pMouse); 1077 OnMouseLeave(pMouse);
1059 break; 1078 break;
1060 } 1079 }
1061 default: 1080 default:
1062 break; 1081 break;
1063 } 1082 }
1064 break; 1083 break;
1065 } 1084 }
1066 default: { 1085 default: { break; }
1067 break;
1068 }
1069 } 1086 }
1070 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 1087 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
1071 } 1088 }
1072 1089
1073 void CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1090 void CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
1074 const CFX_Matrix* pMatrix) { 1091 const CFX_Matrix* pMatrix) {
1075 m_pOwner->DrawWidget(pGraphics, pMatrix); 1092 m_pOwner->DrawWidget(pGraphics, pMatrix);
1076 } 1093 }
1077 1094
1078 void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {} 1095 void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {}
1079 1096
1080 void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 1097 void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
1081 FX_BOOL bSet) { 1098 FX_BOOL bSet) {
1082 if (bSet) { 1099 if (bSet) {
1083 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1100 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1084 } else { 1101 } else {
1085 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1102 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1086 } 1103 }
1087 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1104 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1088 } 1105 }
1106
1089 void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1107 void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1090 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1108 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1091 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; 1109 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
1092 m_pOwner->PrevMonth(); 1110 m_pOwner->PrevMonth();
1093 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1111 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1094 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1112 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1095 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed; 1113 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
1096 m_pOwner->NextMonth(); 1114 m_pOwner->NextMonth();
1097 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1115 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1098 } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { 1116 } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
(...skipping 15 matching lines...) Expand all
1114 FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel; 1132 FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
1115 if (bSelChanged) { 1133 if (bSelChanged) {
1116 FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1); 1134 FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
1117 CFX_RectF rtInvalidate(lpDatesInfo->rect); 1135 CFX_RectF rtInvalidate(lpDatesInfo->rect);
1118 if (iOldSel > 0) { 1136 if (iOldSel > 0) {
1119 lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1); 1137 lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
1120 rtInvalidate.Union(lpDatesInfo->rect); 1138 rtInvalidate.Union(lpDatesInfo->rect);
1121 } 1139 }
1122 m_pOwner->AddSelDay(iCurSel); 1140 m_pOwner->AddSelDay(iCurSel);
1123 CFWL_EvtClick wmClick; 1141 CFWL_EvtClick wmClick;
1124 wmClick.m_pSrcTarget = m_pOwner->m_pInterface; 1142 wmClick.m_pSrcTarget = m_pOwner;
1125 m_pOwner->DispatchEvent(&wmClick); 1143 m_pOwner->DispatchEvent(&wmClick);
1126 CFWL_EventMcdDateChanged wmDateSelected; 1144 CFWL_EventMcdDateChanged wmDateSelected;
1127 wmDateSelected.m_iStartDay = iCurSel; 1145 wmDateSelected.m_iStartDay = iCurSel;
1128 wmDateSelected.m_iEndDay = iCurSel; 1146 wmDateSelected.m_iEndDay = iCurSel;
1129 wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth; 1147 wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth;
1130 wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear; 1148 wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear;
1131 wmDateSelected.m_pSrcTarget = m_pOwner->m_pInterface; 1149 wmDateSelected.m_pSrcTarget = m_pOwner;
1132 m_pOwner->DispatchEvent(&wmDateSelected); 1150 m_pOwner->DispatchEvent(&wmDateSelected);
1133 m_pOwner->Repaint(&rtInvalidate); 1151 m_pOwner->Repaint(&rtInvalidate);
1134 } 1152 }
1135 } 1153 }
1136 } 1154 }
1137 } 1155 }
1156
1138 void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1157 void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1139 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1158 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1140 m_pOwner->m_iLBtnPartStates = 0; 1159 m_pOwner->m_iLBtnPartStates = 0;
1141 m_pOwner->Repaint(&m_pOwner->m_rtLBtn); 1160 m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
1142 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1161 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1143 m_pOwner->m_iRBtnPartStates = 0; 1162 m_pOwner->m_iRBtnPartStates = 0;
1144 m_pOwner->Repaint(&m_pOwner->m_rtRBtn); 1163 m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
1145 } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { 1164 } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
1146 int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1165 int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1147 if (iDay != -1) { 1166 if (iDay != -1) {
1148 m_pOwner->AddSelDay(iDay); 1167 m_pOwner->AddSelDay(iDay);
1149 } 1168 }
1150 } 1169 }
1151 } 1170 }
1171
1152 void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 1172 void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
1153 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 1173 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
1154 return; 1174 return;
1155 } 1175 }
1156 FX_BOOL bRepaint = FALSE; 1176 FX_BOOL bRepaint = FALSE;
1157 CFX_RectF rtInvalidate; 1177 CFX_RectF rtInvalidate;
1158 rtInvalidate.Set(0, 0, 0, 0); 1178 rtInvalidate.Set(0, 0, 0, 0);
1159 if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { 1179 if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
1160 int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1180 int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1161 bRepaint = m_pOwner->m_iHovered != iHover; 1181 bRepaint = m_pOwner->m_iHovered != iHover;
(...skipping 16 matching lines...) Expand all
1178 bRepaint = m_pOwner->m_iHovered > 0; 1198 bRepaint = m_pOwner->m_iHovered > 0;
1179 if (bRepaint) { 1199 if (bRepaint) {
1180 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); 1200 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
1181 } 1201 }
1182 m_pOwner->m_iHovered = -1; 1202 m_pOwner->m_iHovered = -1;
1183 } 1203 }
1184 if (bRepaint && !rtInvalidate.IsEmpty()) { 1204 if (bRepaint && !rtInvalidate.IsEmpty()) {
1185 m_pOwner->Repaint(&rtInvalidate); 1205 m_pOwner->Repaint(&rtInvalidate);
1186 } 1206 }
1187 } 1207 }
1208
1188 void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 1209 void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
1189 if (m_pOwner->m_iHovered > 0) { 1210 if (m_pOwner->m_iHovered > 0) {
1190 CFX_RectF rtInvalidate; 1211 CFX_RectF rtInvalidate;
1191 rtInvalidate.Set(0, 0, 0, 0); 1212 rtInvalidate.Set(0, 0, 0, 0);
1192 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); 1213 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
1193 m_pOwner->m_iHovered = -1; 1214 m_pOwner->m_iHovered = -1;
1194 if (!rtInvalidate.IsEmpty()) { 1215 if (!rtInvalidate.IsEmpty()) {
1195 m_pOwner->Repaint(&rtInvalidate); 1216 m_pOwner->Repaint(&rtInvalidate);
1196 } 1217 }
1197 } 1218 }
1198 } 1219 }
1199 1220
1200 FWL_DATEINFO::FWL_DATEINFO(int32_t day, 1221 FWL_DATEINFO::FWL_DATEINFO(int32_t day,
1201 int32_t dayofweek, 1222 int32_t dayofweek,
1202 uint32_t dwSt, 1223 uint32_t dwSt,
1203 CFX_RectF rc, 1224 CFX_RectF rc,
1204 CFX_WideString& wsday) 1225 CFX_WideString& wsday)
1205 : iDay(day), 1226 : iDay(day),
1206 iDayOfWeek(dayofweek), 1227 iDayOfWeek(dayofweek),
1207 dwStates(dwSt), 1228 dwStates(dwSt),
1208 rect(rc), 1229 rect(rc),
1209 wsDay(wsday) {} 1230 wsDay(wsday) {}
1210 1231
1211 FWL_DATEINFO::~FWL_DATEINFO() {} 1232 FWL_DATEINFO::~FWL_DATEINFO() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_monthcalendar.h ('k') | xfa/fwl/core/ifwl_picturebox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698