comctl32/monthcal: Cache pens, fix line colour.
This commit is contained in:
parent
49088bf96d
commit
41a113e0ce
|
@ -76,6 +76,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(monthcal);
|
||||||
/* convert from days to 100 nanoseconds unit - used as FILETIME unit */
|
/* convert from days to 100 nanoseconds unit - used as FILETIME unit */
|
||||||
#define DAYSTO100NSECS(days) (((ULONGLONG)(days))*24*60*60*10000000)
|
#define DAYSTO100NSECS(days) (((ULONGLONG)(days))*24*60*60*10000000)
|
||||||
|
|
||||||
|
enum CachedPen
|
||||||
|
{
|
||||||
|
PenRed = 0,
|
||||||
|
PenText,
|
||||||
|
PenLast
|
||||||
|
};
|
||||||
|
|
||||||
/* single calendar data */
|
/* single calendar data */
|
||||||
typedef struct _CALENDAR_INFO
|
typedef struct _CALENDAR_INFO
|
||||||
{
|
{
|
||||||
|
@ -96,6 +103,7 @@ typedef struct
|
||||||
|
|
||||||
COLORREF colors[MCSC_TRAILINGTEXT+1];
|
COLORREF colors[MCSC_TRAILINGTEXT+1];
|
||||||
HBRUSH brushes[MCSC_MONTHBK+1];
|
HBRUSH brushes[MCSC_MONTHBK+1];
|
||||||
|
HPEN pens[PenLast];
|
||||||
|
|
||||||
HFONT hFont;
|
HFONT hFont;
|
||||||
HFONT hBoldFont;
|
HFONT hBoldFont;
|
||||||
|
@ -639,15 +647,13 @@ static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
|
||||||
/* draw today boundary box for specified rectangle */
|
/* draw today boundary box for specified rectangle */
|
||||||
static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
|
static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
|
||||||
{
|
{
|
||||||
HPEN red_pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
|
HPEN old_pen = SelectObject(hdc, infoPtr->pens[PenRed]);
|
||||||
HPEN old_pen = SelectObject(hdc, red_pen);
|
|
||||||
HBRUSH old_brush;
|
HBRUSH old_brush;
|
||||||
|
|
||||||
old_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
old_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
||||||
Rectangle(hdc, r->left, r->top, r->right, r->bottom);
|
Rectangle(hdc, r->left, r->top, r->right, r->bottom);
|
||||||
|
|
||||||
SelectObject(hdc, old_brush);
|
SelectObject(hdc, old_brush);
|
||||||
DeleteObject(red_pen);
|
|
||||||
SelectObject(hdc, old_pen);
|
SelectObject(hdc, old_pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,6 +794,7 @@ static void MONTHCAL_PaintWeeknumbers(const MONTHCAL_INFO *infoPtr, HDC hdc, con
|
||||||
INT i, prev_month;
|
INT i, prev_month;
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
WCHAR buf[80];
|
WCHAR buf[80];
|
||||||
|
HPEN old_pen;
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
if (!(infoPtr->dwStyle & MCS_WEEKNUMBERS)) return;
|
if (!(infoPtr->dwStyle & MCS_WEEKNUMBERS)) return;
|
||||||
|
@ -883,8 +890,10 @@ static void MONTHCAL_PaintWeeknumbers(const MONTHCAL_INFO *infoPtr, HDC hdc, con
|
||||||
}
|
}
|
||||||
|
|
||||||
/* line separator for week numbers column */
|
/* line separator for week numbers column */
|
||||||
|
old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
|
||||||
MoveToEx(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.top + 3 , NULL);
|
MoveToEx(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.top + 3 , NULL);
|
||||||
LineTo(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.bottom);
|
LineTo(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.bottom);
|
||||||
|
SelectObject(hdc, old_pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bottom today date */
|
/* bottom today date */
|
||||||
|
@ -991,6 +1000,7 @@ static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const
|
||||||
RECT r, fill_bk_rect;
|
RECT r, fill_bk_rect;
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
WCHAR buf[80];
|
WCHAR buf[80];
|
||||||
|
HPEN old_pen;
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
/* fill whole days area - from week days area to today note rectangle */
|
/* fill whole days area - from week days area to today note rectangle */
|
||||||
|
@ -1001,10 +1011,12 @@ static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const
|
||||||
FillRect(hdc, &fill_bk_rect, infoPtr->brushes[MCSC_MONTHBK]);
|
FillRect(hdc, &fill_bk_rect, infoPtr->brushes[MCSC_MONTHBK]);
|
||||||
|
|
||||||
/* draw line under day abbreviations */
|
/* draw line under day abbreviations */
|
||||||
|
old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
|
||||||
MoveToEx(hdc, infoPtr->calendars[calIdx].days.left + 3,
|
MoveToEx(hdc, infoPtr->calendars[calIdx].days.left + 3,
|
||||||
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1, NULL);
|
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1, NULL);
|
||||||
LineTo(hdc, infoPtr->calendars[calIdx].days.right - 3,
|
LineTo(hdc, infoPtr->calendars[calIdx].days.right - 3,
|
||||||
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1);
|
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1);
|
||||||
|
SelectObject(hdc, old_pen);
|
||||||
|
|
||||||
prev_month = date->wMonth - 1;
|
prev_month = date->wMonth - 1;
|
||||||
if (prev_month == 0) prev_month = 12;
|
if (prev_month == 0) prev_month = 12;
|
||||||
|
@ -1137,6 +1149,13 @@ MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, UINT index, COLORREF color)
|
||||||
infoPtr->brushes[index] = CreateSolidBrush(color);
|
infoPtr->brushes[index] = CreateSolidBrush(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update cached pen */
|
||||||
|
if (index == MCSC_TEXT)
|
||||||
|
{
|
||||||
|
DeleteObject(infoPtr->pens[PenText]);
|
||||||
|
infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[index]);
|
||||||
|
}
|
||||||
|
|
||||||
InvalidateRect(infoPtr->hwndSelf, NULL, index == MCSC_BACKGROUND ? TRUE : FALSE);
|
InvalidateRect(infoPtr->hwndSelf, NULL, index == MCSC_BACKGROUND ? TRUE : FALSE);
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
@ -2540,6 +2559,9 @@ MONTHCAL_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
||||||
infoPtr->brushes[MCSC_TITLEBK] = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]);
|
infoPtr->brushes[MCSC_TITLEBK] = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]);
|
||||||
infoPtr->brushes[MCSC_MONTHBK] = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]);
|
infoPtr->brushes[MCSC_MONTHBK] = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]);
|
||||||
|
|
||||||
|
infoPtr->pens[PenRed] = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
|
||||||
|
infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[MCSC_TEXT]);
|
||||||
|
|
||||||
infoPtr->minSel = infoPtr->todaysDate;
|
infoPtr->minSel = infoPtr->todaysDate;
|
||||||
infoPtr->maxSel = infoPtr->todaysDate;
|
infoPtr->maxSel = infoPtr->todaysDate;
|
||||||
infoPtr->calendars[0].month = infoPtr->todaysDate;
|
infoPtr->calendars[0].month = infoPtr->todaysDate;
|
||||||
|
@ -2566,6 +2588,8 @@ fail:
|
||||||
static LRESULT
|
static LRESULT
|
||||||
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
||||||
{
|
{
|
||||||
|
INT i;
|
||||||
|
|
||||||
/* free month calendar info data */
|
/* free month calendar info data */
|
||||||
Free(infoPtr->monthdayState);
|
Free(infoPtr->monthdayState);
|
||||||
Free(infoPtr->calendars);
|
Free(infoPtr->calendars);
|
||||||
|
@ -2577,6 +2601,9 @@ MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
||||||
DeleteObject(infoPtr->brushes[MCSC_TITLEBK]);
|
DeleteObject(infoPtr->brushes[MCSC_TITLEBK]);
|
||||||
DeleteObject(infoPtr->brushes[MCSC_MONTHBK]);
|
DeleteObject(infoPtr->brushes[MCSC_MONTHBK]);
|
||||||
|
|
||||||
|
for (i = PenRed; i < PenLast; i++)
|
||||||
|
DeleteObject(infoPtr->pens[i]);
|
||||||
|
|
||||||
Free(infoPtr);
|
Free(infoPtr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue