ReactOS  0.4.13-dev-479-gec9c8fd
monthcal.c File Reference
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for monthcal.c:

Go to the source code of this file.

Classes

struct  _CALENDAR_INFO
 
struct  MONTHCAL_INFO
 

Macros

#define MCS_NOSELCHANGEONNAV   0x0100
 
#define MC_SEL_LBUTUP   1 /* Left button released */
 
#define MC_SEL_LBUTDOWN   2 /* Left button pressed in calendar */
 
#define MC_PREVPRESSED   4 /* Prev month button pressed */
 
#define MC_NEXTPRESSED   8 /* Next month button pressed */
 
#define MC_PREVNEXTMONTHDELAY
 
#define MC_TODAYUPDATEDELAY   120000 /* time between today check for update (2 min) */
 
#define MC_PREVNEXTMONTHTIMER   1 /* Timer IDs */
 
#define MC_TODAYUPDATETIMER   2
 
#define MC_CALENDAR_PADDING   6
 
#define DAYSTO100NSECS(days)   (((ULONGLONG)(days))*24*60*60*10000000)
 

Typedefs

typedef struct _CALENDAR_INFO CALENDAR_INFO
 
typedef struct MONTHCAL_INFOLPMONTHCAL_INFO
 

Enumerations

enum  CachedPen { PenRed = 0, PenText, PenLast }
 
enum  CachedBrush { BrushTitle = 0, BrushMonth, BrushBackground, BrushLast }
 
enum  nav_direction { DIRECTION_BACKWARD, DIRECTION_FORWARD }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (monthcal)
 
static INT MONTHCAL_GetCalCount (const MONTHCAL_INFO *infoPtr)
 
static void MONTHCAL_NotifySelectionChange (const MONTHCAL_INFO *infoPtr)
 
static void MONTHCAL_NotifySelect (const MONTHCAL_INFO *infoPtr)
 
static int MONTHCAL_MonthDiff (const SYSTEMTIME *left, const SYSTEMTIME *right)
 
int MONTHCAL_MonthLength (int month, int year)
 
static BOOL MONTHCAL_IsDateEqual (const SYSTEMTIME *first, const SYSTEMTIME *second)
 
static BOOL MONTHCAL_ValidateDate (const SYSTEMTIME *time)
 
static void MONTHCAL_CopyTime (const SYSTEMTIME *from, SYSTEMTIME *to)
 
static void MONTHCAL_CopyDate (const SYSTEMTIME *from, SYSTEMTIME *to)
 
LONG MONTHCAL_CompareSystemTime (const SYSTEMTIME *first, const SYSTEMTIME *second)
 
static LONG MONTHCAL_CompareMonths (const SYSTEMTIME *first, const SYSTEMTIME *second)
 
static LONG MONTHCAL_CompareDate (const SYSTEMTIME *first, const SYSTEMTIME *second)
 
static BOOL MONTHCAL_IsDateInValidRange (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date, BOOL fix)
 
static BOOL MONTHCAL_IsSelRangeValid (const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *range0, const SYSTEMTIME *range1, SYSTEMTIME *adjust)
 
static BOOL MONTHCAL_ValidateTime (const SYSTEMTIME *time)
 
int MONTHCAL_CalculateDayOfWeek (SYSTEMTIME *date, BOOL inplace)
 
static void MONTHCAL_GetMonth (SYSTEMTIME *date, INT months)
 
static void MONTHCAL_GetNextMonth (SYSTEMTIME *date)
 
static void MONTHCAL_GetPrevMonth (SYSTEMTIME *date)
 
