Esempio n. 1
0
void WeaselPanel::_ResizeWindow()
{
	if (!m_status.composing)
	{
		SetWindowPos( NULL, 0, 0, STATUS_ICON_SIZE, STATUS_ICON_SIZE, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
		return;
	}
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);

	CSize size = m_layout->GetContentSize();
	SetWindowPos(NULL, 0, 0, size.cx, size.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
	dc.DeleteDC();
}
Esempio n. 2
0
//¸üнçÃæ
void WeaselPanel::Refresh()
{
	if (m_layout != NULL)
		delete m_layout;
	if (m_style.layout_type == LAYOUT_VERTICAL)
		m_layout = new VerticalLayout(m_style, m_ctx);
	else if (m_style.layout_type == LAYOUT_HORIZONTAL)
		m_layout = new HorizontalLayout(m_style, m_ctx);
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);
	m_layout->DoLayout(dc);
	dc.DeleteDC();

	_ResizeWindow();
	_RepositionWindow();
	RedrawWindow();
}
Esempio n. 3
0
void CDuiMenuODWnd::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    CRect rcItem=lpDrawItemStruct->rcItem;
    DuiMenuItemData *pdmmi=(DuiMenuItemData*)lpDrawItemStruct->itemData;

    CDCHandle dc(lpDrawItemStruct->hDC);
    CDCHandle dcMem;
    dcMem.CreateCompatibleDC(dc);
    CBitmap	  bmp=CGdiAlpha::CreateBitmap32(dc,rcItem.Width(),rcItem.Height());
    CBitmapHandle hOldBmp=dcMem.SelectBitmap(bmp);
    dcMem.BitBlt(0,0,rcItem.Width(),rcItem.Height(),dc,rcItem.left,rcItem.top,SRCCOPY);
    rcItem.MoveToXY(0,0);

    if(pdmmi)
    {
        MENUITEMINFO mii= {sizeof(MENUITEMINFO),MIIM_FTYPE,0};
        HMENU menuPopup=pdmmi->hMenu;
        GetMenuItemInfo(menuPopup,pdmmi->nID,FALSE,&mii);

        BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED;
        BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED;
        BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED;
        BOOL bRadio = mii.fType&MFT_RADIOCHECK;

        m_pItemSkin->Draw(dcMem,rcItem,bSelected?1:0);	//draw back

        //draw icon
        CRect rcIcon;
        rcIcon.left=rcItem.left+m_nIconMargin;
        rcIcon.right=rcIcon.left+m_szIcon.cx;
        rcIcon.top=rcItem.top+(rcItem.Height()-m_szIcon.cy)/2;
        rcIcon.bottom=rcIcon.top+m_szIcon.cy;
        if(bChecked)
        {
            if(m_pCheckSkin)
            {
                if(bRadio) m_pCheckSkin->Draw(dcMem,rcIcon,1);
                else m_pCheckSkin->Draw(dcMem,rcIcon,0);
            }
        }
        else if(pdmmi->itemInfo.iIcon!=-1 && m_pIconSkin)
        {
            m_pIconSkin->Draw(dcMem,rcIcon,pdmmi->itemInfo.iIcon);
        }
        rcItem.left=rcIcon.right+m_nIconMargin;

        //draw text
        CRect rcTxt=rcItem;
        rcTxt.DeflateRect(m_nTextMargin,0);
        dcMem.SetBkMode(TRANSPARENT);

        COLORREF crOld=dcMem.SetTextColor(bDisabled?m_crTxtGray:(bSelected?m_crTxtSel:m_crTxtNormal));


        HFONT hOldFont=0;
        hOldFont=dcMem.SelectFont(m_hFont);
        dcMem.DrawText(pdmmi->itemInfo.strText,pdmmi->itemInfo.strText.GetLength(),&rcTxt,DT_SINGLELINE|DT_VCENTER|DT_LEFT);
        dcMem.SelectFont(hOldFont);

        dcMem.SetTextColor(crOld);

        if(bSelected && m_pItemSkin->GetStates()>2)
        {
            //draw select mask
            CRect rcItem=lpDrawItemStruct->rcItem;
            rcItem.MoveToXY(0,0);
            m_pItemSkin->Draw(dcMem,rcItem,2);
        }
    }
    else  //if(strcmp("sep",pXmlItem->Value())==0)
    {
        m_pItemSkin->Draw(dcMem,rcItem,0);	//draw back
        if(m_pIconSkin)
        {
            rcItem.left += m_pIconSkin->GetSkinSize().cx+m_nIconMargin*2;
        }

        if(m_pSepSkin)
            m_pSepSkin->Draw(dcMem,&rcItem,0);
        else
        {
            CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top, rcItem.right, rcItem.top, RGB(196,196,196), PS_SOLID);
            CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top+1, rcItem.right, rcItem.top+1, RGB(255,255,255), PS_SOLID);
        }
    }
    rcItem=lpDrawItemStruct->rcItem;
    dc.BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),dcMem,0,0,SRCCOPY);
    dcMem.SelectBitmap(hOldBmp);
    dcMem.DeleteDC();
    bmp.DeleteObject();
}