CBCGPTreeMap::CBCGPTreeMap() { m_LayoutType = Squarified; m_Root.m_pOwner = this; m_Root.m_bIsRoot = TRUE; m_Root.m_sizeMargin = CBCGPSize(1, 1); m_brFill = CBCGPBrush(CBCGPColor::DarkGray); m_pClicked = NULL; }
//******************************************************************************* CBCGPSize CBCGPChartObject::OnCalcObjectSize(CBCGPGraphicsManager* pGM) { ASSERT_VALID(this); if (m_pParentChart != NULL && !m_strText.IsEmpty()) { ASSERT_VALID(m_pParentChart); if (m_format.m_textFormat.IsWordWrap()) { if (m_szObjectSize.cx == 0) { return CBCGPSize(); } return m_pParentChart->OnGetTextSize(pGM, m_strText, m_format.m_textFormat, m_szObjectSize.cx) + m_format.GetContentPadding(TRUE) * 2; } return m_pParentChart->OnGetTextSize(pGM, m_strText, m_format.m_textFormat) + m_format.GetContentPadding(TRUE) * 2; } return CBCGPSize(); }
//******************************************************************************** void CBCGPTreeMapGroup::SetRect(const CBCGPRect& rectIn) { CBCGPRect rect = rectIn; if (m_sizeMargin != CBCGPSize(-1., -1.)) { rect.DeflateRect(m_sizeMargin); } else { for (CBCGPBaseTreeMapNode* pParent = m_pParent; pParent != NULL; pParent = pParent->m_pParent) { ASSERT_VALID(pParent); if (pParent->m_sizeMargin != CBCGPSize(-1., -1.)) { rect.DeflateRect(pParent->m_sizeMargin); break; } } } m_rect = rect; }
//******************************************************************************* void CBCGPKnob::SetImageList(UINT uiResID, int cx, const CBCGPSize& szMargin) { m_Icons.Destroy(); m_sizeIcon = CBCGPSize(0, 0); if (uiResID != 0) { m_Icons.Load(uiResID); m_sizeIcon.cx = cx; m_sizeIconMargin = szMargin; } SetDirty(); }
//******************************************************************************* void CBCGPAnalogClock::EnableDate(BOOL bEnable, BCGP_SUB_GAUGE_POS pos) { if (bEnable) { if (m_pDate != NULL) { return; } m_pDate = new CBCGPNumericIndicatorImpl; m_pDate->SetCells(2); m_pDate->SetDecimals(0); m_pDate->SetSeparatorWidth(0); CBCGPNumericIndicatorColors colors; colors.m_brFill = CBCGPBrush(CBCGPColor::White, CBCGPColor::LightGray, CBCGPBrush::BCGP_GRADIENT_HORIZONTAL); colors.m_brDigit = CBCGPBrush(CBCGPColor::Gray); m_pDate->SetColors(colors); AddSubGauge(m_pDate, pos, CBCGPSize(20, 15), CBCGPPoint(-5, 0)); } else { if (m_pDate == NULL) { return; } ASSERT_VALID(m_pDate); RemoveSubGauge(m_pDate); m_pDate = NULL; } OnSetClockTime(TRUE); }
//*************************************************************************************** void CBCGPRadialMenuObject::OnDraw(CBCGPGraphicsManager* pGM, const CBCGPRect& /*rectClip*/, DWORD dwFlags) { if (dwFlags == BCGP_DRAW_STATIC) { return; } m_nShadowDepth = pGM->IsSupported(BCGP_GRAPHICS_MANAGER_COLOR_OPACITY) ? GetShadowDepth() : 0; CBCGPRect rect = m_rect; if (rect.Width() < rect.Height()) { rect.top += (rect.Height() - rect.Width()) / 2; rect.bottom = rect.top + rect.Width(); } else if (rect.Height() < rect.Width()) { rect.left += (rect.Width() - rect.Height()) / 2; rect.right = rect.left + rect.Height(); } rect.DeflateRect(2., 2.); rect.right -= m_nShadowDepth; rect.bottom -= m_nShadowDepth; const double radius = rect.Width() / 2; const double radiusSmall = INTERNAL_PART * rect.Width() + 1.0; const CBCGPPoint center = rect.CenterPoint(); CBCGPSize sizeIcon((double)m_cxIcon, 16); if (!m_Icons.IsNull()) { sizeIcon.cy = pGM->GetImageSize(m_Icons).cy; } const int nItems = (int)m_arItems.GetSize(); if (IsDirty()) { int nCircleItems = m_bHasCenterButton ? nItems - 1 : nItems; double dblDeltaAngle = nCircleItems == 0 ? 0. : 360. / nCircleItems; double dblStartAngle = 90. - dblDeltaAngle / 2; for (int i = 0; i < nItems; i++) { CBCGPRadialMenuItem* pItem = m_arItems[i]; ASSERT_VALID(pItem); pItem->m_bIsCenter = i == nItems -1 && m_bHasCenterButton; pItem->m_Shape.Destroy(); pItem->m_Shape.Clear(); if (!pItem->m_bIsCenter) { double dblFinishAngle = dblStartAngle + dblDeltaAngle; const double dblStartAngleRad = bcg_deg2rad(dblStartAngle); const double dblFinishAngleRad = bcg_deg2rad(dblFinishAngle); const double dblMiddleAngleRad = bcg_deg2rad(dblStartAngle + dblDeltaAngle / 2); double angleStartCos = cos(dblStartAngleRad); double angleStartSin = sin(dblStartAngleRad); double angleFinishCos = cos(dblFinishAngleRad); double angleFinishSin = sin(dblFinishAngleRad); pItem->m_Shape.SetStart( CBCGPPoint(center.x + angleStartCos * radius, center.y - angleStartSin * radius)); pItem->m_Shape.AddArc( CBCGPPoint(center.x + angleFinishCos * radius, center.y - angleFinishSin * radius), CBCGPSize(radius, radius), dblStartAngle > dblFinishAngle, FALSE); pItem->m_Shape.AddLine( CBCGPPoint(center.x + angleFinishCos * radiusSmall, center.y - angleFinishSin * radiusSmall)); pItem->m_Shape.AddArc( CBCGPPoint(center.x + angleStartCos * radiusSmall, center.y - angleStartSin * radiusSmall), CBCGPSize(radiusSmall, radiusSmall), dblStartAngle < dblFinishAngle, FALSE); pItem->m_ptCenter = CBCGPPoint( center.x + cos(dblMiddleAngleRad) * 2 * radius / 3, center.y - sin(dblMiddleAngleRad) * 2 * radius / 3); dblStartAngle = dblFinishAngle; } else { pItem->m_Shape.SetStart(center); pItem->m_Shape.AddLine(center); pGM->CombineGeometry(pItem->m_Shape, pItem->m_Shape, CBCGPEllipseGeometry(CBCGPEllipse(center, radiusSmall, radiusSmall)), RGN_OR); pItem->m_ptCenter = center; } } } CBCGPEllipse ellipseInt(center, radiusSmall, radiusSmall); CBCGPRect rectShadow = rect; rectShadow.OffsetRect(m_nShadowDepth, m_nShadowDepth); if (!m_bHasCenterButton && m_pCtrl->GetSafeHwnd() != NULL && (m_pCtrl->GetExStyle() & WS_EX_LAYERED)) { if (m_nShadowDepth > 0) { CBCGPEllipseGeometry egShadow(rectShadow); CBCGPPoint centerShadow = center; centerShadow.x += m_nShadowDepth; centerShadow.y += m_nShadowDepth; CBCGPEllipse ellipseIntShadow(centerShadow, radiusSmall, radiusSmall); CBCGPEllipseGeometry egInternalShadow(ellipseIntShadow); CBCGPComplexGeometry shapeShadow; pGM->CombineGeometry(shapeShadow, egShadow, egInternalShadow, RGN_DIFF); pGM->FillGeometry(shapeShadow, m_brShadow); } CBCGPEllipseGeometry eg(rect); CBCGPEllipseGeometry egInternal(ellipseInt); CBCGPComplexGeometry shape; pGM->CombineGeometry(shape, eg, egInternal, RGN_DIFF); pGM->FillGeometry(shape, m_brFill); } else { if (m_nShadowDepth > 0) { pGM->FillEllipse(rectShadow, m_brShadow); } pGM->FillEllipse(rect, m_brFill); } pGM->DrawEllipse(rect, m_brBorder); if (!pGM->IsSupported(BCGP_GRAPHICS_MANAGER_COLOR_OPACITY)) { CBCGPRect rect1 = rect; rect1.DeflateRect(1, 1); pGM->DrawEllipse(rect1, m_brFill); } BOOL bIsCtrlDisabled = m_pCtrl->GetSafeHwnd() != NULL && !m_pCtrl->IsWindowEnabled(); for (int i = 0; i < nItems; i++) { CBCGPRadialMenuItem* pItem = m_arItems[i]; ASSERT_VALID(pItem); if (i == m_nHighlighted) { pGM->FillGeometry(pItem->m_Shape, m_nHighlighted == m_nPressed ? m_brPressed : m_brHighlighted.IsEmpty() ? m_brFill : m_brHighlighted); } pItem->OnDrawIcon(pGM, bIsCtrlDisabled, m_Icons, sizeIcon); pGM->DrawGeometry(pItem->m_Shape, m_brBorder); } pGM->DrawEllipse(ellipseInt, m_brBorder); if (!pGM->IsSupported(BCGP_GRAPHICS_MANAGER_ANTIALIAS)) { rect.InflateRect(1, 1); pGM->DrawEllipse(rect, m_brBorder); } if (m_pCtrl->GetSafeHwnd() != NULL && m_pCtrl->IsFocused() && !m_pCtrl->IsPopup()) { rect.InflateRect(1, 1); pGM->DrawEllipse(rect, m_brFocusedBorder); } }
//****************************************************************************** void CBCGPRadialMenuItem::OnDrawIcon(CBCGPGraphicsManager* pGM, BOOL bIsCtrlDisabled, CBCGPImage& icons, CBCGPSize sizeIcon) { ASSERT_VALID(pGM); if (m_ptCenter == CBCGPPoint(-1, -1)) { return; } BOOL bIsDisabled = bIsCtrlDisabled || m_bIsDisabled; HICON hIcon = NULL; if (m_hIcon != NULL) { hIcon = m_hIcon; } else if (m_nImageIndex >= 0) { CBCGPPoint ptImage = m_ptCenter; ptImage.x -= .5 * sizeIcon.cx; ptImage.y -= .5 * sizeIcon.cy; pGM->DrawImage(icons, ptImage, sizeIcon, bIsDisabled ? .4 : 1., CBCGPImage::BCGP_IMAGE_INTERPOLATION_MODE_LINEAR, CBCGPRect(CBCGPPoint(sizeIcon.cx * m_nImageIndex, 0), sizeIcon)); } else { // Try to obtain icon from ribbon/toolbars: #ifndef _BCGSUITE_ #ifndef BCGP_EXCLUDE_RIBBON CFrameWnd* pParentFrame = DYNAMIC_DOWNCAST (CFrameWnd, AfxGetMainWnd()); CBCGPRibbonBar* pRibbonBar = NULL; CBCGPMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST (CBCGPMDIFrameWnd, pParentFrame); if (pMainFrame != NULL) { pRibbonBar = pMainFrame->GetRibbonBar(); } else // Maybe, SDI frame... { CBCGPFrameWnd* pFrame = DYNAMIC_DOWNCAST (CBCGPFrameWnd, pParentFrame); if (pFrame != NULL) { pRibbonBar = pFrame->GetRibbonBar(); } } if (pRibbonBar != NULL) { ASSERT_VALID(pRibbonBar); hIcon = pRibbonBar->ExportImageToIcon(m_nID, FALSE); } else #endif #endif { #ifndef _BCGSUITE_ int nImage = CImageHash::GetImageOfCommand(m_nID, FALSE); #else int nImage = GetCmdMgr ()->GetCmdImage(m_nID, FALSE); #endif CBCGPToolBarImages* pImages = CBCGPToolBar::GetImages(); if (pImages != NULL && nImage >= 0) { hIcon = pImages->ExtractIcon(nImage); } } if (hIcon != NULL) { m_hIcon = hIcon; m_bDestroyIcon = TRUE; } } if (hIcon != NULL) { CBCGPImage image(hIcon); sizeIcon = pGM->GetImageSize(image); CBCGPPoint ptImage = m_ptCenter; ptImage.x -= .5 * sizeIcon.cx; ptImage.y -= .5 * sizeIcon.cy; pGM->DrawImage(image, ptImage, CBCGPSize(), bIsDisabled ? .4 : 1); } }