ReactOS 0.4.15-dev-5672-gf73ac17
datetime.c File Reference
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/debug.h"
Include dependency graph for datetime.c:

Go to the source code of this file.

Classes

struct  DATETIME_INFO
 

Macros

#define DT_END_FORMAT   0
 
#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
 
#define INVALIDFULLYEAR   0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
 
#define FULLYEAR   0x74
 
#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   0x1000
 
#define DTHT_CHECKBOX   0x2000 /* these should end at '00' , to make */
 
#define DTHT_MCPOPUP   0x3000 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
 
#define DTHT_GOTFOCUS   0x4000 /* tests for date-fields */
 
#define DTHT_NODATEMASK   0xf000 /* to mask check and drop down from others */
 

Typedefs

typedef struct DATETIME_INFOLPDATETIME_INFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (datetime)
 
int MONTHCAL_MonthLength (int month, int year)
 
int MONTHCAL_CalculateDayOfWeek (SYSTEMTIME *date, BOOL inplace)
 
static BOOL DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code)
 
static BOOL DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO *infoPtr)
 
static DWORD DATETIME_GetSystemTime (const DATETIME_INFO *infoPtr, SYSTEMTIME *systime)
 
static BOOL DATETIME_IsDateInValidRange (const DATETIME_INFO *infoPtr, const SYSTEMTIME *date)
 
static BOOL DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *systime)
 
static void DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt)
 
static BOOL DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR format)
 
static BOOL DATETIME_SetFormatA (DATETIME_INFO *infoPtr, LPCSTR lpszFormat)
 
static void DATETIME_ReturnTxt (const DATETIME_INFO *infoPtr, int count, LPWSTR result, int resultSize)
 
static int wrap (int val, int delta, int minVal, int maxVal)
 
static void DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta)
 
static int DATETIME_GetFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count)
 
static void DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
 
static INT DATETIME_HitTest (const DATETIME_INFO *infoPtr, POINT pt)
 
static int DATETIME_GetPrevDateField (const DATETIME_INFO *infoPtr, int i)
 
static void DATETIME_ApplySelectedField (DATETIME_INFO *infoPtr)
 
static void DATETIME_SetSelectedField (DATETIME_INFO *infoPtr, int select)
 
static LRESULT DATETIME_LButtonDown (DATETIME_INFO *infoPtr, INT x, INT y)
 
static LRESULT DATETIME_LButtonUp (DATETIME_INFO *infoPtr)
 
static LRESULT DATETIME_Paint (DATETIME_INFO *infoPtr, HDC hdc)
 
static LRESULT DATETIME_Button_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT DATETIME_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT DATETIME_Enable (DATETIME_INFO *infoPtr, BOOL bEnable)
 
static LRESULT DATETIME_EraseBackground (const DATETIME_INFO *infoPtr, HDC hdc)
 
static LRESULT DATETIME_Notify (DATETIME_INFO *infoPtr, const NMHDR *lpnmh)
 
static LRESULT DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode)
 
static LRESULT DATETIME_Char (DATETIME_INFO *infoPtr, WPARAM vkCode)
 
static LRESULT DATETIME_VScroll (DATETIME_INFO *infoPtr, WORD wScroll)
 
static LRESULT DATETIME_KillFocus (DATETIME_INFO *infoPtr, HWND lostFocus)
 
static LRESULT DATETIME_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs)
 
static LRESULT DATETIME_SetFocus (DATETIME_INFO *infoPtr, HWND lostFocus)
 
static LRESULT DATETIME_Size (DATETIME_INFO *infoPtr, INT width, INT height)
 
static LRESULT DATETIME_StyleChanging (DATETIME_INFO *infoPtr, WPARAM wStyleType, STYLESTRUCT *lpss)
 
static LRESULT DATETIME_StyleChanged (DATETIME_INFO *infoPtr, WPARAM wStyleType, const STYLESTRUCT *lpss)
 
static BOOL DATETIME_GetIdealSize (DATETIME_INFO *infoPtr, SIZE *size)
 
static LRESULT DATETIME_SetFont (DATETIME_INFO *infoPtr, HFONT font, BOOL repaint)
 
static LRESULT DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
 
static LRESULT DATETIME_Destroy (DATETIME_INFO *infoPtr)
 
static INT DATETIME_GetText (const DATETIME_INFO *infoPtr, INT count, LPWSTR dst)
 
static int DATETIME_GetTextLength (const DATETIME_INFO *info)
 
static LRESULT WINAPI DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void DATETIME_Register (void)
 
void DATETIME_Unregister (void)
 

Variables

static const WCHAR allowedformatchars [] = L"dhHmMstyX"
 
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1}
 
static const SYSTEMTIME max_allowed_date = { .wYear = 9999, .wMonth = 12, .wDayOfWeek = 0, .wDay = 31 }
 
static const SYSTEMTIME min_allowed_date = { .wYear = 1752, .wMonth = 9, .wDayOfWeek = 0, .wDay = 14 }
 

Macro Definition Documentation

◆ DT_END_FORMAT

#define DT_END_FORMAT   0

Definition at line 92 of file datetime.c.

◆ DT_STRING

#define DT_STRING   0x0100

Definition at line 117 of file datetime.c.

◆ DTHT_CHECKBOX

#define DTHT_CHECKBOX   0x2000 /* these should end at '00' , to make */

Definition at line 122 of file datetime.c.

◆ DTHT_DATEFIELD

#define DTHT_DATEFIELD   0xff /* for hit-testing */

Definition at line 119 of file datetime.c.

◆ DTHT_GOTFOCUS

#define DTHT_GOTFOCUS   0x4000 /* tests for date-fields */

Definition at line 124 of file datetime.c.

◆ DTHT_MCPOPUP

#define DTHT_MCPOPUP   0x3000 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */

Definition at line 123 of file datetime.c.

◆ DTHT_NODATEMASK

#define DTHT_NODATEMASK   0xf000 /* to mask check and drop down from others */

Definition at line 125 of file datetime.c.

◆ DTHT_NONE

#define DTHT_NONE   0x1000

Definition at line 121 of file datetime.c.

◆ FORMATCALLBACK

#define FORMATCALLBACK   0x81 /* -> maximum of 0x80 callbacks possible */

Definition at line 115 of file datetime.c.

◆ FORMATCALLMASK

#define FORMATCALLMASK   0x80

Definition at line 116 of file datetime.c.

◆ FULLDAY

#define FULLDAY   0x04

Definition at line 96 of file datetime.c.

◆ FULLMONTH

#define FULLMONTH   0x44

Definition at line 106 of file datetime.c.

◆ FULLYEAR

#define FULLYEAR   0x74

Definition at line 114 of file datetime.c.

◆ INVALIDFULLYEAR

#define INVALIDFULLYEAR   0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */

Definition at line 113 of file datetime.c.

◆ ONEDIGIT12HOUR

#define ONEDIGIT12HOUR   0x11

Definition at line 97 of file datetime.c.

◆ ONEDIGIT24HOUR

#define ONEDIGIT24HOUR   0x21

Definition at line 99 of file datetime.c.

◆ ONEDIGITDAY

#define ONEDIGITDAY   0x01

Definition at line 93 of file datetime.c.

◆ ONEDIGITMINUTE

#define ONEDIGITMINUTE   0x31

Definition at line 101 of file datetime.c.

◆ ONEDIGITMONTH

#define ONEDIGITMONTH   0x41

Definition at line 103 of file datetime.c.

◆ ONEDIGITSECOND

#define ONEDIGITSECOND   0x51

Definition at line 107 of file datetime.c.

◆ ONEDIGITYEAR

#define ONEDIGITYEAR   0x71

Definition at line 111 of file datetime.c.

◆ ONELETTERAMPM

#define ONELETTERAMPM   0x61

Definition at line 109 of file datetime.c.

◆ THREECHARDAY

#define THREECHARDAY   0x03

Definition at line 95 of file datetime.c.

◆ THREECHARMONTH

#define THREECHARMONTH   0x43

Definition at line 105 of file datetime.c.

◆ TWODIGIT12HOUR

#define TWODIGIT12HOUR   0x12

Definition at line 98 of file datetime.c.

◆ TWODIGIT24HOUR

#define TWODIGIT24HOUR   0x22

Definition at line 100 of file datetime.c.

◆ TWODIGITDAY

#define TWODIGITDAY   0x02

Definition at line 94 of file datetime.c.

◆ TWODIGITMINUTE

#define TWODIGITMINUTE   0x32

Definition at line 102 of file datetime.c.

◆ TWODIGITMONTH

#define TWODIGITMONTH   0x42

Definition at line 104 of file datetime.c.

◆ TWODIGITSECOND

#define TWODIGITSECOND   0x52

Definition at line 108 of file datetime.c.

◆ TWODIGITYEAR

#define TWODIGITYEAR   0x72

Definition at line 112 of file datetime.c.

◆ TWOLETTERAMPM

#define TWOLETTERAMPM   0x62

Definition at line 110 of file datetime.c.

Typedef Documentation

◆ LPDATETIME_INFO

Function Documentation

◆ DATETIME_ApplySelectedField()

static void DATETIME_ApplySelectedField ( DATETIME_INFO infoPtr)
static

Definition at line 816 of file datetime.c.