static void MONTHCAL_GetMinDate (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
 
static void MONTHCAL_GetMaxDate (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
 
static int MONTHCAL_GetDayFromPos (const MONTHCAL_INFO *infoPtr, POINT pt, INT calIdx)
 
static void MONTHCAL_GetDayPos (const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, INT *col, INT *row, INT calIdx)
 
static void MONTHCAL_GetDayRectI (const MONTHCAL_INFO *infoPtr, RECT *r, INT col, INT row, INT calIdx)
 
static BOOL MONTHCAL_GetDayRect (const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
 
static LRESULT MONTHCAL_GetMonthRange (const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
 
static BOOL MONTHCAL_SetDayFocus (MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
 
static void MONTHCAL_Circle (const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
 
static void MONTHCAL_CircleDay (const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *date)
 
static void MONTHCAL_DrawDay (const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st, int bold, const PAINTSTRUCT *ps)
 
static void MONTHCAL_PaintButton (MONTHCAL_INFO *infoPtr, HDC hdc, enum nav_direction button)
 
static void MONTHCAL_PaintTitle (MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
 
static void MONTHCAL_PaintWeeknumbers (const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
 
static void MONTHCAL_PaintTodayTitle (const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
 
static void MONTHCAL_PaintFocusAndCircle (const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
 
static void MONTHCAL_PaintLeadTrailMonths (const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
 
static int get_localized_dayname (const MONTHCAL_INFO *infoPtr, unsigned int day, WCHAR *buff, unsigned int count)
 
static void MONTHCAL_PaintCalendar (const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
 
static void MONTHCAL_Refresh (MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
 
static LRESULT MONTHCAL_GetMinReqRect (const MONTHCAL_INFO *infoPtr, RECT *rect)
 
static COLORREF MONTHCAL_GetColor (const MONTHCAL_INFO *infoPtr, UINT index)
 
static LRESULT MONTHCAL_SetColor (MONTHCAL_INFO *infoPtr, UINT index, COLORREF color)
 
static LRESULT MONTHCAL_GetMonthDelta (const MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_SetMonthDelta (MONTHCAL_INFO *infoPtr, INT delta)
 
static LRESULT MONTHCAL_GetFirstDayOfWeek (const MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_SetFirstDayOfWeek (MONTHCAL_INFO *infoPtr, INT day)
 
static LRESULT MONTHCAL_GetMaxTodayWidth (const MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_SetRange (MONTHCAL_INFO *infoPtr, SHORT limits, SYSTEMTIME *range)
 
static LRESULT MONTHCAL_GetRange (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
 
static LRESULT MONTHCAL_SetDayState (const MONTHCAL_INFO *infoPtr, INT months, MONTHDAYSTATE *states)
 
static LRESULT MONTHCAL_GetCurSel (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
 
static LRESULT MONTHCAL_SetCurSel (MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
 
static LRESULT MONTHCAL_GetMaxSelCount (const MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_SetMaxSelCount (MONTHCAL_INFO *infoPtr, INT max)
 
static LRESULT MONTHCAL_GetSelRange (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
 
static LRESULT MONTHCAL_SetSelRange (MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
 
static LRESULT MONTHCAL_GetToday (const MONTHCAL_INFO *infoPtr, SYSTEMTIME *today)
 
static BOOL MONTHCAL_UpdateToday (MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today)
 
static LRESULT MONTHCAL_SetToday (MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today)
 
static INT MONTHCAL_GetCalendarFromPoint (const MONTHCAL_INFO *infoPtr, const POINT *pt)
 
static UINT fill_hittest_info (const MCHITTESTINFO *src, MCHITTESTINFO *dest)
 
static LRESULT MONTHCAL_HitTest (const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
 
static void MONTHCAL_NotifyDayState (MONTHCAL_INFO *infoPtr)
 
static void MONTHCAL_Scroll (MONTHCAL_INFO *infoPtr, INT delta, BOOL keep_selection)
 
static void MONTHCAL_GoToMonth (MONTHCAL_INFO *infoPtr, enum nav_direction direction)
 
static LRESULT MONTHCAL_RButtonUp (MONTHCAL_INFO *infoPtr, LPARAM lParam)
 
static LRESULT CALLBACK EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void MONTHCAL_EditYear (MONTHCAL_INFO *infoPtr, INT calIdx)
 
static LRESULT MONTHCAL_LButtonDown (MONTHCAL_INFO *infoPtr, LPARAM lParam)
 
static LRESULT MONTHCAL_LButtonUp (MONTHCAL_INFO *infoPtr, LPARAM lParam)
 
static LRESULT MONTHCAL_Timer (MONTHCAL_INFO *infoPtr, WPARAM id)
 
static LRESULT MONTHCAL_MouseMove (MONTHCAL_INFO *infoPtr, LPARAM lParam)
 
static LRESULT MONTHCAL_Paint (MONTHCAL_INFO *infoPtr, HDC hdc_paint)
 
static LRESULT MONTHCAL_EraseBkgnd (const MONTHCAL_INFO *infoPtr, HDC hdc)
 
static LRESULT MONTHCAL_PrintClient (MONTHCAL_INFO *infoPtr, HDC hdc, DWORD options)
 
static LRESULT MONTHCAL_SetFocus (const MONTHCAL_INFO *infoPtr)
 
static void MONTHCAL_UpdateSize (MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_Size (MONTHCAL_INFO *infoPtr, int Width, int Height)
 
static LRESULT MONTHCAL_GetFont (const MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_SetFont (MONTHCAL_INFO *infoPtr, HFONT hFont, BOOL redraw)
 
static LRESULT theme_changed (const MONTHCAL_INFO *infoPtr)
 
static INT MONTHCAL_StyleChanged (MONTHCAL_INFO *infoPtr, WPARAM wStyleType, const STYLESTRUCT *lpss)
 
static INT MONTHCAL_StyleChanging (MONTHCAL_INFO *infoPtr, WPARAM wStyleType, STYLESTRUCT *lpss)
 
static LRESULT MONTHCAL_Create (HWND hwnd, LPCREATESTRUCTW lpcs)
 
static LRESULT MONTHCAL_Destroy (MONTHCAL_INFO *infoPtr)
 
static LRESULT MONTHCAL_Notify (MONTHCAL_INFO *infoPtr, NMHDR *hdr)
 
static BOOL MONTHCAL_SetUnicodeFormat (MONTHCAL_INFO *infoPtr, BOOL isUnicode)
 
static BOOL MONTHCAL_GetUnicodeFormat (const MONTHCAL_INFO *infoPtr)
 
static LRESULT WINAPI MONTHCAL_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void MONTHCAL_Register (void)
 
void MONTHCAL_Unregister (void)
 

Variables

static const WCHAR themeClass [] = { 'S','c','r','o','l','l','b','a','r',0 }
 
static const SYSTEMTIME st_null
 
static const SYSTEMTIME max_allowed_date = { 9999, 12, 0, 31 }
 
static const SYSTEMTIME min_allowed_date = { 1752, 9, 0, 14 }
 

Macro Definition Documentation

◆ DAYSTO100NSECS

#define DAYSTO100NSECS (   days)    (((ULONGLONG)(days))*24*60*60*10000000)

Definition at line 72 of file monthcal.c.

◆ MC_CALENDAR_PADDING

#define MC_CALENDAR_PADDING   6

Definition at line 69 of file monthcal.c.

◆ MC_NEXTPRESSED

#define MC_NEXTPRESSED   8 /* Next month button pressed */

Definition at line 60 of file monthcal.c.

◆ MC_PREVNEXTMONTHDELAY

#define MC_PREVNEXTMONTHDELAY
Value:
350 /* when continuously pressing `next/prev
month', wait 350 ms before going
to the next/prev month */

Definition at line 61 of file monthcal.c.

◆ MC_PREVNEXTMONTHTIMER

#define MC_PREVNEXTMONTHTIMER   1 /* Timer IDs */

Definition at line 66 of file monthcal.c.

◆ MC_PREVPRESSED

#define MC_PREVPRESSED   4 /* Prev month button pressed */

Definition at line 59 of file monthcal.c.

◆ MC_SEL_LBUTDOWN

#define MC_SEL_LBUTDOWN   2 /* Left button pressed in calendar */

Definition at line 58 of file monthcal.c.

◆ MC_SEL_LBUTUP

#define MC_SEL_LBUTUP   1 /* Left button released */

Definition at line 57 of file monthcal.c.

◆ MC_TODAYUPDATEDELAY

#define MC_TODAYUPDATEDELAY   120000 /* time between today check for update (2 min) */

Definition at line 64 of file monthcal.c.

◆ MC_TODAYUPDATETIMER

#define MC_TODAYUPDATETIMER   2

Definition at line 67 of file monthcal.c.

◆ MCS_NOSELCHANGEONNAV

#define MCS_NOSELCHANGEONNAV   0x0100

Definition at line 55 of file monthcal.c.

Typedef Documentation

◆ CALENDAR_INFO

◆ LPMONTHCAL_INFO

Enumeration Type Documentation

◆ CachedBrush

Enumerator
BrushTitle 
BrushMonth 
BrushBackground 
BrushLast 

Definition at line 81 of file monthcal.c.

82 {
83  BrushTitle = 0,
84  BrushMonth,
86  BrushLast
87 };

◆ CachedPen

Enumerator
PenRed 
PenText 
PenLast 

Definition at line 74 of file monthcal.c.

75 {
76  PenRed = 0,
77  PenText,
78  PenLast
79 };

◆ nav_direction

Enumerator
DIRECTION_BACKWARD 
DIRECTION_FORWARD 

Definition at line 158 of file monthcal.c.

Function Documentation

◆ EditWndProc()

static LRESULT CALLBACK EditWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2082 of file monthcal.c.

2083 {
2085 
2086  TRACE("(hwnd=%p, uMsg=%x, wParam=%lx, lParam=%lx)\n",
2087  hwnd, uMsg, wParam, lParam);
2088 
2089  switch (uMsg)
2090  {
2091  case WM_GETDLGCODE:
2093 
2094  case WM_DESTROY:
2095  {
2096  WNDPROC editProc = infoPtr->EditWndProc;
2097  infoPtr->EditWndProc = NULL;
2099  return CallWindowProcW(editProc, hwnd, uMsg, wParam, lParam);
2100  }
2101 
2102  case WM_KILLFOCUS:
2103  break;
2104 
2105  case WM_KEYDOWN:
2106  if ((VK_ESCAPE == (INT)wParam) || (VK_RETURN == (INT)wParam))
2107  break;
2108 
2109  default:
2110  return CallWindowProcW(infoPtr->EditWndProc, hwnd, uMsg, wParam, lParam);
2111  }
2112 
2113  SendMessageW(infoPtr->hWndYearUpDown, WM_CLOSE, 0, 0);
2114  SendMessageW(hwnd, WM_CLOSE, 0, 0);
2115  return 0;
2116 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define VK_ESCAPE
Definition: winuser.h:2168
int32_t INT
Definition: typedefs.h:56
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
HWND hWndYearUpDown
Definition: monthcal.c:142
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KILLFOCUS
Definition: winuser.h:1596
WNDPROC EditWndProc
Definition: monthcal.c:143
#define WM_CLOSE
Definition: winuser.h:1603
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define DLGC_WANTALLKEYS
Definition: winuser.h:2566
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SetWindowLongPtrW
Definition: winuser.h:5215
LPARAM lParam
Definition: combotst.c:139
#define DLGC_WANTARROWS
Definition: winuser.h:2564

Referenced by MONTHCAL_EditYear().

◆ fill_hittest_info()

static UINT fill_hittest_info ( const MCHITTESTINFO src,
MCHITTESTINFO dest 
)
inlinestatic

Definition at line 1794 of file monthcal.c.

1795 {
1796  dest->uHit = src->uHit;
1797  dest->st = src->st;
1798 
1799  if (dest->cbSize == sizeof(MCHITTESTINFO))
1800  memcpy(&dest->rc, &src->rc, sizeof(MCHITTESTINFO) - MCHITTESTINFO_V1_SIZE);
1801 
1802  return src->uHit;
1803 }
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
#define MCHITTESTINFO_V1_SIZE
Definition: commctrl.h:4206
static char * dest
Definition: rtl.c:135

Referenced by MONTHCAL_HitTest().

◆ get_localized_dayname()

static int get_localized_dayname ( const MONTHCAL_INFO infoPtr,
unsigned int  day,
WCHAR buff,
unsigned int  count 
)
static

Definition at line 1158 of file monthcal.c.

1159 {
1160  LCTYPE lctype;
1161 
1162  if (infoPtr->dwStyle & MCS_SHORTDAYSOFWEEK)
1163  lctype = LOCALE_SSHORTESTDAYNAME1 + day;
1164  else
1165  lctype = LOCALE_SABBREVDAYNAME1 + day;
1166 
1167  return GetLocaleInfoW(LOCALE_USER_DEFAULT, lctype, buff, count);
1168 }
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_USER_DEFAULT
GLuint GLuint GLsizei count
Definition: gl.h:1545
static DOUBLE day(DOUBLE time)
Definition: date.c:115
#define MCS_SHORTDAYSOFWEEK
Definition: commctrl.h:4285
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
DWORD LCTYPE
Definition: winnls.h:514
DWORD dwStyle
Definition: monthcal.c:105
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by MONTHCAL_PaintCalendar(), and MONTHCAL_UpdateSize().

◆ MONTHCAL_CalculateDayOfWeek()

int MONTHCAL_CalculateDayOfWeek ( SYSTEMTIME date,
BOOL  inplace 
)

Definition at line 470 of file monthcal.c.

471 {
472  SYSTEMTIME st = st_null;
473  FILETIME ft;
474 
475  MONTHCAL_CopyDate(date, &st);
476 
477  SystemTimeToFileTime(&st, &ft);
478  FileTimeToSystemTime(&ft, &st);
479 
480  if (inplace) date->wDayOfWeek = st.wDayOfWeek;
481 
482  return st.wDayOfWeek;
483 }
WORD wDayOfWeek
Definition: winbase.h:872
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:282
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
__u16 date
Definition: mkdosfs.c:366
static const SYSTEMTIME st_null
Definition: monthcal.c:152

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

◆ MONTHCAL_Circle()

static void MONTHCAL_Circle ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const RECT r 
)
static

Definition at line 759 of file monthcal.c.

760 {
761  HPEN old_pen = SelectObject(hdc, infoPtr->pens[PenRed]);
762  HBRUSH old_brush;
763 
764  old_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
765  Rectangle(hdc, r->left, r->top, r->right, r->bottom);
766 
767  SelectObject(hdc, old_brush);
768  SelectObject(hdc, old_pen);
769 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define NULL_BRUSH
Definition: wingdi.h:900
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HPEN pens[PenLast]
Definition: monthcal.c:109
HDC hdc
Definition: main.c:9

Referenced by MONTHCAL_CircleDay(), and MONTHCAL_PaintTodayTitle().

◆ MONTHCAL_CircleDay()

static void MONTHCAL_CircleDay ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const SYSTEMTIME date 
)
static

Definition at line 777 of file monthcal.c.

779 {
780  RECT r;
781 
782  MONTHCAL_GetDayRect(infoPtr, date, &r, -1);
783  MONTHCAL_Circle(infoPtr, hdc, &r);
784 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HDC hdc
Definition: main.c:9
static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
Definition: monthcal.c:759
static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
Definition: monthcal.c:637
__u16 date
Definition: mkdosfs.c:366

Referenced by MONTHCAL_PaintFocusAndCircle().

◆ MONTHCAL_CompareDate()

static LONG MONTHCAL_CompareDate ( const SYSTEMTIME first,
const SYSTEMTIME second 
)
static

Definition at line 327 of file monthcal.c.

328 {
329  SYSTEMTIME st_first, st_second;
330 
331  st_first = st_second = st_null;
332  MONTHCAL_CopyDate(first, &st_first);
333  MONTHCAL_CopyDate(second, &st_second);
334 
335  return MONTHCAL_CompareSystemTime(&st_first, &st_second);
336 }
const GLint * first
Definition: glext.h:5794
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:282
LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:305
static const SYSTEMTIME st_null
Definition: monthcal.c:152

Referenced by MONTHCAL_DrawDay().

◆ MONTHCAL_CompareMonths()

static LONG MONTHCAL_CompareMonths ( const SYSTEMTIME first,
const SYSTEMTIME second 
)
static

Definition at line 315 of file monthcal.c.

316 {
317  SYSTEMTIME st_first, st_second;
318 
319  st_first = st_second = st_null;
320  MONTHCAL_CopyDate(first, &st_first);
321  MONTHCAL_CopyDate(second, &st_second);
322  st_first.wDay = st_second.wDay = 1;
323 
324  return MONTHCAL_CompareSystemTime(&st_first, &st_second);
325 }
const GLint * first
Definition: glext.h:5794
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:282
LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:305
WORD wDay
Definition: winbase.h:873
static const SYSTEMTIME st_null
Definition: monthcal.c:152

Referenced by MONTHCAL_GetDayPos(), MONTHCAL_GetDayRect(), MONTHCAL_PaintFocusAndCircle(), and MONTHCAL_Scroll().

◆ MONTHCAL_CompareSystemTime()

LONG MONTHCAL_CompareSystemTime ( const SYSTEMTIME first,
const SYSTEMTIME second 
)

Definition at line 305 of file monthcal.c.

306 {
307  FILETIME ft_first, ft_second;
308 
309  SystemTimeToFileTime(first, &ft_first);
310  SystemTimeToFileTime(second, &ft_second);
311 
312  return CompareFileTime(&ft_first, &ft_second);
313 }
const GLint * first
Definition: glext.h:5794
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148

Referenced by DATETIME_IncreaseField(), DATETIME_IsDateInValidRange(), MONTHCAL_CompareDate(), MONTHCAL_CompareMonths(), MONTHCAL_IsDateInValidRange(), and MONTHCAL_SetSelRange().

◆ MONTHCAL_CopyDate()

static void MONTHCAL_CopyDate ( const SYSTEMTIME from,
SYSTEMTIME to 
)
static

Definition at line 282 of file monthcal.c.

283 {
284  to->wYear = from->wYear;
285  to->wMonth = from->wMonth;
286  to->wDay = from->wDay;
287  to->wDayOfWeek = from->wDayOfWeek;
288 }
WORD wMonth
Definition: winbase.h:871
WORD wDayOfWeek
Definition: winbase.h:872
WORD wYear
Definition: winbase.h:870
WORD wDay
Definition: winbase.h:873
CardRegion * from
Definition: spigame.cpp:19

Referenced by MONTHCAL_CalculateDayOfWeek(), MONTHCAL_CompareDate(), MONTHCAL_CompareMonths(), MONTHCAL_LButtonDown(), and MONTHCAL_MouseMove().

◆ MONTHCAL_CopyTime()

static void MONTHCAL_CopyTime ( const SYSTEMTIME from,
SYSTEMTIME to 
)
static

Definition at line 268 of file monthcal.c.

269 {
270  to->wHour = from->wHour;
271  to->wMinute = from->wMinute;
272  to->wSecond = from->wSecond;
273 }
WORD wMinute
Definition: winbase.h:875
WORD wSecond
Definition: winbase.h:876
WORD wHour
Definition: winbase.h:874
CardRegion * from
Definition: spigame.cpp:19

Referenced by MONTHCAL_SetRange(), and MONTHCAL_SetSelRange().

◆ MONTHCAL_Create()

static LRESULT MONTHCAL_Create ( HWND  hwnd,
LPCREATESTRUCTW  lpcs 
)
static

Definition at line 2763 of file monthcal.c.

2764 {
2765  MONTHCAL_INFO *infoPtr;
2766 
2767  /* allocate memory for info structure */
2768  infoPtr = heap_alloc_zero(sizeof(*infoPtr));
2769  SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
2770 
2771  if (infoPtr == NULL) {
2772  ERR("could not allocate info memory!\n");
2773  return 0;
2774  }
2775 
2776  infoPtr->hwndSelf = hwnd;
2777  infoPtr->hwndNotify = lpcs->hwndParent;
2778  infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
2779  infoPtr->dim.cx = infoPtr->dim.cy = 1;
2780  infoPtr->calendars = heap_alloc_zero(sizeof(CALENDAR_INFO));
2781  if (!infoPtr->calendars) goto fail;
2782  infoPtr->monthdayState = heap_alloc_zero(3 * sizeof(MONTHDAYSTATE));
2783  if (!infoPtr->monthdayState) goto fail;
2784 
2785  /* initialize info structure */
2786  /* FIXME: calculate systemtime ->> localtime(subtract timezoneinfo) */
2787 
2788  GetLocalTime(&infoPtr->todaysDate);
2789  MONTHCAL_SetFirstDayOfWeek(infoPtr, -1);
2790 
2791  infoPtr->maxSelCount = (infoPtr->dwStyle & MCS_MULTISELECT) ? 7 : 1;
2792 
2799 
2801  infoPtr->brushes[BrushTitle] = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]);
2802  infoPtr->brushes[BrushMonth] = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]);
2803 
2804  infoPtr->pens[PenRed] = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
2805  infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[MCSC_TEXT]);
2806 
2807  infoPtr->minSel = infoPtr->todaysDate;
2808  infoPtr->maxSel = infoPtr->todaysDate;
2809  infoPtr->calendars[0].month = infoPtr->todaysDate;
2810  infoPtr->isUnicode = TRUE;
2811 
2812  /* setup control layout and day state data */
2813  MONTHCAL_UpdateSize(infoPtr);
2814 
2815  /* today auto update timer, to be freed only on control destruction */
2817 
2818  OpenThemeData (infoPtr->hwndSelf, themeClass);
2819 
2820  return 0;
2821 
2822 fail:
2823  heap_free(infoPtr->monthdayState);
2824  heap_free(infoPtr->calendars);
2825  heap_free(infoPtr);
2826  return 0;
2827 }
#define MCSC_MONTHBK
Definition: commctrl.h:4183
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
SYSTEMTIME todaysDate
Definition: monthcal.c:125
#define MCSC_TEXT
Definition: commctrl.h:4180
static LRESULT MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, INT day)
Definition: monthcal.c:1405
HWND hwndSelf
Definition: monthcal.c:104
INT maxSelCount
Definition: monthcal.c:129
#define MC_TODAYUPDATEDELAY
Definition: monthcal.c:64
#define MCSC_TITLETEXT
Definition: commctrl.h:4182
COLORREF clrWindowText
Definition: comctl32.h:169
HWND hwndNotify
Definition: monthcal.c:140
#define PS_SOLID
Definition: wingdi.h:585
COLORREF clrActiveCaption
Definition: comctl32.h:171
static const WCHAR themeClass[]
Definition: monthcal.c:149
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define MC_TODAYUPDATETIMER
Definition: monthcal.c:67
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
HPEN pens[PenLast]
Definition: monthcal.c:109
SYSTEMTIME maxSel
Definition: monthcal.c:131
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
SYSTEMTIME minSel
Definition: monthcal.c:130
static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:2488
DWORD dwStyle
Definition: monthcal.c:105
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define MCS_MULTISELECT
Definition: commctrl.h:4280
SYSTEMTIME month
Definition: monthcal.c:99
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
#define MCSC_BACKGROUND
Definition: commctrl.h:4179
MONTHDAYSTATE * monthdayState
Definition: monthcal.c:124
uint32_t DWORD_PTR
Definition: typedefs.h:63
CALENDAR_INFO * calendars
Definition: monthcal.c:145
BOOL isUnicode
Definition: monthcal.c:122
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
#define MCSC_TITLEBK
Definition: commctrl.h:4181
COLORREF clrGrayText
Definition: comctl32.h:170
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define MCSC_TRAILINGTEXT
Definition: commctrl.h:4184
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
#define SetWindowLongPtrW
Definition: winuser.h:5215
COLORREF clrWindow
Definition: comctl32.h:168
LONG cy
Definition: windef.h:320
DWORD MONTHDAYSTATE
Definition: commctrl.h:4152
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_Destroy()

static LRESULT MONTHCAL_Destroy ( MONTHCAL_INFO infoPtr)
static

Definition at line 2830 of file monthcal.c.

2831 {
2832  INT i;
2833 
2834  /* free month calendar info data */
2835  heap_free(infoPtr->monthdayState);
2836  heap_free(infoPtr->calendars);
2837  SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
2838 
2839  CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
2840 
2841  for (i = 0; i < BrushLast; i++) DeleteObject(infoPtr->brushes[i]);
2842  for (i = 0; i < PenLast; i++) DeleteObject(infoPtr->pens[i]);
2843 
2844  heap_free(infoPtr);
2845  return 0;
2846 }
HWND hwndSelf
Definition: monthcal.c:104
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int32_t INT
Definition: typedefs.h:56
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
HPEN pens[PenLast]
Definition: monthcal.c:109
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
MONTHDAYSTATE * monthdayState
Definition: monthcal.c:124
CALENDAR_INFO * calendars
Definition: monthcal.c:145
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
#define SetWindowLongPtrW
Definition: winuser.h:5215
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_DrawDay()

static void MONTHCAL_DrawDay ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const SYSTEMTIME st,
int  bold,
const PAINTSTRUCT ps 
)
static

Definition at line 786 of file monthcal.c.

788 {
789  static const WCHAR fmtW[] = { '%','d',0 };
790  WCHAR buf[10];
791  RECT r, r_temp;
792  COLORREF oldCol = 0;
793  COLORREF oldBk = 0;
794  INT old_bkmode, selection;
795 
796  /* no need to check styles: when selection is not valid, it is set to zero.
797  1 < day < 31, so everything is OK */
798  MONTHCAL_GetDayRect(infoPtr, st, &r, -1);
799  if(!IntersectRect(&r_temp, &(ps->rcPaint), &r)) return;
800 
801  if ((MONTHCAL_CompareDate(st, &infoPtr->minSel) >= 0) &&
802  (MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0))
803  {
804  TRACE("%d %d %d\n", st->wDay, infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
805  TRACE("%s\n", wine_dbgstr_rect(&r));
806  oldCol = SetTextColor(hdc, infoPtr->colors[MCSC_MONTHBK]);
807  oldBk = SetBkColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
808  FillRect(hdc, &r, infoPtr->brushes[BrushTitle]);
809 
810  selection = 1;
811  }
812  else
813  selection = 0;
814 
815  SelectObject(hdc, bold ? infoPtr->hBoldFont : infoPtr->hFont);
816 
817  old_bkmode = SetBkMode(hdc, TRANSPARENT);
818  wsprintfW(buf, fmtW, st->wDay);
820  SetBkMode(hdc, old_bkmode);
821 
822  if (selection)
823  {
824  SetTextColor(hdc, oldCol);
825  SetBkColor(hdc, oldBk);
826  }
827 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MCSC_MONTHBK
Definition: commctrl.h:4183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
int32_t INT
Definition: typedefs.h:56
int selection
Definition: ctm.c:92
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
HFONT hBoldFont
Definition: monthcal.c:112
#define TRANSPARENT
Definition: wingdi.h:949
#define DT_VCENTER
Definition: winuser.h:543
SYSTEMTIME maxSel
Definition: monthcal.c:131
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME minSel
Definition: monthcal.c:130
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD COLORREF
Definition: windef.h:285
const char * wine_dbgstr_rect(const RECT *rect)
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
HDC hdc
Definition: main.c:9
static LONG MONTHCAL_CompareDate(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:327
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
WORD wDay
Definition: winbase.h:873
#define DT_SINGLELINE
Definition: winuser.h:540
static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
Definition: monthcal.c:637
HFONT hFont
Definition: monthcal.c:111
#define MCSC_TRAILINGTEXT
Definition: commctrl.h:4184
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by MONTHCAL_PaintCalendar(), and MONTHCAL_PaintLeadTrailMonths().

◆ MONTHCAL_EditYear()

static void MONTHCAL_EditYear ( MONTHCAL_INFO infoPtr,
INT  calIdx 
)
static

Definition at line 2119 of file monthcal.c.

2120 {
2121  RECT *rc = &infoPtr->calendars[calIdx].titleyear;
2122  RECT *title = &infoPtr->calendars[calIdx].title;
2123 
2124  infoPtr->hWndYearEdit =
2126  rc->left + 3, (title->bottom + title->top - infoPtr->textHeight) / 2,
2127  rc->right - rc->left + 4,
2128  infoPtr->textHeight, infoPtr->hwndSelf,
2129  NULL, NULL, NULL);
2130 
2131  SendMessageW(infoPtr->hWndYearEdit, WM_SETFONT, (WPARAM)infoPtr->hBoldFont, TRUE);
2132 
2133  infoPtr->hWndYearUpDown =
2136  rc->right + 7, (title->bottom + title->top - infoPtr->textHeight) / 2,
2137  18, infoPtr->textHeight, infoPtr->hwndSelf,
2138  NULL, NULL, NULL);
2139 
2140  /* attach edit box */
2143  SendMessageW(infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM)infoPtr->hWndYearEdit, 0);
2144  SendMessageW(infoPtr->hWndYearUpDown, UDM_SETPOS, 0, infoPtr->calendars[calIdx].month.wYear);
2145 
2146  /* subclass edit box */
2147  infoPtr->EditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hWndYearEdit,
2149 
2150  SetFocus(infoPtr->hWndYearEdit);
2151 }
#define TRUE
Definition: types.h:120
#define WC_EDITW
Definition: commctrl.h:4658
static const SYSTEMTIME max_allowed_date
Definition: monthcal.c:154
int textHeight
Definition: monthcal.c:113
HWND hwndSelf
Definition: monthcal.c:104
static const SYSTEMTIME min_allowed_date
Definition: monthcal.c:155
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT_PTR WPARAM
Definition: windef.h:207
#define ES_READONLY
Definition: pedump.c:675
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
WORD wYear
Definition: winbase.h:870
#define UDS_NOTHOUSANDS
Definition: commctrl.h:2110
HFONT hBoldFont
Definition: monthcal.c:112
RECT titleyear
Definition: monthcal.c:94
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define UDS_ARROWKEYS
Definition: commctrl.h:2108
smooth NULL
Definition: ftsmooth.c:416
#define UDM_SETRANGE
Definition: commctrl.h:2113
HWND hWndYearUpDown
Definition: monthcal.c:142
static LRESULT CALLBACK EditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: monthcal.c:2082
WNDPROC EditWndProc
Definition: monthcal.c:143
HWND hWndYearEdit
Definition: monthcal.c:141
SYSTEMTIME month
Definition: monthcal.c:99
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)
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define GWLP_WNDPROC
Definition: treelist.c:66
CALENDAR_INFO * calendars
Definition: monthcal.c:145
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define UDM_SETBUDDY
Definition: commctrl.h:2117
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define UDM_SETPOS
Definition: commctrl.h:2115
#define WM_SETFONT
Definition: winuser.h:1632
#define UDS_SETBUDDYINT
Definition: commctrl.h:2104
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define UPDOWN_CLASSW
Definition: commctrl.h:2091
#define WS_VISIBLE
Definition: pedump.c:620
static char title[]
Definition: ps.c:92

Referenced by MONTHCAL_LButtonDown().

◆ MONTHCAL_EraseBkgnd()

static LRESULT MONTHCAL_EraseBkgnd ( const MONTHCAL_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 2449 of file monthcal.c.

2450 {
2451  RECT rc;
2452 
2453  if (!GetClipBox(hdc, &rc)) return FALSE;
2454 
2455  FillRect(hdc, &rc, infoPtr->brushes[BrushBackground]);
2456 
2457  return TRUE;
2458 }
#define TRUE
Definition: types.h:120
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
HDC hdc
Definition: main.c:9
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by MONTHCAL_PrintClient(), and MONTHCAL_WindowProc().

◆ MONTHCAL_GetCalCount()

◆ MONTHCAL_GetCalendarFromPoint()

static INT MONTHCAL_GetCalendarFromPoint ( const MONTHCAL_INFO infoPtr,
const POINT pt 
)
static

Definition at line 1775 of file monthcal.c.

1776 {
1777  RECT r;
1778  INT i;
1779 
1780  for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
1781  {
1782  /* whole bounding rectangle allows some optimization to compute */
1783  r.left = infoPtr->calendars[i].title.left;
1784  r.top = infoPtr->calendars[i].title.top;
1785  r.bottom = infoPtr->calendars[i].days.bottom;
1786  r.right = infoPtr->calendars[i].days.right;
1787 
1788  if (PtInRect(&r, *pt)) return i;
1789  }
1790 
1791  return -1;
1792 }
#define pt(x, y)
Definition: drawing.c:79
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
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
CALENDAR_INFO * calendars
Definition: monthcal.c:145
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
LONG bottom
Definition: windef.h:294
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_HitTest().

◆ MONTHCAL_GetColor()

static COLORREF MONTHCAL_GetColor ( const MONTHCAL_INFO infoPtr,
UINT  index 
)
static

Definition at line 1298 of file monthcal.c.

1299 {
1300  TRACE("%p, %d\n", infoPtr, index);
1301 
1302  if (index > MCSC_TRAILINGTEXT) return -1;
1303  return infoPtr->colors[index];
1304 }
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
#define index(s, c)
Definition: various.h:29
#define MCSC_TRAILINGTEXT
Definition: commctrl.h:4184

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetCurSel()

static LRESULT MONTHCAL_GetCurSel ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME curSel 
)
static

Definition at line 1543 of file monthcal.c.

1544 {
1545  TRACE("%p\n", curSel);
1546  if(!curSel) return FALSE;
1547  if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
1548 
1549  *curSel = infoPtr->minSel;
1550  TRACE("%d/%d/%d\n", curSel->wYear, curSel->wMonth, curSel->wDay);
1551  return TRUE;
1552 }
#define TRUE
Definition: types.h:120
WORD wMonth
Definition: winbase.h:871
WORD wYear
Definition: winbase.h:870
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME minSel
Definition: monthcal.c:130
DWORD dwStyle
Definition: monthcal.c:105
#define MCS_MULTISELECT
Definition: commctrl.h:4280
WORD wDay
Definition: winbase.h:873

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetDayFromPos()

static int MONTHCAL_GetDayFromPos ( const MONTHCAL_INFO infoPtr,
POINT  pt,
INT  calIdx 
)
static

Definition at line 565 of file monthcal.c.

566 {
567  SYSTEMTIME st = infoPtr->calendars[calIdx].month;
568  int firstDay, col, row;
569  RECT client;
570 
571  GetClientRect(infoPtr->hwndSelf, &client);
572 
573  /* if the point is outside the x bounds of the window put it at the boundary */
574  if (pt.x > client.right) pt.x = client.right;
575 
576  col = (pt.x - infoPtr->calendars[calIdx].days.left ) / infoPtr->width_increment;
577  row = (pt.y - infoPtr->calendars[calIdx].days.top ) / infoPtr->height_increment;
578 
579  st.wDay = 1;
580  firstDay = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
581  return col + 7 * row - firstDay;
582 }
#define pt(x, y)
Definition: drawing.c:79
HWND hwndSelf
Definition: monthcal.c:104
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
int width_increment
Definition: monthcal.c:115
static FILE * client
Definition: client.c:41
SYSTEMTIME month
Definition: monthcal.c:99
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int height_increment
Definition: monthcal.c:114
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by MONTHCAL_HitTest().

◆ MONTHCAL_GetDayPos()

static void MONTHCAL_GetDayPos ( const MONTHCAL_INFO infoPtr,
const SYSTEMTIME date,
INT col,
INT row,
INT  calIdx 
)
static

Definition at line 594 of file monthcal.c.

596 {
597  SYSTEMTIME st = infoPtr->calendars[calIdx].month;
598  INT first;
599 
600  st.wDay = 1;
601  first = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
602 
603  if (calIdx == 0 || calIdx == MONTHCAL_GetCalCount(infoPtr)-1) {
604  const SYSTEMTIME *cal = &infoPtr->calendars[calIdx].month;
606 
607  /* previous month */
608  if (cmp == -1) {
609  *col = (first - MONTHCAL_MonthLength(date->wMonth, cal->wYear) + date->wDay) % 7;
610  *row = 0;
611  return;
612  }
613 
614  /* next month calculation is same as for current, just add current month length */
615  if (cmp == 1)
616  first += MONTHCAL_MonthLength(cal->wMonth, cal->wYear);
617  }
618 
619  *col = (date->wDay + first) % 7;
620  *row = (date->wDay + first - *col) / 7;
621 }
WORD wMonth
Definition: winbase.h:871
const GLint * first
Definition: glext.h:5794
#define cmp(status, error)
Definition: error.c:114
int32_t INT
Definition: typedefs.h:56
WORD wYear
Definition: winbase.h:870
long LONG
Definition: pedump.c:60
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
SYSTEMTIME month
Definition: monthcal.c:99
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
__u16 date
Definition: mkdosfs.c:366
static LONG MONTHCAL_CompareMonths(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:315
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by MONTHCAL_GetDayRect(), and MONTHCAL_HitTest().

◆ MONTHCAL_GetDayRect()

static BOOL MONTHCAL_GetDayRect ( const MONTHCAL_INFO infoPtr,
const SYSTEMTIME date,
RECT r,
INT  calIdx 
)
static

Definition at line 637 of file monthcal.c.

638 {
639  INT col, row;
640 
642  {
643  SetRectEmpty(r);
644  return FALSE;
645  }
646 
647  if (calIdx == -1)
648  {
650 
651  if (cmp <= 0)
652  calIdx = 0;
653  else
654  {
656  if (cmp >= 0)
657  calIdx = MONTHCAL_GetCalCount(infoPtr)-1;
658  else
659  {
660  for (calIdx = 1; calIdx < MONTHCAL_GetCalCount(infoPtr)-1; calIdx++)
661  if (MONTHCAL_CompareMonths(date, &infoPtr->calendars[calIdx].month) == 0)
662  break;
663  }
664  }
665  }
666 
667  MONTHCAL_GetDayPos(infoPtr, date, &col, &row, calIdx);
668  MONTHCAL_GetDayRectI(infoPtr, r, col, row, calIdx);
669 
670  return TRUE;
671 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define cmp(status, error)
Definition: error.c:114
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_GetDayPos(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, INT *col, INT *row, INT calIdx)
Definition: monthcal.c:594
SYSTEMTIME month
Definition: monthcal.c:99
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
static BOOL MONTHCAL_ValidateDate(const SYSTEMTIME *time)
Definition: monthcal.c:251
CALENDAR_INFO * calendars
Definition: monthcal.c:145
__u16 date
Definition: mkdosfs.c:366
static void MONTHCAL_GetDayRectI(const MONTHCAL_INFO *infoPtr, RECT *r, INT col, INT row, INT calIdx)
Definition: monthcal.c:624
static LONG MONTHCAL_CompareMonths(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:315
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165
int month[12]
Definition: systime.c:13
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by MONTHCAL_CircleDay(), MONTHCAL_DrawDay(), MONTHCAL_MouseMove(), MONTHCAL_PaintFocusAndCircle(), MONTHCAL_SetCurSel(), MONTHCAL_SetDayFocus(), and MONTHCAL_UpdateToday().

◆ MONTHCAL_GetDayRectI()

static void MONTHCAL_GetDayRectI ( const MONTHCAL_INFO infoPtr,
RECT r,
INT  col,
INT  row,
INT  calIdx 
)
inlinestatic

Definition at line 624 of file monthcal.c.

626 {
627  r->left = infoPtr->calendars[calIdx].days.left + col * infoPtr->width_increment;
628  r->right = r->left + infoPtr->width_increment;
629  r->top = infoPtr->calendars[calIdx].days.top + row * infoPtr->height_increment;
630  r->bottom = r->top + infoPtr->textHeight;
631 }
int textHeight
Definition: monthcal.c:113
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
int width_increment
Definition: monthcal.c:115
CALENDAR_INFO * calendars
Definition: monthcal.c:145
int height_increment
Definition: monthcal.c:114
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by MONTHCAL_GetDayRect(), MONTHCAL_HitTest(), and MONTHCAL_PaintTodayTitle().

◆ MONTHCAL_GetFirstDayOfWeek()

static LRESULT MONTHCAL_GetFirstDayOfWeek ( const MONTHCAL_INFO infoPtr)
inlinestatic

Definition at line 1377 of file monthcal.c.

1378 {
1379  int day;
1380 
1381  /* convert from SYSTEMTIME to locale format */
1382  day = (infoPtr->firstDay >= 0) ? (infoPtr->firstDay+6)%7 : infoPtr->firstDay;
1383 
1384  return MAKELONG(day, infoPtr->firstDaySet);
1385 }
static DOUBLE day(DOUBLE time)
Definition: date.c:115
BOOL firstDaySet
Definition: monthcal.c:120
#define MAKELONG(a, b)
Definition: typedefs.h:248

Referenced by MONTHCAL_SetFirstDayOfWeek(), and MONTHCAL_WindowProc().

◆ MONTHCAL_GetFont()

static LRESULT MONTHCAL_GetFont ( const MONTHCAL_INFO infoPtr)
static

Definition at line 2681 of file monthcal.c.

2682 {
2683  return (LRESULT)infoPtr->hFont;
2684 }
HFONT hFont
Definition: monthcal.c:111
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetMaxDate()

static void MONTHCAL_GetMaxDate ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME date 
)
static

Definition at line 534 of file monthcal.c.

535 {
536  /* the latest date is in latest calendar */
537  SYSTEMTIME st, *lt_month = &infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
538  INT first_day;
539 
540  *date = *lt_month;
541  st = *lt_month;
542 
543  /* day of week of first day of current month */
544  st.wDay = 1;
545  first_day = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
546 
549 
550  /* last calendar starts with some date from previous month that not displayed */
551  st.wDay = MONTHCAL_MonthLength(st.wMonth, st.wYear) +
552  (infoPtr->firstDay - first_day) % 7 + 1;
553  if (st.wDay > MONTHCAL_MonthLength(st.wMonth, st.wYear)) st.wDay -= 7;
554 
555  /* Use month length to get max day. 42 means max day count in calendar area */
556  date->wDay = 42 - (MONTHCAL_MonthLength(st.wMonth, st.wYear) - st.wDay + 1) -
557  MONTHCAL_MonthLength(lt_month->wMonth, lt_month->wYear);
558 
559  /* fix day of week */
561 }
#define TRUE
Definition: types.h:120
WORD wMonth
Definition: winbase.h:871
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_GetPrevMonth(SYSTEMTIME *date)
Definition: monthcal.c:505
WORD wYear
Definition: winbase.h:870
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
SYSTEMTIME month
Definition: monthcal.c:99
static void MONTHCAL_GetNextMonth(SYSTEMTIME *date)
Definition: monthcal.c:499
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
__u16 date
Definition: mkdosfs.c:366
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_GetMonthRange(), and MONTHCAL_PaintLeadTrailMonths().

◆ MONTHCAL_GetMaxSelCount()

static LRESULT MONTHCAL_GetMaxSelCount ( const MONTHCAL_INFO infoPtr)
static

Definition at line 1618 of file monthcal.c.

1619 {
1620  return infoPtr->maxSelCount;
1621 }
INT maxSelCount
Definition: monthcal.c:129

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetMaxTodayWidth()

static LRESULT MONTHCAL_GetMaxTodayWidth ( const MONTHCAL_INFO infoPtr)
static

Definition at line 1450 of file monthcal.c.

1451 {
1452  return(infoPtr->todayrect.right - infoPtr->todayrect.left);
1453 }
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
RECT todayrect
Definition: monthcal.c:139

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetMinDate()

static void MONTHCAL_GetMinDate ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME date 
)
static

Definition at line 511 of file monthcal.c.

512 {
513  /* zero indexed calendar has the earliest date */
514  SYSTEMTIME st_first = infoPtr->calendars[0].month;
515  INT firstDay;
516 
517  st_first.wDay = 1;
518  firstDay = MONTHCAL_CalculateDayOfWeek(&st_first, FALSE);
519 
520  *date = infoPtr->calendars[0].month;
522 
523  date->wDay = MONTHCAL_MonthLength(date->wMonth, date->wYear) +
524  (infoPtr->firstDay - firstDay) % 7 + 1;
525 
526  if(date->wDay > MONTHCAL_MonthLength(date->wMonth, date->wYear))
527  date->wDay -= 7;
528 
529  /* fix day of week */
531 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_GetPrevMonth(SYSTEMTIME *date)
Definition: monthcal.c:505
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
SYSTEMTIME month
Definition: monthcal.c:99
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
__u16 date
Definition: mkdosfs.c:366

Referenced by MONTHCAL_GetMonthRange(), MONTHCAL_NotifyDayState(), MONTHCAL_PaintLeadTrailMonths(), and MONTHCAL_PaintWeeknumbers().

◆ MONTHCAL_GetMinReqRect()

static LRESULT MONTHCAL_GetMinReqRect ( const MONTHCAL_INFO infoPtr,
RECT rect 
)
static

Definition at line 1277 of file monthcal.c.

1278 {
1279  TRACE("rect %p\n", rect);
1280 
1281  if(!rect) return FALSE;
1282 
1283  *rect = infoPtr->calendars[0].title;
1284  rect->bottom = infoPtr->calendars[0].days.bottom + infoPtr->todayrect.bottom -
1285  infoPtr->todayrect.top;
1286 
1287  AdjustWindowRect(rect, infoPtr->dwStyle, FALSE);
1288 
1289  /* minimal rectangle is zero based */
1290  OffsetRect(rect, -rect->left, -rect->top);
1291 
1292  TRACE("%s\n", wine_dbgstr_rect(rect));
1293 
1294  return TRUE;
1295 }
#define TRUE
Definition: types.h:120
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
LONG top
Definition: windef.h:292
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwStyle
Definition: monthcal.c:105
const char * wine_dbgstr_rect(const RECT *rect)
CALENDAR_INFO * calendars
Definition: monthcal.c:145
RECT todayrect
Definition: monthcal.c:139
LONG bottom
Definition: windef.h:294

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetMonth()

static void MONTHCAL_GetMonth ( SYSTEMTIME date,
INT  months 
)
inlinestatic

Definition at line 486 of file monthcal.c.

487 {
488  INT length, m = date->wMonth + months;
489 
490  date->wYear += m > 0 ? (m - 1) / 12 : m / 12 - 1;
491  date->wMonth = m > 0 ? (m - 1) % 12 + 1 : 12 + m % 12;
492  /* fix moving from last day in a month */
493  length = MONTHCAL_MonthLength(date->wMonth, date->wYear);
494  if(date->wDay > length) date->wDay = length;
496 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
const GLfloat * m
Definition: glext.h:10848
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
__u16 date
Definition: mkdosfs.c:366

Referenced by MONTHCAL_GetNextMonth(), MONTHCAL_GetPrevMonth(), MONTHCAL_GoToMonth(), MONTHCAL_LButtonDown(), MONTHCAL_Scroll(), MONTHCAL_SetCurSel(), MONTHCAL_SetSelRange(), and MONTHCAL_UpdateSize().

◆ MONTHCAL_GetMonthDelta()

static LRESULT MONTHCAL_GetMonthDelta ( const MONTHCAL_INFO infoPtr)
static

Definition at line 1353 of file monthcal.c.

1354 {
1355  TRACE("\n");
1356 
1357  if(infoPtr->delta)
1358  return infoPtr->delta;
1359 
1360  return MONTHCAL_GetMonthRange(infoPtr, GMR_VISIBLE, NULL);
1361 }
static LRESULT MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
Definition: monthcal.c:674
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GMR_VISIBLE
Definition: commctrl.h:4287

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetMonthRange()

static LRESULT MONTHCAL_GetMonthRange ( const MONTHCAL_INFO infoPtr,
DWORD  flag,
SYSTEMTIME st 
)
static

Definition at line 674 of file monthcal.c.

675 {
676  INT range;
677 
678  TRACE("flag=%d, st=%p\n", flag, st);
679 
680  switch (flag) {
681  case GMR_VISIBLE:
682  {
683  if (st)
684  {
685  st[0] = infoPtr->calendars[0].month;
686  st[1] = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
687 
688  if (st[0].wMonth == min_allowed_date.wMonth &&
689  st[0].wYear == min_allowed_date.wYear)
690  {
691  st[0].wDay = min_allowed_date.wDay;
692  }
693  else
694  st[0].wDay = 1;
696 
697  st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].wYear);
699  }
700 
701  range = MONTHCAL_GetCalCount(infoPtr);
702  break;
703  }
704  case GMR_DAYSTATE:
705  {
706  if (st)
707  {
708  MONTHCAL_GetMinDate(infoPtr, &st[0]);
709  MONTHCAL_GetMaxDate(infoPtr, &st[1]);
710  }
711  /* include two partially visible months */
712  range = MONTHCAL_GetCalCount(infoPtr) + 2;
713  break;
714  }
715  default:
716  WARN("Unknown flag value, got %d\n", flag);
717  range = 0;
718  }
719 
720  return range;
721 }
#define TRUE
Definition: types.h:120
WORD wMonth
Definition: winbase.h:871
#define WARN(fmt,...)
Definition: debug.h:111
static const SYSTEMTIME min_allowed_date
Definition: monthcal.c:155
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
Definition: monthcal.c:534
WORD wYear
Definition: winbase.h:870
#define GMR_DAYSTATE
Definition: commctrl.h:4288
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME month
Definition: monthcal.c:99
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
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
static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
Definition: monthcal.c:511
GLenum GLint * range
Definition: glext.h:7539
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
#define GMR_VISIBLE
Definition: commctrl.h:4287
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_GetMonthDelta(), MONTHCAL_NotifyDayState(), MONTHCAL_PaintLeadTrailMonths(), MONTHCAL_SetDayState(), MONTHCAL_UpdateSize(), and MONTHCAL_WindowProc().

◆ MONTHCAL_GetNextMonth()

static void MONTHCAL_GetNextMonth ( SYSTEMTIME date)
inlinestatic

Definition at line 499 of file monthcal.c.

500 {
502 }
__u16 date
Definition: mkdosfs.c:366
static void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months)
Definition: monthcal.c:486

Referenced by MONTHCAL_GetMaxDate(), MONTHCAL_HitTest(), and MONTHCAL_PaintLeadTrailMonths().

◆ MONTHCAL_GetPrevMonth()

static void MONTHCAL_GetPrevMonth ( SYSTEMTIME date)
inlinestatic

Definition at line 505 of file monthcal.c.

506 {
507  MONTHCAL_GetMonth(date, -1);
508 }
__u16 date
Definition: mkdosfs.c:366
static void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months)
Definition: monthcal.c:486

Referenced by MONTHCAL_GetMaxDate(), MONTHCAL_GetMinDate(), and MONTHCAL_HitTest().

◆ MONTHCAL_GetRange()

static LRESULT MONTHCAL_GetRange ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME range 
)
static

Definition at line 1516 of file monthcal.c.

1517 {
1518  TRACE("%p\n", range);
1519 
1520  if (!range) return 0;
1521 
1522  range[1] = infoPtr->maxDate;
1523  range[0] = infoPtr->minDate;
1524 
1525  return infoPtr->rangeValid;
1526 }
SYSTEMTIME minDate
Definition: monthcal.c:134
#define TRACE(s)
Definition: solgame.cpp:4
DWORD rangeValid
Definition: monthcal.c:133
GLenum GLint * range
Definition: glext.h:7539
SYSTEMTIME maxDate
Definition: monthcal.c:135

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetSelRange()

static LRESULT MONTHCAL_GetSelRange ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME range 
)
static

Definition at line 1639 of file monthcal.c.

1640 {
1641  TRACE("%p\n", range);
1642 
1643  if(!range) return FALSE;
1644 
1645  if(infoPtr->dwStyle & MCS_MULTISELECT)
1646  {
1647  range[1] = infoPtr->maxSel;
1648  range[0] = infoPtr->minSel;
1649  TRACE("[min,max]=[%d %d]\n", infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
1650  return TRUE;
1651  }
1652 
1653  return FALSE;
1654 }
#define TRUE
Definition: types.h:120
SYSTEMTIME maxSel
Definition: monthcal.c:131
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME minSel
Definition: monthcal.c:130
DWORD dwStyle
Definition: monthcal.c:105
#define MCS_MULTISELECT
Definition: commctrl.h:4280
GLenum GLint * range
Definition: glext.h:7539
WORD wDay
Definition: winbase.h:873

Referenced by MONTHCAL_MouseMove(), MONTHCAL_Scroll(), and MONTHCAL_WindowProc().

◆ MONTHCAL_GetToday()

static LRESULT MONTHCAL_GetToday ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME today 
)
static

Definition at line 1722 of file monthcal.c.

1723 {
1724  TRACE("%p\n", today);
1725 
1726  if(!today) return FALSE;
1727  *today = infoPtr->todaysDate;
1728  return TRUE;
1729 }
#define TRUE
Definition: types.h:120
SYSTEMTIME todaysDate
Definition: monthcal.c:125
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GetUnicodeFormat()

static BOOL MONTHCAL_GetUnicodeFormat ( const MONTHCAL_INFO infoPtr)
inlinestatic

Definition at line 2879 of file monthcal.c.

2880 {
2881  return infoPtr->isUnicode;
2882 }
BOOL isUnicode
Definition: monthcal.c:122

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_GoToMonth()

static void MONTHCAL_GoToMonth ( MONTHCAL_INFO infoPtr,
enum nav_direction  direction 
)
static

Definition at line 2009 of file monthcal.c.

2010 {
2011  INT delta = infoPtr->delta ? infoPtr->delta : MONTHCAL_GetCalCount(infoPtr);
2012  BOOL keep_selection;
2013  SYSTEMTIME st;
2014 
2015  TRACE("%s\n", direction == DIRECTION_BACKWARD ? "back" : "fwd");
2016 
2017  /* check if change allowed by range set */
2018  if(direction == DIRECTION_BACKWARD)
2019  {
2020  st = infoPtr->calendars[0].month;
2021  MONTHCAL_GetMonth(&st, -delta);
2022  }
2023  else
2024  {
2025  st = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
2026  MONTHCAL_GetMonth(&st, delta);
2027  }
2028 
2029  if(!MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE)) return;
2030 
2031  keep_selection = infoPtr->dwStyle & MCS_NOSELCHANGEONNAV;
2032  MONTHCAL_Scroll(infoPtr, direction == DIRECTION_BACKWARD ? -delta : delta, keep_selection);
2033  MONTHCAL_NotifyDayState(infoPtr);
2034  if (!keep_selection)
2036 }
static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:1950
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
static void MONTHCAL_Scroll(MONTHCAL_INFO *infoPtr, INT delta, BOOL keep_selection)
Definition: monthcal.c:1974
static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date, BOOL fix)
Definition: monthcal.c:351
#define TRACE(s)
Definition: solgame.cpp:4
#define MCS_NOSELCHANGEONNAV
Definition: monthcal.c:55
DWORD dwStyle
Definition: monthcal.c:105
static void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:171
SYSTEMTIME month
Definition: monthcal.c:99
CALENDAR_INFO * calendars
Definition: monthcal.c:145
static void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months)
Definition: monthcal.c:486
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_LButtonDown(), and MONTHCAL_Timer().

◆ MONTHCAL_HitTest()

static LRESULT MONTHCAL_HitTest ( const MONTHCAL_INFO infoPtr,
MCHITTESTINFO lpht 
)
static

Definition at line 1806 of file monthcal.c.

1807 {
1808  MCHITTESTINFO htinfo;
1809  SYSTEMTIME *ht_month;
1810  INT day, calIdx;
1811 
1812  if(!lpht || lpht->cbSize < MCHITTESTINFO_V1_SIZE) return -1;
1813 
1814  htinfo.st = st_null;
1815 
1816  /* we should preserve passed fields if hit area doesn't need them */
1817  if (lpht->cbSize == sizeof(MCHITTESTINFO))
1818  memcpy(&htinfo.rc, &lpht->rc, sizeof(MCHITTESTINFO) - MCHITTESTINFO_V1_SIZE);
1819 
1820  /* guess in what calendar we are */
1821  calIdx = MONTHCAL_GetCalendarFromPoint(infoPtr, &lpht->pt);
1822  if (calIdx == -1)
1823  {
1824  if (PtInRect(&infoPtr->todayrect, lpht->pt))
1825  {
1826  htinfo.uHit = MCHT_TODAYLINK;
1827  htinfo.rc = infoPtr->todayrect;
1828  }
1829  else
1830  /* outside of calendar area? What's left must be background :-) */
1831  htinfo.uHit = MCHT_CALENDARBK;
1832 
1833  return fill_hittest_info(&htinfo, lpht);
1834  }
1835 
1836  /* are we in the header? */
1837  if (PtInRect(&infoPtr->calendars[calIdx].title, lpht->pt)) {
1838  /* FIXME: buttons hittesting could be optimized cause maximum
1839  two calendars have buttons */
1840  if (calIdx == 0 && PtInRect(&infoPtr->titlebtnprev, lpht->pt))
1841  {
1842  htinfo.uHit = MCHT_TITLEBTNPREV;
1843  htinfo.rc = infoPtr->titlebtnprev;
1844  }
1845  else if (PtInRect(&infoPtr->titlebtnnext, lpht->pt))
1846  {
1847  htinfo.uHit = MCHT_TITLEBTNNEXT;
1848  htinfo.rc = infoPtr->titlebtnnext;
1849  }
1850  else if (PtInRect(&infoPtr->calendars[calIdx].titlemonth, lpht->pt))
1851  {
1852  htinfo.uHit = MCHT_TITLEMONTH;
1853  htinfo.rc = infoPtr->calendars[calIdx].titlemonth;
1854  htinfo.iOffset = calIdx;
1855  }
1856  else if (PtInRect(&infoPtr->calendars[calIdx].titleyear, lpht->pt))
1857  {
1858  htinfo.uHit = MCHT_TITLEYEAR;
1859  htinfo.rc = infoPtr->calendars[calIdx].titleyear;
1860  htinfo.iOffset = calIdx;
1861  }
1862  else
1863  {
1864  htinfo.uHit = MCHT_TITLE;
1865  htinfo.rc = infoPtr->calendars[calIdx].title;
1866  htinfo.iOffset = calIdx;
1867  }
1868 
1869  return fill_hittest_info(&htinfo, lpht);
1870  }
1871 
1872  ht_month = &infoPtr->calendars[calIdx].month;
1873  /* days area (including week days and week numbers) */
1874  day = MONTHCAL_GetDayFromPos(infoPtr, lpht->pt, calIdx);
1875  if (PtInRect(&infoPtr->calendars[calIdx].wdays, lpht->pt))
1876  {
1877  htinfo.uHit = MCHT_CALENDARDAY;
1878  htinfo.iOffset = calIdx;
1879  htinfo.st.wYear = ht_month->wYear;
1880  htinfo.st.wMonth = (day < 1) ? ht_month->wMonth -1 : ht_month->wMonth;
1881  htinfo.st.wDay = (day < 1) ?
1882  MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day : day;
1883 
1884  MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx);
1885  }
1886  else if(PtInRect(&infoPtr->calendars[calIdx].weeknums, lpht->pt))
1887  {
1888  htinfo.uHit = MCHT_CALENDARWEEKNUM;
1889  htinfo.st.wYear = ht_month->wYear;
1890  htinfo.iOffset = calIdx;
1891 
1892  if (day < 1)
1893  {
1894  htinfo.st.wMonth = ht_month->wMonth - 1;
1895  htinfo.st.wDay = MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day;
1896  }
1897  else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
1898  {
1899  htinfo.st.wMonth = ht_month->wMonth + 1;
1900  htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
1901  }
1902  else
1903  {
1904  htinfo.st.wMonth = ht_month->wMonth;
1905  htinfo.st.wDay = day;
1906  }
1907  }
1908  else if(PtInRect(&infoPtr->calendars[calIdx].days, lpht->pt))
1909  {
1910  htinfo.iOffset = calIdx;
1911  htinfo.st.wDay = ht_month->wDay;
1912  htinfo.st.wYear = ht_month->wYear;
1913  htinfo.st.wMonth = ht_month->wMonth;
1914  /* previous month only valid for first calendar */
1915  if (day < 1 && calIdx == 0)
1916  {
1917  htinfo.uHit = MCHT_CALENDARDATEPREV;
1918  MONTHCAL_GetPrevMonth(&htinfo.st);
1919  htinfo.st.wDay = MONTHCAL_MonthLength(htinfo.st.wMonth, htinfo.st.wYear) + day;
1920  }
1921  /* next month only valid for last calendar */
1922  else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear) &&
1923  calIdx == MONTHCAL_GetCalCount(infoPtr)-1)
1924  {
1925  htinfo.uHit = MCHT_CALENDARDATENEXT;
1926  MONTHCAL_GetNextMonth(&htinfo.st);
1927  htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
1928  }
1929  /* multiple calendars case - blank areas for previous/next month */
1930  else if (day < 1 || day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
1931  {
1932  htinfo.uHit = MCHT_CALENDARBK;
1933  }
1934  else
1935  {
1936  htinfo.uHit = MCHT_CALENDARDATE;
1937  htinfo.st.wDay = day;
1938  }
1939 
1940  MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx);
1941  MONTHCAL_GetDayRectI(infoPtr, &htinfo.rc, htinfo.iCol, htinfo.iRow, calIdx);
1942  /* always update day of week */
1944  }
1945 
1946  return fill_hittest_info(&htinfo, lpht);
1947 }
#define MCHT_CALENDARDATENEXT
Definition: commctrl.h:4225
#define TRUE
Definition: types.h:120
#define MCHT_CALENDARDATE
Definition: commctrl.h:4224
RECT titlebtnprev
Definition: monthcal.c:138
#define MCHT_TITLEBTNPREV
Definition: commctrl.h:4221
static UINT fill_hittest_info(const MCHITTESTINFO *src, MCHITTESTINFO *dest)
Definition: monthcal.c:1794
WORD wMonth
Definition: winbase.h:871
#define MCHT_CALENDARWEEKNUM
Definition: commctrl.h:4228
#define MCHT_TITLEBTNNEXT
Definition: commctrl.h:4220
static DOUBLE day(DOUBLE time)
Definition: date.c:115
#define MCHT_TODAYLINK
Definition: commctrl.h:4210
RECT weeknums
Definition: monthcal.c:97
int32_t INT
Definition: typedefs.h:56
static INT MONTHCAL_GetCalendarFromPoint(const MONTHCAL_INFO *infoPtr, const POINT *pt)
Definition: monthcal.c:1775
static void MONTHCAL_GetPrevMonth(SYSTEMTIME *date)
Definition: monthcal.c:505
WORD wYear
Definition: winbase.h:870
RECT titleyear
Definition: monthcal.c:94
#define MCHT_CALENDARBK
Definition: commctrl.h:4223
static void MONTHCAL_GetDayPos(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, INT *col, INT *row, INT calIdx)
Definition: monthcal.c:594
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
#define MCHT_TITLE
Definition: commctrl.h:4208
RECT titlemonth
Definition: monthcal.c:93
SYSTEMTIME month
Definition: monthcal.c:99
static void MONTHCAL_GetNextMonth(SYSTEMTIME *date)
Definition: monthcal.c:499
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
Definition: monthcal.c:470
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MCHT_TITLEMONTH
Definition: commctrl.h:4218
CALENDAR_INFO * calendars
Definition: monthcal.c:145
WORD wDay
Definition: winbase.h:873
SYSTEMTIME st
Definition: commctrl.h:4197
RECT titlebtnnext
Definition: monthcal.c:137
RECT todayrect
Definition: monthcal.c:139
static const SYSTEMTIME st_null
Definition: monthcal.c:152
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define MCHITTESTINFO_V1_SIZE
Definition: commctrl.h:4206
#define MCHT_CALENDARDAY
Definition: commctrl.h:4227
static void MONTHCAL_GetDayRectI(const MONTHCAL_INFO *infoPtr, RECT *r, INT col, INT row, INT calIdx)
Definition: monthcal.c:624
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165
static int MONTHCAL_GetDayFromPos(const MONTHCAL_INFO *infoPtr, POINT pt, INT calIdx)
Definition: monthcal.c:565
#define MCHT_CALENDARDATEPREV
Definition: commctrl.h:4226
#define MCHT_TITLEYEAR
Definition: commctrl.h:4219

Referenced by MONTHCAL_LButtonDown(), MONTHCAL_LButtonUp(), MONTHCAL_MouseMove(), and MONTHCAL_WindowProc().

◆ MONTHCAL_IsDateEqual()

static BOOL MONTHCAL_IsDateEqual ( const SYSTEMTIME first,
const SYSTEMTIME second 
)
inlinestatic

Definition at line 244 of file monthcal.c.

245 {
246  return (first->wYear == second->wYear) && (first->wMonth == second->wMonth) &&
247  (first->wDay == second->wDay);
248 }
WORD wMonth
Definition: winbase.h:871
const GLint * first
Definition: glext.h:5794
WORD wYear
Definition: winbase.h:870
WORD wDay
Definition: winbase.h:873

Referenced by MONTHCAL_LButtonUp(), MONTHCAL_MouseMove(), MONTHCAL_PaintFocusAndCircle(), MONTHCAL_SetCurSel(), MONTHCAL_SetDayFocus(), MONTHCAL_SetSelRange(), and MONTHCAL_UpdateToday().

◆ MONTHCAL_IsDateInValidRange()

static BOOL MONTHCAL_IsDateInValidRange ( const MONTHCAL_INFO infoPtr,
SYSTEMTIME date,
BOOL  fix 
)
static

Definition at line 351 of file monthcal.c.

353 {
354  const SYSTEMTIME *fix_st = NULL;
355 
357  fix_st = &max_allowed_date;
358  }
360  fix_st = &min_allowed_date;
361  }
362  else {
363  if(infoPtr->rangeValid & GDTR_MAX) {
364  if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxDate) == 1)) {
365  fix_st = &infoPtr->maxDate;
366  }
367  }
368 
369  if(infoPtr->rangeValid & GDTR_MIN) {
370  if((MONTHCAL_CompareSystemTime(date, &infoPtr->minDate) == -1)) {
371  fix_st = &infoPtr->minDate;
372  }
373  }
374  }
375 
376  if (fix && fix_st) {
377  date->wYear = fix_st->wYear;
378  date->wMonth = fix_st->wMonth;
379  }
380 
381  return !fix_st;
382 }
static const SYSTEMTIME max_allowed_date
Definition: monthcal.c:154
WORD wMonth
Definition: winbase.h:871
SYSTEMTIME minDate
Definition: monthcal.c:134
static const SYSTEMTIME min_allowed_date
Definition: monthcal.c:155
WORD wYear
Definition: winbase.h:870
smooth NULL
Definition: ftsmooth.c:416
DWORD rangeValid
Definition: monthcal.c:133
#define GDTR_MAX
Definition: commctrl.h:4429
#define GDTR_MIN
Definition: commctrl.h:4428
LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:305
__u16 date
Definition: mkdosfs.c:366
SYSTEMTIME maxDate
Definition: monthcal.c:135

Referenced by MONTHCAL_GoToMonth(), MONTHCAL_LButtonDown(), and MONTHCAL_SetCurSel().

◆ MONTHCAL_IsSelRangeValid()

static BOOL MONTHCAL_IsSelRangeValid ( const MONTHCAL_INFO infoPtr,
const SYSTEMTIME range0,
const SYSTEMTIME range1,
SYSTEMTIME adjust 
)
static

Definition at line 402 of file monthcal.c.

406 {
407  ULARGE_INTEGER ul_range0, ul_range1, ul_diff;
408  FILETIME ft_range0, ft_range1;
409  LONG cmp;
410 
411  SystemTimeToFileTime(range0, &ft_range0);
412  SystemTimeToFileTime(range1, &ft_range1);
413 
414  ul_range0.u.LowPart = ft_range0.dwLowDateTime;
415  ul_range0.u.HighPart = ft_range0.dwHighDateTime;
416  ul_range1.u.LowPart = ft_range1.dwLowDateTime;
417  ul_range1.u.HighPart = ft_range1.dwHighDateTime;
418 
419  cmp = CompareFileTime(&ft_range0, &ft_range1);
420 
421  if(cmp == 1)
422  ul_diff.QuadPart = ul_range0.QuadPart - ul_range1.QuadPart;
423  else
424  ul_diff.QuadPart = -ul_range0.QuadPart + ul_range1.QuadPart;
425 
426  if(ul_diff.QuadPart >= DAYSTO100NSECS(infoPtr->maxSelCount)) {
427 
428  if(adjust) {
429  if(cmp == 1)
430  ul_range0.QuadPart = ul_range1.QuadPart + DAYSTO100NSECS(infoPtr->maxSelCount - 1);
431  else
432  ul_range0.QuadPart = ul_range1.QuadPart - DAYSTO100NSECS(infoPtr->maxSelCount - 1);
433 
434  ft_range0.dwLowDateTime = ul_range0.u.LowPart;
435  ft_range0.dwHighDateTime = ul_range0.u.HighPart;
436  FileTimeToSystemTime(&ft_range0, adjust);
437  }
438 
439  return FALSE;
440  }
441  else return TRUE;
442 }
struct _ULARGE_INTEGER::@3744 u
#define TRUE
Definition: types.h:120
INT maxSelCount
Definition: monthcal.c:129
#define cmp(status, error)
Definition: error.c:114
DWORD dwHighDateTime
Definition: mapidefs.h:66
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
long LONG
Definition: pedump.c:60
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
#define DAYSTO100NSECS(days)
Definition: monthcal.c:72
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by MONTHCAL_MouseMove(), and MONTHCAL_SetSelRange().

◆ MONTHCAL_LButtonDown()

static LRESULT MONTHCAL_LButtonDown ( MONTHCAL_INFO infoPtr,
LPARAM  lParam 
)
static

Definition at line 2154 of file monthcal.c.

2155 {
2156  MCHITTESTINFO ht;
2157  DWORD hit;
2158 
2159  /* Actually we don't need input focus for calendar, this is used to kill
2160  year updown and its buddy edit box */
2161  if (IsWindow(infoPtr->hWndYearUpDown))
2162  {
2163  SetFocus(infoPtr->hwndSelf);
2164  return 0;
2165  }
2166 
2167  SetCapture(infoPtr->hwndSelf);
2168 
2169  ht.cbSize = sizeof(MCHITTESTINFO);
2170  ht.pt.x = (short)LOWORD(lParam);
2171  ht.pt.y = (short)HIWORD(lParam);
2172 
2173  hit = MONTHCAL_HitTest(infoPtr, &ht);
2174 
2175  TRACE("%x at %s\n", hit, wine_dbgstr_point(&ht.pt));
2176 
2177  switch(hit)
2178  {
2179  case MCHT_TITLEBTNNEXT:
2181  infoPtr->status = MC_NEXTPRESSED;
2183  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
2184  return 0;
2185 
2186  case MCHT_TITLEBTNPREV:
2188  infoPtr->status = MC_PREVPRESSED;
2190  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
2191  return 0;
2192 
2193  case MCHT_TITLEMONTH:
2194  {
2195  HMENU hMenu = CreatePopupMenu();
2196  WCHAR buf[32];
2197  POINT menupoint;
2198  INT i;
2199 
2200  for (i = 0; i < 12; i++)
2201  {
2203  AppendMenuW(hMenu, MF_STRING|MF_ENABLED, i + 1, buf);
2204  }
2205  menupoint.x = ht.pt.x;
2206  menupoint.y = ht.pt.y;
2207  ClientToScreen(infoPtr->hwndSelf, &menupoint);
2209  menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL);
2210 
2211  if ((i > 0) && (i < 13) && infoPtr->calendars[ht.iOffset].month.wMonth != i)
2212  {
2213  INT delta = i - infoPtr->calendars[ht.iOffset].month.wMonth;
2214  SYSTEMTIME st;
2215 
2216  /* check if change allowed by range set */
2217  st = delta < 0 ? infoPtr->calendars[0].month :
2218  infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
2219  MONTHCAL_GetMonth(&st, delta);
2220 
2221  if (MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE))
2222  {
2223  MONTHCAL_Scroll(infoPtr, delta, FALSE);
2224  MONTHCAL_NotifyDayState(infoPtr);
2226  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
2227  }
2228  }
2229  return 0;
2230  }
2231  case MCHT_TITLEYEAR:
2232  {
2233  MONTHCAL_EditYear(infoPtr, ht.iOffset);
2234  return 0;
2235  }
2236  case MCHT_TODAYLINK:
2237  {
2238  if (infoPtr->dwStyle & MCS_MULTISELECT)
2239  {
2240  SYSTEMTIME range[2];
2241 
2242  range[0] = range[1] = infoPtr->todaysDate;
2243  MONTHCAL_SetSelRange(infoPtr, range);
2244  }
2245  else
2246  MONTHCAL_SetCurSel(infoPtr, &infoPtr->todaysDate);
2247 
2249  MONTHCAL_NotifySelect(infoPtr);
2250  return 0;
2251  }
2252  case MCHT_CALENDARDATENEXT:
2253  case MCHT_CALENDARDATEPREV:
2254  case MCHT_CALENDARDATE:
2255  {
2256  SYSTEMTIME st[2];
2257 
2258  MONTHCAL_CopyDate(&ht.st, &infoPtr->firstSel);
2259 
2260  st[0] = st[1] = ht.st;
2261  /* clear selection range */
2262  MONTHCAL_SetSelRange(infoPtr, st);
2263 
2264  infoPtr->status = MC_SEL_LBUTDOWN;
2265  MONTHCAL_SetDayFocus(infoPtr, &ht.st);
2266  return 0;
2267  }
2268  }
2269 
2270  return 1;
2271 }
#define MCHT_CALENDARDATENEXT
Definition: commctrl.h:4225
SYSTEMTIME todaysDate
Definition: monthcal.c:125
#define MCHT_CALENDARDATE
Definition: commctrl.h:4224
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define MCHT_TITLEBTNPREV
Definition: commctrl.h:4221
BOOL WINAPI IsWindow(_In_opt_ HWND)
long x
Definition: polytest.cpp:48
WORD wMonth
Definition: winbase.h:871
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TPM_LEFTALIGN
Definition: winuser.h:2331
#define MCHT_TITLEBTNNEXT
Definition: commctrl.h:4220
#define TPM_RETURNCMD
Definition: winuser.h:2341
#define LOCALE_USER_DEFAULT
static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:1950
#define MF_STRING
Definition: winuser.h:138
HWND hwndSelf
Definition: monthcal.c:104
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MCHT_TODAYLINK
Definition: commctrl.h:4210
static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
Definition: monthcal.c:731
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:282
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
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
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define MC_NEXTPRESSED
Definition: monthcal.c:60
static void MONTHCAL_Scroll(MONTHCAL_INFO *infoPtr, INT delta, BOOL keep_selection)
Definition: monthcal.c:1974
static void MONTHCAL_GoToMonth(MONTHCAL_INFO *infoPtr, enum nav_direction direction)
Definition: monthcal.c:2009
smooth NULL
Definition: ftsmooth.c:416
static LRESULT MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
Definition: monthcal.c:1658
static LRESULT MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
Definition: monthcal.c:1806
HWND hWndYearUpDown
Definition: monthcal.c:142
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date, BOOL fix)
Definition: monthcal.c:351
#define MC_PREVPRESSED
Definition: monthcal.c:59
const char * wine_dbgstr_point(const POINT *guid)
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME firstSel
Definition: monthcal.c:128
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStyle
Definition: monthcal.c:105
#define MF_ENABLED
Definition: winuser.h:128
#define MCS_MULTISELECT
Definition: commctrl.h:4280
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
static void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:171
SYSTEMTIME month
Definition: monthcal.c:99
#define TPM_NONOTIFY
Definition: winuser.h:2340
#define MCHT_TITLEMONTH
Definition: commctrl.h:4218
GLenum GLint * range
Definition: glext.h:7539
CALENDAR_INFO * calendars
Definition: monthcal.c:145
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define ARRAY_SIZE(a)
Definition: main.h:24
static const struct newhuff ht[]
Definition: huffman.h:296
static void MONTHCAL_NotifySelect(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:191
static void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months)
Definition: monthcal.c:486
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
static LRESULT MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
Definition: monthcal.c:1555
static void MONTHCAL_EditYear(MONTHCAL_INFO *infoPtr, INT calIdx)
Definition: monthcal.c:2119
#define MC_PREVNEXTMONTHTIMER
Definition: monthcal.c:66
#define HIWORD(l)
Definition: typedefs.h:246
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165
#define MC_SEL_LBUTDOWN
Definition: monthcal.c:58
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
#define MCHT_CALENDARDATEPREV
Definition: commctrl.h:4226
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
#define MCHT_TITLEYEAR
Definition: commctrl.h:4219
#define MC_PREVNEXTMONTHDELAY
Definition: monthcal.c:61

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_LButtonUp()

static LRESULT MONTHCAL_LButtonUp ( MONTHCAL_INFO infoPtr,
LPARAM  lParam 
)
static

Definition at line 2275 of file monthcal.c.

2276 {
2277  NMHDR nmhdr;
2278  MCHITTESTINFO ht;
2279  DWORD hit;
2280 
2281  TRACE("\n");
2282 
2283  if(infoPtr->status & (MC_PREVPRESSED | MC_NEXTPRESSED)) {
2284  RECT *r;
2285 
2287  r = infoPtr->status & MC_PREVPRESSED ? &infoPtr->titlebtnprev : &infoPtr->titlebtnnext;
2288  infoPtr->status &= ~(MC_PREVPRESSED | MC_NEXTPRESSED);
2289 
2290  InvalidateRect(infoPtr->hwndSelf, r, FALSE);
2291  }
2292 
2293  ReleaseCapture();
2294 
2295  /* always send NM_RELEASEDCAPTURE notification */
2296  nmhdr.hwndFrom = infoPtr->hwndSelf;
2297  nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
2298  nmhdr.code = NM_RELEASEDCAPTURE;
2299  TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify);
2300 
2301  SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
2302 
2303  if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
2304 
2305  ht.cbSize = sizeof(MCHITTESTINFO);
2306  ht.pt.x = (short)LOWORD(lParam);
2307  ht.pt.y = (short)HIWORD(lParam);
2308  hit = MONTHCAL_HitTest(infoPtr, &ht);
2309 
2310  infoPtr->status = MC_SEL_LBUTUP;
2311  MONTHCAL_SetDayFocus(infoPtr, NULL);
2312 
2313  if((hit & MCHT_CALENDARDATE) == MCHT_CALENDARDATE)
2314  {
2315  SYSTEMTIME sel = infoPtr->minSel;
2316 
2317  /* will be invalidated here */
2318  MONTHCAL_SetCurSel(infoPtr, &ht.st);
2319 
2320  /* send MCN_SELCHANGE only if new date selected */
2321  if (!MONTHCAL_IsDateEqual(&sel, &ht.st))
2323 
2324  MONTHCAL_NotifySelect(infoPtr);
2325  }
2326 
2327  return 0;
2328 }
#define MCHT_CALENDARDATE
Definition: commctrl.h:4224
RECT titlebtnprev
Definition: monthcal.c:138
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define NM_RELEASEDCAPTURE
Definition: commctrl.h:141
HWND hwndSelf
Definition: monthcal.c:104
#define GetWindowLongPtrW
Definition: winuser.h:4698
static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
Definition: monthcal.c:731
UINT code
Definition: winuser.h:3112
HWND hwndNotify
Definition: monthcal.c:140
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
#define MC_NEXTPRESSED
Definition: monthcal.c:60
UINT_PTR idFrom
Definition: winuser.h:3111
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static LRESULT MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
Definition: monthcal.c:1806
#define MC_PREVPRESSED
Definition: monthcal.c:59
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME minSel
Definition: monthcal.c:130
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
static void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:171
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HWND hwndFrom
Definition: winuser.h:3110
RECT titlebtnnext
Definition: monthcal.c:137
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const struct newhuff ht[]
Definition: huffman.h:296
static void MONTHCAL_NotifySelect(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:191
static BOOL MONTHCAL_IsDateEqual(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:244
static LRESULT MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
Definition: monthcal.c:1555
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
#define MC_PREVNEXTMONTHTIMER
Definition: monthcal.c:66
#define HIWORD(l)
Definition: typedefs.h:246
#define MC_SEL_LBUTUP
Definition: monthcal.c:57
#define MC_SEL_LBUTDOWN
Definition: monthcal.c:58
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_MonthDiff()

static int MONTHCAL_MonthDiff ( const SYSTEMTIME left,
const SYSTEMTIME right 
)
inlinestatic

Definition at line 210 of file monthcal.c.

211 {
212  return (right->wYear - left->wYear)*12 + right->wMonth - left->wMonth;
213 }
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859

Referenced by MONTHCAL_SetCurSel(), and MONTHCAL_SetSelRange().

◆ MONTHCAL_MonthLength()

int MONTHCAL_MonthLength ( int  month,
int  year 
)

Definition at line 217 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];
240  }
241 }
WORD wMonth
Definition: winbase.h:871
static const SYSTEMTIME min_allowed_date
Definition: monthcal.c:155
WORD wYear
Definition: winbase.h:870
int month[12]
Definition: systime.c:13

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

