
Public Member Functions | |
| LRESULT | command (WPARAM wParam, LPARAM lParam) |
| DatePicker (HWND _hwnd, CREATESTRUCT &cs) | |
| LRESULT | destroy () |
| LRESULT | enable (bool) |
| LRESULT | getSystemTime (SYSTEMTIME *sysTime) |
| LRESULT | keyDown (DWORD vkcode, LPARAM lParam) |
| LRESULT | killFocus (HWND lostFocus) |
| LRESULT | leftButtonDown (WORD key, int x, int y) |
| LRESULT | notify (int id, const NMHDR &nmhdr) |
| bool | notifyDateChanged () |
| LRESULT | paint (HDC hdc) |
| void | redraw (HDC hdc) |
| LRESULT | resize (WORD flags, int width, int height) |
| bool | sendNotify (UINT code) |
| LRESULT | setFocus (HWND lostFocus) |
| LRESULT | setSystemTime (DWORD flag, SYSTEMTIME *sysTime) |
| ~DatePicker () | |
Private Member Functions | |
| void | decrementField () |
| int | getFieldWidth (DatePickerField field, HDC hdc) |
| void | incrementField () |
Private Attributes | |
| RECT | clientRect |
| astro::Date | date |
| RECT | fieldRects [NumFields] |
| bool | firstDigit |
| bool | haveFocus |
| HFONT | hFont |
| HWND | hwnd |
| HWND | parent |
| DatePickerField | selectedField |
| DWORD | style |
| char | textBuffer [64] |
|
||||||||||||
|
Definition at line 101 of file windatepicker.cpp. References clientRect, hFont, textBuffer, and YearField. 00101 : 00102 hwnd(_hwnd), 00103 parent(cs.hwndParent), 00104 date(1970, 10, 25), 00105 selectedField(YearField), 00106 haveFocus(false), 00107 firstDigit(true) 00108 { 00109 textBuffer[0] = '\0'; 00110 00111 hFont = reinterpret_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)); 00112 00113 clientRect.left = 0; 00114 clientRect.right = 0; 00115 clientRect.top = 0; 00116 clientRect.bottom = 0; 00117 }
|
|
|
Definition at line 120 of file windatepicker.cpp. 00121 {
00122 }
|
|
||||||||||||
|
Definition at line 438 of file windatepicker.cpp. Referenced by DatePickerProc(). 00439 {
00440 return 0;
00441 }
|
|
|
Definition at line 534 of file windatepicker.cpp. References clampToValidDate(), date, astro::Date::day, DayField, daysInMonth(), astro::Date::month, MonthField, selectedField, astro::Date::year, and YearField. Referenced by keyDown(). 00535 {
00536 switch (selectedField)
00537 {
00538 case YearField:
00539 date.year--;
00540 clampToValidDate(date);
00541 break;
00542 case MonthField:
00543 date.month--;
00544 if (date.month < 1)
00545 date.month = 12;
00546 clampToValidDate(date);
00547 break;
00548 case DayField:
00549 date.day--;
00550 if (date.day < 1)
00551 date.day = daysInMonth(date.month, date.year);
00552 // Skip 10 days deleted in Gregorian calendar reform
00553 if (date.year == 1582 && date.month == 10 && date.day == 14)
00554 date.day = 4;
00555 break;
00556 }
00557 }
|
|
|
Definition at line 561 of file windatepicker.cpp. Referenced by DatePickerProc(). 00562 {
00563 return 0;
00564 }
|
|
|
Definition at line 419 of file windatepicker.cpp. References style. Referenced by DatePickerProc(). 00420 {
00421 if (!b)
00422 style &= ~WS_DISABLED;
00423 else
00424 style |= WS_DISABLED;
00425
00426 return 0;
00427 }
|
|
||||||||||||
|
Definition at line 480 of file windatepicker.cpp. References DayField, MonthField, and YearField. Referenced by redraw(). 00481 {
00482 char* maxWidthText = "\0";
00483
00484 switch (field)
00485 {
00486 case YearField:
00487 maxWidthText = "-2222 ";
00488 break;
00489
00490 case MonthField:
00491 maxWidthText = " Oct ";
00492 break;
00493
00494 case DayField:
00495 maxWidthText = "22 ";
00496 break;
00497 }
00498
00499 SIZE size;
00500 GetTextExtentPoint32(hdc, maxWidthText, strlen(maxWidthText), &size);
00501
00502 return size.cx;
00503 }
|
|
|
Definition at line 593 of file windatepicker.cpp. References date, astro::Date::day, astro::Date::month, and astro::Date::year. Referenced by DatePickerProc(). 00594 {
00595 if (sysTime != NULL)
00596 {
00597 sysTime->wYear = date.year;
00598 sysTime->wMonth = date.month;
00599 sysTime->wDay = date.day;
00600 }
00601
00602 return GDT_VALID;
00603 }
|
|
|
Definition at line 507 of file windatepicker.cpp. References clampToValidDate(), date, astro::Date::day, DayField, daysInMonth(), astro::Date::month, MonthField, selectedField, astro::Date::year, and YearField. Referenced by keyDown(). 00508 {
00509 switch (selectedField)
00510 {
00511 case YearField:
00512 date.year++;
00513 clampToValidDate(date);
00514 break;
00515 case MonthField:
00516 date.month++;
00517 if (date.month > 12)
00518 date.month = 1;
00519 clampToValidDate(date);
00520 break;
00521 case DayField:
00522 date.day++;
00523 if (date.day > (int) daysInMonth(date.month, date.year))
00524 date.day = 1;
00525 // Skip 10 days deleted in Gregorian calendar reform
00526 if (date.year == 1582 && date.month == 10 && date.day == 5)
00527 date.day = 15;
00528 break;
00529 }
00530 }
|
|
||||||||||||
|
Definition at line 246 of file windatepicker.cpp. References clampToValidDate(), date, astro::Date::day, DayField, daysInMonth(), decrementField(), firstDigit, haveFocus, hwnd, incrementField(), astro::Date::month, MonthField, notifyDateChanged(), NumFields, selectedField, astro::Date::year, and YearField. Referenced by DatePickerProc(). 00247 {
00248 if (!haveFocus)
00249 return 0;
00250
00251 if (vkcode >= '0' && vkcode <= '9')
00252 {
00253 unsigned int digit = vkcode - '0';
00254
00255 if (firstDigit)
00256 {
00257 switch (selectedField)
00258 {
00259 case DayField:
00260 if (digit != 0)
00261 date.day = digit;
00262 break;
00263 case MonthField:
00264 if (digit != 0)
00265 date.month = digit;
00266 break;
00267 case YearField:
00268 if (digit != 0)
00269 date.year = digit;
00270 break;
00271 }
00272 firstDigit = false;
00273 }
00274 else
00275 {
00276 switch (selectedField)
00277 {
00278 case DayField:
00279 {
00280 unsigned int day = date.day * 10 + digit;
00281 if (day >= 10)
00282 firstDigit = true;
00283 if (day > daysInMonth(date.month, date.year))
00284 day = 1;
00285 date.day = day;
00286 }
00287 break;
00288
00289 case MonthField:
00290 {
00291 unsigned int month = date.month * 10 + digit;
00292 if (month > 1)
00293 firstDigit = true;
00294 if (month > 12)
00295 month = 1;
00296 date.month = month;
00297 }
00298 break;
00299
00300 case YearField:
00301 {
00302 unsigned int year = date.year * 10 + digit;
00303 if (year >= 1000)
00304 firstDigit = true;
00305 if (year <= 9999)
00306 date.year = year;
00307 }
00308 break;
00309 }
00310 }
00311 clampToValidDate(date);
00312 notifyDateChanged();
00313 }
00314 else if (vkcode == VK_SUBTRACT || vkcode == VK_OEM_MINUS)
00315 {
00316 if (selectedField == YearField)
00317 {
00318 date.year = -date.year;
00319 clampToValidDate(date);
00320 notifyDateChanged();
00321 }
00322 }
00323 else
00324 {
00325 firstDigit = true;
00326
00327 switch (vkcode)
00328 {
00329 case VK_LEFT:
00330 if ((int) selectedField == 0)
00331 selectedField = DatePickerField((int) NumFields - 1);
00332 else
00333 selectedField = DatePickerField((int) selectedField - 1);
00334 break;
00335
00336 case VK_RIGHT:
00337 if ((int) selectedField == (int) NumFields - 1)
00338 selectedField = DatePickerField(0);
00339 else
00340 selectedField = DatePickerField((int) selectedField + 1);
00341 break;
00342
00343 case VK_UP:
00344 incrementField();
00345 notifyDateChanged();
00346 break;
00347
00348 case VK_DOWN:
00349 decrementField();
00350 notifyDateChanged();
00351 break;
00352
00353 default:
00354 break;
00355 }
00356 }
00357
00358 InvalidateRect(hwnd, NULL, TRUE);
00359
00360 return 0;
00361 }
|
|
|
Definition at line 404 of file windatepicker.cpp. References haveFocus, hwnd, and sendNotify(). Referenced by DatePickerProc(). 00405 {
00406 if (haveFocus)
00407 {
00408 sendNotify(NM_KILLFOCUS);
00409 haveFocus = false;
00410 }
00411
00412 InvalidateRect(hwnd, NULL, TRUE);
00413
00414 return 0;
00415 }
|
|
||||||||||||||||
|
Definition at line 365 of file windatepicker.cpp. References DayField, fieldRects, hwnd, MonthField, selectedField, and YearField. Referenced by DatePickerProc(). 00366 {
00367 POINT pt;
00368 pt.x = x;
00369 pt.y = y;
00370
00371 if (PtInRect(&fieldRects[DayField], pt))
00372 selectedField = DayField;
00373 else if (PtInRect(&fieldRects[MonthField], pt))
00374 selectedField = MonthField;
00375 else if (PtInRect(&fieldRects[YearField], pt))
00376 selectedField = YearField;
00377
00378 InvalidateRect(hwnd, NULL, TRUE);
00379
00380 ::SetFocus(hwnd); // note that this is the Win32 API function, not the class method
00381
00382 return 0;
00383 }
|
|
||||||||||||
|
Definition at line 431 of file windatepicker.cpp. Referenced by DatePickerProc(). 00432 {
00433 return 0;
00434 }
|
|
|
Definition at line 461 of file windatepicker.cpp. References date, astro::Date::day, hwnd, astro::Date::month, parent, and astro::Date::year. Referenced by keyDown(). 00462 {
00463 NMDATETIMECHANGE change;
00464
00465 ZeroMemory(&change, sizeof(change));
00466 change.nmhdr.hwndFrom = hwnd;
00467 change.nmhdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID);
00468 change.nmhdr.code = DTN_DATETIMECHANGE;
00469 change.st.wYear = date.year;
00470 change.st.wMonth = date.month;
00471 change.st.wDay = date.day;
00472
00473 return SendMessage(parent, WM_NOTIFY,
00474 change.nmhdr.idFrom,
00475 reinterpret_cast<LPARAM>(&change)) ? true : false;
00476 }
|
|
|
Definition at line 126 of file windatepicker.cpp. References hwnd, and redraw(). Referenced by DatePickerProc(). 00127 {
00128 PAINTSTRUCT ps;
00129
00130 if (!hdc)
00131 {
00132 hdc = BeginPaint(hwnd, &ps);
00133 redraw(hdc);
00134 EndPaint(hwnd, &ps);
00135 }
00136 else
00137 {
00138 redraw(hdc);
00139 }
00140
00141 return 0;
00142 }
|
|
|
Definition at line 146 of file windatepicker.cpp. References clientRect, date, astro::Date::day, DayField, fieldRects, getFieldWidth(), haveFocus, hFont, hwnd, astro::Date::month, MonthField, Months, NumFields, selectedField, astro::Date::year, and YearField. Referenced by paint(). 00147 {
00148 RECT rect;
00149 GetClientRect(hwnd, &rect);
00150
00151 SelectObject(hdc, hFont);
00152 SetTextColor(hdc, RGB(0, 0, 0));
00153 SetBkMode(hdc, TRANSPARENT);
00154
00155 char dayBuf[32];
00156 char monthBuf[32];
00157 char yearBuf[32];
00158
00159 sprintf(dayBuf, "%02d", date.day);
00160 sprintf(monthBuf, "%s", Months[date.month - 1]);
00161 sprintf(yearBuf, "%5d", date.year);
00162
00163 char* fieldText[NumFields];
00164 fieldText[DayField] = dayBuf;
00165 fieldText[MonthField] = monthBuf;
00166 fieldText[YearField] = yearBuf;
00167
00168 int right = 2;
00169 for (unsigned int i = 0; i < NumFields; i++)
00170 {
00171 SIZE size;
00172 GetTextExtentPoint(hdc, fieldText[i], strlen(fieldText[i]), &size);
00173 int fieldWidth = getFieldWidth(DatePickerField(i), hdc);
00174 fieldRects[i].left = right;
00175 fieldRects[i].right = right + fieldWidth;
00176 fieldRects[i].top = rect.top;
00177 fieldRects[i].bottom = rect.bottom;
00178
00179 right = fieldRects[i].right;
00180
00181 if (i == selectedField && haveFocus)
00182 {
00183 RECT r = fieldRects[i];
00184 r.top = (clientRect.bottom - size.cy) / 2;
00185 r.bottom = r.top + size.cy + 1;
00186
00187 HBRUSH hbrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
00188 FillRect(hdc, &r, hbrush);
00189 DeleteObject(hbrush);
00190
00191 SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
00192 }
00193 else
00194 {
00195 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
00196 }
00197
00198 DrawText(hdc, fieldText[i], strlen(fieldText[i]), &fieldRects[i], DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
00199 }
00200 }
|
|
||||||||||||||||
|
Definition at line 568 of file windatepicker.cpp. References clientRect, and hwnd. Referenced by DatePickerProc(). 00569 {
00570 clientRect.bottom = height;
00571 clientRect.right = width;
00572
00573 InvalidateRect(hwnd, NULL, FALSE);
00574
00575 return 0;
00576 }
|
|
|
Definition at line 445 of file windatepicker.cpp. Referenced by killFocus(), and setFocus(). 00446 {
00447 NMHDR nmhdr;
00448
00449 ZeroMemory(&nmhdr, sizeof(nmhdr));
00450 nmhdr.hwndFrom = hwnd;
00451 nmhdr.idFrom = GetWindowLongPtr(hwnd, GWLP_ID);
00452 nmhdr.code = code;
00453
00454 return SendMessage(parent, WM_NOTIFY,
00455 nmhdr.idFrom,
00456 reinterpret_cast<LPARAM>(&nmhdr)) ? true : false;
00457 }
|
|
|
Definition at line 387 of file windatepicker.cpp. References firstDigit, haveFocus, hwnd, and sendNotify(). Referenced by DatePickerProc(). 00388 {
00389 if (!haveFocus)
00390 {
00391 sendNotify(NM_SETFOCUS);
00392 haveFocus = true;
00393 }
00394
00395 firstDigit = true;
00396
00397 InvalidateRect(hwnd, NULL, TRUE);
00398
00399 return 0;
00400 }
|
|
||||||||||||
|
Definition at line 580 of file windatepicker.cpp. References date, astro::Date::day, hwnd, astro::Date::month, and astro::Date::year. Referenced by DatePickerProc(). 00581 {
00582 date.year = (int16) sysTime->wYear;
00583 date.month = sysTime->wMonth;
00584 date.day = sysTime->wDay;
00585
00586 InvalidateRect(hwnd, NULL, TRUE);
00587
00588 return 0;
00589 }
|
|
|
Definition at line 97 of file windatepicker.cpp. Referenced by DatePicker(), redraw(), and resize(). |
|
|
Definition at line 87 of file windatepicker.cpp. Referenced by decrementField(), getSystemTime(), incrementField(), keyDown(), notifyDateChanged(), redraw(), and setSystemTime(). |
|
|
Definition at line 96 of file windatepicker.cpp. Referenced by leftButtonDown(), and redraw(). |
|
|
Definition at line 94 of file windatepicker.cpp. Referenced by keyDown(), and setFocus(). |
|
|
Definition at line 93 of file windatepicker.cpp. Referenced by keyDown(), killFocus(), redraw(), and setFocus(). |
|
|
Definition at line 90 of file windatepicker.cpp. Referenced by DatePicker(), and redraw(). |
|
|
Definition at line 85 of file windatepicker.cpp. Referenced by keyDown(), killFocus(), leftButtonDown(), notifyDateChanged(), paint(), redraw(), resize(), sendNotify(), setFocus(), and setSystemTime(). |
|
|
Definition at line 86 of file windatepicker.cpp. Referenced by notifyDateChanged(), and sendNotify(). |
|
|
Definition at line 88 of file windatepicker.cpp. Referenced by decrementField(), incrementField(), keyDown(), leftButtonDown(), and redraw(). |
|
|
Definition at line 91 of file windatepicker.cpp. Referenced by enable(), and RegisterDatePicker(). |
|
|
Definition at line 89 of file windatepicker.cpp. Referenced by DatePicker(). |
1.4.1