Changeset 6644 for trunk/src/comctl32/monthcal.c
- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- File:
-
- 1 edited
-
trunk/src/comctl32/monthcal.c (modified) (94 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/monthcal.c
r5416 r6644 1 /* $Id: monthcal.c,v 1.12 2001-09-05 12:05:00 bird Exp $ */ 1 2 /* Month calendar control 2 3 * 3 4 * 4 5 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de) 5 6 * Copyright 1999 Alex Priem (alexp@sci.kun.nl) 6 7 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and 7 * James Abbatiello <abbeyj@wpi.edu>8 * James Abbatiello <abbeyj@wpi.edu> 8 9 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de> 9 10 * … … 13 14 * 14 15 * FIXME: handle resources better (doesn't work now); also take care 15 of internationalization.16 * of internationalization. 16 17 * FIXME: keyboard handling. 17 18 */ … … 43 44 DEFAULT_DEBUG_CHANNEL(monthcal); 44 45 45 #define MC_SEL_LBUTUP 1/* Left button released */46 #define MC_SEL_LBUTDOWN 2/* Left button pressed in calendar */46 #define MC_SEL_LBUTUP 1 /* Left button released */ 47 #define MC_SEL_LBUTDOWN 2 /* Left button pressed in calendar */ 47 48 #define MC_PREVPRESSED 4 /* Prev month button pressed */ 48 49 #define MC_NEXTPRESSED 8 /* Next month button pressed */ 49 #define MC_NEXTMONTHDELAY 350 /* when continuously pressing `next */50 /* month', wait 500 ms before going */51 /* to the next month */52 #define MC_NEXTMONTHTIMER 1 /* Timer ID's */53 #define MC_PREVMONTHTIMER 2 50 #define MC_NEXTMONTHDELAY 350 /* when continuously pressing `next */ 51 /* month', wait 500 ms before going */ 52 /* to the next month */ 53 #define MC_NEXTMONTHTIMER 1 /* Timer ID's */ 54 #define MC_PREVMONTHTIMER 2 54 55 55 56 typedef struct … … 58 59 COMCTL32_HEADER header; 59 60 #endif 60 COLORREF bk;61 COLORREF txt;62 COLORREF titlebk;63 COLORREF titletxt;64 COLORREF monthbk;65 COLORREF trailingtxt;66 HFONT hFont;67 HFONT hBoldFont;68 int textHeight;69 int textWidth;70 int height_increment;71 int width_increment;72 int left_offset;73 int top_offset;74 int firstDayplace; /* place of the first day of the current month */75 int delta;/* scroll rate; # of months that the */61 COLORREF bk; 62 COLORREF txt; 63 COLORREF titlebk; 64 COLORREF titletxt; 65 COLORREF monthbk; 66 COLORREF trailingtxt; 67 HFONT hFont; 68 HFONT hBoldFont; 69 int textHeight; 70 int textWidth; 71 int height_increment; 72 int width_increment; 73 int left_offset; 74 int top_offset; 75 int firstDayplace; /* place of the first day of the current month */ 76 int delta; /* scroll rate; # of months that the */ 76 77 /* control moves when user clicks a scroll button */ 77 int visible;/* # of months visible */78 int firstDay;/* Start month calendar with firstDay's day */79 int monthRange;78 int visible; /* # of months visible */ 79 int firstDay; /* Start month calendar with firstDay's day */ 80 int monthRange; 80 81 MONTHDAYSTATE *monthdayState; 81 SYSTEMTIME todaysDate;82 DWORD currentMonth;83 DWORD currentYear;84 int status;/* See MC_SEL flags */85 int curSelDay;/* current selected day */86 int firstSelDay;/* first selected day */87 int maxSelCount;88 SYSTEMTIME minSel;89 SYSTEMTIME maxSel;90 DWORD rangeValid;91 SYSTEMTIME minDate;92 SYSTEMTIME maxDate;93 94 RECT rcClient; /* rect for whole client area */95 RECT rcDraw; /* rect for drawable portion of client area */96 RECT title; /* rect for the header above the calendar */97 RECT titlebtnnext; /* the `next month' button in the header */98 RECT titlebtnprev; /* the `prev month' button in the header */ 99 RECT titlemonth; /* the `month name' txt in the header */100 RECT titleyear; /* the `year number' txt in the header */101 RECT wdays; /* week days at top */102 RECT days; /* calendar area */103 RECT weeknums; /* week numbers at left side */104 RECT todayrect; /* `today: xx/xx/xx' text rect */82 SYSTEMTIME todaysDate; 83 DWORD currentMonth; 84 DWORD currentYear; 85 int status; /* See MC_SEL flags */ 86 int curSelDay; /* current selected day */ 87 int firstSelDay; /* first selected day */ 88 int maxSelCount; 89 SYSTEMTIME minSel; 90 SYSTEMTIME maxSel; 91 DWORD rangeValid; 92 SYSTEMTIME minDate; 93 SYSTEMTIME maxDate; 94 95 RECT rcClient; /* rect for whole client area */ 96 RECT rcDraw; /* rect for drawable portion of client area */ 97 RECT title; /* rect for the header above the calendar */ 98 RECT titlebtnnext; /* the `next month' button in the header */ 99 RECT titlebtnprev; /* the `prev month' button in the header */ 100 RECT titlemonth; /* the `month name' txt in the header */ 101 RECT titleyear; /* the `year number' txt in the header */ 102 RECT wdays; /* week days at top */ 103 RECT days; /* calendar area */ 104 RECT weeknums; /* week numbers at left side */ 105 RECT todayrect; /* `today: xx/xx/xx' text rect */ 105 106 HWND hWndYearEdit; /* Window Handle of edit box to handle years */ 106 107 HWND hWndYearUpDown;/* Window Handle of updown box to handle years */ … … 141 142 142 143 /* make sure that time is valid */ 143 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 144 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 144 145 { 145 146 if(time.wMonth > 12) return FALSE; 146 147 if(time.wDayOfWeek > 6) return FALSE; 147 148 if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear)) 148 return FALSE;149 return FALSE; 149 150 if(time.wHour > 23) return FALSE; 150 151 if(time.wMinute > 59) return FALSE; … … 156 157 157 158 158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 159 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 159 160 { 160 161 to->wYear = from->wYear; … … 169 170 170 171 171 /* Note:Depending on DST, this may be offset by a day. 172 /* Note:Depending on DST, this may be offset by a day. 172 173 Need to find out if we're on a DST place & adjust the clock accordingly. 173 174 Above function assumes we have a valid data. … … 182 183 year-=(month < 3); 183 184 184 return((year + year/4 - year/100 + year/400 + 185 return((year + year/4 - year/100 + year/400 + 185 186 DayOfWeekTable[month-1] + day - 1 ) % 7); 186 187 } … … 189 190 and day in the calendar. day== 0 mean the last day of tha last month 190 191 */ 191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 192 int *daypos,int *weekpos) 192 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 193 int *daypos,int *weekpos) 193 194 { 194 195 int retval, firstDay; … … 202 203 *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment; 203 204 *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment; 204 205 205 206 firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7; 206 207 retval = *daypos + (7 * *weekpos) - firstDay; … … 211 212 /* sets x and y to be the position of the day */ 212 213 /* x == day, y == week where(0,0) == firstDay, 1st week */ 213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 214 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 214 215 int *x, int *y) 215 216 { … … 227 228 if(prevMonth==0) 228 229 prevMonth = 12; 229 230 230 231 *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7; 231 232 *y = 0; … … 240 241 241 242 /* x: column(day), y: row(week) */ 242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 243 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 243 244 { 244 245 r->left = infoPtr->days.left + x * infoPtr->width_increment; … … 252 253 /* day is the day value of the month(1 == 1st), month is the month */ 253 254 /* value(january == 1, december == 12) */ 254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 255 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 255 256 int day, int month, RECT *r) 256 257 { … … 278 279 x = day_rect.left; 279 280 y = day_rect.top; 280 281 281 282 points[0].x = x; 282 283 points[0].y = y - 1; … … 287 288 points[3].x = x + infoPtr->width_increment; 288 289 points[3].y = y + 0.5 * infoPtr->height_increment; 289 290 290 291 points[4].x = x + infoPtr->width_increment; 291 292 points[4].y = y + 0.9 * infoPtr->height_increment; … … 294 295 points[6].x = x + 0.5 * infoPtr->width_increment; 295 296 points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just 296 a hair to fit inside the day rectangle */297 297 a hair to fit inside the day rectangle */ 298 298 299 points[7].x = x + 0.2 * infoPtr->width_increment; 299 300 points[7].y = y + 0.8 * infoPtr->height_increment; … … 309 310 points[12].x = x + 0.4 * infoPtr->width_increment; 310 311 points[12].y = y + 0.2 * infoPtr->height_increment; 311 312 312 313 PolyBezier(hdc, points, 13); 313 314 DeleteObject(hRedPen); … … 329 330 sprintf(buf, "%d", day); 330 331 331 /* No need to check styles: when selection is not valid, it is set to zero. 332 /* No need to check styles: when selection is not valid, it is set to zero. 332 333 * 1<day<31, so evertyhing's OK. 333 334 */ … … 349 350 350 351 /* FIXME: this may need to be changed now b/c of the other 351 drawing changes 11/3/99 CMM */352 drawing changes 11/3/99 CMM */ 352 353 r2.left = r.left - 0.25 * infoPtr->textWidth; 353 354 r2.top = r.top; … … 390 391 391 392 /* CHECKME: For `todays date', do we need to check the locale?*/ 392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 393 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 393 394 { 394 395 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); … … 425 426 hbr = CreateSolidBrush (infoPtr->bk); 426 427 FillRect(hdc, rcClient, hbr); 427 DeleteObject(hbr); 428 DeleteObject(hbr); 428 429 429 430 /* draw header */ … … 434 435 DeleteObject(hbr); 435 436 } 436 437 437 438 /* if the previous button is pressed draw it depressed */ 438 439 if(IntersectRect(&rcTemp, &(ps->rcPaint), prev)) 439 { 440 { 440 441 if((infoPtr->status & MC_PREVPRESSED)) 441 442 DrawFrameControl(hdc, prev, DFC_SCROLL, 442 DFCS_SCROLLLEFT | DFCS_PUSHED |443 DFCS_SCROLLLEFT | DFCS_PUSHED | 443 444 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0)); 444 445 else /* if the previous button is pressed draw it depressed */ 445 446 DrawFrameControl(hdc, prev, DFC_SCROLL, 446 DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));447 } 448 449 /* if next button is depressed draw it depressed */ 447 DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0)); 448 } 449 450 /* if next button is depressed draw it depressed */ 450 451 if(IntersectRect(&rcTemp, &(ps->rcPaint), next)) 451 452 { 452 453 if((infoPtr->status & MC_NEXTPRESSED)) 453 454 DrawFrameControl(hdc, next, DFC_SCROLL, 454 DFCS_SCROLLRIGHT | DFCS_PUSHED |455 DFCS_SCROLLRIGHT | DFCS_PUSHED | 455 456 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0)); 456 457 else /* if the next button is pressed draw it depressed */ … … 466 467 titlemonth->left = title->left; 467 468 titlemonth->right = title->right; 468 469 469 470 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1, 470 buf1,sizeof(buf1));471 buf1,sizeof(buf1)); 471 472 sprintf(buf, "%s %ld", buf1, infoPtr->currentYear); 472 473 473 474 if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth)) 474 475 { 475 DrawTextA(hdc, buf, strlen(buf), titlemonth, 476 DrawTextA(hdc, buf, strlen(buf), titlemonth, 476 477 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 477 478 } … … 481 482 /* titlemonth left/right contained rect for whole titletxt('June 1999') 482 483 * MCM_HitTestInfo wants month & year rects, so prepare these now. 483 *(no, we can't draw them separately; the whole text is centered) 484 *(no, we can't draw them separately; the whole text is centered) 484 485 */ 485 486 GetTextExtentPoint32A(hdc, buf, strlen(buf), &size); … … 489 490 titlemonth->right = titlemonth->left + size.cx; 490 491 titleyear->left = titlemonth->right; 491 492 492 493 /* draw month area */ 493 494 rcTemp.top=infoPtr->wdays.top; … … 501 502 DeleteObject(hbr); 502 503 } 503 504 504 505 /* draw line under day abbreviatons */ 505 506 506 507 MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL); 507 508 508 509 LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1); 509 510 510 511 prevMonth = infoPtr->currentMonth - 1; 511 512 if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */ … … 529 530 for(j=0; j<7; j++) { 530 531 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7, 531 buf,sizeof(buf));532 buf,sizeof(buf)); 532 533 DrawTextA(hdc, buf, strlen(buf), days, 533 534 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); … … 537 538 538 539 /* draw day numbers; first, the previous month */ 539 540 540 541 firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear); 541 542 day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) + 542 543 day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) + 543 544 (infoPtr->firstDay + 7 - firstDay)%7 + 1; 544 545 if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)) … … 553 554 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) 554 555 { 555 MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 556 MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 556 557 infoPtr->monthdayState[m] & mask); 557 558 } … … 577 578 { 578 579 579 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 580 infoPtr->monthdayState[m] & mask);580 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 581 infoPtr->monthdayState[m] & mask); 581 582 582 583 if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 583 584 (day==infoPtr->todaysDate.wDay) && 584 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {585 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) { 585 586 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 586 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);587 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); 587 588 } 588 589 } … … 595 596 j = 1; /* move to the 2nd week of the current month */ 596 597 i = 0; /* move back to sunday */ 597 while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) { 598 while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) { 598 599 MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); 599 600 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) … … 604 605 if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 605 606 (day==infoPtr->todaysDate.wDay) && 606 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 607 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 608 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);607 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 608 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 609 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); 609 610 } 610 611 mask<<=1; … … 627 628 MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); 628 629 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) 629 { 630 { 630 631 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j, 631 infoPtr->monthdayState[m] & mask);632 infoPtr->monthdayState[m] & mask); 632 633 } 633 634 634 635 mask<<=1; 635 636 day++; 636 i++; 637 i++; 637 638 if(i==7) { /* past saturday, go to next week's sunday */ 638 639 i = 0; … … 650 651 if(!(dwStyle & MCS_NOTODAYCIRCLE)) { 651 652 /*day is the number of days from nextmonth we put on the calendar */ 652 MONTHCAL_CircleDay(hdc, infoPtr, 653 day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear), 654 infoPtr->currentMonth);653 MONTHCAL_CircleDay(hdc, infoPtr, 654 day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear), 655 infoPtr->currentMonth); 655 656 offset+=textWidth; 656 657 } 657 658 if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1))) 658 659 { 659 WARN("Can't load resource\n");660 strcpy(buf1,"Today:");660 WARN("Can't load resource\n"); 661 strcpy(buf1,"Today:"); 661 662 } 662 663 MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6); … … 674 675 } 675 676 676 /*eventually draw week numbers*/ 677 /*eventually draw week numbers*/ 677 678 if(dwStyle & MCS_WEEKNUMBERS) { 678 679 /* display weeknumbers*/ … … 682 683 LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?): 683 684 The week containing Jan 1 is the first week of year 684 LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 685 LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 685 686 First week of year must contain 4 days of the new year 686 687 LOCALE_IFIRSTWEEKOFYEAR == 1 (what contries?) … … 688 689 */ 689 690 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, 690 buf, sizeof(buf));691 buf, sizeof(buf)); 691 692 sscanf(buf, "%d", &weeknum); 692 693 switch (weeknum) 693 694 { 694 695 case 1: mindays = 6; 695 break;696 break; 696 697 case 2: mindays = 3; 697 break;698 break; 698 699 case 0: 699 700 default: 700 mindays = 0;701 mindays = 0; 701 702 } 702 703 if (infoPtr->currentMonth < 2) 703 704 { 704 /* calculate all those exceptions for january */705 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);706 if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays) 707 weeknum =1;708 else709 {710 weeknum = 0;711 for(i=0; i<11; i++) 712 weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);713 weeknum +=startofprescal+ 7;714 weeknum /=7;715 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);716 if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)717 weeknum++;718 }705 /* calculate all those exceptions for january */ 706 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear); 707 if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays) 708 weeknum =1; 709 else 710 { 711 weeknum = 0; 712 for(i=0; i<11; i++) 713 weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1); 714 weeknum +=startofprescal+ 7; 715 weeknum /=7; 716 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1); 717 if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays) 718 weeknum++; 719 } 719 720 } 720 721 else 721 722 { 722 weeknum = 0;723 for(i=0; i<prevMonth-1; i++) 724 weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);725 weeknum +=startofprescal+ 7;726 weeknum /=7;727 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);728 if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)729 weeknum++;723 weeknum = 0; 724 for(i=0; i<prevMonth-1; i++) 725 weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear); 726 weeknum +=startofprescal+ 7; 727 weeknum /=7; 728 weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear); 729 if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays) 730 weeknum++; 730 731 } 731 732 days->left = infoPtr->weeknums.left; … … 735 736 for(i=0; i<6; i++) { 736 737 if((i==0)&&(weeknum>50)) 737 {738 sprintf(buf, "%d", weeknum);739 weeknum=0;740 }738 { 739 sprintf(buf, "%d", weeknum); 740 weeknum=0; 741 } 741 742 else if((i==5)&&(weeknum>47)) 742 {743 sprintf(buf, "%d", 1);744 }743 { 744 sprintf(buf, "%d", 1); 745 } 745 746 else 746 sprintf(buf, "%d", weeknum + i);747 sprintf(buf, "%d", weeknum + i); 747 748 DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 748 749 days->top+=infoPtr->height_increment; 749 750 days->bottom+=infoPtr->height_increment; 750 751 } 751 752 752 753 MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL); 753 754 LineTo(hdc, infoPtr->weeknums.right, infoPtr->weeknums.bottom ); 754 755 755 756 } 756 757 /* currentFont was font at entering Refresh */ 757 758 758 759 SetBkColor(hdc, oldBkColor); 759 SelectObject(hdc, currentFont); 760 SelectObject(hdc, currentFont); 760 761 SetTextColor(hdc, oldTextColor); 761 762 } 762 763 763 764 764 static LRESULT 765 static LRESULT 765 766 MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam) 766 767 { … … 768 769 LPRECT lpRect = (LPRECT) lParam; 769 770 TRACE("%x %lx\n", wParam, lParam); 770 771 771 772 /* validate parameters */ 772 773 … … 781 782 782 783 783 static LRESULT 784 static LRESULT 784 785 MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) 785 786 { … … 807 808 808 809 809 static LRESULT 810 static LRESULT 810 811 MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) 811 812 { … … 847 848 848 849 849 static LRESULT 850 static LRESULT 850 851 MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) 851 852 { … … 853 854 854 855 TRACE("%x %lx\n", wParam, lParam); 855 856 856 857 if(infoPtr->delta) 857 858 return infoPtr->delta; … … 861 862 862 863 863 static LRESULT 864 static LRESULT 864 865 MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) 865 866 { … … 868 869 869 870 TRACE("%x %lx\n", wParam, lParam); 870 871 871 872 infoPtr->delta = (int)wParam; 872 873 return prev; … … 874 875 875 876 876 static LRESULT 877 static LRESULT 877 878 MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) 878 879 { 879 880 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); 880 881 881 882 return infoPtr->firstDay; 882 883 } … … 887 888 /* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */ 888 889 /* FIXME: we need more error checking here */ 889 static LRESULT 890 static LRESULT 890 891 MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) 891 892 { … … 903 904 { 904 905 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, 905 buf, sizeof(buf));906 buf, sizeof(buf)); 906 907 TRACE("%s %d\n", buf, strlen(buf)); 907 908 if(sscanf(buf, "%d", &day) == 1) 908 infoPtr->firstDay = day;909 infoPtr->firstDay = day; 909 910 else 910 infoPtr->firstDay = 0;911 infoPtr->firstDay = 0; 911 912 } 912 913 return prev; … … 916 917 /* FIXME: fill this in */ 917 918 static LRESULT 918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 919 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 919 920 { 920 921 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); … … 937 938 938 939 /* FIXME: are validated times taken from current date/time or simply 939 * copied? 940 * copied? 940 941 * FIXME: check whether MCM_GETMONTHRANGE shows correct result after 941 942 * adjusting range with MCM_SETRANGE … … 950 951 951 952 TRACE("%x %lx\n", wParam, lParam); 952 953 953 954 if(wParam & GDTR_MAX) { 954 955 if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){ … … 973 974 infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth; 974 975 975 if(infoPtr->monthRange!=prev) { 976 COMCTL32_ReAlloc(infoPtr->monthdayState, 977 infoPtr->monthRange * sizeof(MONTHDAYSTATE));976 if(infoPtr->monthRange!=prev) { 977 COMCTL32_ReAlloc(infoPtr->monthdayState, 978 infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 978 979 } 979 980 … … 983 984 984 985 /* CHECKME: At the moment, we copy ranges anyway,regardless of 985 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 986 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 986 987 * SetRange. Is this the right behavior? 987 988 */ … … 1015 1016 if(iMonths!=infoPtr->monthRange) return 0; 1016 1017 1017 for(i=0; i<iMonths; i++) 1018 for(i=0; i<iMonths; i++) 1018 1019 infoPtr->monthdayState[i] = dayStates[i]; 1019 1020 return 1; 1020 1021 } 1021 1022 1022 static LRESULT 1023 static LRESULT 1023 1024 MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) 1024 1025 { … … 1036 1037 /* FIXME: if the specified date is not visible, make it visible */ 1037 1038 /* FIXME: redraw? */ 1038 static LRESULT 1039 static LRESULT 1039 1040 MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) 1040 1041 { … … 1057 1058 1058 1059 1059 static LRESULT 1060 static LRESULT 1060 1061 MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) 1061 1062 { … … 1067 1068 1068 1069 1069 static LRESULT 1070 static LRESULT 1070 1071 MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) 1071 1072 { … … 1081 1082 1082 1083 1083 static LRESULT 1084 static LRESULT 1084 1085 MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 1085 1086 { … … 1100 1101 return TRUE; 1101 1102 } 1102 1103 1103 1104 return FALSE; 1104 1105 } 1105 1106 1106 1107 1107 static LRESULT 1108 static LRESULT 1108 1109 MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 1109 1110 { … … 1124 1125 return TRUE; 1125 1126 } 1126 1127 1127 1128 return FALSE; 1128 1129 } 1129 1130 1130 1131 1131 static LRESULT 1132 static LRESULT 1132 1133 MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) 1133 1134 { … … 1145 1146 1146 1147 1147 static LRESULT 1148 static LRESULT 1148 1149 MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) 1149 1150 { … … 1170 1171 DWORD retval; 1171 1172 int day,wday,wnum; 1172 1173 1173 1174 1174 1175 x = lpht->pt.x; 1175 1176 y = lpht->pt.y; 1176 1177 retval = MCHT_NOWHERE; 1177 1178 1179 /* Comment in for debugging... 1180 TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y, 1181 infoPtr->wdays.left, infoPtr->wdays.right,1182 infoPtr->wdays.top, infoPtr->wdays.bottom,1183 infoPtr->days.left, infoPtr->days.right,1184 infoPtr->days.top, infoPtr->days.bottom,1185 infoPtr->todayrect.left, infoPtr->todayrect.right,1186 infoPtr->todayrect.top, infoPtr->todayrect.bottom,1187 infoPtr->weeknums.left, infoPtr->weeknums.right,1188 infoPtr->weeknums.top, infoPtr->weeknums.bottom);1178 1179 1180 /* Comment in for debugging... 1181 TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y, 1182 infoPtr->wdays.left, infoPtr->wdays.right, 1183 infoPtr->wdays.top, infoPtr->wdays.bottom, 1184 infoPtr->days.left, infoPtr->days.right, 1185 infoPtr->days.top, infoPtr->days.bottom, 1186 infoPtr->todayrect.left, infoPtr->todayrect.right, 1187 infoPtr->todayrect.top, infoPtr->todayrect.bottom, 1188 infoPtr->weeknums.left, infoPtr->weeknums.right, 1189 infoPtr->weeknums.top, infoPtr->weeknums.bottom); 1189 1190 */ 1190 1191 1191 1192 /* are we in the header? */ 1192 1193 1193 1194 if(PtInRect(&infoPtr->title, lpht->pt)) { 1194 1195 if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) { … … 1208 1209 goto done; 1209 1210 } 1210 1211 1211 1212 retval = MCHT_TITLE; 1212 1213 goto done; 1213 1214 } 1214 1215 1215 1216 day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum); 1216 1217 if(PtInRect(&infoPtr->wdays, lpht->pt)) { … … 1218 1219 lpht->st.wYear = infoPtr->currentYear; 1219 1220 lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth; 1220 lpht->st.wDay = (day < 1)? 1221 lpht->st.wDay = (day < 1)? 1221 1222 MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day; 1222 1223 goto done; 1223 1224 } 1224 if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 1225 retval = MCHT_CALENDARWEEKNUM; 1225 if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 1226 retval = MCHT_CALENDARWEEKNUM; 1226 1227 lpht->st.wYear = infoPtr->currentYear; 1227 lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 1228 (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 1228 lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 1229 (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 1229 1230 infoPtr->currentMonth +1 :infoPtr->currentMonth; 1230 lpht->st.wDay = (day < 1 ) ? 1231 MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : 1232 (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 1231 lpht->st.wDay = (day < 1 ) ? 1232 MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : 1233 (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 1233 1234 day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day; 1234 goto done; 1235 } 1236 if(PtInRect(&infoPtr->days, lpht->pt)) 1235 goto done; 1236 } 1237 if(PtInRect(&infoPtr->days, lpht->pt)) 1237 1238 { 1238 1239 lpht->st.wYear = infoPtr->currentYear; 1239 if ( day < 1) 1240 {1241 retval = MCHT_CALENDARDATEPREV;1242 lpht->st.wMonth = infoPtr->currentMonth - 1;1243 if (lpht->st.wMonth <1)1244 {1245 lpht->st.wMonth = 12;1246 lpht->st.wYear--;1247 }1248 lpht->st.wDay = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;1249 }1240 if ( day < 1) 1241 { 1242 retval = MCHT_CALENDARDATEPREV; 1243 lpht->st.wMonth = infoPtr->currentMonth - 1; 1244 if (lpht->st.wMonth <1) 1245 { 1246 lpht->st.wMonth = 12; 1247 lpht->st.wYear--; 1248 } 1249 lpht->st.wDay = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day; 1250 } 1250 1251 else if (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) 1251 {1252 retval = MCHT_CALENDARDATENEXT;1253 lpht->st.wMonth = infoPtr->currentMonth + 1;1254 if (lpht->st.wMonth <12)1255 {1256 lpht->st.wMonth = 1;1257 lpht->st.wYear++;1258 }1259 lpht->st.wDay = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;1260 }1252 { 1253 retval = MCHT_CALENDARDATENEXT; 1254 lpht->st.wMonth = infoPtr->currentMonth + 1; 1255 if (lpht->st.wMonth <12) 1256 { 1257 lpht->st.wMonth = 1; 1258 lpht->st.wYear++; 1259 } 1260 lpht->st.wDay = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ; 1261 } 1261 1262 else { 1262 retval = MCHT_CALENDARDATE;1263 lpht->st.wMonth = infoPtr->currentMonth;1264 lpht->st.wDay = day;1263 retval = MCHT_CALENDARDATE; 1264 lpht->st.wMonth = infoPtr->currentMonth; 1265 lpht->st.wDay = day; 1265 1266 } 1266 1267 goto done; 1267 1268 } 1268 1269 if(PtInRect(&infoPtr->todayrect, lpht->pt)) { 1269 retval = MCHT_TODAYLINK; 1270 retval = MCHT_TODAYLINK; 1270 1271 goto done; 1271 1272 } 1272 1273 1273 1274 1274 1275 /* Hit nothing special? What's left must be background :-) */ 1275 1276 retval = MCHT_CALENDARBK; 1277 done: 1276 1277 retval = MCHT_CALENDARBK; 1278 done: 1278 1279 lpht->uHit = retval; 1279 1280 return retval; … … 1300 1301 nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 1301 1302 nmds.nmhdr.code = MCN_GETDAYSTATE; 1302 nmds.cDayState = infoPtr->monthRange;1303 nmds.prgDayState = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));1303 nmds.cDayState = infoPtr->monthRange; 1304 nmds.prgDayState = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1304 1305 1305 1306 SendMessageA(GetParent(hwnd), WM_NOTIFY, … … 1330 1331 nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 1331 1332 nmds.nmhdr.code = MCN_GETDAYSTATE; 1332 nmds.cDayState = infoPtr->monthRange;1333 nmds.prgDayState = COMCTL32_Alloc1333 nmds.cDayState = infoPtr->monthRange; 1334 nmds.prgDayState = COMCTL32_Alloc 1334 1335 (infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1335 1336 … … 1348 1349 POINT menupoint; 1349 1350 char buf[32]; 1350 1351 1351 1352 hMenu = CreatePopupMenu(); 1352 1353 if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf))) … … 1360 1361 ClientToScreen(hwnd, &menupoint); 1361 1362 if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD, 1362 menupoint.x,menupoint.y,0,hwnd,NULL))1363 menupoint.x,menupoint.y,0,hwnd,NULL)) 1363 1364 { 1364 1365 infoPtr->currentMonth=infoPtr->todaysDate.wMonth; 1365 1366 infoPtr->currentYear=infoPtr->todaysDate.wYear; 1366 1367 InvalidateRect(hwnd, NULL, FALSE); 1367 } 1368 } 1368 1369 return 0; 1369 1370 } … … 1381 1382 POINT menupoint; 1382 1383 TRACE("%x %lx\n", wParam, lParam); 1383 1384 1384 1385 if (infoPtr->hWndYearUpDown) 1385 1386 { 1386 1387 infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)0); 1387 1388 if(!DestroyWindow(infoPtr->hWndYearUpDown)) 1388 {1389 FIXME("Can't destroy Updown Control\n");1390 }1389 { 1390 FIXME("Can't destroy Updown Control\n"); 1391 } 1391 1392 else 1392 infoPtr->hWndYearUpDown=0;1393 infoPtr->hWndYearUpDown=0; 1393 1394 if(!DestroyWindow(infoPtr->hWndYearEdit)) 1394 {1395 FIXME("Can't destroy Updown Control\n");1396 }1395 { 1396 FIXME("Can't destroy Updown Control\n"); 1397 } 1397 1398 else 1398 infoPtr->hWndYearEdit=0;1399 infoPtr->hWndYearEdit=0; 1399 1400 InvalidateRect(hwnd, NULL, FALSE); 1400 1401 } 1401 1402 1402 1403 ht.pt.x = (INT)LOWORD(lParam); 1403 1404 ht.pt.y = (INT)HIWORD(lParam); … … 1414 1415 return TRUE; 1415 1416 } 1416 if(hit == MCHT_TITLEBTNPREV){ 1417 if(hit == MCHT_TITLEBTNPREV){ 1417 1418 MONTHCAL_GoToPrevMonth(hwnd, infoPtr); 1418 1419 infoPtr->status = MC_PREVPRESSED; … … 1424 1425 if(hit == MCHT_TITLEMONTH) { 1425 1426 hMenu = CreatePopupMenu(); 1426 1427 1427 1428 for (i=0; i<12;i++) 1428 1429 { 1429 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,1430 buf,sizeof(buf));1431 AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);1430 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i, 1431 buf,sizeof(buf)); 1432 AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf); 1432 1433 } 1433 1434 menupoint.x=infoPtr->titlemonth.right; … … 1435 1436 ClientToScreen(hwnd, &menupoint); 1436 1437 i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD, 1437 menupoint.x,menupoint.y,0,hwnd,NULL);1438 menupoint.x,menupoint.y,0,hwnd,NULL); 1438 1439 if ((i>0) && (i<13)) 1439 1440 { 1440 infoPtr->currentMonth=i;1441 InvalidateRect(hwnd, NULL, FALSE);1441 infoPtr->currentMonth=i; 1442 InvalidateRect(hwnd, NULL, FALSE); 1442 1443 } 1443 1444 } 1444 1445 if(hit == MCHT_TITLEYEAR) { 1445 1446 infoPtr->hWndYearEdit=CreateWindowExA(0, 1446 "EDIT",1447 0,1448 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,1449 infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,1450 infoPtr->titleyear.right-infoPtr->titleyear.left,1451 infoPtr->textHeight,1452 hwnd,1453 (HMENU)NULL, 1454 (HINSTANCE)NULL, 1455 NULL);1447 "EDIT", 1448 0, 1449 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT, 1450 infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top, 1451 infoPtr->titleyear.right-infoPtr->titleyear.left, 1452 infoPtr->textHeight, 1453 hwnd, 1454 (HMENU)NULL, 1455 (HINSTANCE)NULL, 1456 NULL); 1456 1457 infoPtr->hWndYearUpDown=CreateWindowExA(0, 1457 UPDOWN_CLASSA,1458 0,1459 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,1460 infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,1461 20,1462 infoPtr->textHeight,1463 hwnd,1464 (HMENU)NULL, 1465 (HINSTANCE)NULL, 1466 NULL);1458 UPDOWN_CLASSA, 1459 0, 1460 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS, 1461 infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top, 1462 20, 1463 infoPtr->textHeight, 1464 hwnd, 1465 (HMENU)NULL, 1466 (HINSTANCE)NULL, 1467 NULL); 1467 1468 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753)); 1468 1469 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 ); 1469 1470 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)infoPtr->currentYear ); 1470 1471 return TRUE; 1471 1472 1472 1473 } 1473 1474 if(hit == MCHT_TODAYLINK) { … … 1487 1488 MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel); 1488 1489 MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel); 1489 1490 1490 1491 SendMessageA(GetParent(hwnd), WM_NOTIFY, 1491 1492 (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc); … … 1493 1494 MONTHCAL_CopyTime(&ht.st, &selArray[0]); 1494 1495 MONTHCAL_CopyTime(&ht.st, &selArray[1]); 1495 MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 1496 MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 1496 1497 1497 1498 /* redraw both old and new days if the selected day changed */ … … 1546 1547 return TRUE; 1547 1548 } 1548 if(hit == MCHT_CALENDARDATEPREV){ 1549 if(hit == MCHT_CALENDARDATEPREV){ 1549 1550 MONTHCAL_GoToPrevMonth(hwnd, infoPtr); 1550 1551 InvalidateRect(hwnd, NULL, FALSE); … … 1564 1565 MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel); 1565 1566 MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel); 1566 1567 1567 1568 SendMessageA(GetParent(hwnd), WM_NOTIFY, 1568 1569 (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); 1569 1570 1570 1571 /* redraw if necessary */ 1571 1572 if(redraw) 1572 1573 InvalidateRect(hwnd, NULL, FALSE); 1573 1574 1574 1575 return 0; 1575 1576 } … … 1586 1587 1587 1588 switch(wParam) { 1588 case MC_NEXTMONTHTIMER: 1589 case MC_NEXTMONTHTIMER: 1589 1590 redraw = TRUE; 1590 1591 MONTHCAL_GoToNextMonth(hwnd, infoPtr); … … 1618 1619 ht.pt.x = LOWORD(lParam); 1619 1620 ht.pt.y = HIWORD(lParam); 1620 1621 1621 1622 hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht); 1622 1623 1623 1624 /* not on the calendar date numbers? bail out */ 1624 1625 TRACE("hit:%x\n",hit); … … 1638 1639 if(infoPtr->firstSelDay==selArray[0].wDay) i=1; 1639 1640 TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i); 1640 if(infoPtr->firstSelDay==selArray[1].wDay) { 1641 if(infoPtr->firstSelDay==selArray[1].wDay) { 1641 1642 /* 1st time we get here: selArray[0]=selArray[1]) */ 1642 1643 /* if we're still at the first selected date, return */ … … 1644 1645 if(selday<infoPtr->firstSelDay) i = 0; 1645 1646 } 1646 1647 1647 1648 if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) { 1648 1649 if(selday>infoPtr->firstSelDay) … … 1651 1652 selday = infoPtr->firstSelDay - infoPtr->maxSelCount; 1652 1653 } 1653 1654 1654 1655 if(selArray[i].wDay!=selday) { 1655 1656 TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i); 1656 1657 1657 1658 selArray[i].wDay = selday; 1658 1659 … … 1712 1713 { 1713 1714 TRACE("\n"); 1714 1715 1715 1716 InvalidateRect(hwnd, NULL, FALSE); 1716 1717 … … 1769 1770 1770 1771 /* recalculate the height and width increments and offsets */ 1771 /* FIXME: We use up all available width. This will inhibit having multiple 1772 calendars in a row, like win doesn 1772 /* FIXME: We use up all available width. This will inhibit having multiple 1773 calendars in a row, like win doesn 1773 1774 */ 1774 1775 if(dwStyle & MCS_WEEKNUMBERS) … … 1776 1777 else 1777 1778 xdiv=7.0; 1778 infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; 1779 infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; 1779 infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; 1780 infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; 1780 1781 infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv); 1781 1782 infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0); … … 1790 1791 rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5; 1791 1792 }*/ 1792 1793 1793 1794 /* calculate title area */ 1794 1795 title->top = rcClient->top; … … 1805 1806 next->right = title->right - 6; 1806 1807 next->left = next->right - (title->bottom - title->top); 1807 1808 1808 1809 /* titlemonth->left and right change based upon the current month */ 1809 1810 /* and are recalculated in refresh as the current month may change */ … … 1811 1812 titlemonth->top = titleyear->top = title->top + (infoPtr->height_increment)/2; 1812 1813 titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2; 1813 1814 1814 1815 /* setup the dimensions of the rectangle we draw the names of the */ 1815 1816 /* days of the week in */ 1816 1817 weeknumrect->left =infoPtr->left_offset; 1817 if(dwStyle & MCS_WEEKNUMBERS) 1818 if(dwStyle & MCS_WEEKNUMBERS) 1818 1819 weeknumrect->right=prev->right; 1819 1820 else … … 1823 1824 wdays->top = title->bottom ; 1824 1825 wdays->bottom = wdays->top + infoPtr->height_increment; 1825 1826 1826 1827 days->top = weeknumrect->top = wdays->bottom ; 1827 1828 days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment; 1828 1829 1829 1830 todayrect->left = rcClient->left; 1830 1831 todayrect->right = rcClient->right; … … 1832 1833 todayrect->bottom = days->bottom + infoPtr->height_increment; 1833 1834 1834 /* uncomment for excessive debugging 1835 /* uncomment for excessive debugging 1835 1836 TRACE("dx=%d dy=%d rcC[%d %d %d %d] t[%d %d %d %d] wd[%d %d %d %d] w[%d %d %d %d] t[%d %d %d %d]\n", 1836 infoPtr->width_increment,infoPtr->height_increment,1837 rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,1838 title->left, title->right, title->top, title->bottom,1839 wdays->left, wdays->right, wdays->top, wdays->bottom,1840 days->left, days->right, days->top, days->bottom,1841 todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);1837 infoPtr->width_increment,infoPtr->height_increment, 1838 rcClient->left, rcClient->right, rcClient->top, rcClient->bottom, 1839 title->left, title->right, title->top, title->bottom, 1840 wdays->left, wdays->right, wdays->top, wdays->bottom, 1841 days->left, days->right, days->top, days->bottom, 1842 todayrect->left,todayrect->right,todayrect->top,todayrect->bottom); 1842 1843 */ 1843 1844 1844 1845 /* restore the originally selected font */ 1845 SelectObject(hdc, currentFont); 1846 SelectObject(hdc, currentFont); 1846 1847 1847 1848 ReleaseDC(hwnd, hdc); … … 1865 1866 { 1866 1867 MONTHCAL_INFO *infoPtr; 1867 LOGFONTA logFont;1868 LOGFONTA logFont; 1868 1869 1869 1870 /* allocate memory for info structure */ … … 1900 1901 infoPtr->maxSelCount = 7; 1901 1902 infoPtr->monthRange = 3; 1902 infoPtr->monthdayState = COMCTL32_Alloc 1903 infoPtr->monthdayState = COMCTL32_Alloc 1903 1904 (infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1904 1905 infoPtr->titlebk = GetSysColor(COLOR_ACTIVECAPTION); … … 1907 1908 infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT); 1908 1909 infoPtr->bk = GetSysColor(COLOR_WINDOW); 1909 infoPtr->txt = GetSysColor(COLOR_WINDOWTEXT);1910 infoPtr->txt = GetSysColor(COLOR_WINDOWTEXT); 1910 1911 1911 1912 /* call MONTHCAL_UpdateSize to set all of the dimensions */ … … 2062 2063 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 2063 2064 wndClass.lpszClassName = MONTHCAL_CLASSA; 2064 2065 2065 2066 RegisterClassA(&wndClass); 2066 2067 }
Note:
See TracChangeset
for help on using the changeset viewer.