◆ MONTHCAL_MouseMove()

static LRESULT MONTHCAL_MouseMove ( MONTHCAL_INFO infoPtr,
LPARAM  lParam 
)
static

Definition at line 2366 of file monthcal.c.

2367 {
2368  MCHITTESTINFO ht;
2369  SYSTEMTIME st_ht;
2370  INT hit;
2371  RECT r;
2372 
2373  if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
2374 
2375  ht.cbSize = sizeof(MCHITTESTINFO);
2376  ht.pt.x = (short)LOWORD(lParam);
2377  ht.pt.y = (short)HIWORD(lParam);
2378  ht.iOffset = -1;
2379 
2380  hit = MONTHCAL_HitTest(infoPtr, &ht);
2381 
2382  /* not on the calendar date numbers? bail out */
2383  TRACE("hit:%x\n",hit);
2384  if((hit & MCHT_CALENDARDATE) != MCHT_CALENDARDATE)
2385  {
2386  MONTHCAL_SetDayFocus(infoPtr, NULL);
2387  return 0;
2388  }
2389 
2390  st_ht = ht.st;
2391 
2392  /* if pointer is over focused day still there's nothing to do */
2393  if(!MONTHCAL_SetDayFocus(infoPtr, &ht.st)) return 0;
2394 
2395  MONTHCAL_GetDayRect(infoPtr, &ht.st, &r, ht.iOffset);
2396 
2397  if(infoPtr->dwStyle & MCS_MULTISELECT) {
2398  SYSTEMTIME st[2];
2399 
2400  MONTHCAL_GetSelRange(infoPtr, st);
2401 
2402  /* If we're still at the first selected date and range is empty, return.
2403  If range isn't empty we should change range to a single firstSel */
2404  if(MONTHCAL_IsDateEqual(&infoPtr->firstSel, &st_ht) &&
2405  MONTHCAL_IsDateEqual(&st[0], &st[1])) goto done;
2406 
2407  MONTHCAL_IsSelRangeValid(infoPtr, &st_ht, &infoPtr->firstSel, &st_ht);
2408 
2409  st[0] = infoPtr->firstSel;
2410  /* we should overwrite timestamp here */
2411  MONTHCAL_CopyDate(&st_ht, &st[1]);
2412 
2413  /* bounds will be swapped here if needed */
2414  MONTHCAL_SetSelRange(infoPtr, st);
2415 
2416  return 0;
2417  }
2418 
2419 done:
2420 
2421  /* FIXME: this should specify a rectangle containing only the days that changed
2422  using InvalidateRect */
2423  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
2424 
2425  return 0;
2426 }
#define MCHT_CALENDARDATE
Definition: commctrl.h:4224
static LRESULT MONTHCAL_GetSelRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
Definition: monthcal.c:1639
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HWND hwndSelf
Definition: monthcal.c:104
static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
Definition: monthcal.c:731
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
Definition: monthcal.c:282
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
static BOOL MONTHCAL_IsSelRangeValid(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *range0, const SYSTEMTIME *range1, SYSTEMTIME *adjust)
Definition: monthcal.c:402
smooth NULL
Definition: ftsmooth.c:416
static LRESULT MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
Definition: monthcal.c:1658
static LRESULT MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
Definition: monthcal.c:1806
#define TRACE(s)
Definition: solgame.cpp:4
SYSTEMTIME firstSel
Definition: monthcal.c:128
DWORD dwStyle
Definition: monthcal.c:105
#define MCS_MULTISELECT
Definition: commctrl.h:4280
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
Definition: monthcal.c:637
static const struct newhuff ht[]
Definition: huffman.h:296
static BOOL MONTHCAL_IsDateEqual(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:244
#define HIWORD(l)
Definition: typedefs.h:246
#define MC_SEL_LBUTDOWN
Definition: monthcal.c:58
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_Notify()

static LRESULT MONTHCAL_Notify ( MONTHCAL_INFO infoPtr,
NMHDR hdr 
)
static

Definition at line 2852 of file monthcal.c.

2853 {
2854  /* notification from year edit updown */
2855  if (hdr->code == UDN_DELTAPOS)
2856  {
2857  NMUPDOWN *nmud = (NMUPDOWN*)hdr;
2858 
2859  if (hdr->hwndFrom == infoPtr->hWndYearUpDown && nmud->iDelta)
2860  {
2861  /* year value limits are set up explicitly after updown creation */
2862  MONTHCAL_Scroll(infoPtr, 12 * nmud->iDelta, FALSE);
2863  MONTHCAL_NotifyDayState(infoPtr);
2865  }
2866  }
2867  return 0;
2868 }
char hdr[14]
Definition: iptest.cpp:33
static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:1950
static void MONTHCAL_Scroll(MONTHCAL_INFO *infoPtr, INT delta, BOOL keep_selection)
Definition: monthcal.c:1974
HWND hWndYearUpDown
Definition: monthcal.c:142
static void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:171
#define UDN_DELTAPOS
Definition: commctrl.h:2141
int iDelta
Definition: commctrl.h:2138

Referenced by MONTHCAL_WindowProc().

◆ MONTHCAL_NotifyDayState()

static void MONTHCAL_NotifyDayState ( MONTHCAL_INFO infoPtr)
static

Definition at line 1950 of file monthcal.c.

1951 {
1953  NMDAYSTATE nmds;
1954 
1955  if (!(infoPtr->dwStyle & MCS_DAYSTATE)) return;
1956 
1957  nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
1958  nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
1959  nmds.nmhdr.code = MCN_GETDAYSTATE;
1960  nmds.cDayState = MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0);
1961  nmds.prgDayState = state = heap_alloc_zero(nmds.cDayState * sizeof(MONTHDAYSTATE));
1962 
1963  MONTHCAL_GetMinDate(infoPtr, &nmds.stStart);
1964  nmds.stStart.wDay = 1;
1965 
1966  SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmds.nmhdr.idFrom, (LPARAM)&nmds);
1967  memcpy(infoPtr->monthdayState, nmds.prgDayState,
1968  MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)*sizeof(MONTHDAYSTATE));
1969 
1970  heap_free(state);
1971 }
HWND hwndSelf
Definition: monthcal.c:104
static LRESULT MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
Definition: monthcal.c:674
#define GetWindowLongPtrW
Definition: winuser.h:4698
LPMONTHDAYSTATE prgDayState
Definition: commctrl.h:4270
#define MCS_DAYSTATE
Definition: commctrl.h:4279
UINT code
Definition: winuser.h:3112
HWND hwndNotify
Definition: monthcal.c:140
UINT_PTR idFrom
Definition: winuser.h:3111
LONG_PTR LPARAM
Definition: windef.h:208
#define GMR_DAYSTATE
Definition: commctrl.h:4288
DWORD dwStyle
Definition: monthcal.c:105
static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
Definition: monthcal.c:511
static int state
Definition: maze.c:121
MONTHDAYSTATE * monthdayState
Definition: monthcal.c:124
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HWND hwndFrom
Definition: winuser.h:3110
WORD wDay
Definition: winbase.h:873
SYSTEMTIME stStart
Definition: commctrl.h:4267
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MCN_GETDAYSTATE
Definition: commctrl.h:4273
DWORD MONTHDAYSTATE
Definition: commctrl.h:4152
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by MONTHCAL_GoToMonth(), MONTHCAL_LButtonDown(), MONTHCAL_Notify(), and MONTHCAL_UpdateSize().