817{
818 int fieldNum = infoPtr->select & DTHT_DATEFIELD;
819 int i, val = 0;
820 BOOL clamp_day = FALSE;
821 SYSTEMTIME date = infoPtr->date;
822 int oldyear;
823
824 if (infoPtr->select == -1 || infoPtr->nCharsEntered == 0)
825 return;
826
827 if ((infoPtr->fieldspec[fieldNum] == ONELETTERAMPM) ||
828 (infoPtr->fieldspec[fieldNum] == TWOLETTERAMPM))
829 val = infoPtr->charsEntered[0];
830 else {
831 for (i=0; i<infoPtr->nCharsEntered; i++)
832 val = val * 10 + infoPtr->charsEntered[i] - '0';
833 }
834
835 infoPtr->nCharsEntered = 0;
836
837 switch (infoPtr->fieldspec[fieldNum]) {
838 case ONEDIGITYEAR:
839 case TWODIGITYEAR:
840 oldyear = date.wYear;
841 date.wYear = date.wYear - (date.wYear%100) + val;
842
843 if (DATETIME_IsDateInValidRange(infoPtr, &date))
844 clamp_day = TRUE;
845 else
846 date.wYear = oldyear;
847
848 break;
849 case INVALIDFULLYEAR:
850 case FULLYEAR:
851 oldyear = date.wYear;
852 date.wYear = val;
853
854 if (DATETIME_IsDateInValidRange(infoPtr, &date))
855 clamp_day = TRUE;
856 else
857 date.wYear = oldyear;
858
859 break;
860 case ONEDIGITMONTH:
861 case TWODIGITMONTH:
862 date.wMonth = val;
863 clamp_day = TRUE;
864 break;
865 case ONEDIGITDAY:
866 case TWODIGITDAY:
867 date.wDay = val;
868 break;
869 case ONEDIGIT12HOUR:
870 case TWODIGIT12HOUR:
871 if (val >= 24)
872 val -= 20;
873
874 if (val >= 13)
875 date.wHour = val;
876 else if (val != 0) {
877 if (date.wHour >= 12) /* preserve current AM/PM state */
878 date.wHour = (val == 12 ? 12 : val + 12);
879 else
880 date.wHour = (val == 12 ? 0 : val);
881 }
882 break;
883 case ONEDIGIT24HOUR:
884 case TWODIGIT24HOUR:
885 date.wHour = val;
886 break;
887 case ONEDIGITMINUTE:
888 case TWODIGITMINUTE:
889 date.wMinute = val;
890 break;
891 case ONEDIGITSECOND:
892 case TWODIGITSECOND:
893 date.wSecond = val;
894 break;
895 case ONELETTERAMPM:
896 case TWOLETTERAMPM:
897 if (val == 'a' || val == 'A') {
898 if (date.wHour >= 12)
899 date.wHour -= 12;
900 } else if (val == 'p' || val == 'P') {
901 if (date.wHour < 12)
902 date.wHour += 12;
903 }
904 break;
905 }
906
907 if (clamp_day && date.wDay > MONTHCAL_MonthLength(date.wMonth, date.wYear))
908 date.wDay = MONTHCAL_MonthLength(date.wMonth, date.wYear);
909
910 if (DATETIME_SetSystemTime(infoPtr, GDT_VALID, &date))
912}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define TWODIGITMONTH
Definition: datetime.c:104
#define ONEDIGIT12HOUR
Definition: datetime.c:97
#define ONEDIGITDAY
Definition: datetime.c:93
#define INVALIDFULLYEAR
Definition: datetime.c:113
#define TWODIGITSECOND
Definition: datetime.c:108
#define ONELETTERAMPM
Definition: datetime.c:109
#define ONEDIGIT24HOUR
Definition: datetime.c:99
#define ONEDIGITMONTH
Definition: datetime.c:103
#define TWODIGIT12HOUR
Definition: datetime.c:98
#define TWODIGITMINUTE
Definition: datetime.c:102
static BOOL DATETIME_IsDateInValidRange(const DATETIME_INFO *infoPtr, const SYSTEMTIME *date)
Definition: datetime.c:167
#define FULLYEAR
Definition: datetime.c:114
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:215
#define TWOLETTERAMPM
Definition: datetime.c:110
#define ONEDIGITMINUTE
Definition: datetime.c:101
#define TWODIGITYEAR
Definition: datetime.c:112
static BOOL DATETIME_SendDateTimeChangeNotify(const DATETIME_INFO *infoPtr)
Definition: datetime.c:1319
#define ONEDIGITYEAR
Definition: datetime.c:111
#define ONEDIGITSECOND
Definition: datetime.c:107
#define DTHT_DATEFIELD
Definition: datetime.c:119
static BOOL DATETIME_SetSystemTime(DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *systime)
Definition: datetime.c:194
#define TWODIGITDAY
Definition: datetime.c:94
#define TWODIGIT24HOUR
Definition: datetime.c:100
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__u16 date
Definition: mkdosfs.c:8
#define GDT_VALID
Definition: commctrl.h:4460
int nCharsEntered
Definition: datetime.c:68
int * fieldspec
Definition: datetime.c:73
SYSTEMTIME date
Definition: datetime.c:57
WCHAR charsEntered[4]
Definition: datetime.c:67

Referenced by DATETIME_Char(), and DATETIME_SetSelectedField().

◆ DATETIME_Button_Command()

static LRESULT DATETIME_Button_Command ( DATETIME_INFO infoPtr,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1035 of file datetime.c.

1036{
1037 if( HIWORD(wParam) == BN_CLICKED) {
1039 infoPtr->dateValid = (state == BST_CHECKED);
1040 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1041 }
1042 return 0;
1043}
static int state
Definition: maze.c:121
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND hwndSelf
Definition: datetime.c:52
BOOL dateValid
Definition: datetime.c:58
#define HIWORD(l)
Definition: typedefs.h:247
#define BN_CLICKED
Definition: winuser.h:1915
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1908

Referenced by DATETIME_Command().

◆ DATETIME_Char()

static LRESULT DATETIME_Char ( DATETIME_INFO infoPtr,
WPARAM  vkCode 
)
static

Definition at line 1196 of file datetime.c.

1197{
1198 int fieldNum, fieldSpec;
1199
1200 fieldNum = infoPtr->select & DTHT_DATEFIELD;
1201 fieldSpec = infoPtr->fieldspec[fieldNum];
1202
1203 if (fieldSpec == ONELETTERAMPM || fieldSpec == TWOLETTERAMPM) {
1204 infoPtr->charsEntered[0] = vkCode;
1205 infoPtr->nCharsEntered = 1;
1206
1208 } else if (vkCode >= '0' && vkCode <= '9') {
1209 int maxChars;
1210
1211 infoPtr->charsEntered[infoPtr->nCharsEntered++] = vkCode;
1212
1213 if (fieldSpec == INVALIDFULLYEAR || fieldSpec == FULLYEAR)
1214 maxChars = 4;
1215 else
1216 maxChars = 2;
1217
1218 if ((fieldSpec == ONEDIGIT12HOUR ||
1219 fieldSpec == TWODIGIT12HOUR ||
1220 fieldSpec == ONEDIGIT24HOUR ||
1221 fieldSpec == TWODIGIT24HOUR) &&
1222 (infoPtr->nCharsEntered == 1))
1223 {
1224 if (vkCode >= '3')
1225 maxChars = 1;
1226 }
1227
1228 if (maxChars == infoPtr->nCharsEntered)
1230 }
1231
1232 return 0;
1233}
static void DATETIME_ApplySelectedField(DATETIME_INFO *infoPtr)
Definition: datetime.c:816

Referenced by DATETIME_WindowProc().

◆ DATETIME_Command()

static LRESULT DATETIME_Command ( DATETIME_INFO infoPtr,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1048 of file datetime.c.

1049{
1050 TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut);
1051 if(infoPtr->hwndCheckbut == (HWND)lParam)
1052 return DATETIME_Button_Command(infoPtr, wParam, lParam);
1053 return 0;
1054}
static LRESULT DATETIME_Button_Command(DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
Definition: datetime.c:1035
#define TRACE(s)
Definition: solgame.cpp:4
HWND hwndCheckbut
Definition: datetime.c:59

Referenced by DATETIME_WindowProc().

◆ DATETIME_Create()

static LRESULT DATETIME_Create ( HWND  hwnd,
const CREATESTRUCTW lpcs 
)
static

Definition at line 1499 of file datetime.c.

1500{
1501 DATETIME_INFO *infoPtr = Alloc (sizeof(DATETIME_INFO));
1502 STYLESTRUCT ss = { 0, lpcs->style };
1503
1504 if (!infoPtr) return -1;
1505
1506 infoPtr->hwndSelf = hwnd;
1507 infoPtr->dwStyle = lpcs->style;
1508
1509 infoPtr->nrFieldsAllocated = 32;
1510 infoPtr->fieldspec = Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
1511 infoPtr->fieldRect = Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT));
1512 infoPtr->buflen = Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
1513 infoPtr->hwndNotify = lpcs->hwndParent;
1514 infoPtr->select = -1; /* initially, nothing is selected */
1515 infoPtr->bDropdownEnabled = TRUE;
1516
1518 DATETIME_SetFormatW (infoPtr, 0);
1519
1520 /* create the monthcal control */
1522 0, 0, 0, 0, infoPtr->hwndSelf, 0, 0, 0);
1523
1524 /* initialize info structure */
1525 GetLocalTime (&infoPtr->date);
1526 infoPtr->dateValid = TRUE;
1528
1529 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
1530
1531 return 0;
1532}
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
static LRESULT DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, const STYLESTRUCT *lpss)
Definition: datetime.c:1406
static BOOL DATETIME_SetFormatW(DATETIME_INFO *infoPtr, LPCWSTR format)
Definition: datetime.c:322
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define ss
Definition: i386-dis.c:442
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define MONTHCAL_CLASSW
Definition: commctrl.h:4175
int nrFieldsAllocated
Definition: datetime.c:70
HWND hMonthCal
Definition: datetime.c:53
HFONT hFont
Definition: datetime.c:69
HWND hwndNotify
Definition: datetime.c:54
RECT * fieldRect
Definition: datetime.c:74
DWORD dwStyle
Definition: datetime.c:56
BOOL bDropdownEnabled
Definition: datetime.c:65
int * buflen
Definition: datetime.c:75
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define SetWindowLongPtrW
Definition: winuser.h:5336
#define GWL_STYLE
Definition: winuser.h:846

Referenced by DATETIME_WindowProc().

◆ DATETIME_Destroy()

static LRESULT DATETIME_Destroy ( DATETIME_INFO infoPtr)
static

Definition at line 1537 of file datetime.c.

1538{
1539 if (infoPtr->hwndCheckbut)
1540 DestroyWindow(infoPtr->hwndCheckbut);
1541 if (infoPtr->hUpdown)
1542 DestroyWindow(infoPtr->hUpdown);
1543 if (infoPtr->hMonthCal)
1544 DestroyWindow(infoPtr->hMonthCal);
1545 SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); /* clear infoPtr */
1546 Free (infoPtr->buflen);
1547 Free (infoPtr->fieldRect);
1548 Free (infoPtr->fieldspec);
1549 Free (infoPtr);
1550 return 0;
1551}
HWND hUpdown
Definition: datetime.c:55
BOOL WINAPI DestroyWindow(_In_ HWND)
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815

Referenced by DATETIME_WindowProc().

◆ DATETIME_Enable()

static LRESULT DATETIME_Enable ( DATETIME_INFO infoPtr,
BOOL  bEnable 
)
static

Definition at line 1058 of file datetime.c.

1059{
1060 TRACE("%p %s\n", infoPtr, bEnable ? "TRUE" : "FALSE");
1061 if (bEnable)
1062 infoPtr->dwStyle &= ~WS_DISABLED;
1063 else
1064 infoPtr->dwStyle |= WS_DISABLED;
1065
1066 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1067
1068 return 0;
1069}
#define WS_DISABLED
Definition: pedump.c:621
_In_ BOOL bEnable
Definition: winddi.h:3426

Referenced by DATETIME_WindowProc().

◆ DATETIME_EraseBackground()

static LRESULT DATETIME_EraseBackground ( const DATETIME_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 1073 of file datetime.c.

1074{
1075 HBRUSH hBrush, hSolidBrush = NULL;
1076 RECT rc;
1077
1078 if (infoPtr->dwStyle & WS_DISABLED)
1079 hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrBtnFace);
1080 else
1081 {
1082 hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT,
1083 (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
1084 if (!hBrush)
1085 hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow);
1086 }
1087
1088 GetClientRect (infoPtr->hwndSelf, &rc);
1089
1090 FillRect (hdc, &rc, hBrush);
1091
1092 if (hSolidBrush)
1093 DeleteObject(hSolidBrush);
1094
1095 return -1;
1096}
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
pKey DeleteObject()
HDC hdc
Definition: main.c:9
COLORREF clrBtnFace
Definition: comctl32.h:168
COLORREF clrWindow
Definition: comctl32.h:176
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_CTLCOLOREDIT
Definition: winuser.h:1757

