Ignore:
Timestamp:
Sep 15, 2001, 11:26:26 AM (24 years ago)
Author:
sandervl
Message:

restored old version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/monthcal.c

    r6705 r6709  
    11/* Month calendar control
    2  *
     2
    33 *
    44 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
    55 * Copyright 1999 Alex Priem (alexp@sci.kun.nl)
    66 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and
    7  *        James Abbatiello <abbeyj@wpi.edu>
     7 *                James Abbatiello <abbeyj@wpi.edu>
    88 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
    99 *
     
    1313 *
    1414 *  FIXME: handle resources better (doesn't work now); also take care
    15  *         of internationalization.
     15           of internationalization.
    1616 *  FIXME: keyboard handling.
    1717 */
     
    4343DEFAULT_DEBUG_CHANNEL(monthcal);
    4444
    45 #define MC_SEL_LBUTUP       1   /* Left button released */
    46 #define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
     45#define MC_SEL_LBUTUP       1   /* Left button released */
     46#define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
    4747#define MC_PREVPRESSED      4   /* Prev month button pressed */
    4848#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
     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                   
    5454
    5555typedef struct
     
    5858    COMCTL32_HEADER header;
    5959#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 */
     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 */
    7676                        /* 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;
     77    int         visible;        /* # of months visible */
     78    int         firstDay;       /* Start month calendar with firstDay's day */
     79    int         monthRange;
    8080    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 */
     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 */
    105105    HWND hWndYearEdit;  /* Window Handle of edit box to handle years */
    106106    HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
     
    141141
    142142/* make sure that time is valid */
    143 static int MONTHCAL_ValidateTime(SYSTEMTIME time)
     143static int MONTHCAL_ValidateTime(SYSTEMTIME time) 
    144144{
    145145  if(time.wMonth > 12) return FALSE;
    146146  if(time.wDayOfWeek > 6) return FALSE;
    147147  if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
    148       return FALSE;
     148          return FALSE;
    149149  if(time.wHour > 23) return FALSE;
    150150  if(time.wMinute > 59) return FALSE;
     
    156156
    157157
    158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
     158void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 
    159159{
    160160  to->wYear = from->wYear;
     
    169169
    170170
    171 /* Note:Depending on DST, this may be offset by a day.
     171/* Note:Depending on DST, this may be offset by a day. 
    172172   Need to find out if we're on a DST place & adjust the clock accordingly.
    173173   Above function assumes we have a valid data.
     
    182182  year-=(month < 3);
    183183
    184   return((year + year/4 - year/100 + year/400 +
     184  return((year + year/4 - year/100 + year/400 + 
    185185         DayOfWeekTable[month-1] + day - 1 ) % 7);
    186186}
     
    189189   and day in the calendar. day== 0 mean the last day of tha last month
    190190*/
    191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y,
    192                    int *daypos,int *weekpos)
     191static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 
     192                                   int *daypos,int *weekpos)
    193193{
    194194  int retval, firstDay;
     
    202202  *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
    203203  *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
    204 
     204   
    205205  firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
    206206  retval = *daypos + (7 * *weekpos) - firstDay;
     
    211211/* sets x and y to be the position of the day */
    212212/* x == day, y == week where(0,0) == firstDay, 1st week */
    213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month,
     213static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 
    214214                                 int *x, int *y)
    215215{
     
    227227    if(prevMonth==0)
    228228       prevMonth = 12;
    229 
     229   
    230230    *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
    231231    *y = 0;
     
    240240
    241241/* x: column(day), y: row(week) */
    242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
     242static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 
    243243{
    244244  r->left = infoPtr->days.left + x * infoPtr->width_increment;
     
    252252/* day is the day value of the month(1 == 1st), month is the month */
    253253/* value(january == 1, december == 12) */
    254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
     254static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 
    255255                                            int day, int month, RECT *r)
    256256{
     
    278278  x = day_rect.left;
    279279  y = day_rect.top;
    280 
     280       
    281281  points[0].x = x;
    282282  points[0].y = y - 1;
     
    287287  points[3].x = x + infoPtr->width_increment;
    288288  points[3].y = y + 0.5 * infoPtr->height_increment;
    289 
     289       
    290290  points[4].x = x + infoPtr->width_increment;
    291291  points[4].y = y + 0.9 * infoPtr->height_increment;
     
    294294  points[6].x = x + 0.5 * infoPtr->width_increment;
    295295  points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
    296                 a hair to fit inside the day rectangle */
    297 
     296                                a hair to fit inside the day rectangle */
     297       
    298298  points[7].x = x + 0.2 * infoPtr->width_increment;
    299299  points[7].y = y + 0.8 * infoPtr->height_increment;
     
    309309  points[12].x = x + 0.4 * infoPtr->width_increment;
    310310  points[12].y = y + 0.2 * infoPtr->height_increment;
    311 
     311 
    312312  PolyBezier(hdc, points, 13);
    313313  DeleteObject(hRedPen);
     
    329329  sprintf(buf, "%d", day);
    330330
    331 /* No need to check styles: when selection is not valid, it is set to zero.
     331/* No need to check styles: when selection is not valid, it is set to zero. 
    332332 * 1<day<31, so evertyhing's OK.
    333333 */
     
    349349
    350350    /* FIXME: this may need to be changed now b/c of the other
    351     drawing changes 11/3/99 CMM */
     351        drawing changes 11/3/99 CMM */
    352352    r2.left   = r.left - 0.25 * infoPtr->textWidth;
    353353    r2.top    = r.top;
     
    390390
    391391/* CHECKME: For `todays date', do we need to check the locale?*/
    392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
     392static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 
    393393{
    394394  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     
    425425  hbr = CreateSolidBrush (infoPtr->bk);
    426426  FillRect(hdc, rcClient, hbr);
    427   DeleteObject(hbr);
     427  DeleteObject(hbr);       
    428428
    429429  /* draw header */
     
    434434    DeleteObject(hbr);
    435435  }
    436 
     436       
    437437  /* if the previous button is pressed draw it depressed */
    438438  if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
    439   {
     439  { 
    440440    if((infoPtr->status & MC_PREVPRESSED))
    441441        DrawFrameControl(hdc, prev, DFC_SCROLL,
    442        DFCS_SCROLLLEFT | DFCS_PUSHED |
     442           DFCS_SCROLLLEFT | DFCS_PUSHED |
    443443          (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    444444    else /* if the previous button is pressed draw it depressed */
    445445      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 */
     446           DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
     447  }
     448
     449  /* if next button is depressed draw it depressed */   
    450450  if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
    451451  {
    452452    if((infoPtr->status & MC_NEXTPRESSED))
    453453      DrawFrameControl(hdc, next, DFC_SCROLL,
    454            DFCS_SCROLLRIGHT | DFCS_PUSHED |
     454           DFCS_SCROLLRIGHT | DFCS_PUSHED |
    455455           (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    456456    else /* if the next button is pressed draw it depressed */
     
    466466  titlemonth->left   = title->left;
    467467  titlemonth->right  = title->right;
    468 
     468 
    469469  GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
    470           buf1,sizeof(buf1));
     470                  buf1,sizeof(buf1));
    471471  sprintf(buf, "%s %ld", buf1, infoPtr->currentYear);
    472 
     472 
    473473  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
    474474  {
    475     DrawTextA(hdc, buf, strlen(buf), titlemonth,
     475    DrawTextA(hdc, buf, strlen(buf), titlemonth, 
    476476                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    477477  }
     
    481481/* titlemonth left/right contained rect for whole titletxt('June  1999')
    482482  * MCM_HitTestInfo wants month & year rects, so prepare these now.
    483   *(no, we can't draw them separately; the whole text is centered)
     483  *(no, we can't draw them separately; the whole text is centered) 
    484484  */
    485485  GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
     
    489489  titlemonth->right = titlemonth->left + size.cx;
    490490  titleyear->left = titlemonth->right;
    491 
     491 
    492492  /* draw month area */
    493493  rcTemp.top=infoPtr->wdays.top;
     
    501501    DeleteObject(hbr);
    502502  }
    503 
     503       
    504504/* draw line under day abbreviatons */
    505505
    506506  MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
    507 
     507     
    508508  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
    509 
     509 
    510510  prevMonth = infoPtr->currentMonth - 1;
    511511  if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
     
    529529  for(j=0; j<7; j++) {
    530530    GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7,
    531             buf,sizeof(buf));
     531                    buf,sizeof(buf));
    532532    DrawTextA(hdc, buf, strlen(buf), days,
    533533                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     
    537537
    538538/* draw day numbers; first, the previous month */
    539 
     539 
    540540  firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
    541 
    542   day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  +
     541 
     542  day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  + 
    543543    (infoPtr->firstDay + 7  - firstDay)%7 + 1;
    544544  if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
     
    553553    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    554554    {
    555       MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
     555      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 
    556556          infoPtr->monthdayState[m] & mask);
    557557    }
     
    577577    {
    578578
    579       MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
    580     infoPtr->monthdayState[m] & mask);
     579      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 
     580        infoPtr->monthdayState[m] & mask);
    581581
    582582      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    583583          (day==infoPtr->todaysDate.wDay) &&
    584       (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
     584          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
    585585        if(!(dwStyle & MCS_NOTODAYCIRCLE))
    586       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     586          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    587587      }
    588588    }
     
    595595  j = 1; /* move to the 2nd week of the current month */
    596596  i = 0; /* move back to sunday */
    597   while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
     597  while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {     
    598598    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    599599    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     
    604604      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    605605          (day==infoPtr->todaysDate.wDay) &&
    606           (infoPtr->currentYear == infoPtr->todaysDate.wYear))
    607         if(!(dwStyle & MCS_NOTODAYCIRCLE))
    608       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     606          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 
     607        if(!(dwStyle & MCS_NOTODAYCIRCLE)) 
     608          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    609609    }
    610610    mask<<=1;
     
    627627    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    628628    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    629     {
     629    {   
    630630      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
    631         infoPtr->monthdayState[m] & mask);
     631                infoPtr->monthdayState[m] & mask);
    632632    }
    633633
    634634    mask<<=1;
    635635    day++;
    636     i++;
     636    i++;       
    637637    if(i==7) { /* past saturday, go to next week's sunday */
    638638      i = 0;
     
    650650    if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
    651651      /*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);
     652      MONTHCAL_CircleDay(hdc, infoPtr, 
     653                         day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
     654                        infoPtr->currentMonth);
    655655      offset+=textWidth;
    656656    }
    657657    if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1)))
    658658      {
    659     WARN("Can't load resource\n");
    660     strcpy(buf1,"Today:");
     659        WARN("Can't load resource\n");
     660        strcpy(buf1,"Today:");
    661661      }
    662662    MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
     
    674674  }
    675675
    676 /*eventually draw week numbers*/
     676/*eventually draw week numbers*/   
    677677  if(dwStyle & MCS_WEEKNUMBERS)  {
    678678    /* display weeknumbers*/
     
    682682       LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
    683683       The week containing Jan 1 is the first week of year
    684        LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
     684       LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 
    685685       First week of year must contain 4 days of the new year
    686686       LOCALE_IFIRSTWEEKOFYEAR == 1  (what contries?)
     
    688688    */
    689689    GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR,
    690              buf, sizeof(buf));
     690                     buf, sizeof(buf));
    691691    sscanf(buf, "%d", &weeknum);
    692692    switch (weeknum)
    693693      {
    694694      case 1: mindays = 6;
    695     break;
     695        break;
    696696      case 2: mindays = 3;
    697     break;
     697        break;
    698698      case 0:
    699699      default:
    700     mindays = 0;
     700        mindays = 0;
    701701      }
    702702    if (infoPtr->currentMonth < 2)
    703703      {
    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     else
    709       {
    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       }
     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        else
     709          {
     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          }
    719719      }
    720720    else
    721721      {
    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++;
     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++;
    730730      }
    731731    days->left = infoPtr->weeknums.left;
     
    735735    for(i=0; i<6; i++) {
    736736      if((i==0)&&(weeknum>50))
    737     {
    738       sprintf(buf, "%d", weeknum);
    739       weeknum=0;
    740     }
     737        {
     738          sprintf(buf, "%d", weeknum);
     739          weeknum=0;
     740        }
    741741      else if((i==5)&&(weeknum>47))
    742     {
    743       sprintf(buf, "%d", 1);
    744     }
     742        {
     743          sprintf(buf, "%d", 1);
     744        }
    745745      else
    746     sprintf(buf, "%d", weeknum + i);
     746        sprintf(buf, "%d", weeknum + i);
    747747      DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
    748748      days->top+=infoPtr->height_increment;
    749749      days->bottom+=infoPtr->height_increment;
    750750    }
    751 
     751                       
    752752    MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
    753753    LineTo(hdc,   infoPtr->weeknums.right, infoPtr->weeknums.bottom );
    754 
     754               
    755755  }
    756756  /* currentFont was font at entering Refresh */
    757757
    758758  SetBkColor(hdc, oldBkColor);
    759   SelectObject(hdc, currentFont);
     759  SelectObject(hdc, currentFont);     
    760760  SetTextColor(hdc, oldTextColor);
    761761}
    762762
    763763
    764 static LRESULT
     764static LRESULT 
    765765MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    766766{
     
    768768  LPRECT lpRect = (LPRECT) lParam;
    769769  TRACE("%x %lx\n", wParam, lParam);
    770 
     770       
    771771  /* validate parameters */
    772772
     
    781781
    782782
    783 static LRESULT
     783static LRESULT 
    784784MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    785785{
     
    807807
    808808
    809 static LRESULT
     809static LRESULT 
    810810MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    811811{
     
    847847
    848848
    849 static LRESULT
     849static LRESULT 
    850850MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    851851{
     
    853853
    854854  TRACE("%x %lx\n", wParam, lParam);
    855 
     855 
    856856  if(infoPtr->delta)
    857857    return infoPtr->delta;
     
    861861
    862862
    863 static LRESULT
     863static LRESULT 
    864864MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    865865{
     
    868868
    869869  TRACE("%x %lx\n", wParam, lParam);
    870 
     870       
    871871  infoPtr->delta = (int)wParam;
    872872  return prev;
     
    874874
    875875
    876 static LRESULT
     876static LRESULT 
    877877MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    878878{
    879879  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
    880 
     880       
    881881  return infoPtr->firstDay;
    882882}
     
    887887/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
    888888/* FIXME: we need more error checking here */
    889 static LRESULT
     889static LRESULT 
    890890MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    891891{
     
    903903    {
    904904      GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
    905              buf, sizeof(buf));
     905                     buf, sizeof(buf));
    906906      TRACE("%s %d\n", buf, strlen(buf));
    907907      if(sscanf(buf, "%d", &day) == 1)
    908     infoPtr->firstDay = day;
     908        infoPtr->firstDay = day;
    909909      else
    910     infoPtr->firstDay = 0;
     910        infoPtr->firstDay = 0;
    911911    }
    912912  return prev;
     
    916916/* FIXME: fill this in */
    917917static LRESULT
    918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
     918MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 
    919919{
    920920  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
     
    937937
    938938/* FIXME: are validated times taken from current date/time or simply
    939  * copied?
     939 * copied? 
    940940 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
    941941 *            adjusting range with MCM_SETRANGE
     
    950950
    951951  TRACE("%x %lx\n", wParam, lParam);
    952 
     952 
    953953  if(wParam & GDTR_MAX) {
    954954    if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     
    973973  infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
    974974
    975   if(infoPtr->monthRange!=prev) {
    976     COMCTL32_ReAlloc(infoPtr->monthdayState,
    977         infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     975  if(infoPtr->monthRange!=prev) { 
     976        COMCTL32_ReAlloc(infoPtr->monthdayState,
     977                infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    978978  }
    979979
     
    983983
    984984/* CHECKME: At the moment, we copy ranges anyway,regardless of
    985  * infoPtr->rangeValid; a invalid range is simply filled with zeros in
     985 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 
    986986 * SetRange.  Is this the right behavior?
    987987*/
     
    10151015  if(iMonths!=infoPtr->monthRange) return 0;
    10161016
    1017   for(i=0; i<iMonths; i++)
     1017  for(i=0; i<iMonths; i++) 
    10181018    infoPtr->monthdayState[i] = dayStates[i];
    10191019  return 1;
    10201020}
    10211021
    1022 static LRESULT
     1022static LRESULT 
    10231023MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10241024{
     
    10361036/* FIXME: if the specified date is not visible, make it visible */
    10371037/* FIXME: redraw? */
    1038 static LRESULT
     1038static LRESULT 
    10391039MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10401040{
     
    10571057
    10581058
    1059 static LRESULT
     1059static LRESULT 
    10601060MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10611061{
     
    10671067
    10681068
    1069 static LRESULT
     1069static LRESULT 
    10701070MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10711071{
     
    10811081
    10821082
    1083 static LRESULT
     1083static LRESULT 
    10841084MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10851085{
     
    11001100    return TRUE;
    11011101  }
    1102 
     1102 
    11031103  return FALSE;
    11041104}
    11051105
    11061106
    1107 static LRESULT
     1107static LRESULT 
    11081108MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11091109{
     
    11241124    return TRUE;
    11251125  }
    1126 
     1126 
    11271127  return FALSE;
    11281128}
    11291129
    11301130
    1131 static LRESULT
     1131static LRESULT 
    11321132MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11331133{
     
    11451145
    11461146
    1147 static LRESULT
     1147static LRESULT 
    11481148MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11491149{
     
    11701170  DWORD retval;
    11711171  int day,wday,wnum;
    1172 
    1173 
     1172 
     1173 
    11741174  x = lpht->pt.x;
    11751175  y = lpht->pt.y;
    11761176  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);
     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);
    11891189  */
    11901190
    11911191  /* are we in the header? */
    1192 
     1192 
    11931193  if(PtInRect(&infoPtr->title, lpht->pt)) {
    11941194    if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
     
    12081208      goto done;
    12091209    }
    1210 
     1210   
    12111211    retval = MCHT_TITLE;
    12121212    goto done;
    12131213  }
    1214 
     1214 
    12151215  day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
    12161216  if(PtInRect(&infoPtr->wdays, lpht->pt)) {
     
    12181218    lpht->st.wYear  = infoPtr->currentYear;
    12191219    lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
    1220     lpht->st.wDay   = (day < 1)?
     1220    lpht->st.wDay   = (day < 1)? 
    12211221      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
    12221222    goto done;
    12231223  }
    1224   if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
    1225     retval = MCHT_CALENDARWEEKNUM;
     1224  if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 
     1225    retval = MCHT_CALENDARWEEKNUM; 
    12261226    lpht->st.wYear  = infoPtr->currentYear;
    1227     lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 :
    1228       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
     1227    lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 
     1228      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12291229      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)) ?
     1230    lpht->st.wDay   = (day < 1 ) ? 
     1231      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : 
     1232      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12331233      day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day;
    1234     goto done;
    1235   }
    1236   if(PtInRect(&infoPtr->days, lpht->pt))
     1234    goto done;                             
     1235  }
     1236  if(PtInRect(&infoPtr->days, lpht->pt)) 
    12371237    {
    12381238      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     }
     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        }
    12501250      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     }
     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        }
    12611261      else {
    1262     retval = MCHT_CALENDARDATE;
    1263     lpht->st.wMonth = infoPtr->currentMonth;
    1264     lpht->st.wDay   = day;
     1262        retval = MCHT_CALENDARDATE;
     1263        lpht->st.wMonth = infoPtr->currentMonth;
     1264        lpht->st.wDay   = day;
    12651265      }
    12661266      goto done;
    12671267    }
    12681268  if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
    1269     retval = MCHT_TODAYLINK;
     1269    retval = MCHT_TODAYLINK; 
    12701270    goto done;
    12711271  }
    1272 
    1273 
     1272 
     1273 
    12741274  /* Hit nothing special? What's left must be background :-) */
    1275 
    1276   retval = MCHT_CALENDARBK;
    1277  done:
     1275 
     1276  retval = MCHT_CALENDARBK;       
     1277 done: 
    12781278  lpht->uHit = retval;
    12791279  return retval;
     
    13001300    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13011301    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1302     nmds.cDayState  = infoPtr->monthRange;
    1303     nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     1302    nmds.cDayState      = infoPtr->monthRange;
     1303    nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13041304
    13051305    SendMessageA(GetParent(hwnd), WM_NOTIFY,
     
    13301330    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13311331    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1332     nmds.cDayState  = infoPtr->monthRange;
    1333     nmds.prgDayState    = COMCTL32_Alloc
     1332    nmds.cDayState      = infoPtr->monthRange;
     1333    nmds.prgDayState    = COMCTL32_Alloc
    13341334                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13351335
     
    13481348  POINT menupoint;
    13491349  char buf[32];
    1350 
     1350 
    13511351  hMenu = CreatePopupMenu();
    13521352  if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf)))
     
    13601360  ClientToScreen(hwnd, &menupoint);
    13611361  if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD,
    1362              menupoint.x,menupoint.y,0,hwnd,NULL))
     1362                     menupoint.x,menupoint.y,0,hwnd,NULL))
    13631363    {
    13641364      infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
    13651365      infoPtr->currentYear=infoPtr->todaysDate.wYear;
    13661366      InvalidateRect(hwnd, NULL, FALSE);
    1367     }
     1367    }   
    13681368  return 0;
    13691369}
     
    13811381  POINT menupoint;
    13821382  TRACE("%x %lx\n", wParam, lParam);
    1383 
     1383       
    13841384  if (infoPtr->hWndYearUpDown)
    13851385    {
    13861386      infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)0);
    13871387      if(!DestroyWindow(infoPtr->hWndYearUpDown))
    1388     {
    1389       FIXME("Can't destroy Updown Control\n");
    1390     }
     1388        {
     1389          FIXME("Can't destroy Updown Control\n");
     1390        }
    13911391      else
    1392     infoPtr->hWndYearUpDown=0;
     1392        infoPtr->hWndYearUpDown=0;
    13931393      if(!DestroyWindow(infoPtr->hWndYearEdit))
    1394     {
    1395       FIXME("Can't destroy Updown Control\n");
    1396     }
     1394        {
     1395          FIXME("Can't destroy Updown Control\n");
     1396        }
    13971397      else
    1398     infoPtr->hWndYearEdit=0;
     1398        infoPtr->hWndYearEdit=0;
    13991399      InvalidateRect(hwnd, NULL, FALSE);
    14001400    }
    1401 
     1401 
    14021402  ht.pt.x = (INT)LOWORD(lParam);
    14031403  ht.pt.y = (INT)HIWORD(lParam);
     
    14141414    return TRUE;
    14151415  }
    1416   if(hit == MCHT_TITLEBTNPREV){
     1416  if(hit == MCHT_TITLEBTNPREV){ 
    14171417    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    14181418    infoPtr->status = MC_PREVPRESSED;
     
    14241424  if(hit == MCHT_TITLEMONTH) {
    14251425    hMenu = CreatePopupMenu();
    1426 
     1426   
    14271427    for (i=0; i<12;i++)
    14281428      {
    1429     GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
    1430           buf,sizeof(buf));
    1431     AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
     1429        GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
     1430                  buf,sizeof(buf));
     1431        AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
    14321432      }
    14331433    menupoint.x=infoPtr->titlemonth.right;
     
    14351435    ClientToScreen(hwnd, &menupoint);
    14361436    i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
    1437               menupoint.x,menupoint.y,0,hwnd,NULL);
     1437                      menupoint.x,menupoint.y,0,hwnd,NULL);
    14381438    if ((i>0) && (i<13))
    14391439      {
    1440     infoPtr->currentMonth=i;
    1441     InvalidateRect(hwnd, NULL, FALSE);
     1440        infoPtr->currentMonth=i;
     1441        InvalidateRect(hwnd, NULL, FALSE);
    14421442      }
    14431443  }
    14441444  if(hit == MCHT_TITLEYEAR) {
    14451445    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);
     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);
    14561456    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);
     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);
    14671467    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
    14681468    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 );
    14691469    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)infoPtr->currentYear );
    14701470    return TRUE;
    1471 
     1471         
    14721472  }
    14731473  if(hit == MCHT_TODAYLINK) {
     
    14871487    MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    14881488    MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1489 
     1489       
    14901490    SendMessageA(GetParent(hwnd), WM_NOTIFY,
    14911491           (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
     
    14931493    MONTHCAL_CopyTime(&ht.st, &selArray[0]);
    14941494    MONTHCAL_CopyTime(&ht.st, &selArray[1]);
    1495     MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
     1495    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 
    14961496
    14971497    /* redraw both old and new days if the selected day changed */
     
    15461546    return TRUE;
    15471547  }
    1548   if(hit == MCHT_CALENDARDATEPREV){
     1548  if(hit == MCHT_CALENDARDATEPREV){ 
    15491549    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    15501550    InvalidateRect(hwnd, NULL, FALSE);
     
    15641564  MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    15651565  MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1566 
     1566       
    15671567  SendMessageA(GetParent(hwnd), WM_NOTIFY,
    15681568           (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
    1569 
     1569 
    15701570  /* redraw if necessary */
    15711571  if(redraw)
    15721572    InvalidateRect(hwnd, NULL, FALSE);
    1573 
     1573       
    15741574  return 0;
    15751575}
     
    15861586
    15871587  switch(wParam) {
    1588   case MC_NEXTMONTHTIMER:
     1588  case MC_NEXTMONTHTIMER: 
    15891589    redraw = TRUE;
    15901590    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
     
    16181618  ht.pt.x = LOWORD(lParam);
    16191619  ht.pt.y = HIWORD(lParam);
    1620 
     1620       
    16211621  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
    1622 
     1622 
    16231623  /* not on the calendar date numbers? bail out */
    16241624  TRACE("hit:%x\n",hit);
     
    16381638    if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
    16391639    TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1640     if(infoPtr->firstSelDay==selArray[1].wDay) {
     1640    if(infoPtr->firstSelDay==selArray[1].wDay) { 
    16411641      /* 1st time we get here: selArray[0]=selArray[1])  */
    16421642      /* if we're still at the first selected date, return */
     
    16441644      if(selday<infoPtr->firstSelDay) i = 0;
    16451645    }
    1646 
     1646                       
    16471647    if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
    16481648      if(selday>infoPtr->firstSelDay)
     
    16511651        selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
    16521652    }
    1653 
     1653               
    16541654    if(selArray[i].wDay!=selday) {
    16551655      TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1656 
     1656                       
    16571657      selArray[i].wDay = selday;
    16581658
     
    17121712{
    17131713  TRACE("\n");
    1714 
     1714 
    17151715  InvalidateRect(hwnd, NULL, FALSE);
    17161716
     
    17691769
    17701770  /* 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
     1771  /* FIXME: We use up all available width. This will inhibit having multiple 
     1772     calendars in a row, like win doesn 
    17731773  */
    17741774  if(dwStyle & MCS_WEEKNUMBERS)
     
    17761776  else
    17771777    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;
     1778  infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; 
     1779  infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; 
    17801780  infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv);
    17811781  infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0);
     
    17901790    rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5;
    17911791    }*/
    1792 
     1792   
    17931793  /* calculate title area */
    17941794  title->top    = rcClient->top;
     
    18051805  next->right  = title->right - 6;
    18061806  next->left   = next->right - (title->bottom - title->top);
    1807 
     1807 
    18081808  /* titlemonth->left and right change based upon the current month */
    18091809  /* and are recalculated in refresh as the current month may change */
     
    18111811  titlemonth->top    = titleyear->top    = title->top    + (infoPtr->height_increment)/2;
    18121812  titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
    1813 
     1813 
    18141814  /* setup the dimensions of the rectangle we draw the names of the */
    18151815  /* days of the week in */
    18161816  weeknumrect->left =infoPtr->left_offset;
    1817   if(dwStyle & MCS_WEEKNUMBERS)
     1817  if(dwStyle & MCS_WEEKNUMBERS) 
    18181818    weeknumrect->right=prev->right;
    18191819  else
     
    18231823  wdays->top    = title->bottom ;
    18241824  wdays->bottom = wdays->top + infoPtr->height_increment;
    1825 
     1825 
    18261826  days->top    = weeknumrect->top = wdays->bottom ;
    18271827  days->bottom = weeknumrect->bottom = days->top     + 6 * infoPtr->height_increment;
    1828 
     1828 
    18291829  todayrect->left   = rcClient->left;
    18301830  todayrect->right  = rcClient->right;
     
    18321832  todayrect->bottom = days->bottom + infoPtr->height_increment;
    18331833
    1834   /* uncomment for excessive debugging
     1834  /* uncomment for excessive debugging 
    18351835  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);
     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);
    18421842  */
    1843 
     1843 
    18441844  /* restore the originally selected font */
    1845   SelectObject(hdc, currentFont);
     1845  SelectObject(hdc, currentFont);     
    18461846
    18471847  ReleaseDC(hwnd, hdc);
     
    18651865{
    18661866  MONTHCAL_INFO *infoPtr;
    1867   LOGFONTA  logFont;
     1867  LOGFONTA      logFont;
    18681868
    18691869  /* allocate memory for info structure */
     
    19001900  infoPtr->maxSelCount  = 7;
    19011901  infoPtr->monthRange = 3;
    1902   infoPtr->monthdayState = COMCTL32_Alloc
     1902  infoPtr->monthdayState = COMCTL32_Alloc 
    19031903                         (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    19041904  infoPtr->titlebk     = GetSysColor(COLOR_ACTIVECAPTION);
     
    19071907  infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT);
    19081908  infoPtr->bk          = GetSysColor(COLOR_WINDOW);
    1909   infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
     1909  infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
    19101910
    19111911  /* call MONTHCAL_UpdateSize to set all of the dimensions */
     
    20622062  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    20632063  wndClass.lpszClassName = MONTHCAL_CLASSA;
    2064 
     2064 
    20652065  RegisterClassA(&wndClass);
    20662066}
Note: See TracChangeset for help on using the changeset viewer.