◆ MONTHCAL_NotifySelect()

static void MONTHCAL_NotifySelect ( const MONTHCAL_INFO infoPtr)
inlinestatic

Definition at line 191 of file monthcal.c.

192 {
193  NMSELCHANGE nmsc;
194 
195  nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
196  nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
197  nmsc.nmhdr.code = MCN_SELECT;
198  nmsc.stSelStart = infoPtr->minSel;
199  nmsc.stSelStart.wDayOfWeek = 0;
200  if(infoPtr->dwStyle & MCS_MULTISELECT){
201  nmsc.stSelEnd = infoPtr->maxSel;
202  nmsc.stSelEnd.wDayOfWeek = 0;
203  }
204  else
205  nmsc.stSelEnd = st_null;
206 
207  SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
208 }
#define MCN_SELECT
Definition: commctrl.h:4277
WORD wDayOfWeek
Definition: winbase.h:872
HWND hwndSelf
Definition: monthcal.c:104
#define GetWindowLongPtrW
Definition: winuser.h:4698
UINT code
Definition: winuser.h:3112
HWND hwndNotify
Definition: monthcal.c:140
SYSTEMTIME stSelEnd
Definition: commctrl.h:4260
UINT_PTR idFrom
Definition: winuser.h:3111
SYSTEMTIME stSelStart
Definition: commctrl.h:4259
LONG_PTR LPARAM
Definition: windef.h:208
SYSTEMTIME maxSel
Definition: monthcal.c:131
SYSTEMTIME minSel
Definition: monthcal.c:130
DWORD dwStyle
Definition: monthcal.c:105
#define MCS_MULTISELECT
Definition: commctrl.h:4280
HWND hwndFrom
Definition: winuser.h:3110
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const SYSTEMTIME st_null
Definition: monthcal.c:152
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by MONTHCAL_LButtonDown(), MONTHCAL_LButtonUp(), and MONTHCAL_RButtonUp().