Referenced by DATETIME_WindowProc().

◆ DATETIME_GetFieldWidth()

static int DATETIME_GetFieldWidth ( const DATETIME_INFO infoPtr,
HDC  hdc,
int  count 
)
static

Definition at line 602 of file datetime.c.

603{
604 /* fields are a fixed width, determined by the largest possible string */
605 /* presumably, these widths should be language dependent */
606 int spec;
607 WCHAR buffer[80];
609 SIZE size;
610
611 if (!infoPtr->fieldspec) return 0;
612
613 spec = infoPtr->fieldspec[count];
614 if (spec & DT_STRING) {
615 int txtlen = infoPtr->buflen[count];
616
617 if (txtlen > 79)
618 txtlen = 79;
619 memcpy (buffer, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR));
620 buffer[txtlen] = 0;
621 bufptr = buffer;
622 }
623 else {
624 switch (spec) {
625 case ONEDIGITDAY:
626 case ONEDIGIT12HOUR:
627 case ONEDIGIT24HOUR:
628 case ONEDIGITSECOND:
629 case ONEDIGITMINUTE:
630 case ONEDIGITMONTH:
631 case ONEDIGITYEAR:
632 /* these seem to use a two byte field */
633 case TWODIGITDAY:
634 case TWODIGIT12HOUR:
635 case TWODIGIT24HOUR:
636 case TWODIGITSECOND:
637 case TWODIGITMINUTE:
638 case TWODIGITMONTH:
639 case TWODIGITYEAR:
640 bufptr = L"22";
641 break;
642 case INVALIDFULLYEAR:
643 case FULLYEAR:
644 bufptr = L"2222";
645 break;
646 case THREECHARMONTH:
647 case FULLMONTH:
648 case THREECHARDAY:
649 case FULLDAY:
650 {
651 const WCHAR *fall;
652 LCTYPE lctype;
653 INT i, max_count;
654 LONG cx;
655
656 /* choose locale data type and fallback string */
657 switch (spec) {
658 case THREECHARDAY:
659 fall = L"Wed";
660 lctype = LOCALE_SABBREVDAYNAME1;
661 max_count = 7;
662 break;
663 case FULLDAY:
664 fall = L"Wednesday";
665 lctype = LOCALE_SDAYNAME1;
666 max_count = 7;
667 break;
668 case THREECHARMONTH:
669 fall = L"Dec";
671 max_count = 12;
672 break;
673 default: /* FULLMONTH */
674 fall = L"September";
675 lctype = LOCALE_SMONTHNAME1;
676 max_count = 12;
677 break;
678 }
679
680 cx = 0;
681 for (i = 0; i < max_count; i++)
682 {
685 {
687 if (size.cx > cx) cx = size.cx;
688 }
689 else /* locale independent fallback on failure */
690 {
691 GetTextExtentPoint32W(hdc, fall, lstrlenW(fall), &size);
692 cx = size.cx;
693 break;
694 }
695 }
696 return cx;
697 }
698 case ONELETTERAMPM:
699 bufptr = L"A";
700 break;
701 case TWOLETTERAMPM:
702 bufptr = L"AM";
703 break;
704 default:
705 bufptr = L"2";
706 break;
707 }
708 }
710 return size.cx;
711}
#define ARRAY_SIZE(a)
Definition: main.h:24
#define FULLMONTH
Definition: datetime.c:106
#define THREECHARMONTH
Definition: datetime.c:105
#define THREECHARDAY
Definition: datetime.c:95
#define DT_STRING
Definition: datetime.c:117
#define FULLDAY
Definition: datetime.c:96
#define lstrlenW
Definition: compat.h:750
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1102
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define LOCALE_USER_DEFAULT
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_Out_opt_ int * cx
Definition: commctrl.h:585
WCHAR textbuf[256]
Definition: datetime.c:76
static unsigned int bufptr
Definition: tncon.cpp:77
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
DWORD LCTYPE
Definition: winnls.h:517
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by DATETIME_GetIdealSize(), and DATETIME_Refresh().

◆ DATETIME_GetIdealSize()

static BOOL DATETIME_GetIdealSize ( DATETIME_INFO infoPtr,
SIZE size 
)
static

Definition at line 1438 of file datetime.c.

1439{
1440 SIZE field_size;
1441 RECT rect;
1442 WCHAR txt[80];
1443 HDC hdc;
1444 HFONT oldFont;
1445 int i;
1446
1447 size->cx = size->cy = 0;
1448
1449 hdc = GetDC(infoPtr->hwndSelf);
1450 oldFont = SelectObject(hdc, infoPtr->hFont);
1451
1452 /* Get text font height */
1453 DATETIME_ReturnTxt(infoPtr, 0, txt, ARRAY_SIZE(txt));
1454 GetTextExtentPoint32W(hdc, txt, lstrlenW(txt), &field_size);
1455 size->cy = field_size.cy;
1456
1457 /* Get text font width */
1458 for (i = 0; i < infoPtr->nrFields; i++)
1459 {
1460 size->cx += DATETIME_GetFieldWidth(infoPtr, hdc, i);
1461 }
1462
1463 SelectObject(hdc, oldFont);
1464 ReleaseDC(infoPtr->hwndSelf, hdc);
1465
1466 if (infoPtr->dwStyle & DTS_UPDOWN)
1467 {
1468 GetWindowRect(infoPtr->hUpdown, &rect);
1469 size->cx += rect.right - rect.left;
1470 }
1471 else
1472 {
1473 size->cx += infoPtr->calbutton.right - infoPtr->calbutton.left;
1474 }
1475
1476 if (infoPtr->dwStyle & DTS_SHOWNONE)
1477 {
1478 size->cx += infoPtr->checkbox.right - infoPtr->checkbox.left;
1479 }
1480
1481 /* Add space between controls for them not to get too close */
1482 size->cx += 12;
1483 size->cy += 4;
1484
1485 TRACE("cx=%d cy=%d\n", size->cx, size->cy);
1486 return TRUE;
1487}
static int DATETIME_GetFieldWidth(const DATETIME_INFO *infoPtr, HDC hdc, int count)
Definition: datetime.c:602
static void DATETIME_ReturnTxt(const DATETIME_INFO *infoPtr, int count, LPWSTR result, int resultSize)
Definition: datetime.c:367
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define DTS_UPDOWN
Definition: commctrl.h:4357
#define DTS_SHOWNONE
Definition: commctrl.h:4358
& rect
Definition: startmenu.cpp:1413
RECT calbutton
Definition: datetime.c:63
RECT checkbox
Definition: datetime.c:62
int nrFields
Definition: datetime.c:71
LONG right
Definition: windef.h:308
LONG left
Definition: windef.h:306
LONG cy
Definition: windef.h:335
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by DATETIME_WindowProc().

◆ DATETIME_GetPrevDateField()

static int DATETIME_GetPrevDateField ( const DATETIME_INFO infoPtr,
int  i 
)
static

Definition at line 806 of file datetime.c.

807{
808 for(--i; i >= 0; i--)
809 {
810 if (infoPtr->fieldspec[i] & DTHT_DATEFIELD) return i;
811 }
812 return -1;
813}

Referenced by DATETIME_LButtonDown().

◆ DATETIME_GetSystemTime()

static DWORD DATETIME_GetSystemTime ( const DATETIME_INFO infoPtr,
SYSTEMTIME systime 
)
static

Definition at line 142 of file datetime.c.

