Ignore:
Timestamp:
May 15, 2003, 4:26:27 PM (22 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

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

    r6709 r10098  
    88 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
    99 *
     10 * This library is free software; you can redistribute it and/or
     11 * modify it under the terms of the GNU Lesser General Public
     12 * License as published by the Free Software Foundation; either
     13 * version 2.1 of the License, or (at your option) any later version.
     14 *
     15 * This library is distributed in the hope that it will be useful,
     16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     18 * Lesser General Public License for more details.
     19 *
     20 * You should have received a copy of the GNU Lesser General Public
     21 * License along with this library; if not, write to the Free Software
     22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     23 *
    1024 * TODO:
    1125 *   - Notifications.
     
    1327 *
    1428 *  FIXME: handle resources better (doesn't work now); also take care
    15            of internationalization. 
     29           of internationalization.
    1630 *  FIXME: keyboard handling.
    1731 */
    18 
    19 #ifdef __WIN32OS2__
    20 #include <odin.h>
    21 #include <string.h>
    22 #define inline
    23 #endif
    2432
    2533#include <math.h>
     
    3543#include "commctrl.h"
    3644#include "comctl32.h"
    37 #include "debugtools.h"
    38 
    39 #ifdef __WIN32OS2__
    40 #include "ccbase.h"
    41 #endif
    42 
    43 DEFAULT_DEBUG_CHANNEL(monthcal);
     45#include "wine/debug.h"
     46
     47WINE_DEFAULT_DEBUG_CHANNEL(monthcal);
    4448
    4549#define MC_SEL_LBUTUP       1   /* Left button released */
     
    5155                                                                                /* to the next month */
    5256#define MC_NEXTMONTHTIMER   1                   /* Timer ID's */
    53 #define MC_PREVMONTHTIMER   2                   
     57#define MC_PREVMONTHTIMER   2
    5458
    5559typedef struct
    5660{
    57 #ifdef __WIN32OS2__
    58     COMCTL32_HEADER header;
    59 #endif
    6061    COLORREF    bk;
    6162    COLORREF    txt;
     
    9192    SYSTEMTIME  minDate;
    9293    SYSTEMTIME  maxDate;
    93                
     94
    9495    RECT rcClient;      /* rect for whole client area */
    9596    RECT rcDraw;        /* rect for drawable portion of client area */
    9697    RECT title;         /* rect for the header above the calendar */
    9798    RECT titlebtnnext;  /* the `next month' button in the header */
    98     RECT titlebtnprev;  /* the `prev month' button in the header */     
     99    RECT titlebtnprev;  /* the `prev month' button in the header */
    99100    RECT titlemonth;    /* the `month name' txt in the header */
    100101    RECT titleyear;     /* the `year number' txt in the header */
     
    121122{
    122123const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
    123   /*Wrap around, this eases handleing*/
     124  /*Wrap around, this eases handling*/
    124125  if(month == 0)
    125126    month = 12;
     
    141142
    142143/* make sure that time is valid */
    143 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 
     144static int MONTHCAL_ValidateTime(SYSTEMTIME time)
    144145{
    145146  if(time.wMonth > 12) return FALSE;
     
    156157
    157158
    158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 
     159void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
    159160{
    160161  to->wYear = from->wYear;
     
    169170
    170171
    171 /* Note:Depending on DST, this may be offset by a day. 
     172/* Note:Depending on DST, this may be offset by a day.
    172173   Need to find out if we're on a DST place & adjust the clock accordingly.
    173174   Above function assumes we have a valid data.
     
    182183  year-=(month < 3);
    183184
    184   return((year + year/4 - year/100 + year/400 + 
     185  return((year + year/4 - year/100 + year/400 +
    185186         DayOfWeekTable[month-1] + day - 1 ) % 7);
    186187}
     
    189190   and day in the calendar. day== 0 mean the last day of tha last month
    190191*/
    191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 
    192                                    int *daypos,int *weekpos) 
     192static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y,
     193                                   int *daypos,int *weekpos)
    193194{
    194195  int retval, firstDay;
     
    202203  *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
    203204  *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
    204    
     205
    205206  firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
    206207  retval = *daypos + (7 * *weekpos) - firstDay;
     
    211212/* sets x and y to be the position of the day */
    212213/* x == day, y == week where(0,0) == firstDay, 1st week */
    213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 
     214static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month,
    214215                                 int *x, int *y)
    215216{
     
    227228    if(prevMonth==0)
    228229       prevMonth = 12;
    229    
     230
    230231    *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
    231232    *y = 0;
     
    240241
    241242/* x: column(day), y: row(week) */
    242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 
     243static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
    243244{
    244245  r->left = infoPtr->days.left + x * infoPtr->width_increment;
     
    252253/* day is the day value of the month(1 == 1st), month is the month */
    253254/* value(january == 1, december == 12) */
    254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 
     255static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
    255256                                            int day, int month, RECT *r)
    256257{
     
    278279  x = day_rect.left;
    279280  y = day_rect.top;
    280        
     281
    281282  points[0].x = x;
    282283  points[0].y = y - 1;
     
    287288  points[3].x = x + infoPtr->width_increment;
    288289  points[3].y = y + 0.5 * infoPtr->height_increment;
    289        
     290
    290291  points[4].x = x + infoPtr->width_increment;
    291292  points[4].y = y + 0.9 * infoPtr->height_increment;
     
    295296  points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
    296297                                a hair to fit inside the day rectangle */
    297        
     298
    298299  points[7].x = x + 0.2 * infoPtr->width_increment;
    299300  points[7].y = y + 0.8 * infoPtr->height_increment;
     
    309310  points[12].x = x + 0.4 * infoPtr->width_increment;
    310311  points[12].y = y + 0.2 * infoPtr->height_increment;
    311  
     312
    312313  PolyBezier(hdc, points, 13);
    313314  DeleteObject(hRedPen);
     
    329330  sprintf(buf, "%d", day);
    330331
    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.
    332333 * 1<day<31, so evertyhing's OK.
    333334 */
     
    341342
    342343    TRACE("%d %d %d\n",day, infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
    343     TRACE("%d %d %d %d\n", r.left, r.top, r.right, r.bottom);
     344    TRACE("%ld %ld %ld %ld\n", r.left, r.top, r.right, r.bottom);
    344345    oldCol = SetTextColor(hdc, infoPtr->monthbk);
    345346    oldBk = SetBkColor(hdc, infoPtr->trailingtxt);
     
    390391
    391392/* CHECKME: For `todays date', do we need to check the locale?*/
    392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 
     393static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
    393394{
    394395  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     
    425426  hbr = CreateSolidBrush (infoPtr->bk);
    426427  FillRect(hdc, rcClient, hbr);
    427   DeleteObject(hbr);       
     428  DeleteObject(hbr);
    428429
    429430  /* draw header */
     
    434435    DeleteObject(hbr);
    435436  }
    436        
     437
    437438  /* if the previous button is pressed draw it depressed */
    438439  if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
    439   { 
     440  {
    440441    if((infoPtr->status & MC_PREVPRESSED))
    441442        DrawFrameControl(hdc, prev, DFC_SCROLL,
     
    447448  }
    448449
    449   /* if next button is depressed draw it depressed */   
     450  /* if next button is depressed draw it depressed */
    450451  if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
    451452  {
     
    466467  titlemonth->left   = title->left;
    467468  titlemonth->right  = title->right;
    468  
     469
    469470  GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
    470471                  buf1,sizeof(buf1));
    471472  sprintf(buf, "%s %ld", buf1, infoPtr->currentYear);
    472  
     473
    473474  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
    474475  {
    475     DrawTextA(hdc, buf, strlen(buf), titlemonth, 
     476    DrawTextA(hdc, buf, strlen(buf), titlemonth,
    476477                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    477478  }
     
    481482/* titlemonth left/right contained rect for whole titletxt('June  1999')
    482483  * 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)
    484485  */
    485486  GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
     
    489490  titlemonth->right = titlemonth->left + size.cx;
    490491  titleyear->left = titlemonth->right;
    491  
     492
    492493  /* draw month area */
    493494  rcTemp.top=infoPtr->wdays.top;
     
    501502    DeleteObject(hbr);
    502503  }
    503        
     504
    504505/* draw line under day abbreviatons */
    505506
    506507  MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
    507      
     508
    508509  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
    509  
     510
    510511  prevMonth = infoPtr->currentMonth - 1;
    511512  if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
     
    537538
    538539/* draw day numbers; first, the previous month */
    539  
     540
    540541  firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
    541  
    542   day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  + 
     542
     543  day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  +
    543544    (infoPtr->firstDay + 7  - firstDay)%7 + 1;
    544545  if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
     
    553554    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    554555    {
    555       MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 
     556      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
    556557          infoPtr->monthdayState[m] & mask);
    557558    }
     
    577578    {
    578579
    579       MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 
     580      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
    580581        infoPtr->monthdayState[m] & mask);
    581582
     
    595596  j = 1; /* move to the 2nd week of the current month */
    596597  i = 0; /* move back to sunday */
    597   while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {     
     598  while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
    598599    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    599600    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     
    604605      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    605606          (day==infoPtr->todaysDate.wDay) &&
    606           (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 
    607         if(!(dwStyle & MCS_NOTODAYCIRCLE)) 
     607          (infoPtr->currentYear == infoPtr->todaysDate.wYear))
     608        if(!(dwStyle & MCS_NOTODAYCIRCLE))
    608609          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    609610    }
     
    627628    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    628629    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    629     {   
     630    {
    630631      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
    631632                infoPtr->monthdayState[m] & mask);
     
    634635    mask<<=1;
    635636    day++;
    636     i++;       
     637    i++;
    637638    if(i==7) { /* past saturday, go to next week's sunday */
    638639      i = 0;
     
    650651    if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
    651652      /*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), 
     653      MONTHCAL_CircleDay(hdc, infoPtr,
     654                         day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
    654655                         infoPtr->currentMonth);
    655656      offset+=textWidth;
     
    674675  }
    675676
    676 /*eventually draw week numbers*/   
     677/*eventually draw week numbers*/
    677678  if(dwStyle & MCS_WEEKNUMBERS)  {
    678679    /* display weeknumbers*/
     
    682683       LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
    683684       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):
    685686       First week of year must contain 4 days of the new year
    686687       LOCALE_IFIRSTWEEKOFYEAR == 1  (what contries?)
     
    704705        /* calculate all those exceptions for january */
    705706        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
    706         if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays) 
     707        if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
    707708            weeknum =1;
    708709        else
    709710          {
    710711            weeknum = 0;
    711             for(i=0; i<11; i++) 
     712            for(i=0; i<11; i++)
    712713              weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
    713714            weeknum +=startofprescal+ 7;
     
    721722      {
    722723        weeknum = 0;
    723         for(i=0; i<prevMonth-1; i++) 
     724        for(i=0; i<prevMonth-1; i++)
    724725          weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
    725726        weeknum +=startofprescal+ 7;
     
    749750      days->bottom+=infoPtr->height_increment;
    750751    }
    751                        
     752
    752753    MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
    753754    LineTo(hdc,   infoPtr->weeknums.right, infoPtr->weeknums.bottom );
    754                
     755
    755756  }
    756757  /* currentFont was font at entering Refresh */
    757758
    758759  SetBkColor(hdc, oldBkColor);
    759   SelectObject(hdc, currentFont);     
     760  SelectObject(hdc, currentFont);
    760761  SetTextColor(hdc, oldTextColor);
    761762}
    762763
    763764
    764 static LRESULT 
     765static LRESULT
    765766MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    766767{
     
    768769  LPRECT lpRect = (LPRECT) lParam;
    769770  TRACE("%x %lx\n", wParam, lParam);
    770        
     771
    771772  /* validate parameters */
    772773
     
    781782
    782783
    783 static LRESULT 
     784static LRESULT
    784785MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    785786{
     
    807808
    808809
    809 static LRESULT 
     810static LRESULT
    810811MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    811812{
     
    847848
    848849
    849 static LRESULT 
     850static LRESULT
    850851MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    851852{
     
    853854
    854855  TRACE("%x %lx\n", wParam, lParam);
    855  
     856
    856857  if(infoPtr->delta)
    857858    return infoPtr->delta;
     
    861862
    862863
    863 static LRESULT 
     864static LRESULT
    864865MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    865866{
     
    868869
    869870  TRACE("%x %lx\n", wParam, lParam);
    870        
     871
    871872  infoPtr->delta = (int)wParam;
    872873  return prev;
     
    874875
    875876
    876 static LRESULT 
     877static LRESULT
    877878MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    878879{
    879880  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
    880        
     881
    881882  return infoPtr->firstDay;
    882883}
     
    887888/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
    888889/* FIXME: we need more error checking here */
    889 static LRESULT 
     890static LRESULT
    890891MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    891892{
     
    916917/* FIXME: fill this in */
    917918static LRESULT
    918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 
     919MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    919920{
    920921  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
     
    937938
    938939/* FIXME: are validated times taken from current date/time or simply
    939  * copied? 
     940 * copied?
    940941 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
    941942 *            adjusting range with MCM_SETRANGE
     
    950951
    951952  TRACE("%x %lx\n", wParam, lParam);
    952  
     953
    953954  if(wParam & GDTR_MAX) {
    954955    if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     
    973974  infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
    974975
    975   if(infoPtr->monthRange!=prev) { 
    976         COMCTL32_ReAlloc(infoPtr->monthdayState,
    977                 infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     976  if(infoPtr->monthRange!=prev) {
     977        infoPtr->monthdayState = COMCTL32_ReAlloc(infoPtr->monthdayState,
     978                                                  infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    978979  }
    979980
     
    983984
    984985/* 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
    986987 * SetRange.  Is this the right behavior?
    987988*/
     
    10151016  if(iMonths!=infoPtr->monthRange) return 0;
    10161017
    1017   for(i=0; i<iMonths; i++) 
     1018  for(i=0; i<iMonths; i++)
    10181019    infoPtr->monthdayState[i] = dayStates[i];
    10191020  return 1;
    10201021}
    10211022
    1022 static LRESULT 
     1023static LRESULT
    10231024MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10241025{
     
    10361037/* FIXME: if the specified date is not visible, make it visible */
    10371038/* FIXME: redraw? */
    1038 static LRESULT 
     1039static LRESULT
    10391040MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10401041{
     
    10571058
    10581059
    1059 static LRESULT 
     1060static LRESULT
    10601061MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10611062{
     
    10671068
    10681069
    1069 static LRESULT 
     1070static LRESULT
    10701071MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10711072{
     
    10811082
    10821083
    1083 static LRESULT 
     1084static LRESULT
    10841085MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10851086{
     
    11001101    return TRUE;
    11011102  }
    1102  
     1103
    11031104  return FALSE;
    11041105}
    11051106
    11061107
    1107 static LRESULT 
     1108static LRESULT
    11081109MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11091110{
     
    11241125    return TRUE;
    11251126  }
    1126  
     1127
    11271128  return FALSE;
    11281129}
    11291130
    11301131
    1131 static LRESULT 
     1132static LRESULT
    11321133MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11331134{
     
    11451146
    11461147
    1147 static LRESULT 
     1148static LRESULT
    11481149MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11491150{
     
    11701171  DWORD retval;
    11711172  int day,wday,wnum;
    1172  
    1173  
     1173
     1174
    11741175  x = lpht->pt.x;
    11751176  y = lpht->pt.y;
    11761177  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, 
     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,
    11811182        infoPtr->wdays.left, infoPtr->wdays.right,
    11821183        infoPtr->wdays.top, infoPtr->wdays.bottom,
     
    11901191
    11911192  /* are we in the header? */
    1192  
     1193
    11931194  if(PtInRect(&infoPtr->title, lpht->pt)) {
    11941195    if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
     
    12081209      goto done;
    12091210    }
    1210    
     1211
    12111212    retval = MCHT_TITLE;
    12121213    goto done;
    12131214  }
    1214  
     1215
    12151216  day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
    12161217  if(PtInRect(&infoPtr->wdays, lpht->pt)) {
     
    12181219    lpht->st.wYear  = infoPtr->currentYear;
    12191220    lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
    1220     lpht->st.wDay   = (day < 1)? 
     1221    lpht->st.wDay   = (day < 1)?
    12211222      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
    12221223    goto done;
    12231224  }
    1224   if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 
    1225     retval = MCHT_CALENDARWEEKNUM; 
     1225  if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
     1226    retval = MCHT_CALENDARWEEKNUM;
    12261227    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)) ?
    12291230      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)) ?
    12331234      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))
    12371238    {
    12381239      lpht->st.wYear  = infoPtr->currentYear;
    1239       if ( day < 1) 
     1240      if ( day < 1)
    12401241        {
    12411242          retval = MCHT_CALENDARDATEPREV;
     
    12671268    }
    12681269  if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
    1269     retval = MCHT_TODAYLINK; 
     1270    retval = MCHT_TODAYLINK;
    12701271    goto done;
    12711272  }
    1272  
    1273  
     1273
     1274
    12741275  /* Hit nothing special? What's left must be background :-) */
    1275  
    1276   retval = MCHT_CALENDARBK;       
    1277  done: 
     1276
     1277  retval = MCHT_CALENDARBK;
     1278 done:
    12781279  lpht->uHit = retval;
    12791280  return retval;
     
    13311332    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    13321333    nmds.cDayState      = infoPtr->monthRange;
    1333     nmds.prgDayState    = COMCTL32_Alloc 
     1334    nmds.prgDayState    = COMCTL32_Alloc
    13341335                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13351336
     
    13481349  POINT menupoint;
    13491350  char buf[32];
    1350  
     1351
    13511352  hMenu = CreatePopupMenu();
    13521353  if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf)))
     
    13651366      infoPtr->currentYear=infoPtr->todaysDate.wYear;
    13661367      InvalidateRect(hwnd, NULL, FALSE);
    1367     }   
     1368    }
    13681369  return 0;
    13691370}
     
    13811382  POINT menupoint;
    13821383  TRACE("%x %lx\n", wParam, lParam);
    1383        
     1384
    13841385  if (infoPtr->hWndYearUpDown)
    13851386    {
     
    13991400      InvalidateRect(hwnd, NULL, FALSE);
    14001401    }
    1401  
     1402
    14021403  ht.pt.x = (INT)LOWORD(lParam);
    14031404  ht.pt.y = (INT)HIWORD(lParam);
     
    14141415    return TRUE;
    14151416  }
    1416   if(hit == MCHT_TITLEBTNPREV){ 
     1417  if(hit == MCHT_TITLEBTNPREV){
    14171418    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    14181419    infoPtr->status = MC_PREVPRESSED;
     
    14241425  if(hit == MCHT_TITLEMONTH) {
    14251426    hMenu = CreatePopupMenu();
    1426    
     1427
    14271428    for (i=0; i<12;i++)
    14281429      {
     
    14511452                         infoPtr->textHeight,
    14521453                         hwnd,
    1453                          (HMENU)NULL,
    1454                          (HINSTANCE)NULL,
     1454                         NULL,
     1455                         NULL,
    14551456                         NULL);
    14561457    infoPtr->hWndYearUpDown=CreateWindowExA(0,
     
    14621463                         infoPtr->textHeight,
    14631464                         hwnd,
    1464                          (HMENU)NULL,
    1465                          (HINSTANCE)NULL,
     1465                         NULL,
     1466                         NULL,
    14661467                         NULL);
    14671468    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
     
    14691470    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)infoPtr->currentYear );
    14701471    return TRUE;
    1471          
     1472
    14721473  }
    14731474  if(hit == MCHT_TODAYLINK) {
     
    14871488    MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    14881489    MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1489        
     1490
    14901491    SendMessageA(GetParent(hwnd), WM_NOTIFY,
    14911492           (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
     
    14931494    MONTHCAL_CopyTime(&ht.st, &selArray[0]);
    14941495    MONTHCAL_CopyTime(&ht.st, &selArray[1]);
    1495     MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 
     1496    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
    14961497
    14971498    /* redraw both old and new days if the selected day changed */
     
    15461547    return TRUE;
    15471548  }
    1548   if(hit == MCHT_CALENDARDATEPREV){ 
     1549  if(hit == MCHT_CALENDARDATEPREV){
    15491550    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    15501551    InvalidateRect(hwnd, NULL, FALSE);
     
    15541555  nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
    15551556  nmhdr.code     = NM_RELEASEDCAPTURE;
    1556   TRACE("Sent notification from %x to %x\n", hwnd, GetParent(hwnd));
     1557  TRACE("Sent notification from %p to %p\n", hwnd, GetParent(hwnd));
    15571558
    15581559  SendMessageA(GetParent(hwnd), WM_NOTIFY,
     
    15641565  MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    15651566  MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1566        
     1567
    15671568  SendMessageA(GetParent(hwnd), WM_NOTIFY,
    15681569           (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
    1569  
     1570
    15701571  /* redraw if necessary */
    15711572  if(redraw)
    15721573    InvalidateRect(hwnd, NULL, FALSE);
    1573        
     1574
    15741575  return 0;
    15751576}
     
    15861587
    15871588  switch(wParam) {
    1588   case MC_NEXTMONTHTIMER: 
     1589  case MC_NEXTMONTHTIMER:
    15891590    redraw = TRUE;
    15901591    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
     
    16181619  ht.pt.x = LOWORD(lParam);
    16191620  ht.pt.y = HIWORD(lParam);
    1620        
     1621
    16211622  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
    1622  
     1623
    16231624  /* not on the calendar date numbers? bail out */
    16241625  TRACE("hit:%x\n",hit);
     
    16381639    if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
    16391640    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) {
    16411642      /* 1st time we get here: selArray[0]=selArray[1])  */
    16421643      /* if we're still at the first selected date, return */
     
    16441645      if(selday<infoPtr->firstSelDay) i = 0;
    16451646    }
    1646                        
     1647
    16471648    if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
    16481649      if(selday>infoPtr->firstSelDay)
     
    16511652        selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
    16521653    }
    1653                
     1654
    16541655    if(selArray[i].wDay!=selday) {
    16551656      TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1656                        
     1657
    16571658      selArray[i].wDay = selday;
    16581659
     
    17121713{
    17131714  TRACE("\n");
    1714  
     1715
    17151716  InvalidateRect(hwnd, NULL, FALSE);
    17161717
     
    17691770
    17701771  /* 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
    17731774  */
    17741775  if(dwStyle & MCS_WEEKNUMBERS)
     
    17761777  else
    17771778    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;
    17801781  infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv);
    17811782  infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0);
     
    17901791    rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5;
    17911792    }*/
    1792    
     1793
    17931794  /* calculate title area */
    17941795  title->top    = rcClient->top;
     
    18051806  next->right  = title->right - 6;
    18061807  next->left   = next->right - (title->bottom - title->top);
    1807  
     1808
    18081809  /* titlemonth->left and right change based upon the current month */
    18091810  /* and are recalculated in refresh as the current month may change */
     
    18111812  titlemonth->top    = titleyear->top    = title->top    + (infoPtr->height_increment)/2;
    18121813  titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
    1813  
     1814
    18141815  /* setup the dimensions of the rectangle we draw the names of the */
    18151816  /* days of the week in */
    18161817  weeknumrect->left =infoPtr->left_offset;
    1817   if(dwStyle & MCS_WEEKNUMBERS) 
     1818  if(dwStyle & MCS_WEEKNUMBERS)
    18181819    weeknumrect->right=prev->right;
    18191820  else
     
    18231824  wdays->top    = title->bottom ;
    18241825  wdays->bottom = wdays->top + infoPtr->height_increment;
    1825  
     1826
    18261827  days->top    = weeknumrect->top = wdays->bottom ;
    18271828  days->bottom = weeknumrect->bottom = days->top     + 6 * infoPtr->height_increment;
    1828  
     1829
    18291830  todayrect->left   = rcClient->left;
    18301831  todayrect->right  = rcClient->right;
     
    18321833  todayrect->bottom = days->bottom + infoPtr->height_increment;
    18331834
    1834   /* uncomment for excessive debugging 
     1835  /* uncomment for excessive debugging
    18351836  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",
    18361837        infoPtr->width_increment,infoPtr->height_increment,
     
    18411842        todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
    18421843  */
    1843  
     1844
    18441845  /* restore the originally selected font */
    1845   SelectObject(hdc, currentFont);     
     1846  SelectObject(hdc, currentFont);
    18461847
    18471848  ReleaseDC(hwnd, hdc);
     
    18501851static LRESULT MONTHCAL_Size(HWND hwnd, int Width, int Height)
    18511852{
    1852   TRACE("(hwnd=%x, width=%d, height=%d)\n", hwnd, Width, Height);
     1853  TRACE("(hwnd=%p, width=%d, height=%d)\n", hwnd, Width, Height);
    18531854
    18541855  MONTHCAL_UpdateSize(hwnd);
     
    18681869
    18691870  /* allocate memory for info structure */
    1870 #ifdef __WIN32OS2__
    1871   infoPtr =(MONTHCAL_INFO*)initControl(hwnd,sizeof(MONTHCAL_INFO));
    1872 #else
    18731871  infoPtr =(MONTHCAL_INFO*)COMCTL32_Alloc(sizeof(MONTHCAL_INFO));
    1874 #endif
    18751872  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    18761873
     
    19001897  infoPtr->maxSelCount  = 7;
    19011898  infoPtr->monthRange = 3;
    1902   infoPtr->monthdayState = COMCTL32_Alloc 
     1899  infoPtr->monthdayState = COMCTL32_Alloc
    19031900                         (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    19041901  infoPtr->titlebk     = GetSysColor(COLOR_ACTIVECAPTION);
     
    19231920
    19241921  /* free month calendar info data */
     1922  if(infoPtr->monthdayState)
     1923      COMCTL32_Free(infoPtr->monthdayState);
    19251924  COMCTL32_Free(infoPtr);
    19261925  SetWindowLongA(hwnd, 0, 0);
     
    19321931MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    19331932{
    1934   TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
     1933  TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
    19351934  if (!MONTHCAL_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
    19361935    return DefWindowProcA(hwnd, uMsg, wParam, lParam);
     
    20372036
    20382037  default:
    2039     if(uMsg >= WM_USER)
     2038    if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    20402039      ERR( "unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
    2041 #ifdef __WIN32OS2__
    2042     return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);
    2043 #else
    20442040    return DefWindowProcA(hwnd, uMsg, wParam, lParam);
    2045 #endif
    20462041  }
    20472042  return 0;
     
    20622057  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    20632058  wndClass.lpszClassName = MONTHCAL_CLASSA;
    2064  
     2059
    20652060  RegisterClassA(&wndClass);
    20662061}
     
    20702065MONTHCAL_Unregister(void)
    20712066{
    2072     UnregisterClassA(MONTHCAL_CLASSA, (HINSTANCE)NULL);
    2073 }
     2067    UnregisterClassA(MONTHCAL_CLASSA, NULL);
     2068}
Note: See TracChangeset for help on using the changeset viewer.