◆ MONTHCAL_NotifySelectionChange()

static void MONTHCAL_NotifySelectionChange ( const MONTHCAL_INFO infoPtr)
inlinestatic

Definition at line 171 of file monthcal.c.

172 {
173  NMSELCHANGE nmsc;
174 
175  nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
176  nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
177  nmsc.nmhdr.code = MCN_SELCHANGE;
178  nmsc.stSelStart = infoPtr->minSel;
179  nmsc.stSelStart.wDayOfWeek = 0;
180  if(infoPtr->dwStyle & MCS_MULTISELECT){
181  nmsc.stSelEnd = infoPtr->maxSel;
182  nmsc.stSelEnd.wDayOfWeek = 0;
183  }
184  else
185  nmsc.stSelEnd = st_null;
186 
187  SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
188 }
WORD wDayOfWeek
Definition: winbase.h:872
HWND hwndSelf
Definition: monthcal.c:104
#define MCN_SELCHANGE
Definition: commctrl.h:4263
#define GetWindowLongPtrW
Definition: winuser.h:4698
UINT code
Definition: winuser.h:3112
HWND hwndNotify
Definition: monthcal.c:140
SYSTEMTIME stSelEnd
Definition: commctrl.h:4260
UINT_PTR idFrom
Definition: winuser.h:3111
SYSTEMTIME stSelStart
Definition: commctrl.h:4259
LONG_PTR LPARAM
Definition: windef.h:208
SYSTEMTIME maxSel
Definition: monthcal.c:131
SYSTEMTIME minSel
Definition: monthcal.c:130
DWORD dwStyle
Definition: monthcal.c:105
#define MCS_MULTISELECT
Definition: commctrl.h:4280
HWND hwndFrom
Definition: winuser.h:3110
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const SYSTEMTIME st_null
Definition: monthcal.c:152
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by MONTHCAL_GoToMonth(), MONTHCAL_LButtonDown(), MONTHCAL_LButtonUp(), MONTHCAL_Notify(), MONTHCAL_RButtonUp(), and MONTHCAL_Timer().

