XTPCalendarThemeOffice2007.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:211k
源码类别:
对话框与窗口
开发平台:
Visual C++
- // XTPCalendarThemeOffice2007.cpp : implementation file
- //
- // This file is a part of the XTREME CALENDAR MFC class library.
- // (c)1998-2008 Codejock Software, All Rights Reserved.
- //
- // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
- // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
- // CONSENT OF CODEJOCK SOFTWARE.
- //
- // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
- // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
- // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
- // SINGLE COMPUTER.
- //
- // CONTACT INFORMATION:
- // support@codejock.com
- // http://www.codejock.com
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Resource.h"
- #include "Common/XTPVC50Helpers.h"
- #include "Common/XTPVC80Helpers.h"
- #include "Common/XTPResourceManager.h"
- #include "Common/XTPOffice2007Image.h"
- #include "Common/XTPImageManager.h"
- #include "Common/XTPPropExchange.h"
- #include "Common/XTPMarkupRender.h"
- #include "XTPCalendarThemeOffice2007.h"
- #include "XTPCalendarPaintManager.h"
- #include "XTPCalendarControl.h"
- #include "XTPCalendarDayViewEvent.h"
- #include "XTPCalendarEvent.h"
- #include "XTPCalendarEventLabel.h"
- #include "XTPCalendarDayView.h"
- #include "XTPCalendarWeekView.h"
- #include "XTPCalendarMonthView.h"
- #include "XTPCalendarData.h"
- #include "XTPCalendarDayViewTimeScale.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- // DBG
- #define DBG_TRACE_PREVNEXTBTN
- //#define DBG_TRACE_PREVNEXTBTN TRACE
- // DBG
- //===========================================================================
- //
- #define XTP_CALENDAR_OFFICE2007_BASE_BLUE RGB(93, 140, 201) // default base color for a "blue" theme
- #define XTP_CALENDAR_OFFICE2007_BASE_GREEN RGB(114, 164, 90) // default base color for a "green" theme
- #define XTP_CALENDAR_OFFICE2007_TODAYBORDER RGB(238, 147, 17)
- //===========================================================================
- // Should be a prime number:
- // 37, 53, 79 , 101, 127, 199, 503, 1021, 1511, 2003, 3001, 4001, 5003, 6007, 8009, 12007, 16001, 32003, 48017, 64007
- #define XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT 37
- #define XTP_CALCLR(clrName, nScale) GetColorsSetPart()->SetColor(xtpCLR_##clrName, _T(#clrName), nScale);
- static const double dXTPMaxAlpha2007 = 90.;
- const int CXTPCalendarThemeOffice2007::cnGripperSize = 5;
- const int CXTPCalendarThemeOffice2007::cnShadowWidth = 5;
- //////////////////////////////////////////////////////////////////////////
- //{{AFX_CODEJOCK_PRIVATE
- struct XTP_CALENDAR_EVENT_ICON_INFO
- {
- // common data
- RECT m_rcDestination;
- // image data
- CXTPOffice2007Image* m_pImage;
- RECT m_rcSrc;
- // icon data
- CXTPImageManagerIcon* m_pIcon;
- };
- //}}AFX_CODEJOCK_PRIVATE
- //{{AFX_CODEJOCK_PRIVATE
- class CXTPTextDC
- {
- public:
- CXTPTextDC(CDC* pDC, COLORREF clrText = COLORREF_NULL, COLORREF clrBk = COLORREF_NULL)
- {
- ASSERT(pDC);
- m_pDC = pDC;
- m_clrText_prev = COLORREF_NULL;
- m_clrBk_prev = COLORREF_NULL;
- SetColors(clrText, clrBk);
- }
- virtual ~CXTPTextDC()
- {
- SetColors(m_clrText_prev, m_clrBk_prev);
- }
- void SetColors(COLORREF clrText, COLORREF clrBk = COLORREF_NULL)
- {
- ASSERT(m_pDC);
- if (!m_pDC)
- return;
- if (clrText != COLORREF_NULL)
- {
- COLORREF clrText_prev = m_pDC->SetTextColor(clrText);
- if (m_clrText_prev == COLORREF_NULL)
- m_clrText_prev = clrText_prev;
- }
- if (clrBk != COLORREF_NULL)
- {
- COLORREF clrBk_prev = m_pDC->SetBkColor(clrBk);
- if (m_clrBk_prev == COLORREF_NULL)
- m_clrBk_prev = clrBk_prev;
- }
- }
- protected:
- CDC* m_pDC;
- COLORREF m_clrText_prev;
- COLORREF m_clrBk_prev;
- };
- //}}AFX_CODEJOCK_PRIVATE
- //////////////////////////////////////////////////////////////////////////
- //class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
- //{{AFX_CODEJOCK_PRIVATE
- class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
- {
- public:
- CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder();
- virtual void BiuldEventPaces(CXTPCalendarDayViewGroup* pViewGroup);
- protected:
- class CViewEventsMap : public CMap<CXTPCalendarDayViewEvent*, CXTPCalendarDayViewEvent*, int, int>
- {
- public:
- CViewEventsMap();
- int GetMinFreeEventPlace();
- int GetMaxEventPlace();
- int GetMaxEventPlaceCountEx();
- };
- virtual void _Clear();
- virtual void _UpdateDataFor(CXTPCalendarDayViewEvent* pViewEvent, CXTPCalendarDayViewGroup* pViewGroup);
- virtual void _UpdateEventsPaces(CXTPCalendarDayViewGroup* pViewGroup);
- //CXTPCalendarTypedPtrAutoDeleteMap<CXTPCalendarDayViewEvent*, CViewEventsMap*> m_mapEvToOverlapped;
- // to avoid warning C4786 CObject* used.
- CXTPCalendarTypedPtrAutoDeleteMap<CXTPCalendarDayViewEvent*, CObject*> m_mapEvToOverlapped;
- COleDateTimeSpan m_spCellDuration;
- COleDateTime m_dtMinStartTime;
- protected:
- virtual CViewEventsMap* _XGetDataFor(CXTPCalendarDayViewEvent* pViewEvent);
- virtual void _XAddOverlapped(CXTPCalendarDayViewEvent* pVEv_base, CXTPCalendarDayViewEvent* pVEv_overlapped);
- };
- //}}AFX_CODEJOCK_PRIVATE
- //////////////////////////////////////////////////////////////////////////
- BEGIN_MESSAGE_MAP(CXTPCalendarViewEventSubjectEditor2007, CXTPCalendarViewEventSubjectEditor)
- ON_WM_ERASEBKGND()
- ON_WM_CTLCOLOR_REFLECT()
- ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
- END_MESSAGE_MAP()
- CXTPCalendarViewEventSubjectEditor2007::CXTPCalendarViewEventSubjectEditor2007(CXTPCalendarControl* pOwner,
- CXTPCalendarViewEvent* pViewEvent, CXTPCalendarThemeOffice2007* pTheme2007) :
- CXTPCalendarViewEventSubjectEditor(pOwner)
- {
- ASSERT(pViewEvent);
- ASSERT(pTheme2007);
- m_pViewEvent = pViewEvent;
- m_pTheme2007 = pTheme2007;
- if (!pViewEvent || !pTheme2007)
- {
- return;
- }
- CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = m_pTheme2007->GetThemePartForEvent(m_pViewEvent);
- ASSERT(pEventPart);
- if (pEventPart)
- {
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- pEventPart->GetEventColors(NULL, pViewEvent, clrBorder, clrBorderNotSel, m_grclrBk, FALSE);
- if (m_grclrBk.IsNull())
- {
- m_grclrBk.SetStandardValue(RGB(255,255,255));
- }
- }
- }
- CXTPCalendarViewEventSubjectEditor2007::~CXTPCalendarViewEventSubjectEditor2007()
- {
- }
- BOOL CXTPCalendarViewEventSubjectEditor2007::OnEraseBkgnd(CDC* pDC)
- {
- UNUSED_ALWAYS(pDC);
- if (!m_pViewEvent || !m_pOwner)
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CRect rcEvent = m_pViewEvent->GetEventRect();
- m_pOwner->ClientToScreen(&rcEvent);
- ScreenToClient(&rcEvent);
- CXTPClientRect rcClient(this);
- XTPDrawHelpers()->GradientFill(pDC, &rcEvent, m_grclrBk, FALSE, &rcClient);
- return TRUE;
- }
- HBRUSH CXTPCalendarViewEventSubjectEditor2007::CtlColor(CDC* pDC, UINT nCtlColor)
- {
- ASSERT(nCtlColor == CTLCOLOR_EDIT);
- UNREFERENCED_PARAMETER(nCtlColor);
- static CBrush s_null_brush;
- if (s_null_brush.m_hObject == NULL)
- {
- s_null_brush.CreateStockObject(NULL_BRUSH);
- }
- pDC->SetBkMode(TRANSPARENT);
- DWORD dwStyle = GetStyle();
- BOOL bMultiLine = (dwStyle & ES_MULTILINE) != 0;
- return bMultiLine ? (HBRUSH)s_null_brush : (HBRUSH)NULL;
- }
- void CXTPCalendarViewEventSubjectEditor2007::OnChange()
- {
- Invalidate();
- }
- /////////////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNCREATE(CXTPCalendarThemeOffice2007, CXTPCalendarTheme)
- ////////////////////////////////////////////////////////////////////////
- CSize CXTPCalendarThemeOffice2007::DrawText_Auto2SL3ML(CDC* pDC,
- LPCTSTR pcszText1, LPCTSTR pcszText2, LPCTSTR pcszText3,
- CThemeFontColorSet* pFontColor1, CThemeFontColorSet* pFontColor2,
- CThemeFontColorSet* pFontColor3,
- CRect& rcRect, LPCTSTR pcszText1Separator, UINT uWordBreakMode)
- {
- CXTPFontDC autoFont(pDC, pFontColor2->Font());
- CSize sz2 = pDC->GetTextExtent(pcszText2);
- autoFont.SetFont(pFontColor1->Font());
- CSize sz1 = pDC->GetTextExtent(pcszText1);
- if ((sz1.cy + sz2.cy) > rcRect.Height())
- {
- CString strText1 = pcszText1;
- if (_tcslen(pcszText2) > 0)
- {
- strText1 += pcszText1Separator;
- }
- return DrawLine2_CenterLR(pDC, strText1, pcszText2, pFontColor1,
- pFontColor2, rcRect, DT_VCENTER | DT_LEFT,
- DT_VCENTER | DT_LEFT);
- }
- //=======================================================================
- UINT uFormat = DT_NOPREFIX | DT_LEFT | DT_TOP | DT_EDITCONTROL | uWordBreakMode;
- int nYspace = sz2.cy/4;
- int nHeight1 = 0, nHeight2 = 0, nHeight3 = 0;
- //--------------------
- autoFont.SetColor(pFontColor1->Color());
- CRect rcText1 = rcRect;
- nHeight1 = pDC->DrawText(pcszText1, &rcText1, uFormat);
- //--------------------
- CRect rcText2 = rcRect;
- rcText2.top = min(rcRect.top + nHeight1 + nYspace, rcRect.bottom);
- if (sz2.cy < rcText2.Height() && _tcslen(pcszText2))
- {
- autoFont.SetFontColor(pFontColor2->Font(), pFontColor2->Color());
- nHeight2 = pDC->DrawText(pcszText2, &rcText2, uFormat);
- }
- int nTLen3 = (int)_tcslen(pcszText3);
- if (pcszText3 && nTLen3)
- {
- autoFont.SetFontColor(pFontColor3->Font(), pFontColor3->Color());
- CRect rcText3 = rcRect;
- rcText3.top = min(rcText2.top + nHeight2 + nYspace, rcRect.bottom);
- if (sz2.cy < rcText3.Height())
- {
- nHeight3 = pDC->DrawText(pcszText3, &rcText3, uFormat);
- }
- }
- //--------------------
- return CSize(rcRect.Width(), nHeight1 + nHeight2 + nHeight3 + 2 * nYspace);
- }
- COLORREF AFX_CDECL CXTPCalendarThemeOffice2007::PowerColor(COLORREF clrBase, double dFactor, double dPower)
- {
- BYTE bR = (BYTE)max(0, min(255, (int)GetRValue(clrBase) + (int)(pow((double)GetRValue(clrBase), dPower) * dFactor)) );
- BYTE bG = (BYTE)max(0, min(255, (int)GetGValue(clrBase) + (int)(pow((double)GetGValue(clrBase), dPower) * dFactor)) );
- BYTE bB = (BYTE)max(0, min(255, (int)GetBValue(clrBase) + (int)(pow((double)GetBValue(clrBase), dPower) * dFactor)) );
- return RGB(bR, bG, bB);
- }
- /////////////////////////////////////////////////////////////////////////////
- CXTPCalendarThemeOffice2007::CXTPCalendarThemeOffice2007()
- {
- m_nPaintTheme = xtpCalendarThemeOffice2007;
- Init();
- RefreshMetrics();
- }
- CXTPCalendarThemeOffice2007::~CXTPCalendarThemeOffice2007()
- {
- m_Sink.UnadviseAll();
- if (m_pCalendar)
- OnDetachCalendar();
- }
- CXTPCalendarViewEventSubjectEditor* CXTPCalendarThemeOffice2007::StartEditSubject(CXTPCalendarViewEvent* pViewEvent)
- {
- if (!pViewEvent || !pViewEvent->GetCalendarControl())
- {
- ASSERT(FALSE);
- return NULL;
- }
- CXTPCalendarViewEventSubjectEditor2007* pSE;
- pSE = new CXTPCalendarViewEventSubjectEditor2007(pViewEvent->GetCalendarControl(),
- pViewEvent, this);
- if (!pSE)
- {
- return NULL;
- }
- DWORD dwEditStyles = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_MULTILINE;
- if (pViewEvent->IsMultidayEvent())
- {
- dwEditStyles |= ES_AUTOHSCROLL /*| ES_CENTER*/;
- }
- else
- {
- dwEditStyles |= ES_AUTOVSCROLL | ES_MULTILINE;
- }
- CRect rcEditor = pViewEvent->GetSubjectEditorRect();
- pSE->Create(dwEditStyles, rcEditor, pViewEvent->GetCalendarControl(), 0);
- pSE->SetFocus();
- CFont* pEditorFont = NULL;
- CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = GetThemePartForEvent(pViewEvent);
- ASSERT(pEventPart);
- if (pEventPart)
- {
- pEditorFont = pEventPart->m_fcsetNormal.fcsetSubject.Font();
- }
- ASSERT(pEditorFont);
- if (pEditorFont)
- {
- pSE->SetFont(pEditorFont);
- }
- pSE->SetWindowText(XTP_SAFE_GET2(pViewEvent, GetEvent(), GetSubject(), _T("")));
- pSE->SetSel(0, 0);
- return pSE;
- }
- CXTPCalendarThemeOffice2007::CTOEvent* CXTPCalendarThemeOffice2007::GetThemePartForEvent(CXTPCalendarViewEvent* pViewEvent)
- {
- if (!pViewEvent)
- {
- ASSERT(FALSE);
- return NULL;
- }
- CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = NULL;
- CXTPCalendarDayViewEvent* pVEDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pViewEvent);
- CXTPCalendarWeekViewEvent* pVEWeek= DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pViewEvent);
- CXTPCalendarMonthViewEvent* pVEMonth = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pViewEvent);
- if (pVEDay)
- {
- if (pViewEvent->IsMultidayEvent())
- {
- pEventPart = GetDayViewPartX()->GetDayPartX()->GetGroupPartX()->GetMultiDayEventPartX();
- }
- else
- {
- pEventPart = GetDayViewPartX()->GetDayPartX()->GetGroupPartX()->GetSingleDayEventPartX();
- }
- }
- else if (pVEWeek)
- {
- if (pViewEvent->IsMultidayEvent())
- {
- pEventPart = GetWeekViewPartX()->GetDayPartX()->GetMultiDayEventPartX();
- }
- else
- {
- pEventPart = GetWeekViewPartX()->GetDayPartX()->GetSingleDayEventPartX();
- }
- }
- else if (pVEMonth)
- {
- if (pViewEvent->IsMultidayEvent())
- {
- pEventPart = GetMonthViewPartX()->GetDayPartX()->GetMultiDayEventPartX();
- }
- else
- {
- pEventPart = GetMonthViewPartX()->GetDayPartX()->GetSingleDayEventPartX();
- }
- }
- else
- {
- ASSERT(FALSE);
- }
- return pEventPart;
- }
- void CXTPCalendarThemeOffice2007::GetItemTextIfNeed(int nItem, CString* pstrText,
- CXTPCalendarViewDay* pViewDay)
- {
- if (!pstrText || !pViewDay)
- {
- ASSERT(FALSE);
- return;
- }
- DWORD dwFlags = GetAskItemTextFlags();
- if (dwFlags & nItem)
- {
- XTP_CALENDAR_GETITEMTEXT_PARAMS objRequest;
- ::ZeroMemory(&objRequest, sizeof(objRequest));
- objRequest.nItem = nItem;
- objRequest.pstrText = pstrText;
- objRequest.pViewDay = pViewDay;
- SendNotificationAlways(XTP_NC_CALENDAR_GETITEMTEXT, (WPARAM)&objRequest, 0);
- }
- }
- void CXTPCalendarThemeOffice2007::SetCalendarControl(CXTPCalendarControl* pCalendar)
- {
- m_Sink.UnadviseAll();
- CXTPCalendarTheme::SetCalendarControl(pCalendar);
- if (pCalendar && XTPOffice2007Images() && XTPOffice2007Images()->GetConnection())
- {
- m_Sink.Advise(XTPOffice2007Images()->GetConnection(), XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED,
- &CXTPCalendarThemeOffice2007::OnEvent_Office2007ImagesChanged);
- }
- }
- void CXTPCalendarThemeOffice2007::OnEvent_Office2007ImagesChanged(XTP_NOTIFY_CODE Event, WPARAM wParam, LPARAM lParam)
- {
- UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam);
- ASSERT(Event == XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED);
- if (Event == XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED)
- {
- RefreshMetrics();
- if (GetCalendarControl())
- GetCalendarControl()->RedrawControl();
- }
- }
- void CXTPCalendarThemeOffice2007::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarTheme::RefreshMetrics(FALSE);
- m_clrBaseColor.SetStandardValue(GetColor2(_T("BaseColor"), XTP_CALENDAR_OFFICE2007_BASE_BLUE));
- //m_clrBaseColor.SetStandardValue(XTP_CALENDAR_OFFICE2007_BASE_GREEN);
- // Try to set default Office 2007 font,
- // otherwise icon font used.
- BOOL bFontExists = XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME);
- if (bFontExists)
- {
- LOGFONT lfBaseFont;
- ::ZeroMemory(&lfBaseFont, sizeof(lfBaseFont));
- STRCPY_S(lfBaseFont.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
- lfBaseFont.lfCharSet = DEFAULT_CHARSET;
- lfBaseFont.lfHeight = -11;
- lfBaseFont.lfWeight = FW_NORMAL;
- if (XTPSystemVersion()->IsClearTypeTextQualitySupported())
- lfBaseFont.lfQuality = 5;
- m_fntBaseFont.SetStandardValue(&lfBaseFont);
- LOGFONT lfBaseFontBold = lfBaseFont;
- lfBaseFontBold.lfWeight = FW_BOLD;
- m_fntBaseFontBold.SetStandardValue(&lfBaseFontBold);
- }
- if (!GetColorsSetPart() || !m_pImagesStd || !m_pImageList)
- {
- return;
- }
- /*
- rgb (HSL)
- Blue Silver Green
- 141,174, 217 (142, 118, 168) * 30 176, 182, 190 (142, 22, 172) * 27 156, 191, 139 (66, 68, 155) * 36
- DayBorder 93, 140, 201 (142, 118, 138) -30 * 145, 153, 164 (142, 21, 145) -27 * 114, 164, 90 (66, 68, 119) -36 *
- NonWorkBk 230,237, 247 (143, 116, 224) 56 -86 232, 234, 236 (139, 21, 220) 48 -75 233, 241, 230 (68, 64, 222) 67 103
- sel cell 41, 76, 122 (142, 120, 77) -91 61 76, 83, 92 (142, 23, 79) -93 66 63, 91, 50 (66, 71, 66) -89 -53
- ADEventsBk 165, 191, 225(142, 117, 183) 45 199,203, 209 (143, 22, 192) 47 177, 205, 164 (66, 68, 174)
- */ //-- set dynamic colors -------------------------
- // selected cell for blue, green
- // 41, 76, 122 {93, 140, 201}
- // 63, 91, 50 [114, 164, 90] 114
- GetColorsSetPart()->SetCLR_DarkenOffset(xtpCLR_DarkenOffset);
- //GetColorsSetPart()->SetColor(xtpCLR_
- XTP_CALCLR(SelectedBk, 114); // 51, 77, 111
- XTP_CALCLR(HeaderBorder, 76); // 141, 174, 217
- // Day View colors
- XTP_CALCLR(DayBorder, 0); // 93, 140, 201
- XTP_CALCLR(DayViewCellWorkBk, 255); // 255, 255, 255
- XTP_CALCLR(DayViewCellNonWorkBk, 216); // 230, 237, 247
- XTP_CALCLR(DayViewCellWorkBorderBottomInHour, 216); // 230, 237, 247
- XTP_CALCLR(DayViewCellWorkBorderBottomHour, 113); // 165, 191, 225
- XTP_CALCLR(DayViewCellNonWorkBorderBottomInHour, 189); // 213, 225, 241
- XTP_CALCLR(DayViewCellNonWorkBorderBottomHour, 113); // 165, 191, 225
- XTP_CALCLR(DayViewAllDayEventsBk, 113); // 165, 191, 225
- //GetColorsSetPart()->SetColorHSL(xtpCLR_DayViewAllDayEventsBk, 113); // 165, 191, 225
- XTP_CALCLR(DayViewAllDayEventsBorderBottom, 0); // 93, 140, 201
- XTP_CALCLR(MultiDayEventBorder, 0); // 93, 140, 201
- XTP_CALCLR(MultiDayEventSelectedBorder, 255); // 0, 0, 0
- XTP_CALCLR(MultiDayEventBkGRfrom, 249); // 251, 252, 254 multi-day event gradient fill Light
- XTP_CALCLR(MultiDayEventBkGRto, 161); // 195, 213, 235 multi-day event gradient fill Dark
- XTP_CALCLR(MultiDayEventFromToDates, 38); // 117, 157, 209
- XTP_CALCLR(DayViewSingleDayEventBorder, 0); // 93, 140, 201
- XTP_CALCLR(DayViewSingleDayEventSelectedBorder, 255); // 0, 0, 0
- XTP_CALCLR(DayViewSingleDayEventBkGRfrom, 255); // 255, 255, 255 // single-day event gradient fill Light
- XTP_CALCLR(DayViewSingleDayEventBkGRto, 155); // 191, 210, 234 // single-day event gradient fill Dark
- // Month view colors
- XTP_CALCLR(MonthViewDayBkLight, 255); // 255, 255, 255
- XTP_CALCLR(MonthViewDayBkDark, 113); // 165, 191, 225
- XTP_CALCLR(MonthViewDayBkSelected, 216); // 230, 237, 247
- XTP_CALCLR(MonthViewEventTime, 38);
- XTP_CALCLR(MonthViewSingleDayEventBorder, 217); // 230, 238, 247
- XTP_CALCLR(MonthViewSingleDayEventSelectedBorder, 255); // 0, 0, 0
- XTP_CALCLR(MonthViewSingleDayEventBkGRfrom, 250); // 252, 253, 254
- XTP_CALCLR(MonthViewSingleDayEventBkGRto, 181); // 208, 222, 240
- // Week view colors are same as month view by default
- XTP_CALCLR(WeekViewDayBkLight, 255); // 255, 255, 255
- XTP_CALCLR(WeekViewDayBkDark, 113); // 165, 191, 225
- XTP_CALCLR(WeekViewDayBkSelected, 216); // 230, 237, 247
- XTP_CALCLR(WeekViewEventTime, 114); // 51, 77, 111
- XTP_CALCLR(WeekViewSingleDayEventBorder, 217); // 230, 238, 247
- XTP_CALCLR(WeekViewSingleDayEventSelectedBorder, 255); // 0, 0, 0
- XTP_CALCLR(WeekViewSingleDayEventBkGRfrom, 250); // 252, 253, 254
- XTP_CALCLR(WeekViewSingleDayEventBkGRto, 181); // 208, 222, 240
- //----------------------------------------------------------------------
- if (m_pImagesStd)
- {
- VERIFY( m_pImagesStd->InitResourceHandle(_T("Office2007_CalendarHeader_bmp"), _T("PNG")));
- }
- //-----------------------------------------------------------------------
- _LoadStdBitmap(xtpIMG_DayViewHeader, _T("CalendarHeader"));
- _LoadStdBitmap(xtpIMG_DayViewHeaderTooday, _T("CalendarTodayHeader"));
- _LoadStdBitmap(xtpIMG_DayViewGroupHeader, _T("CalendarHeaderDVGroup"));
- _LoadStdBitmap(xtpIMG_MonthViewDayHeader, _T("CalendarHeaderMVDay"));
- _LoadStdBitmap(xtpIMG_MonthViewDayHeaderToday, _T("CalendarTodayHeaderMVDay"));
- //_LoadStdBitmap(xtpIMG_MonthViewWeekDayHeader, _T("CalendarHeaderMVWeekDay"));
- _LoadStdBitmap(xtpIMG_MonthViewWeekHeader, _T("CalendarHeaderMVWeek"));
- _LoadStdBitmap(xtpIMG_WeekViewDayHeader, _T("CalendarHeaderWVDay"));
- _LoadStdBitmap(xtpIMG_ExpandDayButtons, _T("CalendarExpandDay"));
- _LoadStdBitmap(xtpIMG_PrevNextEventButtons, _T("CalendarPrevNextEventButton"));
- //-----------------------------------------------------------------------
- if (bRefreshChildren)
- {
- CXTPCalendarThemePart::RefreshMetrics();
- }
- }
- BOOL CXTPCalendarThemeOffice2007::IsBaseColorOrig()
- {
- return !m_clrBaseColor.IsCustomValue() ||
- m_clrBaseColor.GetStandardColor() == (COLORREF)m_clrBaseColor;
- }
- COLORREF CXTPCalendarThemeOffice2007::GetColor(int eCLR, COLORREF clrBaseColor)
- {
- COLORREF clrColor = COLORREF_NULL;
- if (XTPOffice2007Images()->IsValid() && IsBaseColorOrig())
- {
- CString strColorName = GetColorsSetPart()->GetName(eCLR);
- clrColor = XTPOffice2007Images()->GetImageColor(_T("CalendarControl"), strColorName);
- }
- if (clrColor == COLORREF_NULL)
- {
- clrColor = GetColorsSetPart()->GetColor(eCLR, clrBaseColor);
- }
- return clrColor;
- }
- COLORREF CXTPCalendarThemeOffice2007::GetColor2(LPCTSTR pcszColorName, COLORREF clrDefault)
- {
- COLORREF clrColor = COLORREF_NULL;
- if (XTPOffice2007Images()->IsValid())
- {
- clrColor = XTPOffice2007Images()->GetImageColor(_T("CalendarControl"), pcszColorName);
- }
- if (clrColor == COLORREF_NULL)
- {
- clrColor = clrDefault;
- }
- return clrColor;
- }
- CXTPOffice2007Image* CXTPCalendarThemeOffice2007::GetBitmap(LPCTSTR pcszStdBmpName)
- {
- if (!m_pImagesStd || !m_pImageList || !pcszStdBmpName)
- {
- ASSERT(FALSE);
- return NULL;
- }
- CXTPOffice2007Image* pBmp = NULL;
- if (XTPOffice2007Images()->IsValid() && IsBaseColorOrig())
- {
- pBmp = XTPOffice2007Images()->LoadFile(pcszStdBmpName);
- }
- if (!pBmp)
- {
- CString strName;
- strName.Format(_T("Office2007_%s_BMP"), pcszStdBmpName);
- pBmp = m_pImagesStd->LoadFile(strName);
- }
- if (!pBmp && !IsBaseColorOrig() && XTPOffice2007Images()->IsValid())
- {
- pBmp = XTPOffice2007Images()->LoadFile(pcszStdBmpName);
- }
- return pBmp;
- }
- int CXTPCalendarThemeOffice2007::CTODay::HitTestExpandDayButton(CXTPCalendarViewDay* pViewDay, const CPoint* pPoint)
- {
- if (!pViewDay || !GetTheme() || !GetTheme()->GetCalendarControl())
- {
- ASSERT(FALSE);
- return 0;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
- CRect rc = dayLayout.m_rcDay;
- rc.right -= 5;
- rc.bottom -= 5;
- return _HitTestExpandDayButton(pViewDay, rc, pPoint);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetHeaderPartX());
- }
- void CXTPCalendarThemeOffice2007::CTODayView::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->RefreshMetrics(bRefreshChildren);
- }
- void CXTPCalendarThemeOffice2007::CTODayView::AdjustLayout(CDC* pDC, const CRect& rcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::AdjustLayout(pDC, rcRect);
- CRect rcRect2 = rcRect;
- rcRect2.left = XTP_SAFE_GET3(pThemeX->GetCalendarControl(), GetDayView(), GetViewDay_(0),
- GetDayRect().left, rcRect.left);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRect2);
- }
- void CXTPCalendarThemeOffice2007::CTODayView::Draw(CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::Draw(pDC);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
- };
- int CXTPCalendarThemeOffice2007::CTODayViewTimeScale::CalcMinRowHeight(CDC* pDC, CXTPCalendarDayViewTimeScale* pTimeScale)
- {
- if (!pDC || !pTimeScale)
- {
- ASSERT(FALSE);
- return 0;
- }
- int nHeight = TBase::CalcMinRowHeight(pDC, pTimeScale);
- if (GETTOTAL_MINUTES_DTS(pTimeScale->GetScaleInterval()) % 60 == 0 && nHeight > 0)
- {
- nHeight -= 1;
- }
- return nHeight;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewTimeScale::RefreshMetrics(BOOL)
- {
- ASSERT(GetTheme());
- if (!GetTheme())
- {
- return;
- }
- TBase::RefreshMetrics();
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(18, 13, 5));
- m_hflaBigHourFont.SetStandardValue(1, 1, -1);
- //-----------------------------
- m_clrBackground.SetStandardValue(GetTheme()->GetColor2(_T("TimeScaleBk"), RGB(227, 239, 255)));
- m_clrLine.SetStandardValue(GetTheme()->GetColor2(_T("TimeScaleLine"), RGB(101, 147, 207)));
- COLORREF clrText = m_clrLine.GetStandardColor(); //RGB(101, 147, 207);
- m_fcsetCaption.clrColor.SetStandardValue(clrText);
- CopySettings(m_fcsetAMPM.clrColor, clrText);
- CopySettings(m_fcsetSmall.clrColor, clrText);
- CopySettings(m_fcsetBigBase.clrColor, clrText);
- CopySettings(m_fcsetBigHour_.clrColor, m_fcsetBigBase.clrColor);
- //-----------------------
- if (IsXPTheme())
- {
- m_grclrNowLineBk.SetStandardValue(m_clrBackground, RGB(247, 202, 95));
- m_clrNowLine.SetStandardValue(RGB(187, 85, 3));
- }
- else
- {
- m_grclrNowLineBk.SetStandardValue(m_clrBackground);
- m_clrNowLine.SetStandardValue(::GetSysColor(COLOR_HIGHLIGHT));
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
- //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
- TBase::RefreshMetrics(bRefreshChildren);
- m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewDay")));
- if (pPX->IsStoring())
- secData->EmptySection();
- PX_Color(&secData, _T("BorderColor"), m_clrBorder);
- PX_Color(&secData, _T("TodayBorderColor"), m_clrTodayBorder);
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::Serialize(CArchive& ar)
- {
- m_clrBorder.Serialize(ar);
- m_clrTodayBorder.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetDayViewPartX()->GetHeaderPartX());
- // m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
- m_UseOffice2003HeaderFormat.SetStandardValue(FALSE);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetDayViewPartX()->GetDayPartX()->GetHeaderPartX());
- m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
- m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
- m_bkToday.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
- m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
- }
- void CXTPCalendarThemeOffice2007::CTOHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- m_clrBaseColor.SetStandardValue(pThemeX->m_clrBaseColor);
- m_clrTodayBaseColor.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- m_clrBorderLeft.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
- TBase::RefreshMetrics(bRefreshChildren);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupCell::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- //TBase::RefreshMetrics(); // has no children
- m_clrsetWorkCell.clrBackground.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBk));
- m_clrsetWorkCell.clrBorderBottomInHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBorderBottomInHour));
- m_clrsetWorkCell.clrBorderBottomHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBorderBottomHour));
- m_clrsetWorkCell.clrSelected.SetStandardValue(GetTheme()->GetColor(xtpCLR_SelectedBk));
- m_clrsetNonWorkCell.clrBackground.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBk));
- m_clrsetNonWorkCell.clrBorderBottomInHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBorderBottomInHour));
- m_clrsetNonWorkCell.clrBorderBottomHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBorderBottomHour));
- m_clrsetNonWorkCell.clrSelected.SetStandardValue(GetTheme()->GetColor(xtpCLR_SelectedBk));
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- //TBase::RefreshMetrics(); // has no children
- m_clrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewAllDayEventsBk));
- m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_SelectedBk));
- m_clrBottomBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewAllDayEventsBorderBottom));
- }
- /////////////////////////////////////////////////////////////////////////////
- void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::CopySettings(
- const CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet& rSrc)
- {
- CXTPCalendarTheme::CopySettings(clrBorder, rSrc.clrBorder);
- CXTPCalendarTheme::CopySettings(grclrBackground, rSrc.grclrBackground);
- fcsetSubject.CopySettings(rSrc.fcsetSubject);
- fcsetLocation.CopySettings(rSrc.fcsetLocation);
- fcsetBody.CopySettings(rSrc.fcsetBody);
- fcsetStartEnd.CopySettings(rSrc.fcsetStartEnd);
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::RefreshFromParent(CTOEvent* pParentSrc)
- {
- ASSERT(pParentSrc);
- if (!pParentSrc)
- {
- return;
- }
- m_fcsetNormal.CopySettings(pParentSrc->m_fcsetNormal);
- m_fcsetSelected.CopySettings(pParentSrc->m_fcsetSelected);
- CXTPCalendarTheme::CopySettings(m_clrGripperBorder, pParentSrc->m_clrGripperBorder);
- CXTPCalendarTheme::CopySettings(m_clrGripperBackground, pParentSrc->m_clrGripperBackground);
- if (pParentSrc->GetHeightFormulaPart())
- XTP_SAFE_CALL1(GetHeightFormulaPart(), RefreshFromParent(pParentSrc->GetHeightFormulaPart()) );
- if (pParentSrc->GetEventIconsToDrawPart())
- XTP_SAFE_CALL1(GetEventIconsToDrawPart(), RefreshFromParent(pParentSrc->GetEventIconsToDrawPart()) );
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- m_fcsetNormal.clrBorder.SetStandardValue(RGB(0, 0, 0));
- m_fcsetNormal.grclrBackground.SetStandardValue(RGB(255, 255, 255), RGB(255, 255, 255));
- m_fcsetSelected.clrBorder.SetStandardValue(RGB(0, 0, 0));
- m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
- //----------------------------------------------
- CFont* pFontDef = pThemeX->m_fntBaseFont;
- CFont* pFontBoldDef = pThemeX->m_fntBaseFontBold;
- //----------------------------------------------
- m_fcsetNormal.fcsetSubject.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetNormal.fcsetSubject.fntFont.SetStandardValue(pFontBoldDef);
- m_fcsetNormal.fcsetLocation.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetNormal.fcsetLocation.fntFont.SetStandardValue(pFontDef);
- m_fcsetNormal.fcsetBody.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetNormal.fcsetBody.fntFont.SetStandardValue(pFontDef);
- //----------------------------------------------
- m_fcsetSelected.fcsetSubject.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetSelected.fcsetSubject.fntFont.SetStandardValue(pFontBoldDef);
- m_fcsetSelected.fcsetLocation.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetSelected.fcsetLocation.fntFont.SetStandardValue(pFontDef);
- m_fcsetSelected.fcsetBody.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_fcsetSelected.fcsetBody.fntFont.SetStandardValue(pFontDef);
- m_clrGripperBorder.SetStandardValue(m_fcsetSelected.clrBorder);
- m_clrGripperBackground.SetStandardValue(RGB(255, 255, 255));
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::doPX(
- CXTPPropExchange* pPX, LPCTSTR pcszPropName, CXTPCalendarTheme* pTheme)
- {
- if (!pPX || !pcszPropName || !pTheme)
- {
- ASSERT(FALSE);
- return;
- }
- CXTPPropExchangeSection secData(pPX->GetSection(pcszPropName));
- if (pPX->IsStoring())
- secData->EmptySection();
- PX_Color(&secData, _T("BorderColor"), clrBorder);
- PX_GrColor(&secData, _T("Background"), grclrBackground);
- fcsetSubject.doPX(&secData, _T("Subject"), pTheme);
- fcsetLocation.doPX(&secData, _T("Location"), pTheme);
- fcsetBody.doPX(&secData, _T("Body"), pTheme);
- fcsetStartEnd.doPX(&secData, _T("StartEnd"), pTheme);
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::
- Serialize(CArchive& ar)
- {
- clrBorder.Serialize(ar);
- grclrBackground.Serialize(ar);
- fcsetSubject.Serialize(ar);
- fcsetLocation.Serialize(ar);
- fcsetBody.Serialize(ar);
- fcsetStartEnd.Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("Event")));
- if (pPX->IsStoring())
- secData->EmptySection();
- m_fcsetNormal.doPX(&secData, _T("Normal"), GetTheme());
- m_fcsetSelected.doPX(&secData, _T("Selected"), GetTheme());
- PX_Color(&secData, _T("GripperBorderColor"), m_clrGripperBorder);
- PX_Color(&secData, _T("GripperBackgroundColor"), m_clrGripperBackground);
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::Serialize(CArchive& ar)
- {
- m_fcsetNormal.Serialize(ar);
- m_fcsetSelected.Serialize(ar);
- m_clrGripperBorder.Serialize(ar);
- m_clrGripperBackground.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewEvent_MultiDay")));
- if (pPX->IsStoring())
- secData->EmptySection();
- m_strDateFormatFrom.DoPropExchange(&secData, _T("DateFormatFrom"));
- m_strDateFormatTo.DoPropExchange(&secData, _T("DateFormatTo"));
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Serialize(CArchive& ar)
- {
- m_strDateFormatFrom.Serialize(ar);
- m_strDateFormatTo.Serialize(ar);
- TBase::Serialize(ar);
- }
- int CXTPCalendarThemeOffice2007::CTOEvent::CalcMinEventHeight(CDC* pDC)
- {
- CArray<CFont*, CFont*> arFonts;
- arFonts.Add(m_fcsetNormal.fcsetSubject.Font());
- arFonts.Add(m_fcsetNormal.fcsetLocation.Font());
- arFonts.Add(m_fcsetNormal.fcsetStartEnd.Font());
- arFonts.Add(m_fcsetSelected.fcsetSubject.Font());
- arFonts.Add(m_fcsetSelected.fcsetLocation.Font());
- arFonts.Add(m_fcsetSelected.fcsetStartEnd.Font());
- int nFontHeightMax = 0;
- CXTPCalendarUtils::GetMaxHeightFont(arFonts, pDC, &nFontHeightMax);
- ASSERT(GetHeightFormulaPart());
- if (!GetHeightFormulaPart())
- {
- ASSERT(FALSE);
- return TBase::CalcMinEventHeight(pDC);
- }
- int nHeight = GetHeightFormulaPart()->Calculate(nFontHeightMax);
- return nHeight;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetEventPartX());
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
- XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, TRUE, TRUE, FALSE, TRUE));
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetDayViewPartX()->GetEventPartX());
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto) );
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
- //------------------------------------------------
- //LOCALE_IDATE - short date format ordering
- // 0 Month-Day-Year
- // 1 Day-Month-Year
- // 2 Year-Month-Day
- int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
- CString strFormatFrom, strFormatTo;
- XTPResourceManager()->LoadString(&strFormatFrom, XTP_IDS_CALENDAR_FROM);
- XTPResourceManager()->LoadString(&strFormatTo, XTP_IDS_CALENDAR_TO);
- if (nDateOrdering == 1)
- {
- strFormatFrom += _T(": MMM d");
- strFormatTo += _T(": MMM d");
- }
- else
- {
- strFormatFrom += _T(": d MMM");
- strFormatTo += _T(": d MMM");
- }
- m_strDateFormatFrom.SetStandardValue(strFormatFrom);
- m_strDateFormatTo.SetStandardValue(strFormatTo);
- //------------------------------------------------
- m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
- m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
- m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
- m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetDayViewPartX()->GetEventPartX());
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBkGRto));
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
- InitBusyStatusDefaultColors();
- }
- BOOL CXTPCalendarThemeOffice2007::CTOEvent::Draw_ArrowL(CXTPCalendarViewEvent* pViewEvent, CDC* pDC,
- CRect& rrcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return FALSE;
- }
- CXTPOffice2007Image* pArrowLR = pThemeX->GetBitmap(_T("CalendarAllDayEventArrowsLR"));
- if (!pArrowLR || !pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CSize szArrow = pArrowLR->GetExtent();
- szArrow.cy /= 2;
- CRect rcEventMax(pViewEvent->GetViewEventRectMax());
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return FALSE;
- }
- CRect rcArrow = rcEvent;
- rcArrow.top = rcEvent.top + rcEvent.Height() / 2 - szArrow.cy / 2;
- rcArrow.bottom = rcArrow.top + szArrow.cy;
- rcArrow.left = rcEventMax.left + 5;
- rcArrow.right = rcArrow.left + szArrow.cx;
- if (rcEventMax.Width() < szArrow.cx * 4)
- {
- rcArrow.right = rcArrow.left = rcEventMax.left;
- rrcRect = rcArrow;
- return FALSE;
- }
- rrcRect = rcArrow;
- pArrowLR->DrawImage(pDC, rcArrow, pArrowLR->GetSource(0, 2), CRect(0,0,0,0), RGB(255, 0, 255));
- return TRUE;
- }
- BOOL CXTPCalendarThemeOffice2007::CTOEvent::Draw_ArrowR(CXTPCalendarViewEvent* pViewEvent, CDC* pDC, CRect& rrcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return FALSE;
- }
- CXTPOffice2007Image* pArrowLR = pThemeX->GetBitmap(_T("CalendarAllDayEventArrowsLR"));
- if (!pArrowLR || !pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CSize szArrow = pArrowLR->GetExtent();
- szArrow.cy /= 2;
- CRect rcEventMax(pViewEvent->GetViewEventRectMax());
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return FALSE;
- }
- CRect rcArrow = rcEvent;
- rcArrow.top = rcEvent.top + rcEvent.Height() / 2 - szArrow.cy / 2;
- rcArrow.bottom = rcArrow.top + szArrow.cy;
- rcArrow.left = rcEventMax.right - 5 - szArrow.cx;
- rcArrow.right = rcArrow.left + szArrow.cx;
- if (rcEventMax.Width() < szArrow.cx * 4)
- {
- rcArrow.right = rcArrow.left = rcEventMax.right;
- rrcRect = rcArrow;
- return FALSE;
- }
- rrcRect = rcArrow;
- pArrowLR->DrawImage(pDC, rcArrow, pArrowLR->GetSource(1, 2), CRect(0,0,0,0), RGB(255, 0, 255));
- return TRUE;
- }
- CSize CXTPCalendarThemeOffice2007::CTOEvent::Draw_Icons(CXTPCalendarViewEvent* pViewEvent,
- CDC* pDC, const CRect& rcIconsMax, BOOL bCalculate)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pThemeX || !pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
- //-----------------------------------------------------
- CArray<XTP_CALENDAR_EVENT_ICON_INFO, XTP_CALENDAR_EVENT_ICON_INFO&> arIcons;
- CXTPCalendarCustomIconIDs* pCustIconsIDs = pEvent->GetCustomIcons();
- ASSERT(pCustIconsIDs);
- ASSERT(GetEventIconsToDrawPart());
- // get standard icons ===================================================
- CUIntArray arGlyphID, arGlyphIndex;
- if (GetEventIconsToDrawPart())
- GetEventIconsToDrawPart()->FillIconIDs(arGlyphID, arGlyphIndex, pEvent);
- CPoint ptNext_rb = rcIconsMax.BottomRight();
- int nIconYMax = 0;
- if (arGlyphID.GetSize())
- {
- CXTPOffice2007Image* pGlyphs = pThemeX->GetBitmap(_T("CalendarEventGlyphs"));
- ASSERT(pGlyphs);
- CSize szGlyph = pGlyphs ? pGlyphs->GetExtent() : CSize(0);
- szGlyph.cy /= 5;
- nIconYMax = max(nIconYMax, szGlyph.cy);
- int nCount = (int)arGlyphID.GetSize();
- for (int i = 0; i < nCount && pGlyphs; i++)
- {
- // skip if customized -------------------------------------
- if (pCustIconsIDs && pCustIconsIDs->Find(arGlyphID[i]) >= 0)
- {
- continue;
- }
- //---------------------------------------------------------
- if (ptNext_rb.x - szGlyph.cx >= rcIconsMax.left &&
- ptNext_rb.y - szGlyph.cy >= rcIconsMax.top)
- {
- XTP_CALENDAR_EVENT_ICON_INFO ii;
- ::ZeroMemory(&ii, sizeof(ii));
- ii.m_pImage = pGlyphs;
- ii.m_rcSrc = pGlyphs->GetSource(arGlyphIndex[i], 5);
- ii.m_rcDestination.bottom = ptNext_rb.y;
- ii.m_rcDestination.right = ptNext_rb.x;
- ii.m_rcDestination.left = ptNext_rb.x - szGlyph.cx;
- ii.m_rcDestination.top = ptNext_rb.y - szGlyph.cy;
- ptNext_rb.x -= szGlyph.cx;
- arIcons.Add(ii);
- }
- }
- }
- // get custom icons ===================================================
- CXTPImageManager* pImageMan = pThemeX->GetCustomIconsList();
- ASSERT(pImageMan);
- if (pImageMan && pCustIconsIDs && pCustIconsIDs->GetSize())
- {
- int nCount = pCustIconsIDs->GetSize();
- for (int i = 0; i < nCount; i++)
- {
- UINT uIconID = pCustIconsIDs->GetAt(nCount - i - 1);
- CXTPImageManagerIcon* pIcon = pImageMan->GetImage(uIconID, 0);
- if (pIcon)
- {
- CSize szIcon = pIcon->GetExtent();
- //------------------------------------------------------
- if (ptNext_rb.x - szIcon.cx < rcIconsMax.left)
- break;
- if (ptNext_rb.y - szIcon.cy < rcIconsMax.top)
- continue;
- //------------------------------------------------------
- XTP_CALENDAR_EVENT_ICON_INFO ii;
- ::ZeroMemory(&ii, sizeof(ii));
- ii.m_pIcon = pIcon;
- ii.m_rcDestination.bottom = ptNext_rb.y;
- ii.m_rcDestination.right = ptNext_rb.x;
- ii.m_rcDestination.left = ptNext_rb.x - szIcon.cx;
- ii.m_rcDestination.top = ptNext_rb.y - szIcon.cy;
- ptNext_rb.x -= szIcon.cx;
- nIconYMax = max(nIconYMax, szIcon.cy);
- arIcons.Add(ii);
- }
- }
- }
- //
- CSize szIcons(rcIconsMax.right - ptNext_rb.x, nIconYMax);
- if (bCalculate)
- {
- return szIcons;
- }
- //------------------------
- CRect rcIcons = rcIconsMax;
- rcIcons.left = max(rcIcons.right - szIcons.cx - 2, rcIconsMax.left);
- rcIcons.top = max(rcIcons.bottom - szIcons.cy - 2, rcIconsMax.top);
- CTOEvent* pEventPart = pThemeX->GetThemePartForEvent(pViewEvent);
- ASSERT(pEventPart);
- if (pEventPart && !rcIcons.IsRectEmpty())
- {
- pEventPart->FillEventBackgroundEx(pDC, pViewEvent, rcIcons);
- }
- // Draw icons
- int nCount = (int)arIcons.GetSize();
- for (int i = 0; i < nCount; i++)
- {
- XTP_CALENDAR_EVENT_ICON_INFO ii = arIcons[i];
- CRect rcIcon = ii.m_rcDestination;
- if (pDC->IsPrinting())
- {
- CRect rcIcon00(0, 0, rcIcon.Width(), rcIcon.Height());
- CBitmap bmp;
- bmp.CreateCompatibleBitmap(pDC, rcIcon.Width(), rcIcon.Height());
- CXTPCompatibleDC dcMem(NULL, &bmp);
- dcMem.m_bPrinting = TRUE;
- pEventPart->FillEventBackgroundEx(&dcMem, pViewEvent, rcIcon00);
- dcMem.m_bPrinting = FALSE;
- //------------------------------
- if (ii.m_pImage)
- {
- ii.m_pImage->DrawImage(&dcMem, rcIcon00, ii.m_rcSrc, CRect(0,0,0,0), RGB(255, 0, 255));
- }
- else if (ii.m_pIcon)
- {
- ii.m_pIcon->Draw(&dcMem, CPoint(0, 0));
- }
- else ASSERT(FALSE);
- pDC->BitBlt(rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), &dcMem, 0, 0, SRCCOPY);
- }
- else
- {
- if (ii.m_pImage)
- {
- ii.m_pImage->DrawImage(pDC, ii.m_rcDestination, ii.m_rcSrc, CRect(0,0,0,0), RGB(255, 0, 255));
- }
- else if (ii.m_pIcon)
- {
- ii.m_pIcon->Draw(pDC, rcIcon.TopLeft());
- }
- else ASSERT(FALSE);
- }
- }
- return szIcons;
- }
- BOOL CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw_ArrowLtext(CXTPCalendarViewEvent* pViewEvent,
- CDC* pDC, CThemeFontColorSetValue* pfcsetText, CRect& rrcRect, int nLeft_x)
- {
- if (!pDC || !pViewEvent || !pViewEvent->GetEvent() || !pfcsetText)
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CXTPFontDC autoFont(pDC, pfcsetText->Font(), pfcsetText->Color());
- CString strText = Format_FromToDate(pViewEvent, 1);
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return FALSE;
- }
- CSize szText = pDC->GetTextExtent(strText);
- CRect rcText = rcEvent;
- rcText.left = nLeft_x + 5;
- rcText.right = rcText.left + szText.cx;
- if (rcEvent.Width() / 2 < szText.cx * 3)
- {
- rcText.left = rcText.right = nLeft_x;
- rrcRect = rcText;
- return FALSE;
- }
- rrcRect = rcText;
- pDC->DrawText(strText, &rcText, DT_LEFT | DT_SINGLELINE | DT_VCENTER);
- return TRUE;
- }
- BOOL CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw_ArrowRtext(CXTPCalendarViewEvent* pViewEvent,
- CDC* pDC, CThemeFontColorSetValue* pfcsetText, CRect& rrcRect, int nRight_x)
- {
- if (!pDC || !pViewEvent || !pViewEvent->GetEvent() || !pfcsetText)
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CXTPFontDC autoFont(pDC, pfcsetText->Font(), pfcsetText->Color());
- CString strText = Format_FromToDate(pViewEvent, 2);
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return FALSE;
- }
- CSize szText = pDC->GetTextExtent(strText);
- CRect rcText = rcEvent;
- rcText.right = nRight_x - 5;
- rcText.left = rcText.right - szText.cx;
- if (rcEvent.Width() / 2 < szText.cx * 3)
- {
- rcText.left = rcText.right = nRight_x;
- rrcRect = rcText;
- return FALSE;
- }
- rrcRect = rcText;
- pDC->DrawText(strText, &rcText, DT_RIGHT | DT_SINGLELINE | DT_VCENTER);
- return TRUE;
- }
- CString CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Format_FromToDate(CXTPCalendarViewEvent* pViewEvent, int nStart1End2)
- {
- if (!pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return _T("");
- }
- ASSERT(nStart1End2 == 1 || nStart1End2 == 2);
- COleDateTime dtDate = nStart1End2 == 1 ? pViewEvent->GetEvent()->GetStartTime() : pViewEvent->GetEvent()->GetEndTime();
- if (nStart1End2 == 2 && CXTPCalendarUtils::IsZeroTime(dtDate))
- {
- dtDate -= COleDateTimeSpan(0, 0, 1, 0);
- }
- const CString& strFormat = nStart1End2 == 1 ? m_strDateFormatFrom : m_strDateFormatTo;
- CString strDate = CXTPCalendarUtils::GetDateFormat(dtDate, strFormat);
- return strDate;
- }
- ///*** ======================================================================
- CRect CXTPCalendarThemeOffice2007::CTODayViewDay::ExcludeDayBorder(
- CXTPCalendarDayViewDay* pDayViewDay, const CRect& rcDay)
- {
- BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
- int nWidthH = bIsToday ? 2 : 1;
- CRect rcGroups = rcDay;
- rcGroups.DeflateRect(nWidthH, 0, nWidthH, 1);
- return rcGroups;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- TBase::Draw(pObject, pDC);
- CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
- if (!pDC || !pDayViewDay)
- {
- ASSERT(FALSE);
- return;
- }
- CRect rcBottom = pDayViewDay->GetDayRect();
- rcBottom.top = rcBottom.bottom - 1;
- BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
- COLORREF clrBorder = bIsToday ? m_clrTodayBorder : m_clrBorder;
- pDC->FillSolidRect(&rcBottom, clrBorder);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::Draw_DayBorder(CXTPCalendarDayViewDay* pDayViewDay, CDC* pDC)
- {
- CRect rcDay = pDayViewDay->GetDayRect();
- CRect rcGroup(rcDay);
- if (pDayViewDay->GetViewGroupsCount() > 0)
- {
- rcGroup = pDayViewDay->GetViewGroup(0)->GetRect();
- }
- CRect rcDayDetails = rcDay;
- rcDayDetails.top = rcGroup.top;
- CRect rcDayDetails2 = ExcludeDayBorder(pDayViewDay, rcDayDetails);
- BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
- COLORREF clrBorder = bIsToday ? m_clrTodayBorder : m_clrBorder;
- CRect rcLeft = rcDayDetails, rcRight = rcDayDetails, rcBottom = rcDayDetails;
- rcLeft.right = min(rcDayDetails2.left, rcDayDetails.right);
- rcRight.left = max(rcDayDetails2.right, rcDayDetails.left);
- rcBottom.top = max(rcDayDetails2.bottom, rcDayDetails.top);
- pDC->FillSolidRect(&rcLeft, clrBorder);
- pDC->FillSolidRect(&rcRight, clrBorder);
- pDC->FillSolidRect(&rcBottom, clrBorder);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::AdjustLayout(CCmdTarget* pObject,
- CDC* pDC, const CRect& rcRect)
- {
- //TBase::AdjustLayout(pObject, pDC, rcRect);
- CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
- if (!pDC || !pDayViewDay || !pDayViewDay->GetView())
- {
- ASSERT(FALSE);
- return;
- }
- if (pDayViewDay->GetDayIndex() != 0)
- {
- return;
- }
- m_nWeekDayFormat = 0;
- CXTPCalendarDayView* pDayView = pDayViewDay->GetView();
- if (m_UseOffice2003HeaderFormat)
- {
- int nDayWidth = rcRect.Width() - 4;
- pDayView->CalculateHeaderFormat(pDC, nDayWidth, m_TextCenter.fcsetNormal.Font());
- }
- else
- {
- int nWDLong_max = 0;
- int nWDShort_max = 0;
- CXTPFontDC autoFnt(pDC, m_TextCenter.fcsetNormal.Font());
- for (int i = 0; i < 7; i++)
- {
- CString strWDLong = CXTPCalendarUtils::GetLocaleString(LOCALE_SDAYNAME1 + i, 100);
- CString strWDShort = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVDAYNAME1 + i, 100);
- nWDLong_max = max(nWDLong_max, pDC->GetTextExtent(strWDLong).cx);
- nWDShort_max = max(nWDShort_max, pDC->GetTextExtent(strWDShort).cx);
- }
- autoFnt.SetFont(m_TextLeftRight.fcsetNormal.Font());
- int nLR_width = pDC->GetTextExtent(_T("88"), 2).cx * 2;
- int nCenterTextWidth = max(rcRect.Width() - nLR_width, 0);
- if (nCenterTextWidth >= nWDLong_max + 4)
- {
- m_nWeekDayFormat = 2;
- }
- else if (nCenterTextWidth >= nWDShort_max + 4)
- {
- m_nWeekDayFormat = 1;
- }
- else
- {
- m_nWeekDayFormat = 0;
- }
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
- if (!pDC || !pDayViewDay || !pDayViewDay->GetView() || !GetTheme() || !pThemeX)
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& rLayout = GetTheme()->GetViewDayLayout(pDayViewDay);
- COleDateTime dtDay = pDayViewDay->GetDayDate();
- CPoint pt(0, 0);
- if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
- pThemeX->GetCalendarControl()->ScreenToClient(&pt);
- BOOL bIsToday = IsToday(pDayViewDay);
- BOOL bIsSelected = IsSelected(pDayViewDay);
- BOOL bFirstDay = pDayViewDay->GetDayIndex() == 0;
- BOOL bLastDay = pDayViewDay->GetDayIndex() == pDayViewDay->GetView()->GetViewDayCount() - 1;
- int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
- nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
- nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
- nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
- if (rLayout.m_rcDayHeader.PtInRect(pt))
- {
- nFlags |= CTOHeader::xtpCalendarItemState_Hot;
- rLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- else
- {
- rLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- CRect rcRect = rLayout.m_rcDayHeader;
- //------------------------------------------------------
- CString strTextLeft;
- CString strTextCenter;
- CString strTextRight;
- if (m_UseOffice2003HeaderFormat)
- {
- strTextCenter = pDayViewDay->GetCaption();
- }
- else
- {
- strTextLeft.Format(_T("%d"), dtDay.GetDay());
- if (m_nWeekDayFormat > 0)
- {
- LCTYPE lctWDName1 = m_nWeekDayFormat > 1 ? LOCALE_SDAYNAME1 : LOCALE_SABBREVDAYNAME1;
- int nWD = dtDay.GetDayOfWeek();
- strTextCenter = CXTPCalendarUtils::GetLocaleString(lctWDName1 + ((nWD-2+7)%7), 100);
- }
- //------------------------------------------------------
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderLeft, &strTextLeft, pDayViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderCenter, &strTextCenter, pDayViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderRight, &strTextRight, pDayViewDay);
- //------------------------------------------------------
- }
- Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- if (pPX->GetSchema() >= _XTP_SCHEMA_112)
- {
- CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewDayHeader")));
- if (pPX->IsStoring())
- secData->EmptySection();
- m_UseOffice2003HeaderFormat.DoPropExchange(&secData, _T("UseOffice2003HeaderFormat"));
- XTP_SAFE_CALL_BASE(TBase, DoPropExchange(&secData));
- }
- else
- {
- XTP_SAFE_CALL_BASE(TBase, DoPropExchange(pPX));
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::Serialize(CArchive& ar)
- {
- m_UseOffice2003HeaderFormat.Serialize(ar);
- XTP_SAFE_CALL_BASE(TBase, Serialize(ar));
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarDayViewGroup* pDayViewGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
- if (!pThemeX || !pDayViewGroup || !pDayViewGroup->GetViewDay())
- {
- ASSERT(FALSE);
- return;
- }
- const CXTPCalendarViewGroup::XTP_VIEW_GROUP_LAYOUT layoutGoup = CXTPCalendarTheme::GetViewGroupLayout(pDayViewGroup);
- CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayoutX = CXTPCalendarTheme::GetDayViewGroupLayout(pDayViewGroup);
- CRect rcRect = layoutGoup.m_rcGroupHeader;
- CPoint pt(0, 0);
- if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
- pThemeX->GetCalendarControl()->ScreenToClient(&pt);
- BOOL bIsToday = IsToday(pDayViewGroup->GetViewDay());
- BOOL bIsSelected = IsSelected(pDayViewGroup);
- BOOL bHot = rcRect.PtInRect(pt);
- BOOL bFirstDay = pDayViewGroup->GetGroupIndex() == 0;
- BOOL bLastDay = pDayViewGroup->GetGroupIndex() == pDayViewGroup->GetViewDay()->GetViewGroupsCount() - 1;
- int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
- nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
- nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
- nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
- if (bHot)
- {
- nFlags |= CTOHeader::xtpCalendarItemState_Hot;
- groupLayoutX.m_nHotState |= CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader;
- }
- else
- {
- groupLayoutX.m_nHotState &= ~CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader;
- }
- CString strCaption = pDayViewGroup->GetCaption();
- Draw_Header(pDC, rcRect, nFlags, _T(""), strCaption);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarViewDay* pViewDay = DYNAMIC_DOWNCAST(CXTPCalendarViewDay, pObject);
- if (!pThemeX || !pViewDay || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
- BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
- if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::AdjustDayEvents(
- CXTPCalendarDayViewGroup* pDayViewGroup, CDC* pDC)
- {
- if (!pDayViewGroup || !pDC)
- {
- ASSERT(FALSE);
- return;
- }
- ASSERT(pDC);
- CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder placeBuilder;
- placeBuilder.BiuldEventPaces(pDayViewGroup);
- CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& rLayoutX = GetTheme()->GetDayViewGroupLayout(pDayViewGroup);
- int nCount = pDayViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pViewEvent = pDayViewGroup->GetViewEvent(i);
- ASSERT(pViewEvent);
- if (!pViewEvent || pViewEvent->IsMultidayEvent())
- continue;
- int nPlaceNumber = pViewEvent->GetEventPlaceNumber();
- pViewEvent->AdjustLayout2(pDC, rLayoutX.m_rcDayDetails, nPlaceNumber);
- }
- }
- CRect CXTPCalendarThemeOffice2007::CTODayViewDayGroup::GetScrollButtonRect(
- const CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayout, int nButton)
- {
- CRect rc;
- switch (nButton)
- {
- case CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp:
- rc = groupLayout.m_rcDayDetails;
- rc.right -= 5;
- rc.top += 5;
- break;
- case CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown:
- rc = groupLayout.m_rcDayDetails;
- rc.right -= 5;
- rc.bottom -= 5;
- break;
- default:
- ASSERT(FALSE);
- rc.SetRect(0, 0, 0, 0);
- }
- return rc;
- }
- int CXTPCalendarThemeOffice2007::CTOCellDynBackground::GetCellDynBackground(CXTPCalendarViewGroup* pViewGroup,
- COleDateTime dtCellTime, int nCellIndex, CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT& rContext)
- {
- ::ZeroMemory(&rContext, sizeof(rContext));
- ASSERT(pViewGroup);
- if (!pViewGroup)
- return xtpCalendarBusyStatusUnknown;
- CXTPCalendarViewEvent* pBkVEv = GetCellBackgroundEvent(pViewGroup, dtCellTime, nCellIndex);
- if (!pBkVEv || !pBkVEv->GetEvent() || !pBkVEv->GetEvent()->GetCategories())
- return xtpCalendarBusyStatusUnknown;
- CXTPCalendarEvent* pEvent = pBkVEv->GetEvent();
- CXTPCalendarEventCategory* pCat = NULL;
- if (pEvent->GetCategories()->GetSize())
- {
- UINT nCatID = pEvent->GetCategories()->GetAt(0);
- pCat = XTP_SAFE_GET3(pEvent, GetDataProvider(), GetEventCategories(), Find(nCatID), NULL);
- }
- int nBusyStatus = pEvent->GetBusyStatus();
- if (nBusyStatus == xtpCalendarBusyStatusBusy ||
- nBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (!pCat)
- return nBusyStatus;
- rContext.clrBkAllDayEvents = pCat->GetBkColorAllDayEvents();
- rContext.clrBkNonWorkCell = pCat->GetBkColorNonWorkCell();
- rContext.clrBkWorkCell = pCat->GetBkColorWorkCell();
- rContext.clrCellBorder = pCat->GetColorCellBorder();
- }
- else if (nBusyStatus == xtpCalendarBusyStatusOutOfOffice)
- {
- rContext.clrBkAllDayEvents = RGB(183, 141, 206);
- rContext.clrBkNonWorkCell = RGB(214, 190, 227);
- rContext.clrBkWorkCell = RGB(229, 214, 237);
- rContext.clrCellBorder = rContext.clrBkAllDayEvents;
- }
- return nBusyStatus;
- }
- int CXTPCalendarThemeOffice2007::CTOCellDynBackground::_GetEventBusyStatusRank(CXTPCalendarEvent* pEvent)
- {
- ASSERT(pEvent);
- if (!pEvent)
- return -1;
- //----------------------------------------------------------------------------
- const int cnRankSize = 4;
- ASSERT(xtpCalendarBusyStatusFree < cnRankSize && xtpCalendarBusyStatusTentative < cnRankSize &&
- xtpCalendarBusyStatusBusy < cnRankSize && xtpCalendarBusyStatusOutOfOffice < cnRankSize);
- static int sarBSrank[cnRankSize] = {0, 0, 0, 0};
- if (sarBSrank[0] == 0)
- {
- sarBSrank[xtpCalendarBusyStatusFree] = 1; // min rank
- sarBSrank[xtpCalendarBusyStatusTentative] = 2;
- sarBSrank[xtpCalendarBusyStatusOutOfOffice] = 3;
- sarBSrank[xtpCalendarBusyStatusBusy] = 4; // max rank
- }
- //----------------------------------------------------------------------------
- int nBS = pEvent->GetBusyStatus();
- int nBSindex = max(0, min(nBS, cnRankSize-1));
- ASSERT(nBSindex >= 0 && nBSindex < cnRankSize);
- int nBSrank = sarBSrank[nBSindex];
- return nBSrank;
- }
- int CXTPCalendarThemeOffice2007::CTOCellDynBackground::CmpEventBusyStatus(CXTPCalendarEvent* pEvent1, CXTPCalendarEvent* pEvent2)
- {
- ASSERT(pEvent1 && pEvent2);
- if (!pEvent1 || !pEvent2)
- return XTPCompare(pEvent1, pEvent2);
- int nBS1rank = _GetEventBusyStatusRank(pEvent1);
- int nBS2rank = _GetEventBusyStatusRank(pEvent2);
- int nCmp = XTPCompare(nBS1rank, nBS2rank);
- if (nCmp == 0)
- nCmp = XTPCompare(pEvent1->GetDurationMinutes(), pEvent2->GetDurationMinutes());
- if (nCmp == 0 && !CXTPCalendarUtils::IsEqual(pEvent1->GetStartTime(), pEvent2->GetStartTime()))
- nCmp = XTPCompare(pEvent1->GetStartTime(), pEvent2->GetStartTime());
- if (nCmp == 0)
- nCmp = XTPCompare(pEvent1->GetEventID(), pEvent2->GetEventID());
- return nCmp;
- }
- CXTPCalendarViewEvent* CXTPCalendarThemeOffice2007::CTOCellDynBackground::GetCellBackgroundEvent(CXTPCalendarViewGroup* pViewGroup,
- COleDateTime dtCellTime, int nCellIndex)
- {
- ASSERT(pViewGroup);
- if (!pViewGroup)
- return NULL;
- // TODO: Not optimal implementation. Optimize later if need.
- // #pragma XTPNOTE("Not optimal implementation. Optimize later if need.")
- CXTPCalendarViewEvent* pBkVEvent = NULL;
- int nCount = pViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarEvent* pEvent = XTP_SAFE_GET2(pViewGroup, GetViewEvent_(i), GetEvent(), NULL);
- if (XTP_SAFE_GET2(pViewGroup, GetViewEvent_(i), IsMultidayEvent(), FALSE) && pEvent)
- {
- if (pEvent->IsAllDayEvent())
- continue;
- if (nCellIndex < 0 ||
- (dtCellTime >= pEvent->GetStartTime() && dtCellTime <= pEvent->GetEndTime())
- )
- {
- if (!pBkVEvent || CmpEventBusyStatus(pBkVEvent->GetEvent(), pEvent) < 0)
- {
- pBkVEvent = pViewGroup->GetViewEvent_(i);
- }
- }
- }
- }
- return pBkVEvent;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupCell::Draw(CDC* pDC, const CRect& rcRect,
- const XTP_CALENDAR_THEME_DAYVIEWCELL_PARAMS& cellParams, CXTPPropsStateContext* pStateCnt)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
- XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
- if (!pDC || !pThemeX || !cellParams.pViewGroup || !pCellDynBkPart || !pThemeX->GetColorsSetPart())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPPropsStateContext autoStateCnt0(this);
- //--------------------------------------------------------------------
- CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
- int nCellBusyStatus = pCellDynBkPart->GetCellDynBackground(cellParams.pViewGroup,
- cellParams.dtBeginTime, cellParams.nIndex, bsColors);
- //--------------------------------------------------------------------
- COLORREF clrHatch = 0;
- if (nCellBusyStatus == xtpCalendarBusyStatusBusy ||
- nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
- nCellBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or Tentative
- {
- clrHatch = bsColors.clrBkAllDayEvents;
- if (cellParams.bWorkCell)
- {
- if (nCellBusyStatus != xtpCalendarBusyStatusTentative)
- m_clrsetWorkCell.clrBackground = bsColors.clrBkWorkCell;
- m_clrsetWorkCell.clrBorderBottomHour = bsColors.clrCellBorder;
- int nScale = (nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice) ? 110 : 30;
- m_clrsetWorkCell.clrBorderBottomInHour = XTPDrawHelpers()->LightenColor(nScale, bsColors.clrCellBorder);
- }
- else
- {
- if (nCellBusyStatus != xtpCalendarBusyStatusTentative)
- m_clrsetNonWorkCell.clrBackground = bsColors.clrBkNonWorkCell;
- m_clrsetNonWorkCell.clrBorderBottomHour = bsColors.clrCellBorder;
- int nScale = (nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice) ? 54 : 30;
- m_clrsetNonWorkCell.clrBorderBottomInHour = XTPDrawHelpers()->LightenColor(nScale, bsColors.clrCellBorder);
- }
- }
- else
- {
- if (nCellBusyStatus == xtpCalendarBusyStatusBusy ||
- nCellBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (nCellBusyStatus == xtpCalendarBusyStatusBusy)
- {
- //GetColorsSetPart()->SetColor(xtpCLR_DayViewSingleDayEventBkGRto, 155); // 191, 210, 234 // single-day event gradient fill Dark
- m_clrsetWorkCell.clrBackground = XTPDrawHelpers()->LightenColor(155, GetTheme()->m_clrBaseColor);
- m_clrsetNonWorkCell.clrBackground = (COLORREF)m_clrsetWorkCell.clrBackground;
- }
- m_clrsetWorkCell.clrBorderBottomHour = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
- m_clrsetNonWorkCell.clrBorderBottomHour = (COLORREF)m_clrsetWorkCell.clrBorderBottomHour;
- m_clrsetWorkCell.clrBorderBottomInHour = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_DayViewCellWorkBorderBottomHour);
- m_clrsetNonWorkCell.clrBorderBottomInHour = (COLORREF)m_clrsetWorkCell.clrBorderBottomInHour;
- }
- clrHatch = m_clrsetWorkCell.clrBorderBottomHour;
- }
- }
- //--------------------------------------------------------------------
- if (pStateCnt)
- pStateCnt->SendBeforeDrawThemeObject((LPARAM)&cellParams, xtpCalendarBeforeDraw_DayViewCell);
- //--------------------------------------------------------------------
- TBase::Draw(pDC, rcRect, cellParams, NULL);
- //--------------------------------------------------------------------
- if (nCellBusyStatus == xtpCalendarBusyStatusTentative)
- {
- COLORREF clrBk = 0;
- if (cellParams.bSelected)
- clrBk = cellParams.bWorkCell ? m_clrsetWorkCell.clrSelected : m_clrsetNonWorkCell.clrSelected;
- else
- clrBk = cellParams.bWorkCell ? m_clrsetWorkCell.clrBackground : m_clrsetNonWorkCell.clrBackground;
- CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBk);
- CBrush br(HS_BDIAGONAL, clrHatch);
- CRect rc = rcRect;
- if (cellParams.nIndex != cellParams.pViewGroup->GetViewDay()->GetView()->GetTopRow())
- rc.top++;
- pDC->FillRect(&rc, &br);
- }
- //--------------------------------------------------------------------
- autoStateCnt0.RestoreState();
- autoStateCnt0.Clear();
- //--------------------------------------------------------------------
- if (pStateCnt)
- pStateCnt->RestoreState();
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::SetDynColors(CXTPCalendarDayViewGroup* pViewGroup)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
- XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
- if (!pViewGroup || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
- {
- ASSERT(FALSE);
- return;
- }
- COleDateTime dtDate = pViewGroup->GetViewDay()->GetDayDate();
- //--------------------------------------------------------------------
- CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
- m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, dtDate, -1, bsColors);
- //--------------------------------------------------------------------
- m_clrDynHatch = 0;
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
- m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
- m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
- {
- m_clrDynHatch = bsColors.clrBkAllDayEvents;
- if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
- {
- m_clrBackground = bsColors.clrBkAllDayEvents;
- m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
- }
- }
- else
- {
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
- {
- m_clrBackground = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
- }
- m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
- }
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarDayViewGroup* pDayViewGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
- if (!pDC || !pDayViewGroup || !pDayViewGroup->GetViewDay() || !pThemeX)
- {
- ASSERT(FALSE);
- return;
- }
- CRect rcRectBk = pDayViewGroup->GetAllDayEventsRect();
- CRect rcRect2 = rcRectBk;
- if (rcRectBk.IsRectEmpty())
- {
- return;
- }
- rcRectBk.bottom -= 2;
- rcRect2.top = rcRectBk.bottom;
- BOOL bIsSelected = GetTheme()->GetDayViewPart()->GetDayPart()->GetGroupPart()->IsSelected(pDayViewGroup);
- BOOL bIsToday = GetTheme()->GetDayViewPart()->GetHeaderPart()->IsToday(pDayViewGroup->GetViewDay());
- COLORREF clrBk = bIsSelected ? m_clrBackgroundSelected : m_clrBackground;
- COLORREF clrBorder = bIsToday ? (COLORREF)pThemeX->GetDayViewPartX()->GetDayPartX()->m_clrTodayBorder : m_clrBottomBorder;
- pDC->FillSolidRect(&rcRectBk, clrBk);
- pDC->FillSolidRect(&rcRect2, clrBorder);
- //--------------------------------------------------------------------
- if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBk);
- CBrush br(HS_BDIAGONAL, m_clrDynHatch);
- pDC->FillRect(&rcRectBk, &br);
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- TBase::Draw(pObject, pDC);
- CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pDVGroup || !pThemeX)
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayout = GetTheme()->GetDayViewGroupLayout(pDVGroup);
- if (pDC->IsPrinting())
- return;
- groupLayout.m_nHotState &= ~(CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp | CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown);
- int nHit = HitTestScrollButton(pDVGroup);
- if (pDVGroup->IsExpandUp())
- {
- int nButton = CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp;
- CRect rc = GetScrollButtonRect(groupLayout, nButton);
- BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollUp);
- pThemeX->DrawExpandDayButton(pDC, rc, TRUE, bHot);
- if (bHot)
- groupLayout.m_nHotState |= nButton;
- }
- if (pDVGroup->IsExpandDown())
- {
- int nButton = CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown;
- CRect rc = GetScrollButtonRect(groupLayout, nButton);
- BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollDown);
- pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
- if (bHot)
- groupLayout.m_nHotState |= nButton;
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
- if (!pDVGroup || !pThemeX || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewGroup::XTP_VIEW_GROUP_LAYOUT groupLayout = GetTheme()->GetViewGroupLayout(pDVGroup);
- CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayoutX = GetTheme()->GetDayViewGroupLayout(pDVGroup);
- BOOL bRedraw = FALSE;
- int nHit = HitTestScrollButton(pDVGroup, &point);
- BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollUp);
- BOOL bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp);
- bRedraw |= (bHot != bHotPrev);
- bHot = !!(nHit & xtpCalendarHitTestDayViewScrollDown);
- bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown);
- bRedraw |= (bHot != bHotPrev);
- //-----------------------------------------------------------------------
- bHot = groupLayoutX.m_bShowHeader && groupLayout.m_rcGroupHeader.PtInRect(point);
- bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader);
- bRedraw |= (bHot != bHotPrev);
- if (bRedraw)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL CXTPCalendarThemeOffice2007::CTODayViewDayGroup::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
- if (!pDVGroup || !pDVGroup->GetViewDay() || !pThemeX || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- int nHit = HitTestScrollButton(pDVGroup, &point);
- if (nHit & xtpCalendarHitTestDayViewScrollUp)
- {
- pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
- (WPARAM)(xtpCalendarUserAction_OnScrollDay | xtpCalendarScrollDayButton_DayViewUp),
- MAKELPARAM((WORD)pDVGroup->GetGroupIndex(), pDVGroup->GetViewDay()->GetDayIndex()) );
- return TRUE;
- }
- if (nHit & xtpCalendarHitTestDayViewScrollDown)
- {
- pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
- (WPARAM)(xtpCalendarUserAction_OnScrollDay | xtpCalendarScrollDayButton_DayViewDown),
- MAKELPARAM((WORD)pDVGroup->GetGroupIndex(), pDVGroup->GetViewDay()->GetDayIndex()) );
- return TRUE;
- }
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- //class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
- CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder()
- {
- m_mapEvToOverlapped.InitHashTable(XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT, FALSE);
- m_spCellDuration.SetDateTimeSpan(0, 0, 30, 0);
- m_dtMinStartTime = (DATE)0;
- }
- void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::BiuldEventPaces(CXTPCalendarDayViewGroup* pViewGroup)
- {
- ASSERT(pViewGroup);
- if (!pViewGroup)
- return;
- //----------------------------------------------------
- m_spCellDuration = XTP_SAFE_GET3(pViewGroup, GetViewDay(), GetView(), GetCellDuration(), 0);
- if (double(m_spCellDuration) <= XTP_HALF_SECOND)
- {
- m_spCellDuration.SetDateTimeSpan(0, 0, 30, 0);
- }
- m_dtMinStartTime = XTP_SAFE_GET2(pViewGroup, GetViewDay(), GetDayDate(), (DATE)0) +
- COleDateTimeSpan(1, 0, 0, 1) - m_spCellDuration;
- //----------------------------------------------------
- _Clear();
- int nCount = pViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
- ASSERT(pViewEvent);
- if (!pViewEvent || pViewEvent->IsMultidayEvent())
- continue;
- // Reset Events Paces
- pViewEvent->SetEventPlacePos(XTP_EVENT_PLACE_POS_UNDEFINED);
- pViewEvent->SetEventPlaceCount(1);
- // Update X Data for each event
- _UpdateDataFor(pViewEvent, pViewGroup);
- }
- // Update Events Paces using X Data
- _UpdateEventsPaces(pViewGroup);
- // Delete intermediate X data
- _Clear();
- }
- void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_Clear()
- {
- m_mapEvToOverlapped.RemoveAll();
- }
- void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_UpdateDataFor(CXTPCalendarDayViewEvent* pViewEvent,
- CXTPCalendarDayViewGroup* pViewGroup)
- {
- if (!pViewEvent || !pViewGroup || !pViewGroup->GetViewDay())
- {
- ASSERT(FALSE);
- return;
- }
- COleDateTime dtStart = pViewEvent->GetEvent()->GetStartTime();
- COleDateTime dtEnd = pViewEvent->GetEvent()->GetEndTime();
- COleDateTime dtGroupDay = pViewGroup->GetViewDay()->GetDayDate();
- if (dtStart < dtGroupDay)
- {
- dtStart = dtGroupDay;
- ASSERT(dtStart <= dtEnd);
- }
- COleDateTimeSpan spEventDuration2 = dtEnd - dtStart;
- // adjust end time if need
- //if (pViewEvent->GetEvent()->GetDuration() < m_spCellDuration)
- if (spEventDuration2 < m_spCellDuration)
- {
- dtEnd = dtStart + m_spCellDuration;
- }
- // adjust start time if need
- if (dtStart > m_dtMinStartTime)
- {
- dtStart = m_dtMinStartTime;
- }
- //=====================================================
- int nCount = pViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pVEv_i = pViewGroup->GetViewEvent(i);
- ASSERT(pVEv_i);
- if (!pVEv_i || pVEv_i->IsMultidayEvent() || !pVEv_i->GetEvent())
- continue;
- COleDateTime dtStart_i = pVEv_i->GetEvent()->GetStartTime();
- COleDateTime dtEnd_i = pVEv_i->GetEvent()->GetEndTime();
- if (dtStart_i < dtGroupDay)
- {
- dtStart_i = dtGroupDay;
- ASSERT(dtStart_i <= dtEnd_i);
- }
- COleDateTimeSpan spEventDuration2_i = dtEnd_i - dtStart_i;
- // adjust end time if need
- //if (pVEv_i->GetEvent()->GetDuration() < m_spCellDuration)
- if (spEventDuration2_i < m_spCellDuration)
- {
- dtEnd_i = dtStart_i + m_spCellDuration;
- }
- // adjust start time if need
- if (dtStart_i > m_dtMinStartTime)
- {
- dtStart_i = m_dtMinStartTime;
- }
- // is Overlapped
- if (!(dtEnd_i < dtStart || dtStart_i > dtEnd ||
- CXTPCalendarUtils::IsEqual(dtEnd_i, dtStart) ||
- CXTPCalendarUtils::IsEqual(dtStart_i, dtEnd) )
- )
- {
- _XAddOverlapped(pViewEvent, pVEv_i);
- }
- }
- }
- void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_UpdateEventsPaces(CXTPCalendarDayViewGroup* pViewGroup)
- {
- UNREFERENCED_PARAMETER(pViewGroup);
- // assign event places
- int i;
- int nCount = pViewGroup->GetViewEventsCount();
- for (i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
- ASSERT(pViewEvent);
- if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
- continue;
- ASSERT(pViewEvent->GetEventPlacePos() == XTP_EVENT_PLACE_POS_UNDEFINED);
- if (pViewEvent->GetEventPlacePos() == XTP_EVENT_PLACE_POS_UNDEFINED)
- {
- CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
- ASSERT(pMapOvr);
- if (pMapOvr)
- {
- int nPlace = pMapOvr->GetMinFreeEventPlace();
- ASSERT(nPlace >= 0 && nPlace != XTP_EVENT_PLACE_POS_UNDEFINED);
- pViewEvent->SetEventPlacePos(nPlace);
- }
- }
- }
- // update event places count
- for (i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
- ASSERT(pViewEvent);
- if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
- continue;
- ASSERT(pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
- if (pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED)
- {
- CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
- ASSERT(pMapOvr);
- if (pMapOvr)
- {
- int nPlaceMax = pMapOvr->GetMaxEventPlace();
- ASSERT(nPlaceMax >= 0);
- pViewEvent->SetEventPlaceCount(nPlaceMax + 1);
- }
- }
- }
- // update event places count to maximum from overlapped set
- // TODO: update to recurrence
- for (int k = 0; k < min(nCount, 3); k++)
- {
- for (i = 0; i < nCount; i++)
- {
- CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
- ASSERT(pViewEvent);
- if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
- continue;
- ASSERT(pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
- if (pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED)
- {
- CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
- ASSERT(pMapOvr);
- if (pMapOvr)
- {
- int nPlaceCountMax = pMapOvr->GetMaxEventPlaceCountEx();
- ASSERT(nPlaceCountMax >= pViewEvent->GetEventPlaceCount());
- pViewEvent->SetEventPlaceCount(nPlaceCountMax);
- }
- }
- }
- }
- }
- CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap* CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::
- _XGetDataFor(CXTPCalendarDayViewEvent* pViewEvent)
- {
- // CViewEventsMap* pVEvMap = NULL;
- // to avoid warning C4786 CObject* used.
- CObject* pVEvMap = NULL;
- if (m_mapEvToOverlapped.Lookup(pViewEvent, pVEvMap) && pVEvMap)
- {
- return (CViewEventsMap*)pVEvMap;
- }
- // Create a new sub-data map
- pVEvMap = new CViewEventsMap();
- if (pVEvMap)
- {
- m_mapEvToOverlapped[pViewEvent] = pVEvMap;
- }
- return (CViewEventsMap*)pVEvMap;
- }
- void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_XAddOverlapped(
- CXTPCalendarDayViewEvent* pVEv_base,
- CXTPCalendarDayViewEvent* pVEv_overlapped)
- {
- CViewEventsMap* pVEvMap = _XGetDataFor(pVEv_base);
- if (!pVEvMap) // no memory to create
- return;
- pVEvMap->SetAt(pVEv_overlapped, 0);
- }
- /////////////////////////////////////////////////////////////////////////////
- CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::CViewEventsMap()
- {
- InitHashTable(XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT, FALSE);
- }
- int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMinFreeEventPlace()
- {
- int nMinFreeEventPlace = 0;
- BOOL bBysy = FALSE;
- do
- {
- bBysy = FALSE;
- POSITION pos = GetStartPosition();
- while (pos)
- {
- CXTPCalendarDayViewEvent* pVEv = NULL;
- int nTmp = 0;
- GetNextAssoc(pos, pVEv, nTmp);
- if (pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED &&
- pVEv->GetEventPlacePos() == nMinFreeEventPlace)
- {
- nMinFreeEventPlace++;
- bBysy = TRUE;
- break;
- }
- }
- }
- while (bBysy);
- return nMinFreeEventPlace;
- }
- int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMaxEventPlace()
- {
- int nMaxEventPlace = 0;
- POSITION pos = GetStartPosition();
- while (pos)
- {
- CXTPCalendarDayViewEvent* pVEv = NULL;
- int nTmp = 0;
- GetNextAssoc(pos, pVEv, nTmp);
- ASSERT(pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
- if (pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED &&
- pVEv->GetEventPlacePos() > nMaxEventPlace)
- {
- nMaxEventPlace = pVEv->GetEventPlacePos();
- }
- }
- return nMaxEventPlace;
- }
- int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMaxEventPlaceCountEx()
- {
- int nMaxEventPlaceCount = 1;
- POSITION pos = GetStartPosition();
- while (pos)
- {
- CXTPCalendarDayViewEvent* pVEv = NULL;
- int nTmp = 0;
- GetNextAssoc(pos, pVEv, nTmp);
- ASSERT(pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
- if (pVEv && pVEv->GetEventPlaceCount() > nMaxEventPlaceCount)
- {
- nMaxEventPlaceCount = pVEv->GetEventPlaceCount();
- }
- }
- return nMaxEventPlaceCount;
- }
- //////////////////////////////////////////////////////////////////////////
- BOOL CXTPCalendarThemeOffice2007::CTODayViewDayGroup::IsSelected(CXTPCalendarViewGroup* pViewGroup)
- {
- if (!pViewGroup || !pViewGroup->GetViewDay_() || !pViewGroup->GetViewDay_()->GetView_())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- COleDateTime dtBegin;
- COleDateTime dtEnd;
- if (pViewGroup->GetViewDay_()->GetView_()->GetSelection(&dtBegin, &dtEnd))
- {
- COleDateTime dtDay = pViewGroup->GetViewDay_()->GetDayDate();
- ASSERT(CXTPCalendarUtils::IsZeroTime(dtDay));
- dtDay = CXTPCalendarUtils::ResetTime(dtDay);
- COleDateTimeSpan spSel = dtBegin - dtEnd;
- int nSelDays = abs(GETTOTAL_DAYS_DTS(spSel));
- dtBegin = CXTPCalendarUtils::ResetTime(dtBegin);
- int nCorrector = CXTPCalendarUtils::IsZeroTime(dtEnd) ? 0 : 1;
- dtEnd = CXTPCalendarUtils::ResetTime(dtEnd) + COleDateTimeSpan(nCorrector, 0, 0, 0);
- return nSelDays > 0 && dtBegin <= dtDay && dtDay < dtEnd;
- }
- return FALSE;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::CalcEventYs(CRect& rrcRect, int nEventPlaceNumber)
- {
- CXTPCalendarDayView* pView = DYNAMIC_DOWNCAST(CXTPCalendarDayView, XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetDayView(), NULL));
- if (!pView)
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarDayView::XTP_DAY_VIEW_LAYOUT& rLayoutX = GetTheme()->GetDayViewLayout(pView);
- int nAllDayEventHeight = rLayoutX.m_nAllDayEventHeight;
- rrcRect.top = rLayoutX.m_rcAllDayEvents.top + nAllDayEventHeight * nEventPlaceNumber;
- rrcRect.bottom = rrcRect.top + nAllDayEventHeight;
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::AdjustLayout(CCmdTarget* pObject, CDC* pDC,
- const CRect& rcRect, int nEventPlaceNumber)
- {
- UNREFERENCED_PARAMETER(rcRect);
- CXTPCalendarDayViewEvent* pDayViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
- CXTPCalendarDayView* pView = XTP_SAFE_GET3(pDayViewEvent, GetViewGroup(), GetViewDay(), GetView(), NULL);
- CXTPCalendarEvent* pEvent = XTP_SAFE_GET1(pDayViewEvent, GetEvent(), NULL);
- if (!pDC || !pDayViewEvent || !pView || !pEvent)
- {
- ASSERT(FALSE);
- return;
- }
- if (!pDayViewEvent->IsMultidayEvent())
- {
- ASSERT(FALSE);
- return;
- }
- //**********************
- int nMDEFlags = pDayViewEvent->GetMultiDayEventFlags();
- CalcEventYs(pDayViewEvent->m_rcEventMax, nEventPlaceNumber);
- pDayViewEvent->m_rcEvent.CopyRect(&pDayViewEvent->m_rcEventMax);
- pDayViewEvent->m_rcText.CopyRect(&pDayViewEvent->m_rcEventMax);
- if ((nMDEFlags & xtpCalendarMultiDayFirst) != 0)
- {
- pDayViewEvent->m_rcEvent.left += 8;
- }
- if ((nMDEFlags & xtpCalendarMultiDayLast) != 0)
- {
- pDayViewEvent->m_rcEvent.right -= 8;
- }
- pDayViewEvent->m_rcText.CopyRect(pDayViewEvent->m_rcEvent);
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
- int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
- if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
- {
- return;// was drawn in the Master (or out of events rect)
- }
- CRect rcEventMax(pViewEvent->GetViewEventRectMax());
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // fill event background
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
- //----------------
- pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
- int nSelOffset = bSelected ? 2 : 1;
- if (nMDEFlags & xtpCalendarMultiDayFirst)
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
- CRect rcText(rcEvent); //(pViewEvent->GetTextRect());
- rcText.DeflateRect(3, 2, 3, 2);
- BOOL bHideArrow = FALSE;
- BOOL bHideArrowText = FALSE;
- if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
- {
- rcText.left = rcEventMax.left;
- CRect rcSQ = rcEventMax;
- rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(1,1,0,1));
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, 0, rcEvent.bottom - nSelOffset);
- //---------------------------
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
- bHideArrow = !bArrow;
- if (bArrow)
- {
- rcText.left = rcArrow.right;
- }
- if (bArrow && (nMDEFlags & xtpCalendarMultiDayLast) == 0)
- {
- CRect rcArrowText;
- CThemeFontColorSetValue* pFCsetFromTo = bSelected ? &m_fcsetSelected.fcsetStartEnd : &m_fcsetNormal.fcsetStartEnd;
- BOOL bArrowText = Draw_ArrowLtext(pViewEvent, pDC, pFCsetFromTo,
- rcArrowText, rcArrow.right);
- bHideArrowText = !bArrowText;
- if (bArrowText)
- {
- rcText.left = rcArrowText.right;
- }
- }
- }
- else if (bSelected)
- {
- // draw left Gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.left = rcEvent.left - 1;
- rcGripper.right = rcGripper.left + cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
- {
- rcText.right = rcEventMax.right;
- CRect rcSQ = rcEventMax;
- rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,1,1));
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcSQ.left, rcEvent.top + nSelOffset),
- rcEventMax.right - nSelOffset, grclrBk, 0, INT_MAX, FALSE);
- if (!bHideArrow)
- {
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
- if (bArrow)
- {
- rcText.right = rcArrow.left;
- }
- if (bArrow && (nMDEFlags & xtpCalendarMultiDayFirst) == 0 && !bHideArrowText)
- {
- CRect rcArrowText;
- CThemeFontColorSetValue* pFCsetFromTo = bSelected ? &m_fcsetSelected.fcsetStartEnd : &m_fcsetNormal.fcsetStartEnd;
- BOOL bArrowText = Draw_ArrowRtext(pViewEvent, pDC, pFCsetFromTo,
- rcArrowText, rcArrow.left);
- if (bArrowText)
- {
- rcText.right = rcArrowText.left;
- }
- }
- }
- }
- else if (bSelected)
- {
- // draw right gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.right = rcEvent.right + 1;
- rcGripper.left = rcGripper.right - cnGripperSize;;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- //=======================================================================
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- if (!strLoc.IsEmpty())
- {
- strSubj += _T(";");
- }
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- //rcText.DeflateRect(3, 2, 3, 2);
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- //pViewEvent->AdjustSubjectEditorEx(FALSE);
- pViewEvent->AdjustSubjectEditor();
- CRect rcIconsMax = rcText;
- //
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- rcText.right = max(rcText.left, rcText.right - szIcons.cx - 2);
- //---------------------------------------------------------------
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- }
- }
- //
- //--- calculate rects and fix to be centered if enough space ---
- if (!bMarkupDrawn)
- {
- UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
- CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign | DT_CALCRECT);
- rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- int nTIcx = szText.cx + szIcons.cx;
- if (nTIcx + 5 < rcText.Width())
- {
- int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
- rcText.left += ncx_2;
- rcText.right = rcText.left + szText.cx + 2;
- rcIconsMax.right -= ncx_2;
- }
- else
- {
- rcText.right -= szIcons.cx + 2;
- }
- //- Draw ================================
- pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign);
- }
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- // TODO:
- /*
- BOOL bOutOfBorders = nY_need > rcText.Height() ||
- nX_need > rcText.Width() ||
- bTimeOutOfBorders;
- pViewEvent->SetTextOutOfBorders(bOutOfBorders);
- */
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::FillEventBackgroundEx(CDC* pDC,
- CXTPCalendarViewEvent* pViewEvent, const CRect& rcRect)
- {
- if (!pDC || !pViewEvent)
- {
- ASSERT(FALSE);
- return;
- }
- CRect rcEventFull = pViewEvent->GetEventRect();
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
- if (pDC->IsPrinting())
- {
- CXTPCalendarTheme::DrawRectPartly(pDC, rcRect, 0, FALSE, grclrBk, CRect(0, 0, 0, 0));
- }
- else
- {
- XTPDrawHelpers()->GradientFill(pDC, &rcEventFull, grclrBk, FALSE, &rcRect);
- }
- }
- void CXTPCalendarThemeOffice2007::CTOEvent::GetEventColors(CDC* pDC, CXTPCalendarViewEvent* pViewEvent,
- COLORREF& rClrBorder, COLORREF& rClrBorderNotSel, CXTPPaintManagerColorGradient& rGrclrBk,
- BOOL bSelected, int* pnColorsSrc_1Cat2Lbl)
- {
- rClrBorderNotSel = m_fcsetNormal.clrBorder;
- rClrBorder = m_fcsetNormal.clrBorder;
- rGrclrBk = m_fcsetNormal.grclrBackground;
- if (!pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- if (bSelected == -1)
- {
- bSelected = pViewEvent->IsSelected();
- }
- rClrBorder = bSelected ? m_fcsetSelected.clrBorder : m_fcsetNormal.clrBorder;
- rGrclrBk = bSelected ? m_fcsetSelected.grclrBackground : m_fcsetNormal.grclrBackground;
- CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
- CXTPCalendarEventCategoryIDs* pCategoryIDs = pEvent->GetCategories();
- CXTPCalendarEventLabel* ptrLabel = pEvent->GetLabel();
- if (pnColorsSrc_1Cat2Lbl)
- *pnColorsSrc_1Cat2Lbl = 0;
- if (pCategoryIDs && pCategoryIDs->GetSize())
- {
- UINT nCatID_0 = pCategoryIDs->GetAt(0);
- CXTPCalendarEventCategories* pCategories = pEvent->GetDataProvider()->GetEventCategories();
- if (pCategories)
- {
- CXTPCalendarEventCategory* pCat = pCategories->Find(nCatID_0);
- if (pCat)
- {
- rGrclrBk.SetCustomValue(pCat->GetBackgroundColor());
- if (XTPDrawHelpers()->IsLowResolution(pDC->GetSafeHdc()))
- rGrclrBk.SetCustomValue(pCat->GetBackgroundColor().clrDark);
- rClrBorderNotSel = pCat->GetBorderColor();
- if (!bSelected)
- rClrBorder = rClrBorderNotSel;
- if (pnColorsSrc_1Cat2Lbl)
- *pnColorsSrc_1Cat2Lbl = 1;
- }
- }
- }
- else if (ptrLabel && ptrLabel->m_nLabelID != XTP_CALENDAR_NONE_LABEL_ID)
- {
- COLORREF crBkLight = XTPDrawHelpers()->LightenColor(120, ptrLabel->m_clrColor);
- COLORREF crBkDark = XTPDrawHelpers()->DarkenColor(20, ptrLabel->m_clrColor);
- if (XTPDrawHelpers()->IsLowResolution(pDC->GetSafeHdc()))
- crBkLight = crBkDark = ptrLabel->m_clrColor;
- rGrclrBk.SetCustomValue(crBkLight, crBkDark);
- rClrBorderNotSel = XTPDrawHelpers()->DarkenColor(88, ptrLabel->m_clrColor);
- if (!bSelected)
- rClrBorder = rClrBorderNotSel;
- if (pnColorsSrc_1Cat2Lbl)
- *pnColorsSrc_1Cat2Lbl = 2;
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
- !pViewEvent->GetViewGroup() || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
- int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
- if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
- {
- return;// was drawn in the Master (or out of events rect)
- }
- CRect rcEvent(pViewEvent->GetEventRect());
- CRect rcTimeframe(pViewEvent->m_rcTimeframe);
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // ----- Fill event background -----
- int nTopRow = pViewEvent->GetViewGroup()->GetTopRow();
- CRect rcTopRow = pViewEvent->GetViewGroup()->GetCellRect(nTopRow);
- BOOL bShortEvent = rcTimeframe.Height() + 1 < rcTopRow.Height();
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
- // --- Calculate event rectangle ---
- CRect rcEventX(rcEvent);
- if (bShortEvent)
- {
- rcEventX.left += 5;
- }
- // ------ Draw Event Border ------
- pThemeX->DrawRoundRect(pDC, rcEventX, clrBorder, bSelected, grclrBk);
- // -------- Draw Event Contents --------
- CRect rcText(rcEventX);
- rcText.left += 2;
- int nSelOffset = bSelected ? 2 : 1;
- int nBusyStatus = pViewEvent->GetEvent()->GetBusyStatus();
- CBrush* pBSBrush = GetBusyStatusBrush(nBusyStatus);
- if (!bShortEvent)
- {
- if (pBSBrush)
- {
- CRect rcBS = rcEvent;
- rcBS.right = min(rcBS.left + 12, rcEvent.right);
- CXTPTextDC autoText(pDC, clrBorderNotSel, RGB(255, 255, 255));
- pThemeX->DrawRoundRect(pDC, rcBS, clrBorder, bSelected, pBSBrush);
- rcBS.right++;
- rcBS.left = min(rcBS.left + 5, rcBS.right);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, bSelected, grclrBk, CRect(0, 1, 0, 1));
- rcBS.right = rcBS.left + 1;
- pDC->FillSolidRect(&rcBS, clrBorder);
- rcText.left = rcEvent.left + 6;
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcText.left, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk);
- }
- else
- {
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
- }
- }
- else
- {
- CRect rcBS = rcEvent;
- rcBS.right = rcEventX.left + 6;
- CRect rcBSfull = rcBS;
- rcBS.bottom = rcTimeframe.bottom;
- // draw BK's
- if (pDC->IsPrinting())
- {
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, 0, FALSE, grclrBk, CRect(0, 0, 0, 0));
- }
- else
- {
- XTPDrawHelpers()->GradientFill(pDC, &rcBSfull, grclrBk, FALSE, &rcBS);
- }
- if (pBSBrush)
- {
- CRect rcBSfill = rcBS;
- rcBSfill.right = rcEventX.left;
- CXTPTextDC autoText(pDC, clrBorderNotSel, RGB(255, 255, 255));
- pDC->FillRect(&rcBSfill, pBSBrush);
- }
- // draw borders
- int nBorderWidth = bSelected ? 2 : 1;
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, nBorderWidth, CRect(1, 1, 0, 0));
- rcBS.right = rcEventX.left + 1;
- rcBS.top += nBorderWidth;
- if (pBSBrush)
- {
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorderNotSel, 1, CRect(0, 0, 1, 0));
- }
- rcBS.right += bSelected ? 1 : 0;
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, nBorderWidth, CRect(0, 0, 0, 1));
- rcText.left = rcEventX.left;
- if (pBSBrush)
- {
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEventX.left + 1, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk);
- }
- else
- {
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, 0, rcTimeframe.bottom - nSelOffset);
- }
- }
- // ----- Draw Grippers for selected events -----
- if (bSelected)
- {
- CBrush brBorder(m_clrGripperBorder);
- CRect rcGripper;
- rcGripper.left = rcEvent.left + rcEvent.Width() / 2 - cnGripperSize / 2;
- rcGripper.right = rcGripper.left + cnGripperSize;
- // draw top Gripper
- rcGripper.top = rcEvent.top - 1; //cnGripperSize / 2 + 1;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- pDC->FrameRect(&rcGripper, &brBorder);
- // draw bottom Gripper
- rcGripper.bottom = rcEvent.bottom + 1; //cnGripperSize / 2 - 1;
- rcGripper.top = rcGripper.bottom - cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- // ===== Process Markup Drawing =====
- rcText.DeflateRect(3, 3, 3, 3);
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- }
- }
- ///////////////////////////////
- // ----- Draw event Icons -----
- CRect rcIconsMax = rcText;
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() >= rcTopRow.Height())
- {
- rcIconsMax.bottom -= 4;
- }
- else
- {
- if (rcTopRow.Height() - 4 > szIcons.cy)
- {