#include <windows.h>#include <commctrl.h>#include "celutil/basictypes.h"#include "celengine/astro.h"Include dependency graph for windatepicker.cpp:

Go to the source code of this file.
Enumerations | |
| enum | DatePickerField { InvalidField = -1, DayField = 0, MonthField = 1, YearField = 2, NumFields = 3 } |
Functions | |
| static void | clampToValidDate (astro::Date &date) |
| static LRESULT | DatePickerCreate (HWND hwnd, CREATESTRUCT &cs) |
| static LRESULT | DatePickerNCCreate (HWND hwnd, CREATESTRUCT &cs) |
| static LRESULT WINAPI | DatePickerProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| static unsigned int | daysInMonth (unsigned int month, unsigned int year) |
| static bool | isLeapYear (unsigned int year) |
| void | RegisterDatePicker () |
Variables | |
| static char * | Months [12] |
|
|
Definition at line 45 of file windatepicker.cpp. 00046 {
00047 InvalidField = -1,
00048 DayField = 0,
00049 MonthField = 1,
00050 YearField = 2,
00051 NumFields = 3,
00052 };
|
|
|
Definition at line 228 of file windatepicker.cpp. References daysInMonth(). Referenced by DatePicker::decrementField(), DatePicker::incrementField(), and DatePicker::keyDown(). 00229 {
00230 int days = (int) daysInMonth(date.month, date.year);
00231 if (date.day > days)
00232 date.day = days;
00233
00234 // 10 days skipped in Gregorian calendar reform
00235 if (date.year == 1582 && date.month == 10 && date.day > 4 && date.day < 15)
00236 {
00237 if (date.day < 10)
00238 date.day = 4;
00239 else
00240 date.day = 15;
00241 }
00242 }
|
|
||||||||||||
|
Definition at line 619 of file windatepicker.cpp. Referenced by DatePickerProc(). 00620 {
00621 DatePicker* dp = new DatePicker(hwnd, cs);
00622 if (dp == NULL)
00623 return -1;
00624
00625 SetWindowLongPtr(hwnd, 0, reinterpret_cast<DWORD_PTR>(dp));
00626
00627 return 0;
00628 }
|
|
||||||||||||
|
Definition at line 607 of file windatepicker.cpp. Referenced by DatePickerProc(). 00608 {
00609 DWORD exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
00610
00611 exStyle |= WS_EX_CLIENTEDGE;
00612 SetWindowLong(hwnd, GWL_EXSTYLE, exStyle);
00613
00614 return DefWindowProc(hwnd, WM_NCCREATE, 0, reinterpret_cast<LPARAM>(&cs));
00615 }
|
|
||||||||||||||||||||
|
Definition at line 632 of file windatepicker.cpp. References DatePicker::command(), DatePickerCreate(), DatePickerNCCreate(), DatePicker::destroy(), DatePicker::enable(), DatePicker::getSystemTime(), DatePicker::keyDown(), DatePicker::killFocus(), DatePicker::leftButtonDown(), DatePicker::notify(), DatePicker::paint(), DatePicker::resize(), DatePicker::setFocus(), and DatePicker::setSystemTime(). Referenced by RegisterDatePicker(). 00633 {
00634 DatePicker* dp = reinterpret_cast<DatePicker*>(GetWindowLongPtr(hwnd, 0));
00635
00636 if (!dp && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
00637 return DefWindowProc(hwnd, uMsg, wParam, lParam);
00638
00639
00640 switch (uMsg)
00641 {
00642 case DTM_SETSYSTEMTIME:
00643 return dp->setSystemTime(wParam, reinterpret_cast<SYSTEMTIME*>(lParam));
00644 break;
00645
00646 case DTM_GETSYSTEMTIME:
00647 return dp->getSystemTime(reinterpret_cast<SYSTEMTIME*>(lParam));
00648 break;
00649
00650 case WM_NOTIFY:
00651 return dp->notify((int) wParam, *reinterpret_cast<NMHDR*>(lParam));
00652 break;
00653
00654 case WM_ENABLE:
00655 return dp->enable(wParam != 0 ? true : false);
00656 break;
00657
00658 //case WM_ERASEBKGND:
00659 //break;
00660
00661 case WM_PAINT:
00662 return dp->paint(reinterpret_cast<HDC>(wParam));
00663 break;
00664
00665 case WM_GETDLGCODE:
00666 return DLGC_WANTARROWS | DLGC_WANTCHARS;
00667
00668 case WM_KEYDOWN:
00669 return dp->keyDown(wParam, lParam);
00670 break;
00671
00672 case WM_KILLFOCUS:
00673 return dp->killFocus(reinterpret_cast<HWND>(wParam));
00674 break;
00675
00676 case WM_SETFOCUS:
00677 return dp->setFocus(reinterpret_cast<HWND>(wParam));
00678 break;
00679
00680 case WM_NCCREATE:
00681 return DatePickerNCCreate(hwnd, *reinterpret_cast<CREATESTRUCT*>(lParam));
00682 break;
00683
00684 case WM_SIZE:
00685 return dp->resize(wParam, LOWORD(lParam), HIWORD(lParam));
00686 break;
00687
00688 case WM_LBUTTONDOWN:
00689 return dp->leftButtonDown((WORD) wParam, LOWORD(lParam), HIWORD(lParam));
00690 break;
00691
00692 case WM_LBUTTONUP:
00693 return 0;
00694 break;
00695
00696 case WM_CREATE:
00697 return DatePickerCreate(hwnd, *reinterpret_cast<CREATESTRUCT*>(lParam));
00698 break;
00699
00700 case WM_DESTROY:
00701 return dp->destroy();
00702 break;
00703
00704 case WM_COMMAND:
00705 return dp->command(wParam, lParam);
00706 break;
00707
00708 default:
00709 return DefWindowProc(hwnd, uMsg, wParam, lParam);
00710 }
00711 }
|
|
||||||||||||
|
Definition at line 216 of file windatepicker.cpp. References isLeapYear(). Referenced by clampToValidDate(), DatePicker::decrementField(), DatePicker::incrementField(), and DatePicker::keyDown(). 00217 {
00218 static unsigned int daysPerMonth[12] =
00219 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
00220
00221 if (month == 2)
00222 return isLeapYear(year) ? 29 : 28;
00223 else
00224 return daysPerMonth[month - 1];
00225 }
|
|
|
Definition at line 203 of file windatepicker.cpp. Referenced by daysInMonth(). 00204 {
00205 if (year > 1582)
00206 {
00207 return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
00208 }
00209 else
00210 {
00211 return year % 4 == 0;
00212 }
00213 }
|
|
|
Definition at line 715 of file windatepicker.cpp. References DatePickerProc(), and DatePicker::style. Referenced by WinMain(). 00716 {
00717 WNDCLASS wc;
00718
00719 ZeroMemory(&wc, sizeof(wc));
00720 wc.style = CS_GLOBALCLASS;
00721 wc.lpfnWndProc = DatePickerProc;
00722 wc.cbClsExtra = 0;
00723 wc.cbWndExtra = sizeof(DatePicker*);
00724 wc.hCursor = LoadCursor(0, IDC_ARROW);
00725 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
00726 wc.lpszClassName = "CelestiaDatePicker";
00727
00728 RegisterClass(&wc);
00729 }
|
|
|
Initial value:
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}
Definition at line 39 of file windatepicker.cpp. Referenced by DatePicker::redraw(). |
1.4.1