143{
144 if (!systime) return GDT_NONE;
145
146 if ((infoPtr->dwStyle & DTS_SHOWNONE) &&
147 (SendMessageW (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
148 return GDT_NONE;
149
150 *systime = infoPtr->date;
151
152 return GDT_VALID;
153}
#define GDT_NONE
Definition: commctrl.h:4461
#define BST_UNCHECKED
Definition: winuser.h:199

Referenced by DATETIME_WindowProc().

◆ DATETIME_GetText()

static INT DATETIME_GetText ( const DATETIME_INFO infoPtr,
INT  count,
LPWSTR  dst 
)
static

Definition at line 1555 of file datetime.c.

1556{
1557 WCHAR buf[80];
1558 int i;
1559
1560 if (!dst || (count <= 0)) return 0;
1561
1562 dst[0] = 0;
1563 for (i = 0; i < infoPtr->nrFields; i++)
1564 {
1565 DATETIME_ReturnTxt(infoPtr, i, buf, ARRAY_SIZE(buf));
1566 if ((lstrlenW(dst) + lstrlenW(buf)) < count)
1567 lstrcatW(dst, buf);
1568 else break;
1569 }
1570 return lstrlenW(dst);
1571}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by DATETIME_WindowProc().

◆ DATETIME_GetTextLength()

static int DATETIME_GetTextLength ( const DATETIME_INFO info)
static

Definition at line 1573 of file datetime.c.

1574{
1575 int i, length = 0;
1576 WCHAR buffer[80];
1577
1578 TRACE("%p.\n", info);
1579
1580 for (i = 0; i < info->nrFields; i++)
1581 {
1584 }
1585 return length;
1586}
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Referenced by DATETIME_WindowProc().

◆ DATETIME_HitTest()

static INT DATETIME_HitTest ( const DATETIME_INFO infoPtr,
POINT  pt 
)
static

Definition at line 788 of file datetime.c.

789{
790 int i;
791
792 TRACE ("%s\n", wine_dbgstr_point(&pt));
793
794 if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP;
795 if (PtInRect (&infoPtr->checkbox, pt)) return DTHT_CHECKBOX;
796
797 for (i = 0; i < infoPtr->nrFields; i++) {
798 if (PtInRect (&infoPtr->fieldRect[i], pt)) return i;
799 }
800
801 return DTHT_NONE;
802}
#define DTHT_MCPOPUP
Definition: datetime.c:123
#define DTHT_NONE
Definition: datetime.c:121
#define DTHT_CHECKBOX
Definition: datetime.c:122
#define pt(x, y)
Definition: drawing.c:79
static __inline const char * wine_dbgstr_point(const POINT *pt)
Definition: debug.h:207
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

Referenced by DATETIME_LButtonDown().

◆ DATETIME_IncreaseField()

static void DATETIME_IncreaseField ( DATETIME_INFO infoPtr,
int  number,
int  delta 
)
static

Definition at line 500 of file datetime.c.

501{
502 SYSTEMTIME *date = &infoPtr->date;
503 SYSTEMTIME range[2];
504 DWORD limits;
505 BOOL min;
506
507 TRACE ("%d\n", number);
508 if ((number > infoPtr->nrFields) || (number < 0)) return;
509
510 if ((infoPtr->fieldspec[number] & DTHT_DATEFIELD) == 0) return;
511
512 switch (infoPtr->fieldspec[number]) {
513 case ONEDIGITYEAR:
514 case TWODIGITYEAR:
515 case FULLYEAR:
516 if (delta == INT_MIN)
517 date->wYear = 1752;
518 else if (delta == INT_MAX)
519 date->wYear = 9999;
520 else
521 date->wYear = max(min(date->wYear + delta, 9999), 1752);
522
523 if (date->wDay > MONTHCAL_MonthLength(date->wMonth, date->wYear))
524 /* This can happen when moving away from a leap year. */
525 date->wDay = MONTHCAL_MonthLength(date->wMonth, date->wYear);
527 break;
528 case ONEDIGITMONTH:
529 case TWODIGITMONTH:
530 case THREECHARMONTH:
531 case FULLMONTH:
532 date->wMonth = wrap(date->wMonth, delta, 1, 12);
534 delta = 0;
535 /* fall through */
536 case ONEDIGITDAY:
537 case TWODIGITDAY:
538 case THREECHARDAY:
539 case FULLDAY:
540 date->wDay = wrap(date->wDay, delta, 1, MONTHCAL_MonthLength(date->wMonth, date->wYear));
542 break;
543 case ONELETTERAMPM:
544 case TWOLETTERAMPM:
545 delta *= 12;
546 /* fall through */
547 case ONEDIGIT12HOUR:
548 case TWODIGIT12HOUR:
549 case ONEDIGIT24HOUR:
550 case TWODIGIT24HOUR:
551 date->wHour = wrap(date->wHour, delta, 0, 23);
552 break;
553 case ONEDIGITMINUTE:
554 case TWODIGITMINUTE:
555 date->wMinute = wrap(date->wMinute, delta, 0, 59);
556 break;
557 case ONEDIGITSECOND:
558 case TWODIGITSECOND:
559 date->wSecond = wrap(date->wSecond, delta, 0, 59);
560 break;
561 case FORMATCALLBACK:
562 FIXME ("Not implemented\n");
563 break;
564 }
565
566 /* FYI: On 1752/9/14 the calendar changed and England and the
567 * American colonies changed to the Gregorian calendar. This change
568 * involved having September 14th follow September 2nd. So no date
569 * algorithm works before that date.
570 */
571 if (10000 * date->wYear + 100 * date->wMonth + date->wDay < 17520914) {
572 date->wYear = 1752;
573 date->wMonth = 9;
574 date->wDay = 14;
575 date->wSecond = 0;
576 date->wMinute = 0;
577 date->wHour = 0;
578 }
579
580 /* Ensure time is within bounds */
581 limits = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, 0, (LPARAM)range);
582 min = delta < 0;
583
584 if (limits & (min ? GDTR_MIN : GDTR_MAX))
585 {
586 int i = (min ? 0 : 1);
587
588 if (MONTHCAL_CompareSystemTime(date, &range[i]) == (min ? -1 : 1))
589 {
590 date->wYear = range[i].wYear;
591 date->wMonth = range[i].wMonth;
592 date->wDayOfWeek = range[i].wDayOfWeek;
593 date->wDay = range[i].wDay;
594 date->wHour = range[i].wHour;
595 date->wMinute = range[i].wMinute;
596 date->wSecond = range[i].wSecond;
597 date->wMilliseconds = range[i].wMilliseconds;
598 }
599 }
600}
#define FIXME(fmt,...)
Definition: debug.h:111
LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second) DECLSPEC_HIDDEN
Definition: monthcal.c:303
#define FORMATCALLBACK
Definition: datetime.c:115
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:468
#define wrap(journal, var)
Definition: recovery.c:207
GLenum GLint * range
Definition: glext.h:7539
#define INT_MIN
Definition: limits.h:39
#define INT_MAX
Definition: limits.h:40
static unsigned int number
Definition: dsound.c:1479
#define min(a, b)
Definition: monoChain.cc:55
#define MCM_GETRANGE
Definition: commctrl.h:4262
#define GDTR_MAX
Definition: commctrl.h:4457
#define GDTR_MIN
Definition: commctrl.h:4456
#define max(a, b)
Definition: svc.c:63

Referenced by DATETIME_KeyDown(), and DATETIME_VScroll().

◆ DATETIME_IsDateInValidRange()

static BOOL DATETIME_IsDateInValidRange ( const DATETIME_INFO infoPtr,
const SYSTEMTIME date 
)
static

Definition at line 167 of file datetime.c.

168{
169 SYSTEMTIME range[2];
170 DWORD limits;
171
174 return FALSE;
175
176 limits = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, 0, (LPARAM)range);
177
178 if (limits & GDTR_MAX)
179 {
181 return FALSE;
182 }
183
184 if (limits & GDTR_MIN)
185 {
186 if (MONTHCAL_CompareSystemTime(date, &range[0]) == -1)
187 return FALSE;
188 }
189
190 return TRUE;
191}
static const SYSTEMTIME max_allowed_date
Definition: datetime.c:134
static const SYSTEMTIME min_allowed_date
Definition: datetime.c:135

Referenced by DATETIME_ApplySelectedField(), and DATETIME_SetSystemTime().

◆ DATETIME_KeyDown()

static LRESULT DATETIME_KeyDown ( DATETIME_INFO infoPtr,
DWORD  vkCode 
)
static

Definition at line 1126 of file datetime.c.

1127{
1128 int fieldNum = infoPtr->select & DTHT_DATEFIELD;
1129 int wrap = 0;
1130 int new;
1131
1132 if (!(infoPtr->haveFocus)) return 0;
1133 if ((fieldNum==0) && (infoPtr->select)) return 0;
1134
1135 if (infoPtr->select & FORMATCALLMASK) {
1136 FIXME ("Callbacks not implemented yet\n");
1137 }
1138
1139 switch (vkCode) {
1140 case VK_ADD:
1141 case VK_UP:
1142 infoPtr->nCharsEntered = 0;
1143 DATETIME_IncreaseField (infoPtr, fieldNum, 1);
1145 break;
1146 case VK_SUBTRACT:
1147 case VK_DOWN:
1148 infoPtr->nCharsEntered = 0;
1149 DATETIME_IncreaseField (infoPtr, fieldNum, -1);
1151 break;
1152 case VK_HOME:
1153 infoPtr->nCharsEntered = 0;
1154 DATETIME_IncreaseField (infoPtr, fieldNum, INT_MIN);
1156 break;
1157 case VK_END:
1158 infoPtr->nCharsEntered = 0;
1159 DATETIME_IncreaseField (infoPtr, fieldNum, INT_MAX);
1161 break;
1162 case VK_LEFT:
1163 new = infoPtr->select;
1164 do {
1165 if (new == 0) {
1166 new = new - 1;
1167 wrap++;
1168 } else {
1169 new--;
1170 }
1171 } while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2));
1172 if (new != infoPtr->select)
1173 DATETIME_SetSelectedField(infoPtr, new);
1174 break;
1175 case VK_RIGHT:
1176 new = infoPtr->select;
1177 do {
1178 new++;
1179 if (new==infoPtr->nrFields) {
1180 new = 0;
1181 wrap++;
1182 }
1183 } while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2));
1184 if (new != infoPtr->select)
1185 DATETIME_SetSelectedField(infoPtr, new);
1186 break;
1187 }
1188
1189 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1190
1191 return 0;
1192}
static void DATETIME_IncreaseField(DATETIME_INFO *infoPtr, int number, int delta)
Definition: datetime.c:500
#define FORMATCALLMASK
Definition: datetime.c:116
static void DATETIME_SetSelectedField(DATETIME_INFO *infoPtr, int select)
Definition: datetime.c:915
int haveFocus
Definition: datetime.c:72
#define VK_UP
Definition: winuser.h:2215
#define VK_END
Definition: winuser.h:2212
#define VK_HOME
Definition: winuser.h:2213
#define VK_ADD
Definition: winuser.h:2240
#define VK_LEFT
Definition: winuser.h:2214
#define VK_RIGHT
Definition: winuser.h:2216
#define VK_DOWN
Definition: winuser.h:2217
#define VK_SUBTRACT
Definition: winuser.h:2242

Referenced by DATETIME_WindowProc().

◆ DATETIME_KillFocus()

static LRESULT DATETIME_KillFocus ( DATETIME_INFO infoPtr,
HWND  lostFocus 
)
static

Definition at line 1261 of file datetime.c.

1262{
1263 TRACE("lost focus to %p\n", lostFocus);
1264
1265 if (infoPtr->haveFocus) {
1267 infoPtr->haveFocus = 0;
1268 DATETIME_SetSelectedField (infoPtr, -1);
1269 }
1270
1271 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
1272
1273 return 0;
1274}
static BOOL DATETIME_SendSimpleNotify(const DATETIME_INFO *infoPtr, UINT code)
Definition: datetime.c:1336
#define NM_KILLFOCUS
Definition: commctrl.h:136

Referenced by DATETIME_WindowProc().

◆ DATETIME_LButtonDown()

static LRESULT DATETIME_LButtonDown ( DATETIME_INFO infoPtr,
INT  x,
INT  y 
)
static

Definition at line 924 of file datetime.c.

925{
926 POINT pt;
927 int new;
928
929 pt.x = x;
930 pt.y = y;
931 new = DATETIME_HitTest (infoPtr, pt);
932
933 SetFocus(infoPtr->hwndSelf);
934
935 if (!(new & DTHT_NODATEMASK) || (new == DTHT_NONE))
936 {
937 if (new == DTHT_NONE)
938 new = infoPtr->nrFields - 1;
939 else
940 {
941 /* hitting string part moves selection to next date field to left */
942 if (infoPtr->fieldspec[new] & DT_STRING)
943 {
944 new = DATETIME_GetPrevDateField(infoPtr, new);
945 if (new == -1) return 0;
946 }
947 /* never select full day of week */
948 if (infoPtr->fieldspec[new] == FULLDAY) return 0;
949 }
950 }
951
952 DATETIME_SetSelectedField(infoPtr, new);
953
954 if (infoPtr->select == DTHT_MCPOPUP) {
955 RECT rcMonthCal;
956 POINT pos;
957 SendMessageW(infoPtr->hMonthCal, MCM_GETMINREQRECT, 0, (LPARAM)&rcMonthCal);
958
959 /* FIXME: button actually is only depressed during dropdown of the */
960 /* calendar control and when the mouse is over the button window */
961 infoPtr->bCalDepressed = TRUE;
962
963 /* recalculate the position of the monthcal popup */
964 if(infoPtr->dwStyle & DTS_RIGHTALIGN)
965 pos.x = infoPtr->calbutton.left - (rcMonthCal.right - rcMonthCal.left);
966 else
967 /* FIXME: this should be after the area reserved for the checkbox */
968 pos.x = infoPtr->rcDraw.left;
969
970 pos.y = infoPtr->rcClient.bottom;
971 OffsetRect( &rcMonthCal, pos.x, pos.y );
972 MapWindowPoints( infoPtr->hwndSelf, 0, (POINT *)&rcMonthCal, 2 );
973 SetWindowPos(infoPtr->hMonthCal, 0, rcMonthCal.left, rcMonthCal.top,
974 rcMonthCal.right - rcMonthCal.left, rcMonthCal.bottom - rcMonthCal.top, 0);
975
976 if(IsWindowVisible(infoPtr->hMonthCal)) {
977 ShowWindow(infoPtr->hMonthCal, SW_HIDE);
978 infoPtr->bDropdownEnabled = FALSE;
980 } else {
981 const SYSTEMTIME *lprgSysTimeArray = &infoPtr->date;
982 TRACE("update calendar %04d/%02d/%02d\n",
983 lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay);
984 SendMessageW(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
985
986 if (infoPtr->bDropdownEnabled) {
987 ShowWindow(infoPtr->hMonthCal, SW_SHOW);
989 }
990 infoPtr->bDropdownEnabled = TRUE;
991 }
992
993 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
994 infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hwndNotify, GetDesktopWindow ());
995 }
996
997 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
998
999 return 0;
1000}
static INT DATETIME_HitTest(const DATETIME_INFO *infoPtr, POINT pt)
Definition: datetime.c:788
static int DATETIME_GetPrevDateField(const DATETIME_INFO *infoPtr, int i)
Definition: datetime.c:806
#define DTHT_NODATEMASK
Definition: datetime.c:125
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DTN_DROPDOWN
Definition: commctrl.h:4453
#define DTS_RIGHTALIGN
Definition: commctrl.h:4364
#define DTN_CLOSEUP
Definition: commctrl.h:4454
#define MCM_SETCURSEL
Definition: commctrl.h:4186
#define MCM_GETMINREQRECT
Definition: commctrl.h:4200
BOOL bCalDepressed
Definition: datetime.c:64
RECT rcDraw
Definition: datetime.c:61
RECT rcClient
Definition: datetime.c:60
WORD wYear
Definition: winbase.h:905
WORD wMonth
Definition: winbase.h:906
WORD wDay
Definition: winbase.h:908
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by DATETIME_WindowProc().

◆ DATETIME_LButtonUp()

static LRESULT DATETIME_LButtonUp ( DATETIME_INFO infoPtr)
static

Definition at line 1004 of file datetime.c.

1005{
1006 if(infoPtr->bCalDepressed) {
1007 infoPtr->bCalDepressed = FALSE;
1008 InvalidateRect(infoPtr->hwndSelf, &(infoPtr->calbutton), TRUE);
1009 }
1010
1011 return 0;
1012}

Referenced by DATETIME_WindowProc().

◆ DATETIME_NCCreate()

static LRESULT DATETIME_NCCreate ( HWND  hwnd,
const CREATESTRUCTW lpcs 
)
static

Definition at line 1278 of file datetime.c.

1279{
1280 DWORD dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
1281 /* force control to have client edge */
1282 dwExStyle |= WS_EX_CLIENTEDGE;
1283 SetWindowLongW(hwnd, GWL_EXSTYLE, dwExStyle);
1284
1285 return 1;
1286}
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define GWL_EXSTYLE
Definition: winuser.h:845

Referenced by DATETIME_WindowProc().

◆ DATETIME_Notify()

static LRESULT DATETIME_Notify ( DATETIME_INFO infoPtr,
const NMHDR lpnmh 
)
static

Definition at line 1100 of file datetime.c.

1101{
1102 TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
1103 TRACE ("info: %p %p %p\n", infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hUpdown);
1104
1105 if (lpnmh->code == MCN_SELECT) {
1106 ShowWindow(infoPtr->hMonthCal, SW_HIDE);
1107 infoPtr->dateValid = TRUE;
1108 SendMessageW (infoPtr->hMonthCal, MCM_GETCURSEL, 0, (LPARAM)&infoPtr->date);
1109 TRACE("got from calendar %04d/%02d/%02d day of week %d\n",
1110 infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay, infoPtr->date.wDayOfWeek);
1112 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1115 }
1116 if ((lpnmh->hwndFrom == infoPtr->hUpdown) && (lpnmh->code == UDN_DELTAPOS)) {
1117 const NM_UPDOWN *lpnmud = (const NM_UPDOWN*)lpnmh;
1118 TRACE("Delta pos %d\n", lpnmud->iDelta);
1119 infoPtr->pendingUpdown = lpnmud->iDelta;
1120 }
1121 return 0;
1122}
#define NM_UPDOWN
Definition: commctrl.h:2160
#define MCM_GETCURSEL
Definition: commctrl.h:4184
#define UDN_DELTAPOS
Definition: commctrl.h:2169
#define MCN_SELECT
Definition: commctrl.h:4305
int pendingUpdown
Definition: datetime.c:78
WORD wDayOfWeek
Definition: winbase.h:907
UINT code
Definition: winuser.h:3149
HWND hwndFrom
Definition: winuser.h:3147
#define BM_SETCHECK
Definition: winuser.h:1911

Referenced by DATETIME_WindowProc().

◆ DATETIME_Paint()

static LRESULT DATETIME_Paint ( DATETIME_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 1016 of file datetime.c.

1017{
1018 if (!hdc) {
1019 PAINTSTRUCT ps;
1020 hdc = BeginPaint (infoPtr->hwndSelf, &ps);
1021 DATETIME_Refresh (infoPtr, hdc);
1022 EndPaint (infoPtr->hwndSelf, &ps);
1023 } else {
1024 DATETIME_Refresh (infoPtr, hdc);
1025 }
1026
1027 /* Not a click on the dropdown box, enabled it */
1028 infoPtr->bDropdownEnabled = TRUE;
1029
1030 return 0;
1031}
static void DATETIME_Refresh(DATETIME_INFO *infoPtr, HDC hdc)
Definition: datetime.c:714
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by DATETIME_WindowProc().

◆ DATETIME_Refresh()

static void DATETIME_Refresh ( DATETIME_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 714 of file datetime.c.

715{
716 TRACE("\n");
717
718 if (infoPtr->dateValid) {
719 int i, prevright;
720 RECT *field;
721 RECT *rcDraw = &infoPtr->rcDraw;
722 SIZE size;
723 COLORREF oldTextColor;
724 HFONT oldFont = SelectObject (hdc, infoPtr->hFont);
725 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
726 WCHAR txt[80];
727
728 DATETIME_ReturnTxt (infoPtr, 0, txt, ARRAY_SIZE(txt));
729 GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
730 rcDraw->bottom = size.cy + 2;
731
732 prevright = infoPtr->checkbox.right = ((infoPtr->dwStyle & DTS_SHOWNONE) ? 18 : 2);
733
734 for (i = 0; i < infoPtr->nrFields; i++) {
735 DATETIME_ReturnTxt (infoPtr, i, txt, ARRAY_SIZE(txt));
736 GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
737 field = &infoPtr->fieldRect[i];
738 field->left = prevright;
739 field->right = prevright + DATETIME_GetFieldWidth (infoPtr, hdc, i);
740 field->top = rcDraw->top;
741 field->bottom = rcDraw->bottom;
742 prevright = field->right;
743
744 if (infoPtr->dwStyle & WS_DISABLED)
745 oldTextColor = SetTextColor (hdc, comctl32_color.clrGrayText);
746 else if ((infoPtr->haveFocus) && (i == infoPtr->select)) {
748
749 /* fill if focused */
751
752 if (infoPtr->nCharsEntered)
753 {
754 memcpy(txt, infoPtr->charsEntered, infoPtr->nCharsEntered * sizeof(WCHAR));
755 txt[infoPtr->nCharsEntered] = 0;
756 GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
757 }
758
759 SetRect(&selection, 0, 0, size.cx, size.cy);
760 /* center rectangle */
761 OffsetRect(&selection, (field->right + field->left - size.cx)/2,
762 (field->bottom - size.cy)/2);
763
764 FillRect(hdc, &selection, hbr);
765 DeleteObject (hbr);
766 oldTextColor = SetTextColor (hdc, comctl32_color.clrWindow);
767 }
768 else
770
771 /* draw the date text using the colour set above */
773 SetTextColor (hdc, oldTextColor);
774 }
775 SetBkMode (hdc, oldBkMode);
776 SelectObject (hdc, oldFont);
777 }
778
779 if (!(infoPtr->dwStyle & DTS_UPDOWN)) {
781 DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) |
782 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
783 }
784}
int selection
Definition: ctm.c:92
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
COLORREF clrActiveCaption
Definition: comctl32.h:179
COLORREF clrGrayText
Definition: comctl32.h:178
COLORREF clrWindowText
Definition: comctl32.h:177
Definition: parser.c:44
DWORD COLORREF
Definition: windef.h:300
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define DFC_SCROLL
Definition: winuser.h:475
#define DT_CENTER
Definition: winuser.h:527
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DT_SINGLELINE
Definition: winuser.h:540
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DT_VCENTER
Definition: winuser.h:543
#define DFCS_SCROLLDOWN
Definition: winuser.h:490
#define DFCS_PUSHED
Definition: winuser.h:503
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by DATETIME_Paint().

◆ DATETIME_Register()

void DATETIME_Register ( void  )

Definition at line 1719 of file datetime.c.

1720{
1721 WNDCLASSW wndClass;
1722
1723 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
1724 wndClass.style = CS_GLOBALCLASS;
1726 wndClass.cbClsExtra = 0;
1727 wndClass.cbWndExtra = sizeof(DATETIME_INFO *);
1728 wndClass.hCursor = LoadCursorW (0, (LPCWSTR)IDC_ARROW);
1729 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1731
1732 RegisterClassW (&wndClass);
1733}
static LRESULT WINAPI DATETIME_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: datetime.c:1589
#define DATETIMEPICK_CLASSW
Definition: commctrl.h:4322
LPCWSTR lpszClassName
Definition: winuser.h:3175
HBRUSH hbrBackground
Definition: winuser.h:3173
int cbClsExtra
Definition: winuser.h:3168
UINT style
Definition: winuser.h:3166
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbWndExtra
Definition: winuser.h:3169
HCURSOR hCursor
Definition: winuser.h:3172
#define ZeroMemory
Definition: winbase.h:1670
#define COLOR_WINDOW
Definition: winuser.h:912
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:682
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define CS_GLOBALCLASS
Definition: winuser.h:647

Referenced by DllMain().

◆ DATETIME_ReturnTxt()

static void DATETIME_ReturnTxt ( const DATETIME_INFO infoPtr,
int  count,
LPWSTR  result,
int  resultSize 
)
static

Definition at line 367 of file datetime.c.

368{
369 SYSTEMTIME date = infoPtr->date;
370 int spec;
371 WCHAR buffer[80];
372
373 *result=0;
374 TRACE ("%d,%d\n", infoPtr->nrFields, count);
375 if (count>infoPtr->nrFields || count < 0) {
376 WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
377 return;
378 }
379
380 if (!infoPtr->fieldspec) return;
381
382 spec = infoPtr->fieldspec[count];
383 if (spec & DT_STRING) {
384 int txtlen = infoPtr->buflen[count];
385
386 if (txtlen > resultSize)
387 txtlen = resultSize - 1;
388 memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR));
389 result[txtlen] = 0;
390 TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
391 return;
392 }
393
394
395 switch (spec) {
396 case DT_END_FORMAT:
397 *result = 0;
398 break;
399 case ONEDIGITDAY:
400 wsprintfW (result, L"%d", date.wDay);
401 break;
402 case TWODIGITDAY:
403 wsprintfW (result, L"%.2d", date.wDay);
404 break;
405 case THREECHARDAY:
407 /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
408 break;
409 case FULLDAY:
410 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME1+(date.wDayOfWeek+6)%7, result, resultSize);
411 break;
412 case ONEDIGIT12HOUR:
413 if (date.wHour == 0) {
414 result[0] = '1';
415 result[1] = '2';
416 result[2] = 0;
417 }
418 else
419 wsprintfW (result, L"%d", date.wHour - (date.wHour > 12 ? 12 : 0));
420 break;
421 case TWODIGIT12HOUR:
422 if (date.wHour == 0) {
423 result[0] = '1';
424 result[1] = '2';
425 result[2] = 0;
426 }
427 else
428 wsprintfW (result, L"%.2d", date.wHour - (date.wHour > 12 ? 12 : 0));
429 break;
430 case ONEDIGIT24HOUR:
431 wsprintfW (result, L"%d", date.wHour);
432 break;
433 case TWODIGIT24HOUR:
434 wsprintfW (result, L"%.2d", date.wHour);
435 break;
436 case ONEDIGITSECOND:
437 wsprintfW (result, L"%d", date.wSecond);
438 break;
439 case TWODIGITSECOND:
440 wsprintfW (result, L"%.2d", date.wSecond);
441 break;
442 case ONEDIGITMINUTE:
443 wsprintfW (result, L"%d", date.wMinute);
444 break;
445 case TWODIGITMINUTE:
446 wsprintfW (result, L"%.2d", date.wMinute);
447 break;
448 case ONEDIGITMONTH:
449 wsprintfW (result, L"%d", date.wMonth);
450 break;
451 case TWODIGITMONTH:
452 wsprintfW (result, L"%.2d", date.wMonth);
453 break;
454 case THREECHARMONTH:
456 wsprintfW (result, L"%s.3s", buffer);
457 break;
458 case FULLMONTH:
460 result, resultSize);
461 break;
462 case ONELETTERAMPM:
463 result[0] = (date.wHour < 12 ? 'A' : 'P');
464 result[1] = 0;
465 break;
466 case TWOLETTERAMPM:
467 result[0] = (date.wHour < 12 ? 'A' : 'P');
468 result[1] = 'M';
469 result[2] = 0;
470 break;
471 case FORMATCALLBACK:
472 FIXME ("Not implemented\n");
473 result[0] = 'x';
474 result[1] = 0;
475 break;
476 case ONEDIGITYEAR:
477 wsprintfW (result, L"%d", date.wYear % 10);
478 break;
479 case TWODIGITYEAR:
480 wsprintfW (result, L"%.2d", date.wYear % 100);
481 break;
482 case INVALIDFULLYEAR:
483 case FULLYEAR:
484 wsprintfW (result, L"%d", date.wYear);
485 break;
486 }
487
488 TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
489}
#define WARN(fmt,...)
Definition: debug.h:112
#define DT_END_FORMAT
Definition: datetime.c:92
GLuint64EXT * result
Definition: glext.h:11304
#define debugstr_w
Definition: kernel32.h:32
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by DATETIME_GetIdealSize(), DATETIME_GetText(), DATETIME_GetTextLength(), and DATETIME_Refresh().