◆ MONTHCAL_Paint()

static LRESULT MONTHCAL_Paint ( MONTHCAL_INFO infoPtr,
HDC  hdc_paint 
)
static

Definition at line 2430 of file monthcal.c.

2431 {
2432  HDC hdc;
2433  PAINTSTRUCT ps;
2434 
2435  if (hdc_paint)
2436  {
2437  GetClientRect(infoPtr->hwndSelf, &ps.rcPaint);
2438  hdc = hdc_paint;
2439  }
2440  else
2441  hdc = BeginPaint(infoPtr->hwndSelf, &ps);
2442 
2443  MONTHCAL_Refresh(infoPtr, hdc, &ps);
2444  if (!hdc_paint) EndPaint(infoPtr->hwndSelf, &ps);
2445  return 0;
2446 }
static HDC
Definition: imagelist.c:92
HWND hwndSelf
Definition: monthcal.c:104
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
Definition: monthcal.c:1229
HDC hdc
Definition: main.c:9
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by MONTHCAL_PrintClient(), and MONTHCAL_WindowProc().

◆ MONTHCAL_PaintButton()

static void MONTHCAL_PaintButton ( MONTHCAL_INFO infoPtr,
HDC  hdc,
enum nav_direction  button 
)
static

Definition at line 829 of file monthcal.c.

