1998-11-08 12:30:27 +01:00
|
|
|
/*
|
|
|
|
* Date and time picker control
|
|
|
|
*
|
1999-03-12 18:42:50 +01:00
|
|
|
* Copyright 1998, 1999 Eric Kohl
|
2000-02-03 01:48:39 +01:00
|
|
|
* Copyright 1999, 2000 Alex Priem <alexp@sci.kun.nl>
|
2000-05-30 22:06:54 +02:00
|
|
|
* Copyright 2000 Chris Morgan <cmorgan@wpi.edu>
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - All messages.
|
|
|
|
* - All notifications.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-03-16 11:53:11 +01:00
|
|
|
#include "winbase.h"
|
2000-05-30 22:06:54 +02:00
|
|
|
#include "wingdi.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
#include "commctrl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(datetime);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
HWND hMonthCal;
|
|
|
|
HWND hUpdown;
|
|
|
|
SYSTEMTIME date;
|
|
|
|
BOOL dateValid;
|
|
|
|
HWND hwndCheckbut;
|
|
|
|
RECT rcClient; /* rect around the edge of the window */
|
|
|
|
RECT rcDraw; /* rect inside of the border */
|
|
|
|
RECT checkbox; /* checkbox allowing the control to be enabled/disabled */
|
|
|
|
RECT calbutton; /* button that toggles the dropdown of the monthcal control */
|
|
|
|
BOOL bCalDepressed; /* TRUE = cal button is depressed */
|
|
|
|
int select;
|
|
|
|
HFONT hFont;
|
|
|
|
int nrFieldsAllocated;
|
|
|
|
int nrFields;
|
|
|
|
int haveFocus;
|
|
|
|
int *fieldspec;
|
|
|
|
RECT *fieldRect;
|
2002-06-01 01:06:46 +02:00
|
|
|
int *buflen;
|
2000-08-09 02:41:17 +02:00
|
|
|
char textbuf[256];
|
|
|
|
POINT monthcal_pos;
|
|
|
|
} DATETIME_INFO, *LPDATETIME_INFO;
|
|
|
|
|
|
|
|
/* in monthcal.c */
|
2000-10-15 02:28:00 +02:00
|
|
|
extern int MONTHCAL_MonthLength(int month, int year);
|
2000-08-09 02:41:17 +02:00
|
|
|
|
|
|
|
/* this list of defines is closely related to `allowedformatchars' defined
|
|
|
|
* in datetime.c; the high nibble indicates the `base type' of the format
|
2002-06-01 01:06:46 +02:00
|
|
|
* specifier.
|
2000-08-09 02:41:17 +02:00
|
|
|
* Do not change without first reading DATETIME_UseFormat.
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2000-08-09 02:41:17 +02:00
|
|
|
*/
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
#define DT_END_FORMAT 0
|
2000-08-09 02:41:17 +02:00
|
|
|
#define ONEDIGITDAY 0x01
|
|
|
|
#define TWODIGITDAY 0x02
|
|
|
|
#define THREECHARDAY 0x03
|
|
|
|
#define FULLDAY 0x04
|
|
|
|
#define ONEDIGIT12HOUR 0x11
|
|
|
|
#define TWODIGIT12HOUR 0x12
|
|
|
|
#define ONEDIGIT24HOUR 0x21
|
|
|
|
#define TWODIGIT24HOUR 0x22
|
|
|
|
#define ONEDIGITMINUTE 0x31
|
|
|
|
#define TWODIGITMINUTE 0x32
|
|
|
|
#define ONEDIGITMONTH 0x41
|
|
|
|
#define TWODIGITMONTH 0x42
|
|
|
|
#define THREECHARMONTH 0x43
|
|
|
|
#define FULLMONTH 0x44
|
|
|
|
#define ONEDIGITSECOND 0x51
|
|
|
|
#define TWODIGITSECOND 0x52
|
|
|
|
#define ONELETTERAMPM 0x61
|
|
|
|
#define TWOLETTERAMPM 0x62
|
|
|
|
#define ONEDIGITYEAR 0x71
|
|
|
|
#define TWODIGITYEAR 0x72
|
2003-05-14 00:04:40 +02:00
|
|
|
#define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
|
|
|
|
#define FULLYEAR 0x74
|
2000-08-09 02:41:17 +02:00
|
|
|
#define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */
|
|
|
|
#define FORMATCALLMASK 0x80
|
|
|
|
#define DT_STRING 0x0100
|
|
|
|
|
|
|
|
#define DTHT_DATEFIELD 0xff /* for hit-testing */
|
|
|
|
|
|
|
|
#define DTHT_NONE 0
|
|
|
|
#define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
|
|
|
|
#define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
|
|
|
|
#define DTHT_GOTFOCUS 0x400 /* tests for date-fields */
|
1999-07-31 13:12:45 +02:00
|
|
|
|
1999-03-12 18:42:50 +01:00
|
|
|
#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongA (hwnd, 0))
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
static BOOL DATETIME_SendSimpleNotify (HWND hwnd, UINT code);
|
|
|
|
static BOOL DATETIME_SendDateTimeChangeNotify (HWND hwnd);
|
|
|
|
extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to);
|
|
|
|
static const char *allowedformatchars = {"dhHmMstyX'"};
|
2003-05-14 00:04:40 +02:00
|
|
|
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1};
|
2000-02-03 01:48:39 +01:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|
|
|
SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
if (!lParam) return GDT_NONE;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if ((dwStyle & DTS_SHOWNONE) &&
|
2003-05-14 00:04:40 +02:00
|
|
|
(SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
|
1999-07-31 13:12:45 +02:00
|
|
|
return GDT_NONE;
|
|
|
|
|
|
|
|
MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
|
|
|
|
|
|
|
|
return GDT_VALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
|
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
TRACE("%p %04x %08lx\n",hwnd, wParam, lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
if (!lParam) return 0;
|
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
TRACE("%04d/%02d/%02d %02d:%02d:%02d)\n",
|
|
|
|
lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
|
|
|
|
lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
|
|
|
|
|
|
|
|
if (wParam==GDT_VALID) {
|
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
|
|
|
|
SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
} else if (wParam==GDT_NONE) {
|
|
|
|
infoPtr->dateValid = FALSE;
|
|
|
|
SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
|
|
|
|
}
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
1999-07-31 13:12:45 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-25 22:38:20 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_GetRange (HWND hwnd, LPARAM lParam )
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
TRACE("%08lx\n", lParam);
|
|
|
|
ret = SendMessageA (infoPtr->hMonthCal, MCM_GETRANGE, 0, lParam);
|
|
|
|
if (!ret) ret = 1; /* bug emulation... */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
|
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
|
|
|
|
|
|
|
return SendMessageA (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x\n",wParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: need to get way to force font into monthcal structure */
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_GetMonthCal (HWND hwnd)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
2002-09-06 21:41:17 +02:00
|
|
|
return (LRESULT)infoPtr->hMonthCal;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: need to get way to force font into monthcal structure */
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_GetMonthCalFont (HWND hwnd)
|
|
|
|
{
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
1999-07-31 13:12:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
|
|
|
Split up a formattxt in actions.
|
2000-02-03 01:48:39 +01:00
|
|
|
See ms documentation for the meaning of the letter codes/'specifiers'.
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
Notes:
|
2000-02-03 01:48:39 +01:00
|
|
|
*'dddddd' is handled as 'dddd' plus 'dd'.
|
2002-06-01 01:06:46 +02:00
|
|
|
*unrecognized formats are strings (here given the type DT_STRING;
|
2000-02-03 01:48:39 +01:00
|
|
|
start of the string is encoded in lower bits of DT_STRING.
|
|
|
|
Therefore, 'string' ends finally up as '<show seconds>tring'.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt)
|
|
|
|
{
|
|
|
|
int i,j,k,len;
|
|
|
|
int *nrFields=& infoPtr->nrFields;
|
|
|
|
|
|
|
|
TRACE ("%s\n",formattxt);
|
|
|
|
|
|
|
|
|
|
|
|
*nrFields=0;
|
|
|
|
infoPtr->fieldspec[*nrFields]=0;
|
|
|
|
len=strlen(allowedformatchars);
|
|
|
|
k=0;
|
|
|
|
|
|
|
|
for (i=0; i<strlen (formattxt); i++) {
|
|
|
|
TRACE ("\n%d %c:",i, formattxt[i]);
|
|
|
|
for (j=0; j<len; j++) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if (allowedformatchars[j]==formattxt[i]) {
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
|
|
|
|
infoPtr->fieldspec[*nrFields]);
|
|
|
|
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
|
|
|
|
infoPtr->fieldspec[*nrFields]=(j<<4) +1;
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (infoPtr->fieldspec[*nrFields]>>4!=j) {
|
|
|
|
(*nrFields)++;
|
2000-02-03 01:48:39 +01:00
|
|
|
infoPtr->fieldspec[*nrFields]=(j<<4) +1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
|
2002-06-01 01:06:46 +02:00
|
|
|
(*nrFields)++;
|
2000-02-03 01:48:39 +01:00
|
|
|
infoPtr->fieldspec[*nrFields]=(j<<4) +1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
infoPtr->fieldspec[*nrFields]++;
|
|
|
|
break;
|
|
|
|
} /* if allowedformatchar */
|
|
|
|
} /* for j */
|
|
|
|
|
|
|
|
|
|
|
|
/* char is not a specifier: handle char like a string */
|
|
|
|
if (j==len) {
|
|
|
|
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
|
|
|
|
infoPtr->fieldspec[*nrFields]=DT_STRING+k;
|
|
|
|
infoPtr->buflen[*nrFields]=0;
|
2002-06-01 01:06:46 +02:00
|
|
|
} else
|
2000-02-03 01:48:39 +01:00
|
|
|
if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields]=DT_STRING+k;
|
|
|
|
infoPtr->buflen[*nrFields]=0;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
infoPtr->textbuf[k]=formattxt[i];
|
|
|
|
k++;
|
|
|
|
infoPtr->buflen[*nrFields]++;
|
|
|
|
} /* if j=len */
|
|
|
|
|
|
|
|
if (*nrFields==infoPtr->nrFieldsAllocated) {
|
|
|
|
FIXME ("out of memory; should reallocate. crash ahead.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* for i */
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (infoPtr->fieldspec[*nrFields]!=0) (*nrFields)++;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr= DATETIME_GetInfoPtr (hwnd);
|
2000-10-15 02:28:00 +02:00
|
|
|
char format_buf[80];
|
|
|
|
DWORD format_item;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
if (!lParam) {
|
|
|
|
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwStyle & DTS_LONGDATEFORMAT)
|
2000-10-15 02:28:00 +02:00
|
|
|
format_item=LOCALE_SLONGDATE;
|
2002-06-01 01:06:46 +02:00
|
|
|
else if (dwStyle & DTS_TIMEFORMAT)
|
2000-10-15 02:28:00 +02:00
|
|
|
format_item=LOCALE_STIMEFORMAT;
|
2000-05-30 22:06:54 +02:00
|
|
|
else /* DTS_SHORTDATEFORMAT */
|
2000-10-15 02:28:00 +02:00
|
|
|
format_item=LOCALE_SSHORTDATE;
|
|
|
|
GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
|
|
|
|
DATETIME_UseFormat (infoPtr, format_buf);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
else
|
|
|
|
DATETIME_UseFormat (infoPtr, (char *) lParam);
|
|
|
|
|
|
|
|
return infoPtr->nrFields;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
|
|
{
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
if (lParam) {
|
|
|
|
LPSTR buf;
|
|
|
|
int retval;
|
2000-11-28 23:40:56 +01:00
|
|
|
int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
buf = (LPSTR) COMCTL32_Alloc (len);
|
2000-11-28 23:40:56 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL );
|
2000-02-03 01:48:39 +01:00
|
|
|
retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
|
|
|
|
COMCTL32_Free (buf);
|
|
|
|
return retval;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
else
|
|
|
|
return DATETIME_SetFormat (hwnd, 0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2003-04-03 01:25:01 +02:00
|
|
|
DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result, int resultSize)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
|
|
|
SYSTEMTIME date = infoPtr->date;
|
|
|
|
int spec;
|
2000-10-15 02:28:00 +02:00
|
|
|
char buffer[80];
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
*result=0;
|
|
|
|
TRACE ("%d,%d\n", infoPtr->nrFields, count);
|
|
|
|
if ((count>infoPtr->nrFields) || (count<0)) {
|
|
|
|
WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!infoPtr->fieldspec) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
spec=infoPtr->fieldspec[count];
|
|
|
|
if (spec & DT_STRING) {
|
|
|
|
int txtlen=infoPtr->buflen[count];
|
|
|
|
|
2003-04-03 01:25:01 +02:00
|
|
|
if (txtlen > resultSize)
|
|
|
|
txtlen = resultSize - 1;
|
|
|
|
memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
|
2000-02-03 01:48:39 +01:00
|
|
|
result[txtlen]=0;
|
|
|
|
TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case DT_END_FORMAT:
|
2000-02-03 01:48:39 +01:00
|
|
|
*result=0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wDay);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wDay);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case THREECHARDAY:
|
2000-10-15 02:28:00 +02:00
|
|
|
GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
|
|
|
|
result,4);
|
|
|
|
/*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2000-10-15 02:28:00 +02:00
|
|
|
case FULLDAY:
|
|
|
|
GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
|
2003-04-03 01:25:01 +02:00
|
|
|
result, resultSize);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
if (date.wHour>12)
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wHour-12);
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
if (date.wHour>12)
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wHour-12);
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT24HOUR:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGIT24HOUR:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wSecond);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITSECOND:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wSecond);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wMinute);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITMINUTE:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wMinute);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wMonth);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITMONTH:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wMonth);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case THREECHARMONTH:
|
2000-10-15 02:28:00 +02:00
|
|
|
GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
|
2003-04-03 01:25:01 +02:00
|
|
|
buffer,sizeof(buffer));
|
2000-10-15 02:28:00 +02:00
|
|
|
sprintf (result,"%.3s",buffer);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLMONTH:
|
2000-10-15 02:28:00 +02:00
|
|
|
GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
|
2003-04-03 01:25:01 +02:00
|
|
|
result, resultSize);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONELETTERAMPM:
|
|
|
|
if (date.wHour<12)
|
2000-02-03 01:48:39 +01:00
|
|
|
strcpy (result,"A");
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-02-03 01:48:39 +01:00
|
|
|
strcpy (result,"P");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWOLETTERAMPM:
|
|
|
|
if (date.wHour<12)
|
2000-02-03 01:48:39 +01:00
|
|
|
strcpy (result,"AM");
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-02-03 01:48:39 +01:00
|
|
|
strcpy (result,"PM");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
strcpy (result,"xxx");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
|
|
|
|
break;
|
2003-05-14 00:04:40 +02:00
|
|
|
case INVALIDFULLYEAR:
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
sprintf (result,"%d",date.wYear);
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number)
|
|
|
|
{
|
|
|
|
SYSTEMTIME *date = &infoPtr->date;
|
|
|
|
int spec;
|
|
|
|
|
|
|
|
TRACE ("%d\n",number);
|
|
|
|
if ((number>infoPtr->nrFields) || (number<0)) return;
|
|
|
|
|
|
|
|
spec=infoPtr->fieldspec[number];
|
|
|
|
if ((spec & DTHT_DATEFIELD)==0) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case THREECHARDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
case FULLDAY:
|
|
|
|
date->wDay++;
|
2000-10-15 02:28:00 +02:00
|
|
|
if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
|
2002-06-01 01:06:46 +02:00
|
|
|
date->wDay=1;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wHour++;
|
|
|
|
if (date->wHour>23) date->wHour=0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wSecond++;
|
|
|
|
if (date->wSecond>59) date->wSecond=0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMinute++;
|
|
|
|
if (date->wMinute>59) date->wMinute=0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMonth++;
|
|
|
|
if (date->wMonth>12) date->wMonth=1;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
|
2000-10-15 02:28:00 +02:00
|
|
|
date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wHour+=12;
|
|
|
|
if (date->wHour>23) date->wHour-=24;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
|
|
|
case FULLYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wYear++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number)
|
|
|
|
{
|
|
|
|
SYSTEMTIME *date = & infoPtr->date;
|
|
|
|
int spec;
|
|
|
|
|
|
|
|
TRACE ("%d\n",number);
|
|
|
|
if ((number>infoPtr->nrFields) || (number<0)) return;
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
spec = infoPtr->fieldspec[number];
|
2000-02-03 01:48:39 +01:00
|
|
|
if ((spec & DTHT_DATEFIELD)==0) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("%x\n",spec);
|
|
|
|
|
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case THREECHARDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
case FULLDAY:
|
|
|
|
date->wDay--;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (date->wDay<1)
|
2000-10-15 02:28:00 +02:00
|
|
|
date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
|
|
|
if (date->wHour)
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wHour--;
|
|
|
|
else
|
|
|
|
date->wHour=23;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
|
|
|
if (date->wHour)
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wSecond--;
|
|
|
|
else
|
|
|
|
date->wHour=59;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
|
|
|
if (date->wMinute)
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMinute--;
|
|
|
|
else
|
|
|
|
date->wMinute=59;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
|
|
|
if (date->wMonth>1)
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMonth--;
|
|
|
|
else
|
|
|
|
date->wMonth=12;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
|
2000-10-15 02:28:00 +02:00
|
|
|
date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
|
|
|
if (date->wHour<12)
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wHour+=12;
|
|
|
|
else
|
|
|
|
date->wHour-=12;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
|
|
|
case FULLYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wYear--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number)
|
|
|
|
{
|
|
|
|
SYSTEMTIME *date = &infoPtr->date;
|
|
|
|
int spec;
|
|
|
|
|
|
|
|
TRACE ("%d\n",number);
|
|
|
|
if ((number>infoPtr->nrFields) || (number<0)) return;
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
spec = infoPtr->fieldspec[number];
|
2000-02-03 01:48:39 +01:00
|
|
|
if ((spec & DTHT_DATEFIELD)==0) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case THREECHARDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
case FULLDAY:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wDay = 1;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wHour = 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wSecond = 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wMinute = 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wMonth = 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
|
|
|
/* FYI: On 1752/9/14 the calendar changed and England and the
|
|
|
|
* American colonies changed to the Gregorian calendar. This change
|
|
|
|
* involved having September 14th follow September 2nd. So no date
|
2001-07-17 02:40:30 +02:00
|
|
|
* algorithm works before that date.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLYEAR:
|
2000-05-30 22:06:54 +02:00
|
|
|
date->wSecond = 0;
|
|
|
|
date->wMinute = 0;
|
|
|
|
date->wHour = 0;
|
|
|
|
date->wDay = 14; /* overactive ms-programmers..*/
|
|
|
|
date->wMonth = 9;
|
|
|
|
date->wYear = 1752;
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number)
|
|
|
|
{
|
|
|
|
SYSTEMTIME *date = & infoPtr->date;
|
|
|
|
int spec;
|
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%d \n",number);
|
2000-02-03 01:48:39 +01:00
|
|
|
if ((number>infoPtr->nrFields) || (number<0)) return;
|
|
|
|
|
|
|
|
spec=infoPtr->fieldspec[number];
|
|
|
|
if ((spec & DTHT_DATEFIELD)==0) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case THREECHARDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
case FULLDAY:
|
2000-10-15 02:28:00 +02:00
|
|
|
date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
|
2000-02-03 01:48:39 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wHour=23;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wSecond=59;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMinute=59;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wMonth=12;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
|
|
|
case FULLYEAR:
|
2000-02-03 01:48:39 +01:00
|
|
|
date->wYear=9999; /* Y10K problem? naaah. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static void DATETIME_Refresh (HWND hwnd, HDC hdc)
|
|
|
|
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-02-03 01:48:39 +01:00
|
|
|
int i,prevright;
|
|
|
|
RECT *field;
|
1999-07-31 13:12:45 +02:00
|
|
|
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
2000-05-30 22:06:54 +02:00
|
|
|
RECT *rcDraw = &infoPtr->rcDraw;
|
|
|
|
RECT *rcClient = &infoPtr->rcClient;
|
|
|
|
RECT *calbutton = &infoPtr->calbutton;
|
|
|
|
RECT *checkbox = &infoPtr->checkbox;
|
2000-02-03 01:48:39 +01:00
|
|
|
HBRUSH hbr;
|
1999-07-31 13:12:45 +02:00
|
|
|
SIZE size;
|
2000-02-03 01:48:39 +01:00
|
|
|
COLORREF oldBk, oldTextColor;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* draw control edge */
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
2000-05-30 22:06:54 +02:00
|
|
|
hbr = CreateSolidBrush(RGB(255, 255, 255));
|
|
|
|
FillRect(hdc, rcClient, hbr);
|
|
|
|
DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteObject(hbr);
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
if (infoPtr->dateValid) {
|
|
|
|
char txt[80];
|
2000-05-30 22:06:54 +02:00
|
|
|
HFONT oldFont;
|
|
|
|
oldFont = SelectObject (hdc, infoPtr->hFont);
|
|
|
|
|
2003-04-03 01:25:01 +02:00
|
|
|
DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt));
|
2000-05-30 22:06:54 +02:00
|
|
|
GetTextExtentPoint32A (hdc, txt, strlen (txt), &size);
|
|
|
|
rcDraw->bottom = size.cy+2;
|
|
|
|
|
|
|
|
if (dwStyle & DTS_SHOWNONE) checkbox->right = 18;
|
|
|
|
|
|
|
|
prevright = checkbox->right;
|
|
|
|
|
|
|
|
for (i=0; i<infoPtr->nrFields; i++) {
|
2003-04-03 01:25:01 +02:00
|
|
|
DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt));
|
2000-05-30 22:06:54 +02:00
|
|
|
GetTextExtentPoint32A (hdc, txt, strlen (txt), &size);
|
|
|
|
field = & infoPtr->fieldRect[i];
|
|
|
|
field->left = prevright;
|
|
|
|
field->right = prevright+size.cx;
|
|
|
|
field->top = rcDraw->top;
|
|
|
|
field->bottom = rcDraw->bottom;
|
|
|
|
prevright = field->right;
|
|
|
|
|
|
|
|
if ((infoPtr->haveFocus) && (i==infoPtr->select)) {
|
|
|
|
hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION));
|
|
|
|
FillRect(hdc, field, hbr);
|
|
|
|
oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION));
|
|
|
|
oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW));
|
|
|
|
DeleteObject (hbr);
|
|
|
|
DrawTextA ( hdc, txt, strlen(txt), field,
|
|
|
|
DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
|
|
|
|
SetBkColor (hdc, oldBk);
|
2000-02-03 01:48:39 +01:00
|
|
|
SetTextColor (hdc, oldTextColor);
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawTextA ( hdc, txt, strlen(txt), field,
|
1999-07-31 13:12:45 +02:00
|
|
|
DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
SelectObject (hdc, oldFont);
|
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
if (!(dwStyle & DTS_UPDOWN)) {
|
|
|
|
DrawFrameControl(hdc, calbutton, DFC_SCROLL,
|
|
|
|
DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) |
|
|
|
|
(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
|
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_HitTest (HWND hwnd, DATETIME_INFO *infoPtr, POINT pt)
|
|
|
|
{
|
2000-05-30 22:06:54 +02:00
|
|
|
int i, retval;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
TRACE ("%ld, %ld\n",pt.x,pt.y);
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
retval = DTHT_NONE;
|
|
|
|
if (PtInRect (&infoPtr->calbutton, pt))
|
|
|
|
{retval = DTHT_MCPOPUP; TRACE("Hit in calbutton(DTHT_MCPOPUP)\n"); goto done; }
|
|
|
|
if (PtInRect (&infoPtr->checkbox, pt))
|
|
|
|
{retval = DTHT_CHECKBOX; TRACE("Hit in checkbox(DTHT_CHECKBOX)\n"); goto done; }
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
for (i=0; i<infoPtr->nrFields; i++) {
|
2000-05-30 22:06:54 +02:00
|
|
|
if (PtInRect (&infoPtr->fieldRect[i], pt)) {
|
|
|
|
retval = i;
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Hit in date text in field %d\n", i);
|
2000-05-30 22:06:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return retval;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-05-30 22:06:54 +02:00
|
|
|
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|
|
|
int old, new;
|
2000-02-03 01:48:39 +01:00
|
|
|
POINT pt;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("\n");
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
old = infoPtr->select;
|
|
|
|
pt.x = (INT)LOWORD(lParam);
|
|
|
|
pt.y = (INT)HIWORD(lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
new = DATETIME_HitTest (hwnd, infoPtr, pt);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* FIXME: might be conditions where we don't want to update infoPtr->select */
|
|
|
|
infoPtr->select = new;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
if (infoPtr->select != old) {
|
|
|
|
infoPtr->haveFocus = DTHT_GOTFOCUS;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
if (infoPtr->select == DTHT_MCPOPUP) {
|
|
|
|
/* FIXME: button actually is only depressed during dropdown of the */
|
2001-07-17 02:40:30 +02:00
|
|
|
/* calendar control and when the mouse is over the button window */
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->bCalDepressed = TRUE;
|
|
|
|
|
|
|
|
/* recalculate the position of the monthcal popup */
|
|
|
|
if(dwStyle & DTS_RIGHTALIGN)
|
|
|
|
infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
|
|
|
|
infoPtr->calbutton.left) + 145);
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->monthcal_pos.x = 8;
|
|
|
|
|
|
|
|
infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
|
|
|
|
ClientToScreen (hwnd, &(infoPtr->monthcal_pos));
|
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x,
|
|
|
|
infoPtr->monthcal_pos.y, 145, 150, 0);
|
|
|
|
|
|
|
|
if(IsWindowVisible(infoPtr->hMonthCal))
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_HIDE);
|
|
|
|
else
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_SHOW);
|
|
|
|
|
2002-10-24 00:19:10 +02:00
|
|
|
TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p, mcpp:%p\n",
|
2002-06-01 01:06:46 +02:00
|
|
|
hwnd,infoPtr->hMonthCal,
|
2000-05-30 22:06:54 +02:00
|
|
|
GetParent (infoPtr->hMonthCal),
|
|
|
|
GetDesktopWindow (),
|
|
|
|
GetParent (GetParent (infoPtr->hMonthCal)));
|
|
|
|
DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-05-30 22:06:54 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
if(infoPtr->bCalDepressed == TRUE) {
|
|
|
|
infoPtr->bCalDepressed = FALSE;
|
2000-09-22 22:49:12 +02:00
|
|
|
InvalidateRect(hwnd, &(infoPtr->calbutton), TRUE);
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_Paint (HWND hwnd, WPARAM wParam)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
|
|
|
hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
|
|
|
|
DATETIME_Refresh (hwnd, hdc);
|
|
|
|
if(!wParam)
|
|
|
|
EndPaint (hwnd, &ps);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_Button_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
|
|
|
|
|
|
|
|
switch(HIWORD(wParam)) {
|
|
|
|
case BN_CLICKED:
|
|
|
|
{
|
|
|
|
DWORD state = SendMessageA((HWND)lParam, BM_GETCHECK, 0, 0);
|
|
|
|
if(state == BST_CHECKED)
|
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
else
|
|
|
|
infoPtr->dateValid = FALSE;
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
|
|
|
|
|
|
|
|
TRACE("%08x %08lx\n", wParam, lParam);
|
|
|
|
TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut);
|
|
|
|
if(infoPtr->hwndCheckbut == (HWND)lParam)
|
|
|
|
return DATETIME_Button_Command(hwnd, wParam, lParam);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-05-30 22:06:54 +02:00
|
|
|
LPNMHDR lpnmh = (LPNMHDR) lParam;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("%x,%lx\n",wParam, lParam);
|
2002-10-24 00:19:10 +02:00
|
|
|
TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
|
|
|
|
TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
|
2000-02-03 01:48:39 +01:00
|
|
|
return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-05-30 22:06:54 +02:00
|
|
|
LPNMHDR lpnmh = (LPNMHDR) lParam;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
TRACE ("%x,%lx\n",wParam, lParam);
|
2002-10-24 00:19:10 +02:00
|
|
|
TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
|
|
|
|
TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
|
2000-02-03 01:48:39 +01:00
|
|
|
return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
|
|
|
int FieldNum,wrap=0;
|
|
|
|
|
|
|
|
TRACE("%x %lx %x\n",wParam, lParam, infoPtr->select);
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
FieldNum = infoPtr->select & DTHT_DATEFIELD;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
if (!(infoPtr->haveFocus)) return 0;
|
|
|
|
if ((FieldNum==0) && (infoPtr->select)) return 0;
|
|
|
|
|
|
|
|
if (infoPtr->select & FORMATCALLMASK) {
|
|
|
|
FIXME ("Callbacks not implemented yet\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (wParam) {
|
|
|
|
case VK_ADD:
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_UP:
|
2000-02-03 01:48:39 +01:00
|
|
|
DATETIME_IncreaseField (infoPtr,FieldNum);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (hwnd);
|
|
|
|
break;
|
|
|
|
case VK_SUBTRACT:
|
|
|
|
case VK_DOWN:
|
|
|
|
DATETIME_DecreaseField (infoPtr,FieldNum);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (hwnd);
|
|
|
|
break;
|
|
|
|
case VK_HOME:
|
|
|
|
DATETIME_ResetFieldDown (infoPtr,FieldNum);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (hwnd);
|
|
|
|
break;
|
|
|
|
case VK_END:
|
|
|
|
DATETIME_ResetFieldUp(infoPtr,FieldNum);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (hwnd);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_LEFT:
|
2000-02-03 01:48:39 +01:00
|
|
|
do {
|
|
|
|
if (infoPtr->select==0) {
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->select = infoPtr->nrFields - 1;
|
2000-02-03 01:48:39 +01:00
|
|
|
wrap++;
|
2002-06-01 01:06:46 +02:00
|
|
|
} else
|
2000-02-03 01:48:39 +01:00
|
|
|
infoPtr->select--;
|
|
|
|
}
|
|
|
|
while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_RIGHT:
|
2000-02-03 01:48:39 +01:00
|
|
|
do {
|
|
|
|
infoPtr->select++;
|
|
|
|
if (infoPtr->select==infoPtr->nrFields) {
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->select = 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
wrap++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
if (infoPtr->haveFocus) {
|
|
|
|
DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
|
|
|
|
infoPtr->haveFocus = 0;
|
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
InvalidateRect (hwnd, NULL, TRUE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
if (infoPtr->haveFocus==0) {
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->haveFocus = DTHT_GOTFOCUS;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
static BOOL
|
|
|
|
DATETIME_SendDateTimeChangeNotify (HWND hwnd)
|
|
|
|
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2000-02-03 01:48:39 +01:00
|
|
|
NMDATETIMECHANGE dtdtc;
|
|
|
|
|
|
|
|
TRACE ("\n");
|
|
|
|
dtdtc.nmhdr.hwndFrom = hwnd;
|
|
|
|
dtdtc.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID);
|
|
|
|
dtdtc.nmhdr.code = DTN_DATETIMECHANGE;
|
|
|
|
|
|
|
|
if ((GetWindowLongA (hwnd, GWL_STYLE) & DTS_SHOWNONE))
|
2000-05-30 22:06:54 +02:00
|
|
|
dtdtc.dwFlags = GDT_NONE;
|
2000-02-03 01:48:39 +01:00
|
|
|
else
|
2000-05-30 22:06:54 +02:00
|
|
|
dtdtc.dwFlags = GDT_VALID;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
MONTHCAL_CopyTime (&infoPtr->date, &dtdtc.st);
|
|
|
|
return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
|
|
|
(WPARAM)dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static BOOL
|
|
|
|
DATETIME_SendSimpleNotify (HWND hwnd, UINT code)
|
|
|
|
{
|
|
|
|
NMHDR nmhdr;
|
|
|
|
|
|
|
|
TRACE("%x\n",code);
|
|
|
|
nmhdr.hwndFrom = hwnd;
|
|
|
|
nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID);
|
|
|
|
nmhdr.code = code;
|
|
|
|
|
|
|
|
return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
2000-02-03 01:48:39 +01:00
|
|
|
(WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
|
|
|
|
DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* set size */
|
|
|
|
infoPtr->rcClient.bottom = HIWORD(lParam);
|
|
|
|
infoPtr->rcClient.right = LOWORD(lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* use DrawEdge to adjust the size of rcEdge to get rcDraw */
|
|
|
|
memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw));
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2002-12-02 19:10:57 +01:00
|
|
|
DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2001-07-17 02:40:30 +02:00
|
|
|
/* set the size of the button that drops the calendar down */
|
2000-05-30 22:06:54 +02:00
|
|
|
/* FIXME: account for style that allows button on left side */
|
|
|
|
infoPtr->calbutton.top = infoPtr->rcDraw.top;
|
|
|
|
infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom;
|
|
|
|
infoPtr->calbutton.left = infoPtr->rcDraw.right-15;
|
|
|
|
infoPtr->calbutton.right = infoPtr->rcDraw.right;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* set enable/disable button size for show none style being enabled */
|
|
|
|
/* FIXME: these dimensions are completely incorrect */
|
|
|
|
infoPtr->checkbox.top = infoPtr->rcDraw.top;
|
|
|
|
infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom;
|
|
|
|
infoPtr->checkbox.left = infoPtr->rcDraw.left;
|
|
|
|
infoPtr->checkbox.right = infoPtr->rcDraw.left + 10;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* update the position of the monthcal control */
|
|
|
|
if(dwStyle & DTS_RIGHTALIGN)
|
|
|
|
infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
|
|
|
|
infoPtr->calbutton.left) + 145);
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->monthcal_pos.x = 8;
|
1999-03-12 18:42:50 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
|
|
|
|
ClientToScreen (hwnd, &(infoPtr->monthcal_pos));
|
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x,
|
|
|
|
infoPtr->monthcal_pos.y,
|
|
|
|
145, 150, 0);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DATETIME_INFO *infoPtr;
|
|
|
|
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
/* allocate memory for info structure */
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("%04x %08lx\n",wParam,lParam);
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO));
|
|
|
|
if (infoPtr == NULL) {
|
|
|
|
ERR("could not allocate info memory!\n");
|
1998-11-08 12:30:27 +01:00
|
|
|
return 0;
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
|
|
|
|
|
|
|
if (dwStyle & DTS_SHOWNONE) {
|
2002-06-01 01:06:46 +02:00
|
|
|
infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0,
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
|
2000-05-30 22:06:54 +02:00
|
|
|
2,2,13,13,
|
2002-06-01 01:06:46 +02:00
|
|
|
hwnd,
|
2002-10-23 22:19:22 +02:00
|
|
|
0, (HINSTANCE)GetWindowLongA (hwnd, GWL_HINSTANCE), 0);
|
2000-05-30 22:06:54 +02:00
|
|
|
SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwStyle & DTS_UPDOWN) {
|
|
|
|
infoPtr->hUpdown=CreateUpDownControl (
|
|
|
|
WS_CHILD | WS_BORDER | WS_VISIBLE,
|
|
|
|
120,1,20,20,
|
|
|
|
hwnd,1,0,0,
|
|
|
|
UD_MAXVAL, UD_MINVAL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
infoPtr->fieldspec = (int *) COMCTL32_Alloc (32*sizeof(int));
|
|
|
|
infoPtr->fieldRect = (RECT *) COMCTL32_Alloc (32*sizeof(RECT));
|
|
|
|
infoPtr->buflen = (int *) COMCTL32_Alloc (32*sizeof(int));
|
|
|
|
infoPtr->nrFieldsAllocated = 32;
|
|
|
|
|
|
|
|
DATETIME_SetFormat (hwnd, 0, 0);
|
|
|
|
|
|
|
|
/* create the monthcal control */
|
2002-06-01 01:06:46 +02:00
|
|
|
infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0,
|
2000-05-30 22:06:54 +02:00
|
|
|
WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
|
|
|
|
0, 0, 0, 0,
|
2002-06-01 01:06:46 +02:00
|
|
|
GetParent(hwnd),
|
2000-05-30 22:06:54 +02:00
|
|
|
0, 0, 0);
|
|
|
|
|
|
|
|
/* initialize info structure */
|
|
|
|
GetSystemTime (&infoPtr->date);
|
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
1999-03-12 18:42:50 +01:00
|
|
|
DATETIME_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
1999-03-12 18:42:50 +01:00
|
|
|
DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
1998-11-08 12:30:27 +01:00
|
|
|
COMCTL32_Free (infoPtr);
|
2001-02-12 04:42:23 +01:00
|
|
|
SetWindowLongA( hwnd, 0, 0 );
|
1998-11-08 12:30:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 16:41:43 +02:00
|
|
|
static LRESULT WINAPI
|
1999-02-26 12:11:13 +01:00
|
|
|
DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2001-02-12 04:42:23 +01:00
|
|
|
if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
|
|
|
|
return DefWindowProcA( hwnd, uMsg, wParam, lParam );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-08 12:30:27 +01:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
|
1999-01-17 17:32:32 +01:00
|
|
|
case DTM_GETSYSTEMTIME:
|
2001-05-25 22:38:20 +02:00
|
|
|
return DATETIME_GetSystemTime (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETSYSTEMTIME:
|
2001-05-25 22:38:20 +02:00
|
|
|
return DATETIME_SetSystemTime (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETRANGE:
|
2001-05-25 22:38:20 +02:00
|
|
|
return DATETIME_GetRange(hwnd, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETRANGE:
|
2001-05-25 22:38:20 +02:00
|
|
|
return DATETIME_SetRange(hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
case DTM_SETFORMATA:
|
2000-02-03 01:48:39 +01:00
|
|
|
return DATETIME_SetFormat (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
case DTM_SETFORMATW:
|
2000-02-03 01:48:39 +01:00
|
|
|
return DATETIME_SetFormatW (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETMCCOLOR:
|
1999-07-31 13:12:45 +02:00
|
|
|
return DATETIME_SetMonthCalColor (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETMCCOLOR:
|
1999-07-31 13:12:45 +02:00
|
|
|
return DATETIME_GetMonthCalColor (hwnd, wParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETMONTHCAL:
|
1999-07-31 13:12:45 +02:00
|
|
|
return DATETIME_GetMonthCal (hwnd);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETMCFONT:
|
1999-07-31 13:12:45 +02:00
|
|
|
return DATETIME_SetMonthCalFont (hwnd, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETMCFONT:
|
1999-07-31 13:12:45 +02:00
|
|
|
return DATETIME_GetMonthCalFont (hwnd);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_PARENTNOTIFY:
|
|
|
|
return DATETIME_ParentNotify (hwnd, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
return DATETIME_Notify (hwnd, wParam, lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
return DATETIME_Paint (hwnd, wParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
return DATETIME_KeyDown (hwnd, wParam, lParam);
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_KILLFOCUS:
|
|
|
|
return DATETIME_KillFocus (hwnd, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
return DATETIME_SetFocus (hwnd, wParam, lParam);
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
case WM_SIZE:
|
|
|
|
return DATETIME_Size (hwnd, wParam, lParam);
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
return DATETIME_LButtonDown (hwnd, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
return DATETIME_LButtonUp (hwnd, wParam, lParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_CREATE:
|
|
|
|
return DATETIME_Create (hwnd, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_DESTROY:
|
|
|
|
return DATETIME_Destroy (hwnd, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
return DATETIME_Command (hwnd, wParam, lParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
default:
|
2002-07-16 03:23:59 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP))
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("unknown msg %04x wp=%08x lp=%08lx\n",
|
1998-11-08 12:30:27 +01:00
|
|
|
uMsg, wParam, lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
1999-06-12 10:27:49 +02:00
|
|
|
DATETIME_Register (void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
WNDCLASSA wndClass;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
1999-02-26 12:11:13 +01:00
|
|
|
ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
1998-11-08 12:30:27 +01:00
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
1999-02-26 12:11:13 +01:00
|
|
|
wndClass.lpfnWndProc = (WNDPROC)DATETIME_WindowProc;
|
1998-11-08 12:30:27 +01:00
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = sizeof(DATETIME_INFO *);
|
1999-02-26 12:11:13 +01:00
|
|
|
wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
wndClass.lpszClassName = DATETIMEPICK_CLASSA;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
RegisterClassA (&wndClass);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
1999-06-12 10:27:49 +02:00
|
|
|
DATETIME_Unregister (void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2000-10-15 02:28:00 +02:00
|
|
|
TRACE("\n");
|
2002-12-02 19:10:57 +01:00
|
|
|
UnregisterClassA (DATETIMEPICK_CLASSA, NULL);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|