//************************************************************************************
BOOL CBCGPShowAllButton::OnClick (CWnd* /*pWnd*/, BOOL bDelay)
{
	CBCGPPopupMenuBar* pParentMenuBar = DYNAMIC_DOWNCAST (CBCGPPopupMenuBar, m_pWndParent);
	if (pParentMenuBar == NULL)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	if (bDelay)
	{
		if (CBCGPMenuBar::IsShowAllCommandsDelay ())
		{
			pParentMenuBar->StartPopupMenuTimer (this, 2);
		}

		return TRUE;
	}

	CBCGPPopupMenu* pParentMenu = 
		DYNAMIC_DOWNCAST (CBCGPPopupMenu, pParentMenuBar->GetParent ());
	if (pParentMenu == NULL)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	pParentMenu->ShowAllCommands ();
	return TRUE;
}
//****************************************************************************
CBCGPToolbarButton* CBCGPDropDownList::GetItem (int nIndex) const
{
	ASSERT_VALID (this);

	CBCGPPopupMenuBar* pMenuBar = ((CBCGPDropDownList*) this)->GetMenuBar ();
	ASSERT_VALID (pMenuBar);

	int nCurrIndex = 0;

	for (int i = 0; i < pMenuBar->GetCount (); i++)
	{
		CBCGPToolbarButton* pItem = pMenuBar->GetButton (i);
		ASSERT_VALID (pItem);

		if (!(pItem->m_nStyle & TBBS_SEPARATOR))
		{
			if (nIndex == nCurrIndex)
			{
				return pItem;
			}
		}
	}

	return NULL;
}
void CBCGPDropDownList::Track (CPoint point, CWnd *pWndOwner)
{
	if (!Create (pWndOwner, point.x, point.y, m_Menu, FALSE, TRUE))
	{
		return;
	}

	CBCGPPopupMenuBar* pMenuBar = GetMenuBar ();
	ASSERT_VALID (pMenuBar);

	pMenuBar->m_iMinWidth = m_nMinWidth;
	pMenuBar->m_bDisableSideBarInXPMode = TRUE;

	HighlightItem (m_nCurSel);
	pMenuBar->RedrawWindow ();

	CRect rect;
	GetWindowRect (&rect);
	UpdateShadow (&rect);

	CBCGPDialog* pParentDlg = NULL;
	if (pWndOwner != NULL && pWndOwner->GetParent () != NULL)
	{
		pParentDlg = DYNAMIC_DOWNCAST (CBCGPDialog, pWndOwner->GetParent ());
		if (pParentDlg != NULL)
		{
			pParentDlg->SetActiveMenu (this);
		}
	}

	CBCGPPropertyPage* pParentPropPage = NULL;
	if (pWndOwner != NULL && pWndOwner->GetParent () != NULL)
	{
		pParentPropPage = DYNAMIC_DOWNCAST (CBCGPPropertyPage, pWndOwner->GetParent ());
		if (pParentPropPage != NULL)
		{
			pParentPropPage->SetActiveMenu (this);
		}
	}
}
//***************************************************************************
int CBCGPDropDownList::GetCurSel()
{
	ASSERT_VALID (this);

	if (GetSafeHwnd () == NULL)
	{
		return m_nCurSel;
	}

	CBCGPPopupMenuBar* pMenuBar = ((CBCGPDropDownList*) this)->GetMenuBar ();
	ASSERT_VALID (pMenuBar);

	CBCGPToolbarButton* pSel = pMenuBar->GetHighlightedButton ();
	if (pSel == NULL)
	{
		return -1;
	}

	int nIndex = 0;

	for (int i = 0; i < pMenuBar->GetCount (); i++)
	{
		CBCGPToolbarButton* pItem = pMenuBar->GetButton (i);
		ASSERT_VALID (pItem);

		if (!(pItem->m_nStyle & TBBS_SEPARATOR))
		{
			if (pSel == pItem)
			{
				m_nCurSel = nIndex;
				return nIndex;
			}

			nIndex++;
		}
	}

	return -1;
}
Esempio n. 5
0
//****************************************************************************************
CBCGPDropDownFrame* CBCGPDropDownFrame::GetParentPopupMenu () const
{
	if (m_pParentBtn == NULL)
	{
		return NULL;
	}
	
	CBCGPPopupMenuBar* pParentBar = 
		DYNAMIC_DOWNCAST (CBCGPPopupMenuBar, m_pParentBtn->m_pWndParent);
	if (pParentBar != NULL)
	{
		CBCGPDropDownFrame* pParentMenu =
			DYNAMIC_DOWNCAST (CBCGPDropDownFrame, pParentBar->GetParentFrame ());
		ASSERT_VALID (pParentMenu);
		
		return pParentMenu;
	}
	else
	{
		return NULL;
	}
}
//***************************************************************************
void CBCGPDropDownList::HighlightItem (int nIndex)
{
	ASSERT_VALID (this);

	CBCGPPopupMenuBar* pMenuBar = GetMenuBar ();
	ASSERT_VALID (pMenuBar);

	if (nIndex < 0)
	{
		return;
	}

	pMenuBar->m_iHighlighted = nIndex;

	SCROLLINFO scrollInfo;
	ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));

    scrollInfo.cbSize = sizeof(SCROLLINFO);
	scrollInfo.fMask = SIF_ALL;

	m_wndScrollBarVert.GetScrollInfo (&scrollInfo);

	int iOffset = nIndex;
	int nMaxOffset = scrollInfo.nMax;

	iOffset = min (max (0, iOffset), nMaxOffset);

	if (iOffset != pMenuBar->GetOffset ())
	{
		pMenuBar->SetOffset (iOffset);

		m_wndScrollBarVert.SetScrollPos (iOffset);
		AdjustScroll ();
		
	}
}
//***************************************************************************
int CBCGPDropDownList::SetCurSel(int nSelect)
{
	ASSERT_VALID (this);

	const int nSelOld = GetCurSel ();

	if (GetSafeHwnd () == NULL)
	{
		m_nCurSel = nSelect;
		return nSelOld;
	}

	CBCGPPopupMenuBar* pMenuBar = ((CBCGPDropDownList*) this)->GetMenuBar ();
	ASSERT_VALID (pMenuBar);

	int nIndex = 0;

	for (int i = 0; i < pMenuBar->GetCount (); i++)
	{
		CBCGPToolbarButton* pItem = pMenuBar->GetButton (i);
		ASSERT_VALID (pItem);

		if (!(pItem->m_nStyle & TBBS_SEPARATOR))
		{
			if (nIndex == nSelect)
			{
				HighlightItem (i);
				return nSelOld;
			}

			nIndex++;
		}
	}

	return -1;
}
Esempio n. 8
0
BOOL CMainFrame::OnShowPopupMenu (CBCGPPopupMenu* pMenuPopup)
{
    CBCGPMDIFrameWnd::OnShowPopupMenu (pMenuPopup);

    if (pMenuPopup == NULL)
    {
        return TRUE;
    }

    CBCGPPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar ();
    ASSERT_VALID (pMenuBar);

    for (int i = 0; i < pMenuBar->GetCount (); i ++)
    {
        CBCGPToolbarButton* pButton = pMenuBar->GetButton (i);
        ASSERT_VALID (pButton);

        if (pButton->m_nID == ID_FAVORITES_DUMMY)
        {
            pMenuBar->ImportFromMenu (m_menuFavotites);
            pMenuPopup->SetMaxWidth (300);

            return TRUE;
        }

        if (pButton->m_nID == ID_VIEW_HISTORY)
        {
            CMenu menuHistory;
            menuHistory.LoadMenu (IDR_HISTORY_POPUP);

            CMenu* subMenu = menuHistory.GetSubMenu (0);
            ASSERT_VALID (subMenu);

            CBCGPIE7DemoView* pView = DYNAMIC_DOWNCAST(CBCGPIE7DemoView, GetActiveHTML ());
            if (pView != NULL)
            {
                CBCGPIE7DemoDoc* pDoc = pView->GetDocument ();
                if (pDoc != NULL)
                {
                    _T_HistotyList lst;

                    int index = 0;
                    POSITION pos = NULL;

                    pDoc->GetBackList (lst);
                    for (pos = lst.GetHeadPosition (); pos != NULL;)
                    {
                        CHistoryObj* pObj = lst.GetNext (pos);
                        ASSERT (pObj != NULL);

                        subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION,
                                             pObj->GetCommand (), pObj->GetTitle ());
                        index++;
                    }

                    pDoc->GetFrwdList (lst);
                    for (pos = lst.GetHeadPosition (); pos != NULL;)
                    {
                        CHistoryObj* pObj = lst.GetNext (pos);
                        ASSERT (pObj != NULL);

                        subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION,
                                             pObj->GetCommand (), pObj->GetTitle ());
                        index++;
                    }

                    if (index > 0)
                    {
                        subMenu->InsertMenu (index, MF_SEPARATOR | MF_BYPOSITION, 0, (LPCTSTR)NULL);
                    }
                }
            }

            pMenuBar->ImportFromMenu (subMenu->GetSafeHmenu ());
            return TRUE;
        }
    }

    return TRUE;
}
//*******************************************************************************************
BOOL CBCGPDlgImpl::ProcessMouseClick (POINT pt)
{
	if (!CBCGPToolBar::IsCustomizeMode () &&
		CBCGPPopupMenu::GetActiveMenu() != NULL &&
		::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd))
	{
		CBCGPPopupMenu::MENUAREA_TYPE clickArea = CBCGPPopupMenu::GetActiveMenu()->CheckArea (pt);

		if (clickArea == CBCGPPopupMenu::OUTSIDE)
		{
			// Click outside of menu

			//--------------------------------------------
			// Maybe secondary click on the parent button?
			//--------------------------------------------
			CBCGPToolbarMenuButton* pParentButton = 
				CBCGPPopupMenu::GetActiveMenu()->GetParentButton ();
			if (pParentButton != NULL)
			{
				CWnd* pWndParent = pParentButton->GetParentWnd ();
				if (pWndParent != NULL)
				{
					CBCGPPopupMenuBar* pWndParentPopupMenuBar = 
						DYNAMIC_DOWNCAST (CBCGPPopupMenuBar, pWndParent);

					CPoint ptClient = pt;
					pWndParent->ScreenToClient (&ptClient);

					if (pParentButton->Rect ().PtInRect (ptClient))
					{
						//-------------------------------------------------------
						// If user clicks second time on the parent button,
						// we should close an active menu on the toolbar/menubar
						// and leave it on the popup menu:
						//-------------------------------------------------------
						if (pWndParentPopupMenuBar == NULL &&
							!CBCGPPopupMenu::GetActiveMenu()->InCommand ())
						{
							//----------------------------------------
							// Toolbar/menu bar: close an active menu!
							//----------------------------------------
							CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE);
						}

						return TRUE;
					}

					if (pWndParentPopupMenuBar != NULL)
					{
						pWndParentPopupMenuBar->CloseDelayedSubMenu ();
						
						CBCGPPopupMenu* pWndParentPopupMenu = 
							DYNAMIC_DOWNCAST (CBCGPPopupMenu, 
							pWndParentPopupMenuBar->GetParent ());

						if (pWndParentPopupMenu != NULL)
						{
							CBCGPPopupMenu::MENUAREA_TYPE clickAreaParent = 
								pWndParentPopupMenu->CheckArea (pt);

							switch (clickAreaParent)
							{
							case CBCGPPopupMenu::MENU:
							case CBCGPPopupMenu::TEAROFF_CAPTION:
							case CBCGPPopupMenu::LOGO:
								return FALSE;

							case CBCGPPopupMenu::SHADOW_RIGHT:
							case CBCGPPopupMenu::SHADOW_BOTTOM:
								pWndParentPopupMenu->SendMessage (WM_CLOSE);
								m_Dlg.SetFocus ();

								return TRUE;
							}
						}
					}
				}
			}

			if (!CBCGPPopupMenu::GetActiveMenu()->InCommand ())
			{
				CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE);

				CWnd* pWndFocus = CWnd::GetFocus ();
				if (pWndFocus != NULL && pWndFocus->IsKindOf (RUNTIME_CLASS (CBCGPToolBar)))
				{
					m_Dlg.SetFocus ();
				}

				if (clickArea != CBCGPPopupMenu::OUTSIDE)	// Click on shadow
				{
					return TRUE;
				}
			}
		}
		else if (clickArea == CBCGPPopupMenu::SHADOW_RIGHT ||
				clickArea == CBCGPPopupMenu::SHADOW_BOTTOM)
		{
			CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE);
			m_Dlg.SetFocus ();

			return TRUE;
		}
	}

	return FALSE;
}
void CBCGPVisualManagerVS2008::OnFillBarBackground (CDC* pDC, CBCGPBaseControlBar* pBar,
								CRect rectClient, CRect rectClip,
								BOOL bNCArea)
{
	ASSERT_VALID(pBar);
	ASSERT_VALID(pDC);

	if (pBar->IsOnGlass ())
	{
		pDC->FillSolidRect (rectClient, RGB (0, 0, 0));
		return;
	}

	if (DYNAMIC_DOWNCAST (CBCGPReBar, pBar) != NULL ||
		DYNAMIC_DOWNCAST (CBCGPReBar, pBar->GetParent ()))
	{
		FillRebarPane (pDC, pBar, rectClient);
		return;
	}

	if (globalData.m_nBitsPerPixel <= 8 ||
		globalData.IsHighContastMode () ||
		!pBar->IsKindOf (RUNTIME_CLASS (CBCGPPopupMenuBar)) ||
		pBar->IsKindOf (RUNTIME_CLASS (CBCGPColorBar)) ||
		pBar->IsKindOf (RUNTIME_CLASS (CBCGPCalculator)) ||
		pBar->IsKindOf (RUNTIME_CLASS (CBCGPCalendarBar)) ||
		GetStandardWinXPTheme () != WinXpTheme_Blue ||
		m_bOSColors)
	{
		CBCGPVisualManagerVS2005::OnFillBarBackground (pDC, pBar, rectClient, rectClip, bNCArea);
		return;
	}

	if (rectClip.IsRectEmpty ())
	{
		rectClip = rectClient;
	}

	pDC->FillRect (rectClip, &m_brMenuLight);

	CBCGPPopupMenuBar* pMenuBar = DYNAMIC_DOWNCAST (CBCGPPopupMenuBar, pBar);
	ASSERT_VALID (pMenuBar);

	if (!pMenuBar->m_bDisableSideBarInXPMode)
	{
		CRect rectImages = rectClient;

		rectImages.right = rectImages.left + pMenuBar->GetGutterWidth ();

		if (!pMenuBar->HasGutterLogo())
		{
			rectImages.DeflateRect (0, 1);
		}

		CBrush br (WINXPBLUE_MENU_GUTTER);
		pDC->FillRect (rectImages, &br);

		CPen* pOldPen = pDC->SelectObject (&m_penSeparator);
		ASSERT (pOldPen != NULL);

		pDC->MoveTo (rectImages.right, rectImages.top);
		pDC->LineTo (rectImages.right, rectImages.bottom);

		pDC->SelectObject (pOldPen);
	}
}