XTPCalendarThemeOffice2007.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:211k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarThemeOffice2007.cpp : implementation file
  2. //
  3. // This file is a part of the XTREME CALENDAR MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Resource.h"
  22. #include "Common/XTPVC50Helpers.h"
  23. #include "Common/XTPVC80Helpers.h"
  24. #include "Common/XTPResourceManager.h"
  25. #include "Common/XTPOffice2007Image.h"
  26. #include "Common/XTPImageManager.h"
  27. #include "Common/XTPPropExchange.h"
  28. #include "Common/XTPMarkupRender.h"
  29. #include "XTPCalendarThemeOffice2007.h"
  30. #include "XTPCalendarPaintManager.h"
  31. #include "XTPCalendarControl.h"
  32. #include "XTPCalendarDayViewEvent.h"
  33. #include "XTPCalendarEvent.h"
  34. #include "XTPCalendarEventLabel.h"
  35. #include "XTPCalendarDayView.h"
  36. #include "XTPCalendarWeekView.h"
  37. #include "XTPCalendarMonthView.h"
  38. #include "XTPCalendarData.h"
  39. #include "XTPCalendarDayViewTimeScale.h"
  40. #ifdef _DEBUG
  41. #define new DEBUG_NEW
  42. #undef THIS_FILE
  43. static char THIS_FILE[] = __FILE__;
  44. #endif
  45. // DBG
  46. #define DBG_TRACE_PREVNEXTBTN
  47. //#define DBG_TRACE_PREVNEXTBTN  TRACE
  48. // DBG
  49. //===========================================================================
  50. //
  51. #define XTP_CALENDAR_OFFICE2007_BASE_BLUE   RGB(93, 140, 201) // default base color for a "blue" theme
  52. #define XTP_CALENDAR_OFFICE2007_BASE_GREEN  RGB(114, 164, 90) // default base color for a "green" theme
  53. #define XTP_CALENDAR_OFFICE2007_TODAYBORDER RGB(238, 147, 17)
  54. //===========================================================================
  55. // Should be a prime number:
  56. // 37, 53, 79 , 101, 127, 199, 503, 1021, 1511, 2003, 3001, 4001, 5003, 6007, 8009, 12007, 16001, 32003, 48017, 64007
  57. #define XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT 37
  58. #define XTP_CALCLR(clrName, nScale) GetColorsSetPart()->SetColor(xtpCLR_##clrName, _T(#clrName), nScale);
  59. static const double dXTPMaxAlpha2007 = 90.;
  60. const int CXTPCalendarThemeOffice2007::cnGripperSize = 5;
  61. const int CXTPCalendarThemeOffice2007::cnShadowWidth = 5;
  62. //////////////////////////////////////////////////////////////////////////
  63. //{{AFX_CODEJOCK_PRIVATE
  64. struct XTP_CALENDAR_EVENT_ICON_INFO
  65. {
  66. // common data
  67. RECT                 m_rcDestination;
  68. // image data
  69. CXTPOffice2007Image* m_pImage;
  70. RECT                 m_rcSrc;
  71. // icon data
  72. CXTPImageManagerIcon* m_pIcon;
  73. };
  74. //}}AFX_CODEJOCK_PRIVATE
  75. //{{AFX_CODEJOCK_PRIVATE
  76. class CXTPTextDC
  77. {
  78. public:
  79. CXTPTextDC(CDC* pDC, COLORREF clrText = COLORREF_NULL, COLORREF clrBk = COLORREF_NULL)
  80. {
  81. ASSERT(pDC);
  82. m_pDC = pDC;
  83. m_clrText_prev = COLORREF_NULL;
  84. m_clrBk_prev = COLORREF_NULL;
  85. SetColors(clrText, clrBk);
  86. }
  87. virtual ~CXTPTextDC()
  88. {
  89. SetColors(m_clrText_prev, m_clrBk_prev);
  90. }
  91. void SetColors(COLORREF clrText, COLORREF clrBk = COLORREF_NULL)
  92. {
  93. ASSERT(m_pDC);
  94. if (!m_pDC)
  95. return;
  96. if (clrText != COLORREF_NULL)
  97. {
  98. COLORREF clrText_prev = m_pDC->SetTextColor(clrText);
  99. if (m_clrText_prev == COLORREF_NULL)
  100. m_clrText_prev = clrText_prev;
  101. }
  102. if (clrBk != COLORREF_NULL)
  103. {
  104. COLORREF clrBk_prev = m_pDC->SetBkColor(clrBk);
  105. if (m_clrBk_prev == COLORREF_NULL)
  106. m_clrBk_prev = clrBk_prev;
  107. }
  108. }
  109. protected:
  110. CDC*     m_pDC;
  111. COLORREF m_clrText_prev;
  112. COLORREF m_clrBk_prev;
  113. };
  114. //}}AFX_CODEJOCK_PRIVATE
  115. //////////////////////////////////////////////////////////////////////////
  116. //class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
  117. //{{AFX_CODEJOCK_PRIVATE
  118. class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
  119. {
  120. public:
  121. CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder();
  122. virtual void BiuldEventPaces(CXTPCalendarDayViewGroup* pViewGroup);
  123. protected:
  124. class CViewEventsMap : public CMap<CXTPCalendarDayViewEvent*, CXTPCalendarDayViewEvent*, int, int>
  125. {
  126. public:
  127. CViewEventsMap();
  128. int GetMinFreeEventPlace();
  129. int GetMaxEventPlace();
  130. int GetMaxEventPlaceCountEx();
  131. };
  132. virtual void _Clear();
  133. virtual void _UpdateDataFor(CXTPCalendarDayViewEvent* pViewEvent, CXTPCalendarDayViewGroup* pViewGroup);
  134. virtual void _UpdateEventsPaces(CXTPCalendarDayViewGroup* pViewGroup);
  135. //CXTPCalendarTypedPtrAutoDeleteMap<CXTPCalendarDayViewEvent*, CViewEventsMap*> m_mapEvToOverlapped;
  136. // to avoid warning C4786 CObject* used.
  137. CXTPCalendarTypedPtrAutoDeleteMap<CXTPCalendarDayViewEvent*, CObject*> m_mapEvToOverlapped;
  138. COleDateTimeSpan m_spCellDuration;
  139. COleDateTime     m_dtMinStartTime;
  140. protected:
  141. virtual CViewEventsMap* _XGetDataFor(CXTPCalendarDayViewEvent* pViewEvent);
  142. virtual void _XAddOverlapped(CXTPCalendarDayViewEvent* pVEv_base, CXTPCalendarDayViewEvent* pVEv_overlapped);
  143. };
  144. //}}AFX_CODEJOCK_PRIVATE
  145. //////////////////////////////////////////////////////////////////////////
  146. BEGIN_MESSAGE_MAP(CXTPCalendarViewEventSubjectEditor2007, CXTPCalendarViewEventSubjectEditor)
  147. ON_WM_ERASEBKGND()
  148. ON_WM_CTLCOLOR_REFLECT()
  149. ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
  150. END_MESSAGE_MAP()
  151. CXTPCalendarViewEventSubjectEditor2007::CXTPCalendarViewEventSubjectEditor2007(CXTPCalendarControl* pOwner,
  152. CXTPCalendarViewEvent* pViewEvent, CXTPCalendarThemeOffice2007* pTheme2007) :
  153. CXTPCalendarViewEventSubjectEditor(pOwner)
  154. {
  155. ASSERT(pViewEvent);
  156. ASSERT(pTheme2007);
  157. m_pViewEvent = pViewEvent;
  158. m_pTheme2007 = pTheme2007;
  159. if (!pViewEvent || !pTheme2007)
  160. {
  161. return;
  162. }
  163. CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = m_pTheme2007->GetThemePartForEvent(m_pViewEvent);
  164. ASSERT(pEventPart);
  165. if (pEventPart)
  166. {
  167. COLORREF clrBorderNotSel;
  168. COLORREF clrBorder;
  169. pEventPart->GetEventColors(NULL, pViewEvent, clrBorder, clrBorderNotSel, m_grclrBk, FALSE);
  170. if (m_grclrBk.IsNull())
  171. {
  172. m_grclrBk.SetStandardValue(RGB(255,255,255));
  173. }
  174. }
  175. }
  176. CXTPCalendarViewEventSubjectEditor2007::~CXTPCalendarViewEventSubjectEditor2007()
  177. {
  178. }
  179. BOOL CXTPCalendarViewEventSubjectEditor2007::OnEraseBkgnd(CDC* pDC)
  180. {
  181. UNUSED_ALWAYS(pDC);
  182. if (!m_pViewEvent || !m_pOwner)
  183. {
  184. ASSERT(FALSE);
  185. return FALSE;
  186. }
  187. CRect rcEvent = m_pViewEvent->GetEventRect();
  188. m_pOwner->ClientToScreen(&rcEvent);
  189. ScreenToClient(&rcEvent);
  190. CXTPClientRect rcClient(this);
  191. XTPDrawHelpers()->GradientFill(pDC, &rcEvent, m_grclrBk, FALSE, &rcClient);
  192. return TRUE;
  193. }
  194. HBRUSH CXTPCalendarViewEventSubjectEditor2007::CtlColor(CDC* pDC, UINT nCtlColor)
  195. {
  196. ASSERT(nCtlColor == CTLCOLOR_EDIT);
  197. UNREFERENCED_PARAMETER(nCtlColor);
  198. static CBrush s_null_brush;
  199. if (s_null_brush.m_hObject == NULL)
  200. {
  201. s_null_brush.CreateStockObject(NULL_BRUSH);
  202. }
  203. pDC->SetBkMode(TRANSPARENT);
  204. DWORD dwStyle = GetStyle();
  205. BOOL bMultiLine = (dwStyle & ES_MULTILINE) != 0;
  206. return bMultiLine ? (HBRUSH)s_null_brush : (HBRUSH)NULL;
  207. }
  208. void CXTPCalendarViewEventSubjectEditor2007::OnChange()
  209. {
  210. Invalidate();
  211. }
  212. /////////////////////////////////////////////////////////////////////////////
  213. IMPLEMENT_DYNCREATE(CXTPCalendarThemeOffice2007, CXTPCalendarTheme)
  214. ////////////////////////////////////////////////////////////////////////
  215. CSize CXTPCalendarThemeOffice2007::DrawText_Auto2SL3ML(CDC* pDC,
  216. LPCTSTR pcszText1, LPCTSTR pcszText2, LPCTSTR pcszText3,
  217. CThemeFontColorSet* pFontColor1, CThemeFontColorSet* pFontColor2,
  218. CThemeFontColorSet* pFontColor3,
  219. CRect& rcRect, LPCTSTR pcszText1Separator, UINT uWordBreakMode)
  220. {
  221. CXTPFontDC autoFont(pDC, pFontColor2->Font());
  222. CSize sz2 = pDC->GetTextExtent(pcszText2);
  223. autoFont.SetFont(pFontColor1->Font());
  224. CSize sz1 = pDC->GetTextExtent(pcszText1);
  225. if ((sz1.cy + sz2.cy) > rcRect.Height())
  226. {
  227. CString strText1 = pcszText1;
  228. if (_tcslen(pcszText2) > 0)
  229. {
  230. strText1 += pcszText1Separator;
  231. }
  232. return DrawLine2_CenterLR(pDC, strText1, pcszText2, pFontColor1,
  233.  pFontColor2, rcRect, DT_VCENTER | DT_LEFT,
  234.  DT_VCENTER | DT_LEFT);
  235. }
  236. //=======================================================================
  237. UINT uFormat = DT_NOPREFIX | DT_LEFT | DT_TOP | DT_EDITCONTROL | uWordBreakMode;
  238. int nYspace = sz2.cy/4;
  239. int nHeight1 = 0, nHeight2 = 0, nHeight3 = 0;
  240. //--------------------
  241. autoFont.SetColor(pFontColor1->Color());
  242. CRect rcText1 = rcRect;
  243. nHeight1 = pDC->DrawText(pcszText1, &rcText1, uFormat);
  244. //--------------------
  245. CRect rcText2 = rcRect;
  246. rcText2.top = min(rcRect.top + nHeight1 + nYspace, rcRect.bottom);
  247. if (sz2.cy < rcText2.Height() && _tcslen(pcszText2))
  248. {
  249. autoFont.SetFontColor(pFontColor2->Font(), pFontColor2->Color());
  250. nHeight2 = pDC->DrawText(pcszText2, &rcText2, uFormat);
  251. }
  252. int nTLen3 = (int)_tcslen(pcszText3);
  253. if (pcszText3 && nTLen3)
  254. {
  255. autoFont.SetFontColor(pFontColor3->Font(), pFontColor3->Color());
  256. CRect rcText3 = rcRect;
  257. rcText3.top = min(rcText2.top + nHeight2 + nYspace, rcRect.bottom);
  258. if (sz2.cy < rcText3.Height())
  259. {
  260. nHeight3 = pDC->DrawText(pcszText3, &rcText3, uFormat);
  261. }
  262. }
  263. //--------------------
  264. return CSize(rcRect.Width(), nHeight1 + nHeight2 + nHeight3 + 2 * nYspace);
  265. }
  266. COLORREF AFX_CDECL CXTPCalendarThemeOffice2007::PowerColor(COLORREF clrBase, double dFactor, double dPower)
  267. {
  268. BYTE bR = (BYTE)max(0, min(255, (int)GetRValue(clrBase) + (int)(pow((double)GetRValue(clrBase), dPower) * dFactor)) );
  269. BYTE bG = (BYTE)max(0, min(255, (int)GetGValue(clrBase) + (int)(pow((double)GetGValue(clrBase), dPower) * dFactor)) );
  270. BYTE bB = (BYTE)max(0, min(255, (int)GetBValue(clrBase) + (int)(pow((double)GetBValue(clrBase), dPower) * dFactor)) );
  271. return RGB(bR, bG, bB);
  272. }
  273. /////////////////////////////////////////////////////////////////////////////
  274. CXTPCalendarThemeOffice2007::CXTPCalendarThemeOffice2007()
  275. {
  276. m_nPaintTheme = xtpCalendarThemeOffice2007;
  277. Init();
  278. RefreshMetrics();
  279. }
  280. CXTPCalendarThemeOffice2007::~CXTPCalendarThemeOffice2007()
  281. {
  282. m_Sink.UnadviseAll();
  283. if (m_pCalendar)
  284. OnDetachCalendar();
  285. }
  286. CXTPCalendarViewEventSubjectEditor* CXTPCalendarThemeOffice2007::StartEditSubject(CXTPCalendarViewEvent* pViewEvent)
  287. {
  288. if (!pViewEvent || !pViewEvent->GetCalendarControl())
  289. {
  290. ASSERT(FALSE);
  291. return NULL;
  292. }
  293. CXTPCalendarViewEventSubjectEditor2007* pSE;
  294. pSE = new CXTPCalendarViewEventSubjectEditor2007(pViewEvent->GetCalendarControl(),
  295.  pViewEvent, this);
  296. if (!pSE)
  297. {
  298. return NULL;
  299. }
  300. DWORD dwEditStyles = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_MULTILINE;
  301. if (pViewEvent->IsMultidayEvent())
  302. {
  303. dwEditStyles |= ES_AUTOHSCROLL /*| ES_CENTER*/;
  304. }
  305. else
  306. {
  307. dwEditStyles |= ES_AUTOVSCROLL | ES_MULTILINE;
  308. }
  309. CRect rcEditor = pViewEvent->GetSubjectEditorRect();
  310. pSE->Create(dwEditStyles, rcEditor, pViewEvent->GetCalendarControl(), 0);
  311. pSE->SetFocus();
  312. CFont* pEditorFont = NULL;
  313. CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = GetThemePartForEvent(pViewEvent);
  314. ASSERT(pEventPart);
  315. if (pEventPart)
  316. {
  317. pEditorFont = pEventPart->m_fcsetNormal.fcsetSubject.Font();
  318. }
  319. ASSERT(pEditorFont);
  320. if (pEditorFont)
  321. {
  322. pSE->SetFont(pEditorFont);
  323. }
  324. pSE->SetWindowText(XTP_SAFE_GET2(pViewEvent, GetEvent(), GetSubject(), _T("")));
  325. pSE->SetSel(0, 0);
  326. return pSE;
  327. }
  328. CXTPCalendarThemeOffice2007::CTOEvent* CXTPCalendarThemeOffice2007::GetThemePartForEvent(CXTPCalendarViewEvent* pViewEvent)
  329. {
  330. if (!pViewEvent)
  331. {
  332. ASSERT(FALSE);
  333. return NULL;
  334. }
  335. CXTPCalendarThemeOffice2007::CTOEvent* pEventPart = NULL;
  336. CXTPCalendarDayViewEvent* pVEDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pViewEvent);
  337. CXTPCalendarWeekViewEvent* pVEWeek= DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pViewEvent);
  338. CXTPCalendarMonthViewEvent* pVEMonth = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pViewEvent);
  339. if (pVEDay)
  340. {
  341. if (pViewEvent->IsMultidayEvent())
  342. {
  343. pEventPart = GetDayViewPartX()->GetDayPartX()->GetGroupPartX()->GetMultiDayEventPartX();
  344. }
  345. else
  346. {
  347. pEventPart = GetDayViewPartX()->GetDayPartX()->GetGroupPartX()->GetSingleDayEventPartX();
  348. }
  349. }
  350. else if (pVEWeek)
  351. {
  352. if (pViewEvent->IsMultidayEvent())
  353. {
  354. pEventPart = GetWeekViewPartX()->GetDayPartX()->GetMultiDayEventPartX();
  355. }
  356. else
  357. {
  358. pEventPart = GetWeekViewPartX()->GetDayPartX()->GetSingleDayEventPartX();
  359. }
  360. }
  361. else if (pVEMonth)
  362. {
  363. if (pViewEvent->IsMultidayEvent())
  364. {
  365. pEventPart = GetMonthViewPartX()->GetDayPartX()->GetMultiDayEventPartX();
  366. }
  367. else
  368. {
  369. pEventPart = GetMonthViewPartX()->GetDayPartX()->GetSingleDayEventPartX();
  370. }
  371. }
  372. else
  373. {
  374. ASSERT(FALSE);
  375. }
  376. return pEventPart;
  377. }
  378. void CXTPCalendarThemeOffice2007::GetItemTextIfNeed(int nItem, CString* pstrText,
  379. CXTPCalendarViewDay* pViewDay)
  380. {
  381. if (!pstrText || !pViewDay)
  382. {
  383. ASSERT(FALSE);
  384. return;
  385. }
  386. DWORD dwFlags = GetAskItemTextFlags();
  387. if (dwFlags & nItem)
  388. {
  389. XTP_CALENDAR_GETITEMTEXT_PARAMS objRequest;
  390. ::ZeroMemory(&objRequest, sizeof(objRequest));
  391. objRequest.nItem = nItem;
  392. objRequest.pstrText = pstrText;
  393. objRequest.pViewDay = pViewDay;
  394. SendNotificationAlways(XTP_NC_CALENDAR_GETITEMTEXT, (WPARAM)&objRequest, 0);
  395. }
  396. }
  397. void CXTPCalendarThemeOffice2007::SetCalendarControl(CXTPCalendarControl* pCalendar) 
  398. {
  399. m_Sink.UnadviseAll();
  400. CXTPCalendarTheme::SetCalendarControl(pCalendar);
  401. if (pCalendar && XTPOffice2007Images() && XTPOffice2007Images()->GetConnection())
  402. {
  403. m_Sink.Advise(XTPOffice2007Images()->GetConnection(), XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED,
  404.    &CXTPCalendarThemeOffice2007::OnEvent_Office2007ImagesChanged);
  405. }
  406. }
  407. void CXTPCalendarThemeOffice2007::OnEvent_Office2007ImagesChanged(XTP_NOTIFY_CODE Event, WPARAM wParam, LPARAM lParam)
  408. {
  409. UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam);
  410. ASSERT(Event == XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED);
  411. if (Event == XTP_NC_COMMON_OFFICE2007IMAGES_CHANGED)
  412. {
  413. RefreshMetrics();
  414. if (GetCalendarControl())
  415. GetCalendarControl()->RedrawControl();
  416. }
  417. }
  418. void CXTPCalendarThemeOffice2007::RefreshMetrics(BOOL bRefreshChildren)
  419. {
  420. CXTPCalendarTheme::RefreshMetrics(FALSE);
  421. m_clrBaseColor.SetStandardValue(GetColor2(_T("BaseColor"), XTP_CALENDAR_OFFICE2007_BASE_BLUE));
  422. //m_clrBaseColor.SetStandardValue(XTP_CALENDAR_OFFICE2007_BASE_GREEN);
  423. // Try to set default Office 2007 font,
  424. // otherwise icon font used.
  425. BOOL bFontExists = XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME);
  426. if (bFontExists)
  427. {
  428. LOGFONT lfBaseFont;
  429. ::ZeroMemory(&lfBaseFont, sizeof(lfBaseFont));
  430. STRCPY_S(lfBaseFont.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
  431. lfBaseFont.lfCharSet = DEFAULT_CHARSET;
  432. lfBaseFont.lfHeight = -11;
  433. lfBaseFont.lfWeight = FW_NORMAL;
  434. if (XTPSystemVersion()->IsClearTypeTextQualitySupported())
  435. lfBaseFont.lfQuality = 5;
  436. m_fntBaseFont.SetStandardValue(&lfBaseFont);
  437. LOGFONT lfBaseFontBold = lfBaseFont;
  438. lfBaseFontBold.lfWeight = FW_BOLD;
  439. m_fntBaseFontBold.SetStandardValue(&lfBaseFontBold);
  440. }
  441. if (!GetColorsSetPart() || !m_pImagesStd || !m_pImageList)
  442. {
  443. return;
  444. }
  445. /*
  446. rgb (HSL)
  447. Blue                                  Silver                                Green
  448. 141,174, 217 (142, 118, 168)  *  30   176, 182, 190 (142, 22, 172)  *   27  156, 191, 139 (66, 68, 155)  *   36
  449. DayBorder   93, 140, 201 (142, 118, 138) -30 *    145, 153, 164 (142, 21, 145) -27  *   114, 164, 90  (66, 68, 119) -36  *
  450. 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
  451. 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
  452. ADEventsBk  165, 191, 225(142, 117, 183)      45  199,203, 209  (143, 22, 192)      47  177, 205, 164 (66, 68, 174)
  453. */  //-- set dynamic colors -------------------------
  454.  // selected cell for blue, green
  455. // 41, 76, 122  {93, 140, 201}
  456. // 63, 91, 50 [114, 164, 90]  114
  457. GetColorsSetPart()->SetCLR_DarkenOffset(xtpCLR_DarkenOffset);
  458. //GetColorsSetPart()->SetColor(xtpCLR_
  459. XTP_CALCLR(SelectedBk, 114); // 51, 77, 111
  460. XTP_CALCLR(HeaderBorder, 76); // 141, 174, 217
  461. // Day View colors
  462. XTP_CALCLR(DayBorder,                      0);   // 93, 140, 201
  463. XTP_CALCLR(DayViewCellWorkBk,              255); // 255, 255, 255
  464. XTP_CALCLR(DayViewCellNonWorkBk,           216); // 230, 237, 247
  465. XTP_CALCLR(DayViewCellWorkBorderBottomInHour, 216); // 230, 237, 247
  466. XTP_CALCLR(DayViewCellWorkBorderBottomHour,   113); // 165, 191, 225
  467. XTP_CALCLR(DayViewCellNonWorkBorderBottomInHour, 189); // 213, 225, 241
  468. XTP_CALCLR(DayViewCellNonWorkBorderBottomHour,   113); // 165, 191, 225
  469. XTP_CALCLR(DayViewAllDayEventsBk,                113); // 165, 191, 225
  470. //GetColorsSetPart()->SetColorHSL(xtpCLR_DayViewAllDayEventsBk,                113); // 165, 191, 225
  471. XTP_CALCLR(DayViewAllDayEventsBorderBottom,      0);   // 93, 140, 201
  472. XTP_CALCLR(MultiDayEventBorder,         0);   // 93, 140, 201
  473. XTP_CALCLR(MultiDayEventSelectedBorder, 255); // 0, 0, 0
  474. XTP_CALCLR(MultiDayEventBkGRfrom,       249); // 251, 252, 254  multi-day event gradient fill Light
  475. XTP_CALCLR(MultiDayEventBkGRto,         161); // 195, 213, 235 multi-day event gradient fill Dark
  476. XTP_CALCLR(MultiDayEventFromToDates,     38); // 117, 157, 209
  477. XTP_CALCLR(DayViewSingleDayEventBorder,          0);   // 93, 140, 201
  478. XTP_CALCLR(DayViewSingleDayEventSelectedBorder,  255); // 0, 0, 0
  479. XTP_CALCLR(DayViewSingleDayEventBkGRfrom,        255); // 255, 255, 255 // single-day event gradient fill Light
  480. XTP_CALCLR(DayViewSingleDayEventBkGRto,          155); // 191, 210, 234 // single-day event gradient fill Dark
  481. // Month view colors
  482. XTP_CALCLR(MonthViewDayBkLight,    255); // 255, 255, 255
  483. XTP_CALCLR(MonthViewDayBkDark,     113); // 165, 191, 225
  484. XTP_CALCLR(MonthViewDayBkSelected, 216); // 230, 237, 247
  485. XTP_CALCLR(MonthViewEventTime,  38);
  486. XTP_CALCLR(MonthViewSingleDayEventBorder,          217); // 230, 238, 247
  487. XTP_CALCLR(MonthViewSingleDayEventSelectedBorder,  255); // 0, 0, 0
  488. XTP_CALCLR(MonthViewSingleDayEventBkGRfrom,        250); // 252, 253, 254
  489. XTP_CALCLR(MonthViewSingleDayEventBkGRto,          181); // 208, 222, 240
  490. // Week view colors are same as month view by default
  491. XTP_CALCLR(WeekViewDayBkLight,    255); // 255, 255, 255
  492. XTP_CALCLR(WeekViewDayBkDark,     113); // 165, 191, 225
  493. XTP_CALCLR(WeekViewDayBkSelected, 216); // 230, 237, 247
  494. XTP_CALCLR(WeekViewEventTime,  114); // 51, 77, 111
  495. XTP_CALCLR(WeekViewSingleDayEventBorder,          217); // 230, 238, 247
  496. XTP_CALCLR(WeekViewSingleDayEventSelectedBorder,  255); // 0, 0, 0
  497. XTP_CALCLR(WeekViewSingleDayEventBkGRfrom,        250); // 252, 253, 254
  498. XTP_CALCLR(WeekViewSingleDayEventBkGRto,          181); // 208, 222, 240
  499. //----------------------------------------------------------------------
  500. if (m_pImagesStd)
  501. {
  502. VERIFY( m_pImagesStd->InitResourceHandle(_T("Office2007_CalendarHeader_bmp"), _T("PNG")));
  503. }
  504. //-----------------------------------------------------------------------
  505. _LoadStdBitmap(xtpIMG_DayViewHeader,        _T("CalendarHeader"));
  506. _LoadStdBitmap(xtpIMG_DayViewHeaderTooday,  _T("CalendarTodayHeader"));
  507. _LoadStdBitmap(xtpIMG_DayViewGroupHeader,   _T("CalendarHeaderDVGroup"));
  508. _LoadStdBitmap(xtpIMG_MonthViewDayHeader,       _T("CalendarHeaderMVDay"));
  509. _LoadStdBitmap(xtpIMG_MonthViewDayHeaderToday,  _T("CalendarTodayHeaderMVDay"));
  510. //_LoadStdBitmap(xtpIMG_MonthViewWeekDayHeader,   _T("CalendarHeaderMVWeekDay"));
  511. _LoadStdBitmap(xtpIMG_MonthViewWeekHeader,      _T("CalendarHeaderMVWeek"));
  512. _LoadStdBitmap(xtpIMG_WeekViewDayHeader,        _T("CalendarHeaderWVDay"));
  513. _LoadStdBitmap(xtpIMG_ExpandDayButtons,         _T("CalendarExpandDay"));
  514. _LoadStdBitmap(xtpIMG_PrevNextEventButtons,   _T("CalendarPrevNextEventButton"));
  515. //-----------------------------------------------------------------------
  516. if (bRefreshChildren)
  517. {
  518. CXTPCalendarThemePart::RefreshMetrics();
  519. }
  520. }
  521. BOOL CXTPCalendarThemeOffice2007::IsBaseColorOrig()
  522. {
  523. return !m_clrBaseColor.IsCustomValue() ||
  524. m_clrBaseColor.GetStandardColor() == (COLORREF)m_clrBaseColor;
  525. }
  526. COLORREF CXTPCalendarThemeOffice2007::GetColor(int eCLR, COLORREF clrBaseColor)
  527. {
  528. COLORREF clrColor = COLORREF_NULL;
  529. if (XTPOffice2007Images()->IsValid() && IsBaseColorOrig())
  530. {
  531. CString strColorName = GetColorsSetPart()->GetName(eCLR);
  532. clrColor = XTPOffice2007Images()->GetImageColor(_T("CalendarControl"), strColorName);
  533. }
  534. if (clrColor == COLORREF_NULL)
  535. {
  536. clrColor = GetColorsSetPart()->GetColor(eCLR, clrBaseColor);
  537. }
  538. return clrColor;
  539. }
  540. COLORREF CXTPCalendarThemeOffice2007::GetColor2(LPCTSTR pcszColorName, COLORREF clrDefault)
  541. {
  542. COLORREF clrColor = COLORREF_NULL;
  543. if (XTPOffice2007Images()->IsValid())
  544. {
  545. clrColor = XTPOffice2007Images()->GetImageColor(_T("CalendarControl"), pcszColorName);
  546. }
  547. if (clrColor == COLORREF_NULL)
  548. {
  549. clrColor = clrDefault;
  550. }
  551. return clrColor;
  552. }
  553. CXTPOffice2007Image* CXTPCalendarThemeOffice2007::GetBitmap(LPCTSTR pcszStdBmpName)
  554. {
  555. if (!m_pImagesStd || !m_pImageList || !pcszStdBmpName)
  556. {
  557. ASSERT(FALSE);
  558. return NULL;
  559. }
  560. CXTPOffice2007Image* pBmp = NULL;
  561. if (XTPOffice2007Images()->IsValid() && IsBaseColorOrig())
  562. {
  563. pBmp = XTPOffice2007Images()->LoadFile(pcszStdBmpName);
  564. }
  565. if (!pBmp)
  566. {
  567. CString strName;
  568. strName.Format(_T("Office2007_%s_BMP"), pcszStdBmpName);
  569. pBmp = m_pImagesStd->LoadFile(strName);
  570. }
  571. if (!pBmp && !IsBaseColorOrig() && XTPOffice2007Images()->IsValid())
  572. {
  573. pBmp = XTPOffice2007Images()->LoadFile(pcszStdBmpName);
  574. }
  575. return pBmp;
  576. }
  577. int CXTPCalendarThemeOffice2007::CTODay::HitTestExpandDayButton(CXTPCalendarViewDay* pViewDay, const CPoint* pPoint)
  578. {
  579. if (!pViewDay || !GetTheme() || !GetTheme()->GetCalendarControl())
  580. {
  581. ASSERT(FALSE);
  582. return 0;
  583. }
  584. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
  585. CRect rc = dayLayout.m_rcDay;
  586. rc.right -= 5;
  587. rc.bottom -= 5;
  588. return _HitTestExpandDayButton(pViewDay, rc, pPoint);
  589. }
  590. void CXTPCalendarThemeOffice2007::CTODayViewHeader::RefreshMetrics(BOOL bRefreshChildren)
  591. {
  592. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  593. ASSERT(pThemeX);
  594. if (!pThemeX)
  595. {
  596. return;
  597. }
  598. TBase::RefreshMetrics(bRefreshChildren);
  599. RefreshFromParent(pThemeX->GetHeaderPartX());
  600. }
  601. void CXTPCalendarThemeOffice2007::CTODayView::RefreshMetrics(BOOL bRefreshChildren)
  602. {
  603. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  604. ASSERT(pThemeX);
  605. if (!pThemeX)
  606. {
  607. return;
  608. }
  609. TBase::RefreshMetrics(bRefreshChildren);
  610. if (pThemeX->GetPrevNextEventControllerPartX())
  611. pThemeX->GetPrevNextEventControllerPartX()->RefreshMetrics(bRefreshChildren);
  612. }
  613. void CXTPCalendarThemeOffice2007::CTODayView::AdjustLayout(CDC* pDC, const CRect& rcRect)
  614. {
  615. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  616. ASSERT(pThemeX);
  617. if (!pThemeX)
  618. {
  619. return;
  620. }
  621. TBase::AdjustLayout(pDC, rcRect);
  622. CRect rcRect2 = rcRect;
  623. rcRect2.left = XTP_SAFE_GET3(pThemeX->GetCalendarControl(), GetDayView(), GetViewDay_(0),
  624. GetDayRect().left, rcRect.left);
  625. if (pThemeX->GetPrevNextEventControllerPartX())
  626. pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRect2);
  627. }
  628. void CXTPCalendarThemeOffice2007::CTODayView::Draw(CDC* pDC)
  629. {
  630. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  631. ASSERT(pThemeX);
  632. if (!pThemeX)
  633. {
  634. return;
  635. }
  636. TBase::Draw(pDC);
  637. if (pThemeX->GetPrevNextEventControllerPartX())
  638. pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
  639. };
  640. int CXTPCalendarThemeOffice2007::CTODayViewTimeScale::CalcMinRowHeight(CDC* pDC, CXTPCalendarDayViewTimeScale* pTimeScale)
  641. {
  642. if (!pDC || !pTimeScale)
  643. {
  644. ASSERT(FALSE);
  645. return 0;
  646. }
  647. int nHeight = TBase::CalcMinRowHeight(pDC, pTimeScale);
  648. if (GETTOTAL_MINUTES_DTS(pTimeScale->GetScaleInterval()) % 60 == 0 && nHeight > 0)
  649. {
  650. nHeight -= 1;
  651. }
  652. return nHeight;
  653. }
  654. void CXTPCalendarThemeOffice2007::CTODayViewTimeScale::RefreshMetrics(BOOL)
  655. {
  656. ASSERT(GetTheme());
  657. if (!GetTheme())
  658. {
  659. return;
  660. }
  661. TBase::RefreshMetrics();
  662. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(18, 13, 5));
  663. m_hflaBigHourFont.SetStandardValue(1, 1, -1);
  664. //-----------------------------
  665. m_clrBackground.SetStandardValue(GetTheme()->GetColor2(_T("TimeScaleBk"), RGB(227, 239, 255)));
  666. m_clrLine.SetStandardValue(GetTheme()->GetColor2(_T("TimeScaleLine"), RGB(101, 147, 207)));
  667. COLORREF clrText = m_clrLine.GetStandardColor(); //RGB(101, 147, 207);
  668. m_fcsetCaption.clrColor.SetStandardValue(clrText);
  669. CopySettings(m_fcsetAMPM.clrColor, clrText);
  670. CopySettings(m_fcsetSmall.clrColor, clrText);
  671. CopySettings(m_fcsetBigBase.clrColor, clrText);
  672. CopySettings(m_fcsetBigHour_.clrColor, m_fcsetBigBase.clrColor);
  673. //-----------------------
  674. if (IsXPTheme())
  675. {
  676. m_grclrNowLineBk.SetStandardValue(m_clrBackground, RGB(247, 202, 95));
  677. m_clrNowLine.SetStandardValue(RGB(187, 85, 3));
  678. }
  679. else
  680. {
  681. m_grclrNowLineBk.SetStandardValue(m_clrBackground);
  682. m_clrNowLine.SetStandardValue(::GetSysColor(COLOR_HIGHLIGHT));
  683. }
  684. }
  685. void CXTPCalendarThemeOffice2007::CTODayViewDay::RefreshMetrics(BOOL bRefreshChildren)
  686. {
  687. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  688. ASSERT(pThemeX);
  689. if (!pThemeX)
  690. {
  691. return;
  692. }
  693. m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
  694. //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
  695. TBase::RefreshMetrics(bRefreshChildren);
  696. m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
  697. }
  698. void CXTPCalendarThemeOffice2007::CTODayViewDay::DoPropExchange(CXTPPropExchange* pPX)
  699. {
  700. ASSERT(pPX);
  701. if (!pPX)
  702. return;
  703. CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewDay")));
  704. if (pPX->IsStoring())
  705. secData->EmptySection();
  706. PX_Color(&secData, _T("BorderColor"), m_clrBorder);
  707. PX_Color(&secData, _T("TodayBorderColor"), m_clrTodayBorder);
  708. TBase::DoPropExchange(&secData);
  709. }
  710. void CXTPCalendarThemeOffice2007::CTODayViewDay::Serialize(CArchive& ar)
  711. {
  712. m_clrBorder.Serialize(ar);
  713. m_clrTodayBorder.Serialize(ar);
  714. TBase::Serialize(ar);
  715. }
  716. void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
  717. {
  718. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  719. ASSERT(pThemeX);
  720. if (!pThemeX)
  721. {
  722. return;
  723. }
  724. TBase::RefreshMetrics(bRefreshChildren);
  725. RefreshFromParent(pThemeX->GetDayViewPartX()->GetHeaderPartX());
  726. //  m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
  727. m_UseOffice2003HeaderFormat.SetStandardValue(FALSE);
  728. }
  729. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupHeader::RefreshMetrics(BOOL bRefreshChildren)
  730. {
  731. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  732. ASSERT(pThemeX);
  733. if (!pThemeX)
  734. {
  735. return;
  736. }
  737. TBase::RefreshMetrics(bRefreshChildren);
  738. RefreshFromParent(pThemeX->GetDayViewPartX()->GetDayPartX()->GetHeaderPartX());
  739. m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
  740. m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
  741. m_bkToday.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
  742. m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_DayViewGroupHeader);
  743. }
  744. void CXTPCalendarThemeOffice2007::CTOHeader::RefreshMetrics(BOOL bRefreshChildren)
  745. {
  746. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  747. ASSERT(pThemeX);
  748. if (!pThemeX)
  749. {
  750. return;
  751. }
  752. TBase::RefreshMetrics(bRefreshChildren);
  753. m_clrBaseColor.SetStandardValue(pThemeX->m_clrBaseColor);
  754. m_clrTodayBaseColor.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
  755. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
  756. }
  757. void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::RefreshMetrics(BOOL bRefreshChildren)
  758. {
  759. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  760. ASSERT(pThemeX);
  761. if (!pThemeX)
  762. {
  763. return;
  764. }
  765. m_clrBorderLeft.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
  766. TBase::RefreshMetrics(bRefreshChildren);
  767. }
  768. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupCell::RefreshMetrics(BOOL bRefreshChildren)
  769. {
  770. UNREFERENCED_PARAMETER(bRefreshChildren);
  771. //TBase::RefreshMetrics(); // has no children
  772. m_clrsetWorkCell.clrBackground.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBk));
  773. m_clrsetWorkCell.clrBorderBottomInHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBorderBottomInHour));
  774. m_clrsetWorkCell.clrBorderBottomHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellWorkBorderBottomHour));
  775. m_clrsetWorkCell.clrSelected.SetStandardValue(GetTheme()->GetColor(xtpCLR_SelectedBk));
  776. m_clrsetNonWorkCell.clrBackground.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBk));
  777. m_clrsetNonWorkCell.clrBorderBottomInHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBorderBottomInHour));
  778. m_clrsetNonWorkCell.clrBorderBottomHour.SetStandardValue(GetTheme()->GetColor(xtpCLR_DayViewCellNonWorkBorderBottomHour));
  779. m_clrsetNonWorkCell.clrSelected.SetStandardValue(GetTheme()->GetColor(xtpCLR_SelectedBk));
  780. }
  781. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::RefreshMetrics(BOOL bRefreshChildren)
  782. {
  783. UNREFERENCED_PARAMETER(bRefreshChildren);
  784. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  785. ASSERT(pThemeX);
  786. if (!pThemeX)
  787. {
  788. return;
  789. }
  790. //TBase::RefreshMetrics(); // has no children
  791. m_clrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewAllDayEventsBk));
  792. m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_SelectedBk));
  793. m_clrBottomBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewAllDayEventsBorderBottom));
  794. }
  795. /////////////////////////////////////////////////////////////////////////////
  796. void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::CopySettings(
  797. const CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet& rSrc)
  798. {
  799. CXTPCalendarTheme::CopySettings(clrBorder, rSrc.clrBorder);
  800. CXTPCalendarTheme::CopySettings(grclrBackground, rSrc.grclrBackground);
  801. fcsetSubject.CopySettings(rSrc.fcsetSubject);
  802. fcsetLocation.CopySettings(rSrc.fcsetLocation);
  803. fcsetBody.CopySettings(rSrc.fcsetBody);
  804. fcsetStartEnd.CopySettings(rSrc.fcsetStartEnd);
  805. }
  806. void CXTPCalendarThemeOffice2007::CTOEvent::RefreshFromParent(CTOEvent* pParentSrc)
  807. {
  808. ASSERT(pParentSrc);
  809. if (!pParentSrc)
  810. {
  811. return;
  812. }
  813. m_fcsetNormal.CopySettings(pParentSrc->m_fcsetNormal);
  814. m_fcsetSelected.CopySettings(pParentSrc->m_fcsetSelected);
  815. CXTPCalendarTheme::CopySettings(m_clrGripperBorder, pParentSrc->m_clrGripperBorder);
  816. CXTPCalendarTheme::CopySettings(m_clrGripperBackground, pParentSrc->m_clrGripperBackground);
  817. if (pParentSrc->GetHeightFormulaPart())
  818. XTP_SAFE_CALL1(GetHeightFormulaPart(), RefreshFromParent(pParentSrc->GetHeightFormulaPart()) );
  819. if (pParentSrc->GetEventIconsToDrawPart())
  820. XTP_SAFE_CALL1(GetEventIconsToDrawPart(), RefreshFromParent(pParentSrc->GetEventIconsToDrawPart()) );
  821. }
  822. void CXTPCalendarThemeOffice2007::CTOEvent::RefreshMetrics(BOOL bRefreshChildren)
  823. {
  824. UNREFERENCED_PARAMETER(bRefreshChildren);
  825. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  826. ASSERT(pThemeX);
  827. if (!pThemeX)
  828. {
  829. return;
  830. }
  831. m_fcsetNormal.clrBorder.SetStandardValue(RGB(0, 0, 0));
  832. m_fcsetNormal.grclrBackground.SetStandardValue(RGB(255, 255, 255), RGB(255, 255, 255));
  833. m_fcsetSelected.clrBorder.SetStandardValue(RGB(0, 0, 0));
  834. m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
  835. //----------------------------------------------
  836. CFont* pFontDef = pThemeX->m_fntBaseFont;
  837. CFont* pFontBoldDef = pThemeX->m_fntBaseFontBold;
  838. //----------------------------------------------
  839. m_fcsetNormal.fcsetSubject.clrColor.SetStandardValue(RGB(0, 0, 0));
  840. m_fcsetNormal.fcsetSubject.fntFont.SetStandardValue(pFontBoldDef);
  841. m_fcsetNormal.fcsetLocation.clrColor.SetStandardValue(RGB(0, 0, 0));
  842. m_fcsetNormal.fcsetLocation.fntFont.SetStandardValue(pFontDef);
  843. m_fcsetNormal.fcsetBody.clrColor.SetStandardValue(RGB(0, 0, 0));
  844. m_fcsetNormal.fcsetBody.fntFont.SetStandardValue(pFontDef);
  845. //----------------------------------------------
  846. m_fcsetSelected.fcsetSubject.clrColor.SetStandardValue(RGB(0, 0, 0));
  847. m_fcsetSelected.fcsetSubject.fntFont.SetStandardValue(pFontBoldDef);
  848. m_fcsetSelected.fcsetLocation.clrColor.SetStandardValue(RGB(0, 0, 0));
  849. m_fcsetSelected.fcsetLocation.fntFont.SetStandardValue(pFontDef);
  850. m_fcsetSelected.fcsetBody.clrColor.SetStandardValue(RGB(0, 0, 0));
  851. m_fcsetSelected.fcsetBody.fntFont.SetStandardValue(pFontDef);
  852. m_clrGripperBorder.SetStandardValue(m_fcsetSelected.clrBorder);
  853. m_clrGripperBackground.SetStandardValue(RGB(255, 255, 255));
  854. }
  855. void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::doPX(
  856. CXTPPropExchange* pPX, LPCTSTR pcszPropName, CXTPCalendarTheme* pTheme)
  857. {
  858. if (!pPX || !pcszPropName || !pTheme)
  859. {
  860. ASSERT(FALSE);
  861. return;
  862. }
  863. CXTPPropExchangeSection secData(pPX->GetSection(pcszPropName));
  864. if (pPX->IsStoring())
  865. secData->EmptySection();
  866. PX_Color(&secData, _T("BorderColor"), clrBorder);
  867. PX_GrColor(&secData, _T("Background"), grclrBackground);
  868. fcsetSubject.doPX(&secData, _T("Subject"), pTheme);
  869. fcsetLocation.doPX(&secData, _T("Location"), pTheme);
  870. fcsetBody.doPX(&secData, _T("Body"), pTheme);
  871. fcsetStartEnd.doPX(&secData, _T("StartEnd"), pTheme);
  872. }
  873. void CXTPCalendarThemeOffice2007::CTOEvent::CEventFontsColorsSet::
  874. Serialize(CArchive& ar)
  875. {
  876. clrBorder.Serialize(ar);
  877. grclrBackground.Serialize(ar);
  878. fcsetSubject.Serialize(ar);
  879. fcsetLocation.Serialize(ar);
  880. fcsetBody.Serialize(ar);
  881. fcsetStartEnd.Serialize(ar);
  882. }
  883. void CXTPCalendarThemeOffice2007::CTOEvent::DoPropExchange(CXTPPropExchange* pPX)
  884. {
  885. ASSERT(pPX);
  886. if (!pPX)
  887. return;
  888. CXTPPropExchangeSection secData(pPX->GetSection(_T("Event")));
  889. if (pPX->IsStoring())
  890. secData->EmptySection();
  891. m_fcsetNormal.doPX(&secData, _T("Normal"), GetTheme());
  892. m_fcsetSelected.doPX(&secData, _T("Selected"), GetTheme());
  893. PX_Color(&secData, _T("GripperBorderColor"),     m_clrGripperBorder);
  894. PX_Color(&secData, _T("GripperBackgroundColor"), m_clrGripperBackground);
  895. TBase::DoPropExchange(&secData);
  896. }
  897. void CXTPCalendarThemeOffice2007::CTOEvent::Serialize(CArchive& ar)
  898. {
  899. m_fcsetNormal.Serialize(ar);
  900. m_fcsetSelected.Serialize(ar);
  901. m_clrGripperBorder.Serialize(ar);
  902. m_clrGripperBackground.Serialize(ar);
  903. TBase::Serialize(ar);
  904. }
  905. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::DoPropExchange(CXTPPropExchange* pPX)
  906. {
  907. ASSERT(pPX);
  908. if (!pPX)
  909. return;
  910. CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewEvent_MultiDay")));
  911. if (pPX->IsStoring())
  912. secData->EmptySection();
  913. m_strDateFormatFrom.DoPropExchange(&secData, _T("DateFormatFrom"));
  914. m_strDateFormatTo.DoPropExchange(&secData, _T("DateFormatTo"));
  915. TBase::DoPropExchange(&secData);
  916. }
  917. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Serialize(CArchive& ar)
  918. {
  919. m_strDateFormatFrom.Serialize(ar);
  920. m_strDateFormatTo.Serialize(ar);
  921. TBase::Serialize(ar);
  922. }
  923. int CXTPCalendarThemeOffice2007::CTOEvent::CalcMinEventHeight(CDC* pDC)
  924. {
  925. CArray<CFont*, CFont*> arFonts;
  926. arFonts.Add(m_fcsetNormal.fcsetSubject.Font());
  927. arFonts.Add(m_fcsetNormal.fcsetLocation.Font());
  928. arFonts.Add(m_fcsetNormal.fcsetStartEnd.Font());
  929. arFonts.Add(m_fcsetSelected.fcsetSubject.Font());
  930. arFonts.Add(m_fcsetSelected.fcsetLocation.Font());
  931. arFonts.Add(m_fcsetSelected.fcsetStartEnd.Font());
  932. int nFontHeightMax = 0;
  933. CXTPCalendarUtils::GetMaxHeightFont(arFonts, pDC, &nFontHeightMax);
  934. ASSERT(GetHeightFormulaPart());
  935. if (!GetHeightFormulaPart())
  936. {
  937. ASSERT(FALSE);
  938. return TBase::CalcMinEventHeight(pDC);
  939. }
  940. int nHeight = GetHeightFormulaPart()->Calculate(nFontHeightMax);
  941. return nHeight;
  942. }
  943. void CXTPCalendarThemeOffice2007::CTODayViewEvent::RefreshMetrics(BOOL bRefreshChildren)
  944. {
  945. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  946. ASSERT(pThemeX);
  947. if (!pThemeX)
  948. {
  949. return;
  950. }
  951. TBase::RefreshMetrics(bRefreshChildren);
  952. RefreshFromParent(pThemeX->GetEventPartX());
  953. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
  954. XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, TRUE, TRUE, FALSE, TRUE));
  955. }
  956. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
  957. {
  958. UNREFERENCED_PARAMETER(bRefreshChildren);
  959. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  960. ASSERT(pThemeX);
  961. if (!pThemeX)
  962. {
  963. return;
  964. }
  965. RefreshFromParent(pThemeX->GetDayViewPartX()->GetEventPartX());
  966. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
  967. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
  968.    pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto)   );
  969. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
  970. m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
  971. //------------------------------------------------
  972. //LOCALE_IDATE  -  short date format ordering
  973. // 0 Month-Day-Year
  974. // 1 Day-Month-Year
  975. // 2 Year-Month-Day
  976. int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
  977. CString strFormatFrom, strFormatTo;
  978. XTPResourceManager()->LoadString(&strFormatFrom, XTP_IDS_CALENDAR_FROM);
  979. XTPResourceManager()->LoadString(&strFormatTo, XTP_IDS_CALENDAR_TO);
  980. if (nDateOrdering == 1)
  981. {
  982. strFormatFrom += _T(": MMM d");
  983. strFormatTo += _T(": MMM d");
  984. }
  985. else
  986. {
  987. strFormatFrom += _T(": d MMM");
  988. strFormatTo += _T(": d MMM");
  989. }
  990. m_strDateFormatFrom.SetStandardValue(strFormatFrom);
  991. m_strDateFormatTo.SetStandardValue(strFormatTo);
  992. //------------------------------------------------
  993. m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
  994. m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
  995. m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
  996. m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
  997. }
  998. void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
  999. {
  1000. UNREFERENCED_PARAMETER(bRefreshChildren);
  1001. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1002. ASSERT(pThemeX);
  1003. if (!pThemeX)
  1004. {
  1005. return;
  1006. }
  1007. RefreshFromParent(pThemeX->GetDayViewPartX()->GetEventPartX());
  1008. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBorder));
  1009. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBkGRfrom),
  1010. pThemeX->GetColor(xtpCLR_DayViewSingleDayEventBkGRto));
  1011. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayViewSingleDayEventSelectedBorder));
  1012. m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
  1013. InitBusyStatusDefaultColors();
  1014. }
  1015. BOOL CXTPCalendarThemeOffice2007::CTOEvent::Draw_ArrowL(CXTPCalendarViewEvent* pViewEvent, CDC* pDC,
  1016. CRect& rrcRect)
  1017. {
  1018. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1019. ASSERT(pThemeX);
  1020. if (!pThemeX)
  1021. {
  1022. return FALSE;
  1023. }
  1024. CXTPOffice2007Image* pArrowLR = pThemeX->GetBitmap(_T("CalendarAllDayEventArrowsLR"));
  1025. if (!pArrowLR || !pDC || !pViewEvent || !pViewEvent->GetEvent())
  1026. {
  1027. ASSERT(FALSE);
  1028. return FALSE;
  1029. }
  1030. CSize szArrow =  pArrowLR->GetExtent();
  1031. szArrow.cy /= 2;
  1032. CRect rcEventMax(pViewEvent->GetViewEventRectMax());
  1033. CRect rcEvent(pViewEvent->GetEventRect());
  1034. if (rcEvent.IsRectEmpty())
  1035. {
  1036. return FALSE;
  1037. }
  1038. CRect rcArrow = rcEvent;
  1039. rcArrow.top = rcEvent.top + rcEvent.Height() / 2 - szArrow.cy / 2;
  1040. rcArrow.bottom = rcArrow.top + szArrow.cy;
  1041. rcArrow.left = rcEventMax.left + 5;
  1042. rcArrow.right = rcArrow.left + szArrow.cx;
  1043. if (rcEventMax.Width() < szArrow.cx * 4)
  1044. {
  1045. rcArrow.right = rcArrow.left = rcEventMax.left;
  1046. rrcRect = rcArrow;
  1047. return FALSE;
  1048. }
  1049. rrcRect = rcArrow;
  1050. pArrowLR->DrawImage(pDC, rcArrow, pArrowLR->GetSource(0, 2), CRect(0,0,0,0), RGB(255, 0, 255));
  1051. return TRUE;
  1052. }
  1053. BOOL CXTPCalendarThemeOffice2007::CTOEvent::Draw_ArrowR(CXTPCalendarViewEvent* pViewEvent, CDC* pDC, CRect& rrcRect)
  1054. {
  1055. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1056. ASSERT(pThemeX);
  1057. if (!pThemeX)
  1058. {
  1059. return FALSE;
  1060. }
  1061. CXTPOffice2007Image* pArrowLR = pThemeX->GetBitmap(_T("CalendarAllDayEventArrowsLR"));
  1062. if (!pArrowLR || !pDC || !pViewEvent || !pViewEvent->GetEvent())
  1063. {
  1064. ASSERT(FALSE);
  1065. return FALSE;
  1066. }
  1067. CSize szArrow =  pArrowLR->GetExtent();
  1068. szArrow.cy /= 2;
  1069. CRect rcEventMax(pViewEvent->GetViewEventRectMax());
  1070. CRect rcEvent(pViewEvent->GetEventRect());
  1071. if (rcEvent.IsRectEmpty())
  1072. {
  1073. return FALSE;
  1074. }
  1075. CRect rcArrow = rcEvent;
  1076. rcArrow.top = rcEvent.top + rcEvent.Height() / 2 - szArrow.cy / 2;
  1077. rcArrow.bottom = rcArrow.top + szArrow.cy;
  1078. rcArrow.left = rcEventMax.right - 5 - szArrow.cx;
  1079. rcArrow.right = rcArrow.left + szArrow.cx;
  1080. if (rcEventMax.Width() < szArrow.cx * 4)
  1081. {
  1082. rcArrow.right = rcArrow.left = rcEventMax.right;
  1083. rrcRect = rcArrow;
  1084. return FALSE;
  1085. }
  1086. rrcRect = rcArrow;
  1087. pArrowLR->DrawImage(pDC, rcArrow, pArrowLR->GetSource(1, 2), CRect(0,0,0,0), RGB(255, 0, 255));
  1088. return TRUE;
  1089. }
  1090. CSize CXTPCalendarThemeOffice2007::CTOEvent::Draw_Icons(CXTPCalendarViewEvent* pViewEvent,
  1091. CDC* pDC, const CRect& rcIconsMax, BOOL bCalculate)
  1092. {
  1093. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1094. if (!pThemeX || !pDC || !pViewEvent || !pViewEvent->GetEvent())
  1095. {
  1096. ASSERT(FALSE);
  1097. return FALSE;
  1098. }
  1099. CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
  1100. //-----------------------------------------------------
  1101. CArray<XTP_CALENDAR_EVENT_ICON_INFO, XTP_CALENDAR_EVENT_ICON_INFO&> arIcons;
  1102. CXTPCalendarCustomIconIDs* pCustIconsIDs = pEvent->GetCustomIcons();
  1103. ASSERT(pCustIconsIDs);
  1104. ASSERT(GetEventIconsToDrawPart());
  1105. // get standard icons ===================================================
  1106. CUIntArray arGlyphID, arGlyphIndex;
  1107. if (GetEventIconsToDrawPart())
  1108. GetEventIconsToDrawPart()->FillIconIDs(arGlyphID, arGlyphIndex, pEvent);
  1109. CPoint ptNext_rb = rcIconsMax.BottomRight();
  1110. int nIconYMax = 0;
  1111. if (arGlyphID.GetSize())
  1112. {
  1113. CXTPOffice2007Image* pGlyphs = pThemeX->GetBitmap(_T("CalendarEventGlyphs"));
  1114. ASSERT(pGlyphs);
  1115. CSize szGlyph = pGlyphs ? pGlyphs->GetExtent() : CSize(0);
  1116. szGlyph.cy /= 5;
  1117. nIconYMax = max(nIconYMax, szGlyph.cy);
  1118. int nCount = (int)arGlyphID.GetSize();
  1119. for (int i = 0; i < nCount && pGlyphs; i++)
  1120. {
  1121. // skip if customized -------------------------------------
  1122. if (pCustIconsIDs && pCustIconsIDs->Find(arGlyphID[i]) >= 0)
  1123. {
  1124. continue;
  1125. }
  1126. //---------------------------------------------------------
  1127. if (ptNext_rb.x - szGlyph.cx >= rcIconsMax.left &&
  1128. ptNext_rb.y - szGlyph.cy >= rcIconsMax.top)
  1129. {
  1130. XTP_CALENDAR_EVENT_ICON_INFO ii;
  1131. ::ZeroMemory(&ii, sizeof(ii));
  1132. ii.m_pImage = pGlyphs;
  1133. ii.m_rcSrc = pGlyphs->GetSource(arGlyphIndex[i], 5);
  1134. ii.m_rcDestination.bottom = ptNext_rb.y;
  1135. ii.m_rcDestination.right = ptNext_rb.x;
  1136. ii.m_rcDestination.left = ptNext_rb.x - szGlyph.cx;
  1137. ii.m_rcDestination.top = ptNext_rb.y - szGlyph.cy;
  1138. ptNext_rb.x -= szGlyph.cx;
  1139. arIcons.Add(ii);
  1140. }
  1141. }
  1142. }
  1143. // get custom icons ===================================================
  1144. CXTPImageManager* pImageMan = pThemeX->GetCustomIconsList();
  1145. ASSERT(pImageMan);
  1146. if (pImageMan && pCustIconsIDs && pCustIconsIDs->GetSize())
  1147. {
  1148. int nCount = pCustIconsIDs->GetSize();
  1149. for (int i = 0; i < nCount; i++)
  1150. {
  1151. UINT uIconID = pCustIconsIDs->GetAt(nCount - i - 1);
  1152. CXTPImageManagerIcon* pIcon = pImageMan->GetImage(uIconID, 0);
  1153. if (pIcon)
  1154. {
  1155. CSize szIcon = pIcon->GetExtent();
  1156. //------------------------------------------------------
  1157. if (ptNext_rb.x - szIcon.cx < rcIconsMax.left)
  1158. break;
  1159. if (ptNext_rb.y - szIcon.cy < rcIconsMax.top)
  1160. continue;
  1161. //------------------------------------------------------
  1162. XTP_CALENDAR_EVENT_ICON_INFO ii;
  1163. ::ZeroMemory(&ii, sizeof(ii));
  1164. ii.m_pIcon = pIcon;
  1165. ii.m_rcDestination.bottom = ptNext_rb.y;
  1166. ii.m_rcDestination.right = ptNext_rb.x;
  1167. ii.m_rcDestination.left = ptNext_rb.x - szIcon.cx;
  1168. ii.m_rcDestination.top = ptNext_rb.y - szIcon.cy;
  1169. ptNext_rb.x -= szIcon.cx;
  1170. nIconYMax = max(nIconYMax, szIcon.cy);
  1171. arIcons.Add(ii);
  1172. }
  1173. }
  1174. }
  1175. //
  1176. CSize szIcons(rcIconsMax.right - ptNext_rb.x, nIconYMax);
  1177. if (bCalculate)
  1178. {
  1179. return szIcons;
  1180. }
  1181. //------------------------
  1182. CRect rcIcons = rcIconsMax;
  1183. rcIcons.left = max(rcIcons.right - szIcons.cx - 2, rcIconsMax.left);
  1184. rcIcons.top = max(rcIcons.bottom - szIcons.cy - 2, rcIconsMax.top);
  1185. CTOEvent* pEventPart = pThemeX->GetThemePartForEvent(pViewEvent);
  1186. ASSERT(pEventPart);
  1187. if (pEventPart && !rcIcons.IsRectEmpty())
  1188. {
  1189. pEventPart->FillEventBackgroundEx(pDC, pViewEvent, rcIcons);
  1190. }
  1191. // Draw icons
  1192. int nCount = (int)arIcons.GetSize();
  1193. for (int i = 0; i < nCount; i++)
  1194. {
  1195. XTP_CALENDAR_EVENT_ICON_INFO ii = arIcons[i];
  1196. CRect rcIcon = ii.m_rcDestination;
  1197. if (pDC->IsPrinting())
  1198. {
  1199. CRect rcIcon00(0, 0, rcIcon.Width(), rcIcon.Height());
  1200. CBitmap bmp;
  1201. bmp.CreateCompatibleBitmap(pDC, rcIcon.Width(), rcIcon.Height());
  1202. CXTPCompatibleDC dcMem(NULL, &bmp);
  1203. dcMem.m_bPrinting = TRUE;
  1204. pEventPart->FillEventBackgroundEx(&dcMem, pViewEvent, rcIcon00);
  1205. dcMem.m_bPrinting = FALSE;
  1206. //------------------------------
  1207. if (ii.m_pImage)
  1208. {
  1209. ii.m_pImage->DrawImage(&dcMem, rcIcon00, ii.m_rcSrc, CRect(0,0,0,0), RGB(255, 0, 255));
  1210. }
  1211. else if (ii.m_pIcon)
  1212. {
  1213. ii.m_pIcon->Draw(&dcMem, CPoint(0, 0));
  1214. }
  1215. else ASSERT(FALSE);
  1216. pDC->BitBlt(rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), &dcMem, 0, 0, SRCCOPY);
  1217. }
  1218. else
  1219. {
  1220. if (ii.m_pImage)
  1221. {
  1222. ii.m_pImage->DrawImage(pDC, ii.m_rcDestination, ii.m_rcSrc, CRect(0,0,0,0), RGB(255, 0, 255));
  1223. }
  1224. else if (ii.m_pIcon)
  1225. {
  1226. ii.m_pIcon->Draw(pDC, rcIcon.TopLeft());
  1227. }
  1228. else ASSERT(FALSE);
  1229. }
  1230. }
  1231. return szIcons;
  1232. }
  1233. BOOL CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw_ArrowLtext(CXTPCalendarViewEvent* pViewEvent,
  1234. CDC* pDC, CThemeFontColorSetValue* pfcsetText, CRect& rrcRect, int nLeft_x)
  1235. {
  1236. if (!pDC || !pViewEvent || !pViewEvent->GetEvent() || !pfcsetText)
  1237. {
  1238. ASSERT(FALSE);
  1239. return FALSE;
  1240. }
  1241. CXTPFontDC autoFont(pDC, pfcsetText->Font(), pfcsetText->Color());
  1242. CString strText = Format_FromToDate(pViewEvent, 1);
  1243. CRect rcEvent(pViewEvent->GetEventRect());
  1244. if (rcEvent.IsRectEmpty())
  1245. {
  1246. return FALSE;
  1247. }
  1248. CSize szText = pDC->GetTextExtent(strText);
  1249. CRect rcText = rcEvent;
  1250. rcText.left = nLeft_x + 5;
  1251. rcText.right = rcText.left + szText.cx;
  1252. if (rcEvent.Width() / 2 < szText.cx * 3)
  1253. {
  1254. rcText.left = rcText.right = nLeft_x;
  1255. rrcRect = rcText;
  1256. return FALSE;
  1257. }
  1258. rrcRect = rcText;
  1259. pDC->DrawText(strText, &rcText, DT_LEFT | DT_SINGLELINE | DT_VCENTER);
  1260. return TRUE;
  1261. }
  1262. BOOL CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw_ArrowRtext(CXTPCalendarViewEvent* pViewEvent,
  1263. CDC* pDC, CThemeFontColorSetValue* pfcsetText, CRect& rrcRect, int nRight_x)
  1264. {
  1265. if (!pDC || !pViewEvent || !pViewEvent->GetEvent() || !pfcsetText)
  1266. {
  1267. ASSERT(FALSE);
  1268. return FALSE;
  1269. }
  1270. CXTPFontDC autoFont(pDC, pfcsetText->Font(), pfcsetText->Color());
  1271. CString strText = Format_FromToDate(pViewEvent, 2);
  1272. CRect rcEvent(pViewEvent->GetEventRect());
  1273. if (rcEvent.IsRectEmpty())
  1274. {
  1275. return FALSE;
  1276. }
  1277. CSize szText = pDC->GetTextExtent(strText);
  1278. CRect rcText = rcEvent;
  1279. rcText.right = nRight_x - 5;
  1280. rcText.left = rcText.right - szText.cx;
  1281. if (rcEvent.Width() / 2 < szText.cx * 3)
  1282. {
  1283. rcText.left = rcText.right = nRight_x;
  1284. rrcRect = rcText;
  1285. return FALSE;
  1286. }
  1287. rrcRect = rcText;
  1288. pDC->DrawText(strText, &rcText, DT_RIGHT | DT_SINGLELINE | DT_VCENTER);
  1289. return TRUE;
  1290. }
  1291. CString CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Format_FromToDate(CXTPCalendarViewEvent* pViewEvent, int nStart1End2)
  1292. {
  1293. if (!pViewEvent || !pViewEvent->GetEvent())
  1294. {
  1295. ASSERT(FALSE);
  1296. return _T("");
  1297. }
  1298. ASSERT(nStart1End2 == 1 || nStart1End2 == 2);
  1299. COleDateTime dtDate = nStart1End2 == 1 ? pViewEvent->GetEvent()->GetStartTime() : pViewEvent->GetEvent()->GetEndTime();
  1300. if (nStart1End2 == 2 && CXTPCalendarUtils::IsZeroTime(dtDate))
  1301. {
  1302. dtDate -= COleDateTimeSpan(0, 0, 1, 0);
  1303. }
  1304. const CString& strFormat = nStart1End2 == 1 ? m_strDateFormatFrom : m_strDateFormatTo;
  1305. CString strDate = CXTPCalendarUtils::GetDateFormat(dtDate, strFormat);
  1306. return strDate;
  1307. }
  1308. ///*** ======================================================================
  1309. CRect CXTPCalendarThemeOffice2007::CTODayViewDay::ExcludeDayBorder(
  1310. CXTPCalendarDayViewDay* pDayViewDay, const CRect& rcDay)
  1311. {
  1312. BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
  1313. int nWidthH = bIsToday ? 2 : 1;
  1314. CRect rcGroups = rcDay;
  1315. rcGroups.DeflateRect(nWidthH, 0, nWidthH, 1);
  1316. return rcGroups;
  1317. }
  1318. void CXTPCalendarThemeOffice2007::CTODayViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
  1319. {
  1320. TBase::Draw(pObject, pDC);
  1321. CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
  1322. if (!pDC || !pDayViewDay)
  1323. {
  1324. ASSERT(FALSE);
  1325. return;
  1326. }
  1327. CRect rcBottom = pDayViewDay->GetDayRect();
  1328. rcBottom.top = rcBottom.bottom - 1;
  1329. BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
  1330. COLORREF clrBorder = bIsToday ? m_clrTodayBorder : m_clrBorder;
  1331. pDC->FillSolidRect(&rcBottom, clrBorder);
  1332. }
  1333. void CXTPCalendarThemeOffice2007::CTODayViewDay::Draw_DayBorder(CXTPCalendarDayViewDay* pDayViewDay, CDC* pDC)
  1334. {
  1335. CRect rcDay = pDayViewDay->GetDayRect();
  1336. CRect rcGroup(rcDay);
  1337. if (pDayViewDay->GetViewGroupsCount() > 0)
  1338. {
  1339. rcGroup = pDayViewDay->GetViewGroup(0)->GetRect();
  1340. }
  1341. CRect rcDayDetails = rcDay;
  1342. rcDayDetails.top = rcGroup.top;
  1343. CRect rcDayDetails2 = ExcludeDayBorder(pDayViewDay, rcDayDetails);
  1344. BOOL bIsToday = GetHeaderPart()->IsToday(pDayViewDay);
  1345. COLORREF clrBorder = bIsToday ? m_clrTodayBorder : m_clrBorder;
  1346. CRect rcLeft = rcDayDetails, rcRight = rcDayDetails, rcBottom = rcDayDetails;
  1347. rcLeft.right = min(rcDayDetails2.left, rcDayDetails.right);
  1348. rcRight.left = max(rcDayDetails2.right, rcDayDetails.left);
  1349. rcBottom.top = max(rcDayDetails2.bottom, rcDayDetails.top);
  1350. pDC->FillSolidRect(&rcLeft, clrBorder);
  1351. pDC->FillSolidRect(&rcRight, clrBorder);
  1352. pDC->FillSolidRect(&rcBottom, clrBorder);
  1353. }
  1354. void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::AdjustLayout(CCmdTarget* pObject,
  1355. CDC* pDC, const CRect& rcRect)
  1356. {
  1357. //TBase::AdjustLayout(pObject, pDC, rcRect);
  1358. CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
  1359. if (!pDC || !pDayViewDay || !pDayViewDay->GetView())
  1360. {
  1361. ASSERT(FALSE);
  1362. return;
  1363. }
  1364. if (pDayViewDay->GetDayIndex() != 0)
  1365. {
  1366. return;
  1367. }
  1368. m_nWeekDayFormat = 0;
  1369. CXTPCalendarDayView* pDayView = pDayViewDay->GetView();
  1370. if (m_UseOffice2003HeaderFormat)
  1371. {
  1372. int nDayWidth = rcRect.Width() - 4;
  1373. pDayView->CalculateHeaderFormat(pDC, nDayWidth, m_TextCenter.fcsetNormal.Font());
  1374. }
  1375. else
  1376. {
  1377. int nWDLong_max = 0;
  1378. int nWDShort_max = 0;
  1379. CXTPFontDC autoFnt(pDC, m_TextCenter.fcsetNormal.Font());
  1380. for (int i = 0; i < 7; i++)
  1381. {
  1382. CString strWDLong = CXTPCalendarUtils::GetLocaleString(LOCALE_SDAYNAME1 + i, 100);
  1383. CString strWDShort = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVDAYNAME1 + i, 100);
  1384. nWDLong_max = max(nWDLong_max, pDC->GetTextExtent(strWDLong).cx);
  1385. nWDShort_max = max(nWDShort_max, pDC->GetTextExtent(strWDShort).cx);
  1386. }
  1387. autoFnt.SetFont(m_TextLeftRight.fcsetNormal.Font());
  1388. int nLR_width = pDC->GetTextExtent(_T("88"), 2).cx * 2;
  1389. int nCenterTextWidth = max(rcRect.Width() - nLR_width, 0);
  1390. if (nCenterTextWidth >= nWDLong_max + 4)
  1391. {
  1392. m_nWeekDayFormat = 2;
  1393. }
  1394. else if (nCenterTextWidth >= nWDShort_max + 4)
  1395. {
  1396. m_nWeekDayFormat = 1;
  1397. }
  1398. else
  1399. {
  1400. m_nWeekDayFormat = 0;
  1401. }
  1402. }
  1403. }
  1404. void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  1405. {
  1406. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1407. CXTPCalendarDayViewDay* pDayViewDay = DYNAMIC_DOWNCAST(CXTPCalendarDayViewDay, pObject);
  1408. if (!pDC || !pDayViewDay || !pDayViewDay->GetView() || !GetTheme() || !pThemeX)
  1409. {
  1410. ASSERT(FALSE);
  1411. return;
  1412. }
  1413. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& rLayout = GetTheme()->GetViewDayLayout(pDayViewDay);
  1414. COleDateTime dtDay = pDayViewDay->GetDayDate();
  1415. CPoint pt(0, 0);
  1416. if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
  1417. pThemeX->GetCalendarControl()->ScreenToClient(&pt);
  1418. BOOL bIsToday    = IsToday(pDayViewDay);
  1419. BOOL bIsSelected = IsSelected(pDayViewDay);
  1420. BOOL bFirstDay = pDayViewDay->GetDayIndex() == 0;
  1421. BOOL bLastDay = pDayViewDay->GetDayIndex() == pDayViewDay->GetView()->GetViewDayCount() - 1;
  1422. int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
  1423. nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
  1424. nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
  1425. nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
  1426. if (rLayout.m_rcDayHeader.PtInRect(pt))
  1427. {
  1428. nFlags |=  CTOHeader::xtpCalendarItemState_Hot;
  1429. rLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  1430. }
  1431. else
  1432. {
  1433. rLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  1434. }
  1435. CRect rcRect = rLayout.m_rcDayHeader;
  1436. //------------------------------------------------------
  1437. CString strTextLeft;
  1438. CString strTextCenter;
  1439. CString strTextRight;
  1440. if (m_UseOffice2003HeaderFormat)
  1441. {
  1442. strTextCenter = pDayViewDay->GetCaption();
  1443. }
  1444. else
  1445. {
  1446. strTextLeft.Format(_T("%d"), dtDay.GetDay());
  1447. if (m_nWeekDayFormat > 0)
  1448. {
  1449. LCTYPE lctWDName1 = m_nWeekDayFormat > 1 ? LOCALE_SDAYNAME1 : LOCALE_SABBREVDAYNAME1;
  1450. int nWD = dtDay.GetDayOfWeek();
  1451. strTextCenter = CXTPCalendarUtils::GetLocaleString(lctWDName1 + ((nWD-2+7)%7), 100);
  1452. }
  1453. //------------------------------------------------------
  1454. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderLeft, &strTextLeft, pDayViewDay);
  1455. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderCenter, &strTextCenter, pDayViewDay);
  1456. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_DayViewDayHeaderRight, &strTextRight, pDayViewDay);
  1457. //------------------------------------------------------
  1458. }
  1459. Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
  1460. }
  1461. void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::DoPropExchange(CXTPPropExchange* pPX)
  1462. {
  1463. ASSERT(pPX);
  1464. if (!pPX)
  1465. return;
  1466. if (pPX->GetSchema() >= _XTP_SCHEMA_112)
  1467. {
  1468. CXTPPropExchangeSection secData(pPX->GetSection(_T("DayViewDayHeader")));
  1469. if (pPX->IsStoring())
  1470. secData->EmptySection();
  1471. m_UseOffice2003HeaderFormat.DoPropExchange(&secData, _T("UseOffice2003HeaderFormat"));
  1472. XTP_SAFE_CALL_BASE(TBase, DoPropExchange(&secData));
  1473. }
  1474. else
  1475. {
  1476. XTP_SAFE_CALL_BASE(TBase, DoPropExchange(pPX));
  1477. }
  1478. }
  1479. void CXTPCalendarThemeOffice2007::CTODayViewDayHeader::Serialize(CArchive& ar)
  1480. {
  1481. m_UseOffice2003HeaderFormat.Serialize(ar);
  1482. XTP_SAFE_CALL_BASE(TBase, Serialize(ar));
  1483. }
  1484. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  1485. {
  1486. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1487. CXTPCalendarDayViewGroup* pDayViewGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
  1488. if (!pThemeX || !pDayViewGroup || !pDayViewGroup->GetViewDay())
  1489. {
  1490. ASSERT(FALSE);
  1491. return;
  1492. }
  1493. const CXTPCalendarViewGroup::XTP_VIEW_GROUP_LAYOUT layoutGoup = CXTPCalendarTheme::GetViewGroupLayout(pDayViewGroup);
  1494. CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayoutX = CXTPCalendarTheme::GetDayViewGroupLayout(pDayViewGroup);
  1495. CRect rcRect = layoutGoup.m_rcGroupHeader;
  1496. CPoint pt(0, 0);
  1497. if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
  1498. pThemeX->GetCalendarControl()->ScreenToClient(&pt);
  1499. BOOL bIsToday    = IsToday(pDayViewGroup->GetViewDay());
  1500. BOOL bIsSelected = IsSelected(pDayViewGroup);
  1501. BOOL bHot = rcRect.PtInRect(pt);
  1502. BOOL bFirstDay = pDayViewGroup->GetGroupIndex() == 0;
  1503. BOOL bLastDay = pDayViewGroup->GetGroupIndex() == pDayViewGroup->GetViewDay()->GetViewGroupsCount() - 1;
  1504. int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
  1505. nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
  1506. nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
  1507. nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
  1508. if (bHot)
  1509. {
  1510. nFlags |=  CTOHeader::xtpCalendarItemState_Hot;
  1511. groupLayoutX.m_nHotState |= CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader;
  1512. }
  1513. else
  1514. {
  1515. groupLayoutX.m_nHotState &= ~CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader;
  1516. }
  1517. CString strCaption = pDayViewGroup->GetCaption();
  1518. Draw_Header(pDC, rcRect, nFlags, _T(""), strCaption);
  1519. }
  1520. void CXTPCalendarThemeOffice2007::CTODayViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
  1521. {
  1522. UNREFERENCED_PARAMETER(nFlags);
  1523. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1524. CXTPCalendarViewDay* pViewDay = DYNAMIC_DOWNCAST(CXTPCalendarViewDay, pObject);
  1525. if (!pThemeX || !pViewDay || !pThemeX->GetCalendarControl())
  1526. {
  1527. ASSERT(FALSE);
  1528. return;
  1529. }
  1530. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
  1531. BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
  1532. if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
  1533. {
  1534. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  1535. }
  1536. }
  1537. void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::AdjustDayEvents(
  1538. CXTPCalendarDayViewGroup* pDayViewGroup, CDC* pDC)
  1539. {
  1540. if (!pDayViewGroup || !pDC)
  1541. {
  1542. ASSERT(FALSE);
  1543. return;
  1544. }
  1545. ASSERT(pDC);
  1546. CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder placeBuilder;
  1547. placeBuilder.BiuldEventPaces(pDayViewGroup);
  1548. CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& rLayoutX = GetTheme()->GetDayViewGroupLayout(pDayViewGroup);
  1549. int nCount = pDayViewGroup->GetViewEventsCount();
  1550. for (int i = 0; i < nCount; i++)
  1551. {
  1552. CXTPCalendarDayViewEvent* pViewEvent = pDayViewGroup->GetViewEvent(i);
  1553. ASSERT(pViewEvent);
  1554. if (!pViewEvent || pViewEvent->IsMultidayEvent())
  1555. continue;
  1556. int nPlaceNumber = pViewEvent->GetEventPlaceNumber();
  1557. pViewEvent->AdjustLayout2(pDC, rLayoutX.m_rcDayDetails, nPlaceNumber);
  1558. }
  1559. }
  1560. CRect CXTPCalendarThemeOffice2007::CTODayViewDayGroup::GetScrollButtonRect(
  1561. const CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayout, int nButton)
  1562. {
  1563. CRect rc;
  1564. switch (nButton)
  1565. {
  1566. case CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp:
  1567. rc = groupLayout.m_rcDayDetails;
  1568. rc.right -= 5;
  1569. rc.top += 5;
  1570. break;
  1571. case CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown:
  1572. rc = groupLayout.m_rcDayDetails;
  1573. rc.right -= 5;
  1574. rc.bottom -= 5;
  1575. break;
  1576. default:
  1577. ASSERT(FALSE);
  1578. rc.SetRect(0, 0, 0, 0);
  1579. }
  1580. return rc;
  1581. }
  1582. int CXTPCalendarThemeOffice2007::CTOCellDynBackground::GetCellDynBackground(CXTPCalendarViewGroup* pViewGroup,
  1583. COleDateTime dtCellTime, int nCellIndex, CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT& rContext)
  1584. {
  1585. ::ZeroMemory(&rContext, sizeof(rContext));
  1586. ASSERT(pViewGroup);
  1587. if (!pViewGroup)
  1588. return xtpCalendarBusyStatusUnknown;
  1589. CXTPCalendarViewEvent* pBkVEv = GetCellBackgroundEvent(pViewGroup, dtCellTime, nCellIndex);
  1590. if (!pBkVEv || !pBkVEv->GetEvent() || !pBkVEv->GetEvent()->GetCategories())
  1591. return xtpCalendarBusyStatusUnknown;
  1592. CXTPCalendarEvent* pEvent = pBkVEv->GetEvent();
  1593. CXTPCalendarEventCategory* pCat = NULL;
  1594. if (pEvent->GetCategories()->GetSize())
  1595. {
  1596. UINT nCatID = pEvent->GetCategories()->GetAt(0);
  1597. pCat = XTP_SAFE_GET3(pEvent, GetDataProvider(), GetEventCategories(), Find(nCatID), NULL);
  1598. }
  1599. int nBusyStatus = pEvent->GetBusyStatus();
  1600. if (nBusyStatus == xtpCalendarBusyStatusBusy ||
  1601. nBusyStatus == xtpCalendarBusyStatusTentative)
  1602. {
  1603. if (!pCat)
  1604. return nBusyStatus;
  1605. rContext.clrBkAllDayEvents  = pCat->GetBkColorAllDayEvents();
  1606. rContext.clrBkNonWorkCell   = pCat->GetBkColorNonWorkCell();
  1607. rContext.clrBkWorkCell      = pCat->GetBkColorWorkCell();
  1608. rContext.clrCellBorder      = pCat->GetColorCellBorder();
  1609. }
  1610. else if (nBusyStatus == xtpCalendarBusyStatusOutOfOffice)
  1611. {
  1612. rContext.clrBkAllDayEvents  = RGB(183, 141, 206);
  1613. rContext.clrBkNonWorkCell   = RGB(214, 190, 227);
  1614. rContext.clrBkWorkCell      = RGB(229, 214, 237);
  1615. rContext.clrCellBorder      = rContext.clrBkAllDayEvents;
  1616. }
  1617. return nBusyStatus;
  1618. }
  1619. int CXTPCalendarThemeOffice2007::CTOCellDynBackground::_GetEventBusyStatusRank(CXTPCalendarEvent* pEvent)
  1620. {
  1621. ASSERT(pEvent);
  1622. if (!pEvent)
  1623. return -1;
  1624. //----------------------------------------------------------------------------
  1625. const int cnRankSize = 4;
  1626. ASSERT(xtpCalendarBusyStatusFree < cnRankSize && xtpCalendarBusyStatusTentative < cnRankSize &&
  1627.    xtpCalendarBusyStatusBusy < cnRankSize && xtpCalendarBusyStatusOutOfOffice < cnRankSize);
  1628. static int sarBSrank[cnRankSize] = {0, 0, 0, 0};
  1629. if (sarBSrank[0] == 0)
  1630. {
  1631. sarBSrank[xtpCalendarBusyStatusFree]        = 1; // min rank
  1632. sarBSrank[xtpCalendarBusyStatusTentative]   = 2;
  1633. sarBSrank[xtpCalendarBusyStatusOutOfOffice] = 3;
  1634. sarBSrank[xtpCalendarBusyStatusBusy]        = 4; // max rank
  1635. }
  1636. //----------------------------------------------------------------------------
  1637. int nBS = pEvent->GetBusyStatus();
  1638. int nBSindex = max(0, min(nBS, cnRankSize-1));
  1639. ASSERT(nBSindex >= 0 && nBSindex < cnRankSize);
  1640. int nBSrank = sarBSrank[nBSindex];
  1641. return nBSrank;
  1642. }
  1643. int CXTPCalendarThemeOffice2007::CTOCellDynBackground::CmpEventBusyStatus(CXTPCalendarEvent* pEvent1, CXTPCalendarEvent* pEvent2)
  1644. {
  1645. ASSERT(pEvent1 && pEvent2);
  1646. if (!pEvent1 || !pEvent2)
  1647. return XTPCompare(pEvent1, pEvent2);
  1648. int nBS1rank = _GetEventBusyStatusRank(pEvent1);
  1649. int nBS2rank = _GetEventBusyStatusRank(pEvent2);
  1650. int nCmp = XTPCompare(nBS1rank, nBS2rank);
  1651. if (nCmp == 0)
  1652. nCmp = XTPCompare(pEvent1->GetDurationMinutes(), pEvent2->GetDurationMinutes());
  1653. if (nCmp == 0 && !CXTPCalendarUtils::IsEqual(pEvent1->GetStartTime(), pEvent2->GetStartTime()))
  1654. nCmp = XTPCompare(pEvent1->GetStartTime(), pEvent2->GetStartTime());
  1655. if (nCmp == 0)
  1656. nCmp = XTPCompare(pEvent1->GetEventID(), pEvent2->GetEventID());
  1657. return nCmp;
  1658. }
  1659. CXTPCalendarViewEvent* CXTPCalendarThemeOffice2007::CTOCellDynBackground::GetCellBackgroundEvent(CXTPCalendarViewGroup* pViewGroup,
  1660. COleDateTime dtCellTime, int nCellIndex)
  1661. {
  1662. ASSERT(pViewGroup);
  1663. if (!pViewGroup)
  1664. return NULL;
  1665. // TODO: Not optimal implementation. Optimize later if need.
  1666. //  #pragma XTPNOTE("Not optimal implementation. Optimize later if need.")
  1667. CXTPCalendarViewEvent* pBkVEvent = NULL;
  1668. int nCount = pViewGroup->GetViewEventsCount();
  1669. for (int i = 0; i < nCount; i++)
  1670. {
  1671. CXTPCalendarEvent* pEvent = XTP_SAFE_GET2(pViewGroup, GetViewEvent_(i), GetEvent(), NULL);
  1672. if (XTP_SAFE_GET2(pViewGroup, GetViewEvent_(i), IsMultidayEvent(), FALSE) && pEvent)
  1673. {
  1674. if (pEvent->IsAllDayEvent())
  1675. continue;
  1676. if (nCellIndex < 0 ||
  1677. (dtCellTime >= pEvent->GetStartTime() && dtCellTime <= pEvent->GetEndTime())
  1678.    )
  1679. {
  1680. if (!pBkVEvent || CmpEventBusyStatus(pBkVEvent->GetEvent(), pEvent) < 0)
  1681. {
  1682. pBkVEvent = pViewGroup->GetViewEvent_(i);
  1683. }
  1684. }
  1685. }
  1686. }
  1687. return pBkVEvent;
  1688. }
  1689. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupCell::Draw(CDC* pDC, const CRect& rcRect,
  1690. const XTP_CALENDAR_THEME_DAYVIEWCELL_PARAMS& cellParams, CXTPPropsStateContext* pStateCnt)
  1691. {
  1692. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1693. CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
  1694. XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
  1695. if (!pDC || !pThemeX || !cellParams.pViewGroup || !pCellDynBkPart || !pThemeX->GetColorsSetPart())
  1696. {
  1697. ASSERT(FALSE);
  1698. return;
  1699. }
  1700. CXTPPropsStateContext autoStateCnt0(this);
  1701. //--------------------------------------------------------------------
  1702. CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
  1703. int nCellBusyStatus = pCellDynBkPart->GetCellDynBackground(cellParams.pViewGroup,
  1704. cellParams.dtBeginTime, cellParams.nIndex, bsColors);
  1705. //--------------------------------------------------------------------
  1706. COLORREF clrHatch = 0;
  1707. if (nCellBusyStatus == xtpCalendarBusyStatusBusy ||
  1708.  nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
  1709.  nCellBusyStatus == xtpCalendarBusyStatusTentative)
  1710. {
  1711. if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or Tentative
  1712. {
  1713. clrHatch = bsColors.clrBkAllDayEvents;
  1714. if (cellParams.bWorkCell)
  1715. {
  1716. if (nCellBusyStatus != xtpCalendarBusyStatusTentative)
  1717. m_clrsetWorkCell.clrBackground = bsColors.clrBkWorkCell;
  1718. m_clrsetWorkCell.clrBorderBottomHour = bsColors.clrCellBorder;
  1719. int nScale = (nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice) ? 110 : 30;
  1720. m_clrsetWorkCell.clrBorderBottomInHour = XTPDrawHelpers()->LightenColor(nScale, bsColors.clrCellBorder);
  1721. }
  1722. else
  1723. {
  1724. if (nCellBusyStatus != xtpCalendarBusyStatusTentative)
  1725. m_clrsetNonWorkCell.clrBackground = bsColors.clrBkNonWorkCell;
  1726. m_clrsetNonWorkCell.clrBorderBottomHour = bsColors.clrCellBorder;
  1727. int nScale = (nCellBusyStatus == xtpCalendarBusyStatusOutOfOffice) ? 54 : 30;
  1728. m_clrsetNonWorkCell.clrBorderBottomInHour = XTPDrawHelpers()->LightenColor(nScale, bsColors.clrCellBorder);
  1729. }
  1730. }
  1731. else
  1732. {
  1733. if (nCellBusyStatus == xtpCalendarBusyStatusBusy ||
  1734. nCellBusyStatus == xtpCalendarBusyStatusTentative)
  1735. {
  1736. if (nCellBusyStatus == xtpCalendarBusyStatusBusy)
  1737. {
  1738. //GetColorsSetPart()->SetColor(xtpCLR_DayViewSingleDayEventBkGRto,          155); // 191, 210, 234 // single-day event gradient fill Dark
  1739. m_clrsetWorkCell.clrBackground = XTPDrawHelpers()->LightenColor(155, GetTheme()->m_clrBaseColor);
  1740. m_clrsetNonWorkCell.clrBackground = (COLORREF)m_clrsetWorkCell.clrBackground;
  1741. }
  1742. m_clrsetWorkCell.clrBorderBottomHour = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
  1743. m_clrsetNonWorkCell.clrBorderBottomHour = (COLORREF)m_clrsetWorkCell.clrBorderBottomHour;
  1744. m_clrsetWorkCell.clrBorderBottomInHour = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_DayViewCellWorkBorderBottomHour);
  1745. m_clrsetNonWorkCell.clrBorderBottomInHour = (COLORREF)m_clrsetWorkCell.clrBorderBottomInHour;
  1746. }
  1747. clrHatch = m_clrsetWorkCell.clrBorderBottomHour;
  1748. }
  1749. }
  1750. //--------------------------------------------------------------------
  1751. if (pStateCnt)
  1752. pStateCnt->SendBeforeDrawThemeObject((LPARAM)&cellParams, xtpCalendarBeforeDraw_DayViewCell);
  1753. //--------------------------------------------------------------------
  1754. TBase::Draw(pDC, rcRect, cellParams, NULL);
  1755. //--------------------------------------------------------------------
  1756. if (nCellBusyStatus == xtpCalendarBusyStatusTentative)
  1757. {
  1758. COLORREF clrBk = 0;
  1759. if (cellParams.bSelected)
  1760. clrBk = cellParams.bWorkCell ? m_clrsetWorkCell.clrSelected : m_clrsetNonWorkCell.clrSelected;
  1761. else
  1762. clrBk = cellParams.bWorkCell ? m_clrsetWorkCell.clrBackground : m_clrsetNonWorkCell.clrBackground;
  1763. CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBk);
  1764. CBrush br(HS_BDIAGONAL, clrHatch);
  1765. CRect rc = rcRect;
  1766. if (cellParams.nIndex != cellParams.pViewGroup->GetViewDay()->GetView()->GetTopRow())
  1767. rc.top++;
  1768. pDC->FillRect(&rc, &br);
  1769. }
  1770. //--------------------------------------------------------------------
  1771. autoStateCnt0.RestoreState();
  1772. autoStateCnt0.Clear();
  1773. //--------------------------------------------------------------------
  1774. if (pStateCnt)
  1775. pStateCnt->RestoreState();
  1776. }
  1777. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::SetDynColors(CXTPCalendarDayViewGroup* pViewGroup)
  1778. {
  1779. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1780. CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
  1781. XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
  1782. if (!pViewGroup || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
  1783. {
  1784. ASSERT(FALSE);
  1785. return;
  1786. }
  1787. COleDateTime dtDate = pViewGroup->GetViewDay()->GetDayDate();
  1788. //--------------------------------------------------------------------
  1789. CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
  1790. m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, dtDate, -1, bsColors);
  1791. //--------------------------------------------------------------------
  1792. m_clrDynHatch = 0;
  1793. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
  1794.  m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
  1795.  m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  1796. {
  1797. if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
  1798. {
  1799. m_clrDynHatch = bsColors.clrBkAllDayEvents;
  1800. if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
  1801. {
  1802. m_clrBackground = bsColors.clrBkAllDayEvents;
  1803. m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
  1804. }
  1805. }
  1806. else
  1807. {
  1808. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
  1809. {
  1810. m_clrBackground = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
  1811. }
  1812. m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
  1813. }
  1814. }
  1815. }
  1816. void CXTPCalendarThemeOffice2007::CTODayViewDayGroupAllDayEvents::Draw(CCmdTarget* pObject, CDC* pDC)
  1817. {
  1818. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1819. CXTPCalendarDayViewGroup* pDayViewGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
  1820. if (!pDC || !pDayViewGroup || !pDayViewGroup->GetViewDay() || !pThemeX)
  1821. {
  1822. ASSERT(FALSE);
  1823. return;
  1824. }
  1825. CRect rcRectBk = pDayViewGroup->GetAllDayEventsRect();
  1826. CRect rcRect2 = rcRectBk;
  1827. if (rcRectBk.IsRectEmpty())
  1828. {
  1829. return;
  1830. }
  1831. rcRectBk.bottom -= 2;
  1832. rcRect2.top = rcRectBk.bottom;
  1833. BOOL bIsSelected = GetTheme()->GetDayViewPart()->GetDayPart()->GetGroupPart()->IsSelected(pDayViewGroup);
  1834. BOOL bIsToday = GetTheme()->GetDayViewPart()->GetHeaderPart()->IsToday(pDayViewGroup->GetViewDay());
  1835. COLORREF clrBk = bIsSelected ? m_clrBackgroundSelected : m_clrBackground;
  1836. COLORREF clrBorder = bIsToday ? (COLORREF)pThemeX->GetDayViewPartX()->GetDayPartX()->m_clrTodayBorder : m_clrBottomBorder;
  1837. pDC->FillSolidRect(&rcRectBk, clrBk);
  1838. pDC->FillSolidRect(&rcRect2, clrBorder);
  1839. //--------------------------------------------------------------------
  1840. if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  1841. {
  1842. CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBk);
  1843. CBrush br(HS_BDIAGONAL, m_clrDynHatch);
  1844. pDC->FillRect(&rcRectBk, &br);
  1845. }
  1846. }
  1847. void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::Draw(CCmdTarget* pObject, CDC* pDC)
  1848. {
  1849. TBase::Draw(pObject, pDC);
  1850. CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
  1851. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1852. if (!pDC || !pDVGroup || !pThemeX)
  1853. {
  1854. ASSERT(FALSE);
  1855. return;
  1856. }
  1857. CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayout = GetTheme()->GetDayViewGroupLayout(pDVGroup);
  1858. if (pDC->IsPrinting())
  1859. return;
  1860. groupLayout.m_nHotState &= ~(CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp | CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown);
  1861. int nHit = HitTestScrollButton(pDVGroup);
  1862. if (pDVGroup->IsExpandUp())
  1863. {
  1864. int nButton = CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp;
  1865. CRect rc = GetScrollButtonRect(groupLayout, nButton);
  1866. BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollUp);
  1867. pThemeX->DrawExpandDayButton(pDC, rc, TRUE, bHot);
  1868. if (bHot)
  1869. groupLayout.m_nHotState |= nButton;
  1870. }
  1871. if (pDVGroup->IsExpandDown())
  1872. {
  1873. int nButton = CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown;
  1874. CRect rc = GetScrollButtonRect(groupLayout, nButton);
  1875. BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollDown);
  1876. pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
  1877. if (bHot)
  1878. groupLayout.m_nHotState |= nButton;
  1879. }
  1880. }
  1881. void CXTPCalendarThemeOffice2007::CTODayViewDayGroup::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
  1882. {
  1883. UNREFERENCED_PARAMETER(nFlags);
  1884. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1885. CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
  1886. if (!pDVGroup || !pThemeX || !pThemeX->GetCalendarControl())
  1887. {
  1888. ASSERT(FALSE);
  1889. return;
  1890. }
  1891. CXTPCalendarViewGroup::XTP_VIEW_GROUP_LAYOUT groupLayout = GetTheme()->GetViewGroupLayout(pDVGroup);
  1892. CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT& groupLayoutX = GetTheme()->GetDayViewGroupLayout(pDVGroup);
  1893. BOOL bRedraw = FALSE;
  1894. int nHit = HitTestScrollButton(pDVGroup, &point);
  1895. BOOL bHot = !!(nHit & xtpCalendarHitTestDayViewScrollUp);
  1896. BOOL bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollUp);
  1897. bRedraw |= (bHot != bHotPrev);
  1898. bHot = !!(nHit & xtpCalendarHitTestDayViewScrollDown);
  1899. bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotScrollDown);
  1900. bRedraw |= (bHot != bHotPrev);
  1901. //-----------------------------------------------------------------------
  1902. bHot = groupLayoutX.m_bShowHeader && groupLayout.m_rcGroupHeader.PtInRect(point);
  1903. bHotPrev = !!(groupLayoutX.m_nHotState & CXTPCalendarDayViewGroup::XTP_DAY_VIEW_GROUP_LAYOUT::xtpHotHeader);
  1904. bRedraw |= (bHot != bHotPrev);
  1905. if (bRedraw)
  1906. {
  1907. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  1908. }
  1909. }
  1910. BOOL CXTPCalendarThemeOffice2007::CTODayViewDayGroup::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
  1911. {
  1912. UNREFERENCED_PARAMETER(nFlags);
  1913. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1914. CXTPCalendarDayViewGroup* pDVGroup = DYNAMIC_DOWNCAST(CXTPCalendarDayViewGroup, pObject);
  1915. if (!pDVGroup || !pDVGroup->GetViewDay() || !pThemeX || !pThemeX->GetCalendarControl())
  1916. {
  1917. ASSERT(FALSE);
  1918. return FALSE;
  1919. }
  1920. int nHit = HitTestScrollButton(pDVGroup, &point);
  1921. if (nHit & xtpCalendarHitTestDayViewScrollUp)
  1922. {
  1923. pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
  1924. (WPARAM)(xtpCalendarUserAction_OnScrollDay | xtpCalendarScrollDayButton_DayViewUp),
  1925. MAKELPARAM((WORD)pDVGroup->GetGroupIndex(), pDVGroup->GetViewDay()->GetDayIndex()) );
  1926. return TRUE;
  1927. }
  1928. if (nHit & xtpCalendarHitTestDayViewScrollDown)
  1929. {
  1930. pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
  1931. (WPARAM)(xtpCalendarUserAction_OnScrollDay | xtpCalendarScrollDayButton_DayViewDown),
  1932. MAKELPARAM((WORD)pDVGroup->GetGroupIndex(), pDVGroup->GetViewDay()->GetDayIndex()) );
  1933. return TRUE;
  1934. }
  1935. return FALSE;
  1936. }
  1937. //////////////////////////////////////////////////////////////////////////
  1938. //class CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder
  1939. CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder()
  1940. {
  1941. m_mapEvToOverlapped.InitHashTable(XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT, FALSE);
  1942. m_spCellDuration.SetDateTimeSpan(0, 0, 30, 0);
  1943. m_dtMinStartTime = (DATE)0;
  1944. }
  1945. void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::BiuldEventPaces(CXTPCalendarDayViewGroup* pViewGroup)
  1946. {
  1947. ASSERT(pViewGroup);
  1948. if (!pViewGroup)
  1949. return;
  1950. //----------------------------------------------------
  1951. m_spCellDuration = XTP_SAFE_GET3(pViewGroup, GetViewDay(), GetView(), GetCellDuration(), 0);
  1952. if (double(m_spCellDuration) <= XTP_HALF_SECOND)
  1953. {
  1954. m_spCellDuration.SetDateTimeSpan(0, 0, 30, 0);
  1955. }
  1956. m_dtMinStartTime = XTP_SAFE_GET2(pViewGroup, GetViewDay(), GetDayDate(), (DATE)0) +
  1957.    COleDateTimeSpan(1, 0, 0, 1) - m_spCellDuration;
  1958. //----------------------------------------------------
  1959. _Clear();
  1960. int nCount = pViewGroup->GetViewEventsCount();
  1961. for (int i = 0; i < nCount; i++)
  1962. {
  1963. CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
  1964. ASSERT(pViewEvent);
  1965. if (!pViewEvent || pViewEvent->IsMultidayEvent())
  1966. continue;
  1967. // Reset Events Paces
  1968. pViewEvent->SetEventPlacePos(XTP_EVENT_PLACE_POS_UNDEFINED);
  1969. pViewEvent->SetEventPlaceCount(1);
  1970. // Update X Data for each event
  1971. _UpdateDataFor(pViewEvent, pViewGroup);
  1972. }
  1973. // Update Events Paces using X Data
  1974. _UpdateEventsPaces(pViewGroup);
  1975. // Delete intermediate X data
  1976. _Clear();
  1977. }
  1978. void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_Clear()
  1979. {
  1980. m_mapEvToOverlapped.RemoveAll();
  1981. }
  1982. void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_UpdateDataFor(CXTPCalendarDayViewEvent* pViewEvent,
  1983. CXTPCalendarDayViewGroup* pViewGroup)
  1984. {
  1985. if (!pViewEvent || !pViewGroup || !pViewGroup->GetViewDay())
  1986. {
  1987. ASSERT(FALSE);
  1988. return;
  1989. }
  1990. COleDateTime dtStart = pViewEvent->GetEvent()->GetStartTime();
  1991. COleDateTime dtEnd = pViewEvent->GetEvent()->GetEndTime();
  1992. COleDateTime dtGroupDay = pViewGroup->GetViewDay()->GetDayDate();
  1993. if (dtStart < dtGroupDay)
  1994. {
  1995. dtStart = dtGroupDay;
  1996. ASSERT(dtStart <= dtEnd);
  1997. }
  1998. COleDateTimeSpan spEventDuration2 = dtEnd - dtStart;
  1999. // adjust end time if need
  2000. //if (pViewEvent->GetEvent()->GetDuration() < m_spCellDuration)
  2001. if (spEventDuration2 < m_spCellDuration)
  2002. {
  2003. dtEnd = dtStart + m_spCellDuration;
  2004. }
  2005. // adjust start time if need
  2006. if (dtStart > m_dtMinStartTime)
  2007. {
  2008. dtStart = m_dtMinStartTime;
  2009. }
  2010. //=====================================================
  2011. int nCount = pViewGroup->GetViewEventsCount();
  2012. for (int i = 0; i < nCount; i++)
  2013. {
  2014. CXTPCalendarDayViewEvent* pVEv_i = pViewGroup->GetViewEvent(i);
  2015. ASSERT(pVEv_i);
  2016. if (!pVEv_i || pVEv_i->IsMultidayEvent() || !pVEv_i->GetEvent())
  2017. continue;
  2018. COleDateTime dtStart_i = pVEv_i->GetEvent()->GetStartTime();
  2019. COleDateTime dtEnd_i = pVEv_i->GetEvent()->GetEndTime();
  2020. if (dtStart_i < dtGroupDay)
  2021. {
  2022. dtStart_i = dtGroupDay;
  2023. ASSERT(dtStart_i <= dtEnd_i);
  2024. }
  2025. COleDateTimeSpan spEventDuration2_i = dtEnd_i - dtStart_i;
  2026. // adjust end time if need
  2027. //if (pVEv_i->GetEvent()->GetDuration() < m_spCellDuration)
  2028. if (spEventDuration2_i < m_spCellDuration)
  2029. {
  2030. dtEnd_i = dtStart_i + m_spCellDuration;
  2031. }
  2032. // adjust start time if need
  2033. if (dtStart_i > m_dtMinStartTime)
  2034. {
  2035. dtStart_i = m_dtMinStartTime;
  2036. }
  2037. // is Overlapped
  2038. if (!(dtEnd_i < dtStart || dtStart_i > dtEnd ||
  2039.   CXTPCalendarUtils::IsEqual(dtEnd_i, dtStart) ||
  2040.   CXTPCalendarUtils::IsEqual(dtStart_i, dtEnd) )
  2041.    )
  2042. {
  2043. _XAddOverlapped(pViewEvent, pVEv_i);
  2044. }
  2045. }
  2046. }
  2047. void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_UpdateEventsPaces(CXTPCalendarDayViewGroup* pViewGroup)
  2048. {
  2049. UNREFERENCED_PARAMETER(pViewGroup);
  2050. // assign event places
  2051. int i;
  2052. int nCount = pViewGroup->GetViewEventsCount();
  2053. for (i = 0; i < nCount; i++)
  2054. {
  2055. CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
  2056. ASSERT(pViewEvent);
  2057. if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
  2058. continue;
  2059. ASSERT(pViewEvent->GetEventPlacePos() == XTP_EVENT_PLACE_POS_UNDEFINED);
  2060. if (pViewEvent->GetEventPlacePos() == XTP_EVENT_PLACE_POS_UNDEFINED)
  2061. {
  2062. CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
  2063. ASSERT(pMapOvr);
  2064. if (pMapOvr)
  2065. {
  2066. int nPlace = pMapOvr->GetMinFreeEventPlace();
  2067. ASSERT(nPlace >= 0 && nPlace != XTP_EVENT_PLACE_POS_UNDEFINED);
  2068. pViewEvent->SetEventPlacePos(nPlace);
  2069. }
  2070. }
  2071. }
  2072. // update event places count
  2073. for (i = 0; i < nCount; i++)
  2074. {
  2075. CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
  2076. ASSERT(pViewEvent);
  2077. if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
  2078. continue;
  2079. ASSERT(pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
  2080. if (pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED)
  2081. {
  2082. CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
  2083. ASSERT(pMapOvr);
  2084. if (pMapOvr)
  2085. {
  2086. int nPlaceMax = pMapOvr->GetMaxEventPlace();
  2087. ASSERT(nPlaceMax >= 0);
  2088. pViewEvent->SetEventPlaceCount(nPlaceMax + 1);
  2089. }
  2090. }
  2091. }
  2092. // update event places count to maximum from overlapped set
  2093. // TODO: update to recurrence
  2094. for (int k = 0; k < min(nCount, 3); k++)
  2095. {
  2096. for (i = 0; i < nCount; i++)
  2097. {
  2098. CXTPCalendarDayViewEvent* pViewEvent = pViewGroup->GetViewEvent(i);
  2099. ASSERT(pViewEvent);
  2100. if (!pViewEvent || pViewEvent->IsMultidayEvent() || !pViewEvent->GetEvent())
  2101. continue;
  2102. ASSERT(pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
  2103. if (pViewEvent->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED)
  2104. {
  2105. CViewEventsMap* pMapOvr = _XGetDataFor(pViewEvent);
  2106. ASSERT(pMapOvr);
  2107. if (pMapOvr)
  2108. {
  2109. int nPlaceCountMax = pMapOvr->GetMaxEventPlaceCountEx();
  2110. ASSERT(nPlaceCountMax >= pViewEvent->GetEventPlaceCount());
  2111. pViewEvent->SetEventPlaceCount(nPlaceCountMax);
  2112. }
  2113. }
  2114. }
  2115. }
  2116. }
  2117. CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap* CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::
  2118. _XGetDataFor(CXTPCalendarDayViewEvent* pViewEvent)
  2119. {
  2120. // CViewEventsMap* pVEvMap = NULL;
  2121. // to avoid warning C4786 CObject* used.
  2122. CObject* pVEvMap = NULL;
  2123. if (m_mapEvToOverlapped.Lookup(pViewEvent, pVEvMap) && pVEvMap)
  2124. {
  2125. return (CViewEventsMap*)pVEvMap;
  2126. }
  2127. // Create a new sub-data map
  2128. pVEvMap = new CViewEventsMap();
  2129. if (pVEvMap)
  2130. {
  2131. m_mapEvToOverlapped[pViewEvent] = pVEvMap;
  2132. }
  2133. return (CViewEventsMap*)pVEvMap;
  2134. }
  2135. void CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::_XAddOverlapped(
  2136. CXTPCalendarDayViewEvent* pVEv_base,
  2137. CXTPCalendarDayViewEvent* pVEv_overlapped)
  2138. {
  2139. CViewEventsMap* pVEvMap = _XGetDataFor(pVEv_base);
  2140. if (!pVEvMap) // no memory to create
  2141. return;
  2142. pVEvMap->SetAt(pVEv_overlapped, 0);
  2143. }
  2144. /////////////////////////////////////////////////////////////////////////////
  2145. CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::CViewEventsMap()
  2146. {
  2147. InitHashTable(XTP_CALENDAR_OFFICE2007_DVG_DEV_AVE_COUNT, FALSE);
  2148. }
  2149. int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMinFreeEventPlace()
  2150. {
  2151. int nMinFreeEventPlace = 0;
  2152. BOOL bBysy = FALSE;
  2153. do
  2154. {
  2155. bBysy = FALSE;
  2156. POSITION pos = GetStartPosition();
  2157. while (pos)
  2158. {
  2159. CXTPCalendarDayViewEvent* pVEv = NULL;
  2160. int nTmp = 0;
  2161. GetNextAssoc(pos, pVEv, nTmp);
  2162. if (pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED &&
  2163. pVEv->GetEventPlacePos() == nMinFreeEventPlace)
  2164. {
  2165. nMinFreeEventPlace++;
  2166. bBysy = TRUE;
  2167. break;
  2168. }
  2169. }
  2170. }
  2171. while (bBysy);
  2172. return nMinFreeEventPlace;
  2173. }
  2174. int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMaxEventPlace()
  2175. {
  2176. int nMaxEventPlace = 0;
  2177. POSITION pos = GetStartPosition();
  2178. while (pos)
  2179. {
  2180. CXTPCalendarDayViewEvent* pVEv = NULL;
  2181. int nTmp = 0;
  2182. GetNextAssoc(pos, pVEv, nTmp);
  2183. ASSERT(pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
  2184. if (pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED &&
  2185. pVEv->GetEventPlacePos() > nMaxEventPlace)
  2186. {
  2187. nMaxEventPlace = pVEv->GetEventPlacePos();
  2188. }
  2189. }
  2190. return nMaxEventPlace;
  2191. }
  2192. int CXTPCalendarTheme_DayViewSingleDayEventPlaceBuilder::CViewEventsMap::GetMaxEventPlaceCountEx()
  2193. {
  2194. int nMaxEventPlaceCount = 1;
  2195. POSITION pos = GetStartPosition();
  2196. while (pos)
  2197. {
  2198. CXTPCalendarDayViewEvent* pVEv = NULL;
  2199. int nTmp = 0;
  2200. GetNextAssoc(pos, pVEv, nTmp);
  2201. ASSERT(pVEv && pVEv->GetEventPlacePos() != XTP_EVENT_PLACE_POS_UNDEFINED);
  2202. if (pVEv && pVEv->GetEventPlaceCount() > nMaxEventPlaceCount)
  2203. {
  2204. nMaxEventPlaceCount = pVEv->GetEventPlaceCount();
  2205. }
  2206. }
  2207. return nMaxEventPlaceCount;
  2208. }
  2209. //////////////////////////////////////////////////////////////////////////
  2210. BOOL CXTPCalendarThemeOffice2007::CTODayViewDayGroup::IsSelected(CXTPCalendarViewGroup* pViewGroup)
  2211. {
  2212. if (!pViewGroup || !pViewGroup->GetViewDay_() || !pViewGroup->GetViewDay_()->GetView_())
  2213. {
  2214. ASSERT(FALSE);
  2215. return FALSE;
  2216. }
  2217. COleDateTime dtBegin;
  2218. COleDateTime dtEnd;
  2219. if (pViewGroup->GetViewDay_()->GetView_()->GetSelection(&dtBegin, &dtEnd))
  2220. {
  2221. COleDateTime dtDay = pViewGroup->GetViewDay_()->GetDayDate();
  2222. ASSERT(CXTPCalendarUtils::IsZeroTime(dtDay));
  2223. dtDay = CXTPCalendarUtils::ResetTime(dtDay);
  2224. COleDateTimeSpan spSel = dtBegin - dtEnd;
  2225. int nSelDays = abs(GETTOTAL_DAYS_DTS(spSel));
  2226. dtBegin = CXTPCalendarUtils::ResetTime(dtBegin);
  2227. int nCorrector = CXTPCalendarUtils::IsZeroTime(dtEnd) ? 0 : 1;
  2228. dtEnd = CXTPCalendarUtils::ResetTime(dtEnd) + COleDateTimeSpan(nCorrector, 0, 0, 0);
  2229. return nSelDays > 0 && dtBegin <= dtDay && dtDay < dtEnd;
  2230. }
  2231. return FALSE;
  2232. }
  2233. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::CalcEventYs(CRect& rrcRect, int nEventPlaceNumber)
  2234. {
  2235. CXTPCalendarDayView* pView = DYNAMIC_DOWNCAST(CXTPCalendarDayView, XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetDayView(), NULL));
  2236. if (!pView)
  2237. {
  2238. ASSERT(FALSE);
  2239. return;
  2240. }
  2241. CXTPCalendarDayView::XTP_DAY_VIEW_LAYOUT& rLayoutX = GetTheme()->GetDayViewLayout(pView);
  2242. int nAllDayEventHeight = rLayoutX.m_nAllDayEventHeight;
  2243. rrcRect.top = rLayoutX.m_rcAllDayEvents.top + nAllDayEventHeight * nEventPlaceNumber;
  2244. rrcRect.bottom = rrcRect.top + nAllDayEventHeight;
  2245. }
  2246. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::AdjustLayout(CCmdTarget* pObject, CDC* pDC,
  2247.  const CRect& rcRect, int nEventPlaceNumber)
  2248. {
  2249. UNREFERENCED_PARAMETER(rcRect);
  2250. CXTPCalendarDayViewEvent* pDayViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
  2251. CXTPCalendarDayView* pView = XTP_SAFE_GET3(pDayViewEvent, GetViewGroup(), GetViewDay(), GetView(), NULL);
  2252. CXTPCalendarEvent* pEvent = XTP_SAFE_GET1(pDayViewEvent, GetEvent(), NULL);
  2253. if (!pDC || !pDayViewEvent || !pView || !pEvent)
  2254. {
  2255. ASSERT(FALSE);
  2256. return;
  2257. }
  2258. if (!pDayViewEvent->IsMultidayEvent())
  2259. {
  2260. ASSERT(FALSE);
  2261. return;
  2262. }
  2263. //**********************
  2264. int nMDEFlags = pDayViewEvent->GetMultiDayEventFlags();
  2265. CalcEventYs(pDayViewEvent->m_rcEventMax, nEventPlaceNumber);
  2266. pDayViewEvent->m_rcEvent.CopyRect(&pDayViewEvent->m_rcEventMax);
  2267. pDayViewEvent->m_rcText.CopyRect(&pDayViewEvent->m_rcEventMax);
  2268. if ((nMDEFlags & xtpCalendarMultiDayFirst) != 0)
  2269. {
  2270. pDayViewEvent->m_rcEvent.left += 8;
  2271. }
  2272. if ((nMDEFlags & xtpCalendarMultiDayLast) != 0)
  2273. {
  2274. pDayViewEvent->m_rcEvent.right -= 8;
  2275. }
  2276. pDayViewEvent->m_rcText.CopyRect(pDayViewEvent->m_rcEvent);
  2277. }
  2278. void CXTPCalendarThemeOffice2007::CTODayViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
  2279. {
  2280. CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
  2281. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2282. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
  2283. {
  2284. ASSERT(FALSE);
  2285. return;
  2286. }
  2287. BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
  2288. int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
  2289. if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
  2290. {
  2291. return;// was drawn in the Master (or out of events rect)
  2292. }
  2293. CRect rcEventMax(pViewEvent->GetViewEventRectMax());
  2294. CRect rcEvent(pViewEvent->GetEventRect());
  2295. if (rcEvent.IsRectEmpty())
  2296. {
  2297. return;
  2298. }
  2299. // fill event background
  2300. BOOL bSelected = pViewEvent->IsSelected();
  2301. COLORREF clrBorderNotSel;
  2302. COLORREF clrBorder;
  2303. CXTPPaintManagerColorGradient grclrBk;
  2304. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
  2305. //----------------
  2306. pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
  2307. int nSelOffset = bSelected ? 2 : 1;
  2308. if (nMDEFlags & xtpCalendarMultiDayFirst)
  2309. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  2310.   rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
  2311. CRect rcText(rcEvent); //(pViewEvent->GetTextRect());
  2312. rcText.DeflateRect(3, 2, 3, 2);
  2313. BOOL bHideArrow = FALSE;
  2314. BOOL bHideArrowText = FALSE;
  2315. if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
  2316. {
  2317. rcText.left = rcEventMax.left;
  2318. CRect rcSQ = rcEventMax;
  2319. rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
  2320. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(1,1,0,1));
  2321. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  2322.   rcEvent.right - nSelOffset, grclrBk, 0, rcEvent.bottom - nSelOffset);
  2323. //---------------------------
  2324. CRect rcArrow;
  2325. BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
  2326. bHideArrow = !bArrow;
  2327. if (bArrow)
  2328. {
  2329. rcText.left = rcArrow.right;
  2330. }
  2331. if (bArrow && (nMDEFlags & xtpCalendarMultiDayLast) == 0)
  2332. {
  2333. CRect rcArrowText;
  2334. CThemeFontColorSetValue* pFCsetFromTo = bSelected ? &m_fcsetSelected.fcsetStartEnd : &m_fcsetNormal.fcsetStartEnd;
  2335. BOOL bArrowText = Draw_ArrowLtext(pViewEvent, pDC, pFCsetFromTo,
  2336.   rcArrowText, rcArrow.right);
  2337. bHideArrowText = !bArrowText;
  2338. if (bArrowText)
  2339. {
  2340. rcText.left = rcArrowText.right;
  2341. }
  2342. }
  2343. }
  2344. else if (bSelected)
  2345. {
  2346. // draw left Gripper
  2347. CRect rcGripper;
  2348. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  2349. rcGripper.bottom = rcGripper.top + cnGripperSize;
  2350. rcGripper.left = rcEvent.left - 1;
  2351. rcGripper.right = rcGripper.left + cnGripperSize;
  2352. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  2353. CBrush brBorder(m_clrGripperBorder);
  2354. pDC->FrameRect(&rcGripper, &brBorder);
  2355. }
  2356. if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
  2357. {
  2358. rcText.right = rcEventMax.right;
  2359. CRect rcSQ = rcEventMax;
  2360. rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
  2361. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,1,1));
  2362. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcSQ.left, rcEvent.top + nSelOffset),
  2363.   rcEventMax.right - nSelOffset, grclrBk, 0, INT_MAX, FALSE);
  2364. if (!bHideArrow)
  2365. {
  2366. CRect rcArrow;
  2367. BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
  2368. if (bArrow)
  2369. {
  2370. rcText.right = rcArrow.left;
  2371. }
  2372. if (bArrow && (nMDEFlags & xtpCalendarMultiDayFirst) == 0 && !bHideArrowText)
  2373. {
  2374. CRect rcArrowText;
  2375. CThemeFontColorSetValue* pFCsetFromTo = bSelected ? &m_fcsetSelected.fcsetStartEnd : &m_fcsetNormal.fcsetStartEnd;
  2376. BOOL bArrowText = Draw_ArrowRtext(pViewEvent, pDC, pFCsetFromTo,
  2377.   rcArrowText, rcArrow.left);
  2378. if (bArrowText)
  2379. {
  2380. rcText.right = rcArrowText.left;
  2381. }
  2382. }
  2383. }
  2384. }
  2385. else if (bSelected)
  2386. {
  2387. // draw right gripper
  2388. CRect rcGripper;
  2389. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  2390. rcGripper.bottom = rcGripper.top + cnGripperSize;
  2391. rcGripper.right = rcEvent.right + 1;
  2392. rcGripper.left = rcGripper.right - cnGripperSize;;
  2393. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  2394. CBrush brBorder(m_clrGripperBorder);
  2395. pDC->FrameRect(&rcGripper, &brBorder);
  2396. }
  2397. //=======================================================================
  2398. CString strSubj = pViewEvent->GetItemTextSubject();
  2399. CString strLoc = pViewEvent->GetItemTextLocation();
  2400. if (!strLoc.IsEmpty())
  2401. {
  2402. strSubj += _T(";");
  2403. }
  2404. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  2405. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  2406. //rcText.DeflateRect(3, 2, 3, 2);
  2407. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  2408. //pViewEvent->AdjustSubjectEditorEx(FALSE);
  2409. pViewEvent->AdjustSubjectEditor();
  2410. CRect rcIconsMax = rcText;
  2411. //
  2412. BOOL bMarkupDrawn = FALSE;
  2413. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  2414. {
  2415. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  2416. ASSERT(pMarkupContext);
  2417. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  2418. if (pUIElement && pMarkupContext)
  2419. {
  2420. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2421. if (rcIconsMax.Height() > szIcons.cy)
  2422. {
  2423. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  2424. }
  2425. rcText.right = max(rcText.left,  rcText.right - szIcons.cx - 2);
  2426. //---------------------------------------------------------------
  2427. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  2428. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  2429. bMarkupDrawn = TRUE;
  2430. }
  2431. }
  2432. //
  2433. //--- calculate rects and fix to be centered if enough space ---
  2434. if (!bMarkupDrawn)
  2435. {
  2436. UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
  2437. CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2438. rcText, uTextShortAlign | DT_CALCRECT);
  2439. rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
  2440. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2441. if (rcIconsMax.Height() > szIcons.cy)
  2442. {
  2443. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  2444. }
  2445. int nTIcx = szText.cx + szIcons.cx;
  2446. if (nTIcx + 5 < rcText.Width())
  2447. {
  2448. int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
  2449. rcText.left += ncx_2;
  2450. rcText.right = rcText.left + szText.cx + 2;
  2451. rcIconsMax.right -= ncx_2;
  2452. }
  2453. else
  2454. {
  2455. rcText.right -= szIcons.cx + 2;
  2456. }
  2457. //- Draw ================================
  2458. pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2459. rcText, uTextShortAlign);
  2460. }
  2461. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  2462. // TODO:
  2463. /*
  2464. BOOL bOutOfBorders = nY_need > rcText.Height() ||
  2465.  nX_need > rcText.Width() ||
  2466.  bTimeOutOfBorders;
  2467. pViewEvent->SetTextOutOfBorders(bOutOfBorders);
  2468. */
  2469. }
  2470. void CXTPCalendarThemeOffice2007::CTOEvent::FillEventBackgroundEx(CDC* pDC,
  2471. CXTPCalendarViewEvent* pViewEvent, const CRect& rcRect)
  2472. {
  2473. if (!pDC || !pViewEvent)
  2474. {
  2475. ASSERT(FALSE);
  2476. return;
  2477. }
  2478. CRect rcEventFull = pViewEvent->GetEventRect();
  2479. COLORREF clrBorderNotSel;
  2480. COLORREF clrBorder;
  2481. CXTPPaintManagerColorGradient grclrBk;
  2482. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
  2483. if (pDC->IsPrinting())
  2484. {
  2485. CXTPCalendarTheme::DrawRectPartly(pDC, rcRect, 0, FALSE, grclrBk, CRect(0, 0, 0, 0));
  2486. }
  2487. else
  2488. {
  2489. XTPDrawHelpers()->GradientFill(pDC, &rcEventFull, grclrBk, FALSE, &rcRect);
  2490. }
  2491. }
  2492. void CXTPCalendarThemeOffice2007::CTOEvent::GetEventColors(CDC* pDC, CXTPCalendarViewEvent* pViewEvent,
  2493. COLORREF& rClrBorder, COLORREF& rClrBorderNotSel, CXTPPaintManagerColorGradient& rGrclrBk,
  2494. BOOL bSelected, int* pnColorsSrc_1Cat2Lbl)
  2495. {
  2496. rClrBorderNotSel = m_fcsetNormal.clrBorder;
  2497. rClrBorder = m_fcsetNormal.clrBorder;
  2498. rGrclrBk = m_fcsetNormal.grclrBackground;
  2499. if (!pViewEvent || !pViewEvent->GetEvent())
  2500. {
  2501. ASSERT(FALSE);
  2502. return;
  2503. }
  2504. if (bSelected == -1)
  2505. {
  2506. bSelected = pViewEvent->IsSelected();
  2507. }
  2508. rClrBorder = bSelected ? m_fcsetSelected.clrBorder : m_fcsetNormal.clrBorder;
  2509. rGrclrBk = bSelected ? m_fcsetSelected.grclrBackground : m_fcsetNormal.grclrBackground;
  2510. CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
  2511. CXTPCalendarEventCategoryIDs* pCategoryIDs = pEvent->GetCategories();
  2512. CXTPCalendarEventLabel* ptrLabel = pEvent->GetLabel();
  2513. if (pnColorsSrc_1Cat2Lbl)
  2514. *pnColorsSrc_1Cat2Lbl = 0;
  2515. if (pCategoryIDs && pCategoryIDs->GetSize())
  2516. {
  2517. UINT nCatID_0 = pCategoryIDs->GetAt(0);
  2518. CXTPCalendarEventCategories* pCategories = pEvent->GetDataProvider()->GetEventCategories();
  2519. if (pCategories)
  2520. {
  2521. CXTPCalendarEventCategory* pCat = pCategories->Find(nCatID_0);
  2522. if (pCat)
  2523. {
  2524. rGrclrBk.SetCustomValue(pCat->GetBackgroundColor());
  2525. if (XTPDrawHelpers()->IsLowResolution(pDC->GetSafeHdc()))
  2526. rGrclrBk.SetCustomValue(pCat->GetBackgroundColor().clrDark);
  2527. rClrBorderNotSel = pCat->GetBorderColor();
  2528. if (!bSelected)
  2529. rClrBorder = rClrBorderNotSel;
  2530. if (pnColorsSrc_1Cat2Lbl)
  2531. *pnColorsSrc_1Cat2Lbl = 1;
  2532. }
  2533. }
  2534. }
  2535. else if (ptrLabel && ptrLabel->m_nLabelID != XTP_CALENDAR_NONE_LABEL_ID)
  2536. {
  2537. COLORREF crBkLight = XTPDrawHelpers()->LightenColor(120, ptrLabel->m_clrColor);
  2538. COLORREF crBkDark = XTPDrawHelpers()->DarkenColor(20, ptrLabel->m_clrColor);
  2539. if (XTPDrawHelpers()->IsLowResolution(pDC->GetSafeHdc()))
  2540. crBkLight = crBkDark = ptrLabel->m_clrColor;
  2541. rGrclrBk.SetCustomValue(crBkLight, crBkDark);
  2542. rClrBorderNotSel = XTPDrawHelpers()->DarkenColor(88, ptrLabel->m_clrColor);
  2543. if (!bSelected)
  2544. rClrBorder = rClrBorderNotSel;
  2545. if (pnColorsSrc_1Cat2Lbl)
  2546. *pnColorsSrc_1Cat2Lbl = 2;
  2547. }
  2548. }
  2549. void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
  2550. {
  2551. CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
  2552. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2553. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
  2554. !pViewEvent->GetViewGroup() || !pThemeX->GetCalendarControl())
  2555. {
  2556. ASSERT(FALSE);
  2557. return;
  2558. }
  2559. BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
  2560. int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
  2561. if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
  2562. {
  2563. return;// was drawn in the Master (or out of events rect)
  2564. }
  2565. CRect rcEvent(pViewEvent->GetEventRect());
  2566. CRect rcTimeframe(pViewEvent->m_rcTimeframe);
  2567. if (rcEvent.IsRectEmpty())
  2568. {
  2569. return;
  2570. }
  2571. // ----- Fill event background -----
  2572. int nTopRow = pViewEvent->GetViewGroup()->GetTopRow();
  2573. CRect rcTopRow = pViewEvent->GetViewGroup()->GetCellRect(nTopRow);
  2574. BOOL bShortEvent = rcTimeframe.Height() + 1 < rcTopRow.Height();
  2575. BOOL bSelected = pViewEvent->IsSelected();
  2576. COLORREF clrBorderNotSel;
  2577. COLORREF clrBorder;
  2578. CXTPPaintManagerColorGradient grclrBk;
  2579. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
  2580. // --- Calculate event rectangle ---
  2581. CRect rcEventX(rcEvent);
  2582. if (bShortEvent)
  2583. {
  2584. rcEventX.left += 5;
  2585. }
  2586. // ------ Draw Event Border ------
  2587. pThemeX->DrawRoundRect(pDC, rcEventX, clrBorder, bSelected, grclrBk);
  2588. // -------- Draw Event Contents --------
  2589. CRect rcText(rcEventX);
  2590. rcText.left += 2;
  2591. int nSelOffset = bSelected ? 2 : 1;
  2592. int nBusyStatus = pViewEvent->GetEvent()->GetBusyStatus();
  2593. CBrush* pBSBrush = GetBusyStatusBrush(nBusyStatus);
  2594. if (!bShortEvent)
  2595. {
  2596. if (pBSBrush)
  2597. {
  2598. CRect rcBS = rcEvent;
  2599. rcBS.right = min(rcBS.left + 12, rcEvent.right);
  2600. CXTPTextDC autoText(pDC, clrBorderNotSel, RGB(255, 255, 255));
  2601. pThemeX->DrawRoundRect(pDC, rcBS, clrBorder, bSelected, pBSBrush);
  2602. rcBS.right++;
  2603. rcBS.left = min(rcBS.left + 5, rcBS.right);
  2604. CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, bSelected, grclrBk, CRect(0, 1, 0, 1));
  2605. rcBS.right = rcBS.left + 1;
  2606. pDC->FillSolidRect(&rcBS, clrBorder);
  2607. rcText.left = rcEvent.left + 6;
  2608. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcText.left, rcEvent.top + nSelOffset),
  2609.   rcEvent.right - nSelOffset, grclrBk);
  2610. }
  2611. else
  2612. {
  2613. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  2614.   rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
  2615. }
  2616. }
  2617. else
  2618. {
  2619. CRect rcBS = rcEvent;
  2620. rcBS.right = rcEventX.left + 6;
  2621. CRect rcBSfull = rcBS;
  2622. rcBS.bottom = rcTimeframe.bottom;
  2623. // draw BK's
  2624. if (pDC->IsPrinting())
  2625. {
  2626. CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, 0, FALSE, grclrBk, CRect(0, 0, 0, 0));
  2627. }
  2628. else
  2629. {
  2630. XTPDrawHelpers()->GradientFill(pDC, &rcBSfull, grclrBk, FALSE, &rcBS);
  2631. }
  2632. if (pBSBrush)
  2633. {
  2634. CRect rcBSfill = rcBS;
  2635. rcBSfill.right = rcEventX.left;
  2636. CXTPTextDC autoText(pDC, clrBorderNotSel, RGB(255, 255, 255));
  2637. pDC->FillRect(&rcBSfill, pBSBrush);
  2638. }
  2639. // draw borders
  2640. int nBorderWidth = bSelected ? 2 : 1;
  2641. CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, nBorderWidth, CRect(1, 1, 0, 0));
  2642. rcBS.right = rcEventX.left + 1;
  2643. rcBS.top += nBorderWidth;
  2644. if (pBSBrush)
  2645. {
  2646. CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorderNotSel, 1, CRect(0, 0, 1, 0));
  2647. }
  2648. rcBS.right += bSelected ? 1 : 0;
  2649. CXTPCalendarTheme::DrawRectPartly(pDC, rcBS, clrBorder, nBorderWidth, CRect(0, 0, 0, 1));
  2650. rcText.left = rcEventX.left;
  2651. if (pBSBrush)
  2652. {
  2653. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEventX.left + 1, rcEvent.top + nSelOffset),
  2654.   rcEvent.right - nSelOffset, grclrBk);
  2655. }
  2656. else
  2657. {
  2658. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  2659.   rcEvent.right - nSelOffset, grclrBk, 0, rcTimeframe.bottom - nSelOffset);
  2660. }
  2661. }
  2662. // ----- Draw Grippers for selected events -----
  2663. if (bSelected)
  2664. {
  2665. CBrush brBorder(m_clrGripperBorder);
  2666. CRect rcGripper;
  2667. rcGripper.left = rcEvent.left + rcEvent.Width() / 2 - cnGripperSize / 2;
  2668. rcGripper.right = rcGripper.left + cnGripperSize;
  2669. // draw top Gripper
  2670. rcGripper.top = rcEvent.top - 1; //cnGripperSize / 2 + 1;
  2671. rcGripper.bottom = rcGripper.top + cnGripperSize;
  2672. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  2673. pDC->FrameRect(&rcGripper, &brBorder);
  2674. // draw bottom Gripper
  2675. rcGripper.bottom = rcEvent.bottom + 1; //cnGripperSize / 2 - 1;
  2676. rcGripper.top = rcGripper.bottom - cnGripperSize;
  2677. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  2678. pDC->FrameRect(&rcGripper, &brBorder);
  2679. }
  2680. // ===== Process Markup Drawing =====
  2681. rcText.DeflateRect(3, 3, 3, 3);
  2682. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject  : &m_fcsetNormal.fcsetSubject;
  2683. BOOL bMarkupDrawn = FALSE;
  2684. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  2685. {
  2686. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  2687. ASSERT(pMarkupContext);
  2688. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  2689. if (pUIElement && pMarkupContext)
  2690. {
  2691. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  2692. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  2693. bMarkupDrawn = TRUE;
  2694. }
  2695. }
  2696. ///////////////////////////////
  2697. // ----- Draw event Icons -----
  2698. CRect rcIconsMax = rcText;
  2699. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2700. if (rcIconsMax.Height() >= rcTopRow.Height())
  2701. {
  2702. rcIconsMax.bottom -= 4;
  2703. }
  2704. else
  2705. {
  2706. if (rcTopRow.Height() - 4 > szIcons.cy)
  2707. {