- Allow more customizations in the monthcal

- fixes bug 1338
- by Thomas Weidenmueller


svn path=/trunk/; revision=21250
This commit is contained in:
Ged Murphy 2006-03-08 19:31:03 +00:00
parent 7dfc2dfebb
commit 9a2722b58b

View file

@ -26,6 +26,12 @@ static const TCHAR szMonthCalWndClass[] = TEXT("MonthCalWnd");
#define MONTHCAL_CTRLFG COLOR_WINDOWTEXT #define MONTHCAL_CTRLFG COLOR_WINDOWTEXT
#define MONTHCAL_SELBG COLOR_ACTIVECAPTION #define MONTHCAL_SELBG COLOR_ACTIVECAPTION
#define MONTHCAL_SELFG COLOR_CAPTIONTEXT #define MONTHCAL_SELFG COLOR_CAPTIONTEXT
#define MONTHCAL_DISABLED_HEADERBG COLOR_INACTIVECAPTION
#define MONTHCAL_DISABLED_HEADERFG COLOR_INACTIVECAPTIONTEXT
#define MONTHCAL_DISABLED_CTRLBG COLOR_WINDOW
#define MONTHCAL_DISABLED_CTRLFG COLOR_WINDOWTEXT
#define MONTHCAL_DISABLED_SELBG COLOR_INACTIVECAPTION
#define MONTHCAL_DISABLED_SELFG COLOR_INACTIVECAPTIONTEXT
#define ID_DAYTIMER 1 #define ID_DAYTIMER 1
@ -49,6 +55,7 @@ typedef struct _MONTHCALWND
DWORD UIState; DWORD UIState;
BOOL Changed : 1; BOOL Changed : 1;
BOOL DayTimerSet : 1; BOOL DayTimerSet : 1;
BOOL Enabled : 1;
BOOL HasFocus : 1; BOOL HasFocus : 1;
} MONTHCALWND, *PMONTHCALWND; } MONTHCALWND, *PMONTHCALWND;
@ -248,8 +255,8 @@ MonthCalReload(IN PMONTHCALWND infoPtr)
/* cache the configuration */ /* cache the configuration */
infoPtr->FirstDayOfWeek = MonthCalFirstDayOfWeek(); infoPtr->FirstDayOfWeek = MonthCalFirstDayOfWeek();
infoPtr->hbHeader = GetSysColorBrush(MONTHCAL_HEADERBG); infoPtr->hbHeader = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_HEADERBG : MONTHCAL_DISABLED_HEADERBG);
infoPtr->hbSelection = GetSysColorBrush(MONTHCAL_SELBG); infoPtr->hbSelection = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_SELBG : MONTHCAL_DISABLED_SELBG);
for (i = 0; for (i = 0;
i < 7; i < 7;
@ -447,6 +454,15 @@ MonthCalPaint(IN PMONTHCALWND infoPtr,
HFONT hOldFont; HFONT hOldFont;
INT iOldBkMode; INT iOldBkMode;
#if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
if (!infoPtr->Enabled)
{
FillRect(hDC,
prcUpdate,
GetSysColorBrush(MONTHCAL_DISABLED_CTRLBG));
}
#endif
iOldBkMode = SetBkMode(hDC, iOldBkMode = SetBkMode(hDC,
TRANSPARENT); TRANSPARENT);
hOldFont = (HFONT)SelectObject(hDC, hOldFont = (HFONT)SelectObject(hDC,
@ -474,7 +490,7 @@ MonthCalPaint(IN PMONTHCALWND infoPtr,
infoPtr->hbHeader); infoPtr->hbHeader);
crOldText = SetTextColor(hDC, crOldText = SetTextColor(hDC,
GetSysColor(MONTHCAL_HEADERFG)); GetSysColor(infoPtr->Enabled ? MONTHCAL_HEADERFG : MONTHCAL_DISABLED_HEADERFG));
for (x = prcUpdate->left / infoPtr->CellSize.cx; for (x = prcUpdate->left / infoPtr->CellSize.cx;
x <= prcUpdate->right / infoPtr->CellSize.cx && x < 7; x <= prcUpdate->right / infoPtr->CellSize.cx && x < 7;
@ -499,7 +515,7 @@ MonthCalPaint(IN PMONTHCALWND infoPtr,
if (crOldCtrlText == CLR_INVALID) if (crOldCtrlText == CLR_INVALID)
{ {
crOldCtrlText = SetTextColor(hDC, crOldCtrlText = SetTextColor(hDC,
MONTHCAL_CTRLFG); infoPtr->Enabled ? MONTHCAL_CTRLFG : MONTHCAL_DISABLED_CTRLFG);
} }
for (x = prcUpdate->left / infoPtr->CellSize.cx; for (x = prcUpdate->left / infoPtr->CellSize.cx;
@ -552,7 +568,7 @@ MonthCalPaint(IN PMONTHCALWND infoPtr,
/* highlight the selected day */ /* highlight the selected day */
crOldText = SetTextColor(hDC, crOldText = SetTextColor(hDC,
GetSysColor(MONTHCAL_SELFG)); GetSysColor(infoPtr->Enabled ? MONTHCAL_SELFG : MONTHCAL_DISABLED_SELFG));
} }
else else
{ {
@ -569,12 +585,12 @@ FailNoHighlight:
if (Day == infoPtr->Day && crOldText != CLR_INVALID) if (Day == infoPtr->Day && crOldText != CLR_INVALID)
{ {
if (infoPtr->HasFocus && !(infoPtr->UIState & UISF_HIDEFOCUS)) if (infoPtr->HasFocus && infoPtr->Enabled && !(infoPtr->UIState & UISF_HIDEFOCUS))
{ {
COLORREF crOldBk; COLORREF crOldBk;
crOldBk = SetBkColor(hDC, crOldBk = SetBkColor(hDC,
GetSysColor(MONTHCAL_SELBG)); GetSysColor(infoPtr->Enabled ? MONTHCAL_SELBG : MONTHCAL_DISABLED_SELBG));
DrawFocusRect(hDC, DrawFocusRect(hDC,
&rcHighlight); &rcHighlight);
@ -663,6 +679,12 @@ MonthCalWndProc(IN HWND hwnd,
switch (uMsg) switch (uMsg)
{ {
#if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
case WM_ERASEBKGND:
Ret = !infoPtr->Enabled;
break;
#endif
case WM_PAINT: case WM_PAINT:
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
{ {
@ -969,6 +991,28 @@ MonthCalWndProc(IN HWND hwnd,
break; break;
} }
case WM_ENABLE:
{
infoPtr->Enabled = ((BOOL)wParam != FALSE);
MonthCalReload(infoPtr);
break;
}
case WM_STYLECHANGED:
{
if (wParam == GWL_STYLE)
{
BOOL OldEnabled = infoPtr->Enabled;
infoPtr->Enabled = !(((LPSTYLESTRUCT)lParam)->styleNew & WS_DISABLED);
if (OldEnabled != infoPtr->Enabled)
{
MonthCalReload(infoPtr);
}
}
break;
}
case WM_CREATE: case WM_CREATE:
{ {
infoPtr = HeapAlloc(GetProcessHeap(), infoPtr = HeapAlloc(GetProcessHeap(),
@ -989,6 +1033,7 @@ MonthCalWndProc(IN HWND hwnd,
infoPtr->hSelf = hwnd; infoPtr->hSelf = hwnd;
infoPtr->hNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->hNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
infoPtr->Enabled = !(((LPCREATESTRUCTW)lParam)->style & WS_DISABLED);
MonthCalSetLocalTime(infoPtr, MonthCalSetLocalTime(infoPtr,
NULL); NULL);