◆ DATETIME_SendDateTimeChangeNotify()

static BOOL DATETIME_SendDateTimeChangeNotify ( const DATETIME_INFO infoPtr)
static

Definition at line 1319 of file datetime.c.

1320{
1321 NMDATETIMECHANGE dtdtc;
1322
1323 dtdtc.nmhdr.hwndFrom = infoPtr->hwndSelf;
1324 dtdtc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
1326
1327 dtdtc.dwFlags = infoPtr->dateValid ? GDT_VALID : GDT_NONE;
1328
1329 dtdtc.st = infoPtr->date;
1330 return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
1331 dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc);
1332}
#define DTN_DATETIMECHANGE
Definition: commctrl.h:4366
#define WM_NOTIFY
Definition: richedit.h:61
UINT_PTR idFrom
Definition: winuser.h:3148
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define GWLP_ID
Definition: winuser.h:854

Referenced by DATETIME_ApplySelectedField(), DATETIME_KeyDown(), DATETIME_Notify(), and DATETIME_VScroll().

◆ DATETIME_SendSimpleNotify()

static BOOL DATETIME_SendSimpleNotify ( const DATETIME_INFO infoPtr,
UINT  code 
)
static

Definition at line 1336 of file datetime.c.

1337{
1338 NMHDR nmhdr;
1339
1340 TRACE("%x\n", code);
1341 nmhdr.hwndFrom = infoPtr->hwndSelf;
1342 nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
1343 nmhdr.code = code;
1344
1345 return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
1346 nmhdr.idFrom, (LPARAM)&nmhdr);
1347}
Definition: inflate.c:139

Referenced by DATETIME_KillFocus(), DATETIME_LButtonDown(), DATETIME_Notify(), and DATETIME_SetFocus().

◆ DATETIME_SetFocus()

static LRESULT DATETIME_SetFocus ( DATETIME_INFO infoPtr,
HWND  lostFocus 
)
static

Definition at line 1290 of file datetime.c.

1291{
1292 TRACE("got focus from %p\n", lostFocus);
1293
1294 /* if monthcal is open and it loses focus, close monthcal */
1295 if (infoPtr->hMonthCal && (lostFocus == infoPtr->hMonthCal) &&
1296 IsWindowVisible(infoPtr->hMonthCal))
1297 {
1298 ShowWindow(infoPtr->hMonthCal, SW_HIDE);
1300 /* note: this get triggered even if monthcal loses focus to a dropdown
1301 * box click, which occurs without an intermediate WM_PAINT call
1302 */
1303 infoPtr->bDropdownEnabled = FALSE;
1304 return 0;
1305 }
1306
1307 if (infoPtr->haveFocus == 0) {
1309 infoPtr->haveFocus = DTHT_GOTFOCUS;
1310 }
1311
1312 InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
1313
1314 return 0;
1315}
#define DTHT_GOTFOCUS
Definition: datetime.c:124
#define NM_SETFOCUS
Definition: commctrl.h:135

Referenced by DATETIME_WindowProc().

◆ DATETIME_SetFont()

static LRESULT DATETIME_SetFont ( DATETIME_INFO infoPtr,
HFONT  font,
BOOL  repaint 
)
static

Definition at line 1490 of file datetime.c.

1491{
1492 infoPtr->hFont = font;
1493 if (repaint) InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1494 return 0;
1495}
Definition: mk_font.cpp:20

Referenced by DATETIME_WindowProc().

◆ DATETIME_SetFormatA()

static BOOL DATETIME_SetFormatA ( DATETIME_INFO infoPtr,
LPCSTR  lpszFormat 
)
static

Definition at line 349 of file datetime.c.

350{
351 if (lpszFormat) {
352 BOOL retval;
353 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, NULL, 0);
354 LPWSTR wstr = Alloc(len * sizeof(WCHAR));
355 if (wstr) MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, wstr, len);
356 retval = DATETIME_SetFormatW (infoPtr, wstr);
357 Free (wstr);
358 return retval;
359 }
360 else
361 return DATETIME_SetFormatW (infoPtr, 0);
362
363}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DATETIME_WindowProc().

◆ DATETIME_SetFormatW()

static BOOL DATETIME_SetFormatW ( DATETIME_INFO infoPtr,
LPCWSTR  format 
)
static

Definition at line 322 of file datetime.c.

323{
324 WCHAR format_buf[80];
325
326 if (!format) {
327 DWORD format_item;
328
330 format_item = LOCALE_SSHORTDATE;
331 else if ((infoPtr->dwStyle & DTS_LONGDATEFORMAT) == DTS_LONGDATEFORMAT)
332 format_item = LOCALE_SLONGDATE;
333 else if ((infoPtr->dwStyle & DTS_TIMEFORMAT) == DTS_TIMEFORMAT)
334 format_item = LOCALE_STIMEFORMAT;
335 else /* DTS_SHORTDATEFORMAT */
336 format_item = LOCALE_SSHORTDATE;
337 GetLocaleInfoW(LOCALE_USER_DEFAULT, format_item, format_buf, ARRAY_SIZE(format_buf));
338 format = format_buf;
339 }
340
341 DATETIME_UseFormat (infoPtr, format);
342 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
343
344 return TRUE;
345}
static void DATETIME_UseFormat(DATETIME_INFO *infoPtr, LPCWSTR formattxt)
Definition: datetime.c:249
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define DTS_SHORTDATECENTURYFORMAT
Definition: commctrl.h:4361
#define DTS_LONGDATEFORMAT
Definition: commctrl.h:4360
#define DTS_TIMEFORMAT
Definition: commctrl.h:4362
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62

Referenced by DATETIME_Create(), DATETIME_SetFormatA(), and DATETIME_WindowProc().

◆ DATETIME_SetSelectedField()

static void DATETIME_SetSelectedField ( DATETIME_INFO infoPtr,
int  select 
)
static

Definition at line 915 of file datetime.c.

916{
918
919 infoPtr->select = select;
920 infoPtr->nCharsEntered = 0;
921}
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41

Referenced by DATETIME_KeyDown(), DATETIME_KillFocus(), and DATETIME_LButtonDown().

◆ DATETIME_SetSystemTime()

static BOOL DATETIME_SetSystemTime ( DATETIME_INFO infoPtr,
DWORD  flag,
const SYSTEMTIME systime 
)
static

Definition at line 194 of file datetime.c.

195{
196 if (!systime) return FALSE;
197
198 TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
199 systime->wYear, systime->wMonth, systime->wDay,
200 systime->wHour, systime->wMinute, systime->wSecond);
201
202 if (flag == GDT_VALID) {
203 if (systime->wYear == 0 ||
204 systime->wMonth < 1 || systime->wMonth > 12 ||
205 systime->wDay < 1 ||
206 systime->wDay > MONTHCAL_MonthLength(systime->wMonth, systime->wYear) ||
207 systime->wHour > 23 ||
208 systime->wMinute > 59 ||
209 systime->wSecond > 59 ||
210 systime->wMilliseconds > 999
211 )
212 return FALSE;
213
214 /* Windows returns true if the date is valid but outside the limits set */
215 if (!DATETIME_IsDateInValidRange(infoPtr, systime))
216 return TRUE;
217
218 infoPtr->dateValid = TRUE;
219 infoPtr->date = *systime;
220 /* always store a valid day of week */
222
223 SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
225 } else if ((infoPtr->dwStyle & DTS_SHOWNONE) && (flag == GDT_NONE)) {
226 infoPtr->dateValid = FALSE;
228 }
229 else
230 return FALSE;
231
232 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
233 return TRUE;
234}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
WORD wMilliseconds
Definition: winbase.h:912
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910

Referenced by DATETIME_ApplySelectedField(), and DATETIME_WindowProc().

◆ DATETIME_Size()

static LRESULT DATETIME_Size ( DATETIME_INFO infoPtr,
INT  width,
INT  height 
)
static

Definition at line 1350 of file datetime.c.

