XTPCalendarThemeOffice2007.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:211k
源码类别:
对话框与窗口
开发平台:
Visual C++
- rcIconsMax.bottom = rcIconsMax.top + rcIconsMax.Height()/2 + szIcons.cy/2;
- }
- rcIconsMax.left = min(rcIconsMax.left + rcTopRow.Height(), rcIconsMax.right);
- rcText.right = max(rcText.right - szIcons.cx - 2, rcText.left + rcTopRow.Height() - 2);
- }
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- //pViewEvent->AdjustSubjectEditorEx(FALSE);
- pViewEvent->AdjustSubjectEditor();
- if (!bMarkupDrawn)
- {
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- CString strBody = pViewEvent->GetItemTextBody();
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- CThemeFontColorSet* pFntClr3 = bSelected ? &m_fcsetSelected.fcsetBody : &m_fcsetNormal.fcsetBody;
- //------------------------------------------------------------
- UINT uWordBreakMode = DT_WORDBREAK;
- DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
- if (dwOpt & xtpCalendarOptDayViewNoWordBreak)
- uWordBreakMode = DT_WORD_ELLIPSIS;
- pThemeX->DrawText_Auto2SL3ML(pDC, strSubj, strLoc, strBody,
- pFntClr1, pFntClr2, pFntClr3, rcText, _T(";"), uWordBreakMode);
- }
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- /*
- BOOL bOutOfBorders = nY_need > rcText.Height() ||
- nX_need > rcText.Width() ||
- bTimeOutOfBorders;
- pViewEvent->SetTextOutOfBorders(bOutOfBorders);
- */
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::DrawShadow(CDC* pDC, CXTPCalendarDayViewEvent* pViewEvent)
- {
- ASSERT(pDC && pViewEvent);
- if (!pDC || pDC->IsPrinting() || !pViewEvent)
- return;
- CRect rcEvent(pViewEvent->GetEventRect());
- CRect rcTimeframe(pViewEvent->m_rcTimeframe);
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // ----- Fill event background -----
- int nTopRow = pViewEvent->GetViewGroup()->GetTopRow();
- CRect rcTopRow = pViewEvent->GetViewGroup()->GetCellRect(nTopRow);
- BOOL bShortEvent = rcTimeframe.Height() + 1 < rcTopRow.Height();
- // --- Calculate event rectangle ---
- CRect rcRect(rcEvent);
- if (bShortEvent)
- rcRect.left += 5;
- //------------------------------------------------------------------------
- CXTPCalendarPaintManager::CXTPShadowDrawer oShadow(pDC, dXTPMaxAlpha2007);
- CRect rcVShadow(rcRect);
- rcVShadow.left = rcVShadow.right;
- rcVShadow.right += 5;
- rcVShadow.top += 5*2 + 1;
- oShadow.DrawShadowRectPart(rcVShadow, oShadow.xtpShadow2007Right);
- CRect rcHShadow(rcRect);
- rcHShadow.left += 5*2;
- rcHShadow.top = rcHShadow.bottom;
- rcHShadow.bottom += 5;
- oShadow.DrawShadowRectPart(rcHShadow, oShadow.xtpShadow2007Bottom);
- CRect rcTRShadow(rcVShadow);
- rcTRShadow.bottom = rcTRShadow.top;
- rcTRShadow.top -= 6;
- oShadow.DrawShadowRectPart(rcTRShadow, oShadow.xtpShadow2007TopRight);
- CRect rcBLShadow(rcHShadow);
- rcBLShadow.right = rcBLShadow.left;
- rcBLShadow.left -= 5;
- oShadow.DrawShadowRectPart(rcBLShadow, oShadow.xtpShadow2007BottomLeft);
- CRect rcBRShadow(rcVShadow.left - 3, rcHShadow.top - 3, rcVShadow.right, rcHShadow.bottom);
- oShadow.DrawShadowRectPart(rcBRShadow, oShadow.xtpShadow2007BottomRight);
- }
- void CXTPCalendarThemeOffice2007::_DrawEventLTHighlight(CDC* pDC, CPoint ptLT, int nRTx, const CXTPPaintManagerColorGradient& grclrBk,
- int nLTCorner, int nLBy, BOOL bRCorner)
- {
- COLORREF clrTop = XTPDrawHelpers()->LightenColor(120, grclrBk.clrLight);
- CRect rcTop(ptLT.x + nLTCorner, ptLT.y, nRTx, ptLT.y + 1);
- if (bRCorner)
- rcTop.right -= cnCornerSize / 2 + 1;
- pDC->FillSolidRect(&rcTop, clrTop);
- if(nLBy != INT_MAX)
- {
- CRect rcLLVert(ptLT.x, ptLT.y + nLTCorner, ptLT.x + 1, nLBy - nLTCorner);
- rcLLVert.top += nLTCorner ? 0 : 1;
- COLORREF clrLight = XTPDrawHelpers()->LightenColor(76, grclrBk.clrLight);
- COLORREF clrDrak = XTPDrawHelpers()->LightenColor(15, grclrBk.clrDark);
- XTPDrawHelpers()->GradientFill(pDC, rcLLVert, clrLight, clrDrak, FALSE);
- CPen pen(PS_SOLID, 1, clrLight);
- CXTPPenDC autoPen(pDC, &pen);
- pDC->MoveTo(rcLLVert.TopLeft());
- pDC->LineTo(rcTop.TopLeft());
- }
- if (bRCorner)
- {
- COLORREF clrLight2 = XTPDrawHelpers()->LightenColor(80, grclrBk.clrLight);
- CPen pen(PS_SOLID, 1, clrLight2);
- CXTPPenDC autoPen(pDC, &pen);
- pDC->MoveTo(rcTop.right, rcTop.top);
- pDC->LineTo(rcTop.right + cnCornerSize / 2 + 1, rcTop.top + cnCornerSize / 2 + 1);
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::InitBusyStatusDefaultColors()
- {
- TBase2::InitBusyStatusDefaultColors();
- SetBusyStatusBrush(xtpCalendarBusyStatusBusy, NULL, FALSE);
- // Tentative ---------------------------
- m_bmpTentativePattern.DeleteObject();
- m_brushTentative.DeleteObject();
- VERIFY(XTPResourceManager()->LoadBitmap(&m_bmpTentativePattern, XTP_IDB_CALENDAR_TENATIVE_PATTERN_2007));
- VERIFY(m_brushTentative.CreatePatternBrush(&m_bmpTentativePattern));
- CXTPCalendarViewPartBrushValue* pBVal_Tentative = _GetBusyStatusBrushValue(xtpCalendarBusyStatusTentative, TRUE);
- if (pBVal_Tentative)
- {
- pBVal_Tentative->SetStandardValue(&m_brushTentative, FALSE);
- }
- }
- void CXTPCalendarThemeOffice2007::CTODayViewEvent_SingleDay::AdjustLayout(CCmdTarget* pObject,
- CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
- {
- UNREFERENCED_PARAMETER(nEventPlaceNumber);
- CXTPCalendarDayViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarDayViewEvent, pObject);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() || !pViewEvent->GetViewGroup() ||
- !pViewEvent->GetViewGroup()->GetViewDay())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarEvent* pEvent = pViewEvent->GetEvent();
- CXTPCalendarDayViewGroup* pViewGroup = pViewEvent->GetViewGroup();
- CXTPCalendarDayViewDay* pViewDay = pViewGroup->GetViewDay();
- pViewEvent->m_nMultiDayEventFlags |= xtpCalendarMultiDayNoMultiDay;
- // non all-day event
- int nPace = pViewEvent->GetEventPlacePos();
- int nPaceCount = max(1, pViewEvent->GetEventPlaceCount());
- ASSERT(pViewEvent->GetEventPlaceCount() >= 1);
- ASSERT(nPace >= 0 && nPace < nPaceCount);
- pViewEvent->m_rcEvent.CopyRect(rcRect);
- int nEventsAreaX = pViewEvent->m_rcEvent.Width() - 5;
- int nEventWidth = nEventsAreaX / nPaceCount;
- // skip event views if they are not fit even by 5 pixel bar width
- // and correct some first event views heights
- if (nEventWidth <= 5)
- {
- while (nPaceCount > 1 && nEventWidth <= 5)
- {
- nPaceCount--;
- nEventWidth = nEventsAreaX / nPaceCount;
- }
- if (nPace > nPaceCount)
- {
- pViewEvent->m_rcEvent.SetRectEmpty();
- return;
- }
- }
- // calc other rect coordinates
- pViewEvent->m_rcEvent.left += nEventWidth * nPace;
- pViewEvent->m_rcEvent.right = pViewEvent->m_rcEvent.left + nEventWidth;
- //-------------------------------------------------------------------
- COleDateTime dtStartTime(pEvent->GetStartTime());
- COleDateTime dtEndTime(pEvent->GetEndTime());
- int nTopRow = pViewGroup->GetTopRow();
- CRect rcTopRow = pViewGroup->GetCellRect(nTopRow);
- CRect rcRow0 = pViewGroup->GetCellRect(0);
- CRect rcRowLast = pViewGroup->GetCellRect(pViewGroup->GetRowCount()-1);
- COleDateTime dtTopRowTime = pViewDay->GetView()->GetCellTime(nTopRow);
- dtTopRowTime = (double)pViewDay->GetDayDate() + (double)dtTopRowTime;
- double dblCellDur = (double)pViewDay->GetView()->GetCellDuration();
- if (dblCellDur <= XTP_HALF_SECOND)
- {
- dblCellDur = XTP_HALF_SECOND * 2 * 60 * 30;
- }
- double dblEventOffsetTime1 = double(dtStartTime - dtTopRowTime);
- double dblEventOffsetTime2 = double(dtEndTime - dtTopRowTime);
- double dblPixelPerTime = rcTopRow.Height() / dblCellDur;
- int nEventY1 = int(dblPixelPerTime * dblEventOffsetTime1);
- nEventY1 = max(rcRow0.top, rcTopRow.top + nEventY1);
- nEventY1 = min(rcRowLast.top, nEventY1);
- int nEventY2 = int(dblPixelPerTime * dblEventOffsetTime2);
- nEventY2 = rcTopRow.top + nEventY2;
- nEventY2 = min(rcRowLast.bottom, nEventY2);
- int nEvent_dy = nEventY2 - nEventY1;
- BOOL bShortEvent = nEvent_dy + 1 < rcTopRow.Height();
- nEvent_dy = max(5, nEvent_dy);
- if (bShortEvent)
- {
- nEventY2 = nEventY1 + rcTopRow.Height();
- }
- ///%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- pViewEvent->m_rcEvent.top = nEventY1;
- pViewEvent->m_rcEvent.bottom = nEventY2;
- pViewEvent->m_rcEventMax.top = max(pViewEvent->m_rcEvent.top-5, rcRect.top);
- pViewEvent->m_rcEventMax.bottom = min(pViewEvent->m_rcEvent.bottom + 5, rcRect.bottom);
- // adjust subject area
- pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
- pViewEvent->m_rcText.left += 10; // correct to busy area
- pViewEvent->m_rcText.left += 4;
- pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcText);
- // Set time frame rect
- pViewEvent->m_rcTimeframe.top = pViewEvent->m_rcEvent.top;
- pViewEvent->m_rcTimeframe.bottom = pViewEvent->m_rcTimeframe.top + nEvent_dy;
- pViewEvent->m_rcTimeframe.left = pViewEvent->m_rcEvent.left + 1;
- pViewEvent->m_rcTimeframe.right = pViewEvent->m_rcTimeframe.left + 4;
- // set expanded signs for day view
- CRect rcEvents = rcRect;
- if (pViewEvent->m_rcEvent.top >= rcEvents.bottom-10)
- pViewEvent->GetViewGroup()->SetExpandDown();
- if (pViewEvent->m_rcEvent.bottom <= rcEvents.top + 10)
- pViewEvent->GetViewGroup()->SetExpandUp();
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // ***** Month View *****
- //
- void CXTPCalendarThemeOffice2007::CTOMonthView::RefreshMetrics(BOOL bRefreshChildren)
- {
- TBase::RefreshMetrics(bRefreshChildren);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetEventPartX());
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
- XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, FALSE, FALSE, FALSE, FALSE) );
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetMonthViewPartX()->GetEventPartX());
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto) );
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
- //---------------------------------
- m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
- m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
- m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pThemeX->m_fntBaseFont);
- m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventFromToDates));
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetMonthViewPartX()->GetEventPartX());
- CFont* pFontDef = pThemeX->m_fntBaseFont;
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRto) );
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_MonthViewSingleDayEventBkGRto) );
- //----------------------------------------------
- pThemeX->RemoveBoldAttrFromStd(m_fcsetNormal.fcsetSubject.fntFont);
- pThemeX->RemoveBoldAttrFromStd(m_fcsetSelected.fcsetSubject.fntFont);
- //----------------------------------------------
- m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewEventTime));
- m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
- m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewEventTime));
- m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
- }
- int CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::CalcWidth(CDC* pDC)
- {
- return CalcHeight(pDC, -1);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthView::AdjustLayout(CDC* pDC, const CRect& rcRect, BOOL bCallPostAdjustLayout)
- {
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView,
- XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetMonthView(), NULL));
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- int nWHeaderWidth = GetWeekHeaderPartX()->CalcWidth(pDC);
- CRect rcRectWHeader = rcRect;
- rcRectWHeader.right = min(rcRectWHeader.left + nWHeaderWidth, rcRect.right);
- GetWeekHeaderPartX()->AdjustLayout(pMonthView, pDC, rcRectWHeader);
- CRect rcRectGrid = rcRect;
- rcRectGrid.left = rcRectWHeader.right;
- TBase::AdjustLayout(pDC, rcRectGrid, bCallPostAdjustLayout);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRectGrid);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent::AdjustLayout(CCmdTarget* pObject,
- CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
- {
- CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
- if (!pDC || !GetTheme() || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- int nEventHeight = XTP_SAFE_GET4(pViewEvent, GetViewGroup(), GetViewDay(), GetView(), GetRowHeight(), 0);
- pViewEvent->m_rcEventMax.top = rcRect.top + nEventPlaceNumber * nEventHeight;
- pViewEvent->m_rcEventMax.bottom = pViewEvent->m_rcEventMax.top + nEventHeight;
- pViewEvent->m_rcEvent.top = pViewEvent->m_rcEventMax.top;
- pViewEvent->m_rcEvent.bottom = pViewEvent->m_rcEventMax.bottom;
- pViewEvent->m_rcEvent.left = pViewEvent->m_rcEventMax.left + 4 + 2;
- pViewEvent->m_rcEvent.right = pViewEvent->m_rcEventMax.right - 5 - 2;
- pViewEvent->m_rcToolTip.CopyRect(pViewEvent->m_rcEventMax);
- // adjust subject area
- int nDyx = pViewEvent->IsSelected() ? 5 : 2;
- pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
- pViewEvent->m_rcText.DeflateRect(nDyx + 3, 3, nDyx + 2, 3);
- // set times rects
- pViewEvent->m_rcStartTime.SetRectEmpty();
- pViewEvent->m_rcEndTime.SetRectEmpty();
- pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcEvent);
- pViewEvent->m_rcSubjectEditor.top++;
- pViewEvent->m_rcSubjectEditor.bottom--;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthView::Draw(CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView,
- XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetMonthView(), NULL));
- if (!pDC || !pMonthView || !pThemeX)
- {
- ASSERT(FALSE);
- return;
- }
- pDC->SetBkMode(TRANSPARENT);
- GetWeekHeaderPartX()->Draw(pMonthView, pDC);
- //TBase::Draw(pDC);
- GetWeekDayHeaderPart()->Draw(pMonthView, pDC);
- //CXTPPropsStateContext autoStateCnt1_day(GetDayPart(), xtpCalendarBeforeDraw_MonthViewDay, TRUE);
- CXTPPropsStateContext autoStateCnt1_day(GetDayPart(), 0, TRUE);
- //-- Draw Days with events ------------------------------
- int nCount = pMonthView->GetViewDayCount();
- int i;
- for (i = nCount - 1; i >= 0; i--)
- {
- CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetViewDay(i);
- ASSERT(pViewDay);
- if (pViewDay)
- {
- GetDayPartX()->SetDynColors(pViewDay);
- autoStateCnt1_day.SendBeforeDrawThemeObject((LPARAM)pViewDay, xtpCalendarBeforeDraw_MonthViewDay);
- GetDayPart()->Draw(pViewDay, pDC);
- autoStateCnt1_day.RestoreState();
- }
- }
- autoStateCnt1_day.Clear();
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
- // All saved data must be freed after draw!
- ASSERT(CXTPPropsState::s_dbg_nActiveStates == 0);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetHeaderPartX());
- m_clrBaseColor.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekDayHeaderBk"), RGB(227, 239, 255)));
- m_bkNormal.nBitmapID. SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
- m_bkSelected.nBitmapID. SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
- m_bkToday.nBitmapID. SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
- m_bkTodaySelected.nBitmapID.SetStandardValue(0); //xtpIMG_MonthViewWeekDayHeader);
- m_TextCenter.fcsetNormal.clrColor.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekDayHeaderText"), RGB(101, 147, 201)));
- // 0 - Sunday, 1 - Monday, ...; 7 - Sat/Sun
- m_arWeekDayNamesLong.RemoveAll();
- m_arWeekDayNamesShort.RemoveAll();
- m_arWeekDayNamesLong.SetSize(8);
- m_arWeekDayNamesShort.SetSize(8);
- for (int i = 0; i < 7; i++)
- {
- CString sWDlong = CXTPCalendarUtils::GetLocaleString(LOCALE_SDAYNAME1 + i, 100);
- CString sWDshort = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVDAYNAME1 + i, 100);
- m_arWeekDayNamesLong [(i + 1) % 7] = sWDlong;
- m_arWeekDayNamesShort[(i + 1) % 7] = sWDshort;
- }
- m_arWeekDayNamesLong [7] = m_arWeekDayNamesLong[6] + _T("/") + m_arWeekDayNamesLong[0];
- m_arWeekDayNamesShort[7] = m_arWeekDayNamesShort[6] + _T("/") + m_arWeekDayNamesShort[0];
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetHeaderPartX());
- m_clrFreeSpaceBk.SetStandardValue(pThemeX->GetColor2(_T("MonthViewWeekHeaderFreeSpaceBk"), RGB(227, 239, 255)));
- m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
- m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
- m_bkToday.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
- m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewWeekHeader);
- LOGFONT lfVert;
- VERIFY( m_TextCenter.fcsetNormal.fntFont->GetLogFont(&lfVert) );
- lfVert.lfOrientation = 900;
- lfVert.lfEscapement = 900;
- if (XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME))
- {
- STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
- }
- else
- {
- STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTPDrawHelpers()->GetVerticalFontName(TRUE));
- }
- m_TextCenter.fcsetNormal.fntFont.SetStandardValue(&lfVert);
- m_TextCenter.fcsetNormal.clrColor.SetStandardValue(RGB(0, 0, 0)); //pThemeX->GetColor(xtpCLR_HeaderBorder));
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(13, 10, 1));
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::AdjustLayout(
- CCmdTarget* pObject, CDC* pDC, const CRect& rcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
- if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMonthView->GetGrid();
- int nColsCount = pGrid->GetColsCount();
- int nCellWidth = rcRect.Width() / max(1, nColsCount);
- int nHeaderHeight = CalcHeight(pDC, nCellWidth);
- pGrid->SetColHeaderHeight(nHeaderHeight);
- if (!nColsCount || m_arWeekDayNamesLong.GetSize() < 8 ||
- m_arWeekDayNamesShort.GetSize() < 8)
- {
- ASSERT(FALSE);
- return;
- }
- CString strDWMaxLong;
- for (int i = 0; i < 7; i++)
- {
- if (strDWMaxLong.GetLength() < m_arWeekDayNamesLong[i].GetLength())
- {
- strDWMaxLong = m_arWeekDayNamesLong[i];
- }
- }
- CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.Font());
- CSize szWDlong = pDC->GetTextExtent(strDWMaxLong);
- CSize szSaSuLong = pDC->GetTextExtent(m_arWeekDayNamesLong[7]);
- int nRectSize = nCellWidth;
- m_bWeekDayNamesLong = szWDlong.cx + szWDlong.cx/4 + nRectSize/5 < nRectSize;
- m_bWeekDayNameSaSuLong = szSaSuLong.cx + szSaSuLong.cx/4 + nRectSize/5 < nRectSize;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
- if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMonthView->GetGrid();
- CRect rcWDHeader = pMonthView->GetViewRect();
- rcWDHeader.bottom = rcWDHeader.top + pGrid->GetColHeaderHeight();
- CXTPPropsStateContext autoStateCnt1(this, xtpCalendarBeforeDraw_MonthViewWeekDayHeader, TRUE);
- autoStateCnt1.SendBeforeDrawThemeObject((LPARAM)-1);
- //===========================================
- CStringArray arColHeaderText;
- CUIntArray arWeekDays;
- arColHeaderText.SetSize(7);
- arWeekDays.SetSize(7);
- for (int i = 0; i < 7; i++)
- {
- int nCol = pGrid->GetWeekDayCol(i + 1);
- CString sVal = arColHeaderText[nCol];
- if (!sVal.IsEmpty())
- {
- // compressed col - always Sat/Sun
- arColHeaderText[nCol] = m_bWeekDayNameSaSuLong ? m_arWeekDayNamesLong[7] : m_arWeekDayNamesShort[7];
- arWeekDays[nCol] = 7;
- }
- else
- {
- CString sWD = m_bWeekDayNamesLong ? m_arWeekDayNamesLong[i] : m_arWeekDayNamesShort[i];
- arColHeaderText[nCol] = sWD;
- arWeekDays[nCol] = i + 1;
- }
- }
- CXTPPropsStateContext autoStateCnt2_wd(this, xtpCalendarBeforeDraw_MonthViewWeekDayHeader);
- //===========================================
- int nColsCount = pGrid->GetColsCount();
- for (int nCol = 0; nCol < nColsCount; nCol++)
- {
- CRect rcCell = pGrid->GetCelRect(0, nCol, TRUE);
- rcCell.top = rcWDHeader.top;
- rcCell.bottom = rcWDHeader.bottom;
- CString strWD = arColHeaderText[nCol];
- int nWeekDay = arWeekDays[nCol];
- autoStateCnt2_wd.SendBeforeDrawThemeObject((LPARAM)nWeekDay);
- //--------------------------------------------------------
- pMonthView->GetWeekDayTextIfNeed(&strWD, nWeekDay);
- Draw_Header(pDC, rcCell, 0, _T(""), strWD);
- if (nCol +1 < nColsCount)
- {
- CRect rcLine = rcCell;
- rcLine.left = rcLine.right - 1;
- rcLine.top += 2;
- pDC->FillSolidRect(rcLine, (COLORREF)m_TextCenter.fcsetNormal.clrColor);
- }
- //--------------------------------------------------------
- autoStateCnt2_wd.RestoreState();
- }
- autoStateCnt2_wd.Clear();
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::AdjustLayout(CCmdTarget* pObject, CDC* pDC, const CRect& rcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
- if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- //***
- m_rcHeader = rcRect;
- //***
- int nWeeksCount = pMonthView->GetGrid()->GetWeeksCount();
- if (!nWeeksCount)
- {
- return;
- }
- CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetGrid()->GetViewDay(0, 0);
- ASSERT(pViewDay);
- if (!pViewDay)
- {
- return;
- }
- const CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = pThemeX->GetViewDayLayout(pViewDay);
- COleDateTime dtWDay1 = pViewDay->GetDayDate();
- CRect rcWHeaderTextVert = m_rcHeader;
- rcWHeaderTextVert.top = dayLayout.m_rcDayHeader.bottom;
- rcWHeaderTextVert.bottom = dayLayout.m_rcDay.bottom;
- //---
- CString strTmp, strCaptionLong;
- FormatWeekCaption(dtWDay1, strTmp, strCaptionLong, 2);
- CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.fntFont, m_TextCenter.fcsetNormal.clrColor);
- CSize szText1 = pDC->GetTextExtent(strCaptionLong);
- int nRectSize = abs(rcWHeaderTextVert.Height());
- m_bDateFormatShort = TRUE;
- if (szText1.cx + szText1.cx/3 + nRectSize/10 < nRectSize)
- {
- m_bDateFormatShort = FALSE;
- }
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekDayHeader::Draw_Borders2(
- CDC* /*pDC*/, const CRect& /*rcRect*/, BOOL /*bDrawRightBorder*/)
- {
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("MonthViewWeekHeader")));
- if (pPX->IsStoring())
- secData->EmptySection();
- PX_Color(&secData, _T("FreeSpaceBkColor"), m_clrFreeSpaceBk);
- TBase::DoPropExchange(pPX);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Serialize(CArchive& ar)
- {
- m_clrFreeSpaceBk.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, pObject);
- if (!pDC || !pThemeX || !pMonthView || !pMonthView->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPPropsStateContext autoStateCnt1(this, xtpCalendarBeforeDraw_MonthViewWeekHeader, TRUE);
- autoStateCnt1.SendBeforeDrawThemeObject((LPARAM)-1);
- pDC->FillSolidRect(&m_rcHeader, m_clrFreeSpaceBk);
- CXTPFontDC autoFont(pDC, m_TextCenter.fcsetNormal.fntFont, m_TextCenter.fcsetNormal.clrColor);
- CXTPPropsStateContext autoStateCnt2_week(this, xtpCalendarBeforeDraw_MonthViewWeekHeader);
- int nWeeksCount = pMonthView->GetGrid()->GetWeeksCount();
- for (int i = 0; i < nWeeksCount; i++)
- {
- CXTPCalendarMonthViewDay* pViewDay = pMonthView->GetGrid()->GetViewDay(i, 0);
- ASSERT(pViewDay);
- if (!pViewDay)
- {
- continue;
- }
- const CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = pThemeX->GetViewDayLayout(pViewDay);
- COleDateTime dtWDay1 = pViewDay->GetDayDate();
- CRect rcWHeader = m_rcHeader;
- rcWHeader.left+= 3;
- rcWHeader.top = dayLayout.m_rcDayHeader.bottom - 1;
- rcWHeader.bottom = dayLayout.m_rcDay.bottom;
- autoStateCnt2_week.SendBeforeDrawThemeObject((LPARAM)i);
- //--------------------------------------------------
- CString strWeekCaption;
- FormatWeekCaption(dtWDay1, strWeekCaption, strWeekCaption, m_bDateFormatShort ? 1 : 2);
- //--------------------------------------------------
- Draw_Background(pDC, rcWHeader, 0);
- Draw_TextCenter(pDC, rcWHeader, 0, strWeekCaption);
- if (i +1 < nWeeksCount)
- autoStateCnt2_week.RestoreState();
- }
- autoStateCnt2_week.Clear();
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::Draw_TextCenter(CDC* pDC, const CRect& rcRect, int nState,
- LPCTSTR pcszCenterText, int* pnWidth)
- {
- UNREFERENCED_PARAMETER(nState);
- UNREFERENCED_PARAMETER(pnWidth);
- // Warning: not supported.
- ASSERT(pnWidth == NULL);
- CRect rcWHeaderTextVert = rcRect;
- rcWHeaderTextVert.DeflateRect(1, 3, 1, 3);
- int nTmp = rcWHeaderTextVert.top;
- rcWHeaderTextVert.top = rcWHeaderTextVert.bottom;
- rcWHeaderTextVert.bottom = nTmp;
- int nRectSize = abs(rcWHeaderTextVert.Height());
- //---
- CSize szText = pDC->GetTextExtent(pcszCenterText);
- // Center text vertically
- if (szText.cx + 7 < nRectSize)
- {
- rcWHeaderTextVert.top = max(rcWHeaderTextVert.top - (nRectSize - szText.cx)/2, rcWHeaderTextVert.bottom);
- }
- pDC->DrawText(CString(pcszCenterText), &rcWHeaderTextVert, DT_NOPREFIX | DT_SINGLELINE); //| DT_NOCLIP
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::FormatWeekCaption(COleDateTime dtWDay1,
- CString& rstrShort, CString& rstrLong, int nShort1Long2 )
- {
- //LOCALE_IDATE - short date format ordering
- // 0 Month-Day-Year
- // 1 Day-Month-Year
- // 2 Year-Month-Day
- int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
- CString strDSeparator = CXTPCalendarUtils::GetLocaleString(LOCALE_SDATE, 100);
- // SHORT
- COleDateTime dtWDay6 = dtWDay1 + COleDateTimeSpan(6, 0, 0, 0);
- const int cnBuffSize = 128;
- TCHAR szWDay1[cnBuffSize], szMonth1[cnBuffSize];
- TCHAR szWDay6[cnBuffSize], szMonth6[cnBuffSize];
- ITOT_S(dtWDay1.GetDay(), szWDay1, cnBuffSize);
- ITOT_S(dtWDay6.GetDay(), szWDay6, cnBuffSize);
- if (nShort1Long2 == 0 || nShort1Long2 == 1)
- {
- ITOT_S(dtWDay1.GetMonth(), szMonth1, cnBuffSize);
- ITOT_S(dtWDay6.GetMonth(), szMonth6, cnBuffSize);
- rstrShort = _FormatWCaption(szWDay1, szMonth1, szWDay6, szMonth6, strDSeparator, nDateOrdering);
- }
- if (nShort1Long2 == 0 || nShort1Long2 == 2)
- {
- CString strMonth1 = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + dtWDay1.GetMonth() - 1, 100);
- CString strMonth6 = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + dtWDay6.GetMonth() - 1, 100);
- rstrLong = _FormatWCaption(szWDay1, strMonth1, szWDay6, strMonth6, _T(" "), nDateOrdering);
- }
- }
- CString CXTPCalendarThemeOffice2007::CTOMonthViewWeekHeader::_FormatWCaption(LPCTSTR pcszDay1, LPCTSTR pcszMonth1,
- LPCTSTR pcszDay6, LPCTSTR pcszMonth6,
- LPCTSTR pcszDayMonthSeparator, int nDateOrdering)
- {
- //LOCALE_IDATE - short date format ordering
- // 0 Month-Day-Year
- // 1 Day-Month-Year
- // 2 Year-Month-Day
- CString strCaption;
- if (_tcsicmp(pcszMonth1, pcszMonth6) == 0)
- {
- if (nDateOrdering == 1)
- {
- strCaption.Format(_T("%s - %s%s%s"), pcszDay1, pcszDay6,
- pcszDayMonthSeparator, pcszMonth6);
- }
- else
- {
- strCaption.Format(_T("%s%s%s - %s"), pcszMonth1, pcszDayMonthSeparator,
- pcszDay1, pcszDay6);
- }
- }
- else
- {
- if (nDateOrdering == 1)
- {
- strCaption.Format(_T("%s%s%s - %s%s%s"), pcszDay1, pcszDayMonthSeparator,
- pcszMonth1, pcszDay6, pcszDayMonthSeparator, pcszMonth6);
- }
- else
- {
- strCaption.Format(_T("%s%s%s - %s%s%s"), pcszMonth1, pcszDayMonthSeparator,
- pcszDay1, pcszMonth6, pcszDayMonthSeparator, pcszDay6);
- }
- }
- return strCaption;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
- //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
- m_clrBackgroundLight.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkLight));
- m_clrBackgroundDark.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkDark));
- m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_MonthViewDayBkSelected));
- TBase::RefreshMetrics(bRefreshChildren);
- m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::SetDynColors(CXTPCalendarMonthViewDay* pMViewDay)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
- XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
- if (!pMViewDay || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewGroup* pViewGroup = pMViewDay->GetViewGroupsCount() ? pMViewDay->GetViewGroup_(0) : NULL;
- //--------------------------------------------------------------------
- CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
- m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, pMViewDay->GetDayDate(), -1, bsColors);
- //--------------------------------------------------------------------
- m_clrDynHatch = 0;
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
- m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
- m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
- {
- m_clrDynHatch = bsColors.clrBkAllDayEvents;
- if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
- {
- m_clrBackgroundLight = bsColors.clrBkAllDayEvents;
- m_clrBackgroundDark = bsColors.clrBkAllDayEvents;
- m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
- }
- }
- else
- {
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
- {
- m_clrBackgroundLight = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
- m_clrBackgroundDark = (COLORREF)m_clrBackgroundLight;
- }
- m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
- }
- }
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
- CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
- XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
- if (!pDC || !pThemeX || !pCellDynBkPart || !pMViewDay || !pMViewDay->GetView() ||
- !pMViewDay->GetView()->GetGrid() || pMViewDay->GetViewGroupsCount() == 0 ||
- !pMViewDay->GetViewGroup(0) || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarMonthView::CMonthViewGrid* pGrid = pMViewDay->GetView()->GetGrid();
- CXTPCalendarMonthViewGroup* pMViewGroup = pMViewDay->GetViewGroup(0);
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
- CRect rcDay = dayLayout.m_rcDay;
- CRect rcBorders = rcDay;
- rcBorders.top = dayLayout.m_rcDayHeader.bottom;
- COleDateTime dtDay = pMViewDay->GetDayDate();
- COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
- BOOL bIsToday = GetHeaderPart()->IsToday(pMViewDay);
- BOOL bIsSelected = GetHeaderPart()->IsSelected(pMViewDay);
- //-----------------
- int nCurrentMonth = dtNow.GetMonth();
- int nLiteBkColorIdx = nCurrentMonth % 2;
- int nMonth = dtDay.GetMonth();
- COLORREF clrBackground = nMonth % 2 == nLiteBkColorIdx ? m_clrBackgroundLight : m_clrBackgroundDark;
- if (bIsSelected)
- {
- clrBackground = m_clrBackgroundSelected;
- }
- pDC->FillSolidRect(rcDay, clrBackground);
- //--------------------------------------------------------------------
- if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBackground);
- CBrush br(HS_BDIAGONAL, m_clrDynHatch);
- pDC->FillRect(&rcDay, &br);
- }
- //--------------------------------------------------------------------
- if (bIsToday)
- {
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 2, CRect(1, 0, 1, 1));
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(0, 0, 1, 0));
- }
- else
- {
- int nColIdx = pGrid->GetWeekDayCol(dtDay.GetDayOfWeek());
- int nIsLBorder = nColIdx == 0 ? 1 : 0;
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(nIsLBorder, 0, 1, 0));
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 2, CRect(0, 0, 0, 1));
- }
- //------------------
- GetHeaderPart()->Draw(pMViewDay, pDC);
- //=====================
- BOOL bCnt_EvS = FALSE;
- BOOL bCnt_EvMul = FALSE;
- CXTPPropsStateContext autoStateCnt_EvS;
- CXTPPropsStateContext autoStateCnt_EvMul;
- int nCount = pMViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarViewEvent* pViewEvent = pMViewGroup->GetViewEvent_(i);
- ASSERT(pViewEvent);
- if (pViewEvent && pViewEvent->IsVisible())
- {
- if (pViewEvent->IsMultidayEvent())
- {
- if (!bCnt_EvMul)
- autoStateCnt_EvMul.SetData(GetMultiDayEventPartX(), xtpCalendarBeforeDraw_MonthViewEvent, TRUE);
- bCnt_EvMul = TRUE;
- autoStateCnt_EvMul.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
- GetMultiDayEventPartX()->Draw(pViewEvent, pDC);
- autoStateCnt_EvMul.RestoreState();
- }
- else
- {
- if (!bCnt_EvS)
- autoStateCnt_EvS.SetData(GetSingleDayEventPartX(), xtpCalendarBeforeDraw_MonthViewEvent, TRUE);
- bCnt_EvS = TRUE;
- autoStateCnt_EvS.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
- GetSingleDayEventPartX()->Draw(pViewEvent, pDC);
- autoStateCnt_EvS.RestoreState();
- }
- }
- }
- if (!pDC->IsPrinting() && pMViewDay->NoAllEventsAreVisible())
- {
- CRect rc = dayLayout.m_rcDay;
- rc.right -= 5;
- rc.bottom -= 5;
- BOOL bHot = HitTestExpandDayButton(pMViewDay) != 0;
- dayLayout.m_rcExpandSign = pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
- if (bHot)
- dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
- else
- dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
- }
- autoStateCnt_EvS.Clear();
- autoStateCnt_EvMul.Clear();
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
- if (!pThemeX || !pMViewDay || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
- if (pMViewDay->NoAllEventsAreVisible())
- {
- BOOL bHot = pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE);
- BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton);
- if (bHot != bHotPrev)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
- if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL CXTPCalendarThemeOffice2007::CTOMonthViewDay::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
- if (!pThemeX || !pMViewDay || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
- if (pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE))
- {
- pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
- (WPARAM)(xtpCalendarUserAction_OnExpandDay | xtpCalendarExpandDayButton_MonthView),
- (LPARAM)(LONG)(DATE)pMViewDay->GetDayDate());
- return TRUE;
- }
- return FALSE;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("MonthViewDay")));
- if (pPX->IsStoring())
- secData->EmptySection();
- PX_Color(&secData, _T("BorderColor"), m_clrBorder);
- PX_Color(&secData, _T("TodayBorderColor"), m_clrTodayBorder);
- PX_Color(&secData, _T("BackgroundLightColor"), m_clrBackgroundLight);
- PX_Color(&secData, _T("BackgroundDarkColor"), m_clrBackgroundDark);
- PX_Color(&secData, _T("BackgroundSelectedColor"), m_clrBackgroundSelected);
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDay::Serialize(CArchive& ar)
- {
- m_clrBorder.Serialize(ar);
- m_clrTodayBorder.Serialize(ar);
- m_clrBackgroundLight.Serialize(ar);
- m_clrBackgroundDark.Serialize(ar);
- m_clrBackgroundSelected.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetMonthViewPartX()->GetHeaderPartX());
- // m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
- m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeader);
- m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeader);
- m_bkToday.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeaderToday);
- m_bkTodaySelected.nBitmapID.SetStandardValue(xtpIMG_MonthViewDayHeaderToday);
- m_bkToday.rcBitmapBorder. SetStandardValue(CRect(1, 1, 2, 1));
- m_bkTodaySelected.rcBitmapBorder.SetStandardValue(CRect(1, 1, 2, 1));
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewDay* pMViewDay = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewDay, pObject);
- if (!pDC || !pThemeX || !pMViewDay || !pThemeX->GetCalendarControl() ||
- !pMViewDay->GetView() || !pMViewDay->GetView()->GetGrid())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pMViewDay);
- COleDateTime dtDay = pMViewDay->GetDayDate();
- BOOL bCompressWeD = XTP_SAFE_GET3(pMViewDay, GetView(), GetCalendarControl(), MonthView_IsCompressWeekendDays(), FALSE);
- BOOL bIsToday = IsToday(pMViewDay);
- BOOL bIsSelected = IsSelected(pMViewDay);
- int nDImod7 = pMViewDay->GetDayIndex() % 7;
- BOOL bFirstDay = nDImod7 == 0 || (nDImod7 == 6 && bCompressWeD);
- BOOL bLastDay = nDImod7 >= (bCompressWeD ? 5 : 6);
- CPoint pt(0, 0);
- if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
- pThemeX->GetCalendarControl()->ScreenToClient(&pt);
- int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
- nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
- if (dayLayout.m_rcDayHeader.PtInRect(pt))
- {
- nFlags |= CTOHeader::xtpCalendarItemState_Hot;
- dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- else
- {
- dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
- nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
- CRect rcRect = dayLayout.m_rcDay;
- //***
- rcRect.bottom = dayLayout.m_rcDayHeader.bottom;
- CString strTextLeft;
- CString strTextCenter;
- CString strTextRight;
- int nMonth = dtDay.GetMonth();
- int nDay = dtDay.GetDay();
- if (nDay == 1 || pMViewDay->GetDayIndex() == 0)
- {
- CString strMonth = CXTPCalendarUtils::GetLocaleString(LOCALE_SABBREVMONTHNAME1 + nMonth - 1, 100);
- //LOCALE_IDATE - short date format ordering
- // 0 Month-Day-Year
- // 1 Day-Month-Year
- // 2 Year-Month-Day
- int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
- if (nDateOrdering == 1)
- {
- strTextLeft.Format(_T("%d %s"), nDay, (LPCTSTR)strMonth);
- }
- else
- {
- strTextLeft.Format(_T("%s %d"), (LPCTSTR)strMonth, nDay);
- }
- }
- else
- {
- strTextLeft.Format(_T("%d"), nDay);
- }
- //------------------------------------------------------
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderLeft, &strTextLeft, pMViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderCenter, &strTextCenter, pMViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_MonthViewDayHeaderRight, &strTextRight, pMViewDay);
- //------------------------------------------------------
- Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::Draw_Time(CDC* pDC, const CRect& rcEventRect,
- CXTPCalendarMonthViewEvent* pViewEvent)
- {
- if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bSelected = pViewEvent->IsSelected();
- CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
- COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
- CXTPFontDC autoFont(pDC, pFont, clrColor);
- //--------------------------
- COleDateTime dtStart(pViewEvent->GetEvent()->GetStartTime());
- COleDateTime dtEnd(pViewEvent->GetEvent()->GetEndTime());
- //*****************
- // not implemented for office 2007 theme.
- //if (pViewEvent->IsTimeAsClock()) {}
- //*****************
- CString strStartTime = pViewEvent->GetItemTextStartTime();
- CString strEndTime = pViewEvent->GetItemTextEndTime();
- CSize szStart = pDC->GetTextExtent(strStartTime);
- CSize szEnd = pDC->GetTextExtent(strEndTime);
- CRect rcStart(rcEventRect);
- CRect rcEnd(rcEventRect);
- BOOL bDrawStartEndTimes = szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2;
- if (!bDrawStartEndTimes)
- {
- return;
- }
- rcStart.left = min(rcStart.left + 6, rcStart.right);
- rcStart.right = min(rcStart.left + szStart.cx + 2, rcStart.right);
- rcEnd.right = max(rcEnd.right - 6, rcEventRect.left);
- rcEnd.left = max(rcEnd.right - szEnd.cx - 2, rcEventRect.left);
- //-------------------------------------------------
- UINT uAlign = DT_VCENTER | DT_SINGLELINE ;
- pDC->DrawText(strStartTime, &rcStart, uAlign | DT_LEFT);
- pDC->DrawText(strEndTime, &rcEnd, uAlign | DT_RIGHT);
- //-------------------------------------------------
- pViewEvent->m_rcStartTime.CopyRect(&rcStart);
- pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
- pViewEvent->m_rcText.left = rcStart.right;
- pViewEvent->m_rcText.right = rcEnd.left;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
- CXTPCalendarMonthViewDay* pMVDay = XTP_SAFE_GET2(pViewEvent, GetViewGroup(), GetViewDay(), NULL);
- CXTPCalendarMonthView* pMView = XTP_SAFE_GET1(pMVDay, GetView(), NULL);
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
- !pMView || !pMVDay)
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
- int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
- if ((nMDEFlags & xtpCalendarMultiDaySlave) || bNoVisibleMDEvent)
- {
- return;// was drawn in the Master (or out of events rect)
- }
- CRect rcEventMax(pViewEvent->GetViewEventRectMax());
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // fill event background
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
- //----------------
- pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
- int nSelOffset = bSelected ? 2 : 1;
- if (nMDEFlags & xtpCalendarMultiDayFirst)
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, cnCornerSize / 2, rcEvent.bottom);
- //------------------
- int nViewDayIndex = pMVDay->GetDayIndex();
- BOOL bCompressWD = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), MonthView_IsCompressWeekendDays(), FALSE);
- int nLastDayDx = bCompressWD ? 1 : 7;
- BOOL bFirstOnScreen = nViewDayIndex == 0;
- BOOL bLastOnScreen = nViewDayIndex == (pMView->GetViewDayCount() - nLastDayDx);
- CRect rcText(pViewEvent->GetTextRect());
- if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
- {
- CRect rcSQ = rcEventMax;
- rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(1,1,0,1));
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcEvent.left + nSelOffset, rcEvent.top + nSelOffset),
- rcEvent.right - nSelOffset, grclrBk, 0, rcEvent.bottom - nSelOffset);
- //-------------------------------------------------------------------
- if (bFirstOnScreen)
- {
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
- if (bArrow)
- rcText.left = rcArrow.right;
- }
- }
- else if (bSelected)
- {
- // draw left Gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.left = rcEvent.left - 1;
- rcGripper.right = rcGripper.left + cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
- {
- CRect rcSQ = rcEventMax;
- rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,1,1));
- pThemeX->_DrawEventLTHighlight(pDC, CPoint(rcSQ.left, rcEvent.top + nSelOffset),
- rcEventMax.right - nSelOffset, grclrBk, 0, INT_MAX, FALSE);
- //-------------------------------------------------------------------
- if (bLastOnScreen)
- {
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
- if (bArrow)
- rcText.right = rcArrow.left;
- }
- }
- else if (bSelected)
- {
- // draw right gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.right = rcEvent.right + 1;
- rcGripper.left = rcGripper.right - cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- int nMDFirstLastMask = (xtpCalendarMultiDayFirst|xtpCalendarMultiDayLast);
- if ((nMDEFlags & nMDFirstLastMask) == nMDFirstLastMask)
- {
- COleDateTime dtStart = pViewEvent->GetEvent()->GetStartTime();
- COleDateTime dtEnd = pViewEvent->GetEvent()->GetEndTime();
- if (!CXTPCalendarUtils::IsZeroTime(dtStart) && !CXTPCalendarUtils::IsZeroTime(dtEnd))
- {
- Draw_Time(pDC, rcEvent, pViewEvent);
- rcText = pViewEvent->GetTextRect();
- }
- }
- //****
- pViewEvent->m_rcText.CopyRect(rcText);
- //=====================================
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- rcText.DeflateRect(3, 0, 3, 0);
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- pViewEvent->m_rcSubjectEditor.top = rcEvent.top + 2;
- pViewEvent->m_rcSubjectEditor.bottom = rcEvent.bottom - 2;
- pViewEvent->AdjustSubjectEditor();
- CRect rcIconsMax = rcText;
- rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
- //
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- rcText.right = max(rcText.left, rcText.right - szIcons.cx - 2);
- //---------------------------------------------------------------
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- }
- }
- //
- //----------------------------------------------------
- if (!bMarkupDrawn)
- {
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- if (!strLoc.IsEmpty())
- {
- strSubj += _T(";");
- }
- //----------------------------------------------------
- UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
- CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign | DT_CALCRECT);
- //--- calculate rects and fix to be centered if enough space ---
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
- }
- int nTIcx = szText.cx + szIcons.cx;
- if (nTIcx + 5 < rcText.Width())
- {
- int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
- rcText.left += ncx_2;
- rcText.right = rcText.left + szText.cx + 2;
- rcIconsMax.right -= ncx_2;
- }
- else
- {
- rcText.right -= szIcons.cx + 2;
- }
- pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign);
- }
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarMonthViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarMonthViewEvent, pObject);
- if (!pDC || !pThemeX || !pViewEvent)
- {
- ASSERT(FALSE);
- return;
- }
- if (!pViewEvent->IsVisible())
- {
- return;
- }
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // fill event background
- Draw_Background(pDC, rcEvent, pViewEvent);
- //
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- BOOL bSelected = pViewEvent->IsSelected();
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CRect rcText = rcEvent;
- rcText.DeflateRect(3, 2, 3, 2);
- CRect rcIconsMax = rcText;
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- rcText.right = max(rcText.left, rcText.right - szIcons.cx - 2);
- //---------------------------------------------------------------
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- }
- //
- if (!bMarkupDrawn)
- {
- Draw_Time(pDC, rcEvent, pViewEvent);
- CRect rcText(pViewEvent->GetTextRect());
- Draw_Caption(pDC, rcText, pViewEvent);
- }
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::
- Draw_Background(CDC* pDC, const CRect& rcEventRect, CXTPCalendarMonthViewEvent* pViewEvent)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel, clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- int nColorsSrc_1Cat2Lbl = 0;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk, bSelected, &nColorsSrc_1Cat2Lbl);
- if (!bSelected && nColorsSrc_1Cat2Lbl > 0)
- {
- clrBorder = grclrBk.clrLight;
- }
- pThemeX->DrawRoundRect(pDC, rcEventRect, clrBorder, bSelected, grclrBk);
- }
- CSize CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw_Time(
- CDC* pDC, const CRect& rcEventRect, CXTPCalendarMonthViewEvent* pViewEvent)
- {
- CSize szResult(0, 0);
- if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return szResult;
- }
- BOOL bSelected = pViewEvent->IsSelected();
- CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
- COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
- CXTPFontDC autoFont(pDC, pFont, clrColor);
- //--------------------------
- //*****************
- // not implemented for office 2007 theme.
- //if (pViewEvent->IsTimeAsClock()) {}
- //*****************
- CString strStartTime = pViewEvent->GetItemTextStartTime();
- CString strEndTime = pViewEvent->GetItemTextEndTime();
- CSize szStart = pDC->GetTextExtent(strStartTime);
- CSize szEnd = pDC->GetTextExtent(strEndTime);
- CRect rcStart(rcEventRect);
- CRect rcEnd(rcEventRect);
- DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
- BOOL bShowEndTime = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), MonthView_IsShowEndDate(), TRUE);
- BOOL bDrawStartTime = szStart.cx + 6 < rcEventRect.Width()/2 ||
- (dwOpt & xtpCalendarOptMonthViewShowStartTimeAlways);
- BOOL bDrawEndTime = bShowEndTime && szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2 ||
- (dwOpt & xtpCalendarOptMonthViewShowEndTimeAlways);
- if (!bDrawStartTime && !bDrawEndTime)
- {
- return szResult;
- }
- rcStart.left = min(rcStart.left + 4, rcStart.right);
- rcStart.right = min(rcStart.left + szStart.cx + 6, rcStart.right);
- rcEnd.left = rcStart.right;
- rcEnd.right = min(rcEnd.left + szEnd.cx + 6, rcEnd.right);
- if (!bDrawEndTime)
- {
- rcEnd.right = rcEnd.left;
- }
- //-------------------------------------------------
- UINT uAlign = DT_VCENTER | DT_SINGLELINE | DT_LEFT;
- pDC->DrawText(strStartTime, &rcStart, uAlign);
- if (bDrawEndTime)
- {
- pDC->DrawText(strEndTime, &rcEnd, uAlign);
- }
- //-------------------------------------------------
- pViewEvent->m_rcStartTime.CopyRect(&rcStart);
- pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
- pViewEvent->m_rcText.left = rcEnd.right;
- //-------------------------------------------------
- szResult.cx = max(0, rcEnd.right - rcStart.left);
- szResult.cy = szStart.cy;
- return szResult;
- }
- void CXTPCalendarThemeOffice2007::CTOMonthViewEvent_SingleDay::Draw_Caption(
- CDC* pDC, const CRect& rcTextRect, CXTPCalendarMonthViewEvent* pViewEvent)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pViewEvent || !pThemeX )
- {
- ASSERT(FALSE);
- return;
- }
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- if (!strLoc.IsEmpty())
- {
- strSubj += _T(";");
- }
- BOOL bSelected = pViewEvent->IsSelected();
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- CRect rcText = rcTextRect;
- //rcText.DeflateRect(1, 2, 3, 2);
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- pViewEvent->AdjustSubjectEditor();
- UINT nAlign = DT_VCENTER | DT_LEFT | DT_SINGLELINE;
- CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, nAlign | DT_CALCRECT, nAlign);
- //----------------------------------------------------
- CRect rcIconsMax = rcText;
- rcIconsMax.left = min(rcIconsMax.left + rcTextRect.Height(), rcIconsMax.right);
- //--- calculate rects and fix to be centered if enough space ---
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
- }
- int nTIcx = szText.cx + szIcons.cx;
- if (nTIcx > rcText.Width())
- {
- rcText.right = max(rcIconsMax.left, rcIconsMax.right - szIcons.cx) - 2;
- }
- pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, nAlign, nAlign);
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // ***** Week View *****
- //
- void CXTPCalendarThemeOffice2007::CTOWeekView::RefreshMetrics(BOOL bRefreshChildren)
- {
- TBase::RefreshMetrics(bRefreshChildren);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekView::AdjustLayout(CDC* pDC, const CRect& rcRect, BOOL bCallPostAdjustLayout)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::AdjustLayout(pDC, rcRect, bCallPostAdjustLayout);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->AdjustLayout(NULL, pDC, rcRect);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekView::Draw(CCmdTarget* /*pObject*/, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::Draw(pDC);
- if (pThemeX->GetPrevNextEventControllerPartX())
- pThemeX->GetPrevNextEventControllerPartX()->Draw(NULL, pDC);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- TBase::RefreshMetrics(bRefreshChildren);
- RefreshFromParent(pThemeX->GetEventPartX());
- XTP_SAFE_CALL1(GetHeightFormulaPart(), SetStandardValue(14, 10, 1));
- XTP_SAFE_CALL1(GetEventIconsToDrawPart(), SetStandardValue(FALSE, FALSE, FALSE, FALSE, FALSE) );
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_MultiDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetWeekViewPartX()->GetEventPartX());
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_MultiDayEventBkGRto));
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_MultiDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(m_fcsetNormal.grclrBackground);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- RefreshFromParent(pThemeX->GetWeekViewPartX()->GetEventPartX());
- CFont* pFontDef = pThemeX->m_fntBaseFont;
- m_fcsetNormal.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBorder));
- m_fcsetNormal.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRto) );
- m_fcsetSelected.clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventSelectedBorder));
- m_fcsetSelected.grclrBackground.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRfrom),
- pThemeX->GetColor(xtpCLR_WeekViewSingleDayEventBkGRto) );
- //----------------------------------------------
- pThemeX->RemoveBoldAttrFromStd(m_fcsetNormal.fcsetSubject.fntFont);
- pThemeX->RemoveBoldAttrFromStd(m_fcsetSelected.fcsetSubject.fntFont);
- //----------------------------------------------
- m_fcsetNormal.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewEventTime));
- m_fcsetNormal.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
- m_fcsetSelected.fcsetStartEnd.clrColor.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewEventTime));
- m_fcsetSelected.fcsetStartEnd.fntFont.SetStandardValue(pFontDef);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::RefreshMetrics(BOOL bRefreshChildren)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- m_clrBorder.SetStandardValue(pThemeX->GetColor(xtpCLR_DayBorder));
- //m_clrTodayBorder.SetStandardValue(XTP_CALENDAR_OFFICE2007_TODAYBORDER);
- m_clrBackgroundLight.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkLight));
- m_clrBackgroundDark.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkDark));
- m_clrBackgroundSelected.SetStandardValue(pThemeX->GetColor(xtpCLR_WeekViewDayBkSelected));
- TBase::RefreshMetrics(bRefreshChildren);
- m_clrTodayBorder.SetStandardValue(GetHeaderPartX()->m_clrTodayBaseColor);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::RefreshMetrics(BOOL bRefreshChildren)
- {
- UNREFERENCED_PARAMETER(bRefreshChildren);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- ASSERT(pThemeX);
- if (!pThemeX)
- {
- return;
- }
- //LOCALE_IDATE - short date format ordering
- // 0 Month-Day-Year
- // 1 Day-Month-Year
- // 2 Year-Month-Day
- int nDateOrdering = CXTPCalendarUtils::GetLocaleLong(LOCALE_IDATE);
- if (nDateOrdering == 1)
- {
- m_strHeaderFormat.SetStandardValue(_T("dddd, dd MMMM"));
- }
- else
- {
- m_strHeaderFormat.SetStandardValue(_T("dddd, MMMM dd"));
- }
- RefreshFromParent(pThemeX->GetHeaderPartX());
- // m_clrTodayBaseColor.SetStandardValue(pThemeX->GetHeaderPartX()->m_clrTodayBaseColor);
- m_bkNormal.nBitmapID.SetStandardValue(xtpIMG_WeekViewDayHeader);
- m_bkSelected.nBitmapID.SetStandardValue(xtpIMG_WeekViewDayHeader);
- m_UseOffice2003HeaderFormat.SetStandardValue(FALSE);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::AdjustLayout(CCmdTarget* pObject,
- CDC* pDC, const CRect& rcRect)
- {
- //TBase::AdjustLayout(pObject, pDC, rcRect);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
- if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView())
- {
- ASSERT(FALSE);
- return;
- }
- if (pWViewDay->GetDayIndex() != 0)
- {
- return;
- }
- CXTPCalendarWeekView* pWView = pWViewDay->GetView();
- if (m_UseOffice2003HeaderFormat)
- {
- int nDayWidth = rcRect.Width() - 4;
- pWView->CalculateHeaderFormat(pDC, nDayWidth, m_TextLeftRight.fcsetNormal.Font());
- }
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent::AdjustLayout(CCmdTarget* pObject,
- CDC* pDC, const CRect& rcRect, int nEventPlaceNumber)
- {
- CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
- if (!pDC || !GetTheme() || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- int nEventHeight = XTP_SAFE_GET4(pViewEvent, GetViewGroup(), GetViewDay(), GetView(), GetRowHeight(), 0);
- pViewEvent->m_rcEventMax.top = rcRect.top + nEventPlaceNumber * nEventHeight;
- pViewEvent->m_rcEventMax.bottom = pViewEvent->m_rcEventMax.top + nEventHeight;
- pViewEvent->m_rcEvent.top = pViewEvent->m_rcEventMax.top;
- pViewEvent->m_rcEvent.bottom = pViewEvent->m_rcEventMax.bottom;
- pViewEvent->m_rcEvent.left = pViewEvent->m_rcEventMax.left + 4 + 2;
- pViewEvent->m_rcEvent.right = pViewEvent->m_rcEventMax.right - 5 - 2;
- pViewEvent->m_rcToolTip.CopyRect(pViewEvent->m_rcEventMax);
- // adjust subject area
- int nDyx = pViewEvent->IsSelected() ? 5 : 2;
- pViewEvent->m_rcText.CopyRect(pViewEvent->m_rcEvent);
- pViewEvent->m_rcText.DeflateRect(nDyx + 3, 3, nDyx + 2, 3);
- // set times rects
- pViewEvent->m_rcStartTime.SetRectEmpty();
- pViewEvent->m_rcEndTime.SetRectEmpty();
- pViewEvent->m_rcSubjectEditor.CopyRect(pViewEvent->m_rcEvent);
- pViewEvent->m_rcSubjectEditor.top++;
- pViewEvent->m_rcSubjectEditor.bottom--;
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::SetDynColors(CXTPCalendarWeekViewDay* pWViewDay)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarThemeOffice2007::CTOCellDynBackground* pCellDynBkPart =
- XTP_SAFE_GET1(pThemeX, GetCellDynBackgroundPart(), NULL);
- if (!pWViewDay || !pCellDynBkPart || !GetTheme() || !GetTheme()->GetColorsSetPart())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewGroup* pViewGroup = pWViewDay->GetViewGroupsCount() ? pWViewDay->GetViewGroup_(0) : NULL;
- //--------------------------------------------------------------------
- CXTPCalendarTheme::XTP_BUSY_STATUS_CONTEXT bsColors;
- m_nDynBusyStatus = pCellDynBkPart->GetCellDynBackground(pViewGroup, pWViewDay->GetDayDate(), -1, bsColors);
- //--------------------------------------------------------------------
- m_clrDynHatch = 0;
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy ||
- m_nDynBusyStatus == xtpCalendarBusyStatusOutOfOffice ||
- m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- if (bsColors.clrBkAllDayEvents != 0 && bsColors.clrCellBorder != 0) // is Category or OutOfOffice
- {
- m_clrDynHatch = bsColors.clrBkAllDayEvents;
- if (m_nDynBusyStatus != xtpCalendarBusyStatusTentative)
- {
- m_clrBackgroundLight = bsColors.clrBkAllDayEvents;
- m_clrBackgroundDark = bsColors.clrBkAllDayEvents;
- m_clrBackgroundSelected = CXTPCalendarThemeOffice2007::PowerColor(bsColors.clrBkAllDayEvents, -7.5, 0.25);
- }
- }
- else
- {
- if (m_nDynBusyStatus == xtpCalendarBusyStatusBusy)
- {
- m_clrBackgroundLight = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217
- m_clrBackgroundDark = (COLORREF)m_clrBackgroundLight;
- }
- m_clrDynHatch = GetTheme()->GetColorsSetPart()->GetColor(xtpCLR_HeaderBorder); // 141, 174, 217;
- }
- }
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
- if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView() ||
- pWViewDay->GetViewGroupsCount() == 0 ||
- !pWViewDay->GetViewGroup(0))
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarWeekViewGroup* pWViewGroup = pWViewDay->GetViewGroup(0);
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
- CRect rcDay = dayLayout.m_rcDay;
- CRect rcBorders = rcDay;
- rcBorders.top = dayLayout.m_rcDayHeader.bottom;
- COleDateTime dtDay = pWViewDay->GetDayDate();
- int nDayCol = GetDayCol(pWViewDay);
- BOOL bIsToday = GetHeaderPart()->IsToday(pWViewDay);
- BOOL bIsSelected = GetHeaderPart()->IsSelected(pWViewDay);
- // Draw background
- int nLiteBkColorIdx = 0;
- // for non-work days choose dark background
- if (pWViewDay->GetCalendarControl() &&
- pWViewDay->GetCalendarControl()->GetCalendarOptions())
- {
- int nMask = pWViewDay->GetCalendarControl()->GetCalendarOptions()->nWorkWeekMask;
- int nWeekDay = dtDay.GetDayOfWeek();
- if ((CXTPCalendarUtils::GetDayOfWeekMask(nWeekDay) & nMask) != 0)
- {
- nLiteBkColorIdx = 1;
- }
- }
- // for selected days choose another background
- COLORREF clrBackground = nLiteBkColorIdx ? m_clrBackgroundLight : m_clrBackgroundDark;
- if (bIsSelected)
- {
- clrBackground = m_clrBackgroundSelected;
- }
- // draw background
- pDC->FillSolidRect(rcDay, clrBackground);
- //--------------------------------------------------------------------
- if (m_nDynBusyStatus == xtpCalendarBusyStatusTentative)
- {
- CXTPTextDC autoTxt(pDC, COLORREF_NULL, clrBackground);
- CBrush br(HS_BDIAGONAL, m_clrDynHatch);
- pDC->FillRect(&rcDay, &br);
- }
- //--------------------------------------------------------------------
- if (bIsToday)
- {
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 2, CRect(1, 0, 0, 1));
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrTodayBorder, 1, CRect(0, 0, 1, 0));
- //CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(0, 0, 1, 0));
- }
- else
- {
- int nIsRBorder = nDayCol;
- int nIsLBorder = nDayCol;
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 1, CRect(nIsLBorder, 0, nIsRBorder, 0));
- CXTPCalendarTheme::DrawRectPartly(pDC, rcBorders, m_clrBorder, 2, CRect(0, 0, 0, 1));
- }
- //------------------
- GetHeaderPart()->Draw(pWViewDay, pDC);
- BOOL bCnt_EvS = FALSE;
- BOOL bCnt_EvMul = FALSE;
- CXTPPropsStateContext autoStateCnt_EvS;
- CXTPPropsStateContext autoStateCnt_EvMul;
- //=====================
- int nCount = pWViewGroup->GetViewEventsCount();
- for (int i = 0; i < nCount; i++)
- {
- CXTPCalendarViewEvent* pViewEvent = pWViewGroup->GetViewEvent_(i);
- ASSERT(pViewEvent);
- if (pViewEvent && pViewEvent->IsVisible())
- {
- if (pViewEvent->IsMultidayEvent())
- {
- if (!bCnt_EvMul)
- autoStateCnt_EvMul.SetData(GetMultiDayEventPartX(), xtpCalendarBeforeDraw_WeekViewEvent, TRUE);
- bCnt_EvMul = TRUE;
- autoStateCnt_EvMul.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
- GetMultiDayEventPartX()->Draw(pViewEvent, pDC);
- autoStateCnt_EvMul.RestoreState();
- }
- else
- {
- if (!bCnt_EvS)
- autoStateCnt_EvS.SetData(GetSingleDayEventPartX(), xtpCalendarBeforeDraw_WeekViewEvent, TRUE);
- bCnt_EvS = TRUE;
- autoStateCnt_EvS.SendBeforeDrawThemeObject((LPARAM)pViewEvent);
- GetSingleDayEventPartX()->Draw(pViewEvent, pDC);
- autoStateCnt_EvS.RestoreState();
- }
- }
- }
- if (!pDC->IsPrinting() && pWViewDay->NoAllEventsAreVisible())
- {
- CRect rc = dayLayout.m_rcDay;
- rc.right -= 5;
- rc.bottom -= 5;
- BOOL bHot = _HitTestExpandDayButton(pWViewDay, rc) != 0;
- dayLayout.m_rcExpandSign = pThemeX->DrawExpandDayButton(pDC, rc, FALSE, bHot);
- if (bHot)
- dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
- else
- dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton;
- }
- autoStateCnt_EvS.Clear();
- autoStateCnt_EvMul.Clear();
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
- if (!pThemeX || !pWViewDay || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
- if (pWViewDay->NoAllEventsAreVisible())
- {
- BOOL bHot = pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE);
- BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotExpandButton);
- if (bHot != bHotPrev)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL bHotPrev = !!(dayLayout.m_nHotState & CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader);
- if (dayLayout.m_rcDayHeader.PtInRect(point) != bHotPrev)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL CXTPCalendarThemeOffice2007::CTOWeekViewDay::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- UNREFERENCED_PARAMETER(nFlags);
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarViewDay* pViewDay = DYNAMIC_DOWNCAST(CXTPCalendarViewDay, pObject);
- if (!pThemeX || !pViewDay || !pThemeX->GetCalendarControl())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pViewDay);
- if (pThemeX->ExpandDayButton_HitTest(point, dayLayout.m_rcExpandSign, FALSE))
- {
- pThemeX->GetCalendarControl()->PostMessage(xtp_wm_UserAction,
- (WPARAM)(xtpCalendarUserAction_OnExpandDay | xtpCalendarExpandDayButton_WeekView),
- (LPARAM)(LONG)(DATE)pViewDay->GetDayDate());
- return TRUE;
- }
- return FALSE;
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("WeekViewDay")));
- if (pPX->IsStoring())
- secData->EmptySection();
- PX_Color(&secData, _T("BorderColor"), m_clrBorder);
- PX_Color(&secData, _T("TodayBorderColor"), m_clrTodayBorder);
- PX_Color(&secData, _T("BackgroundLightColor"), m_clrBackgroundLight);
- PX_Color(&secData, _T("BackgroundDarkColor"), m_clrBackgroundDark);
- PX_Color(&secData, _T("BackgroundSelectedColor"), m_clrBackgroundSelected);
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDay::Serialize(CArchive& ar)
- {
- m_clrBorder.Serialize(ar);
- m_clrTodayBorder.Serialize(ar);
- m_clrBackgroundLight.Serialize(ar);
- m_clrBackgroundDark.Serialize(ar);
- m_clrBackgroundSelected.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewDay* pWViewDay = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewDay, pObject);
- if (!pDC || !pThemeX || !pWViewDay || !pWViewDay->GetView())
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT& dayLayout = CXTPCalendarTheme::GetViewDayLayout(pWViewDay);
- COleDateTime dtDay = pWViewDay->GetDayDate();
- int nDayCol = pThemeX->GetWeekViewPart()->GetDayPart()->GetDayCol(pWViewDay);
- CPoint pt(0, 0);
- if (pThemeX->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
- pThemeX->GetCalendarControl()->ScreenToClient(&pt);
- BOOL bIsToday = IsToday(pWViewDay);
- BOOL bIsSelected = IsSelected(pWViewDay);
- BOOL bFirstDay = nDayCol == 0;
- BOOL bLastDay = nDayCol == 1;
- int nFlags = bIsToday ? CTOHeader::xtpCalendarItemState_Today : CTOHeader::xtpCalendarItemState_Normal;
- nFlags |= bIsSelected ? CTOHeader::xtpCalendarItemState_Selected : 0;
- if (dayLayout.m_rcDayHeader.PtInRect(pt))
- {
- nFlags |= CTOHeader::xtpCalendarItemState_Hot;
- dayLayout.m_nHotState |= CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- else
- {
- dayLayout.m_nHotState &= ~CXTPCalendarViewDay::XTP_VIEW_DAY_LAYOUT::xtpHotDayHeader;
- }
- nFlags |= bFirstDay ? CTOHeader::xtpCalendarItemFirst : 0;
- nFlags |= bLastDay ? CTOHeader::xtpCalendarItemLast : 0;
- CRect rcRect(dayLayout.m_rcDay);
- rcRect.bottom = dayLayout.m_rcDayHeader.bottom;
- CString strTextLeft;
- CString strTextCenter;
- CString strTextRight;
- if (m_UseOffice2003HeaderFormat)
- {
- strTextRight = pWViewDay->GetCaption();
- }
- else
- {
- strTextRight = CXTPCalendarUtils::GetDateFormat(dtDay, m_strHeaderFormat);
- //------------------------------------------------------
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderLeft, &strTextLeft, pWViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderCenter, &strTextCenter, pWViewDay);
- pThemeX->GetItemTextIfNeed(xtpCalendarItemText_WeekViewDayHeaderRight, &strTextRight, pWViewDay);
- //------------------------------------------------------
- }
- Draw_Header(pDC, rcRect, nFlags, strTextLeft, strTextCenter, strTextRight);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::DoPropExchange(CXTPPropExchange* pPX)
- {
- ASSERT(pPX);
- if (!pPX)
- return;
- CXTPPropExchangeSection secData(pPX->GetSection(_T("WeekViewDayHeader")));
- if (pPX->IsStoring())
- secData->EmptySection();
- m_strHeaderFormat.DoPropExchange(&secData, _T("HeaderFormat"));
- if (pPX->GetSchema() >= _XTP_SCHEMA_112)
- m_UseOffice2003HeaderFormat.DoPropExchange(&secData, _T("UseOffice2003HeaderFormat"));
- TBase::DoPropExchange(&secData);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewDayHeader::Serialize(CArchive& ar)
- {
- m_strHeaderFormat.Serialize(ar);
- m_UseOffice2003HeaderFormat.Serialize(ar);
- TBase::Serialize(ar);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_MultiDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
- CXTPCalendarWeekViewDay* pMVDay = XTP_SAFE_GET2(pViewEvent, GetViewGroup(), GetViewDay(), NULL);
- CXTPCalendarWeekView* pMView = XTP_SAFE_GET1(pMVDay, GetView(), NULL);
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent() ||
- !pMView || !pMVDay)
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bNoVisibleMDEvent = pViewEvent->IsMultidayEvent() && !pViewEvent->IsVisible();
- int nMDEFlags = pViewEvent->GetMultiDayEventFlags();
- ASSERT(0 == (nMDEFlags & xtpCalendarMultiDaySlave)); // error for week view.
- if (bNoVisibleMDEvent)
- {
- return;
- }
- CRect rcEventMax(pViewEvent->GetViewEventRectMax());
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // fill event background
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel;
- COLORREF clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk);
- //----------------
- pThemeX->DrawRoundRect(pDC, rcEvent, clrBorder, bSelected, grclrBk);
- //------------------
- int nViewDayIndex = pMVDay->GetDayIndex();
- BOOL bFirstOnScreen = nViewDayIndex == 0;
- BOOL bLastOnScreen = nViewDayIndex == 6;
- CRect rcText(pViewEvent->GetTextRect());
- if ((nMDEFlags & xtpCalendarMultiDayFirst) == 0)
- {
- //CRect rcSQ = rcEvent;
- ////rcSQ.left += min(1, rcSQ.Width());
- CRect rcSQ = rcEventMax;
- rcSQ.left += min(1, rcSQ.Width());
- rcSQ.right = min(rcEvent.left + cnCornerSize, rcEventMax.right);
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,0,1));
- //-------------------------------------------------------------------
- if (bFirstOnScreen)
- {
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowL(pViewEvent, pDC, rcArrow);
- if (bArrow)
- rcText.left = rcArrow.right;
- }
- }
- else if (bSelected)
- {
- // draw left Gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.left = rcEvent.left - 1;
- rcGripper.right = rcGripper.left + cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- if ((nMDEFlags & xtpCalendarMultiDayLast) == 0)
- {
- // CRect rcSQ = rcEvent;
- // rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
- // //rcSQ.right -= min(2, rcSQ.Width());
- CRect rcSQ = rcEventMax;
- rcSQ.left = max(rcEvent.right - cnCornerSize, rcEventMax.left);
- rcSQ.right -= min(2, rcSQ.Width());
- CXTPCalendarTheme::DrawRectPartly(pDC, rcSQ, clrBorder, bSelected, grclrBk, CRect(0,1,0, 1));
- //-------------------------------------------------------------------
- if (bLastOnScreen)
- {
- CRect rcArrow;
- BOOL bArrow = Draw_ArrowR(pViewEvent, pDC, rcArrow);
- if (bArrow)
- rcText.right = rcArrow.left;
- }
- }
- else if (bSelected)
- {
- // draw right gripper
- CRect rcGripper;
- rcGripper.top = rcEvent.top + rcEvent.Height() / 2 - cnGripperSize / 2;
- rcGripper.bottom = rcGripper.top + cnGripperSize;
- rcGripper.right = rcEvent.right + 1;
- rcGripper.left = rcGripper.right - cnGripperSize;
- pDC->FillSolidRect(&rcGripper, m_clrGripperBackground);
- CBrush brBorder(m_clrGripperBorder);
- pDC->FrameRect(&rcGripper, &brBorder);
- }
- //****
- pViewEvent->m_rcText.CopyRect(rcText);
- //=====================================
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- if (!strLoc.IsEmpty())
- {
- strSubj += _T(";");
- }
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- rcText.DeflateRect(3, 0, 3, 0);
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- pViewEvent->m_rcSubjectEditor.top = rcEvent.top + 2;
- pViewEvent->m_rcSubjectEditor.bottom = rcEvent.bottom - 2;
- pViewEvent->AdjustSubjectEditor();
- CRect rcIconsMax = rcText;
- rcIconsMax.left = min(rcIconsMax.left + rcText.Height(), rcIconsMax.right);
- //
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- rcText.right = max(rcText.left, rcText.right - szIcons.cx - 2);
- //---------------------------------------------------------------
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- }
- }
- //
- //----------------------------------------------------
- if (!bMarkupDrawn)
- {
- UINT uTextShortAlign = DT_VCENTER | DT_LEFT;
- CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign | DT_CALCRECT);
- //--- calculate rects and fix to be centered if enough space ---
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
- }
- int nTIcx = szText.cx + szIcons.cx;
- if (nTIcx + 5 < rcText.Width())
- {
- int ncx_2 = (rcText.Width() - nTIcx) / 2 - 2;
- rcText.left += ncx_2;
- rcText.right = rcText.left + szText.cx + 2;
- rcIconsMax.right -= ncx_2;
- }
- else
- {
- rcText.right -= szIcons.cx + 2;
- }
- pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, uTextShortAlign);
- }
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw(CCmdTarget* pObject, CDC* pDC)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- CXTPCalendarWeekViewEvent* pViewEvent = DYNAMIC_DOWNCAST(CXTPCalendarWeekViewEvent, pObject);
- if (!pDC || !pThemeX || !pViewEvent)
- {
- ASSERT(FALSE);
- return;
- }
- if (!pViewEvent->IsVisible())
- {
- return;
- }
- CRect rcEvent(pViewEvent->GetEventRect());
- if (rcEvent.IsRectEmpty())
- {
- return;
- }
- // fill event background
- Draw_Background(pDC, rcEvent, pViewEvent);
- //
- BOOL bMarkupDrawn = FALSE;
- if (pThemeX->GetCalendarControl()->IsMarkupEnabled())
- {
- CXTPMarkupContext* pMarkupContext = pThemeX->GetCalendarControl()->GetMarkupContext();
- ASSERT(pMarkupContext);
- CXTPMarkupUIElement* pUIElement = pViewEvent->GetMarkupUIElement();
- if (pUIElement && pMarkupContext)
- {
- BOOL bSelected = pViewEvent->IsSelected();
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CRect rcText = rcEvent;
- rcText.DeflateRect(3, 2, 3, 2);
- CRect rcIconsMax = rcText;
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2 + 1;
- }
- rcText.right = max(rcText.left, rcText.right - szIcons.cx - 2);
- //---------------------------------------------------------------
- XTPMarkupSetDefaultFont(pMarkupContext, (HFONT)pFntClr1->Font()->GetSafeHandle(), pFntClr1->Color());
- XTPMarkupRenderElement(pUIElement, pDC->GetSafeHdc(), rcText);
- bMarkupDrawn = TRUE;
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- }
- //
- if (!bMarkupDrawn)
- {
- Draw_Time(pDC, rcEvent, pViewEvent);
- CRect rcText(pViewEvent->GetTextRect());
- Draw_Caption(pDC, rcText, pViewEvent);
- }
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::
- Draw_Background(CDC* pDC, const CRect& rcEventRect, CXTPCalendarWeekViewEvent* pViewEvent)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pThemeX || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bSelected = pViewEvent->IsSelected();
- COLORREF clrBorderNotSel, clrBorder;
- CXTPPaintManagerColorGradient grclrBk;
- int nColorsSrc_1Cat2Lbl = 0;
- GetEventColors(pDC, pViewEvent, clrBorder, clrBorderNotSel, grclrBk, bSelected, &nColorsSrc_1Cat2Lbl);
- if (!bSelected && nColorsSrc_1Cat2Lbl > 0)
- {
- clrBorder = grclrBk.clrLight;
- }
- pThemeX->DrawRoundRect(pDC, rcEventRect, clrBorder, bSelected, grclrBk);
- }
- CSize CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw_Time(
- CDC* pDC, const CRect& rcEventRect, CXTPCalendarWeekViewEvent* pViewEvent)
- {
- CSize szResult(0, 0);
- if (!pDC || !pViewEvent || !pViewEvent->GetEvent())
- {
- ASSERT(FALSE);
- return szResult;
- }
- BOOL bSelected = pViewEvent->IsSelected();
- CFont* pFont = bSelected ? m_fcsetSelected.fcsetStartEnd.Font() : m_fcsetNormal.fcsetStartEnd.Font();
- COLORREF clrColor = bSelected ? m_fcsetSelected.fcsetStartEnd.Color() : m_fcsetNormal.fcsetStartEnd.Color();
- CXTPFontDC autoFont(pDC, pFont, clrColor);
- //--------------------------
- //*****************
- // not implemented for office 2007 theme.
- //if (pViewEvent->IsTimeAsClock()) {}
- //*****************
- CString strStartTime = pViewEvent->GetItemTextStartTime();
- CString strEndTime = pViewEvent->GetItemTextEndTime();
- CSize szStart = pDC->GetTextExtent(strStartTime);
- CSize szEnd = pDC->GetTextExtent(strEndTime);
- CRect rcStart(rcEventRect);
- CRect rcEnd(rcEventRect);
- DWORD dwOpt = XTP_SAFE_GET3(GetTheme(), GetCalendarControl(), GetCalendarOptions(), dwAdditionalOptions, 0);
- BOOL bShowEndTime = XTP_SAFE_GET2(pViewEvent, GetCalendarControl(), WeekView_IsShowEndDate(), TRUE);
- BOOL bDrawStartTime = szStart.cx + 6 < rcEventRect.Width()/2 ||
- (dwOpt & xtpCalendarOptMonthViewShowStartTimeAlways);
- BOOL bDrawEndTime = bShowEndTime && szStart.cx + szEnd.cx + 6 * 2 < rcEventRect.Width()/2 ||
- (dwOpt & xtpCalendarOptMonthViewShowEndTimeAlways);
- if (!bDrawStartTime && !bDrawEndTime)
- {
- return szResult;
- }
- rcStart.left = min(rcStart.left + 4, rcStart.right);
- rcStart.right = min(rcStart.left + szStart.cx + 6, rcStart.right);
- rcEnd.left = rcStart.right;
- rcEnd.right = min(rcEnd.left + szEnd.cx + 6, rcEnd.right);
- if (!bDrawEndTime)
- {
- rcEnd.right = rcEnd.left;
- }
- //-------------------------------------------------
- UINT uAlign = DT_VCENTER | DT_SINGLELINE | DT_LEFT;
- pDC->DrawText(strStartTime, &rcStart, uAlign);
- if (bDrawEndTime)
- {
- pDC->DrawText(strEndTime, &rcEnd, uAlign);
- }
- //-------------------------------------------------
- pViewEvent->m_rcStartTime.CopyRect(&rcStart);
- pViewEvent->m_rcEndTime.CopyRect(&rcEnd);
- pViewEvent->m_rcText.left = rcEnd.right;
- //-------------------------------------------------
- szResult.cx = max(0, rcEnd.right - rcStart.left);
- szResult.cy = szStart.cy;
- return szResult;
- }
- void CXTPCalendarThemeOffice2007::CTOWeekViewEvent_SingleDay::Draw_Caption(
- CDC* pDC, const CRect& rcTextRect, CXTPCalendarWeekViewEvent* pViewEvent)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pDC || !pViewEvent || !pThemeX )
- {
- ASSERT(FALSE);
- return;
- }
- CString strSubj = pViewEvent->GetItemTextSubject();
- CString strLoc = pViewEvent->GetItemTextLocation();
- if (!strLoc.IsEmpty())
- {
- strSubj += _T(";");
- }
- BOOL bSelected = pViewEvent->IsSelected();
- CThemeFontColorSet* pFntClr1 = bSelected ? &m_fcsetSelected.fcsetSubject : &m_fcsetNormal.fcsetSubject;
- CThemeFontColorSet* pFntClr2 = bSelected ? &m_fcsetSelected.fcsetLocation : &m_fcsetNormal.fcsetLocation;
- CRect rcText = rcTextRect;
- //rcText.DeflateRect(1, 2, 3, 2);
- pViewEvent->m_rcSubjectEditor.CopyRect(rcText);
- pViewEvent->AdjustSubjectEditor();
- UINT nAlign = DT_VCENTER | DT_LEFT | DT_SINGLELINE;
- CSize szText = pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, nAlign | DT_CALCRECT, nAlign);
- //----------------------------------------------------
- CRect rcIconsMax = rcText;
- rcIconsMax.left = min(rcIconsMax.left + rcTextRect.Height(), rcIconsMax.right);
- //--- calculate rects and fix to be centered if enough space ---
- CSize szIcons = Draw_Icons(pViewEvent, pDC, rcIconsMax, TRUE);
- if (rcIconsMax.Height() > szIcons.cy)
- {
- rcIconsMax.bottom -= (rcIconsMax.Height() - szIcons.cy) / 2;
- }
- int nTIcx = szText.cx + szIcons.cx;
- if (nTIcx > rcText.Width())
- {
- rcText.right = max(rcIconsMax.left, rcIconsMax.right - szIcons.cx) - 2;
- }
- pThemeX->DrawLine2_CenterLR(pDC, strSubj, strLoc, pFntClr1, pFntClr2,
- rcText, nAlign, nAlign);
- Draw_Icons(pViewEvent, pDC, rcIconsMax);
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::RefreshMetrics(BOOL /*bRefreshChildren*/)
- {
- m_bPrev = 0 == _tcsnicmp(GetInstanceName(), _T("Prev"), 4);
- m_nBitmapID.SetStandardValue(xtpIMG_PrevNextEventButtons) ;
- m_rcBitmapBorder.SetStandardValue(CRect(1, 8, 1, 8));
- if (!GetTheme())
- return;
- LOGFONT lfVert;
- VERIFY( GetTheme()->m_fntBaseFont->GetLogFont(&lfVert) );
- lfVert.lfOrientation = 900;
- lfVert.lfEscapement = 900;
- if (XTPDrawHelpers()->FontExists(XTP_CALENDAR_OFFICE2007_FONT_NAME))
- {
- STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTP_CALENDAR_OFFICE2007_FONT_NAME);
- }
- else
- {
- STRCPY_S(lfVert.lfFaceName, LF_FACESIZE, XTPDrawHelpers()->GetVerticalFontName(TRUE));
- }
- m_fcsetText.fntFont.SetStandardValue(&lfVert);
- m_fcsetText.clrColor.SetStandardValue(RGB(0, 0, 0));
- m_clrDisabledText.SetStandardValue(RGB(136, 128, 128));
- m_strText.SetStandardValue(XTPResourceManager()->LoadString(m_bPrev ? XTP_IDS_CALENDAR_PREVAPPOINTMENT : XTP_IDS_CALENDAR_NEXTAPPOINTMENT));
- }
- CSize CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::GetSize(const CRect* prcRect)
- {
- CSize szSize(23, 172);
- if (prcRect)
- {
- if (prcRect->Height() < 35 ||
- prcRect->Width() < szSize.cx * 2 + 1)
- {
- szSize.cx = szSize.cy = 0;
- }
- else if (szSize.cy + 70 > prcRect->Height())
- {
- szSize.cy = 34;
- }
- }
- return szSize;
- }
- CRect CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::GetRect()
- {
- if (m_bVisible)
- return m_rcRect;
- else
- return CRect(0, 0, 0, 0);
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::AdjustLayout(CXTPCalendarView* /*pObject*/, CDC* /*pDC*/, const CRect& rcRect)
- {
- CSize szSize = GetSize(&rcRect);
- m_rcRect = rcRect;
- m_rcRect.top += (rcRect.Height() - szSize.cy) / 2;
- m_rcRect.bottom = m_rcRect.top + szSize.cy;
- if (m_bPrev)
- {
- m_rcRect.left++;
- m_rcRect.right = m_rcRect.left + szSize.cx;
- }
- else
- {
- m_rcRect.right--;
- m_rcRect.left = m_rcRect.right - szSize.cx;
- }
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::Draw(CXTPCalendarView* /*pObject*/, CDC* pDC)
- {
- if (m_rcRect.IsRectEmpty() || !m_bVisible || !GetTheme() || !GetTheme()->GetImageList())
- return;
- UINT nButmapID = (UINT)(int)m_nBitmapID;
- // Lookup for bitmap
- CXTPOffice2007Image* pImage = GetTheme()->GetImageList()->GetBitmap(nButmapID);
- ASSERT(pImage);
- CXTPOffice2007Image* pArrow = GetTheme()->GetBitmap(_T("CalendarPrevNextEventButtonArr"));
- ASSERT(pArrow);
- if (!pImage || !pArrow)
- {
- #ifdef _DEBUG
- pDC->FillSolidRect(m_rcRect, RGB(200, 0, 0));
- #else
- m_bVisible = FALSE;
- #endif
- return;
- }
- //------------------------------------------
- m_bHot = HitTest();
- int nBkIdx = (m_bPrev ? 0 : 2) + (m_bHot && !m_bDisabled ? 1 : 0);
- int nArrIdx = (m_bPrev ? 0 : 2) + (m_bDisabled ? 1 : 0);
- CRect rcBkSrc = pImage->GetSource(nBkIdx, 4);
- CRect rcArrSrc = pArrow->GetSource(nArrIdx, 4);
- CRect rcArrDest = m_rcRect;
- rcArrDest.OffsetRect(9, 12);
- rcArrDest.right = rcArrDest.left + rcArrSrc.Width();
- rcArrDest.bottom = rcArrDest.top + rcArrSrc.Height();
- pImage->DrawImage(pDC, m_rcRect, rcBkSrc, m_rcBitmapBorder, RGB(255, 0, 255));
- pArrow->DrawImage(pDC, rcArrDest, rcArrSrc, CRect(0,0,0,0), RGB(255, 0, 255));
- //-------------------------------------------
- CRect rcText = m_rcRect;
- rcText.top = rcArrDest.bottom;
- if (rcText.Height() > 100)
- {
- rcText.DeflateRect(1, 3, 1, 3);
- int nTmp = rcText.top;
- rcText.top = rcText.bottom;
- rcText.bottom = nTmp;
- int nRectSize = abs(rcText.Height());
- //---
- COLORREF clrText = m_bDisabled ? (COLORREF)m_clrDisabledText : (COLORREF)m_fcsetText.clrColor;
- CXTPFontDC autoFont(pDC, m_fcsetText.fntFont, clrText);
- CSize szText = pDC->GetTextExtent(m_strText);
- // Center text vertically
- if (szText.cx + 7 < nRectSize)
- {
- rcText.top = max(rcText.top - (nRectSize - szText.cx)/2, rcText.bottom);
- }
- if (szText.cy < rcText.Width())
- {
- rcText.left += (rcText.Width() - szText.cy) / 2;
- }
- pDC->DrawText((const CString&)m_strText, &rcText, DT_NOPREFIX | DT_SINGLELINE); //| DT_NOCLIP
- }
- }
- int CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::HitTest(const CPoint* pPoint/* = NULL*/)
- {
- if (!m_bVisible || !GetTheme())
- return 0;
- CPoint pt(0, 0);
- if (pPoint)
- {
- pt = *pPoint;
- }
- else if (GetTheme()->GetCalendarControl()->GetSafeHwnd() && GetCursorPos(&pt))
- {
- GetTheme()->GetCalendarControl()->ScreenToClient(&pt);
- }
- if (m_rcRect.PtInRect(pt))
- {
- return m_bPrev ? xtpCalendarHitTestPrevEventButton : xtpCalendarHitTestNextEventButton;
- }
- return 0;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::OnMouseMove(CCmdTarget* /*pObject*/, UINT /*nFlags*/, CPoint point)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pThemeX )
- {
- ASSERT(FALSE);
- return;
- }
- BOOL bHotNew = !!HitTest(&point);
- if (m_bHot != bHotNew)
- {
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- }
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventButton::OnLButtonDown(CCmdTarget* /*pObject*/, UINT /*nFlags*/, CPoint point)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pThemeX || !pThemeX->GetPrevNextEventControllerPartX())
- {
- ASSERT(FALSE);
- return FALSE;
- }
- BOOL bHitTest = HitTest(&point);
- if (bHitTest)
- {
- COleDateTime dtDay;
- BOOL bDayValid = FALSE;
- if (m_bPrev)
- bDayValid = pThemeX->GetPrevNextEventControllerPartX()->GetPrevEventDay(&dtDay);
- else
- bDayValid = pThemeX->GetPrevNextEventControllerPartX()->GetNextEventDay(&dtDay);
- CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
- ASSERT(pView);
- if (pView && bDayValid)
- {
- XTPCalendarViewType nViewType = pView->GetViewType();
- pView->ShowDay(dtDay);
- pView = GetTheme()->GetCalendarControl()->GetActiveView();
- if (pView && pView->GetViewType() != nViewType)
- GetTheme()->GetCalendarControl()->SwitchActiveView(nViewType);
- }
- }
- return bHitTest;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::AdjustLayout(CXTPCalendarView* /*pObject*/, CDC* pDC, const CRect& rcRect)
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pThemeX || !GetPrevEventButtonPartX() || !GetNextEventButtonPartX())
- {
- ASSERT(FALSE);
- return;
- }
- m_rcRect = rcRect;
- BOOL bIsPrevNextButtonsVisible = IsPrevNextButtonsVisible();
- if (pDC && pDC->IsPrinting())
- bIsPrevNextButtonsVisible = FALSE;
- GetPrevEventButtonPartX()->m_bVisible = bIsPrevNextButtonsVisible;
- GetNextEventButtonPartX()->m_bVisible = bIsPrevNextButtonsVisible;
- if (!bIsPrevNextButtonsVisible)
- {
- _StopRequests();
- }
- else
- {
- GetPrevEventButtonPartX()->m_bDisabled = !GetPrevEventDay();
- GetNextEventButtonPartX()->m_bDisabled = !GetNextEventDay();
- }
- //--------------------------------------------
- if (GetPrevEventButtonPartX())
- GetPrevEventButtonPartX()->AdjustLayout(NULL, pDC, rcRect);
- if (GetNextEventButtonPartX())
- GetNextEventButtonPartX()->AdjustLayout(NULL, pDC, rcRect);
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::Draw(CXTPCalendarView* /*pObject*/, CDC* pDC)
- {
- if (GetPrevEventButtonPartX())
- GetPrevEventButtonPartX()->Draw(NULL, pDC);
- if (GetNextEventButtonPartX())
- GetNextEventButtonPartX()->Draw(NULL, pDC);
- }
- int CXTPCalendarThemeOffice2007::CTOPrevNextEventController::HitTest(const CPoint* pPoint)
- {
- int nHit = 0;
- if (GetPrevEventButtonPartX())
- nHit = GetPrevEventButtonPartX()->HitTest(pPoint);
- if (!nHit && GetNextEventButtonPartX())
- nHit = GetNextEventButtonPartX()->HitTest(pPoint);
- return nHit;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnMouseMove(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- if (GetPrevEventButtonPartX())
- GetPrevEventButtonPartX()->OnMouseMove(pObject, nFlags, point);
- if (GetNextEventButtonPartX())
- GetNextEventButtonPartX()->OnMouseMove(pObject, nFlags, point);
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnLButtonDown(CCmdTarget* pObject, UINT nFlags, CPoint point)
- {
- BOOL b1 = FALSE, b2 = FALSE;
- if (GetPrevEventButtonPartX())
- b1 = GetPrevEventButtonPartX()->OnLButtonDown(pObject, nFlags, point);
- if (GetNextEventButtonPartX())
- b2 = GetNextEventButtonPartX()->OnLButtonDown(pObject, nFlags, point);
- return b1 || b2;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnStatusChanged()
- {
- CXTPCalendarThemeOffice2007* pThemeX = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetTheme());
- if (!pThemeX )
- {
- ASSERT(FALSE);
- return;
- }
- CXTPCalendarControl::CUpdateContext updateContext(pThemeX->GetCalendarControl(), xtpCalendarUpdateRedraw);
- AdjustLayout(NULL, NULL, m_rcRect);
- DBG_TRACE_PREVNEXTBTN(_T("PrevNextEventController::OnStatusChanged() n"));
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::IsPrevNextButtonsVisible()
- {
- HWND hWnd = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetSafeHwnd(), NULL);
- if (!hWnd)
- return FALSE;
- return !_IsSomeEventVisible();
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_IsSomeEventVisible()
- {
- CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
- ASSERT(pView);
- if (!pView)
- return FALSE;
- int nDays = pView->GetViewDayCount();
- for (int nDay = 0; nDay < nDays; nDay++)
- {
- CXTPCalendarViewDay* pDay = pView->GetViewDay_(nDay);
- ASSERT(pDay);
- if (!pDay)
- continue;
- int nGroupsCount = pDay->GetViewGroupsCount();
- for (int i = 0; i < nGroupsCount; i++)
- {
- if (pDay->GetViewGroup_(i) && pDay->GetViewGroup_(i)->GetViewEventsCount())
- return TRUE;
- }
- }
- return FALSE;
- }
- COleDateTime CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetVisibleDay(BOOL bFirst)
- {
- CXTPCalendarView* pView = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetActiveView(), NULL);
- ASSERT(pView);
- if (!pView)
- return (DATE)0;
- if (bFirst)
- {
- return pView->GetViewDayDate(0);
- }
- int nDays = pView->GetViewDayCount();
- return pView->GetViewDayDate(max(0, nDays - 1));
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetPrevEventDay(COleDateTime* pdtDay)
- {
- if (pdtDay)
- *pdtDay = COleDateTime((DATE)0);
- long nFirstDay = (long)GetVisibleDay(TRUE);
- long nPrevDay = 0;
- int nCount = m_arNotEmptyDays.GetSize();
- for (int i = 0; i < nCount; i++)
- {
- if (nFirstDay > m_arNotEmptyDays[i])
- nPrevDay = m_arNotEmptyDays[i];
- else
- break;
- }
- if (nPrevDay > 0)
- {
- if (pdtDay)
- *pdtDay = COleDateTime((DATE)nPrevDay);
- return TRUE;
- }
- m_ndtRefreshDatePrev = nFirstDay - 1;
- m_bScanPrev = TRUE;
- _RequestToFindEvents();
- return FALSE;
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::GetNextEventDay(COleDateTime* pdtDay)
- {
- if (pdtDay)
- *pdtDay = COleDateTime((DATE)0);
- long nDay = (long)GetVisibleDay(FALSE);
- long nNextDay = 0;
- int nCount = m_arNotEmptyDays.GetSize();
- for (int i = 0; i < nCount; i++)
- {
- if (nDay < m_arNotEmptyDays[i])
- {
- nNextDay = m_arNotEmptyDays[i];
- break;
- }
- }
- if (nNextDay > 0)
- {
- if (pdtDay)
- *pdtDay = COleDateTime((DATE)nNextDay);
- return TRUE;
- }
- m_ndtRefreshDateNext = nDay + 1;
- m_bScanNext = TRUE;
- _RequestToFindEvents();
- return FALSE;
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnTimer(UINT_PTR uTimerID)
- {
- if (m_nRefreshTimerID != (UINT)uTimerID)
- return FALSE;
- BOOL bIsEventsPrev = FALSE;
- BOOL bIsEventsNext = FALSE;
- if (m_bScanPrev && m_ndtRefreshDatePrev > m_ndtMinScanDay)
- {
- for (int i = 0; i < m_nRefreshDaysPerIdleStep; i++)
- {
- DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_RefreshDay(-- %d) n"), m_nRefreshTimerID, m_ndtRefreshDatePrev);
- bIsEventsPrev = _RefreshDay(m_ndtRefreshDatePrev);
- m_ndtRefreshDatePrev--;
- if (bIsEventsPrev)
- {
- m_bScanPrev = FALSE;
- break;
- }
- }
- }
- else
- {
- m_bScanPrev = FALSE;
- }
- if (m_bScanNext && m_ndtRefreshDateNext < m_ndtMaxScanDay)
- {
- for (int i = 0; i < m_nRefreshDaysPerIdleStep; i++)
- {
- DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_RefreshDay(%d ++) n"), m_nRefreshTimerID, m_ndtRefreshDateNext);
- bIsEventsNext = _RefreshDay(m_ndtRefreshDateNext);
- m_ndtRefreshDateNext++;
- if (bIsEventsNext)
- {
- m_bScanNext = FALSE;
- break;
- }
- }
- }
- else
- {
- m_bScanNext = FALSE;
- }
- BOOL bStatusChanged = bIsEventsPrev || bIsEventsNext;
- if (!m_bScanPrev && !m_bScanNext)
- {
- DBG_TRACE_PREVNEXTBTN(_T("%d - PrevNextEventController::_StopRequests(Prev=%d, Next=%d) n"),
- m_nRefreshTimerID, m_bScanPrev, m_bScanNext);
- _StopRequests();
- bStatusChanged = TRUE;
- }
- if (bStatusChanged)
- {
- OnStatusChanged();
- }
- return TRUE;
- }
- BOOL CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_RefreshDay(long ndtDay)
- {
- // TODO: Change to use multi-Data Providers from Resources
- // also PrePopulate events have to be used too ???
- //
- CXTPCalendarData* pData = XTP_SAFE_GET2(GetTheme(), GetCalendarControl(), GetDataProvider(), NULL);
- ASSERT(pData);
- if (!pData)
- return FALSE;
- CXTPCalendarEventsPtr ptrEvents = pData->RetrieveDayEvents((DATE)ndtDay);
- BOOL bIsEvents = ptrEvents && ptrEvents->GetCount() > 0;
- if (bIsEvents)
- m_arNotEmptyDays.AddDay(ndtDay);
- else
- m_arNotEmptyDays.RemoveElement(ndtDay);
- return bIsEvents;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_RequestToFindEvents()
- {
- if (m_nRefreshTimerID)
- return;
- m_nRefreshTimerID = SetTimer((UINT)m_nIdleStepTime_ms);
- ASSERT(m_nRefreshTimerID);
- DBG_TRACE_PREVNEXTBTN(_T("n%d *** PrevNextEventController::_RequestToFindEvents() n"), m_nRefreshTimerID);
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::_StopRequests()
- {
- if (m_nRefreshTimerID)
- KillTimer(m_nRefreshTimerID);
- m_nRefreshTimerID = 0;
- }
- void CXTPCalendarThemeOffice2007::CTOPrevNextEventController::OnDetachCalendar()
- {
- _StopRequests();
- }
- /////////////////////////////////////////////////////////////////////////////