soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SDateTimePicker.cpp
1#include "souistd.h"
2#include "control/SDateTimePicker.h"
3#include "helper/STime.h"
4
5SNSBEGIN
7 : m_pDropDownWnd(NULL)
8 , m_pSkinBtn(GETBUILTINSKIN(SKIN_SYS_DROPBTN))
9 , m_eSelDateType(eDT_NULL)
10 , m_nNumWidth(0)
11 , m_nCharWidth(0)
12 , m_pCalendar(NULL)
13 , m_nDropWidth(220)
14 , m_bTimeEnable(true)
15 , m_wCharNum(0)
17 , m_crCue(RGBA(0xcc, 0xcc, 0xcc, 0xff))
18 , m_strCue(this)
19{
20 m_evtSet.addEvent(EVENTID(EventDateTimeChanged));
21 m_pNcSkin = GETBUILTINSKIN(SKIN_SYS_BORDER);
22 m_style.SetAttribute(L"margin", L"1", TRUE);
23 m_style.SetAlign(DT_LEFT);
24 m_style.SetVAlign(DT_VCENTER);
25
26 m_bFocusable = TRUE;
27
28 GetLocalTime(&m_sysTime);
29
30 m_crSelBg = RGBA(0, 120, 215, 255);
31 m_crSelText = RGBA(255, 255, 255, 255);
32}
33
35{
36 if (NULL != m_pCalendar)
37 {
38 m_pCalendar->SetOwner(NULL);
39 m_pCalendar->SSendMessage(WM_DESTROY);
40 m_pCalendar->Release();
41 }
42}
43
45{
47 if (NULL == m_pCalendar)
48 return FALSE;
49 m_pCalendar->SetContainer(GetContainer());
50
51 SXmlNode xmlCal = xmlNode.child(L"calstyle");
52 if (xmlCal)
53 m_pCalendar->InitFromXml(&xmlCal);
54
55 m_pCalendar->SetAttribute(L"pos", L"0,0,-0,-0", TRUE);
56 m_pCalendar->SetOwner(this); // chain notify message to SDateTimePicker
57
58 m_pCalendar->GetEventSet()->subscribeEvent(EventCalendarExChanged::EventID, Subscriber(&SDateTimePicker::OnDateChanged, this));
59 m_pCalendar->GetEventSet()->subscribeEvent(EventCmd::EventID, Subscriber(&SDateTimePicker::OnDateCmd, this));
60 return TRUE;
61}
62
63BOOL SDateTimePicker::OnDateChanged(EventCalendarExChanged *pEvt)
64{
65 if (NULL == pEvt)
66 return TRUE;
67
68 m_sysTime.wDay = pEvt->iNewDay;
69 m_sysTime.wMonth = pEvt->iNewMonth;
70 m_sysTime.wYear = pEvt->iNewYear;
71
72 Invalidate();
73
74 EventDateTimeChanged e(this);
75 e.newTime = m_sysTime;
76 FireEvent(e);
77
78 return TRUE;
79}
80
81BOOL SDateTimePicker::OnDateCmd(EventCmd *pEvt)
82{
83 CloseUp();
84 return TRUE;
85}
86
88{
89 return this;
90}
91
93{
94 m_pCalendar->SetShowType(SHOW_MONTH);
95 m_pCalendar->SetDate(m_sysTime.wYear, m_sysTime.wMonth, m_sysTime.wDay);
96 // pDropDown->SetAttribute(L"sendWheel2Hover", L"1", TRUE);
97 pDropDown->GetRoot()->InsertChild(m_pCalendar);
98 pDropDown->GetRoot()->UpdateChildrenPosition();
99 CRect rc = m_pCalendar->GetWindowRect();
100 SSLOGI() << "rc=" << rc.left << "," << rc.top << "," << rc.right << "," << rc.bottom;
101 m_pCalendar->SetVisible(TRUE);
102 m_pCalendar->SetFocus();
103
105 CRect rcBtn;
106 GetDropBtnRect(&rcBtn);
107 InvalidateRect(rcBtn);
108}
109
111{
112 pDropDown->GetRoot()->RemoveChild(m_pCalendar);
113
114 m_pCalendar->SetVisible(FALSE);
115 m_pCalendar->SetContainer(GetContainer());
116
118 m_pDropDownWnd = NULL;
119}
120
121void SDateTimePicker::GetDropBtnRect(LPRECT pBtnRc, LPRECT pSkinRc)
122{
123 SIZE szBtn = m_pSkinBtn->GetSkinSize();
124 GetClientRect(pBtnRc);
125 pBtnRc->left = pBtnRc->right - (pBtnRc->bottom - pBtnRc->top); // 取 右边的正方形 为 按钮 区域
126
127 if (NULL == pSkinRc)
128 return;
129
130 int n = (pBtnRc->bottom - pBtnRc->top - szBtn.cy) / 2; // 按钮皮肤 则 要居中
131
132 pSkinRc->right = pBtnRc->right - n;
133 pSkinRc->left = pSkinRc->right - szBtn.cx;
134
135 pSkinRc->top = pBtnRc->top + n;
136 pSkinRc->bottom = pSkinRc->top + szBtn.cy;
137}
138
140{
141 SStringT szNum;
142 if (eType == m_eSelDateType) // 选中项
143 {
144 if (eDT_Year == eType)
145 {
146 if (m_wCharNum < 10)
147 szNum.Format(_T("%d"), wNum);
148 else if (m_wCharNum < 100)
149 szNum.Format(_T("%02d"), wNum);
150 else if (m_wCharNum < 1000)
151 szNum.Format(_T("%03d"), wNum);
152 else
153 szNum.Format(_T("%04d"), wNum);
154 }
155 else
156 {
157 if (m_wCharNum > 0)
158 szNum.Format(_T("%d"), wNum);
159 else
160 szNum.Format(_T("%02d"), wNum);
161 }
162 }
163 else
164 {
165 if (eDT_Year == eType)
166 {
167 szNum.Format(_T("%04d"), wNum);
168 }
169 else
170 {
171 szNum.Format(_T("%02d"), wNum);
172 }
173 }
174
175 return szNum;
176}
177
178void SDateTimePicker::Draw(EnDateType eType, IRenderTarget *pRT, WORD wNum, CRect &rcText)
179{
180 SStringT szNum = ToFormatText(eType, wNum);
181
182 if (eType != m_eSelDateType)
183 {
184 pRT->DrawText(szNum, szNum.GetLength(), rcText, GetTextAlign());
185 return;
186 }
187
188 // 选中 的 填充 字体颜色 变 白
189 pRT->FillSolidRect(rcText, m_crSelBg);
190
191 COLORREF old = pRT->SetTextColor(m_crSelText);
192 pRT->DrawText(szNum, szNum.GetLength(), rcText, GetTextAlign());
193 pRT->SetTextColor(old);
194}
195
197{
198 SPainter painter;
199
200 BeforePaint(pRT, painter);
201
202 CRect rcText;
203 GetTextRect(rcText);
204 if (m_sysTime.wYear == 0)
205 {
206 COLORREF crOld = pRT->SetTextColor(m_crCue);
207 pRT->DrawText(m_strCue.GetText(FALSE), m_strCue.GetText(FALSE).GetLength(), &rcText, GetTextAlign());
208 pRT->SetTextColor(crOld);
209 }
210 else
211 {
212 if (0 == m_nNumWidth)
213 {
214 SIZE sz;
215 pRT->MeasureText(_T("5"), 1, &sz);
216 m_nNumWidth = sz.cx;
217 m_nNumHeight = sz.cy;
218
219 pRT->MeasureText(_T("-"), 1, &sz);
220 m_nCharWidth = sz.cx;
221 }
222 rcText.OffsetRect(0, (rcText.Height() - m_nNumHeight) / 2 + 1);
223 rcText.bottom = rcText.top + m_nNumHeight;
224
225 // year
226 rcText.right = rcText.left + m_nNumWidth * 4;
227 Draw(eDT_Year, pRT, m_sysTime.wYear, rcText);
228
229 rcText.left = rcText.right;
230 rcText.right = rcText.left + m_nCharWidth;
231 pRT->DrawText(_T("-"), -1, rcText, GetTextAlign());
232
233 // month
234 rcText.left = rcText.right;
235 rcText.right = rcText.left + m_nNumWidth * 2;
236 Draw(eDT_Month, pRT, m_sysTime.wMonth, rcText);
237
238 rcText.left = rcText.right;
239 rcText.right = rcText.left + m_nCharWidth;
240 pRT->DrawText(_T("-"), -1, rcText, GetTextAlign());
241
242 // day
243 rcText.left = rcText.right;
244 rcText.right = rcText.left + m_nNumWidth * 2;
245 Draw(eDT_Day, pRT, m_sysTime.wDay, rcText);
246
247 if (m_bTimeEnable)
248 {
249 // hour
250 rcText.left = rcText.right + m_nCharWidth;
251 rcText.right = rcText.left + m_nNumWidth * 2;
252 Draw(eDT_Hour, pRT, m_sysTime.wHour, rcText);
253
254 rcText.left = rcText.right;
255 rcText.right = rcText.left + m_nCharWidth;
256 pRT->DrawText(_T(":"), -1, rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
257
258 // minute
259 rcText.left = rcText.right;
260 rcText.right = rcText.left + m_nNumWidth * 2;
261 Draw(eDT_Minute, pRT, m_sysTime.wMinute, rcText);
262
263 rcText.left = rcText.right;
264 rcText.right = rcText.left + m_nCharWidth;
265 pRT->DrawText(_T(":"), -1, rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
266
267 // second
268 rcText.left = rcText.right;
269 rcText.right = rcText.left + m_nNumWidth * 2;
270 // strText.Format(_T("%02d"), m_sysTime.wSecond);
271 Draw(eDT_Second, pRT, m_sysTime.wSecond, rcText);
272 }
273 }
274 AfterPaint(pRT, painter);
275
276 CRect rcBtn;
277 CRect rcSkin;
278 GetDropBtnRect(&rcBtn, &rcSkin);
280 {
281 rcBtn += CRect(1, 1, 1, 1);
282 m_pNcSkin->DrawByIndex(pRT, rcBtn, 1);
283 }
284 if (m_pSkinBtn)
285 m_pSkinBtn->DrawByState(pRT, rcSkin, m_dwBtnState);
286}
287
288bool SDateTimePicker::CalcPopupRect(int nWidth, CRect &rcPopup)
289{
290 CRect rcWnd = GetWindowRect();
291 GetContainer()->FrameToHost(&rcWnd);
292
293 ClientToScreen(GetContainer()->GetHostHwnd(), (LPPOINT)&rcWnd);
294 ClientToScreen(GetContainer()->GetHostHwnd(), ((LPPOINT)&rcWnd) + 1);
295
296 HMONITOR hMonitor = ::MonitorFromWindow(GetContainer()->GetHostHwnd(), MONITOR_DEFAULTTONULL);
297 CRect rcMonitor;
298 if (hMonitor)
299 {
300 MONITORINFO mi = { sizeof(MONITORINFO) };
301 ::GetMonitorInfo(hMonitor, &mi);
302 rcMonitor = mi.rcMonitor;
303 }
304 else
305 {
306 rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
307 rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
308 }
309
310 int nHeight = nWidth * 4 / 5;
311
312 if (rcWnd.bottom + nHeight <= rcMonitor.bottom)
313 {
314 rcPopup.SetRect(rcWnd.right - nWidth, rcWnd.bottom, rcWnd.right, rcWnd.bottom + nHeight);
315 return true;
316 }
317
318 rcPopup.SetRect(rcWnd.right - nWidth, rcWnd.top - nHeight, rcWnd.right, rcWnd.top);
319 return false;
320}
321
323{
324 CRect rcText;
325 GetTextRect(rcText);
326 int nWidth = pt.x - rcText.left;
327
328 EnDateType eSelType = eDT_NULL;
329
330 if (nWidth < (4 * m_nNumWidth + m_nCharWidth))
331 {
332 eSelType = eDT_Year; // year
333 }
334 else if (nWidth < (6 * m_nNumWidth + 2 * m_nCharWidth))
335 {
336 eSelType = eDT_Month; // month
337 }
338 else if (!m_bTimeEnable || nWidth < (8 * m_nNumWidth + 3 * m_nCharWidth))
339 {
340 eSelType = eDT_Day; // day
341 }
342 else if (nWidth < (10 * m_nNumWidth + 4 * m_nCharWidth))
343 {
344 eSelType = eDT_Hour; // hour
345 }
346 else if (nWidth < (12 * m_nNumWidth + 5 * m_nCharWidth))
347 {
348 eSelType = eDT_Minute; // minute
349 }
350 else
351 {
352 eSelType = eDT_Second; // second
353 }
354
355 return eSelType;
356}
357
358void SDateTimePicker::SetTime(const SYSTEMTIME &sysTime)
359{
360 m_sysTime = sysTime;
361 Invalidate();
362}
363
364void SDateTimePicker::SetTime(WORD wYear, WORD wMonth, WORD wDay, WORD wHour, WORD wMinute, WORD wSecond)
365{
366 m_sysTime.wYear = wYear;
367 m_sysTime.wMonth = wMonth;
368 m_sysTime.wDay = wDay;
369 m_sysTime.wHour = wHour;
370 m_sysTime.wMinute = wMinute;
371 m_sysTime.wSecond = wSecond;
372 Invalidate();
373}
374
375void SDateTimePicker::GetTime(SYSTEMTIME &sysTime)
376{
377 sysTime = m_sysTime;
378}
379
380void SDateTimePicker::GetTime(WORD *wYear, WORD *wMonth, WORD *wDay, WORD *wHour, WORD *wMinute, WORD *wSecond) const
381{
382 if (wYear)
383 *wYear = m_sysTime.wYear;
384 if (wMonth)
385 *wMonth = m_sysTime.wMonth;
386 if (wDay)
387 *wDay = m_sysTime.wDay;
388 if (wHour)
389 *wHour = m_sysTime.wHour;
390 if (wMinute)
391 *wMinute = m_sysTime.wMinute;
392 if (wSecond)
393 *wSecond = m_sysTime.wSecond;
394}
395
396SStringT SDateTimePicker::GetWindowText(BOOL bRawText)
397{
398 (bRawText);
399 SStringT szText;
400 szText.Format(_T("%04d-%02d-%02d"), m_sysTime.wYear, m_sysTime.wMonth, m_sysTime.wDay);
401 if (m_bTimeEnable)
402 szText.AppendFormat(_T(" %02d:%02d:%02d"), m_sysTime.wHour, m_sysTime.wMinute, m_sysTime.wSecond);
403
404 return szText;
405}
406
407void SDateTimePicker::OnLButtonDown(UINT nFlags, CPoint pt)
408{
409 __baseCls::OnLButtonDown(nFlags, pt);
411 return;
412
413 m_wCharNum = 0;
414 Invalidate();
415
416 CRect rcBtn;
417 GetDropBtnRect(&rcBtn);
418 if (!rcBtn.PtInRect(pt)) // 没有点击 按钮
419 {
420 EnDateType eSelType = HitTest(pt);
421 if (m_eSelDateType != eSelType)
422 {
423 m_eSelDateType = eSelType;
424 }
425 }
426 else
427 {
428 m_eSelDateType = eDT_NULL;
429 DropDown();
430 }
431}
432
433void SDateTimePicker::OnMouseMove(UINT nFlags, CPoint pt)
434{
436 return;
437
438 __baseCls::OnMouseHover(nFlags, pt);
439
440 CRect rcBtn;
441 GetDropBtnRect(&rcBtn);
442
443 if (rcBtn.PtInRect(pt))
444 {
446 InvalidateRect(rcBtn);
447 }
448 else if (WndState_Hover == m_dwBtnState)
449 {
451 InvalidateRect(rcBtn);
452 }
453}
454
456{
458 return;
459
460 if (GetState() & WndState_Hover)
461 __baseCls::OnMouseLeave();
462
464 {
466
467 CRect rcBtn;
468 GetDropBtnRect(&rcBtn);
469 InvalidateRect(rcBtn);
470 }
471}
472
473BOOL SDateTimePicker::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
474{
475 TimeWheel(zDelta > 0);
476 return TRUE;
477}
478
480{
481 switch (m_eSelDateType)
482 {
483 case eDT_Year:
484 bUp ? ++m_sysTime.wYear : --m_sysTime.wYear;
485 break;
486 case eDT_Month:
487 {
488 CircluNum(bUp, m_sysTime.wMonth, 1, 12);
489 break;
490 }
491 case eDT_Day:
492 {
493 int nDays = SCalendarCore::GetDaysOfMonth(m_sysTime.wYear, m_sysTime.wMonth);
494 CircluNum(bUp, m_sysTime.wDay, 1, nDays);
495 break;
496 }
497 case eDT_Hour:
498 {
499 CircluNum(bUp, m_sysTime.wHour, 0, 23);
500 break;
501 }
502 case eDT_Minute:
503 {
504 CircluNum(bUp, m_sysTime.wMinute, 0, 59);
505 break;
506 }
507 case eDT_Second:
508 {
509 CircluNum(bUp, m_sysTime.wSecond, 0, 59);
510 break;
511 }
512 default:
513 break;
514 }
515
516 if (!SCalendarCore::DateCheck(m_sysTime.wYear, m_sysTime.wMonth, m_sysTime.wDay))
517 {
518 WORD nDays = SCalendarCore::GetDaysOfMonth(m_sysTime.wYear, m_sysTime.wMonth);
519 m_sysTime.wDay = nDays;
520 }
521
522 m_wCharNum = 0;
523 Invalidate();
524}
525
526void SDateTimePicker::CircluNum(bool bUp, WORD &wNum, WORD wMin /*=1*/, WORD wMax /*=0*/)
527{
528 if (bUp)
529 {
530 if (wNum >= wMax)
531 wNum = wMin;
532 else
533 ++wNum;
534 }
535 else
536 {
537 if (wNum <= wMin)
538 wNum = wMax;
539 else
540 --wNum;
541 }
542}
543
544void SDateTimePicker::OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
545{
546 if (37 == nChar) // <-
547 {
548 if (eDT_Year == m_eSelDateType)
549 return;
550
551 m_eSelDateType = static_cast<EnDateType>((int)m_eSelDateType - 1);
552 m_wCharNum = 0;
553 Invalidate();
554 }
555 else if (39 == nChar)
556 {
557 if (eDT_Second == m_eSelDateType)
558 return;
559
560 m_eSelDateType = static_cast<EnDateType>((int)m_eSelDateType + 1);
561 m_wCharNum = 0;
562 Invalidate();
563 }
564 else if (38 == nChar)
565 TimeWheel(true);
566 else if (40 == nChar)
567 TimeWheel(false);
568}
569
570void SDateTimePicker::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
571{
572 if (nChar > '9' || nChar < '0')
573 return;
574
575 if (eDT_NULL == m_eSelDateType)
576 return;
577
578 int nNum = nChar - 48;
579 if (m_wCharNum > 0)
580 {
581 m_wCharNum *= 10;
582 m_wCharNum += nNum;
583 }
584 else
585 {
586 m_wCharNum = nNum;
587 }
588
589 switch (m_eSelDateType)
590 {
591 case eDT_Year:
592 m_sysTime.wYear = m_wCharNum;
593 break;
594 case eDT_Month:
595 if (m_wCharNum <= 0)
596 {
597 return;
598 }
599 else if (m_wCharNum > 12)
600 {
601 m_wCharNum = nNum == 0 ? 1 : nNum;
602 }
605 m_sysTime.wMonth = m_wCharNum;
606 break;
607 case eDT_Day:
608 if (m_wCharNum <= 0)
609 {
610 return;
611 }
613 {
614 m_wCharNum = nNum == 0 ? 1 : nNum;
615 }
616 m_sysTime.wDay = m_wCharNum;
617 break;
618 case eDT_Hour:
619 if (m_wCharNum > 23 || m_wCharNum < 0)
620 m_wCharNum = nNum;
621 m_sysTime.wHour = m_wCharNum;
622 break;
623 case eDT_Minute:
624 if (m_wCharNum > 59 || m_wCharNum < 0)
625 m_wCharNum = nNum;
626 m_sysTime.wMinute = m_wCharNum;
627 break;
628 case eDT_Second:
629 if (m_wCharNum > 59 || m_wCharNum < 0)
630 m_wCharNum = nNum;
631 m_sysTime.wSecond = m_wCharNum;
632 break;
633 default:
634 break;
635 }
636
637 if (eDT_NULL != m_eSelDateType)
638 Invalidate();
639}
640
642{
643 CloseUp();
644 __baseCls::OnDestroy();
645}
646
648{
649 __baseCls::OnSetFocus(wndOld);
650}
651
653{
654 __baseCls::OnKillFocus(wndFocus);
655 CloseUp();
656 m_wCharNum = 0;
657 if (eDT_NULL != m_eSelDateType)
658 {
659 m_eSelDateType = eDT_NULL;
660 Invalidate();
661 }
662}
663
665{
666 if (NULL != m_pDropDownWnd)
667 {
668 m_pDropDownWnd->EndDropDown(IDCANCEL);
669 if (m_eSelDateType == eDT_NULL)
670 {
672 }
673 }
674}
675
677{
678 memset(&m_sysTime, 0, sizeof(m_sysTime));
679 Invalidate();
680}
681
682HRESULT SDateTimePicker::OnAttrCueText(const SStringW &strValue, BOOL bLoading)
683{
684 SStringW strTmp = GETSTRING(strValue);
685 m_strCue.SetText(S_CW2T(strTmp));
686 Clear(); // default to show cue.
687 return bLoading ? S_FALSE : S_OK;
688}
689
691{
692 if (NULL != m_pDropDownWnd)
693 return;
694 m_pDropDownWnd = new SDropDownWnd_ComboBox(this);
695 CRect rcPopup;
696 SLayoutSize nWid;
697 nWid.setSize((float)m_nDropWidth, SLayoutSize::dp);
698 bool bDown = CalcPopupRect(nWid.toPixelSize(GetScale()), rcPopup);
699 m_pDropDownWnd->Create(rcPopup, 0);
700
701 m_pDropDownWnd->SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
702
703 m_pDropDownWnd->SNativeWnd::SetCapture();
704}
705
706SNSEND
#define SHOW_MONTH
Definition SCalendar.h:125
@ WndState_Hover
Definition SWnd.h:76
@ WndState_Normal
Definition SWnd.h:75
@ WndState_PushDown
Definition SWnd.h:77
static BOOL DateCheck(WORD wYear, WORD wMonth, WORD wDay)
Validates the year, month, and day.
static WORD GetDaysOfMonth(WORD wYear, WORD wMonth)
Returns the number of days in a specified month.
Calendar Control Class.
Definition SCalendar.h:135
HRESULT OnAttrCueText(const SStringW &strValue, BOOL bLoading)
Handle custom attribute "cueText".
void CircluNum(bool bUp, WORD &wNum, WORD wMin, WORD wMax)
Handle circular number increment/decrement.
SAutoRefPtr< ISkinObj > m_pSkinBtn
EnDateType HitTest(CPoint pt)
Hit test to determine the date type at a given point.
void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle character input event.
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handle mouse wheel event.
void GetTime(WORD *wYear, WORD *wMonth, WORD *wDay, WORD *wHour, WORD *wMinute, WORD *wSecond) SCONST OVERRIDE
Get the time.
void SetTime(WORD wYear, WORD wMonth, WORD wDay, WORD wHour, WORD wMinute, WORD wSecond) OVERRIDE
Set the time.
bool CalcPopupRect(int nHeight, CRect &rcPopup)
Calculate the popup rectangle.
virtual BOOL CreateChildren(SXmlNode xmlNode)
Create child controls.
SDateTimePicker()
Constructor.
EnDateType
Enumeration for date types.
void Clear() OVERRIDE
Clear the selected date and time.
virtual SWindow * GetDropDownOwner()
Get the owner window for the dropdown.
virtual void OnDestroyDropDown(SDropDownWnd *pDropDown)
Handle destruction of the dropdown window.
void OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
Handle key down event.
SCalendar * m_pCalendar
void OnPaint(IRenderTarget *pRT)
Paint the control.
void OnMouseMove(UINT nFlags, CPoint pt)
Handle mouse move event.
virtual void OnCreateDropDown(SDropDownWnd *pDropDown)
Handle creation of the dropdown window.
void GetDropBtnRect(LPRECT pBtnRc, LPRECT pSkinRc=NULL)
Get the rectangle of the dropdown button.
void OnSetFocus(SWND wndOld)
Handle set focus event.
SDropDownWnd * m_pDropDownWnd
EnDateType m_eSelDateType
BOOL OnDateCmd(EventCmd *pEvt)
Handle date command event.
void OnKillFocus(SWND wndFocus)
Handle kill focus event.
void OnMouseLeave()
Handle mouse leave event.
void Draw(EnDateType eType, IRenderTarget *pRT, WORD wNum, CRect &rcText)
Draw the date/time component.
void OnLButtonDown(UINT nFlags, CPoint pt)
Handle left mouse button down event.
void DropDown() OVERRIDE
Drop down the list.
SStringT ToFormatText(EnDateType eType, WORD wNum)
Convert a number to formatted text based on the date type.
void OnDestroy()
Handle destroy event.
~SDateTimePicker()
Destructor.
SStringT GetWindowText(BOOL bRawText=FALSE)
Get the window text.
void TimeWheel(bool bUp)
Handle time wheel event.
BOOL OnDateChanged(EventCalendarExChanged *pEvt)
Handle date change event.
void CloseUp() OVERRIDE
Close the dropdown.
Dropdown Window Class.
Definition SDropDown.h:43
SWindow * GetRoot() const
Gets the root window.
Definition SHostWnd.h:685
布局大小类
Definition SLayoutSize.h:10
int toPixelSize(int scale) const
将大小转换为像素值
void setSize(float fSize, Unit unit)
设置指定大小
static LPCWSTR GetClassName()
Definition Sobject.hpp:41
Helper class for painting.
Definition SWnd.h:178
A class representing an ASCII string.
Definition sstringw.h:96
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
Definition Swnd.cpp:1540
SAutoRefPtr< ISkinObj > m_pNcSkin
Definition SWnd.h:2623
DWORD GetState() SCONST OVERRIDE
Retrieves the current state of the window.
Definition Swnd.cpp:437
SwndStyle m_style
Definition SWnd.h:2596
UINT GetTextAlign() const
Retrieves the text alignment of the window.
Definition Swnd.cpp:218
BOOL RemoveChild(SWindow *pChild)
Removes a child window from the window tree.
Definition Swnd.cpp:602
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
Definition Swnd.cpp:3266
CRect GetWindowRect() const
Retrieves the bounding rectangle of the window.
Definition Swnd.cpp:230
ISwndContainer * GetContainer() OVERRIDE
Retrieves the container associated with this window.
Definition Swnd.cpp:679
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
Definition Swnd.cpp:243
void InsertChild(SWindow *pNewChild, SWindow *pInsertAfter=NULL)
Inserts a child window into the window tree.
Definition Swnd.cpp:538
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
Definition Swnd.cpp:1755
void InvalidateRect(LPCRECT lprect) OVERRIDE
Invalidates a specific rectangle area of the window.
Definition Swnd.cpp:1444
void UpdateChildrenPosition() OVERRIDE
Updates the position of child windows.
Definition Swnd.cpp:2189
BOOL m_bFocusable
Definition SWnd.h:2609
virtual SWindow * CreateChildByName(LPCWSTR pszName)
Create child window by name.
Definition Swnd.cpp:935
SWindow()
Constructor.
Definition Swnd.cpp:104
virtual void GetTextRect(LPRECT pRect)
Calculate text display rectangle.
Definition Swnd.cpp:1961
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
Definition Swnd.cpp:1776
void Invalidate() OVERRIDE
Invalidates the entire window.
Definition Swnd.cpp:1437
SEventSet m_evtSet
Definition SWnd.h:2581
HWND GetHostHwnd() OVERRIDE
Retrieves the host window handle.
Definition Swnd.cpp:3616
BOOL ReleaseCapture() OVERRIDE
Releases the mouse capture from the window.
Definition Swnd.cpp:2491
Class representing an XML node.
Definition SXml.h:352
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
Interface for rendering target objects.
Definition SRender-i.h:1440
HRESULT DrawText(LPCTSTR pszText, int cchLen, LPRECT pRc, UINT uFormat) PURE
Draw text within a rectangle.
HRESULT FillSolidRect(LPCRECT pRect, COLORREF cr) PURE
Fill a rectangle with a solid color.
COLORREF SetTextColor(COLORREF color) PURE
Sets the current text color.
HRESULT MeasureText(LPCTSTR pszText, int cchLen, SIZE *psz) PURE
Measure the size of the text.
void FrameToHost(RECT *rc) SCONST PURE
Converts the rectangle coordinates of the current frame to the final host coordinates.