1351{
1352 /* set size */
1353 infoPtr->rcClient.bottom = height;
1354 infoPtr->rcClient.right = width;
1355
1356 TRACE("Height=%d, Width=%d\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
1357
1358 infoPtr->rcDraw = infoPtr->rcClient;
1359
1360 if (infoPtr->dwStyle & DTS_UPDOWN) {
1361 SetWindowPos(infoPtr->hUpdown, NULL,
1362 infoPtr->rcClient.right-14, 0,
1363 15, infoPtr->rcClient.bottom - infoPtr->rcClient.top,
1365 }
1366 else {
1367 /* set the size of the button that drops the calendar down */
1368 /* FIXME: account for style that allows button on left side */
1369 infoPtr->calbutton.top = infoPtr->rcDraw.top;
1370 infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom;
1371 infoPtr->calbutton.left = infoPtr->rcDraw.right-15;
1372 infoPtr->calbutton.right = infoPtr->rcDraw.right;
1373 }
1374
1375 /* set enable/disable button size for show none style being enabled */
1376 /* FIXME: these dimensions are completely incorrect */
1377 infoPtr->checkbox.top = infoPtr->rcDraw.top;
1378 infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom;
1379 infoPtr->checkbox.left = infoPtr->rcDraw.left;
1380 infoPtr->checkbox.right = infoPtr->rcDraw.left + 10;
1381
1382 InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
1383
1384 return 0;
1385}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define SWP_NOZORDER
Definition: winuser.h:1237

Referenced by DATETIME_WindowProc().

◆ DATETIME_StyleChanged()

static LRESULT DATETIME_StyleChanged ( DATETIME_INFO infoPtr,
WPARAM  wStyleType,
const STYLESTRUCT lpss 
)
static

Definition at line 1406 of file datetime.c.

1407{
1408 TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
1409 wStyleType, lpss->styleOld, lpss->styleNew);
1410
1411 if (wStyleType != GWL_STYLE) return 0;
1412
1413 infoPtr->dwStyle = lpss->styleNew;
1414
1415 if ( !(lpss->styleOld & DTS_SHOWNONE) && (lpss->styleNew & DTS_SHOWNONE) ) {
1417 2, 2, 13, 13, infoPtr->hwndSelf, 0,
1419 SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, infoPtr->dateValid ? 1 : 0, 0);
1420 }
1421 if ( (lpss->styleOld & DTS_SHOWNONE) && !(lpss->styleNew & DTS_SHOWNONE) ) {
1422 DestroyWindow(infoPtr->hwndCheckbut);
1423 infoPtr->hwndCheckbut = 0;
1424 }
1425 if ( !(lpss->styleOld & DTS_UPDOWN) && (lpss->styleNew & DTS_UPDOWN) ) {
1426 infoPtr->hUpdown = CreateUpDownControl (WS_CHILD | WS_BORDER | WS_VISIBLE, 120, 1, 20, 20,
1427 infoPtr->hwndSelf, 1, 0, 0, UD_MAXVAL, UD_MINVAL, 0);
1428 }
1429 if ( (lpss->styleOld & DTS_UPDOWN) && !(lpss->styleNew & DTS_UPDOWN) ) {
1430 DestroyWindow(infoPtr->hUpdown);
1431 infoPtr->hUpdown = 0;
1432 }
1433
1434 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1435 return 0;
1436}
HWND WINAPI CreateUpDownControl(DWORD style, INT x, INT y, INT cx, INT cy, HWND parent, INT id, HINSTANCE inst, HWND buddy, INT maxVal, INT minVal, INT curVal)
Definition: commctrl.c:829
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define WC_BUTTONW
Definition: commctrl.h:4623
#define UD_MINVAL
Definition: commctrl.h:2129
#define UD_MAXVAL
Definition: commctrl.h:2128
DWORD styleNew
Definition: winuser.h:3683
DWORD styleOld
Definition: winuser.h:3682
#define GWLP_HINSTANCE
Definition: winuser.h:850

Referenced by DATETIME_Create(), and DATETIME_WindowProc().

◆ DATETIME_StyleChanging()

static LRESULT DATETIME_StyleChanging ( DATETIME_INFO infoPtr,
WPARAM  wStyleType,
STYLESTRUCT lpss 
)
static

Definition at line 1388 of file datetime.c.

1389{
1390 TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
1391 wStyleType, lpss->styleOld, lpss->styleNew);
1392
1393 /* block DTS_SHOWNONE change */
1394 if ((lpss->styleNew ^ lpss->styleOld) & DTS_SHOWNONE)
1395 {
1396 if (lpss->styleOld & DTS_SHOWNONE)
1397 lpss->styleNew |= DTS_SHOWNONE;
1398 else
1399 lpss->styleNew &= ~DTS_SHOWNONE;
1400 }
1401
1402 return 0;
1403}

Referenced by DATETIME_WindowProc().

◆ DATETIME_Unregister()

void DATETIME_Unregister ( void  )

Definition at line 1737 of file datetime.c.

1738{
1740}
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)

Referenced by DllMain().

◆ DATETIME_UseFormat()

static void DATETIME_UseFormat ( DATETIME_INFO infoPtr,
LPCWSTR  formattxt 
)
static

Definition at line 249 of file datetime.c.

250{
251 unsigned int i;
252 int j, k, len;
253 BOOL inside_literal = FALSE; /* inside '...' */
254 int *nrFields = &infoPtr->nrFields;
255
256 *nrFields = 0;
257 infoPtr->fieldspec[*nrFields] = 0;
259 k = 0;
260
261 for (i = 0; formattxt[i]; i++) {
262 TRACE ("\n%d %c:", i, formattxt[i]);
263 if (!inside_literal) {
264 for (j = 0; j < len; j++) {
265 if (allowedformatchars[j]==formattxt[i]) {
266 TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
267 if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
268 infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
269 break;
270 }
271 if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
272 (*nrFields)++;
273 infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
274 break;
275 }
276 if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
277 (*nrFields)++;
278 infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
279 break;
280 }
281 infoPtr->fieldspec[*nrFields]++;
282 break;
283 } /* if allowedformatchar */
284 } /* for j */
285 }
286 else
287 j = len;
288
289 if (formattxt[i] == '\'')
290 {
291 inside_literal = !inside_literal;
292 continue;
293 }
294
295 /* char is not a specifier: handle char like a string */
296 if (j == len) {
297 if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
298 infoPtr->fieldspec[*nrFields] = DT_STRING + k;
299 infoPtr->buflen[*nrFields] = 0;
300 } else if ((infoPtr->fieldspec[*nrFields] & DT_STRING) != DT_STRING) {
301 (*nrFields)++;
302 infoPtr->fieldspec[*nrFields] = DT_STRING + k;
303 infoPtr->buflen[*nrFields] = 0;
304 }
305 infoPtr->textbuf[k] = formattxt[i];
306 k++;
307 infoPtr->buflen[*nrFields]++;
308 } /* if j=len */
309
310 if (*nrFields == infoPtr->nrFieldsAllocated) {
311 FIXME ("out of memory; should reallocate. crash ahead.\n");
312 }
313 } /* for i */
314
315 TRACE("\n");
316
317 if (infoPtr->fieldspec[*nrFields] != 0) (*nrFields)++;
318}
static const int maxrepetition[]
Definition: datetime.c:130
static const WCHAR allowedformatchars[]
Definition: datetime.c:129
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369

Referenced by DATETIME_SetFormatW().

◆ DATETIME_VScroll()

static LRESULT DATETIME_VScroll ( DATETIME_INFO infoPtr,
WORD  wScroll 
)
static

Definition at line 1237 of file datetime.c.

1238{
1239 int fieldNum = infoPtr->select & DTHT_DATEFIELD;
1240
1241 if ((SHORT)LOWORD(wScroll) != SB_THUMBPOSITION) return 0;
1242 if (!(infoPtr->haveFocus)) return 0;
1243 if ((fieldNum==0) && (infoPtr->select)) return 0;
1244
1245 if (infoPtr->pendingUpdown >= 0) {
1246 DATETIME_IncreaseField (infoPtr, fieldNum, 1);
1248 }
1249 else {
1250 DATETIME_IncreaseField (infoPtr, fieldNum, -1);
1252 }
1253
1254 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
1255
1256 return 0;
1257}
#define LOWORD(l)
Definition: pedump.c:82
short SHORT
Definition: pedump.c:59
#define SB_THUMBPOSITION
Definition: winuser.h:572

Referenced by DATETIME_WindowProc().

◆ DATETIME_WindowProc()

static LRESULT WINAPI DATETIME_WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1589 of file datetime.c.

