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

对话框与窗口

开发平台:

Visual C++

  1. rcIconsMax.bottom = rcIconsMax.top + rcIconsMax.Height()/2 + szIcons.cy/2;
  2. }
  3. rcIconsMax.left = min(rcIconsMax.left + rcTopRow.Height(), rcIconsMax.right);
  4. rcText.right = max(rcText.right - szIcons.cx - 2, rcText.left + rcTopRow.Height() - 2);
  5. }
  6. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  7. //pViewEvent->AdjustSubjectEditorEx(FALSE);
  8. pViewEvent->AdjustSubjectEditor();
  9. if (!bMarkupDrawn)
  10. {
  11. CString strSubj = pViewEvent->GetItemTextSubject();
  12. CString strLoc = pViewEvent->GetItemTextLocation();
  13. CString strBody = pViewEvent->GetItemTextBody();
  14. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  15. CThemeFontColorSet* pFntClr3 = bSelected ? &m_fcsetSelected.fcsetBody     : &m_fcsetNormal.fcsetBody;
  16. //------------------------------------------------------------
  17. UINT uWordBreakMode = DT_WORDBREAK;
  18. DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
  19. if (dwOpt & xtpCalendarOptDayViewNoWordBreak)
  20. uWordBreakMode = DT_WORD_ELLIPSIS;
  21. pThemeX->DrawText_Auto2SL3ML(pDC, strSubj, strLoc, strBody,
  22.  pFntClr1, pFntClr2, pFntClr3, rcText, _T(";"), uWordBreakMode);
  23. }
  24. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  25. /*
  26. BOOL bOutOfBorders = nY_need > rcText.Height() ||
  27.  nX_need > rcText.Width() ||
  28.  bTimeOutOfBorders;
  29. pViewEvent->SetTextOutOfBorders(bOutOfBorders);
  30. */
  31. }
  32. void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::DrawShadow(CDC* pDC, CXTPCalendarDayViewEvent* pViewEvent)
  33. {
  34. ASSERT(pDC && pViewEvent);
  35. if (!pDC || pDC->IsPrinting() || !pViewEvent)
  36. return;
  37. CRect rcEvent(pViewEvent->GetEventRect());
  38. CRect rcTimeframe(pViewEvent->m_rcTimeframe);
  39. if (rcEvent.IsRectEmpty())
  40. {
  41. return;
  42. }
  43. // ----- Fill event background -----
  44. int nTopRow = pViewEvent->GetViewGroup()->GetTopRow();
  45. CRect rcTopRow = pViewEvent->GetViewGroup()->GetCellRect(nTopRow);
  46. BOOL bShortEvent = rcTimeframe.Height() + 1 < rcTopRow.Height();
  47. // --- Calculate event rectangle ---
  48. CRect rcRect(rcEvent);
  49. if (bShortEvent)
  50. rcRect.left += 5;
  51. //------------------------------------------------------------------------
  52. CXTPCalendarPaintManager::CXTPShadowDrawer oShadow(pDC, dXTPMaxAlpha2007);
  53. CRect rcVShadow(rcRect);
  54. rcVShadow.left = rcVShadow.right;
  55. rcVShadow.right += 5;
  56. rcVShadow.top += 5*2 + 1;
  57. oShadow.DrawShadowRectPart(rcVShadow, oShadow.xtpShadow2007Right);
  58. CRect rcHShadow(rcRect);
  59. rcHShadow.left += 5*2;
  60. rcHShadow.top = rcHShadow.bottom;
  61. rcHShadow.bottom += 5;
  62. oShadow.DrawShadowRectPart(rcHShadow, oShadow.xtpShadow2007Bottom);
  63. CRect rcTRShadow(rcVShadow);
  64. rcTRShadow.bottom = rcTRShadow.top;
  65. rcTRShadow.top -= 6;
  66. oShadow.DrawShadowRectPart(rcTRShadow, oShadow.xtpShadow2007TopRight);
  67. CRect rcBLShadow(rcHShadow);
  68. rcBLShadow.right = rcBLShadow.left;
  69. rcBLShadow.left -= 5;
  70. oShadow.DrawShadowRectPart(rcBLShadow, oShadow.xtpShadow2007BottomLeft);
  71. CRect rcBRShadow(rcVShadow.left - 3, rcHShadow.top - 3, rcVShadow.right, rcHShadow.bottom);
  72. oShadow.DrawShadowRectPart(rcBRShadow, oShadow.xtpShadow2007BottomRight);
  73. }
  74. void CXTPCalendarThemeOffice2007::_DrawEventLTHighlight(CDC* pDC, CPoint ptLT, int nRTx, const CXTPPaintManagerColorGradient& grclrBk,
  75. int nLTCorner, int nLBy, BOOL bRCorner)
  76. {
  77. COLORREF clrTop = XTPDrawHelpers()->LightenColor(120, grclrBk.clrLight);
  78. CRect rcTop(ptLT.x + nLTCorner, ptLT.y, nRTx, ptLT.y + 1);
  79. if (bRCorner)
  80. rcTop.right -= cnCornerSize / 2 + 1;
  81. pDC->FillSolidRect(&rcTop, clrTop);
  82. if(nLBy != INT_MAX)
  83. {
  84. CRect rcLLVert(ptLT.x, ptLT.y + nLTCorner, ptLT.x + 1, nLBy - nLTCorner);
  85. rcLLVert.top += nLTCorner ? 0 : 1;
  86. COLORREF clrLight = XTPDrawHelpers()->LightenColor(76, grclrBk.clrLight);
  87. COLORREF clrDrak = XTPDrawHelpers()->LightenColor(15, grclrBk.clrDark);
  88. XTPDrawHelpers()->GradientFill(pDC, rcLLVert, clrLight, clrDrak, FALSE);
  89. CPen pen(PS_SOLID, 1, clrLight);
  90. CXTPPenDC autoPen(pDC, &pen);
  91. pDC->MoveTo(rcLLVert.TopLeft());
  92. pDC->LineTo(rcTop.TopLeft());
  93. }
  94. if (bRCorner)
  95. {
  96. COLORREF clrLight2 = XTPDrawHelpers()->LightenColor(80, grclrBk.clrLight);
  97. CPen pen(PS_SOLID, 1, clrLight2);
  98. CXTPPenDC autoPen(pDC, &pen);
  99. pDC->MoveTo(rcTop.right, rcTop.top);
  100. pDC->LineTo(rcTop.right + cnCornerSize / 2 + 1, rcTop.top + cnCornerSize / 2 + 1);
  101. }
  102. }
  103. void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::InitBusyStatusDefaultColors()
  104. {
  105. TBase2::InitBusyStatusDefaultColors();
  106. SetBusyStatusBrush(xtpCalendarBusyStatusBusy, NULL, FALSE);
  107. // Tentative ---------------------------
  108. m_bmpTentativePattern.DeleteObject();
  109. m_brushTentative.DeleteObject();
  110. VERIFY(XTPResourceManager()->LoadBitmap(&m_bmpTentativePattern, XTP_IDB_CALENDAR_TENATIVE_PATTERN_2007));
  111. VERIFY(m_brushTentative.CreatePatternBrush(&m_bmpTentativePattern));
  112. CXTPCalendarViewPartBrushValue* pBVal_Tentative = _GetBusyStatusBrushValue(xtpCalendarBusyStatusTentative, TRUE);
  113. if (pBVal_Tentative)
  114. {
  115. pBVal_Tentative->SetStandardValue(&m_brushTentative, FALSE);
  116. }
  117. }
  118. void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::AdjustLayout(CCmdTarget* pObject,
  119. CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
  120. {
  121. UNREFERENCED_PARAMETER(nEventPlaceNumber);
  122. CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
  123. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  124. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() || !pViewEvent->GetViewGroup() ||
  125. !pViewEvent->GetViewGroup()->GetViewDay())
  126. {
  127. ASSERT(FALSE);
  128. return;
  129. }
  130. CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
  131. CXTPCalendarDayViewGroup* pViewGroup = pViewEvent->GetViewGroup();
  132. CXTPCalendarDayViewDay* pViewDay = pViewGroup->GetViewDay();
  133. pViewEvent->m_nMultiDayEventFlags |= xtpCalendarMultiDayNoMultiDay;
  134. // non all-day event
  135. int nPace = pViewEvent->GetEventPlacePos();
  136. int nPaceCount = max(1, pViewEvent->GetEventPlaceCount());
  137. ASSERT(pViewEvent->GetEventPlaceCount() >= 1);
  138. ASSERT(nPace >= 0 && nPace < nPaceCount);
  139. pViewEvent->m_rcEvent.CopyRect(rcRect);
  140. int nEventsAreaX = pViewEvent->m_rcEvent.Width() - 5;
  141. int nEventWidth = nEventsAreaX / nPaceCount;
  142. // skip event views if they are not fit even by 5 pixel bar width
  143. // and correct some first event views heights
  144. if (nEventWidth <= 5)
  145. {
  146. while (nPaceCount > 1 && nEventWidth <= 5)
  147. {
  148. nPaceCount--;
  149. nEventWidth = nEventsAreaX / nPaceCount;
  150. }
  151. if (nPace > nPaceCount)
  152. {
  153. pViewEvent->m_rcEvent.SetRectEmpty();
  154. return;
  155. }
  156. }
  157. // calc other rect coordinates
  158. pViewEvent->m_rcEvent.left += nEventWidth * nPace;
  159. pViewEvent->m_rcEvent.right = pViewEvent->m_rcEvent.left + nEventWidth;
  160. //-------------------------------------------------------------------
  161. COleDateTime dtStartTime(pEvent->GetStartTime());
  162. COleDateTime dtEndTime(pEvent->GetEndTime());
  163. int nTopRow = pViewGroup->GetTopRow();
  164. CRect rcTopRow = pViewGroup->GetCellRect(nTopRow);
  165. CRect rcRow0 = pViewGroup->GetCellRect(0);
  166. CRect rcRowLast = pViewGroup->GetCellRect(pViewGroup->GetRowCount()-1);
  167. COleDateTime dtTopRowTime = pViewDay->GetView()->GetCellTime(nTopRow);
  168. dtTopRowTime = (double)pViewDay->GetDayDate() + (double)dtTopRowTime;
  169. double dblCellDur = (double)pViewDay->GetView()->GetCellDuration();
  170. if (dblCellDur <= XTP_HALF_SECOND)
  171. {
  172. dblCellDur = XTP_HALF_SECOND * 2 * 60 * 30;
  173. }
  174. double dblEventOffsetTime1 = double(dtStartTime - dtTopRowTime);
  175. double dblEventOffsetTime2 = double(dtEndTime - dtTopRowTime);
  176. double dblPixelPerTime = rcTopRow.Height() / dblCellDur;
  177. int nEventY1 = int(dblPixelPerTime * dblEventOffsetTime1);
  178. nEventY1 = max(rcRow0.top,  rcTopRow.top + nEventY1);
  179. nEventY1 = min(rcRowLast.top, nEventY1);
  180. int nEventY2 = int(dblPixelPerTime * dblEventOffsetTime2);
  181. nEventY2 = rcTopRow.top + nEventY2;
  182. nEventY2 = min(rcRowLast.bottom, nEventY2);
  183. int nEvent_dy = nEventY2 - nEventY1;
  184. BOOL bShortEvent = nEvent_dy + 1 < rcTopRow.Height();
  185. nEvent_dy = max(5, nEvent_dy);
  186. if (bShortEvent)
  187. {
  188. nEventY2 = nEventY1 + rcTopRow.Height();
  189. }
  190. ///%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  191. pViewEvent->m_rcEvent.top = nEventY1;
  192. pViewEvent->m_rcEvent.bottom = nEventY2;
  193. pViewEvent->m_rcEventMax.top = max(pViewEvent->m_rcEvent.top-5, rcRect.top);
  194. pViewEvent->m_rcEventMax.bottom = min(pViewEvent->m_rcEvent.bottom + 5, rcRect.bottom);
  195. // adjust subject area
  196. pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
  197. pViewEvent->m_rcText.left += 10; // correct to busy area
  198. pViewEvent->m_rcText.left += 4;
  199. pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcText);
  200. // Set time frame rect
  201. pViewEvent->m_rcTimeframe.top = pViewEvent->m_rcEvent.top;
  202. pViewEvent->m_rcTimeframe.bottom = pViewEvent->m_rcTimeframe.top + nEvent_dy;
  203. pViewEvent->m_rcTimeframe.left = pViewEvent->m_rcEvent.left + 1;
  204. pViewEvent->m_rcTimeframe.right = pViewEvent->m_rcTimeframe.left + 4;
  205. // set expanded signs for day view
  206. CRect rcEvents = rcRect;
  207. if (pViewEvent->m_rcEvent.top >= rcEvents.bottom-10)
  208. pViewEvent->GetViewGroup()->SetExpandDown();
  209. if (pViewEvent->m_rcEvent.bottom <= rcEvents.top + 10)
  210. pViewEvent->GetViewGroup()->SetExpandUp();
  211. }
  212. /////////////////////////////////////////////////////////////////////////////
  213. //
  214. // ***** Month View *****
  215. //
  216. void CXTPCalendarThemeOffice2007::CTOMonthView::RefreshMetrics(BOOL bRefreshChildren)
  217. {
  218. TBase::RefreshMetrics(bRefreshChildren);
  219. }
  220. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent::RefreshMetrics(BOOL bRefreshChildren)
  221. {
  222. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  223. ASSERT(pThemeX);
  224. if (!pThemeX)
  225. {
  226. return;
  227. }
  228. TBase::RefreshMetrics(bRefreshChildren);
  229. RefreshFromParent(pThemeX->GetEventPartX());
  230. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
  231. XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, FALSE, FALSE, FALSE, FALSE) );
  232. }
  233. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
  234. {
  235. UNREFERENCED_PARAMETER(bRefreshChildren);
  236. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  237. ASSERT(pThemeX);
  238. if (!pThemeX)
  239. {
  240. return;
  241. }
  242. RefreshFromParent(pThemeX->GetMonthViewPartX()->GetEventPartX());
  243. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
  244. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
  245.    pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto)   );
  246. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
  247. m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
  248. //---------------------------------
  249. m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
  250. m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
  251. m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
  252. m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
  253. }
  254. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
  255. {
  256. UNREFERENCED_PARAMETER(bRefreshChildren);
  257. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  258. ASSERT(pThemeX);
  259. if (!pThemeX)
  260. {
  261. return;
  262. }
  263. RefreshFromParent(pThemeX->GetMonthViewPartX()->GetEventPartX());
  264. CFont* pFontDef = pThemeX->m_fntBaseFont;
  265. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBorder));
  266. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRfrom),
  267.    pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRto) );
  268. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventSelectedBorder));
  269. m_fcsetSelected.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRfrom),
  270.  pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRto) );
  271. //----------------------------------------------
  272. pThemeX->RemoveBoldAttrFromStd(m_fcsetNormal.fcsetSubject.fntFont);
  273. pThemeX->RemoveBoldAttrFromStd(m_fcsetSelected.fcsetSubject.fntFont);
  274. //----------------------------------------------
  275. m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewEventTime));
  276. m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
  277. m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewEventTime));
  278. m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
  279. }
  280. int CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::CalcWidth(CDC* pDC)
  281. {
  282. return CalcHeight(pDC, -1);
  283. }
  284. void CXTPCalendarThemeOffice2007::CTOMonthView::AdjustLayout(CDC* pDC, const CRect& rcRect, BOOL bCallPostAdjustLayout)
  285. {
  286. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView,
  287. XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetMonthView(), NULL));
  288. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  289. if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
  290. {
  291. ASSERT(FALSE);
  292. return;
  293. }
  294. int nWHeaderWidth = GetWeekHeaderPartX()->CalcWidth(pDC);
  295. CRect rcRectWHeader = rcRect;
  296. rcRectWHeader.right = min(rcRectWHeader.left + nWHeaderWidth, rcRect.right);
  297. GetWeekHeaderPartX()->AdjustLayout(pMonthView, pDC, rcRectWHeader);
  298. CRect rcRectGrid = rcRect;
  299. rcRectGrid.left = rcRectWHeader.right;
  300. TBase::AdjustLayout(pDC, rcRectGrid, bCallPostAdjustLayout);
  301. if (pThemeX->GetPrevNextEventControllerPartX())
  302. pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRectGrid);
  303. }
  304. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent::AdjustLayout(CCmdTarget* pObject,
  305.   CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
  306. {
  307. CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
  308. if (!pDC || !GetTheme() || !pViewEvent || !pViewEvent->GetEvent())
  309. {
  310. ASSERT(FALSE);
  311. return;
  312. }
  313. int nEventHeight = XTP_SAFE_GET4(pViewEvent, GetViewGroup(), GetViewDay(), GetView(), GetRowHeight(), 0);
  314. pViewEvent->m_rcEventMax.top = rcRect.top + nEventPlaceNumber * nEventHeight;
  315. pViewEvent->m_rcEventMax.bottom = pViewEvent->m_rcEventMax.top + nEventHeight;
  316. pViewEvent->m_rcEvent.top = pViewEvent->m_rcEventMax.top;
  317. pViewEvent->m_rcEvent.bottom = pViewEvent->m_rcEventMax.bottom;
  318. pViewEvent->m_rcEvent.left = pViewEvent->m_rcEventMax.left + 4 + 2;
  319. pViewEvent->m_rcEvent.right = pViewEvent->m_rcEventMax.right - 5 - 2;
  320. pViewEvent->m_rcToolTip.CopyRect(pViewEvent->m_rcEventMax);
  321. // adjust subject area
  322. int nDyx = pViewEvent->IsSelected() ? 5 : 2;
  323. pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
  324. pViewEvent->m_rcText.DeflateRect(nDyx + 3, 3, nDyx + 2, 3);
  325. // set times rects
  326. pViewEvent->m_rcStartTime.SetRectEmpty();
  327. pViewEvent->m_rcEndTime.SetRectEmpty();
  328. pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcEvent);
  329. pViewEvent->m_rcSubjectEditor.top++;
  330. pViewEvent->m_rcSubjectEditor.bottom--;
  331. }
  332. void CXTPCalendarThemeOffice2007::CTOMonthView::Draw(CDC* pDC)
  333. {
  334. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  335. ASSERT(pThemeX);
  336. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView,
  337. XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetMonthView(), NULL));
  338. if (!pDC || !pMonthView || !pThemeX)
  339. {
  340. ASSERT(FALSE);
  341. return;
  342. }
  343. pDC->SetBkMode(TRANSPARENT);
  344. GetWeekHeaderPartX()->Draw(pMonthView, pDC);
  345. //TBase::Draw(pDC);
  346. GetWeekDayHeaderPart()->Draw(pMonthView, pDC);
  347. //CXTPPropsStateContext autoStateCnt1_day(GetDayPart(), xtpCalendarBeforeDraw_MonthViewDay, TRUE);
  348. CXTPPropsStateContext autoStateCnt1_day(GetDayPart(), 0, TRUE);
  349. //-- Draw Days with events ------------------------------
  350. int nCount = pMonthView->GetViewDayCount();
  351. int i;
  352. for (i = nCount - 1; i >= 0; i--)
  353. {
  354. CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetViewDay(i);
  355. ASSERT(pViewDay);
  356. if (pViewDay)
  357. {
  358. GetDayPartX()->SetDynColors(pViewDay);
  359. autoStateCnt1_day.SendBeforeDrawThemeObject((LPARAM)pViewDay, xtpCalendarBeforeDraw_MonthViewDay);
  360. GetDayPart()->Draw(pViewDay, pDC);
  361. autoStateCnt1_day.RestoreState();
  362. }
  363. }
  364. autoStateCnt1_day.Clear();
  365. if (pThemeX->GetPrevNextEventControllerPartX())
  366. pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
  367. // All saved data must be freed after draw!
  368. ASSERT(CXTPPropsState::s_dbg_nActiveStates == 0);
  369. }
  370. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::RefreshMetrics(BOOL bRefreshChildren)
  371. {
  372. UNREFERENCED_PARAMETER(bRefreshChildren);
  373. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  374. ASSERT(pThemeX);
  375. if (!pThemeX)
  376. {
  377. return;
  378. }
  379. RefreshFromParent(pThemeX->GetHeaderPartX());
  380. m_clrBaseColor.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekDayHeaderBk"), RGB(227, 239, 255)));
  381. m_bkNormal.nBitmapID.       SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
  382. m_bkSelected.nBitmapID.     SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
  383. m_bkToday.nBitmapID.        SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
  384. m_bkTodaySelected.nBitmapID.SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
  385. m_TextCenter.fcsetNormal.clrColor.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekDayHeaderText"), RGB(101, 147, 201)));
  386. // 0 - Sunday, 1 - Monday, ...; 7 - Sat/Sun
  387. m_arWeekDayNamesLong.RemoveAll();
  388. m_arWeekDayNamesShort.RemoveAll();
  389. m_arWeekDayNamesLong.SetSize(8);
  390. m_arWeekDayNamesShort.SetSize(8);
  391. for (int i = 0; i < 7; i++)
  392. {
  393. CString sWDlong = CXTPCalendarUtils::GetLocaleString(LOCALE_SDAYNAME1 + i, 100);
  394. CString sWDshort = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVDAYNAME1 + i, 100);
  395. m_arWeekDayNamesLong [(i + 1) % 7] = sWDlong;
  396. m_arWeekDayNamesShort[(i + 1) % 7] = sWDshort;
  397. }
  398. m_arWeekDayNamesLong [7] = m_arWeekDayNamesLong[6] + _T("/") + m_arWeekDayNamesLong[0];
  399. m_arWeekDayNamesShort[7] = m_arWeekDayNamesShort[6] + _T("/") + m_arWeekDayNamesShort[0];
  400. }
  401. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::RefreshMetrics(BOOL bRefreshChildren)
  402. {
  403. UNREFERENCED_PARAMETER(bRefreshChildren);
  404. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  405. ASSERT(pThemeX);
  406. if (!pThemeX)
  407. {
  408. return;
  409. }
  410. RefreshFromParent(pThemeX->GetHeaderPartX());
  411. m_clrFreeSpaceBk.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekHeaderFreeSpaceBk"), RGB(227, 239, 255)));
  412. m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
  413. m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
  414. m_bkToday.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
  415. m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
  416. LOGFONT lfVert;
  417. VERIFY( m_TextCenter.fcsetNormal.fntFont->GetLogFont(&lfVert) );
  418. lfVert.lfOrientation = 900;
  419. lfVert.lfEscapement = 900;
  420. if (XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME))
  421. {
  422. STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
  423. }
  424. else
  425. {
  426. STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTPDrawHelpers()->GetVerticalFontName(TRUE));
  427. }
  428. m_TextCenter.fcsetNormal.fntFont.SetStandardValue(&lfVert);
  429. m_TextCenter.fcsetNormal.clrColor.SetStandardValue(RGB(0, 0, 0)); //pThemeX->GetColor(xtpCLR_HeaderBorder));
  430. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(13, 10, 1));
  431. }
  432. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::AdjustLayout(
  433. CCmdTarget* pObject, CDC* pDC, const CRect& rcRect)
  434. {
  435. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  436. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
  437. if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
  438. {
  439. ASSERT(FALSE);
  440. return;
  441. }
  442. CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMonthView->GetGrid();
  443. int nColsCount = pGrid->GetColsCount();
  444. int nCellWidth = rcRect.Width() / max(1, nColsCount);
  445. int nHeaderHeight = CalcHeight(pDC, nCellWidth);
  446. pGrid->SetColHeaderHeight(nHeaderHeight);
  447. if (!nColsCount || m_arWeekDayNamesLong.GetSize() < 8 ||
  448. m_arWeekDayNamesShort.GetSize() < 8)
  449. {
  450. ASSERT(FALSE);
  451. return;
  452. }
  453. CString strDWMaxLong;
  454. for (int i = 0; i < 7; i++)
  455. {
  456. if (strDWMaxLong.GetLength() < m_arWeekDayNamesLong[i].GetLength())
  457. {
  458. strDWMaxLong = m_arWeekDayNamesLong[i];
  459. }
  460. }
  461. CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.Font());
  462. CSize szWDlong = pDC->GetTextExtent(strDWMaxLong);
  463. CSize szSaSuLong = pDC->GetTextExtent(m_arWeekDayNamesLong[7]);
  464. int nRectSize = nCellWidth;
  465. m_bWeekDayNamesLong = szWDlong.cx + szWDlong.cx/4 + nRectSize/5 < nRectSize;
  466. m_bWeekDayNameSaSuLong = szSaSuLong.cx + szSaSuLong.cx/4 + nRectSize/5 < nRectSize;
  467. }
  468. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  469. {
  470. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  471. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
  472. if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
  473. {
  474. ASSERT(FALSE);
  475. return;
  476. }
  477. CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMonthView->GetGrid();
  478. CRect rcWDHeader = pMonthView->GetViewRect();
  479. rcWDHeader.bottom = rcWDHeader.top + pGrid->GetColHeaderHeight();
  480. CXTPPropsStateContext autoStateCnt1(this, xtpCalendarBeforeDraw_MonthViewWeekDayHeader, TRUE);
  481. autoStateCnt1.SendBeforeDrawThemeObject((LPARAM)-1);
  482. //===========================================
  483. CStringArray arColHeaderText;
  484. CUIntArray arWeekDays;
  485. arColHeaderText.SetSize(7);
  486. arWeekDays.SetSize(7);
  487. for (int i = 0; i < 7; i++)
  488. {
  489. int nCol = pGrid->GetWeekDayCol(i + 1);
  490. CString sVal = arColHeaderText[nCol];
  491. if (!sVal.IsEmpty())
  492. {
  493. // compressed col - always Sat/Sun
  494. arColHeaderText[nCol] = m_bWeekDayNameSaSuLong ? m_arWeekDayNamesLong[7] : m_arWeekDayNamesShort[7];
  495. arWeekDays[nCol] = 7;
  496. }
  497. else
  498. {
  499. CString sWD = m_bWeekDayNamesLong ? m_arWeekDayNamesLong[i] : m_arWeekDayNamesShort[i];
  500. arColHeaderText[nCol] = sWD;
  501. arWeekDays[nCol] = i + 1;
  502. }
  503. }
  504. CXTPPropsStateContext autoStateCnt2_wd(this, xtpCalendarBeforeDraw_MonthViewWeekDayHeader);
  505. //===========================================
  506. int nColsCount = pGrid->GetColsCount();
  507. for (int nCol = 0; nCol < nColsCount; nCol++)
  508. {
  509. CRect rcCell = pGrid->GetCelRect(0, nCol, TRUE);
  510. rcCell.top = rcWDHeader.top;
  511. rcCell.bottom = rcWDHeader.bottom;
  512. CString strWD = arColHeaderText[nCol];
  513. int nWeekDay = arWeekDays[nCol];
  514. autoStateCnt2_wd.SendBeforeDrawThemeObject((LPARAM)nWeekDay);
  515. //--------------------------------------------------------
  516. pMonthView->GetWeekDayTextIfNeed(&strWD, nWeekDay);
  517. Draw_Header(pDC, rcCell, 0, _T(""), strWD);
  518. if (nCol +1 < nColsCount)
  519. {
  520. CRect rcLine = rcCell;
  521. rcLine.left = rcLine.right - 1;
  522. rcLine.top += 2;
  523. pDC->FillSolidRect(rcLine, (COLORREF)m_TextCenter.fcsetNormal.clrColor);
  524. }
  525. //--------------------------------------------------------
  526. autoStateCnt2_wd.RestoreState();
  527. }
  528. autoStateCnt2_wd.Clear();
  529. }
  530. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::AdjustLayout(CCmdTarget* pObject, CDC* pDC, const CRect& rcRect)
  531. {
  532. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  533. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
  534. if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
  535. {
  536. ASSERT(FALSE);
  537. return;
  538. }
  539. //***
  540. m_rcHeader = rcRect;
  541. //***
  542. int nWeeksCount = pMonthView->GetGrid()->GetWeeksCount();
  543. if (!nWeeksCount)
  544. {
  545. return;
  546. }
  547. CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetGrid()->GetViewDay(0, 0);
  548. ASSERT(pViewDay);
  549. if (!pViewDay)
  550. {
  551. return;
  552. }
  553. const CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = pThemeX->GetViewDayLayout(pViewDay);
  554. COleDateTime dtWDay1 = pViewDay->GetDayDate();
  555. CRect rcWHeaderTextVert = m_rcHeader;
  556. rcWHeaderTextVert.top = dayLayout.m_rcDayHeader.bottom;
  557. rcWHeaderTextVert.bottom = dayLayout.m_rcDay.bottom;
  558. //---
  559. CString strTmp, strCaptionLong;
  560. FormatWeekCaption(dtWDay1, strTmp, strCaptionLong, 2);
  561. CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.fntFont, m_TextCenter.fcsetNormal.clrColor);
  562. CSize szText1 = pDC->GetTextExtent(strCaptionLong);
  563. int nRectSize = abs(rcWHeaderTextVert.Height());
  564. m_bDateFormatShort = TRUE;
  565. if (szText1.cx + szText1.cx/3 + nRectSize/10 < nRectSize)
  566. {
  567. m_bDateFormatShort = FALSE;
  568. }
  569. }
  570. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::Draw_Borders2(
  571. CDC* /*pDC*/, const CRect& /*rcRect*/, BOOL /*bDrawRightBorder*/)
  572. {
  573. }
  574. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::DoPropExchange(CXTPPropExchange* pPX)
  575. {
  576. ASSERT(pPX);
  577. if (!pPX)
  578. return;
  579. CXTPPropExchangeSection secData(pPX->GetSection(_T("MonthViewWeekHeader")));
  580. if (pPX->IsStoring())
  581. secData->EmptySection();
  582. PX_Color(&secData, _T("FreeSpaceBkColor"), m_clrFreeSpaceBk);
  583. TBase::DoPropExchange(pPX);
  584. }
  585. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Serialize(CArchive& ar)
  586. {
  587. m_clrFreeSpaceBk.Serialize(ar);
  588. TBase::Serialize(ar);
  589. }
  590. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  591. {
  592. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  593. CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
  594. if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
  595. {
  596. ASSERT(FALSE);
  597. return;
  598. }
  599. CXTPPropsStateContext autoStateCnt1(this, xtpCalendarBeforeDraw_MonthViewWeekHeader, TRUE);
  600. autoStateCnt1.SendBeforeDrawThemeObject((LPARAM)-1);
  601. pDC->FillSolidRect(&m_rcHeader, m_clrFreeSpaceBk);
  602. CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.fntFont, m_TextCenter.fcsetNormal.clrColor);
  603. CXTPPropsStateContext autoStateCnt2_week(this, xtpCalendarBeforeDraw_MonthViewWeekHeader);
  604. int nWeeksCount = pMonthView->GetGrid()->GetWeeksCount();
  605. for (int i = 0; i < nWeeksCount; i++)
  606. {
  607. CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetGrid()->GetViewDay(i, 0);
  608. ASSERT(pViewDay);
  609. if (!pViewDay)
  610. {
  611. continue;
  612. }
  613. const CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = pThemeX->GetViewDayLayout(pViewDay);
  614. COleDateTime dtWDay1 = pViewDay->GetDayDate();
  615. CRect rcWHeader = m_rcHeader;
  616. rcWHeader.left+= 3;
  617. rcWHeader.top = dayLayout.m_rcDayHeader.bottom - 1;
  618. rcWHeader.bottom = dayLayout.m_rcDay.bottom;
  619. autoStateCnt2_week.SendBeforeDrawThemeObject((LPARAM)i);
  620. //--------------------------------------------------
  621. CString strWeekCaption;
  622. FormatWeekCaption(dtWDay1, strWeekCaption, strWeekCaption, m_bDateFormatShort ? 1 : 2);
  623. //--------------------------------------------------
  624. Draw_Background(pDC, rcWHeader, 0);
  625. Draw_TextCenter(pDC, rcWHeader, 0, strWeekCaption);
  626. if (i +1 < nWeeksCount)
  627. autoStateCnt2_week.RestoreState();
  628. }
  629. autoStateCnt2_week.Clear();
  630. }
  631. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Draw_TextCenter(CDC* pDC, const CRect& rcRect, int nState,
  632.  LPCTSTR pcszCenterText, int* pnWidth)
  633. {
  634. UNREFERENCED_PARAMETER(nState);
  635. UNREFERENCED_PARAMETER(pnWidth);
  636. // Warning: not supported.
  637. ASSERT(pnWidth == NULL);
  638. CRect rcWHeaderTextVert = rcRect;
  639. rcWHeaderTextVert.DeflateRect(1, 3, 1, 3);
  640. int nTmp = rcWHeaderTextVert.top;
  641. rcWHeaderTextVert.top = rcWHeaderTextVert.bottom;
  642. rcWHeaderTextVert.bottom = nTmp;
  643. int nRectSize = abs(rcWHeaderTextVert.Height());
  644. //---
  645. CSize szText = pDC->GetTextExtent(pcszCenterText);
  646. // Center text vertically
  647. if (szText.cx + 7 < nRectSize)
  648. {
  649. rcWHeaderTextVert.top = max(rcWHeaderTextVert.top - (nRectSize - szText.cx)/2, rcWHeaderTextVert.bottom);
  650. }
  651. pDC->DrawText(CString(pcszCenterText), &rcWHeaderTextVert, DT_NOPREFIX | DT_SINGLELINE); //| DT_NOCLIP
  652. }
  653. void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::FormatWeekCaption(COleDateTime dtWDay1,
  654. CString& rstrShort, CString& rstrLong, int nShort1Long2 )
  655. {
  656. //LOCALE_IDATE  -  short date format ordering
  657. // 0 Month-Day-Year
  658. // 1 Day-Month-Year
  659. // 2 Year-Month-Day
  660. int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
  661. CString strDSeparator = CXTPCalendarUtils::GetLocaleString(LOCALE_SDATE, 100);
  662. // SHORT
  663. COleDateTime dtWDay6 = dtWDay1 + COleDateTimeSpan(6, 0, 0, 0);
  664. const int cnBuffSize = 128;
  665. TCHAR szWDay1[cnBuffSize], szMonth1[cnBuffSize];
  666. TCHAR szWDay6[cnBuffSize], szMonth6[cnBuffSize];
  667. ITOT_S(dtWDay1.GetDay(), szWDay1, cnBuffSize);
  668. ITOT_S(dtWDay6.GetDay(), szWDay6, cnBuffSize);
  669. if (nShort1Long2 == 0 || nShort1Long2 == 1)
  670. {
  671. ITOT_S(dtWDay1.GetMonth(), szMonth1, cnBuffSize);
  672. ITOT_S(dtWDay6.GetMonth(), szMonth6, cnBuffSize);
  673. rstrShort = _FormatWCaption(szWDay1, szMonth1, szWDay6, szMonth6, strDSeparator, nDateOrdering);
  674. }
  675. if (nShort1Long2 == 0 || nShort1Long2 == 2)
  676. {
  677. CString strMonth1 = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + dtWDay1.GetMonth() - 1, 100);
  678. CString strMonth6 = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + dtWDay6.GetMonth() - 1, 100);
  679. rstrLong = _FormatWCaption(szWDay1, strMonth1, szWDay6, strMonth6, _T(" "), nDateOrdering);
  680. }
  681. }
  682. CString CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::_FormatWCaption(LPCTSTR pcszDay1, LPCTSTR pcszMonth1,
  683. LPCTSTR pcszDay6, LPCTSTR pcszMonth6,
  684. LPCTSTR pcszDayMonthSeparator, int nDateOrdering)
  685. {
  686. //LOCALE_IDATE  -  short date format ordering
  687. // 0 Month-Day-Year
  688. // 1 Day-Month-Year
  689. // 2 Year-Month-Day
  690. CString strCaption;
  691. if (_tcsicmp(pcszMonth1, pcszMonth6) == 0)
  692. {
  693. if (nDateOrdering == 1)
  694. {
  695. strCaption.Format(_T("%s - %s%s%s"), pcszDay1, pcszDay6,
  696.   pcszDayMonthSeparator, pcszMonth6);
  697. }
  698. else
  699. {
  700. strCaption.Format(_T("%s%s%s - %s"), pcszMonth1, pcszDayMonthSeparator,
  701.   pcszDay1, pcszDay6);
  702. }
  703. }
  704. else
  705. {
  706. if (nDateOrdering == 1)
  707. {
  708. strCaption.Format(_T("%s%s%s - %s%s%s"), pcszDay1, pcszDayMonthSeparator,
  709.   pcszMonth1, pcszDay6, pcszDayMonthSeparator, pcszMonth6);
  710. }
  711. else
  712. {
  713. strCaption.Format(_T("%s%s%s - %s%s%s"), pcszMonth1, pcszDayMonthSeparator,
  714.   pcszDay1, pcszMonth6, pcszDayMonthSeparator, pcszDay6);
  715. }
  716. }
  717. return strCaption;
  718. }
  719. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::RefreshMetrics(BOOL bRefreshChildren)
  720. {
  721. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  722. ASSERT(pThemeX);
  723. if (!pThemeX)
  724. {
  725. return;
  726. }
  727. m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
  728. //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
  729. m_clrBackgroundLight.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkLight));
  730. m_clrBackgroundDark.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkDark));
  731. m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkSelected));
  732. TBase::RefreshMetrics(bRefreshChildren);
  733. m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
  734. }
  735. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::SetDynColors(CXTPCalendarMonthViewDay* pMViewDay)
  736. {
  737. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  738. CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
  739. XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
  740. if (!pMViewDay || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
  741. {
  742. ASSERT(FALSE);
  743. return;
  744. }
  745. CXTPCalendarViewGroup* pViewGroup = pMViewDay->GetViewGroupsCount() ? pMViewDay->GetViewGroup_(0) : NULL;
  746. //--------------------------------------------------------------------
  747. CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
  748. m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, pMViewDay->GetDayDate(), -1, bsColors);
  749. //--------------------------------------------------------------------
  750. m_clrDynHatch = 0;
  751. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
  752.  m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
  753.  m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  754. {
  755. if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
  756. {
  757. m_clrDynHatch = bsColors.clrBkAllDayEvents;
  758. if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
  759. {
  760. m_clrBackgroundLight = bsColors.clrBkAllDayEvents;
  761. m_clrBackgroundDark = bsColors.clrBkAllDayEvents;
  762. m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
  763. }
  764. }
  765. else
  766. {
  767. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
  768. {
  769. m_clrBackgroundLight = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
  770. m_clrBackgroundDark = (COLORREF)m_clrBackgroundLight;
  771. }
  772. m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
  773. }
  774. }
  775. }
  776. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
  777. {
  778. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  779. CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
  780. CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
  781. XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
  782. if (!pDC || !pThemeX || !pCellDynBkPart || !pMViewDay || !pMViewDay->GetView() ||
  783. !pMViewDay->GetView()->GetGrid() || pMViewDay->GetViewGroupsCount() == 0 ||
  784. !pMViewDay->GetViewGroup(0) || !pThemeX->GetCalendarControl())
  785. {
  786. ASSERT(FALSE);
  787. return;
  788. }
  789. CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMViewDay->GetView()->GetGrid();
  790. CXTPCalendarMonthViewGroup* pMViewGroup = pMViewDay->GetViewGroup(0);
  791. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
  792. CRect rcDay = dayLayout.m_rcDay;
  793. CRect rcBorders = rcDay;
  794. rcBorders.top = dayLayout.m_rcDayHeader.bottom;
  795. COleDateTime dtDay = pMViewDay->GetDayDate();
  796. COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
  797. BOOL bIsToday = GetHeaderPart()->IsToday(pMViewDay);
  798. BOOL bIsSelected = GetHeaderPart()->IsSelected(pMViewDay);
  799. //-----------------
  800. int nCurrentMonth = dtNow.GetMonth();
  801. int nLiteBkColorIdx = nCurrentMonth % 2;
  802. int nMonth = dtDay.GetMonth();
  803. COLORREF clrBackground = nMonth % 2 == nLiteBkColorIdx ? m_clrBackgroundLight : m_clrBackgroundDark;
  804. if (bIsSelected)
  805. {
  806. clrBackground = m_clrBackgroundSelected;
  807. }
  808. pDC->FillSolidRect(rcDay, clrBackground);
  809. //--------------------------------------------------------------------
  810. if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  811. {
  812. CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBackground);
  813. CBrush br(HS_BDIAGONAL, m_clrDynHatch);
  814. pDC->FillRect(&rcDay, &br);
  815. }
  816. //--------------------------------------------------------------------
  817. if (bIsToday)
  818. {
  819. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 2, CRect(1, 0, 1, 1));
  820. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(0, 0, 1, 0));
  821. }
  822. else
  823. {
  824. int nColIdx = pGrid->GetWeekDayCol(dtDay.GetDayOfWeek());
  825. int nIsLBorder = nColIdx == 0 ? 1 : 0;
  826. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(nIsLBorder, 0, 1, 0));
  827. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 2, CRect(0, 0, 0, 1));
  828. }
  829. //------------------
  830. GetHeaderPart()->Draw(pMViewDay, pDC);
  831. //=====================
  832. BOOL bCnt_EvS = FALSE;
  833. BOOL bCnt_EvMul = FALSE;
  834. CXTPPropsStateContext autoStateCnt_EvS;
  835. CXTPPropsStateContext autoStateCnt_EvMul;
  836. int nCount = pMViewGroup->GetViewEventsCount();
  837. for (int i = 0; i < nCount; i++)
  838. {
  839. CXTPCalendarViewEvent* pViewEvent = pMViewGroup->GetViewEvent_(i);
  840. ASSERT(pViewEvent);
  841. if (pViewEvent && pViewEvent->IsVisible())
  842. {
  843. if (pViewEvent->IsMultidayEvent())
  844. {
  845. if (!bCnt_EvMul)
  846. autoStateCnt_EvMul.SetData(GetMultiDayEventPartX(), xtpCalendarBeforeDraw_MonthViewEvent, TRUE);
  847. bCnt_EvMul = TRUE;
  848. autoStateCnt_EvMul.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
  849. GetMultiDayEventPartX()->Draw(pViewEvent, pDC);
  850. autoStateCnt_EvMul.RestoreState();
  851. }
  852. else
  853. {
  854. if (!bCnt_EvS)
  855. autoStateCnt_EvS.SetData(GetSingleDayEventPartX(), xtpCalendarBeforeDraw_MonthViewEvent, TRUE);
  856. bCnt_EvS = TRUE;
  857. autoStateCnt_EvS.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
  858. GetSingleDayEventPartX()->Draw(pViewEvent, pDC);
  859. autoStateCnt_EvS.RestoreState();
  860. }
  861. }
  862. }
  863. if (!pDC->IsPrinting() && pMViewDay->NoAllEventsAreVisible())
  864. {
  865. CRect rc = dayLayout.m_rcDay;
  866. rc.right -= 5;
  867. rc.bottom -= 5;
  868. BOOL bHot = HitTestExpandDayButton(pMViewDay) != 0;
  869. dayLayout.m_rcExpandSign = pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
  870. if (bHot)
  871. dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
  872. else
  873. dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
  874. }
  875. autoStateCnt_EvS.Clear();
  876. autoStateCnt_EvMul.Clear();
  877. }
  878. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
  879. {
  880. UNREFERENCED_PARAMETER(nFlags);
  881. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  882. CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
  883. if (!pThemeX || !pMViewDay || !pThemeX->GetCalendarControl())
  884. {
  885. ASSERT(FALSE);
  886. return;
  887. }
  888. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
  889. if (pMViewDay->NoAllEventsAreVisible())
  890. {
  891. BOOL bHot = pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE);
  892. BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton);
  893. if (bHot != bHotPrev)
  894. {
  895. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  896. }
  897. }
  898. BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
  899. if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
  900. {
  901. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  902. }
  903. }
  904. BOOL CXTPCalendarThemeOffice2007::CTOMonthViewDay::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
  905. {
  906. UNREFERENCED_PARAMETER(nFlags);
  907. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  908. CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
  909. if (!pThemeX || !pMViewDay || !pThemeX->GetCalendarControl())
  910. {
  911. ASSERT(FALSE);
  912. return FALSE;
  913. }
  914. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
  915. if (pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE))
  916. {
  917. pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
  918. (WPARAM)(xtpCalendarUserAction_OnExpandDay | xtpCalendarExpandDayButton_MonthView),
  919. (LPARAM)(LONG)(DATE)pMViewDay->GetDayDate());
  920. return TRUE;
  921. }
  922. return FALSE;
  923. }
  924. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::DoPropExchange(CXTPPropExchange* pPX)
  925. {
  926. ASSERT(pPX);
  927. if (!pPX)
  928. return;
  929. CXTPPropExchangeSection secData(pPX->GetSection(_T("MonthViewDay")));
  930. if (pPX->IsStoring())
  931. secData->EmptySection();
  932. PX_Color(&secData, _T("BorderColor"),       m_clrBorder);
  933. PX_Color(&secData, _T("TodayBorderColor"),  m_clrTodayBorder);
  934. PX_Color(&secData, _T("BackgroundLightColor"),   m_clrBackgroundLight);
  935. PX_Color(&secData, _T("BackgroundDarkColor"),    m_clrBackgroundDark);
  936. PX_Color(&secData, _T("BackgroundSelectedColor"), m_clrBackgroundSelected);
  937. TBase::DoPropExchange(&secData);
  938. }
  939. void CXTPCalendarThemeOffice2007::CTOMonthViewDay::Serialize(CArchive& ar)
  940. {
  941. m_clrBorder.Serialize(ar);
  942. m_clrTodayBorder.Serialize(ar);
  943. m_clrBackgroundLight.Serialize(ar);
  944. m_clrBackgroundDark.Serialize(ar);
  945. m_clrBackgroundSelected.Serialize(ar);
  946. TBase::Serialize(ar);
  947. }
  948. void CXTPCalendarThemeOffice2007::CTOMonthViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
  949. {
  950. UNREFERENCED_PARAMETER(bRefreshChildren);
  951. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  952. ASSERT(pThemeX);
  953. if (!pThemeX)
  954. {
  955. return;
  956. }
  957. RefreshFromParent(pThemeX->GetMonthViewPartX()->GetHeaderPartX());
  958. //  m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
  959. m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeader);
  960. m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeader);
  961. m_bkToday.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeaderToday);
  962. m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeaderToday);
  963. m_bkToday.rcBitmapBorder.        SetStandardValue(CRect(1, 1, 2, 1));
  964. m_bkTodaySelected.rcBitmapBorder.SetStandardValue(CRect(1, 1, 2, 1));
  965. }
  966. void CXTPCalendarThemeOffice2007::CTOMonthViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  967. {
  968. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  969. CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
  970. if (!pDC || !pThemeX || !pMViewDay || !pThemeX->GetCalendarControl() ||
  971. !pMViewDay->GetView() || !pMViewDay->GetView()->GetGrid())
  972. {
  973. ASSERT(FALSE);
  974. return;
  975. }
  976. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
  977. COleDateTime dtDay = pMViewDay->GetDayDate();
  978. BOOL bCompressWeD = XTP_SAFE_GET3(pMViewDay, GetView(), GetCalendarControl(), MonthView_IsCompressWeekendDays(), FALSE);
  979. BOOL bIsToday    = IsToday(pMViewDay);
  980. BOOL bIsSelected = IsSelected(pMViewDay);
  981. int nDImod7 = pMViewDay->GetDayIndex() % 7;
  982. BOOL bFirstDay = nDImod7 == 0 || (nDImod7 == 6 && bCompressWeD);
  983. BOOL bLastDay = nDImod7 >= (bCompressWeD ? 5 : 6);
  984. CPoint pt(0, 0);
  985. if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
  986. pThemeX->GetCalendarControl()->ScreenToClient(&pt);
  987. int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
  988. nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
  989. if (dayLayout.m_rcDayHeader.PtInRect(pt))
  990. {
  991. nFlags |=  CTOHeader::xtpCalendarItemState_Hot;
  992. dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  993. }
  994. else
  995. {
  996. dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  997. }
  998. nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
  999. nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
  1000. CRect rcRect = dayLayout.m_rcDay;
  1001. //***
  1002. rcRect.bottom = dayLayout.m_rcDayHeader.bottom;
  1003. CString strTextLeft;
  1004. CString strTextCenter;
  1005. CString strTextRight;
  1006. int nMonth = dtDay.GetMonth();
  1007. int nDay = dtDay.GetDay();
  1008. if (nDay == 1 || pMViewDay->GetDayIndex() == 0)
  1009. {
  1010. CString strMonth = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + nMonth - 1, 100);
  1011. //LOCALE_IDATE  -  short date format ordering
  1012. // 0 Month-Day-Year
  1013. // 1 Day-Month-Year
  1014. // 2 Year-Month-Day
  1015. int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
  1016. if (nDateOrdering == 1)
  1017. {
  1018. strTextLeft.Format(_T("%d %s"), nDay, (LPCTSTR)strMonth);
  1019. }
  1020. else
  1021. {
  1022. strTextLeft.Format(_T("%s %d"), (LPCTSTR)strMonth, nDay);
  1023. }
  1024. }
  1025. else
  1026. {
  1027. strTextLeft.Format(_T("%d"), nDay);
  1028. }
  1029. //------------------------------------------------------
  1030. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderLeft, &strTextLeft, pMViewDay);
  1031. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderCenter, &strTextCenter, pMViewDay);
  1032. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderRight, &strTextRight, pMViewDay);
  1033. //------------------------------------------------------
  1034. Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
  1035. }
  1036. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::Draw_Time(CDC* pDC, const CRect& rcEventRect,
  1037. CXTPCalendarMonthViewEvent* pViewEvent)
  1038. {
  1039. if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
  1040. {
  1041. ASSERT(FALSE);
  1042. return;
  1043. }
  1044. BOOL bSelected = pViewEvent->IsSelected();
  1045. CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
  1046. COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
  1047. CXTPFontDC autoFont(pDC, pFont, clrColor);
  1048. //--------------------------
  1049. COleDateTime dtStart(pViewEvent->GetEvent()->GetStartTime());
  1050. COleDateTime dtEnd(pViewEvent->GetEvent()->GetEndTime());
  1051. //*****************
  1052. // not implemented for office 2007 theme.
  1053. //if (pViewEvent->IsTimeAsClock()) {}
  1054. //*****************
  1055. CString strStartTime = pViewEvent->GetItemTextStartTime();
  1056. CString strEndTime = pViewEvent->GetItemTextEndTime();
  1057. CSize szStart = pDC->GetTextExtent(strStartTime);
  1058. CSize szEnd = pDC->GetTextExtent(strEndTime);
  1059. CRect rcStart(rcEventRect);
  1060. CRect rcEnd(rcEventRect);
  1061. BOOL bDrawStartEndTimes = szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2;
  1062. if (!bDrawStartEndTimes)
  1063. {
  1064. return;
  1065. }
  1066. rcStart.left = min(rcStart.left + 6, rcStart.right);
  1067. rcStart.right = min(rcStart.left + szStart.cx + 2, rcStart.right);
  1068. rcEnd.right = max(rcEnd.right - 6, rcEventRect.left);
  1069. rcEnd.left = max(rcEnd.right - szEnd.cx - 2, rcEventRect.left);
  1070. //-------------------------------------------------
  1071. UINT uAlign = DT_VCENTER | DT_SINGLELINE ;
  1072. pDC->DrawText(strStartTime, &rcStart, uAlign | DT_LEFT);
  1073. pDC->DrawText(strEndTime, &rcEnd, uAlign | DT_RIGHT);
  1074. //-------------------------------------------------
  1075. pViewEvent->m_rcStartTime.CopyRect(&rcStart);
  1076. pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
  1077. pViewEvent->m_rcText.left = rcStart.right;
  1078. pViewEvent->m_rcText.right = rcEnd.left;
  1079. }
  1080. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
  1081. {
  1082. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1083. CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
  1084. CXTPCalendarMonthViewDay* pMVDay = XTP_SAFE_GET2(pViewEvent, GetViewGroup(), GetViewDay(), NULL);
  1085. CXTPCalendarMonthView* pMView = XTP_SAFE_GET1(pMVDay, GetView(), NULL);
  1086. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
  1087. !pMView || !pMVDay)
  1088. {
  1089. ASSERT(FALSE);
  1090. return;
  1091. }
  1092. BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
  1093. int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
  1094. if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
  1095. {
  1096. return;// was drawn in the Master (or out of events rect)
  1097. }
  1098. CRect rcEventMax(pViewEvent->GetViewEventRectMax());
  1099. CRect rcEvent(pViewEvent->GetEventRect());
  1100. if (rcEvent.IsRectEmpty())
  1101. {
  1102. return;
  1103. }
  1104. // fill event background
  1105. BOOL bSelected = pViewEvent->IsSelected();
  1106. COLORREF clrBorderNotSel;
  1107. COLORREF clrBorder;
  1108. CXTPPaintManagerColorGradient grclrBk;
  1109. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
  1110. //----------------
  1111. pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
  1112. int nSelOffset = bSelected ? 2 : 1;
  1113. if (nMDEFlags & xtpCalendarMultiDayFirst)
  1114. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  1115.   rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
  1116. //------------------
  1117. int nViewDayIndex = pMVDay->GetDayIndex();
  1118. BOOL bCompressWD = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), MonthView_IsCompressWeekendDays(), FALSE);
  1119. int nLastDayDx = bCompressWD ? 1 : 7;
  1120. BOOL bFirstOnScreen = nViewDayIndex == 0;
  1121. BOOL bLastOnScreen = nViewDayIndex == (pMView->GetViewDayCount() - nLastDayDx);
  1122. CRect rcText(pViewEvent->GetTextRect());
  1123. if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
  1124. {
  1125. CRect rcSQ = rcEventMax;
  1126. rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
  1127. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(1,1,0,1));
  1128. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
  1129.   rcEvent.right - nSelOffset, grclrBk, 0, rcEvent.bottom - nSelOffset);
  1130. //-------------------------------------------------------------------
  1131. if (bFirstOnScreen)
  1132. {
  1133. CRect rcArrow;
  1134. BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
  1135. if (bArrow)
  1136. rcText.left = rcArrow.right;
  1137. }
  1138. }
  1139. else if (bSelected)
  1140. {
  1141. // draw left Gripper
  1142. CRect rcGripper;
  1143. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  1144. rcGripper.bottom = rcGripper.top + cnGripperSize;
  1145. rcGripper.left = rcEvent.left - 1;
  1146. rcGripper.right = rcGripper.left + cnGripperSize;
  1147. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  1148. CBrush brBorder(m_clrGripperBorder);
  1149. pDC->FrameRect(&rcGripper, &brBorder);
  1150. }
  1151. if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
  1152. {
  1153. CRect rcSQ = rcEventMax;
  1154. rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
  1155. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,1,1));
  1156. pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcSQ.left, rcEvent.top + nSelOffset),
  1157.   rcEventMax.right - nSelOffset, grclrBk, 0, INT_MAX, FALSE);
  1158. //-------------------------------------------------------------------
  1159. if (bLastOnScreen)
  1160. {
  1161. CRect rcArrow;
  1162. BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
  1163. if (bArrow)
  1164. rcText.right = rcArrow.left;
  1165. }
  1166. }
  1167. else if (bSelected)
  1168. {
  1169. // draw right gripper
  1170. CRect rcGripper;
  1171. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  1172. rcGripper.bottom = rcGripper.top + cnGripperSize;
  1173. rcGripper.right = rcEvent.right + 1;
  1174. rcGripper.left = rcGripper.right - cnGripperSize;
  1175. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  1176. CBrush brBorder(m_clrGripperBorder);
  1177. pDC->FrameRect(&rcGripper, &brBorder);
  1178. }
  1179. int nMDFirstLastMask = (xtpCalendarMultiDayFirst|xtpCalendarMultiDayLast);
  1180. if ((nMDEFlags & nMDFirstLastMask) == nMDFirstLastMask)
  1181. {
  1182. COleDateTime dtStart = pViewEvent->GetEvent()->GetStartTime();
  1183. COleDateTime dtEnd = pViewEvent->GetEvent()->GetEndTime();
  1184. if (!CXTPCalendarUtils::IsZeroTime(dtStart) && !CXTPCalendarUtils::IsZeroTime(dtEnd))
  1185. {
  1186. Draw_Time(pDC, rcEvent, pViewEvent);
  1187. rcText = pViewEvent->GetTextRect();
  1188. }
  1189. }
  1190. //****
  1191. pViewEvent->m_rcText.CopyRect(rcText);
  1192. //=====================================
  1193. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  1194. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  1195. rcText.DeflateRect(3, 0, 3, 0);
  1196. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  1197. pViewEvent->m_rcSubjectEditor.top = rcEvent.top + 2;
  1198. pViewEvent->m_rcSubjectEditor.bottom = rcEvent.bottom - 2;
  1199. pViewEvent->AdjustSubjectEditor();
  1200. CRect rcIconsMax = rcText;
  1201. rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
  1202. //
  1203. BOOL bMarkupDrawn = FALSE;
  1204. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  1205. {
  1206. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  1207. ASSERT(pMarkupContext);
  1208. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  1209. if (pUIElement && pMarkupContext)
  1210. {
  1211. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  1212. if (rcIconsMax.Height() > szIcons.cy)
  1213. {
  1214. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  1215. }
  1216. rcText.right = max(rcText.left,  rcText.right - szIcons.cx - 2);
  1217. //---------------------------------------------------------------
  1218. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  1219. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  1220. bMarkupDrawn = TRUE;
  1221. }
  1222. }
  1223. //
  1224. //----------------------------------------------------
  1225. if (!bMarkupDrawn)
  1226. {
  1227. CString strSubj = pViewEvent->GetItemTextSubject();
  1228. CString strLoc = pViewEvent->GetItemTextLocation();
  1229. if (!strLoc.IsEmpty())
  1230. {
  1231. strSubj += _T(";");
  1232. }
  1233. //----------------------------------------------------
  1234. UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
  1235. CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  1236. rcText, uTextShortAlign | DT_CALCRECT);
  1237. //--- calculate rects and fix to be centered if enough space ---
  1238. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  1239. if (rcIconsMax.Height() > szIcons.cy)
  1240. {
  1241. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
  1242. }
  1243. int nTIcx = szText.cx + szIcons.cx;
  1244. if (nTIcx + 5 < rcText.Width())
  1245. {
  1246. int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
  1247. rcText.left += ncx_2;
  1248. rcText.right = rcText.left + szText.cx + 2;
  1249. rcIconsMax.right -= ncx_2;
  1250. }
  1251. else
  1252. {
  1253. rcText.right -= szIcons.cx + 2;
  1254. }
  1255. pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  1256. rcText, uTextShortAlign);
  1257. }
  1258. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  1259. }
  1260. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
  1261. {
  1262. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1263. CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
  1264. if (!pDC || !pThemeX || !pViewEvent)
  1265. {
  1266. ASSERT(FALSE);
  1267. return;
  1268. }
  1269. if (!pViewEvent->IsVisible())
  1270. {
  1271. return;
  1272. }
  1273. CRect rcEvent(pViewEvent->GetEventRect());
  1274. if (rcEvent.IsRectEmpty())
  1275. {
  1276. return;
  1277. }
  1278. // fill event background
  1279. Draw_Background(pDC, rcEvent, pViewEvent);
  1280. //
  1281. BOOL bMarkupDrawn = FALSE;
  1282. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  1283. {
  1284. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  1285. ASSERT(pMarkupContext);
  1286. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  1287. if (pUIElement && pMarkupContext)
  1288. {
  1289. BOOL bSelected = pViewEvent->IsSelected();
  1290. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  1291. CRect rcText = rcEvent;
  1292. rcText.DeflateRect(3, 2, 3, 2);
  1293. CRect rcIconsMax = rcText;
  1294. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  1295. if (rcIconsMax.Height() > szIcons.cy)
  1296. {
  1297. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  1298. }
  1299. rcText.right = max(rcText.left,  rcText.right - szIcons.cx - 2);
  1300. //---------------------------------------------------------------
  1301. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  1302. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  1303. bMarkupDrawn = TRUE;
  1304. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  1305. }
  1306. }
  1307. //
  1308. if (!bMarkupDrawn)
  1309. {
  1310. Draw_Time(pDC, rcEvent, pViewEvent);
  1311. CRect rcText(pViewEvent->GetTextRect());
  1312. Draw_Caption(pDC, rcText, pViewEvent);
  1313. }
  1314. }
  1315. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::
  1316. Draw_Background(CDC* pDC, const CRect& rcEventRect, CXTPCalendarMonthViewEvent* pViewEvent)
  1317. {
  1318. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1319. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
  1320. {
  1321. ASSERT(FALSE);
  1322. return;
  1323. }
  1324. BOOL bSelected = pViewEvent->IsSelected();
  1325. COLORREF clrBorderNotSel, clrBorder;
  1326. CXTPPaintManagerColorGradient grclrBk;
  1327. int nColorsSrc_1Cat2Lbl = 0;
  1328. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk, bSelected, &nColorsSrc_1Cat2Lbl);
  1329. if (!bSelected && nColorsSrc_1Cat2Lbl > 0)
  1330. {
  1331. clrBorder = grclrBk.clrLight;
  1332. }
  1333. pThemeX->DrawRoundRect(pDC, rcEventRect, clrBorder, bSelected, grclrBk);
  1334. }
  1335. CSize CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw_Time(
  1336. CDC* pDC, const CRect& rcEventRect, CXTPCalendarMonthViewEvent* pViewEvent)
  1337. {
  1338. CSize szResult(0, 0);
  1339. if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
  1340. {
  1341. ASSERT(FALSE);
  1342. return szResult;
  1343. }
  1344. BOOL bSelected = pViewEvent->IsSelected();
  1345. CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
  1346. COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
  1347. CXTPFontDC autoFont(pDC, pFont, clrColor);
  1348. //--------------------------
  1349. //*****************
  1350. // not implemented for office 2007 theme.
  1351. //if (pViewEvent->IsTimeAsClock()) {}
  1352. //*****************
  1353. CString strStartTime = pViewEvent->GetItemTextStartTime();
  1354. CString strEndTime = pViewEvent->GetItemTextEndTime();
  1355. CSize szStart = pDC->GetTextExtent(strStartTime);
  1356. CSize szEnd = pDC->GetTextExtent(strEndTime);
  1357. CRect rcStart(rcEventRect);
  1358. CRect rcEnd(rcEventRect);
  1359. DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
  1360. BOOL bShowEndTime = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), MonthView_IsShowEndDate(), TRUE);
  1361. BOOL bDrawStartTime = szStart.cx + 6 < rcEventRect.Width()/2 ||
  1362.   (dwOpt & xtpCalendarOptMonthViewShowStartTimeAlways);
  1363. BOOL bDrawEndTime = bShowEndTime && szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2 ||
  1364. (dwOpt & xtpCalendarOptMonthViewShowEndTimeAlways);
  1365. if (!bDrawStartTime && !bDrawEndTime)
  1366. {
  1367. return szResult;
  1368. }
  1369. rcStart.left = min(rcStart.left + 4, rcStart.right);
  1370. rcStart.right = min(rcStart.left + szStart.cx + 6, rcStart.right);
  1371. rcEnd.left = rcStart.right;
  1372. rcEnd.right = min(rcEnd.left + szEnd.cx + 6, rcEnd.right);
  1373. if (!bDrawEndTime)
  1374. {
  1375. rcEnd.right = rcEnd.left;
  1376. }
  1377. //-------------------------------------------------
  1378. UINT uAlign = DT_VCENTER | DT_SINGLELINE | DT_LEFT;
  1379. pDC->DrawText(strStartTime, &rcStart, uAlign);
  1380. if (bDrawEndTime)
  1381. {
  1382. pDC->DrawText(strEndTime, &rcEnd, uAlign);
  1383. }
  1384. //-------------------------------------------------
  1385. pViewEvent->m_rcStartTime.CopyRect(&rcStart);
  1386. pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
  1387. pViewEvent->m_rcText.left = rcEnd.right;
  1388. //-------------------------------------------------
  1389. szResult.cx = max(0, rcEnd.right - rcStart.left);
  1390. szResult.cy = szStart.cy;
  1391. return szResult;
  1392. }
  1393. void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw_Caption(
  1394. CDC* pDC, const CRect& rcTextRect, CXTPCalendarMonthViewEvent* pViewEvent)
  1395. {
  1396. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1397. if (!pDC || !pViewEvent || !pThemeX )
  1398. {
  1399. ASSERT(FALSE);
  1400. return;
  1401. }
  1402. CString strSubj = pViewEvent->GetItemTextSubject();
  1403. CString strLoc = pViewEvent->GetItemTextLocation();
  1404. if (!strLoc.IsEmpty())
  1405. {
  1406. strSubj += _T(";");
  1407. }
  1408. BOOL bSelected = pViewEvent->IsSelected();
  1409. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  1410. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  1411. CRect rcText = rcTextRect;
  1412. //rcText.DeflateRect(1, 2, 3, 2);
  1413. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  1414. pViewEvent->AdjustSubjectEditor();
  1415. UINT nAlign = DT_VCENTER | DT_LEFT | DT_SINGLELINE;
  1416. CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  1417. rcText, nAlign  | DT_CALCRECT, nAlign);
  1418. //----------------------------------------------------
  1419. CRect rcIconsMax = rcText;
  1420. rcIconsMax.left = min(rcIconsMax.left + rcTextRect.Height(), rcIconsMax.right);
  1421. //--- calculate rects and fix to be centered if enough space ---
  1422. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  1423. if (rcIconsMax.Height() > szIcons.cy)
  1424. {
  1425. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
  1426. }
  1427. int nTIcx = szText.cx + szIcons.cx;
  1428. if (nTIcx > rcText.Width())
  1429. {
  1430. rcText.right = max(rcIconsMax.left, rcIconsMax.right - szIcons.cx) - 2;
  1431. }
  1432. pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  1433. rcText, nAlign, nAlign);
  1434. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  1435. }
  1436. /////////////////////////////////////////////////////////////////////////////
  1437. //
  1438. // ***** Week View *****
  1439. //
  1440. void CXTPCalendarThemeOffice2007::CTOWeekView::RefreshMetrics(BOOL bRefreshChildren)
  1441. {
  1442. TBase::RefreshMetrics(bRefreshChildren);
  1443. }
  1444. void CXTPCalendarThemeOffice2007::CTOWeekView::AdjustLayout(CDC* pDC, const CRect& rcRect, BOOL bCallPostAdjustLayout)
  1445. {
  1446. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1447. ASSERT(pThemeX);
  1448. if (!pThemeX)
  1449. {
  1450. return;
  1451. }
  1452. TBase::AdjustLayout(pDC, rcRect, bCallPostAdjustLayout);
  1453. if (pThemeX->GetPrevNextEventControllerPartX())
  1454. pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRect);
  1455. }
  1456. void CXTPCalendarThemeOffice2007::CTOWeekView::Draw(CCmdTarget* /*pObject*/, CDC* pDC)
  1457. {
  1458. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1459. ASSERT(pThemeX);
  1460. if (!pThemeX)
  1461. {
  1462. return;
  1463. }
  1464. TBase::Draw(pDC);
  1465. if (pThemeX->GetPrevNextEventControllerPartX())
  1466. pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
  1467. }
  1468. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent::RefreshMetrics(BOOL bRefreshChildren)
  1469. {
  1470. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1471. ASSERT(pThemeX);
  1472. if (!pThemeX)
  1473. {
  1474. return;
  1475. }
  1476. TBase::RefreshMetrics(bRefreshChildren);
  1477. RefreshFromParent(pThemeX->GetEventPartX());
  1478. XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
  1479. XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, FALSE, FALSE, FALSE, FALSE) );
  1480. }
  1481. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
  1482. {
  1483. UNREFERENCED_PARAMETER(bRefreshChildren);
  1484. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1485. ASSERT(pThemeX);
  1486. if (!pThemeX)
  1487. {
  1488. return;
  1489. }
  1490. RefreshFromParent(pThemeX->GetWeekViewPartX()->GetEventPartX());
  1491. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
  1492. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
  1493.    pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto));
  1494. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
  1495. m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
  1496. }
  1497. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
  1498. {
  1499. UNREFERENCED_PARAMETER(bRefreshChildren);
  1500. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1501. ASSERT(pThemeX);
  1502. if (!pThemeX)
  1503. {
  1504. return;
  1505. }
  1506. RefreshFromParent(pThemeX->GetWeekViewPartX()->GetEventPartX());
  1507. CFont* pFontDef = pThemeX->m_fntBaseFont;
  1508. m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBorder));
  1509. m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRfrom),
  1510.    pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRto) );
  1511. m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventSelectedBorder));
  1512. m_fcsetSelected.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRfrom),
  1513.  pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRto) );
  1514. //----------------------------------------------
  1515. pThemeX->RemoveBoldAttrFromStd(m_fcsetNormal.fcsetSubject.fntFont);
  1516. pThemeX->RemoveBoldAttrFromStd(m_fcsetSelected.fcsetSubject.fntFont);
  1517. //----------------------------------------------
  1518. m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewEventTime));
  1519. m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
  1520. m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewEventTime));
  1521. m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
  1522. }
  1523. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::RefreshMetrics(BOOL bRefreshChildren)
  1524. {
  1525. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1526. ASSERT(pThemeX);
  1527. if (!pThemeX)
  1528. {
  1529. return;
  1530. }
  1531. m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
  1532. //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
  1533. m_clrBackgroundLight.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkLight));
  1534. m_clrBackgroundDark.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkDark));
  1535. m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkSelected));
  1536. TBase::RefreshMetrics(bRefreshChildren);
  1537. m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
  1538. }
  1539. void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
  1540. {
  1541. UNREFERENCED_PARAMETER(bRefreshChildren);
  1542. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1543. ASSERT(pThemeX);
  1544. if (!pThemeX)
  1545. {
  1546. return;
  1547. }
  1548. //LOCALE_IDATE  -  short date format ordering
  1549. // 0 Month-Day-Year
  1550. // 1 Day-Month-Year
  1551. // 2 Year-Month-Day
  1552. int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
  1553. if (nDateOrdering == 1)
  1554. {
  1555. m_strHeaderFormat.SetStandardValue(_T("dddd, dd MMMM"));
  1556. }
  1557. else
  1558. {
  1559. m_strHeaderFormat.SetStandardValue(_T("dddd, MMMM dd"));
  1560. }
  1561. RefreshFromParent(pThemeX->GetHeaderPartX());
  1562. //  m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
  1563. m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_WeekViewDayHeader);
  1564. m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_WeekViewDayHeader);
  1565. m_UseOffice2003HeaderFormat.SetStandardValue(FALSE);
  1566. }
  1567. void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::AdjustLayout(CCmdTarget* pObject,
  1568. CDC* pDC, const CRect& rcRect)
  1569. {
  1570. //TBase::AdjustLayout(pObject, pDC, rcRect);
  1571. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1572. CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
  1573. if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView())
  1574. {
  1575. ASSERT(FALSE);
  1576. return;
  1577. }
  1578. if (pWViewDay->GetDayIndex() != 0)
  1579. {
  1580. return;
  1581. }
  1582. CXTPCalendarWeekView* pWView = pWViewDay->GetView();
  1583. if (m_UseOffice2003HeaderFormat)
  1584. {
  1585. int nDayWidth = rcRect.Width() - 4;
  1586. pWView->CalculateHeaderFormat(pDC, nDayWidth, m_TextLeftRight.fcsetNormal.Font());
  1587. }
  1588. }
  1589. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent::AdjustLayout(CCmdTarget* pObject,
  1590.   CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
  1591. {
  1592. CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
  1593. if (!pDC || !GetTheme() || !pViewEvent || !pViewEvent->GetEvent())
  1594. {
  1595. ASSERT(FALSE);
  1596. return;
  1597. }
  1598. int nEventHeight = XTP_SAFE_GET4(pViewEvent, GetViewGroup(), GetViewDay(), GetView(), GetRowHeight(), 0);
  1599. pViewEvent->m_rcEventMax.top = rcRect.top + nEventPlaceNumber * nEventHeight;
  1600. pViewEvent->m_rcEventMax.bottom = pViewEvent->m_rcEventMax.top + nEventHeight;
  1601. pViewEvent->m_rcEvent.top = pViewEvent->m_rcEventMax.top;
  1602. pViewEvent->m_rcEvent.bottom = pViewEvent->m_rcEventMax.bottom;
  1603. pViewEvent->m_rcEvent.left = pViewEvent->m_rcEventMax.left + 4 + 2;
  1604. pViewEvent->m_rcEvent.right = pViewEvent->m_rcEventMax.right - 5 - 2;
  1605. pViewEvent->m_rcToolTip.CopyRect(pViewEvent->m_rcEventMax);
  1606. // adjust subject area
  1607. int nDyx = pViewEvent->IsSelected() ? 5 : 2;
  1608. pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
  1609. pViewEvent->m_rcText.DeflateRect(nDyx + 3, 3, nDyx + 2, 3);
  1610. // set times rects
  1611. pViewEvent->m_rcStartTime.SetRectEmpty();
  1612. pViewEvent->m_rcEndTime.SetRectEmpty();
  1613. pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcEvent);
  1614. pViewEvent->m_rcSubjectEditor.top++;
  1615. pViewEvent->m_rcSubjectEditor.bottom--;
  1616. }
  1617. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::SetDynColors(CXTPCalendarWeekViewDay* pWViewDay)
  1618. {
  1619. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1620. CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
  1621. XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
  1622. if (!pWViewDay || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
  1623. {
  1624. ASSERT(FALSE);
  1625. return;
  1626. }
  1627. CXTPCalendarViewGroup* pViewGroup = pWViewDay->GetViewGroupsCount() ? pWViewDay->GetViewGroup_(0) : NULL;
  1628. //--------------------------------------------------------------------
  1629. CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
  1630. m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, pWViewDay->GetDayDate(), -1, bsColors);
  1631. //--------------------------------------------------------------------
  1632. m_clrDynHatch = 0;
  1633. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
  1634.  m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
  1635.  m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  1636. {
  1637. if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
  1638. {
  1639. m_clrDynHatch = bsColors.clrBkAllDayEvents;
  1640. if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
  1641. {
  1642. m_clrBackgroundLight = bsColors.clrBkAllDayEvents;
  1643. m_clrBackgroundDark = bsColors.clrBkAllDayEvents;
  1644. m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
  1645. }
  1646. }
  1647. else
  1648. {
  1649. if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
  1650. {
  1651. m_clrBackgroundLight = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
  1652. m_clrBackgroundDark = (COLORREF)m_clrBackgroundLight;
  1653. }
  1654. m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
  1655. }
  1656. }
  1657. }
  1658. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
  1659. {
  1660. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1661. CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
  1662. if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView() ||
  1663. pWViewDay->GetViewGroupsCount() == 0 ||
  1664. !pWViewDay->GetViewGroup(0))
  1665. {
  1666. ASSERT(FALSE);
  1667. return;
  1668. }
  1669. CXTPCalendarWeekViewGroup* pWViewGroup = pWViewDay->GetViewGroup(0);
  1670. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
  1671. CRect rcDay = dayLayout.m_rcDay;
  1672. CRect rcBorders = rcDay;
  1673. rcBorders.top = dayLayout.m_rcDayHeader.bottom;
  1674. COleDateTime dtDay = pWViewDay->GetDayDate();
  1675. int nDayCol = GetDayCol(pWViewDay);
  1676. BOOL bIsToday = GetHeaderPart()->IsToday(pWViewDay);
  1677. BOOL bIsSelected = GetHeaderPart()->IsSelected(pWViewDay);
  1678. // Draw background
  1679. int nLiteBkColorIdx = 0;
  1680. // for non-work days choose dark background
  1681. if (pWViewDay->GetCalendarControl() &&
  1682. pWViewDay->GetCalendarControl()->GetCalendarOptions())
  1683. {
  1684. int nMask = pWViewDay->GetCalendarControl()->GetCalendarOptions()->nWorkWeekMask;
  1685. int nWeekDay = dtDay.GetDayOfWeek();
  1686. if ((CXTPCalendarUtils::GetDayOfWeekMask(nWeekDay) & nMask) != 0)
  1687. {
  1688. nLiteBkColorIdx = 1;
  1689. }
  1690. }
  1691. // for selected days choose another background
  1692. COLORREF clrBackground = nLiteBkColorIdx ? m_clrBackgroundLight : m_clrBackgroundDark;
  1693. if (bIsSelected)
  1694. {
  1695. clrBackground = m_clrBackgroundSelected;
  1696. }
  1697. // draw background
  1698. pDC->FillSolidRect(rcDay, clrBackground);
  1699. //--------------------------------------------------------------------
  1700. if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
  1701. {
  1702. CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBackground);
  1703. CBrush br(HS_BDIAGONAL, m_clrDynHatch);
  1704. pDC->FillRect(&rcDay, &br);
  1705. }
  1706. //--------------------------------------------------------------------
  1707. if (bIsToday)
  1708. {
  1709. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 2, CRect(1, 0, 0, 1));
  1710. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 1, CRect(0, 0, 1, 0));
  1711. //CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(0, 0, 1, 0));
  1712. }
  1713. else
  1714. {
  1715. int nIsRBorder = nDayCol;
  1716. int nIsLBorder = nDayCol;
  1717. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(nIsLBorder, 0, nIsRBorder, 0));
  1718. CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 2, CRect(0, 0, 0, 1));
  1719. }
  1720. //------------------
  1721. GetHeaderPart()->Draw(pWViewDay, pDC);
  1722. BOOL bCnt_EvS = FALSE;
  1723. BOOL bCnt_EvMul = FALSE;
  1724. CXTPPropsStateContext autoStateCnt_EvS;
  1725. CXTPPropsStateContext autoStateCnt_EvMul;
  1726. //=====================
  1727. int nCount = pWViewGroup->GetViewEventsCount();
  1728. for (int i = 0; i < nCount; i++)
  1729. {
  1730. CXTPCalendarViewEvent* pViewEvent = pWViewGroup->GetViewEvent_(i);
  1731. ASSERT(pViewEvent);
  1732. if (pViewEvent && pViewEvent->IsVisible())
  1733. {
  1734. if (pViewEvent->IsMultidayEvent())
  1735. {
  1736. if (!bCnt_EvMul)
  1737. autoStateCnt_EvMul.SetData(GetMultiDayEventPartX(), xtpCalendarBeforeDraw_WeekViewEvent, TRUE);
  1738. bCnt_EvMul = TRUE;
  1739. autoStateCnt_EvMul.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
  1740. GetMultiDayEventPartX()->Draw(pViewEvent, pDC);
  1741. autoStateCnt_EvMul.RestoreState();
  1742. }
  1743. else
  1744. {
  1745. if (!bCnt_EvS)
  1746. autoStateCnt_EvS.SetData(GetSingleDayEventPartX(), xtpCalendarBeforeDraw_WeekViewEvent, TRUE);
  1747. bCnt_EvS = TRUE;
  1748. autoStateCnt_EvS.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
  1749. GetSingleDayEventPartX()->Draw(pViewEvent, pDC);
  1750. autoStateCnt_EvS.RestoreState();
  1751. }
  1752. }
  1753. }
  1754. if (!pDC->IsPrinting() && pWViewDay->NoAllEventsAreVisible())
  1755. {
  1756. CRect rc = dayLayout.m_rcDay;
  1757. rc.right -= 5;
  1758. rc.bottom -= 5;
  1759. BOOL bHot = _HitTestExpandDayButton(pWViewDay, rc) != 0;
  1760. dayLayout.m_rcExpandSign = pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
  1761. if (bHot)
  1762. dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
  1763. else
  1764. dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
  1765. }
  1766. autoStateCnt_EvS.Clear();
  1767. autoStateCnt_EvMul.Clear();
  1768. }
  1769. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
  1770. {
  1771. UNREFERENCED_PARAMETER(nFlags);
  1772. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1773. CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
  1774. if (!pThemeX || !pWViewDay || !pThemeX->GetCalendarControl())
  1775. {
  1776. ASSERT(FALSE);
  1777. return;
  1778. }
  1779. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
  1780. if (pWViewDay->NoAllEventsAreVisible())
  1781. {
  1782. BOOL bHot = pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE);
  1783. BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton);
  1784. if (bHot != bHotPrev)
  1785. {
  1786. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  1787. }
  1788. }
  1789. BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
  1790. if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
  1791. {
  1792. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  1793. }
  1794. }
  1795. BOOL CXTPCalendarThemeOffice2007::CTOWeekViewDay::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
  1796. {
  1797. UNREFERENCED_PARAMETER(nFlags);
  1798. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1799. CXTPCalendarViewDay* pViewDay = DYNAMIC_DOWNCAST(CXTPCalendarViewDay, pObject);
  1800. if (!pThemeX || !pViewDay || !pThemeX->GetCalendarControl())
  1801. {
  1802. ASSERT(FALSE);
  1803. return FALSE;
  1804. }
  1805. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
  1806. if (pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE))
  1807. {
  1808. pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
  1809. (WPARAM)(xtpCalendarUserAction_OnExpandDay | xtpCalendarExpandDayButton_WeekView),
  1810. (LPARAM)(LONG)(DATE)pViewDay->GetDayDate());
  1811. return TRUE;
  1812. }
  1813. return FALSE;
  1814. }
  1815. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::DoPropExchange(CXTPPropExchange* pPX)
  1816. {
  1817. ASSERT(pPX);
  1818. if (!pPX)
  1819. return;
  1820. CXTPPropExchangeSection secData(pPX->GetSection(_T("WeekViewDay")));
  1821. if (pPX->IsStoring())
  1822. secData->EmptySection();
  1823. PX_Color(&secData, _T("BorderColor"),       m_clrBorder);
  1824. PX_Color(&secData, _T("TodayBorderColor"),  m_clrTodayBorder);
  1825. PX_Color(&secData, _T("BackgroundLightColor"),   m_clrBackgroundLight);
  1826. PX_Color(&secData, _T("BackgroundDarkColor"),    m_clrBackgroundDark);
  1827. PX_Color(&secData, _T("BackgroundSelectedColor"), m_clrBackgroundSelected);
  1828. TBase::DoPropExchange(&secData);
  1829. }
  1830. void CXTPCalendarThemeOffice2007::CTOWeekViewDay::Serialize(CArchive& ar)
  1831. {
  1832. m_clrBorder.Serialize(ar);
  1833. m_clrTodayBorder.Serialize(ar);
  1834. m_clrBackgroundLight.Serialize(ar);
  1835. m_clrBackgroundDark.Serialize(ar);
  1836. m_clrBackgroundSelected.Serialize(ar);
  1837. TBase::Serialize(ar);
  1838. }
  1839. void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
  1840. {
  1841. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1842. CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
  1843. if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView())
  1844. {
  1845. ASSERT(FALSE);
  1846. return;
  1847. }
  1848. CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
  1849. COleDateTime dtDay = pWViewDay->GetDayDate();
  1850. int nDayCol = pThemeX->GetWeekViewPart()->GetDayPart()->GetDayCol(pWViewDay);
  1851. CPoint pt(0, 0);
  1852. if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
  1853. pThemeX->GetCalendarControl()->ScreenToClient(&pt);
  1854. BOOL bIsToday    = IsToday(pWViewDay);
  1855. BOOL bIsSelected = IsSelected(pWViewDay);
  1856. BOOL bFirstDay = nDayCol == 0;
  1857. BOOL bLastDay = nDayCol == 1;
  1858. int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
  1859. nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
  1860. if (dayLayout.m_rcDayHeader.PtInRect(pt))
  1861. {
  1862. nFlags |=  CTOHeader::xtpCalendarItemState_Hot;
  1863. dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  1864. }
  1865. else
  1866. {
  1867. dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
  1868. }
  1869. nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
  1870. nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
  1871. CRect rcRect(dayLayout.m_rcDay);
  1872. rcRect.bottom = dayLayout.m_rcDayHeader.bottom;
  1873. CString strTextLeft;
  1874. CString strTextCenter;
  1875. CString strTextRight;
  1876. if (m_UseOffice2003HeaderFormat)
  1877. {
  1878. strTextRight = pWViewDay->GetCaption();
  1879. }
  1880. else
  1881. {
  1882. strTextRight = CXTPCalendarUtils::GetDateFormat(dtDay, m_strHeaderFormat);
  1883. //------------------------------------------------------
  1884. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderLeft, &strTextLeft, pWViewDay);
  1885. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderCenter, &strTextCenter, pWViewDay);
  1886. pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderRight, &strTextRight, pWViewDay);
  1887. //------------------------------------------------------
  1888. }
  1889. Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
  1890. }
  1891. void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::DoPropExchange(CXTPPropExchange* pPX)
  1892. {
  1893. ASSERT(pPX);
  1894. if (!pPX)
  1895. return;
  1896. CXTPPropExchangeSection secData(pPX->GetSection(_T("WeekViewDayHeader")));
  1897. if (pPX->IsStoring())
  1898. secData->EmptySection();
  1899. m_strHeaderFormat.DoPropExchange(&secData, _T("HeaderFormat"));
  1900. if (pPX->GetSchema() >= _XTP_SCHEMA_112)
  1901. m_UseOffice2003HeaderFormat.DoPropExchange(&secData, _T("UseOffice2003HeaderFormat"));
  1902. TBase::DoPropExchange(&secData);
  1903. }
  1904. void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::Serialize(CArchive& ar)
  1905. {
  1906. m_strHeaderFormat.Serialize(ar);
  1907. m_UseOffice2003HeaderFormat.Serialize(ar);
  1908. TBase::Serialize(ar);
  1909. }
  1910. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
  1911. {
  1912. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  1913. CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
  1914. CXTPCalendarWeekViewDay* pMVDay = XTP_SAFE_GET2(pViewEvent, GetViewGroup(), GetViewDay(), NULL);
  1915. CXTPCalendarWeekView* pMView = XTP_SAFE_GET1(pMVDay, GetView(), NULL);
  1916. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
  1917. !pMView || !pMVDay)
  1918. {
  1919. ASSERT(FALSE);
  1920. return;
  1921. }
  1922. BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
  1923. int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
  1924. ASSERT(0 == (nMDEFlags & xtpCalendarMultiDaySlave)); // error for week view.
  1925. if (bNoVisibleMDEvent)
  1926. {
  1927. return;
  1928. }
  1929. CRect rcEventMax(pViewEvent->GetViewEventRectMax());
  1930. CRect rcEvent(pViewEvent->GetEventRect());
  1931. if (rcEvent.IsRectEmpty())
  1932. {
  1933. return;
  1934. }
  1935. // fill event background
  1936. BOOL bSelected = pViewEvent->IsSelected();
  1937. COLORREF clrBorderNotSel;
  1938. COLORREF clrBorder;
  1939. CXTPPaintManagerColorGradient grclrBk;
  1940. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
  1941. //----------------
  1942. pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
  1943. //------------------
  1944. int nViewDayIndex = pMVDay->GetDayIndex();
  1945. BOOL bFirstOnScreen = nViewDayIndex == 0;
  1946. BOOL bLastOnScreen = nViewDayIndex == 6;
  1947. CRect rcText(pViewEvent->GetTextRect());
  1948. if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
  1949. {
  1950. //CRect rcSQ = rcEvent;
  1951. ////rcSQ.left += min(1, rcSQ.Width());
  1952. CRect rcSQ = rcEventMax;
  1953. rcSQ.left += min(1, rcSQ.Width());
  1954. rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
  1955. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,0,1));
  1956. //-------------------------------------------------------------------
  1957. if (bFirstOnScreen)
  1958. {
  1959. CRect rcArrow;
  1960. BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
  1961. if (bArrow)
  1962. rcText.left = rcArrow.right;
  1963. }
  1964. }
  1965. else if (bSelected)
  1966. {
  1967. // draw left Gripper
  1968. CRect rcGripper;
  1969. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  1970. rcGripper.bottom = rcGripper.top + cnGripperSize;
  1971. rcGripper.left = rcEvent.left - 1;
  1972. rcGripper.right = rcGripper.left + cnGripperSize;
  1973. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  1974. CBrush brBorder(m_clrGripperBorder);
  1975. pDC->FrameRect(&rcGripper, &brBorder);
  1976. }
  1977. if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
  1978. {
  1979. //      CRect rcSQ = rcEvent;
  1980. //      rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
  1981. //      //rcSQ.right -= min(2, rcSQ.Width());
  1982. CRect rcSQ = rcEventMax;
  1983. rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
  1984. rcSQ.right -= min(2, rcSQ.Width());
  1985. CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,0, 1));
  1986. //-------------------------------------------------------------------
  1987. if (bLastOnScreen)
  1988. {
  1989. CRect rcArrow;
  1990. BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
  1991. if (bArrow)
  1992. rcText.right = rcArrow.left;
  1993. }
  1994. }
  1995. else if (bSelected)
  1996. {
  1997. // draw right gripper
  1998. CRect rcGripper;
  1999. rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
  2000. rcGripper.bottom = rcGripper.top + cnGripperSize;
  2001. rcGripper.right = rcEvent.right + 1;
  2002. rcGripper.left = rcGripper.right - cnGripperSize;
  2003. pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
  2004. CBrush brBorder(m_clrGripperBorder);
  2005. pDC->FrameRect(&rcGripper, &brBorder);
  2006. }
  2007. //****
  2008. pViewEvent->m_rcText.CopyRect(rcText);
  2009. //=====================================
  2010. CString strSubj = pViewEvent->GetItemTextSubject();
  2011. CString strLoc = pViewEvent->GetItemTextLocation();
  2012. if (!strLoc.IsEmpty())
  2013. {
  2014. strSubj += _T(";");
  2015. }
  2016. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  2017. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  2018. rcText.DeflateRect(3, 0, 3, 0);
  2019. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  2020. pViewEvent->m_rcSubjectEditor.top = rcEvent.top + 2;
  2021. pViewEvent->m_rcSubjectEditor.bottom = rcEvent.bottom - 2;
  2022. pViewEvent->AdjustSubjectEditor();
  2023. CRect rcIconsMax = rcText;
  2024. rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
  2025. //
  2026. BOOL bMarkupDrawn = FALSE;
  2027. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  2028. {
  2029. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  2030. ASSERT(pMarkupContext);
  2031. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  2032. if (pUIElement && pMarkupContext)
  2033. {
  2034. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2035. if (rcIconsMax.Height() > szIcons.cy)
  2036. {
  2037. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  2038. }
  2039. rcText.right = max(rcText.left,  rcText.right - szIcons.cx - 2);
  2040. //---------------------------------------------------------------
  2041. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  2042. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  2043. bMarkupDrawn = TRUE;
  2044. }
  2045. }
  2046. //
  2047. //----------------------------------------------------
  2048. if (!bMarkupDrawn)
  2049. {
  2050. UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
  2051. CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2052. rcText, uTextShortAlign | DT_CALCRECT);
  2053. //--- calculate rects and fix to be centered if enough space ---
  2054. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2055. if (rcIconsMax.Height() > szIcons.cy)
  2056. {
  2057. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
  2058. }
  2059. int nTIcx = szText.cx + szIcons.cx;
  2060. if (nTIcx + 5 < rcText.Width())
  2061. {
  2062. int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
  2063. rcText.left += ncx_2;
  2064. rcText.right = rcText.left + szText.cx + 2;
  2065. rcIconsMax.right -= ncx_2;
  2066. }
  2067. else
  2068. {
  2069. rcText.right -= szIcons.cx + 2;
  2070. }
  2071. pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2072. rcText, uTextShortAlign);
  2073. }
  2074. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  2075. }
  2076. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
  2077. {
  2078. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2079. CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
  2080. if (!pDC || !pThemeX || !pViewEvent)
  2081. {
  2082. ASSERT(FALSE);
  2083. return;
  2084. }
  2085. if (!pViewEvent->IsVisible())
  2086. {
  2087. return;
  2088. }
  2089. CRect rcEvent(pViewEvent->GetEventRect());
  2090. if (rcEvent.IsRectEmpty())
  2091. {
  2092. return;
  2093. }
  2094. // fill event background
  2095. Draw_Background(pDC, rcEvent, pViewEvent);
  2096. //
  2097. BOOL bMarkupDrawn = FALSE;
  2098. if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
  2099. {
  2100. CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
  2101. ASSERT(pMarkupContext);
  2102. CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
  2103. if (pUIElement && pMarkupContext)
  2104. {
  2105. BOOL bSelected = pViewEvent->IsSelected();
  2106. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  2107. CRect rcText = rcEvent;
  2108. rcText.DeflateRect(3, 2, 3, 2);
  2109. CRect rcIconsMax = rcText;
  2110. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2111. if (rcIconsMax.Height() > szIcons.cy)
  2112. {
  2113. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
  2114. }
  2115. rcText.right = max(rcText.left,  rcText.right - szIcons.cx - 2);
  2116. //---------------------------------------------------------------
  2117. XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
  2118. XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
  2119. bMarkupDrawn = TRUE;
  2120. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  2121. }
  2122. }
  2123. //
  2124. if (!bMarkupDrawn)
  2125. {
  2126. Draw_Time(pDC, rcEvent, pViewEvent);
  2127. CRect rcText(pViewEvent->GetTextRect());
  2128. Draw_Caption(pDC, rcText, pViewEvent);
  2129. }
  2130. }
  2131. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::
  2132. Draw_Background(CDC* pDC, const CRect& rcEventRect, CXTPCalendarWeekViewEvent* pViewEvent)
  2133. {
  2134. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2135. if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
  2136. {
  2137. ASSERT(FALSE);
  2138. return;
  2139. }
  2140. BOOL bSelected = pViewEvent->IsSelected();
  2141. COLORREF clrBorderNotSel, clrBorder;
  2142. CXTPPaintManagerColorGradient grclrBk;
  2143. int nColorsSrc_1Cat2Lbl = 0;
  2144. GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk, bSelected, &nColorsSrc_1Cat2Lbl);
  2145. if (!bSelected && nColorsSrc_1Cat2Lbl > 0)
  2146. {
  2147. clrBorder = grclrBk.clrLight;
  2148. }
  2149. pThemeX->DrawRoundRect(pDC, rcEventRect, clrBorder, bSelected, grclrBk);
  2150. }
  2151. CSize CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw_Time(
  2152. CDC* pDC, const CRect& rcEventRect, CXTPCalendarWeekViewEvent* pViewEvent)
  2153. {
  2154. CSize szResult(0, 0);
  2155. if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
  2156. {
  2157. ASSERT(FALSE);
  2158. return szResult;
  2159. }
  2160. BOOL bSelected = pViewEvent->IsSelected();
  2161. CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
  2162. COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
  2163. CXTPFontDC autoFont(pDC, pFont, clrColor);
  2164. //--------------------------
  2165. //*****************
  2166. // not implemented for office 2007 theme.
  2167. //if (pViewEvent->IsTimeAsClock()) {}
  2168. //*****************
  2169. CString strStartTime = pViewEvent->GetItemTextStartTime();
  2170. CString strEndTime = pViewEvent->GetItemTextEndTime();
  2171. CSize szStart = pDC->GetTextExtent(strStartTime);
  2172. CSize szEnd = pDC->GetTextExtent(strEndTime);
  2173. CRect rcStart(rcEventRect);
  2174. CRect rcEnd(rcEventRect);
  2175. DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
  2176. BOOL bShowEndTime = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), WeekView_IsShowEndDate(), TRUE);
  2177. BOOL bDrawStartTime = szStart.cx + 6 < rcEventRect.Width()/2 ||
  2178.   (dwOpt & xtpCalendarOptMonthViewShowStartTimeAlways);
  2179. BOOL bDrawEndTime = bShowEndTime && szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2 ||
  2180. (dwOpt & xtpCalendarOptMonthViewShowEndTimeAlways);
  2181. if (!bDrawStartTime && !bDrawEndTime)
  2182. {
  2183. return szResult;
  2184. }
  2185. rcStart.left = min(rcStart.left + 4, rcStart.right);
  2186. rcStart.right = min(rcStart.left + szStart.cx + 6, rcStart.right);
  2187. rcEnd.left = rcStart.right;
  2188. rcEnd.right = min(rcEnd.left + szEnd.cx + 6, rcEnd.right);
  2189. if (!bDrawEndTime)
  2190. {
  2191. rcEnd.right = rcEnd.left;
  2192. }
  2193. //-------------------------------------------------
  2194. UINT uAlign = DT_VCENTER | DT_SINGLELINE | DT_LEFT;
  2195. pDC->DrawText(strStartTime, &rcStart, uAlign);
  2196. if (bDrawEndTime)
  2197. {
  2198. pDC->DrawText(strEndTime, &rcEnd, uAlign);
  2199. }
  2200. //-------------------------------------------------
  2201. pViewEvent->m_rcStartTime.CopyRect(&rcStart);
  2202. pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
  2203. pViewEvent->m_rcText.left = rcEnd.right;
  2204. //-------------------------------------------------
  2205. szResult.cx = max(0, rcEnd.right - rcStart.left);
  2206. szResult.cy = szStart.cy;
  2207. return szResult;
  2208. }
  2209. void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw_Caption(
  2210. CDC* pDC, const CRect& rcTextRect, CXTPCalendarWeekViewEvent* pViewEvent)
  2211. {
  2212. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2213. if (!pDC || !pViewEvent || !pThemeX )
  2214. {
  2215. ASSERT(FALSE);
  2216. return;
  2217. }
  2218. CString strSubj = pViewEvent->GetItemTextSubject();
  2219. CString strLoc = pViewEvent->GetItemTextLocation();
  2220. if (!strLoc.IsEmpty())
  2221. {
  2222. strSubj += _T(";");
  2223. }
  2224. BOOL bSelected = pViewEvent->IsSelected();
  2225. CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
  2226. CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
  2227. CRect rcText = rcTextRect;
  2228. //rcText.DeflateRect(1, 2, 3, 2);
  2229. pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
  2230. pViewEvent->AdjustSubjectEditor();
  2231. UINT nAlign = DT_VCENTER | DT_LEFT | DT_SINGLELINE;
  2232. CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2233. rcText, nAlign  | DT_CALCRECT, nAlign);
  2234. //----------------------------------------------------
  2235. CRect rcIconsMax = rcText;
  2236. rcIconsMax.left = min(rcIconsMax.left + rcTextRect.Height(), rcIconsMax.right);
  2237. //--- calculate rects and fix to be centered if enough space ---
  2238. CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
  2239. if (rcIconsMax.Height() > szIcons.cy)
  2240. {
  2241. rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
  2242. }
  2243. int nTIcx = szText.cx + szIcons.cx;
  2244. if (nTIcx > rcText.Width())
  2245. {
  2246. rcText.right = max(rcIconsMax.left, rcIconsMax.right - szIcons.cx) - 2;
  2247. }
  2248. pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
  2249. rcText, nAlign, nAlign);
  2250. Draw_Icons(pViewEvent, pDC, rcIconsMax);
  2251. }
  2252. void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::RefreshMetrics(BOOL /*bRefreshChildren*/)
  2253. {
  2254. m_bPrev = 0 == _tcsnicmp(GetInstanceName(), _T("Prev"), 4);
  2255. m_nBitmapID.SetStandardValue(xtpIMG_PrevNextEventButtons) ;
  2256. m_rcBitmapBorder.SetStandardValue(CRect(1, 8, 1, 8));
  2257. if (!GetTheme())
  2258. return;
  2259. LOGFONT lfVert;
  2260. VERIFY( GetTheme()->m_fntBaseFont->GetLogFont(&lfVert) );
  2261. lfVert.lfOrientation = 900;
  2262. lfVert.lfEscapement = 900;
  2263. if (XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME))
  2264. {
  2265. STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
  2266. }
  2267. else
  2268. {
  2269. STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTPDrawHelpers()->GetVerticalFontName(TRUE));
  2270. }
  2271. m_fcsetText.fntFont.SetStandardValue(&lfVert);
  2272. m_fcsetText.clrColor.SetStandardValue(RGB(0, 0, 0));
  2273. m_clrDisabledText.SetStandardValue(RGB(136, 128, 128));
  2274. m_strText.SetStandardValue(XTPResourceManager()->LoadString(m_bPrev ? XTP_IDS_CALENDAR_PREVAPPOINTMENT : XTP_IDS_CALENDAR_NEXTAPPOINTMENT));
  2275. }
  2276. CSize CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::GetSize(const CRect* prcRect)
  2277. {
  2278. CSize szSize(23, 172);
  2279. if (prcRect)
  2280. {
  2281. if (prcRect->Height() < 35 ||
  2282. prcRect->Width() < szSize.cx * 2 + 1)
  2283. {
  2284. szSize.cx = szSize.cy = 0;
  2285. }
  2286. else if (szSize.cy + 70 > prcRect->Height())
  2287. {
  2288. szSize.cy = 34;
  2289. }
  2290. }
  2291. return szSize;
  2292. }
  2293. CRect CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::GetRect()
  2294. {
  2295. if (m_bVisible)
  2296. return m_rcRect;
  2297. else
  2298. return CRect(0, 0, 0, 0);
  2299. }
  2300. void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::AdjustLayout(CXTPCalendarView* /*pObject*/, CDC* /*pDC*/, const CRect& rcRect)
  2301. {
  2302. CSize szSize = GetSize(&rcRect);
  2303. m_rcRect = rcRect;
  2304. m_rcRect.top += (rcRect.Height() - szSize.cy) / 2;
  2305. m_rcRect.bottom = m_rcRect.top + szSize.cy;
  2306. if (m_bPrev)
  2307. {
  2308. m_rcRect.left++;
  2309. m_rcRect.right = m_rcRect.left + szSize.cx;
  2310. }
  2311. else
  2312. {
  2313. m_rcRect.right--;
  2314. m_rcRect.left = m_rcRect.right - szSize.cx;
  2315. }
  2316. }
  2317. void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::Draw(CXTPCalendarView* /*pObject*/, CDC* pDC)
  2318. {
  2319. if (m_rcRect.IsRectEmpty() || !m_bVisible || !GetTheme() || !GetTheme()->GetImageList())
  2320. return;
  2321. UINT nButmapID = (UINT)(int)m_nBitmapID;
  2322. // Lookup for bitmap
  2323. CXTPOffice2007Image* pImage = GetTheme()->GetImageList()->GetBitmap(nButmapID);
  2324. ASSERT(pImage);
  2325. CXTPOffice2007Image* pArrow = GetTheme()->GetBitmap(_T("CalendarPrevNextEventButtonArr"));
  2326. ASSERT(pArrow);
  2327. if (!pImage || !pArrow)
  2328. {
  2329. #ifdef _DEBUG
  2330. pDC->FillSolidRect(m_rcRect, RGB(200, 0, 0));
  2331. #else
  2332. m_bVisible = FALSE;
  2333. #endif
  2334. return;
  2335. }
  2336. //------------------------------------------
  2337. m_bHot = HitTest();
  2338. int nBkIdx = (m_bPrev ? 0 : 2) + (m_bHot && !m_bDisabled ? 1 : 0);
  2339. int nArrIdx = (m_bPrev ? 0 : 2) + (m_bDisabled ? 1 : 0);
  2340. CRect rcBkSrc = pImage->GetSource(nBkIdx, 4);
  2341. CRect rcArrSrc = pArrow->GetSource(nArrIdx, 4);
  2342. CRect rcArrDest = m_rcRect;
  2343. rcArrDest.OffsetRect(9, 12);
  2344. rcArrDest.right = rcArrDest.left + rcArrSrc.Width();
  2345. rcArrDest.bottom = rcArrDest.top + rcArrSrc.Height();
  2346. pImage->DrawImage(pDC, m_rcRect, rcBkSrc, m_rcBitmapBorder, RGB(255, 0, 255));
  2347. pArrow->DrawImage(pDC, rcArrDest, rcArrSrc, CRect(0,0,0,0), RGB(255, 0, 255));
  2348. //-------------------------------------------
  2349. CRect rcText = m_rcRect;
  2350. rcText.top = rcArrDest.bottom;
  2351. if (rcText.Height() > 100)
  2352. {
  2353. rcText.DeflateRect(1, 3, 1, 3);
  2354. int nTmp = rcText.top;
  2355. rcText.top = rcText.bottom;
  2356. rcText.bottom = nTmp;
  2357. int nRectSize = abs(rcText.Height());
  2358. //---
  2359. COLORREF clrText = m_bDisabled ? (COLORREF)m_clrDisabledText : (COLORREF)m_fcsetText.clrColor;
  2360. CXTPFontDC autoFont(pDC, m_fcsetText.fntFont, clrText);
  2361. CSize szText = pDC->GetTextExtent(m_strText);
  2362. // Center text vertically
  2363. if (szText.cx + 7 < nRectSize)
  2364. {
  2365. rcText.top = max(rcText.top - (nRectSize - szText.cx)/2, rcText.bottom);
  2366. }
  2367. if (szText.cy < rcText.Width())
  2368. {
  2369. rcText.left += (rcText.Width() - szText.cy) / 2;
  2370. }
  2371. pDC->DrawText((const CString&)m_strText, &rcText, DT_NOPREFIX | DT_SINGLELINE); //| DT_NOCLIP
  2372. }
  2373. }
  2374. int CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::HitTest(const CPoint* pPoint/* = NULL*/)
  2375. {
  2376. if (!m_bVisible || !GetTheme())
  2377. return 0;
  2378. CPoint pt(0, 0);
  2379. if (pPoint)
  2380. {
  2381. pt = *pPoint;
  2382. }
  2383. else if (GetTheme()->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
  2384. {
  2385. GetTheme()->GetCalendarControl()->ScreenToClient(&pt);
  2386. }
  2387. if (m_rcRect.PtInRect(pt))
  2388. {
  2389. return m_bPrev ? xtpCalendarHitTestPrevEventButton : xtpCalendarHitTestNextEventButton;
  2390. }
  2391. return 0;
  2392. }
  2393. void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::OnMouseMove(CCmdTarget* /*pObject*/, UINT /*nFlags*/, CPoint point)
  2394. {
  2395. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2396. if (!pThemeX )
  2397. {
  2398. ASSERT(FALSE);
  2399. return;
  2400. }
  2401. BOOL bHotNew = !!HitTest(&point);
  2402. if (m_bHot != bHotNew)
  2403. {
  2404. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  2405. }
  2406. }
  2407. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::OnLButtonDown(CCmdTarget* /*pObject*/, UINT /*nFlags*/, CPoint point)
  2408. {
  2409. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2410. if (!pThemeX || !pThemeX->GetPrevNextEventControllerPartX())
  2411. {
  2412. ASSERT(FALSE);
  2413. return FALSE;
  2414. }
  2415. BOOL bHitTest = HitTest(&point);
  2416. if (bHitTest)
  2417. {
  2418. COleDateTime dtDay;
  2419. BOOL bDayValid = FALSE;
  2420. if (m_bPrev)
  2421. bDayValid = pThemeX->GetPrevNextEventControllerPartX()->GetPrevEventDay(&dtDay);
  2422. else
  2423. bDayValid = pThemeX->GetPrevNextEventControllerPartX()->GetNextEventDay(&dtDay);
  2424. CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
  2425. ASSERT(pView);
  2426. if (pView && bDayValid)
  2427. {
  2428. XTPCalendarViewType nViewType = pView->GetViewType();
  2429. pView->ShowDay(dtDay);
  2430. pView = GetTheme()->GetCalendarControl()->GetActiveView();
  2431. if (pView && pView->GetViewType() != nViewType)
  2432. GetTheme()->GetCalendarControl()->SwitchActiveView(nViewType);
  2433. }
  2434. }
  2435. return bHitTest;
  2436. }
  2437. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::AdjustLayout(CXTPCalendarView* /*pObject*/, CDC* pDC, const CRect& rcRect)
  2438. {
  2439. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2440. if (!pThemeX || !GetPrevEventButtonPartX() || !GetNextEventButtonPartX())
  2441. {
  2442. ASSERT(FALSE);
  2443. return;
  2444. }
  2445. m_rcRect = rcRect;
  2446. BOOL bIsPrevNextButtonsVisible = IsPrevNextButtonsVisible();
  2447. if (pDC && pDC->IsPrinting())
  2448. bIsPrevNextButtonsVisible = FALSE;
  2449. GetPrevEventButtonPartX()->m_bVisible = bIsPrevNextButtonsVisible;
  2450. GetNextEventButtonPartX()->m_bVisible = bIsPrevNextButtonsVisible;
  2451. if (!bIsPrevNextButtonsVisible)
  2452. {
  2453. _StopRequests();
  2454. }
  2455. else
  2456. {
  2457. GetPrevEventButtonPartX()->m_bDisabled = !GetPrevEventDay();
  2458. GetNextEventButtonPartX()->m_bDisabled = !GetNextEventDay();
  2459. }
  2460. //--------------------------------------------
  2461. if (GetPrevEventButtonPartX())
  2462. GetPrevEventButtonPartX()->AdjustLayout(NULL, pDC, rcRect);
  2463. if (GetNextEventButtonPartX())
  2464. GetNextEventButtonPartX()->AdjustLayout(NULL, pDC, rcRect);
  2465. }
  2466. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::Draw(CXTPCalendarView* /*pObject*/, CDC* pDC)
  2467. {
  2468. if (GetPrevEventButtonPartX())
  2469. GetPrevEventButtonPartX()->Draw(NULL, pDC);
  2470. if (GetNextEventButtonPartX())
  2471. GetNextEventButtonPartX()->Draw(NULL, pDC);
  2472. }
  2473. int CXTPCalendarThemeOffice2007::CTOPrevNextEventController::HitTest(const CPoint* pPoint)
  2474. {
  2475. int nHit = 0;
  2476. if (GetPrevEventButtonPartX())
  2477. nHit = GetPrevEventButtonPartX()->HitTest(pPoint);
  2478. if (!nHit && GetNextEventButtonPartX())
  2479. nHit = GetNextEventButtonPartX()->HitTest(pPoint);
  2480. return nHit;
  2481. }
  2482. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
  2483. {
  2484. if (GetPrevEventButtonPartX())
  2485. GetPrevEventButtonPartX()->OnMouseMove(pObject, nFlags, point);
  2486. if (GetNextEventButtonPartX())
  2487. GetNextEventButtonPartX()->OnMouseMove(pObject, nFlags, point);
  2488. }
  2489. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
  2490. {
  2491. BOOL b1 = FALSE, b2 = FALSE;
  2492. if (GetPrevEventButtonPartX())
  2493. b1 = GetPrevEventButtonPartX()->OnLButtonDown(pObject, nFlags, point);
  2494. if (GetNextEventButtonPartX())
  2495. b2 = GetNextEventButtonPartX()->OnLButtonDown(pObject, nFlags, point);
  2496. return b1 || b2;
  2497. }
  2498. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnStatusChanged()
  2499. {
  2500. CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
  2501. if (!pThemeX )
  2502. {
  2503. ASSERT(FALSE);
  2504. return;
  2505. }
  2506. CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
  2507. AdjustLayout(NULL, NULL, m_rcRect);
  2508. DBG_TRACE_PREVNEXTBTN(_T("PrevNextEventController::OnStatusChanged() n"));
  2509. }
  2510. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::IsPrevNextButtonsVisible()
  2511. {
  2512. HWND hWnd = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetSafeHwnd(), NULL);
  2513. if (!hWnd)
  2514. return FALSE;
  2515. return !_IsSomeEventVisible();
  2516. }
  2517. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_IsSomeEventVisible()
  2518. {
  2519. CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
  2520. ASSERT(pView);
  2521. if (!pView)
  2522. return FALSE;
  2523. int nDays = pView->GetViewDayCount();
  2524. for (int nDay = 0; nDay < nDays; nDay++)
  2525. {
  2526. CXTPCalendarViewDay* pDay = pView->GetViewDay_(nDay);
  2527. ASSERT(pDay);
  2528. if (!pDay)
  2529. continue;
  2530. int nGroupsCount = pDay->GetViewGroupsCount();
  2531. for (int i = 0; i < nGroupsCount; i++)
  2532. {
  2533. if (pDay->GetViewGroup_(i) && pDay->GetViewGroup_(i)->GetViewEventsCount())
  2534. return TRUE;
  2535. }
  2536. }
  2537. return FALSE;
  2538. }
  2539. COleDateTime CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetVisibleDay(BOOL bFirst)
  2540. {
  2541. CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
  2542. ASSERT(pView);
  2543. if (!pView)
  2544. return (DATE)0;
  2545. if (bFirst)
  2546. {
  2547. return pView->GetViewDayDate(0);
  2548. }
  2549. int nDays = pView->GetViewDayCount();
  2550. return pView->GetViewDayDate(max(0, nDays - 1));
  2551. }
  2552. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetPrevEventDay(COleDateTime* pdtDay)
  2553. {
  2554. if (pdtDay)
  2555. *pdtDay = COleDateTime((DATE)0);
  2556. long nFirstDay = (long)GetVisibleDay(TRUE);
  2557. long nPrevDay = 0;
  2558. int nCount = m_arNotEmptyDays.GetSize();
  2559. for (int i = 0; i < nCount; i++)
  2560. {
  2561. if (nFirstDay > m_arNotEmptyDays[i])
  2562. nPrevDay = m_arNotEmptyDays[i];
  2563. else
  2564. break;
  2565. }
  2566. if (nPrevDay > 0)
  2567. {
  2568. if (pdtDay)
  2569. *pdtDay = COleDateTime((DATE)nPrevDay);
  2570. return TRUE;
  2571. }
  2572. m_ndtRefreshDatePrev = nFirstDay - 1;
  2573. m_bScanPrev = TRUE;
  2574. _RequestToFindEvents();
  2575. return FALSE;
  2576. }
  2577. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetNextEventDay(COleDateTime* pdtDay)
  2578. {
  2579. if (pdtDay)
  2580. *pdtDay = COleDateTime((DATE)0);
  2581. long nDay = (long)GetVisibleDay(FALSE);
  2582. long nNextDay = 0;
  2583. int nCount = m_arNotEmptyDays.GetSize();
  2584. for (int i = 0; i < nCount; i++)
  2585. {
  2586. if (nDay < m_arNotEmptyDays[i])
  2587. {
  2588. nNextDay = m_arNotEmptyDays[i];
  2589. break;
  2590. }
  2591. }
  2592. if (nNextDay > 0)
  2593. {
  2594. if (pdtDay)
  2595. *pdtDay = COleDateTime((DATE)nNextDay);
  2596. return TRUE;
  2597. }
  2598. m_ndtRefreshDateNext = nDay + 1;
  2599. m_bScanNext = TRUE;
  2600. _RequestToFindEvents();
  2601. return FALSE;
  2602. }
  2603. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnTimer(UINT_PTR uTimerID)
  2604. {
  2605. if (m_nRefreshTimerID != (UINT)uTimerID)
  2606. return FALSE;
  2607. BOOL bIsEventsPrev = FALSE;
  2608. BOOL bIsEventsNext = FALSE;
  2609. if (m_bScanPrev && m_ndtRefreshDatePrev > m_ndtMinScanDay)
  2610. {
  2611. for (int i = 0; i < m_nRefreshDaysPerIdleStep; i++)
  2612. {
  2613. DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_RefreshDay(-- %d) n"), m_nRefreshTimerID, m_ndtRefreshDatePrev);
  2614. bIsEventsPrev = _RefreshDay(m_ndtRefreshDatePrev);
  2615. m_ndtRefreshDatePrev--;
  2616. if (bIsEventsPrev)
  2617. {
  2618. m_bScanPrev = FALSE;
  2619. break;
  2620. }
  2621. }
  2622. }
  2623. else
  2624. {
  2625. m_bScanPrev = FALSE;
  2626. }
  2627. if (m_bScanNext && m_ndtRefreshDateNext < m_ndtMaxScanDay)
  2628. {
  2629. for (int i = 0; i < m_nRefreshDaysPerIdleStep; i++)
  2630. {
  2631. DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_RefreshDay(%d ++) n"), m_nRefreshTimerID, m_ndtRefreshDateNext);
  2632. bIsEventsNext = _RefreshDay(m_ndtRefreshDateNext);
  2633. m_ndtRefreshDateNext++;
  2634. if (bIsEventsNext)
  2635. {
  2636. m_bScanNext = FALSE;
  2637. break;
  2638. }
  2639. }
  2640. }
  2641. else
  2642. {
  2643. m_bScanNext = FALSE;
  2644. }
  2645. BOOL bStatusChanged = bIsEventsPrev || bIsEventsNext;
  2646. if (!m_bScanPrev && !m_bScanNext)
  2647. {
  2648. DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_StopRequests(Prev=%d, Next=%d) n"),
  2649.  m_nRefreshTimerID, m_bScanPrev, m_bScanNext);
  2650. _StopRequests();
  2651. bStatusChanged = TRUE;
  2652. }
  2653. if (bStatusChanged)
  2654. {
  2655. OnStatusChanged();
  2656. }
  2657. return TRUE;
  2658. }
  2659. BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_RefreshDay(long ndtDay)
  2660. {
  2661. // TODO: Change to use multi-Data Providers from Resources
  2662. // also PrePopulate events have to be used too ???
  2663. //
  2664. CXTPCalendarData* pData = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetDataProvider(), NULL);
  2665. ASSERT(pData);
  2666. if (!pData)
  2667. return FALSE;
  2668. CXTPCalendarEventsPtr ptrEvents = pData->RetrieveDayEvents((DATE)ndtDay);
  2669. BOOL bIsEvents = ptrEvents && ptrEvents->GetCount() > 0;
  2670. if (bIsEvents)
  2671. m_arNotEmptyDays.AddDay(ndtDay);
  2672. else
  2673. m_arNotEmptyDays.RemoveElement(ndtDay);
  2674. return bIsEvents;
  2675. }
  2676. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_RequestToFindEvents()
  2677. {
  2678. if (m_nRefreshTimerID)
  2679. return;
  2680. m_nRefreshTimerID = SetTimer((UINT)m_nIdleStepTime_ms);
  2681. ASSERT(m_nRefreshTimerID);
  2682. DBG_TRACE_PREVNEXTBTN(_T("n%d *** PrevNextEventController::_RequestToFindEvents() n"), m_nRefreshTimerID);
  2683. }
  2684. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_StopRequests()
  2685. {
  2686. if (m_nRefreshTimerID)
  2687. KillTimer(m_nRefreshTimerID);
  2688. m_nRefreshTimerID = 0;
  2689. }
  2690. void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnDetachCalendar()
  2691. {
  2692. _StopRequests();
  2693. }
  2694. /////////////////////////////////////////////////////////////////////////////