Changeset 10097 for trunk/src/comctl32/datetime.c
- Timestamp:
- May 15, 2003, 4:25:14 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/datetime.c
r6709 r10097 6 6 * Copyright 2000 Chris Morgan <cmorgan@wpi.edu> 7 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 8 21 * 9 22 * TODO: … … 20 33 #include "wingdi.h" 21 34 #include "commctrl.h" 22 #include "debugtools.h" 23 24 #ifdef __WIN32OS2__ 25 #include "ccbase.h" 26 #define inline 27 #endif 28 29 DEFAULT_DEBUG_CHANNEL(datetime); 35 #include "wine/debug.h" 36 37 WINE_DEFAULT_DEBUG_CHANNEL(datetime); 30 38 31 39 typedef struct 32 40 { 33 #ifdef __WIN32OS2__34 COMCTL32_HEADER header;35 #endif36 41 HWND hMonthCal; 37 42 HWND hUpdown; … … 51 56 int *fieldspec; 52 57 RECT *fieldRect; 53 int *buflen; 58 int *buflen; 54 59 char textbuf[256]; 55 60 POINT monthcal_pos; … … 61 66 /* this list of defines is closely related to `allowedformatchars' defined 62 67 * in datetime.c; the high nibble indicates the `base type' of the format 63 * specifier. 68 * specifier. 64 69 * Do not change without first reading DATETIME_UseFormat. 65 * 70 * 66 71 */ 67 72 68 #define DT_END_FORMAT 0 73 #define DT_END_FORMAT 0 69 74 #define ONEDIGITDAY 0x01 70 75 #define TWODIGITDAY 0x02 … … 87 92 #define ONEDIGITYEAR 0x71 88 93 #define TWODIGITYEAR 0x72 89 # ifdef __WIN32OS2__94 #define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */ 90 95 #define FULLYEAR 0x74 91 #else92 #define FULLYEAR 0x7393 #endif94 96 #define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */ 95 97 #define FORMATCALLMASK 0x80 … … 109 111 extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to); 110 112 static const char *allowedformatchars = {"dhHmMstyX'"}; 111 #ifdef __WIN32OS2__112 113 static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1}; 113 //DT all wine xxx.nls contains yyyy for FULLYEAR 114 #else 115 static const int maxrepetition [] = {4,2,2,2,4,2,2,3,-1,-1}; 116 #endif 114 117 115 118 116 static LRESULT … … 126 124 if (!lParam) return GDT_NONE; 127 125 128 if ((dwStyle & DTS_SHOWNONE) && 129 (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) ))126 if ((dwStyle & DTS_SHOWNONE) && 127 (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED)) 130 128 return GDT_NONE; 131 129 … … 142 140 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 143 141 144 TRACE("% 04x %08lx\n",wParam,lParam);142 TRACE("%p %04x %08lx\n",hwnd, wParam, lParam); 145 143 if (!lParam) return 0; 146 144 147 if (lParam==GDT_VALID) 148 MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); 149 if (lParam==GDT_NONE) { 150 infoPtr->dateValid=FALSE; 151 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0); 152 } 145 TRACE("%04d/%02d/%02d %02d:%02d:%02d)\n", 146 lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay, 147 lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond); 148 149 if (wParam==GDT_VALID) { 150 infoPtr->dateValid = TRUE; 151 MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); 152 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); 153 } else if (wParam==GDT_NONE) { 154 infoPtr->dateValid = FALSE; 155 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0); 156 } 157 InvalidateRect(hwnd, NULL, TRUE); 153 158 return 1; 154 159 } 160 155 161 156 162 static LRESULT … … 203 209 204 210 TRACE("\n"); 205 return infoPtr->hMonthCal;211 return (LRESULT)infoPtr->hMonthCal; 206 212 } 207 213 … … 228 234 229 235 230 /* 231 Split up a formattxt in actions. 236 /* 237 Split up a formattxt in actions. 232 238 See ms documentation for the meaning of the letter codes/'specifiers'. 233 239 234 Notes: 240 Notes: 235 241 *'dddddd' is handled as 'dddd' plus 'dd'. 236 *unrecognized formats are strings (here given the type DT_STRING; 242 *unrecognized formats are strings (here given the type DT_STRING; 237 243 start of the string is encoded in lower bits of DT_STRING. 238 244 Therefore, 'string' ends finally up as '<show seconds>tring'. … … 241 247 242 248 243 static void 249 static void 244 250 DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt) 245 251 { … … 258 264 TRACE ("\n%d %c:",i, formattxt[i]); 259 265 for (j=0; j<len; j++) { 260 if (allowedformatchars[j]==formattxt[i]) { 266 if (allowedformatchars[j]==formattxt[i]) { 261 267 TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields, 262 268 infoPtr->fieldspec[*nrFields]); … … 265 271 break; 266 272 } 267 if (infoPtr->fieldspec[*nrFields]>>4!=j) { 268 (*nrFields)++; 273 if (infoPtr->fieldspec[*nrFields]>>4!=j) { 274 (*nrFields)++; 269 275 infoPtr->fieldspec[*nrFields]=(j<<4) +1; 270 276 break; 271 277 } 272 278 if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) { 273 (*nrFields)++; 279 (*nrFields)++; 274 280 infoPtr->fieldspec[*nrFields]=(j<<4) +1; 275 281 break; … … 286 292 infoPtr->fieldspec[*nrFields]=DT_STRING+k; 287 293 infoPtr->buflen[*nrFields]=0; 288 } else 294 } else 289 295 if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING) { 290 296 (*nrFields)++; 291 297 infoPtr->fieldspec[*nrFields]=DT_STRING+k; 292 298 infoPtr->buflen[*nrFields]=0; 293 } 299 } 294 300 infoPtr->textbuf[k]=formattxt[i]; 295 301 k++; … … 309 315 310 316 311 static LRESULT 317 static LRESULT 312 318 DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 313 319 { … … 320 326 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 321 327 322 if (dwStyle & DTS_LONGDATEFORMAT) 328 if (dwStyle & DTS_LONGDATEFORMAT) 323 329 format_item=LOCALE_SLONGDATE; 324 else if (dwStyle & DTS_TIMEFORMAT) 330 else if (dwStyle & DTS_TIMEFORMAT) 325 331 format_item=LOCALE_STIMEFORMAT; 326 332 else /* DTS_SHORTDATEFORMAT */ … … 328 334 GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf)); 329 335 DATETIME_UseFormat (infoPtr, format_buf); 330 } 336 } 331 337 else 332 338 DATETIME_UseFormat (infoPtr, (char *) lParam); … … 336 342 337 343 338 static LRESULT 344 static LRESULT 339 345 DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam) 340 346 … … 351 357 COMCTL32_Free (buf); 352 358 return retval; 353 } 359 } 354 360 else 355 361 return DATETIME_SetFormat (hwnd, 0, 0); … … 358 364 359 365 360 static void 361 DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result )366 static void 367 DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result, int resultSize) 362 368 { 363 369 SYSTEMTIME date = infoPtr->date; … … 373 379 374 380 if (!infoPtr->fieldspec) return; 375 381 376 382 spec=infoPtr->fieldspec[count]; 377 383 if (spec & DT_STRING) { 378 384 int txtlen=infoPtr->buflen[count]; 379 385 380 strncpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen); 386 if (txtlen > resultSize) 387 txtlen = resultSize - 1; 388 memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen); 381 389 result[txtlen]=0; 382 390 TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result); … … 384 392 } 385 393 386 394 387 395 switch (spec) { 388 case DT_END_FORMAT: 396 case DT_END_FORMAT: 389 397 *result=0; 390 398 break; 391 case ONEDIGITDAY: 399 case ONEDIGITDAY: 392 400 sprintf (result,"%d",date.wDay); 393 401 break; 394 case TWODIGITDAY: 402 case TWODIGITDAY: 395 403 sprintf (result,"%.2d",date.wDay); 396 404 break; 397 case THREECHARDAY: 405 case THREECHARDAY: 398 406 GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7, 399 407 result,4); … … 402 410 case FULLDAY: 403 411 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7, 404 buffer,sizeof(buffer)); 405 strcpy (result,buffer); 406 break; 407 case ONEDIGIT12HOUR: 408 if (date.wHour>12) 412 result, resultSize); 413 break; 414 case ONEDIGIT12HOUR: 415 if (date.wHour>12) 409 416 sprintf (result,"%d",date.wHour-12); 410 else 417 else 411 418 sprintf (result,"%d",date.wHour); 412 419 break; 413 case TWODIGIT12HOUR: 414 if (date.wHour>12) 420 case TWODIGIT12HOUR: 421 if (date.wHour>12) 415 422 sprintf (result,"%.2d",date.wHour-12); 416 else 423 else 417 424 sprintf (result,"%.2d",date.wHour); 418 425 break; 419 case ONEDIGIT24HOUR: 426 case ONEDIGIT24HOUR: 420 427 sprintf (result,"%d",date.wHour); 421 428 break; 422 case TWODIGIT24HOUR: 429 case TWODIGIT24HOUR: 423 430 sprintf (result,"%.2d",date.wHour); 424 431 break; 425 case ONEDIGITSECOND: 432 case ONEDIGITSECOND: 426 433 sprintf (result,"%d",date.wSecond); 427 434 break; 428 case TWODIGITSECOND: 435 case TWODIGITSECOND: 429 436 sprintf (result,"%.2d",date.wSecond); 430 437 break; 431 case ONEDIGITMINUTE: 438 case ONEDIGITMINUTE: 432 439 sprintf (result,"%d",date.wMinute); 433 440 break; 434 case TWODIGITMINUTE: 441 case TWODIGITMINUTE: 435 442 sprintf (result,"%.2d",date.wMinute); 436 443 break; 437 case ONEDIGITMONTH: 444 case ONEDIGITMONTH: 438 445 sprintf (result,"%d",date.wMonth); 439 446 break; 440 case TWODIGITMONTH: 447 case TWODIGITMONTH: 441 448 sprintf (result,"%.2d",date.wMonth); 442 449 break; 443 case THREECHARMONTH: 450 case THREECHARMONTH: 444 451 GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1, 445 452 buffer,sizeof(buffer)); 446 453 sprintf (result,"%.3s",buffer); 447 454 break; 448 case FULLMONTH: 455 case FULLMONTH: 449 456 GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1, 450 457 #ifdef __WIN32OS2__ … … 452 459 strcpy (result,buffer); 453 460 #else 454 result,sizeof(result));461 result, resultSize); 455 462 #endif 456 463 break; 457 case ONELETTERAMPM: 458 if (date.wHour<12) 464 case ONELETTERAMPM: 465 if (date.wHour<12) 459 466 strcpy (result,"A"); 460 else 467 else 461 468 strcpy (result,"P"); 462 469 break; 463 case TWOLETTERAMPM: 464 if (date.wHour<12) 470 case TWOLETTERAMPM: 471 if (date.wHour<12) 465 472 strcpy (result,"AM"); 466 else 473 else 467 474 strcpy (result,"PM"); 468 475 break; 469 case FORMATCALLBACK: 476 case FORMATCALLBACK: 470 477 FIXME ("Not implemented\n"); 471 478 strcpy (result,"xxx"); 472 479 break; 473 case ONEDIGITYEAR: 480 case ONEDIGITYEAR: 474 481 sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10)); 475 482 break; 476 case TWODIGITYEAR: 483 case TWODIGITYEAR: 477 484 sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100)); 478 485 break; 479 case FULLYEAR: 486 case INVALIDFULLYEAR: 487 case FULLYEAR: 480 488 sprintf (result,"%d",date.wYear); 481 489 break; 482 490 } 483 491 484 492 TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result); 485 493 } 486 494 487 495 488 static void 496 static void 489 497 DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number) 490 498 { … … 497 505 spec=infoPtr->fieldspec[number]; 498 506 if ((spec & DTHT_DATEFIELD)==0) return; 499 507 500 508 switch (spec) { 501 case ONEDIGITDAY: 502 case TWODIGITDAY: 503 case THREECHARDAY: 509 case ONEDIGITDAY: 510 case TWODIGITDAY: 511 case THREECHARDAY: 504 512 case FULLDAY: 505 513 date->wDay++; 506 514 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 507 date->wDay=1; 508 break; 509 case ONEDIGIT12HOUR: 510 case TWODIGIT12HOUR: 511 case ONEDIGIT24HOUR: 512 case TWODIGIT24HOUR: 515 date->wDay=1; 516 break; 517 case ONEDIGIT12HOUR: 518 case TWODIGIT12HOUR: 519 case ONEDIGIT24HOUR: 520 case TWODIGIT24HOUR: 513 521 date->wHour++; 514 522 if (date->wHour>23) date->wHour=0; 515 523 break; 516 case ONEDIGITSECOND: 517 case TWODIGITSECOND: 524 case ONEDIGITSECOND: 525 case TWODIGITSECOND: 518 526 date->wSecond++; 519 527 if (date->wSecond>59) date->wSecond=0; 520 528 break; 521 case ONEDIGITMINUTE: 522 case TWODIGITMINUTE: 529 case ONEDIGITMINUTE: 530 case TWODIGITMINUTE: 523 531 date->wMinute++; 524 532 if (date->wMinute>59) date->wMinute=0; 525 533 break; 526 case ONEDIGITMONTH: 527 case TWODIGITMONTH: 528 case THREECHARMONTH: 529 case FULLMONTH: 534 case ONEDIGITMONTH: 535 case TWODIGITMONTH: 536 case THREECHARMONTH: 537 case FULLMONTH: 530 538 date->wMonth++; 531 539 if (date->wMonth>12) date->wMonth=1; 532 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 540 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 533 541 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); 534 542 break; 535 case ONELETTERAMPM: 536 case TWOLETTERAMPM: 543 case ONELETTERAMPM: 544 case TWOLETTERAMPM: 537 545 date->wHour+=12; 538 546 if (date->wHour>23) date->wHour-=24; 539 547 break; 540 case FORMATCALLBACK: 548 case FORMATCALLBACK: 541 549 FIXME ("Not implemented\n"); 542 550 break; 543 case ONEDIGITYEAR: 544 case TWODIGITYEAR: 545 case FULLYEAR: 551 case ONEDIGITYEAR: 552 case TWODIGITYEAR: 553 case FULLYEAR: 546 554 date->wYear++; 547 555 break; … … 551 559 552 560 553 static void 561 static void 554 562 DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number) 555 563 { … … 562 570 spec = infoPtr->fieldspec[number]; 563 571 if ((spec & DTHT_DATEFIELD)==0) return; 564 572 565 573 TRACE ("%x\n",spec); 566 574 567 575 switch (spec) { 568 case ONEDIGITDAY: 569 case TWODIGITDAY: 570 case THREECHARDAY: 576 case ONEDIGITDAY: 577 case TWODIGITDAY: 578 case THREECHARDAY: 571 579 case FULLDAY: 572 580 date->wDay--; 573 if (date->wDay<1) 581 if (date->wDay<1) 574 582 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); 575 583 break; 576 case ONEDIGIT12HOUR: 577 case TWODIGIT12HOUR: 578 case ONEDIGIT24HOUR: 579 case TWODIGIT24HOUR: 580 if (date->wHour) 584 case ONEDIGIT12HOUR: 585 case TWODIGIT12HOUR: 586 case ONEDIGIT24HOUR: 587 case TWODIGIT24HOUR: 588 if (date->wHour) 581 589 date->wHour--; 582 590 else 583 591 date->wHour=23; 584 592 break; 585 case ONEDIGITSECOND: 586 case TWODIGITSECOND: 587 if (date->wHour) 593 case ONEDIGITSECOND: 594 case TWODIGITSECOND: 595 if (date->wHour) 588 596 date->wSecond--; 589 597 else 590 598 date->wHour=59; 591 599 break; 592 case ONEDIGITMINUTE: 593 case TWODIGITMINUTE: 594 if (date->wMinute) 600 case ONEDIGITMINUTE: 601 case TWODIGITMINUTE: 602 if (date->wMinute) 595 603 date->wMinute--; 596 604 else 597 605 date->wMinute=59; 598 606 break; 599 case ONEDIGITMONTH: 600 case TWODIGITMONTH: 601 case THREECHARMONTH: 602 case FULLMONTH: 603 if (date->wMonth>1) 607 case ONEDIGITMONTH: 608 case TWODIGITMONTH: 609 case THREECHARMONTH: 610 case FULLMONTH: 611 if (date->wMonth>1) 604 612 date->wMonth--; 605 613 else 606 614 date->wMonth=12; 607 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 615 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 608 616 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); 609 617 break; 610 case ONELETTERAMPM: 611 case TWOLETTERAMPM: 612 if (date->wHour<12) 618 case ONELETTERAMPM: 619 case TWOLETTERAMPM: 620 if (date->wHour<12) 613 621 date->wHour+=12; 614 622 else 615 623 date->wHour-=12; 616 624 break; 617 case FORMATCALLBACK: 625 case FORMATCALLBACK: 618 626 FIXME ("Not implemented\n"); 619 627 break; 620 case ONEDIGITYEAR: 621 case TWODIGITYEAR: 622 case FULLYEAR: 628 case ONEDIGITYEAR: 629 case TWODIGITYEAR: 630 case FULLYEAR: 623 631 date->wYear--; 624 632 break; … … 628 636 629 637 630 static void 638 static void 631 639 DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number) 632 640 { … … 639 647 spec = infoPtr->fieldspec[number]; 640 648 if ((spec & DTHT_DATEFIELD)==0) return; 641 649 642 650 643 651 switch (spec) { 644 case ONEDIGITDAY: 645 case TWODIGITDAY: 646 case THREECHARDAY: 652 case ONEDIGITDAY: 653 case TWODIGITDAY: 654 case THREECHARDAY: 647 655 case FULLDAY: 648 656 date->wDay = 1; 649 657 break; 650 case ONEDIGIT12HOUR: 651 case TWODIGIT12HOUR: 652 case ONEDIGIT24HOUR: 653 case TWODIGIT24HOUR: 654 case ONELETTERAMPM: 655 case TWOLETTERAMPM: 658 case ONEDIGIT12HOUR: 659 case TWODIGIT12HOUR: 660 case ONEDIGIT24HOUR: 661 case TWODIGIT24HOUR: 662 case ONELETTERAMPM: 663 case TWOLETTERAMPM: 656 664 date->wHour = 0; 657 665 break; 658 case ONEDIGITSECOND: 659 case TWODIGITSECOND: 666 case ONEDIGITSECOND: 667 case TWODIGITSECOND: 660 668 date->wSecond = 0; 661 669 break; 662 case ONEDIGITMINUTE: 663 case TWODIGITMINUTE: 670 case ONEDIGITMINUTE: 671 case TWODIGITMINUTE: 664 672 date->wMinute = 0; 665 673 break; 666 case ONEDIGITMONTH: 667 case TWODIGITMONTH: 668 case THREECHARMONTH: 669 case FULLMONTH: 674 case ONEDIGITMONTH: 675 case TWODIGITMONTH: 676 case THREECHARMONTH: 677 case FULLMONTH: 670 678 date->wMonth = 1; 671 case FORMATCALLBACK: 679 case FORMATCALLBACK: 672 680 FIXME ("Not implemented\n"); 673 681 break; 674 case ONEDIGITYEAR: 675 case TWODIGITYEAR: 676 /* FYI: On 9/14/1752 the calender changed and England and the American */ 677 /* colonies changed to the Gregorian calender. This change involved */ 678 /* having September 14th following September 2nd. So no date algorithms */ 679 /* work before that date. */ 680 case FULLYEAR: 682 case ONEDIGITYEAR: 683 case TWODIGITYEAR: 684 /* FYI: On 1752/9/14 the calendar changed and England and the 685 * American colonies changed to the Gregorian calendar. This change 686 * involved having September 14th follow September 2nd. So no date 687 * algorithm works before that date. 688 */ 689 case FULLYEAR: 681 690 date->wSecond = 0; 682 691 date->wMinute = 0; … … 691 700 692 701 693 static void 702 static void 694 703 DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number) 695 704 { … … 702 711 spec=infoPtr->fieldspec[number]; 703 712 if ((spec & DTHT_DATEFIELD)==0) return; 704 713 705 714 switch (spec) { 706 case ONEDIGITDAY: 707 case TWODIGITDAY: 708 case THREECHARDAY: 715 case ONEDIGITDAY: 716 case TWODIGITDAY: 717 case THREECHARDAY: 709 718 case FULLDAY: 710 719 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); 711 720 break; 712 case ONEDIGIT12HOUR: 713 case TWODIGIT12HOUR: 714 case ONEDIGIT24HOUR: 715 case TWODIGIT24HOUR: 716 case ONELETTERAMPM: 717 case TWOLETTERAMPM: 721 case ONEDIGIT12HOUR: 722 case TWODIGIT12HOUR: 723 case ONEDIGIT24HOUR: 724 case TWODIGIT24HOUR: 725 case ONELETTERAMPM: 726 case TWOLETTERAMPM: 718 727 date->wHour=23; 719 728 break; 720 case ONEDIGITSECOND: 721 case TWODIGITSECOND: 729 case ONEDIGITSECOND: 730 case TWODIGITSECOND: 722 731 date->wSecond=59; 723 732 break; 724 case ONEDIGITMINUTE: 725 case TWODIGITMINUTE: 733 case ONEDIGITMINUTE: 734 case TWODIGITMINUTE: 726 735 date->wMinute=59; 727 736 break; 728 case ONEDIGITMONTH: 729 case TWODIGITMONTH: 730 case THREECHARMONTH: 731 case FULLMONTH: 737 case ONEDIGITMONTH: 738 case TWODIGITMONTH: 739 case THREECHARMONTH: 740 case FULLMONTH: 732 741 date->wMonth=12; 733 case FORMATCALLBACK: 742 case FORMATCALLBACK: 734 743 FIXME ("Not implemented\n"); 735 744 break; 736 case ONEDIGITYEAR: 737 case TWODIGITYEAR: 738 case FULLYEAR: 745 case ONEDIGITYEAR: 746 case TWODIGITYEAR: 747 case FULLYEAR: 739 748 date->wYear=9999; /* Y10K problem? naaah. */ 740 749 break; … … 758 767 SIZE size; 759 768 COLORREF oldBk, oldTextColor; 760 769 761 770 /* draw control edge */ 762 771 TRACE("\n"); … … 764 773 FillRect(hdc, rcClient, hbr); 765 774 DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT); 766 DeleteObject(hbr); 767 775 DeleteObject(hbr); 776 768 777 if (infoPtr->dateValid) { 769 778 char txt[80]; … … 771 780 oldFont = SelectObject (hdc, infoPtr->hFont); 772 781 773 DATETIME_ReturnTxt (infoPtr, 0, txt );782 DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)); 774 783 GetTextExtentPoint32A (hdc, txt, strlen (txt), &size); 775 784 rcDraw->bottom = size.cy+2; … … 780 789 781 790 for (i=0; i<infoPtr->nrFields; i++) { 782 DATETIME_ReturnTxt (infoPtr, i, txt );791 DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt)); 783 792 GetTextExtentPoint32A (hdc, txt, strlen (txt), &size); 784 793 field = & infoPtr->fieldRect[i]; … … 832 841 if (PtInRect (&infoPtr->fieldRect[i], pt)) { 833 842 retval = i; 834 TRACE("Hit in date text in field %d\n", i); 843 TRACE("Hit in date text in field %d\n", i); 835 844 break; 836 845 } … … 845 854 DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 846 855 { 847 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 856 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 848 857 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 849 858 int old, new; … … 867 876 if (infoPtr->select == DTHT_MCPOPUP) { 868 877 /* FIXME: button actually is only depressed during dropdown of the */ 869 /* calend er control and when the mouse is over the button window */878 /* calendar control and when the mouse is over the button window */ 870 879 infoPtr->bCalDepressed = TRUE; 871 880 … … 874 883 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - 875 884 infoPtr->calbutton.left) + 145); 876 else 885 else 877 886 infoPtr->monthcal_pos.x = 8; 878 887 … … 887 896 ShowWindow(infoPtr->hMonthCal, SW_SHOW); 888 897 889 TRACE ("dt:% x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n",890 hwnd,infoPtr->hMonthCal, 898 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p, mcpp:%p\n", 899 hwnd,infoPtr->hMonthCal, 891 900 GetParent (infoPtr->hMonthCal), 892 901 GetDesktopWindow (), … … 904 913 DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) 905 914 { 906 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 915 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 907 916 908 917 TRACE("\n"); 909 918 910 919 if(infoPtr->bCalDepressed == TRUE) { 911 920 infoPtr->bCalDepressed = FALSE; … … 932 941 933 942 static LRESULT 943 DATETIME_Button_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) 944 { 945 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd); 946 947 switch(HIWORD(wParam)) { 948 case BN_CLICKED: 949 { 950 DWORD state = SendMessageA((HWND)lParam, BM_GETCHECK, 0, 0); 951 if(state == BST_CHECKED) 952 infoPtr->dateValid = TRUE; 953 else 954 infoPtr->dateValid = FALSE; 955 InvalidateRect(hwnd, NULL, TRUE); 956 return 0; 957 } 958 default: 959 return 0; 960 } 961 } 962 963 964 965 static LRESULT 966 DATETIME_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) 967 { 968 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd); 969 970 TRACE("%08x %08lx\n", wParam, lParam); 971 TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut); 972 if(infoPtr->hwndCheckbut == (HWND)lParam) 973 return DATETIME_Button_Command(hwnd, wParam, lParam); 974 return 0; 975 } 976 977 static LRESULT 934 978 DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) 935 979 { 936 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 980 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 937 981 LPNMHDR lpnmh = (LPNMHDR) lParam; 938 982 … … 943 987 #else 944 988 TRACE ("%x,%lx\n",wParam, lParam); 945 TRACE ("Got notification %x from % x\n", lpnmh->code, lpnmh->hwndFrom);989 TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom); 946 990 #endif 947 TRACE ("info: % x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);991 TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); 948 992 return 0; 949 993 } … … 954 998 955 999 { 956 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1000 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 957 1001 LPNMHDR lpnmh = (LPNMHDR) lParam; 958 1002 959 1003 TRACE ("%x,%lx\n",wParam, lParam); 960 TRACE ("Got notification %x from % x\n", lpnmh->code, lpnmh->hwndFrom);961 TRACE ("info: % x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);1004 TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom); 1005 TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); 962 1006 return 0; 963 1007 } 964 1008 965 1009 966 static LRESULT 1010 static LRESULT 967 1011 DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 968 1012 { … … 983 1027 switch (wParam) { 984 1028 case VK_ADD: 985 case VK_UP: 1029 case VK_UP: 986 1030 DATETIME_IncreaseField (infoPtr,FieldNum); 987 1031 DATETIME_SendDateTimeChangeNotify (hwnd); … … 1000 1044 DATETIME_SendDateTimeChangeNotify (hwnd); 1001 1045 break; 1002 case VK_LEFT: 1046 case VK_LEFT: 1003 1047 do { 1004 1048 if (infoPtr->select==0) { 1005 1049 infoPtr->select = infoPtr->nrFields - 1; 1006 1050 wrap++; 1007 } else 1051 } else 1008 1052 infoPtr->select--; 1009 1053 } 1010 1054 while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); 1011 1055 break; 1012 case VK_RIGHT: 1056 case VK_RIGHT: 1013 1057 do { 1014 1058 infoPtr->select++; … … 1031 1075 DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1032 1076 { 1033 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1077 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1034 1078 1035 1079 TRACE ("\n"); … … 1049 1093 DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1050 1094 { 1051 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1095 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1052 1096 1053 1097 TRACE ("\n"); 1054 1098 1055 1099 if (infoPtr->haveFocus==0) { 1056 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 1100 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 1057 1101 infoPtr->haveFocus = DTHT_GOTFOCUS; 1058 1102 } … … 1068 1112 1069 1113 { 1070 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1114 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1071 1115 NMDATETIMECHANGE dtdtc; 1072 1116 … … 1111 1155 infoPtr->rcClient.right = LOWORD(lParam); 1112 1156 1113 TRACE("Height=% d, Width=%d\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);1157 TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); 1114 1158 1115 1159 /* use DrawEdge to adjust the size of rcEdge to get rcDraw */ 1116 1160 memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw)); 1117 1161 1118 DrawEdge( (HDC)NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST);1119 1120 /* set the size of the button that drops the calend er down */1162 DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST); 1163 1164 /* set the size of the button that drops the calendar down */ 1121 1165 /* FIXME: account for style that allows button on left side */ 1122 1166 infoPtr->calbutton.top = infoPtr->rcDraw.top; … … 1136 1180 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - 1137 1181 infoPtr->calbutton.left) + 145); 1138 else 1182 else 1139 1183 infoPtr->monthcal_pos.x = 8; 1140 1184 … … 1159 1203 /* allocate memory for info structure */ 1160 1204 TRACE("%04x %08lx\n",wParam,lParam); 1161 #ifdef __WIN32OS2__1162 infoPtr = (DATETIME_INFO*)initControl(hwnd,sizeof(DATETIME_INFO));1163 #else1164 1205 infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO)); 1165 #endif1166 1206 if (infoPtr == NULL) { 1167 1207 ERR("could not allocate info memory!\n"); … … 1172 1212 1173 1213 if (dwStyle & DTS_SHOWNONE) { 1174 infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, 1175 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 1214 infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, 1215 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 1176 1216 2,2,13,13, 1177 hwnd, 1178 0, GetWindowLongA (hwnd, GWL_HINSTANCE), 0);1217 hwnd, 1218 0, (HINSTANCE)GetWindowLongA (hwnd, GWL_HINSTANCE), 0); 1179 1219 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0); 1180 1220 } … … 1196 1236 1197 1237 /* create the monthcal control */ 1198 infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0, 1238 infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0, 1199 1239 WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS, 1200 1240 0, 0, 0, 0, 1201 GetParent(hwnd), 1241 GetParent(hwnd), 1202 1242 0, 0, 0); 1203 1243 … … 1214 1254 { 1215 1255 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1216 1256 1217 1257 TRACE("\n"); 1218 1258 COMCTL32_Free (infoPtr); … … 1225 1265 DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1226 1266 { 1227 1228 1267 if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) 1229 1268 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 1230 1269 1231 1270 switch (uMsg) 1232 1271 { … … 1301 1340 return DATETIME_Destroy (hwnd, wParam, lParam); 1302 1341 1342 case WM_COMMAND: 1343 return DATETIME_Command (hwnd, wParam, lParam); 1344 1303 1345 default: 1304 if ( uMsg >= WM_USER)1346 if ((uMsg >= WM_USER) && (uMsg < WM_APP)) 1305 1347 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 1306 1348 uMsg, wParam, lParam); 1307 #ifdef __WIN32OS2__1308 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);1309 #else1310 1349 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1311 #endif1312 1350 } 1313 1351 return 0; … … 1329 1367 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 1330 1368 wndClass.lpszClassName = DATETIMEPICK_CLASSA; 1331 1369 1332 1370 RegisterClassA (&wndClass); 1333 1371 } … … 1338 1376 { 1339 1377 TRACE("\n"); 1340 UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL); 1341 } 1342 1343 1378 UnregisterClassA (DATETIMEPICK_CLASSA, NULL); 1379 }
Note:
See TracChangeset
for help on using the changeset viewer.