コード例 #1
0
BOOL CBCGPRibbonItemDlg::OnInitDialog() 
{
	CBCGPDialog::OnInitDialog();

	CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout ();
	if (pLayout != NULL)
	{
		pLayout->AddAnchor (IDC_BCGBARRES_IMAGE_LIST, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth, CSize(0, 0), CSize(100, 100));
		pLayout->AddAnchor (IDD_BCGBAR_RES_LABEL1, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_NAME, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeHorz, CSize(50, 100), CSize(100, 100));
		pLayout->AddAnchor (IDOK, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(100, 100));
		pLayout->AddAnchor (IDCANCEL, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(100, 100));
	}
	
	m_wndImageList.SetImages(&m_images);
	
	int nCount = m_images.GetCount ();

	for (int iImage = 0; iImage < nCount; iImage++)
	{
		CBCGPToolbarButton* pButton = new CBCGPToolbarButton;

		pButton->SetImage (iImage);

		m_wndImageList.AddButton (pButton);
		m_Buttons.AddTail (pButton);
	}

	m_wndImageList.SelectButton (m_iSelImage);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #2
0
//********************************************************************************
void CButtonAppearanceDlg::OnImageList() 
{
	CBCGPToolbarButton* pSelButton = m_wndButtonList.GetSelectedButton ();
	m_iSelImage = (pSelButton == NULL) ? -1 : pSelButton->GetImage ();

	m_wndEditImage.EnableWindow (m_iSelImage >= 0 &&
		m_pImages != NULL && !m_pImages->IsReadOnly ());
}
コード例 #3
0
void CButtonsTextList::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CListBox::OnLButtonDown(nFlags, point);

	int iIndex = GetCurSel ();
	if (iIndex == LB_ERR)
	{
		return;
	}

	//-------------------------------------------
	// Be sure that we realy click into the item!
	//-------------------------------------------
	CRect rect;
	GetItemRect (iIndex, &rect);

	if (!rect.PtInRect (point))
	{
		return;
	}

	//-----------------------------------------------------------
	// Trigger mouse up event (to change selection notification):
	//-----------------------------------------------------------
	SendMessage (WM_LBUTTONUP, nFlags, MAKELPARAM (point.x, point.y));

	//---------------------
	// Get selected button:
	//---------------------
	CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) GetItemData (iIndex);
	ASSERT_VALID(pButton);

	//--------------------------------------
	// Prepare clipboard data and start drag:
	//--------------------------------------
	COleDataSource* pSrcItem = new COleDataSource();

	pButton->m_bDragFromCollection = TRUE;
	pButton->PrepareDrag (*pSrcItem);
	pButton->m_bDragFromCollection = FALSE;

	{
		CBCGPLocalResource locaRes;
		::SetCursor (AfxGetApp ()->LoadCursor (IDC_BCGBARRES_DELETE));
	}

	pSrcItem->DoDragDrop(DROPEFFECT_COPY|DROPEFFECT_MOVE, &rect, &CBCGPToolBar::m_DropSource);
	pSrcItem->InternalRelease();
}
コード例 #4
0
//*********************************************************************************
void CBCGPPrintPreviewView::OnUpdatePreviewNumPage(CCmdUI *pCmdUI) 
{
	CPreviewView::OnUpdateNumPageChange(pCmdUI);

	//--------------------------------------------------
	// Change the Icon of AFX_ID_PREVIEW_NUMPAGE button:
	//--------------------------------------------------
	UINT nPages = m_nZoomState == ZOOM_OUT ? m_nPages : m_nZoomOutPages;

#ifndef BCGP_EXCLUDE_RIBBON
	if (m_pWndRibbonBar != NULL && m_pWndRibbonBar->IsVisible())
	{
		ASSERT_VALID (m_pWndRibbonBar);

		if (m_pNumPageButton == NULL)
		{
			m_pNumPageButton = DYNAMIC_DOWNCAST (
				CBCGPRibbonButton,
				m_pWndRibbonBar->GetActiveCategory ()->FindByID (AFX_ID_PREVIEW_NUMPAGE));
		}

		if (m_pNumPageButton != NULL)
		{
			ASSERT_VALID (m_pNumPageButton);

			int nImageIndex = nPages == 1 ? 5 : 4;

			if (m_pNumPageButton->GetImageIndex (TRUE) != nImageIndex)
			{
				m_pNumPageButton->SetImageIndex (nImageIndex, TRUE);
				m_pNumPageButton->SetKeys (nPages == 1 ? _T("2") : _T("1"));
				m_pNumPageButton->Redraw ();
			}
		}
	}
	else
#endif
	if (m_wndToolBar.GetSafeHwnd () != NULL)
	{
		CBCGPToolbarButton* pButton = m_wndToolBar.GetButton (m_iPagesBtnIndex);
		ASSERT_VALID (pButton);

		pButton->SetImage (nPages == 1 ? m_iTwoPageImageIndex : m_iOnePageImageIndex);

		m_wndToolBar.InvalidateRect (pButton->Rect ());
	}
}
コード例 #5
0
ファイル: BCGPDropDown.cpp プロジェクト: iclosure/jframework
//****************************************************************************************
void CBCGPDropDownToolbarButton::SetDefaultCommand (UINT uiCmd)
{
	ASSERT_VALID (m_pToolBar);

	m_nID = uiCmd;

	//------------------
	// Find image index:
	//------------------
	int iImage = 0;
	m_iSelectedImage = -1;

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

		if (pButton->m_nStyle & TBBS_SEPARATOR)
		{
			continue;
		}

		if (pButton->m_nID == uiCmd)
		{
 			m_bLocalUserButton = pButton->m_bUserButton;
			m_strSelectedText = pButton->m_strText;

 			if (m_bLocalUserButton)
			{
 				m_iSelectedImage = pButton->GetImage();
			}
 			else
			{
				m_iSelectedImage = iImage;
			}
			break;
		}

		iImage ++;
	}

	if (m_iSelectedImage == -1)
	{
		ASSERT (FALSE);
		m_iSelectedImage = 0;
	}
}
コード例 #6
0
ファイル: ContextToolbar.cpp プロジェクト: zxlooong/bcgexp
//*******************************************************************************
void CContextToolbar::ShowButtons(UINT btnFirstID, UINT btnLastID, BOOL bVisible, BOOL bAutoAdjust)
{
    for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
    {
        CBCGPToolbarButton* pButton = 
            DYNAMIC_DOWNCAST (CBCGPToolbarButton,
            m_Buttons.GetNext (pos));
        if (pButton->m_nID >= btnFirstID && pButton->m_nID <= btnLastID)
        {
            pButton->SetVisible (bVisible);
        }
    }
    if (bAutoAdjust)
    {
        AdjustLayout ();
    }
}
コード例 #7
0
//**********************************************************************************
void CCxLoginBar::AdjustLocations ()
{
	ASSERT_VALID(this);
	
	if (m_Buttons.IsEmpty () || GetSafeHwnd () == NULL)
	{
		return;
	}

	CRect rectClient;
	GetClientRect (rectClient);
	if ( rectClient.IsRectEmpty() || rectClient.IsRectNull() )
	{
		return;
	}

	CRect rc;

	for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
	{
		CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) m_Buttons.GetNext (pos);
		if (pButton == NULL || pButton == (CBCGPToolbarButton*)m_pCustomizeBtn)
		{
			break;
		}

		ASSERT_VALID (pButton);

		if (pButton->IsVisible ())
		{
			if ( pButton->IsKindOf( RUNTIME_CLASS(CCxLoginBarUserButton) ) )
			{
				rc = rectClient;
				//rc.right = rectClient.right - g_nLoginWidth - 1;
				pButton->SetRect (rc);
			}
			/*else if ( pButton->IsKindOf( RUNTIME_CLASS(CCxLoginBarLoginButton) ) )
			{
			rc = rectClient;
			rc.left = rectClient.right - g_nLoginWidth;
			pButton->SetRect (rc);
			}*/
		}
	}
}
コード例 #8
0
//****************************************************************************************
void CButtonsTextList::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	ASSERT_VALID (pDC);

	CRect rect = lpDIS->rcItem;

	if (lpDIS->itemID != (UINT)-1)
	{
		CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) GetItemData (lpDIS->itemID);
		ASSERT_VALID(pButton);

		CString strText = pButton->m_strText;
		GetText (lpDIS->itemID, pButton->m_strText);

		CBCGPVisualManager::GetInstance ()->OnFillCommandsListBackground (pDC, rect);

		pButton->OnDrawOnCustomizeList (pDC, rect, 
			(lpDIS->itemState & ODS_SELECTED) && (lpDIS->itemState & ODS_FOCUS));
		pButton->m_strText = strText;
	}
}
コード例 #9
0
//********************************************************************************
void CButtonAppearanceDlg::RebuildImageList ()
{
	m_wndButtonList.RemoveButtons ();

	while (!m_Buttons.IsEmpty ())
	{
		delete m_Buttons.RemoveHead ();
	}

	int iEnd = m_pImages->GetCount () - 1;
	for (int iImage = m_iStartImage; iImage <= iEnd; iImage ++)
	{
		CBCGPToolbarButton* pButton = new CBCGPToolbarButton;

		pButton->SetImage (iImage);

		m_wndButtonList.AddButton (pButton);
		m_Buttons.AddTail (pButton);
	}

	m_wndButtonList.Invalidate ();
}
コード例 #10
0
ファイル: Palette.cpp プロジェクト: zxlooong/bcgexp
CSize CToolPalette::CalcButtonLocations(int nColumns, bool bCalcOnly)
{
    if (nColumns < 1)
    {
        nColumns = 1;
    }
    bool bHorizontal = (GetCurrentAlignment () & CBRS_ORIENT_HORZ) != 0; // Toolbar layout mode

    CRect rectClient;
    GetClientRect (rectClient);

    EDisplayOptions edo = GetToolbarDisplayOptions ();
    if ((edo & eDisplayTitle) != 0)
    {
        if (!bHorizontal)
        {
            rectClient.top += m_nCaptionHeight + 4;
        }
    }
    int xBorders = 0;
    int yBorders = 0;
    if ((edo & eDisplayBorder) != 0)
    {
        const CRect& rectCorners = m_imgCaption.GetParams ().m_rectCorners;
        rectClient.left += rectCorners.left + 3;
        rectClient.top += rectCorners.top;
        xBorders = rectCorners.left + rectCorners.right;
        yBorders = rectCorners.top + rectCorners.bottom;
    }
    else
    {
        rectClient.left += 1;
    }
    if ((edo & eDisplaySizeControl) != 0 && bHorizontal)
    {
        const int sizeControlHeight = m_imgCaption.GetParams ().m_rectImage.Height ();
        yBorders += sizeControlHeight;
        rectClient.top += sizeControlHeight;
    }

    // Consider border area

    CPoint xyPos = rectClient.TopLeft (); // Current position
    bool bPrevSeparator = true; // Indicates that previous button was a separator.
                                // Initial 'true' value prevents separator to appear first.
    CClientDC dc (this);
    CSize szButtonDefault (GetColumnWidth (), GetRowHeight ()); // Default button size to pass to button's OnCalculateSize method
    int nMaxSize = nColumns * (bHorizontal ? szButtonDefault.cy : szButtonDefault.cx) * 11 / 10; // (11/10) adds +10% space here
        // The toolbar height (for horizontal layout) or width (for vertical) of toolbar.

    CList<ButtonStripe, const ButtonStripe&> listStripes;

    ButtonStripe stripe; // Current stripe
    CBCGPToolbarButton* pButton = NULL; // Current button
    for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
    {
        pButton = (CBCGPToolbarButton*)m_Buttons.GetNext (pos);
        if (pButton == NULL)
        {
            break;
        }

        if (!pButton->IsVisible ())
        {
            continue;
        }

        bool bSep = (pButton->m_nStyle & TBBS_SEPARATOR) != 0;
        if (bSep && bPrevSeparator)
        {
            continue;
        }

        //  Layout algorithm:
        // -------------------
        // if (separator) AddPreviousStripe, AddSeparatorStripe, BeginNewStripe
        // else {
        //      AddButton
        //      if (stripe.breadth > default_stripe_breadth)
        //          AddPreviousStripe, BeginNewStripe, AddButton
        // }


        CSize szButton = pButton->OnCalculateSize (&dc, szButtonDefault, bHorizontal);
        if (bHorizontal)
        {

        }
        else // vertical layout
        {
            if (bSep)
            {
                if (stripe.buttonCount > 0)
                {
                    listStripes.AddTail (stripe);
                }
                stripe.buttonCount = 1;
                stripe.breadth = 0; // separator length is set automatically
                stripe.size = szButton.cy; // cx for horz.
                listStripes.AddTail (stripe);
                stripe = ButtonStripe ();
            }
            else if (szButton.cx > nMaxSize) // this button is larger than current toolbar width
            {
                if (stripe.buttonCount > 0)
                {
                    listStripes.AddTail (stripe);
                }
                stripe.buttonCount = 1;
                stripe.breadth = szButton.cx; // cy for horz.
                stripe.size = szButton.cy; // cx for horz.
                listStripes.AddTail (stripe); // stripe with a single large button
                stripe = ButtonStripe ();
            }
            else // usual button
            {
                if (stripe.breadth + szButton.cx <= nMaxSize)
                {
                    stripe.breadth += szButton.cx;
                    stripe.buttonCount ++;
                    if (szButton.cy > stripe.size)
                        stripe.size = szButton.cy;
                }
                else
                {
                    if (stripe.buttonCount > 0)
                    {
                        listStripes.AddTail (stripe);
                    }
                    stripe.buttonCount = 1;
                    stripe.breadth = szButton.cx; // cy for horz.
                    stripe.size = szButton.cy; // cx for horz.
                }
            }
        }
        bPrevSeparator = bSep;
    }
    if (stripe.buttonCount > 0)
    {
        listStripes.AddTail (stripe);
    }
    if (listStripes.IsEmpty ())
    {
        return CSize (0, 0);
    }
    if (listStripes.GetTail ().breadth == 0) // last item is separator
    {
        listStripes.RemoveTail ();
    }

    // Now calculate total size
    int totalLength = m_nCaptionHeight + 4;
    int maxBreadth = nMaxSize;
    POSITION posStripes = listStripes.GetHeadPosition ();
    while (posStripes != NULL)
    {
        stripe = listStripes.GetNext (posStripes);
        ASSERT (stripe.buttonCount > 0);
        totalLength += stripe.size;
        if (stripe.breadth > maxBreadth)
        {
            maxBreadth = stripe.breadth;
        }
    }

    if (!bCalcOnly)
    {
        CPoint ptButtonPos = rectClient.TopLeft ();

        posStripes = listStripes.GetHeadPosition ();
        stripe = ButtonStripe();

        for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
        {
            pButton = (CBCGPToolbarButton*)m_Buttons.GetNext (pos);
            if (pButton == NULL)
            {
                break;
            }

            if (!pButton->IsVisible ())
            {
                continue;
            }

            bool bSep = (pButton->m_nStyle & TBBS_SEPARATOR) != 0;
            if (bSep && bPrevSeparator)
            {
                continue;
            }

            CSize szButton = pButton->OnCalculateSize (&dc, szButtonDefault, bHorizontal);
            CRect rcButton (0, 0, 0, 0);

            if (stripe.buttonCount == 0) // this member is decremented below
            {
                ptButtonPos.y += stripe.size;
                if (posStripes == NULL)
                {
                    break;
                }
                stripe = listStripes.GetNext (posStripes);
                ptButtonPos.x = rectClient.left + (maxBreadth - stripe.breadth) / 2; // center-alignment
            }

            if (bSep)
            {
                ASSERT (stripe.breadth == 0);
                ASSERT (stripe.buttonCount == 1);
                rcButton.left = rectClient.left;
                rcButton.top = ptButtonPos.y;
                rcButton.right = rcButton.left + maxBreadth;
                rcButton.bottom = rcButton.top + szButton.cy;
            }
            else
            {
                rcButton.left = ptButtonPos.x;
                rcButton.top = ptButtonPos.y + (stripe.size - szButton.cy) / 2; // center-alignment
                rcButton.right = rcButton.left + szButton.cx;
                rcButton.bottom = rcButton.top + szButton.cy;
                ptButtonPos.x += szButton.cx;
            }
            pButton->SetRect (rcButton);
            stripe.buttonCount --;
        }
    }

    if (m_bAdditionalPixel)
    {
        ++maxBreadth;
    }

    return bHorizontal ? 
        CSize (totalLength + xBorders, maxBreadth + yBorders) :
        CSize (maxBreadth + xBorders, totalLength + yBorders);
}
コード例 #11
0
//***************************************************************************************************************
void CBCGPRibbonItemDlg::OnImageList() 
{
	CBCGPToolbarButton* pSelButton = m_wndImageList.GetSelectedButton ();
	m_iSelImage = (pSelButton == NULL) ? -1 : pSelButton->GetImage ();
}