830 {
831  HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
832  RECT *r = button == DIRECTION_FORWARD ? &infoPtr->titlebtnnext : &infoPtr->titlebtnprev;
833  BOOL pressed = button == DIRECTION_FORWARD ? infoPtr->status & MC_NEXTPRESSED :
834  infoPtr->status & MC_PREVPRESSED;
835  if (theme)
836  {
837  static const int states[] = {
838  /* Prev button */
840  /* Next button */
842  };
843  int stateNum = button == DIRECTION_FORWARD ? 3 : 0;
844  if (pressed)
845  stateNum += 1;
846  else
847  {
848  if (infoPtr->dwStyle & WS_DISABLED) stateNum += 2;
849  }
850  DrawThemeBackground (theme, hdc, SBP_ARROWBTN, states[stateNum], r, NULL);
851  }
852  else
853  {
855  if (pressed)
856  style |= DFCS_PUSHED;
857  else
858  {
859  if (infoPtr->dwStyle & WS_DISABLED) style |= DFCS_INACTIVE;
860  }
861 
863  }
864 }
#define WS_DISABLED
Definition: pedump.c:621
RECT titlebtnprev
Definition: monthcal.c:138
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define DFCS_INACTIVE
Definition: winuser.h:502
HWND hwndSelf
Definition: monthcal.c:104
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
#define DFCS_PUSHED
Definition: winuser.h:503
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MC_NEXTPRESSED
Definition: monthcal.c:60
smooth NULL
Definition: ftsmooth.c:416
#define MC_PREVPRESSED
Definition: monthcal.c:59
DWORD dwStyle
Definition: monthcal.c:105
#define DFCS_SCROLLRIGHT
Definition: winuser.h:492
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HDC hdc
Definition: main.c:9
RECT titlebtnnext
Definition: monthcal.c:137
#define DFC_SCROLL
Definition: winuser.h:475
#define DFCS_SCROLLLEFT
Definition: winuser.h:491
Arabic default style
Definition: afstyles.h:93

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintCalendar()

static void MONTHCAL_PaintCalendar ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps,
INT  calIdx 
)
static

Definition at line 1171 of file monthcal.c.

1172 {
1173  const SYSTEMTIME *date = &infoPtr->calendars[calIdx].month;
1174  INT i, j;
1175  UINT length;
1176  RECT r, fill_bk_rect;
1177  SYSTEMTIME st;
1178  WCHAR buf[80];
1179  HPEN old_pen;
1180  int mask;
1181 
1182  /* fill whole days area - from week days area to today note rectangle */
1183  fill_bk_rect = infoPtr->calendars[calIdx].wdays;
1184  fill_bk_rect.bottom = infoPtr->calendars[calIdx].days.bottom +
1185  (infoPtr->todayrect.bottom - infoPtr->todayrect.top);
1186 
1187  FillRect(hdc, &fill_bk_rect, infoPtr->brushes[BrushMonth]);
1188 
1189  /* draw line under day abbreviations */
1190  old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
1191  MoveToEx(hdc, infoPtr->calendars[calIdx].days.left + 3,
1192  infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1, NULL);
1193  LineTo(hdc, infoPtr->calendars[calIdx].days.right - 3,
1194  infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1);
1195  SelectObject(hdc, old_pen);
1196 
1197  infoPtr->calendars[calIdx].wdays.left = infoPtr->calendars[calIdx].days.left =
1198  infoPtr->calendars[calIdx].weeknums.right;
1199 
1200  /* draw day abbreviations */
1201  SelectObject(hdc, infoPtr->hFont);
1202  SetBkColor(hdc, infoPtr->colors[MCSC_MONTHBK]);
1203  SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
1204  /* rectangle to draw a single day abbreviation within */
1205  r = infoPtr->calendars[calIdx].wdays;
1206  r.right = r.left + infoPtr->width_increment;
1207 
1208  i = infoPtr->firstDay;
1209  for(j = 0; j < 7; j++) {
1210  get_localized_dayname(infoPtr, (i + j + 6) % 7, buf, ARRAY_SIZE(buf));
1212  OffsetRect(&r, infoPtr->width_increment, 0);
1213  }
1214 
1215  /* draw current month */
1216  SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]);
1217  st = *date;
1218  st.wDay = 1;
1219  mask = 1;
1220  length = MONTHCAL_MonthLength(date->wMonth, date->wYear);
1221  while(st.wDay <= length)
1222  {
1223  MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[calIdx+1] & mask, ps);
1224  mask <<= 1;
1225  st.wDay++;
1226  }
1227 }
#define MCSC_MONTHBK
Definition: commctrl.h:4183
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int textHeight
Definition: monthcal.c:113
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MCSC_TEXT
Definition: commctrl.h:4180
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
LONG top
Definition: windef.h:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
RECT weeknums
Definition: monthcal.c:97
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
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
GLenum GLint GLuint mask
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
HPEN pens[PenLast]
Definition: monthcal.c:109
#define DT_VCENTER
Definition: winuser.h:543
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 MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
int width_increment
Definition: monthcal.c:115
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
SYSTEMTIME month
Definition: monthcal.c:99
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
HDC hdc
Definition: main.c:9
static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st, int bold, const PAINTSTRUCT *ps)
Definition: monthcal.c:786
MONTHDAYSTATE * monthdayState
Definition: monthcal.c:124
CALENDAR_INFO * calendars
Definition: monthcal.c:145
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
#define MCSC_TITLEBK
Definition: commctrl.h:4181
WORD wDay
Definition: winbase.h:873
#define DT_SINGLELINE
Definition: winuser.h:540
HFONT hFont
Definition: monthcal.c:111
RECT todayrect
Definition: monthcal.c:139
#define ARRAY_SIZE(a)
Definition: main.h:24
__u16 date
Definition: mkdosfs.c:366
unsigned int UINT
Definition: ndis.h:50
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
static int get_localized_dayname(const MONTHCAL_INFO *infoPtr, unsigned int day, WCHAR *buff, unsigned int count)
Definition: monthcal.c:1158
LONG bottom
Definition: windef.h:294
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintFocusAndCircle()

static void MONTHCAL_PaintFocusAndCircle ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps 
)
static

Definition at line 1095 of file monthcal.c.

1096 {
1097  /* circle today date if only it's in fully visible month */
1098  if (!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE))
1099  {
1100  INT i;
1101 
1102  for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
1103  if (!MONTHCAL_CompareMonths(&infoPtr->todaysDate, &infoPtr->calendars[i].month))
1104  {
1105  MONTHCAL_CircleDay(infoPtr, hdc, &infoPtr->todaysDate);
1106  break;
1107  }
1108  }
1109 
1110  if (!MONTHCAL_IsDateEqual(&infoPtr->focusedSel, &st_null))
1111  {
1112  RECT r;
1113  MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1);
1114  DrawFocusRect(hdc, &r);
1115  }
1116 }
SYSTEMTIME todaysDate
Definition: monthcal.c:125
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
int32_t INT
Definition: typedefs.h:56
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
DWORD dwStyle
Definition: monthcal.c:105
SYSTEMTIME month
Definition: monthcal.c:99
SYSTEMTIME focusedSel
Definition: monthcal.c:132
HDC hdc
Definition: main.c:9
CALENDAR_INFO * calendars
Definition: monthcal.c:145
static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
Definition: monthcal.c:637
#define MCS_NOTODAYCIRCLE
Definition: commctrl.h:4282
static const SYSTEMTIME st_null
Definition: monthcal.c:152
static BOOL MONTHCAL_IsDateEqual(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:244
static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *date)
Definition: monthcal.c:777
static LONG MONTHCAL_CompareMonths(const SYSTEMTIME *first, const SYSTEMTIME *second)
Definition: monthcal.c:315
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintLeadTrailMonths()