1590{
1592
1593 TRACE ("%x, %lx, %lx\n", uMsg, wParam, lParam);
1594
1595 if (!infoPtr && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
1596 return DefWindowProcW( hwnd, uMsg, wParam, lParam );
1597
1598 switch (uMsg) {
1599
1600 case DTM_GETSYSTEMTIME:
1601 return DATETIME_GetSystemTime (infoPtr, (SYSTEMTIME *) lParam);
1602
1603 case DTM_SETSYSTEMTIME:
1604 return DATETIME_SetSystemTime (infoPtr, wParam, (SYSTEMTIME *) lParam);
1605
1606 case DTM_GETRANGE:
1607 return SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, wParam, lParam);
1608
1609 case DTM_SETRANGE:
1610 return SendMessageW (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam);
1611
1612 case DTM_SETFORMATA:
1613 return DATETIME_SetFormatA (infoPtr, (LPCSTR)lParam);
1614
1615 case DTM_SETFORMATW:
1616 return DATETIME_SetFormatW (infoPtr, (LPCWSTR)lParam);
1617
1618 case DTM_GETMONTHCAL:
1619 return (LRESULT)infoPtr->hMonthCal;
1620
1621 case DTM_SETMCCOLOR:
1622 return SendMessageW (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
1623
1624 case DTM_GETMCCOLOR:
1625 return SendMessageW (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
1626
1627 case DTM_SETMCFONT:
1628 return SendMessageW (infoPtr->hMonthCal, WM_SETFONT, wParam, lParam);
1629
1630 case DTM_GETMCFONT:
1631 return SendMessageW (infoPtr->hMonthCal, WM_GETFONT, wParam, lParam);
1632
1633 case DTM_GETIDEALSIZE:
1634 return DATETIME_GetIdealSize(infoPtr, (SIZE *)lParam);
1635
1636 case WM_NOTIFY:
1637 return DATETIME_Notify (infoPtr, (LPNMHDR)lParam);
1638
1639 case WM_ENABLE:
1640 return DATETIME_Enable (infoPtr, (BOOL)wParam);
1641
1642 case WM_ERASEBKGND:
1643 return DATETIME_EraseBackground (infoPtr, (HDC)wParam);
1644
1645 case WM_GETDLGCODE:
1647
1648 case WM_PRINTCLIENT:
1649 case WM_PAINT:
1650 return DATETIME_Paint (infoPtr, (HDC)wParam);
1651
1652 case WM_KEYDOWN:
1653 return DATETIME_KeyDown (infoPtr, wParam);
1654
1655 case WM_CHAR:
1656 return DATETIME_Char (infoPtr, wParam);
1657
1658 case WM_KILLFOCUS:
1659 return DATETIME_KillFocus (infoPtr, (HWND)wParam);
1660
1661 case WM_NCCREATE:
1663
1664 case WM_SETFOCUS:
1665 return DATETIME_SetFocus (infoPtr, (HWND)wParam);
1666
1667 case WM_SIZE:
1668 return DATETIME_Size (infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1669
1670 case WM_LBUTTONDOWN:
1671 return DATETIME_LButtonDown (infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1672
1673 case WM_LBUTTONUP:
1674 return DATETIME_LButtonUp (infoPtr);
1675
1676 case WM_VSCROLL:
1677 return DATETIME_VScroll (infoPtr, (WORD)wParam);
1678
1679 case WM_CREATE:
1681
1682 case WM_DESTROY:
1683 return DATETIME_Destroy (infoPtr);
1684
1685 case WM_COMMAND:
1686 return DATETIME_Command (infoPtr, wParam, lParam);
1687
1688 case WM_STYLECHANGING:
1690
1691 case WM_STYLECHANGED:
1693
1694 case WM_SETFONT:
1695 return DATETIME_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
1696
1697 case WM_GETFONT:
1698 return (LRESULT) infoPtr->hFont;
1699
1700 case WM_GETTEXT:
1701 return (LRESULT) DATETIME_GetText(infoPtr, wParam, (LPWSTR)lParam);
1702
1703 case WM_GETTEXTLENGTH:
1704 return (LRESULT)DATETIME_GetTextLength(infoPtr);
1705
1706 case WM_SETTEXT:
1707 return CB_ERR;
1708
1709 default:
1710 if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
1711 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
1712 uMsg, wParam, lParam);
1713 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
1714 }
1715}
#define ERR(fmt,...)
Definition: debug.h:110
BOOL COMCTL32_IsReflectedMessage(UINT uMsg) DECLSPEC_HIDDEN
Definition: commctrl.c:1748
static LRESULT DATETIME_Notify(DATETIME_INFO *infoPtr, const NMHDR *lpnmh)
Definition: datetime.c:1100
static LRESULT DATETIME_Size(DATETIME_INFO *infoPtr, INT width, INT height)
Definition: datetime.c:1350
static LRESULT DATETIME_SetFocus(DATETIME_INFO *infoPtr, HWND lostFocus)
Definition: datetime.c:1290
static LRESULT DATETIME_Enable(DATETIME_INFO *infoPtr, BOOL bEnable)
Definition: datetime.c:1058
static INT DATETIME_GetText(const DATETIME_INFO *infoPtr, INT count, LPWSTR dst)
Definition: datetime.c:1555
static LRESULT DATETIME_Char(DATETIME_INFO *infoPtr, WPARAM vkCode)
Definition: datetime.c:1196
static LRESULT DATETIME_LButtonUp(DATETIME_INFO *infoPtr)
Definition: datetime.c:1004
static LRESULT DATETIME_KeyDown(DATETIME_INFO *infoPtr, DWORD vkCode)
Definition: datetime.c:1126
static BOOL DATETIME_SetFormatA(DATETIME_INFO *infoPtr, LPCSTR lpszFormat)
Definition: datetime.c:349
static int DATETIME_GetTextLength(const DATETIME_INFO *info)
Definition: datetime.c:1573
static LRESULT DATETIME_VScroll(DATETIME_INFO *infoPtr, WORD wScroll)
Definition: datetime.c:1237
static LRESULT DATETIME_Command(DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
Definition: datetime.c:1048
static DWORD DATETIME_GetSystemTime(const DATETIME_INFO *infoPtr, SYSTEMTIME *systime)
Definition: datetime.c:142
static LRESULT DATETIME_LButtonDown(DATETIME_INFO *infoPtr, INT x, INT y)
Definition: datetime.c:924
static LRESULT DATETIME_Destroy(DATETIME_INFO *infoPtr)
Definition: datetime.c:1537
static LRESULT DATETIME_KillFocus(DATETIME_INFO *infoPtr, HWND lostFocus)
Definition: datetime.c:1261
static LRESULT DATETIME_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
Definition: datetime.c:1499
static LRESULT DATETIME_SetFont(DATETIME_INFO *infoPtr, HFONT font, BOOL repaint)
Definition: datetime.c:1490
static LRESULT DATETIME_StyleChanging(DATETIME_INFO *infoPtr, WPARAM wStyleType, STYLESTRUCT *lpss)
Definition: datetime.c:1388
static LRESULT DATETIME_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
Definition: datetime.c:1278
static LRESULT DATETIME_EraseBackground(const DATETIME_INFO *infoPtr, HDC hdc)
Definition: datetime.c:1073
static BOOL DATETIME_GetIdealSize(DATETIME_INFO *infoPtr, SIZE *size)
Definition: datetime.c:1438
static LRESULT DATETIME_Paint(DATETIME_INFO *infoPtr, HDC hdc)
Definition: datetime.c:1016
#define WM_APP
Definition: eventvwr.h:73
unsigned short WORD
Definition: ntddk_ex.h:93
#define DTM_GETIDEALSIZE
Definition: commctrl.h:4355
#define DTM_GETMONTHCAL
Definition: commctrl.h:4348
#define DTM_SETFORMATW
Definition: commctrl.h:4338
#define MCM_SETRANGE
Definition: commctrl.h:4264
#define DTM_SETMCCOLOR
Definition: commctrl.h:4344
#define DTM_SETMCFONT
Definition: commctrl.h:4350
#define MCM_GETCOLOR
Definition: commctrl.h:4204
#define DTM_GETMCFONT
Definition: commctrl.h:4352
#define MCM_SETCOLOR
Definition: commctrl.h:4202
#define DTM_SETRANGE
Definition: commctrl.h:4335
#define DTM_SETSYSTEMTIME
Definition: commctrl.h:4331
#define DTM_GETMCCOLOR
Definition: commctrl.h:4346
#define DTM_GETRANGE
Definition: commctrl.h:4333
#define DTM_SETFORMATA
Definition: commctrl.h:4337
#define DTM_GETSYSTEMTIME
Definition: commctrl.h:4329
#define WM_PRINTCLIENT
Definition: richedit.h:70
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_PAINT
Definition: winuser.h:1610
#define WM_ERASEBKGND
Definition: winuser.h:1615
#define WM_GETTEXTLENGTH
Definition: winuser.h:1609
#define WM_ENABLE
Definition: winuser.h:1605
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1734
#define WM_CREATE
Definition: winuser.h:1598
#define DLGC_WANTCHARS
Definition: winuser.h:2608
#define WM_SIZE
Definition: winuser.h:1601
#define WM_COMMAND
Definition: winuser.h:1730
#define CB_ERR
Definition: winuser.h:2425
#define WM_SETFOCUS
Definition: winuser.h:1603
#define WM_GETTEXT
Definition: winuser.h:1608
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
#define WM_GETFONT
Definition: winuser.h:1641
#define WM_NCCREATE
Definition: winuser.h:1673
#define WM_SETTEXT
Definition: winuser.h:1607
#define WM_SETFONT
Definition: winuser.h:1640
#define DLGC_WANTARROWS
Definition: winuser.h:2600
#define WM_LBUTTONUP
Definition: winuser.h:1767
#define WM_CHAR
Definition: winuser.h:1707
#define WM_USER
Definition: winuser.h:1885
#define WM_DESTROY
Definition: winuser.h:1599
#define WM_KEYDOWN
Definition: winuser.h:1705
#define WM_KILLFOCUS
Definition: winuser.h:1604
#define WM_GETDLGCODE
Definition: winuser.h:1679
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by DATETIME_Register().

◆ MONTHCAL_CalculateDayOfWeek()

int MONTHCAL_CalculateDayOfWeek ( SYSTEMTIME date,
BOOL  inplace 
)

Definition at line 468 of file monthcal.c.

468 : (0 == sunday,..., 6 == saturday)
469 */
471{
472 SYSTEMTIME st = st_null;
473 FILETIME ft;
474
476
477 SystemTimeToFileTime(&st, &ft);
478 FileTimeToSystemTime(&ft, &st);
479
480 if (inplace) date->wDayOfWeek = st.wDayOfWeek;
481
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:280
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:468
static const SYSTEMTIME st_null
Definition: monthcal.c:150
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158

Referenced by DATETIME_IncreaseField(), DATETIME_SetSystemTime(), MONTHCAL_GetDayFromPos(), MONTHCAL_GetDayPos(), MONTHCAL_GetMaxDate(), MONTHCAL_GetMinDate(), MONTHCAL_GetMonth(), MONTHCAL_GetMonthRange(), MONTHCAL_HitTest(), MONTHCAL_SetCurSel(), and MONTHCAL_SetSelRange().

◆ MONTHCAL_MonthLength()

int MONTHCAL_MonthLength ( int  month,
int  year 
)

Definition at line 215 of file monthcal.c.

218{
219 const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
220 /* Wrap around, this eases handling. Getting length only we shouldn't care
221 about year change here cause January and December have
222 the same day quantity */
223 if(month == 0)
224 month = 12;
225 else if(month == 13)
226 month = 1;
227
228 /* special case for calendar transition year */
229 if(month == min_allowed_date.wMonth && year == min_allowed_date.wYear) return 19;
230
231 /* if we have a leap year add 1 day to February */
232 /* a leap year is a year either divisible by 400 */
233 /* or divisible by 4 and not by 100 */
234 if(month == 2) { /* February */
235 return mdays[month - 1] + ((year%400 == 0) ? 1 : ((year%100 != 0) &&
236 (year%4 == 0)) ? 1 : 0);
237 }
238 else {
239 return mdays[month - 1];
static const SYSTEMTIME min_allowed_date
Definition: monthcal.c:153
static const WCHAR month[12][4]
Definition: session.c:2150

Referenced by DATETIME_ApplySelectedField(), DATETIME_IncreaseField(), DATETIME_SetSystemTime(), MONTHCAL_GetDayPos(), MONTHCAL_GetMaxDate(), MONTHCAL_GetMinDate(), MONTHCAL_GetMonth(), MONTHCAL_GetMonthRange(), MONTHCAL_HitTest(), MONTHCAL_PaintCalendar(), MONTHCAL_PaintLeadTrailMonths(), and MONTHCAL_ValidateDate().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( datetime  )

◆ wrap()

static int wrap ( int  val,
int  delta,
int  minVal,
int  maxVal 
)
static

Definition at line 491 of file datetime.c.

492{
493 val += delta;
494 if (delta == INT_MIN || val < minVal) return maxVal;
495 if (delta == INT_MAX || val > maxVal) return minVal;
496 return val;
497}

Variable Documentation

◆ allowedformatchars

const WCHAR allowedformatchars[] = L"dhHmMstyX"
static

Definition at line 129 of file datetime.c.

Referenced by DATETIME_UseFormat().

◆ max_allowed_date

const SYSTEMTIME max_allowed_date = { .wYear = 9999, .wMonth = 12, .wDayOfWeek = 0, .wDay = 31 }
static

Definition at line 134 of file datetime.c.

Referenced by DATETIME_IsDateInValidRange().

◆ maxrepetition

const int maxrepetition[] = {4,2,2,2,4,2,2,4,-1}
static

Definition at line 130 of file datetime.c.

Referenced by DATETIME_UseFormat().

◆ min_allowed_date

const SYSTEMTIME min_allowed_date = { .wYear = 1752, .wMonth = 9, .wDayOfWeek = 0, .wDay = 14 }
static

Definition at line 135 of file datetime.c.

Referenced by DATETIME_IsDateInValidRange().