static void MONTHCAL_PaintLeadTrailMonths ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps 
)
static

Definition at line 1119 of file monthcal.c.

1120 {
1121  INT mask, index;
1122  UINT length;
1123  SYSTEMTIME st_max, st;
1124 
1125  if (infoPtr->dwStyle & MCS_NOTRAILINGDATES) return;
1126 
1128 
1129  /* draw prev month */
1130  MONTHCAL_GetMinDate(infoPtr, &st);
1131  mask = 1 << (st.wDay-1);
1132  /* December and January both 31 days long, so no worries if wrapped */
1133  length = MONTHCAL_MonthLength(infoPtr->calendars[0].month.wMonth - 1,
1134  infoPtr->calendars[0].month.wYear);
1135  index = 0;
1136  while(st.wDay <= length)
1137  {
1138  MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[index] & mask, ps);
1139  mask <<= 1;
1140  st.wDay++;
1141  }
1142 
1143  /* draw next month */
1144  st = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
1145  st.wDay = 1;
1146  MONTHCAL_GetNextMonth(&st);
1147  MONTHCAL_GetMaxDate(infoPtr, &st_max);
1148  mask = 1;
1149  index = MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)-1;
1150  while(st.wDay <= st_max.wDay)
1151  {
1152  MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[index] & mask, ps);
1153  mask <<= 1;
1154  st.wDay++;
1155  }
1156 }
WORD wMonth
Definition: winbase.h:871
static LRESULT MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
Definition: monthcal.c:674
int32_t INT
Definition: typedefs.h:56
static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
Definition: monthcal.c:534
WORD wYear
Definition: winbase.h:870
GLenum GLint GLuint mask
Definition: glext.h:6028
#define GMR_DAYSTATE
Definition: commctrl.h:4288
GLuint index
Definition: glext.h:6031
int MONTHCAL_MonthLength(int month, int year)
Definition: monthcal.c:217
DWORD dwStyle
Definition: monthcal.c:105
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
SYSTEMTIME month
Definition: monthcal.c:99
static void MONTHCAL_GetNextMonth(SYSTEMTIME *date)
Definition: monthcal.c:499
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
#define index(s, c)
Definition: various.h:29
HDC hdc
Definition: main.c:9
static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st, int bold, const PAINTSTRUCT *ps)
Definition: monthcal.c:786
static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
Definition: monthcal.c:511
MONTHDAYSTATE * monthdayState
Definition: monthcal.c:124
CALENDAR_INFO * calendars
Definition: monthcal.c:145
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
WORD wDay
Definition: winbase.h:873
unsigned int UINT
Definition: ndis.h:50
#define MCSC_TRAILINGTEXT
Definition: commctrl.h:4184
#define MCS_NOTRAILINGDATES
Definition: commctrl.h:4284
static INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
Definition: monthcal.c:165

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintTitle()

static void MONTHCAL_PaintTitle ( MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps,
INT  calIdx 
)
static

Definition at line 867 of file monthcal.c.

868 {
869  static const WCHAR mmmmW[] = {'M','M','M','M',0};
870  static const WCHAR mmmW[] = {'M','M','M',0};
871  static const WCHAR mmW[] = {'M','M',0};
872  static const WCHAR fmtyearW[] = {'%','l','d',0};
873  static const WCHAR fmtmmW[] = {'%','0','2','d',0};
874  static const WCHAR fmtmW[] = {'%','d',0};
875  RECT *title = &infoPtr->calendars[calIdx].title;
876  const SYSTEMTIME *st = &infoPtr->calendars[calIdx].month;
877  WCHAR monthW[80], strW[80], fmtW[80], yearW[6] /* valid year range is 1601-30827 */;
878  int yearoffset, monthoffset, shiftX;
879  SIZE sz;
880 
881  /* fill header box */
882  FillRect(hdc, title, infoPtr->brushes[BrushTitle]);
883 
884  /* month/year string */
885  SetBkColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
887  SelectObject(hdc, infoPtr->hBoldFont);
888 
889  /* draw formatted date string */
890  GetDateFormatW(LOCALE_USER_DEFAULT, DATE_YEARMONTH, st, NULL, strW, ARRAY_SIZE(strW));
892 
893  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SYEARMONTH, fmtW, ARRAY_SIZE(fmtW));
894  wsprintfW(yearW, fmtyearW, st->wYear);
895 
896  /* month is trickier as it's possible to have different format pictures, we'll
897  test for M, MM, MMM, and MMMM */
898  if (strstrW(fmtW, mmmmW))
900  else if (strstrW(fmtW, mmmW))
902  else if (strstrW(fmtW, mmW))
903  wsprintfW(monthW, fmtmmW, st->wMonth);
904  else
905  wsprintfW(monthW, fmtmW, st->wMonth);
906 
907  /* update hit boxes */
908  yearoffset = 0;
909  while (strW[yearoffset])
910  {
911  if (!strncmpW(&strW[yearoffset], yearW, strlenW(yearW)))
912  break;
913  yearoffset++;
914  }
915 
916  monthoffset = 0;
917  while (strW[monthoffset])
918  {
919  if (!strncmpW(&strW[monthoffset], monthW, strlenW(monthW)))
920  break;
921  monthoffset++;
922  }
923 
924  /* for left limits use offsets */
925  sz.cx = 0;
926  if (yearoffset)
927  GetTextExtentPoint32W(hdc, strW, yearoffset, &sz);
928  infoPtr->calendars[calIdx].titleyear.left = sz.cx;
929 
930  sz.cx = 0;
931  if (monthoffset)
932  GetTextExtentPoint32W(hdc, strW, monthoffset, &sz);
933  infoPtr->calendars[calIdx].titlemonth.left = sz.cx;
934 
935  /* for right limits use actual string parts lengths */
936  GetTextExtentPoint32W(hdc, &strW[yearoffset], strlenW(yearW), &sz);
937  infoPtr->calendars[calIdx].titleyear.right = infoPtr->calendars[calIdx].titleyear.left + sz.cx;
938 
939  GetTextExtentPoint32W(hdc, monthW, strlenW(monthW), &sz);
940  infoPtr->calendars[calIdx].titlemonth.right = infoPtr->calendars[calIdx].titlemonth.left + sz.cx;
941 
942  /* Finally translate rectangles to match center aligned string,
943  hit rectangles are relative to title rectangle before translation. */
945  shiftX = (title->right - title->left - sz.cx) / 2 + title->left;
946  OffsetRect(&infoPtr->calendars[calIdx].titleyear, shiftX, 0);
947  OffsetRect(&infoPtr->calendars[calIdx].titlemonth, shiftX, 0);
948 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
WORD wMonth
Definition: winbase.h:871
#define LOCALE_USER_DEFAULT
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
#define MCSC_TITLETEXT
Definition: commctrl.h:4182
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
WORD wYear
Definition: winbase.h:870
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
WCHAR strW[12]
Definition: clipboard.c:2029
HFONT hBoldFont
Definition: monthcal.c:112
RECT titleyear
Definition: monthcal.c:94
#define strstrW(d, s)
Definition: unicode.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define DT_VCENTER
Definition: winuser.h:543
__wchar_t WCHAR
Definition: xmlstorage.h:180
RECT titlemonth
Definition: monthcal.c:93
SYSTEMTIME month
Definition: monthcal.c:99
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
HDC hdc
Definition: main.c:9
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
CALENDAR_INFO * calendars
Definition: monthcal.c:145
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
#define MCSC_TITLEBK
Definition: commctrl.h:4181
#define DT_SINGLELINE
Definition: winuser.h:540
#define ARRAY_SIZE(a)
Definition: main.h:24
HBRUSH brushes[BrushLast]
Definition: monthcal.c:108
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
static char title[]
Definition: ps.c:92
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintTodayTitle()

static void MONTHCAL_PaintTodayTitle ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps 
)
static

Definition at line 1061 of file monthcal.c.

1062 {
1063  static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 };
1064  WCHAR buf_todayW[30], buf_dateW[20], buf[80];
1065  RECT text_rect, box_rect;
1066  HFONT old_font;
1067  INT col;
1068 
1069  if(infoPtr->dwStyle & MCS_NOTODAY) return;
1070 
1071  LoadStringW(COMCTL32_hModule, IDM_TODAY, buf_todayW, ARRAY_SIZE(buf_todayW));
1072  col = infoPtr->dwStyle & MCS_NOTODAYCIRCLE ? 0 : 1;
1073  if (infoPtr->dwStyle & MCS_WEEKNUMBERS) col--;
1074  /* label is located below first calendar last row */
1075  MONTHCAL_GetDayRectI(infoPtr, &text_rect, col, 6, infoPtr->dim.cx * infoPtr->dim.cy - infoPtr->dim.cx);
1076  box_rect = text_rect;
1077 
1078  GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &infoPtr->todaysDate, NULL, buf_dateW, ARRAY_SIZE(buf_dateW));
1079  old_font = SelectObject(hdc, infoPtr->hBoldFont);
1080  SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]);
1081 
1082  wsprintfW(buf, fmt_todayW, buf_todayW, buf_dateW);
1085 
1086  if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) {
1087  OffsetRect(&box_rect, -infoPtr->width_increment, 0);
1088  MONTHCAL_Circle(infoPtr, hdc, &box_rect);
1089  }
1090 
1091  SelectObject(hdc, old_font);
1092 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define IDM_TODAY
Definition: comctl32.h:76
SYSTEMTIME todaysDate
Definition: monthcal.c:125
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MCSC_TEXT
Definition: commctrl.h:4180
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
HFONT hBoldFont
Definition: monthcal.c:112
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define DT_VCENTER
Definition: winuser.h:543
#define MCS_WEEKNUMBERS
Definition: commctrl.h:4281
int width_increment
Definition: monthcal.c:115
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStyle
Definition: monthcal.c:105
COLORREF colors[MCSC_TRAILINGTEXT+1]
Definition: monthcal.c:107
HDC hdc
Definition: main.c:9
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
Definition: monthcal.c:759
#define MCS_NOTODAY
Definition: commctrl.h:4283
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
#define DT_SINGLELINE
Definition: winuser.h:540
HMODULE COMCTL32_hModule
Definition: commctrl.c:79
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MCS_NOTODAYCIRCLE
Definition: commctrl.h:4282
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static void MONTHCAL_GetDayRectI(const MONTHCAL_INFO *infoPtr, RECT *r, INT col, INT row, INT calIdx)
Definition: monthcal.c:624
RECT text_rect
Definition: sndrec32.cpp:77
LONG cy
Definition: windef.h:320
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by MONTHCAL_Refresh().

◆ MONTHCAL_PaintWeeknumbers()

static void MONTHCAL_PaintWeeknumbers ( const MONTHCAL_INFO infoPtr,
HDC  hdc,
const PAINTSTRUCT ps,
INT  calIdx 
)
static

Definition at line 950 of file monthcal.c.

951 {
952  const SYSTEMTIME *date = &infoPtr->calendars[calIdx].month;
953  static const WCHAR fmt_weekW[] = { '%','d',0 };
954  INT mindays, weeknum, weeknum1, startofprescal;
955  INT i, prev_month;
956  SYSTEMTIME st;
957  WCHAR buf[80];
958  HPEN old_pen;
959  RECT r;
960 
961  if (!(infoPtr->dwStyle & MCS_WEEKNUMBERS)) return;
962 
963  MONTHCAL_GetMinDate(infoPtr, &st);
964  startofprescal = st.wDay;
965  st = *date;
966 
967  prev_month = date->wMonth - 1;
968  if(prev_month == 0) prev_month = 12;
969 
970  /*
971  Rules what week to call the first week of a new year:
972  LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
973  The week containing Jan 1 is the first week of year
974  LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
975  First week of year must contain 4 days of the new year
976  LOCALE_IFIRSTWEEKOFYEAR == 1 (what countries?)
977  The first week of the year must contain only days of the new year
978  */
980  weeknum = atoiW(buf);
981  switch (weeknum)
982  {
983  case 1: mindays = 6;
984  break;
985  case 2: mindays = 3;
986  break;
987  case 0: mindays = 0;
988  break;
989  default:
990  WARN("Unknown LOCALE_IFIRSTWEEKOFYEAR value %d, defaulting to 0\n", weeknum);
991  mindays = 0;
992  }
993 
994  if (date->wMonth == 1)
995  {
996  /* calculate all those exceptions for January */
997  st.wDay = st.wMonth = 1;
998  weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
999  if ((infoPtr->firstDay - weeknum1) % 7 > mindays)
1000  weeknum = 1;
1001  else
1002  {
1003  weeknum = 0;
1004  for(i = 0; i < 11; i++)
1005  weeknum += MONTHCAL_MonthLength(i+1, date->wYear - 1);
1006 
1007  weeknum += startofprescal + 7;
1008  weeknum /= 7;
1009  st.wYear -= 1;
1010  weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
1011  if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
1012  }
1013  }
1014  else
1015  {
1016  weeknum = 0;
1017  for(i = 0; i < prev_month - 1; i++)
1018  weeknum += MONTHCAL_MonthLength(i+1, date->wYear);
1019 
1020  weeknum += startofprescal + 7;
1021  weeknum /= 7;
1022  st.wDay = st.wMonth = 1;
1023  weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
1024  if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
1025  }
1026 
1027  r = infoPtr->calendars[calIdx].weeknums;
1028 
1029  /* erase whole week numbers area */
1030  FillRect(hdc, &r, infoPtr->brushes[BrushMonth]);
1031  SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
1032 
1033  /* reduce rectangle to one week number */
1034  r.bottom = r.top + infoPtr->height_increment;
1035 
1036  for(i = 0; i < 6; i++) {
1037  if((i == 0) && (weeknum > 50))
1038  {
1039  wsprintfW(buf, fmt_weekW, weeknum);
1040  weeknum = 0;
1041  }
1042  else if((i == 5) && (weeknum > 47))
1043  {
1044  wsprintfW(buf, fmt_weekW, 1);
1045  }
1046  else
1047  wsprintfW(buf, fmt_weekW, weeknum + i);
1048 
1050  OffsetRect(&r, 0, infoPtr->height_increment);
1051  }
1052 
1053  /* line separator for week numbers column */
1054  old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
1055  MoveToEx(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.top + 3 , NULL);
1056  LineTo(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.bottom);
1057