//*********************************************************************
void CCxNDArrayDimGrid::SetRowHeight ()
{
	if (m_bIsPrinting)
	{
		ASSERT_VALID (m_pPrintDC);

		// map to printer metrics
		HDC hDCFrom = ::GetDC(NULL);
		int nYMul = m_pPrintDC->GetDeviceCaps(LOGPIXELSY);	// pixels in print dc
		int nYDiv = ::GetDeviceCaps(hDCFrom, LOGPIXELSY);	// pixels in screen dc
		::ReleaseDC(NULL, hDCFrom);

		TEXTMETRIC tm;
		m_pPrintDC->GetTextMetrics (&tm);
		m_PrintParams.m_nRowHeight = tm.tmHeight + ::MulDiv (2 * TEXT_VMARGIN, nYMul, nYDiv);
		m_PrintParams.m_nLargeRowHeight = m_PrintParams.m_nRowHeight;
	}
	else
	{
		CClientDC dc (this);
		HFONT hfontOld = SetCurrFont (&dc);

		TEXTMETRIC tm;
		dc.GetTextMetrics (&tm);
		m_nRowHeight = tm.tmHeight + 2 * TEXT_VMARGIN;
		m_nLargeRowHeight = m_nRowHeight;

		::SelectObject (dc.GetSafeHdc (), hfontOld);
	}
}
Exemplo n.º 2
0
void CSketcherView::MoveElement(CClientDC & aDC, const CPoint & point)
{
	CSize distance = point - m_CursorPos; // Get move distance
	m_CursorPos = point; // Set current point as 1st for next time
	
	// If there is an element selected, move it
	if(m_pSelected)
	{
		if (typeid(*m_pSelected) == typeid(CText))
		{
			CRect oldRect=m_pSelected->GetBoundRect(); // Get old bound rect
			aDC.LPtoDP(oldRect); // Convert to client coords
			m_pSelected->Move(distance); // Move the element
			InvalidateRect(&oldRect); // Invalidate combined area
			UpdateWindow(); // Redraw immediately
			m_pSelected->Draw(&aDC,m_pSelected); // Draw highlighted
			return;
		}
		// ...otherwise, use this method
				
		aDC.SetROP2(R2_NOTXORPEN);
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the element to erase it
		m_pSelected-> Move(distance); // Now move the element
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the moved element
	}
}
Exemplo n.º 3
0
void CMainFrame::DrawCell (UINT col,UINT row,BOOL alive)
{
	CBrush* pBrush;
	CClientDC clientDC (this);
	CDC memDC;
	memDC.CreateCompatibleDC (&clientDC);
	memDC.SelectObject (m_pBitmap);

	if(alive)
		pBrush=new CBrush(RGB(255, 0, 0));
	else
	{	
		if (m_showdead)
			pBrush=new CBrush(RGB(200, 200, 200));
		else
			pBrush=new CBrush(RGB(255, 255, 255));
	}

	CBrush* pOldBrush1=memDC.SelectObject (pBrush);
	CBrush* pOldBrush2=clientDC.SelectObject (pBrush);

	UINT drawCol= col * SQUARESIZE + HOROFFSET;
	UINT drawRow= row * SQUARESIZE + VEROFFSET;

	memDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);
	clientDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);

	memDC.SelectObject (pOldBrush1);
	clientDC.SelectObject (pOldBrush2);

	delete pBrush;
}
Exemplo n.º 4
0
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd ::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	//
	// Load the bitmap.
	//
    m_bitmap.LoadBitmap (IDB_BITMAP);

	//
	// Create a palette for a gradient fill if this is a palettized device.
	//
    CClientDC dc (this);
    if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE) {
        struct {
            LOGPALETTE lp;
            PALETTEENTRY ape[63];
        } pal;

        LOGPALETTE* pLP = (LOGPALETTE*) &pal;
        pLP->palVersion = 0x300;
        pLP->palNumEntries = 64;

        for (int i=0; i<64; i++) {
            pLP->palPalEntry[i].peRed = 0;
            pLP->palPalEntry[i].peGreen = 0;
            pLP->palPalEntry[i].peBlue = 255 - (i * 4);
            pLP->palPalEntry[i].peFlags = 0;
        }
        m_palette.CreatePalette (pLP);
    }
	return 0;
}
Exemplo n.º 5
0
// =====
// Helper function to swap palettes...
// ==
BOOL
RealizeSysPalette(CClientDC &dc)
{
	// if user loaded palette not loaded no realize
	if( gPalette == NULL )
		return FALSE;

	CPalette* pOldPal = dc.SelectPalette( gPalette, 0);
	if( pOldPal != NULL ) {
		int rCnt = dc.RealizePalette();

		dc.SelectPalette(pOldPal, 1);

		if( rCnt != 0 )
			afxDump << "QUERYNEWPALETTE  - The number of colors realized " << rCnt << "\n";
		else
			return FALSE;
	}
	else
		return FALSE;

	// we realized our palette so cause a redraw
	if( dc.GetWindow() != NULL )
		dc.GetWindow()->Invalidate(TRUE);

	// indicates that we realized our palette
	return TRUE;
}
Exemplo n.º 6
0
//*****************************************************************************************
void CIconCombo::OnMeasureItem(int /*nIDCtl*/, LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{
	int nTextWidth = 0;
	int nTextHeight = 0;

	if (!m_lstIconNames.IsEmpty ())
	{
		nTextHeight = globalData.GetTextHeight ();

		CClientDC dc (this);
		CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);

		for (POSITION pos = m_lstIconNames.GetHeadPosition (); pos != NULL;)
		{
			CString str = m_lstIconNames.GetNext (pos);

			nTextWidth = max (nTextWidth, dc.GetTextExtent (str).cx + nIconMargin);
		}

		dc.SelectObject (pOldFont);
	}

	lpMeasureItemStruct->itemWidth = m_imageListIcons.GetImageSize ().cx + nTextWidth + 3 * nIconMargin;
	lpMeasureItemStruct->itemHeight = max (nTextHeight, m_imageListIcons.GetImageSize ().cy + 2 * nIconMargin);
}
Exemplo n.º 7
0
void CComputer::eraseDataText(CClientDC &dc)
{
	dc.SetTextColor(white);
	originalFont = dc.SelectObject(&dataFont);
	drawDataText(dc);
	dc.SelectObject(&originalFont);
}
Exemplo n.º 8
0
void CBigIcon::CenterText(CClientDC &dc, LPCSTR lpszStatus, int top)
{
	int			nMargin;
	CRect		rect;
	TEXTMETRIC	tm;

	// Leave a horizontal margin equal to the widest character
	VERIFY(dc.GetTextMetrics(&tm));
	nMargin = tm.tmMaxCharWidth;

	// Compute the opaque rect
	rect.left = nMargin;
	rect.right = m_sizeBitmap.cx - nMargin;
	rect.top = top;
	rect.bottom = rect.top + tm.tmHeight;

	// We need to compute where to draw the text so it is centered
	// horizontally
	int		x = rect.left;
    CSize   extent = CIntlWin::GetTextExtent(0, dc.m_hDC, lpszStatus, XP_STRLEN(lpszStatus));

	if (extent.cx < rect.Width())
		x += (rect.Width() - extent.cx) / 2;

	// Draw opaquely so we can avoid erasing the old text
	dc.ExtTextOut(x, rect.top, ETO_OPAQUE, &rect, lpszStatus, strlen(lpszStatus), NULL);


}
Exemplo n.º 9
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, TRUE); // Set big icon

	// Menu will not take the focus on activation:
	CBCGPPopupMenu::SetForceMenuFocus (FALSE);

	EnableDocking(CBRS_ALIGN_TOP);

	if (!m_wndMenuBar.Create (this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
	m_wndMenuBar.SetRecentlyUsedMenus(FALSE); //不加这句话,菜单初始时,只显示一个下拉键头,不显示全部菜单项.
	// Detect color depth. 256 color toolbars can be used in the
	// high or true color modes only (bits per pixel is > 8):
	CClientDC dc (this);
	BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;

	UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	// TODO: Delete these three lines if you don't want the toolbar to be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	EnableAutoHideBars(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndMenuBar);

	CreateMineToolBar(); // 创建工具栏
	m_MineToolbar.EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_MineToolbar);
	// Allow user-defined toolbars operations:
	InitUserToobars (NULL,
					uiFirstUserToolBarId,
					uiLastUserToolBarId);

	AdjustClientArea();
	// Enable windows manager:
	EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
	OnAppLook (m_nAppLook);

	SetWindowText("综合设计环境");
	SetTitle( "综合设计环境" );
	// VISUAL_MANAGER
	return 0;
}
void CListSelector::draw(CClientDC &dc, int orgX, int orgY, int width, int height)
{
	
	
	list<CSelectorItem>::iterator iter;
	
	int y0 = orgY;
	int y1 = orgY;
	
	int x0 = orgX;
	int x1 = orgX + width;

	
	//dc.Rectangle(orgX,orgY,orgX + width,orgY + height);
	
	int size=this->itemList.size();

	//dc.LineTo(x1,y1);
	int count=9;
	int start=4;
	int isNeedBreak=FALSE;

	int j=0;

	for(int i= -4 + focusIndex ; 
		i<= 4 + focusIndex;
		i++)
	{

		y0 = orgY + (j)*40;
		y1 = y0 + 40;
		CRect rect2(x0, y0+1, x1, y1);
		dc.Rectangle(&rect2);

		if(i==focusIndex)
		{
			CBrush *p=new CBrush();
			p->CreateSolidBrush(RGB(200,0,000));
			dc.FillRect(&rect2,p);
			dc.SetTextColor(RGB(255,255,255));
			delete p;
		}else{
			dc.SetTextColor(RGB(0,0,0));
		}

		int index = 0;
		if(i<0){
			index = (size*0X100000 + i) % size  ;
		}else{
			index=i % size ;
		}

		CString str(itemList[ index  ].getValue().c_str());		
		dc.DrawText(str,&rect2,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
		j++;
	
	}	
	
}
Exemplo n.º 11
0
CSize CBCGPPopupDlg::GetOptimalTextSize (CString str)
{
	if (str.IsEmpty ())
	{
		return CSize (0, 0);
	}

	CRect rectScreen;

	CRect rectDlg;
	GetWindowRect (rectDlg);

	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (MonitorFromPoint (rectDlg.TopLeft (), MONITOR_DEFAULTTONEAREST), &mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	CClientDC dc (this);

	CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);
	ASSERT_VALID (pOldFont);

	int nStepY = globalData.GetTextHeight ();
	int nStepX = nStepY * 3;

	CRect rectText (0, 0, nStepX, nStepY);

	for (;;)
	{
		CRect rectTextSaved = rectText;

		int nHeight = dc.DrawText (str, rectText, DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX);
		int nWidth = rectText.Width ();

		rectText = rectTextSaved;

		if (nHeight <= rectText.Height () ||
			rectText.Width () > rectScreen.Width () ||
			rectText.Height () > rectScreen.Height ())
		{
			rectText.bottom = rectText.top + nHeight + 5;
			rectText.right = rectText.left + nWidth + 5;
			break;
		}

		rectText.right += nStepX;
		rectText.bottom += nStepY;
	}

	dc.SelectObject (pOldFont);
	return rectText.Size ();
}
void CCGuiFlatTabbedViewView::OnSize(UINT nType, int cx, int cy) 
{
	CGuiViewWorkTab::OnSize(nType, cx, cy);
	CClientDC dc (this);
	CString strItem;
	m_wndEdit.GetText (90, strItem);
	int cxExtentMax = 0;
	cxExtentMax = dc.GetTextExtent (strItem).cx;
	m_wndEdit.SetHorizontalExtent (cxExtentMax);
	
	// TODO: Add your message handler code here
	
}
Exemplo n.º 13
0
void CDlgCalcDlg::UpdateDisplay(LPCTSTR pszDisplay)
{
    CClientDC dc (this);
    CFont* pOldFont = dc.SelectObject (GetFont ());
    CSize size = dc.GetTextExtent (pszDisplay);

    CRect rect = m_rect;
    rect.InflateRect (-2, -2);
    int x = rect.right - size.cx - m_cxChar;
    int y = rect.top + ((rect.Height () - m_cyChar) / 2);

    dc.ExtTextOut (x, y, ETO_OPAQUE, rect, pszDisplay, NULL);
    dc.SelectObject (pOldFont);
}
//******************************************************************************
void CBCGPRibbonCommandsListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
	ASSERT (lpMIS != NULL);

	CClientDC dc (this);
	CFont* pOldFont = (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT);
	ASSERT_VALID (pOldFont);

	TEXTMETRIC tm;
	dc.GetTextMetrics (&tm);

	lpMIS->itemHeight = tm.tmHeight + 6;

	dc.SelectObject (pOldFont);
}
Exemplo n.º 15
0
void CAudioCtrl::DrwaWaveChar(CClientDC &dc, DWORD dwDrawBytes, BYTE *pCharData, BOOL bLeftChannel)
{
	CRect rcBK = GetRectByChannel ( bLeftChannel );
	int y = (int) ( pCharData[0] * rcBK.Height() / 0xff );
	dc.MoveTo ( 0, y );
	float fStep = (float)rcBK.Width() / (float)(dwDrawBytes);
	float fLineX = 0;
	for ( DWORD i=1; i<dwDrawBytes; i++ )
	{
		fLineX += fStep;
		y = (int) ( pCharData[i] * rcBK.Height() / 0xff );
		dc.LineTo ( (int)fLineX, y );
		//TRACE2("DrawWave X=%f Y=%d\r\n", fLineX, y);
	}
}
Exemplo n.º 16
0
void CStatusBarXP::OnPaint ()
{
    Default();

    CClientDC cDC (this);
    CPenDC pen (cDC, ::GetSysColor (COLOR_3DSHADOW));
    CRect rcItem;

    cDC.SelectObject (::GetStockObject (NULL_BRUSH));

    for ( int i = 0; i < m_nCount; i++ )
    {
        GetItemRect (i, rcItem);
        cDC.Rectangle (rcItem); 
    }
}
Exemplo n.º 17
0
 MessageHeightMeasurer(HubMessageControl* owner): dc(owner->m_hWnd), oldFont(dc.SelectFont(WinUtil::systemFont)) {
   owner->GetClientRect(clientRect);
   if (!owner->isScrollBarVisible()) {
     clientRect.right -= GetSystemMetrics(SM_CXVSCROLL);
   }
   clientRect.left += owner->m_leftMargin;
   clientRect.right -= owner->m_rightMargin;
 }
Exemplo n.º 18
0
void CComputer::drawDataText(CClientDC &dc)
{
	dc.SelectObject(&dataFont);
	int x,y;
	x=1;//nicht auf 0 setzen, sonst Crash
	y=1;//nicht auf 0 setzen, sonst Crash
	for(int i=0; i<data.getNumberOfLines(); i++){
		if (dataPosition == 1){ //rechts
			x=x2+2*borderWidth;
			y=y1+i*dataTextSize;		
		}else if (dataPosition == 2){ //unten
			x=x1-borderWidth;
			y=y2+2*borderWidth+i*dataTextSize;
		}
		dc.TextOut(x,y,data.getLine(i,isAttacker));
	}
}
Exemplo n.º 19
0
void CAudioCtrl::DrwaWaveShort(CClientDC &dc, DWORD dwDrawBytes, SHORT *pShortData, BOOL bLeftChannel)
{
	CRect rcBK = GetRectByChannel ( bLeftChannel );
	int nCenterY = rcBK.CenterPoint().y;
	int y = nCenterY + (int) ( pShortData[0] * rcBK.Height() / 0xffff );
	dc.MoveTo ( 0, y );
	float fStep = (float)rcBK.Width() / (float)(dwDrawBytes);
	float fLineX = 0;
	for ( DWORD i=1; i<dwDrawBytes; i++ )
	{
		fLineX += fStep;
		y = nCenterY + (int) ( pShortData[i] * rcBK.Height() / 0xffff );
		dc.LineTo ( (int)fLineX, y );

		//TRACE2("DrwaWaveShort X=%f Y=%d\r\n", fLineX, y);
	}
}
Exemplo n.º 20
0
int myframe::OnCreate(LPCREATESTRUCT lp)
{
	if (CWnd::OnCreate (lp) == -1)
        return -1;

	CClientDC dc (this);
	CButton *but;
	but=new CButton;
	but->Create("Show fonts",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(10,10,100,50),this,10);
	fonttitle.Create("",WS_VISIBLE | WS_CHILD,CRect(50,100,500,500),this);

    TEXTMETRIC tm;
    dc.GetTextMetrics (&tm);
    m_cxChar = tm.tmAveCharWidth;
    m_cyChar = tm.tmHeight + tm.tmExternalLeading;
   	
	return 0;
}
Exemplo n.º 21
0
void CRibbonListButton::OnShowPopupMenu ()
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnShowPopupMenu ();

	if (m_sizeMaxText == CSize (0, 0))
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		ASSERT_VALID (pRibbonBar);

		CClientDC dc (pRibbonBar);

		CFont* pOldFont = dc.SelectObject (pRibbonBar->GetFont ());
		ASSERT (pOldFont != NULL);

		int i = 0;

		for (i = 0; i < m_arLabels.GetSize (); i++)
		{
			CSize szText = dc.GetTextExtent (m_arLabels [i]);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx);
			m_sizeMaxText.cy = max (m_sizeMaxText.cy, szText.cy);
		}

		const int cxImage = m_listImages.GetImageSize ().cx;

		for (i = 0; i < m_arSubItems.GetSize (); i++)
		{
			CBCGPBaseRibbonElement* pButton = m_arSubItems [i];
			ASSERT_VALID (pButton);

			CString strText = pButton->GetText ();
			CSize szText = dc.GetTextExtent (strText);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx - cxImage);
		}

		dc.SelectObject (pOldFont);
	}

	CBCGPRibbonPaletteButton::OnShowPopupMenu ();
}
Exemplo n.º 22
0
void CMyStatusBar::OnPaint() 
{
	Default();

    CClientDC cDC (this);
	CPen pen(PS_SOLID, 1, ::GetSysColor (COLOR_3DSHADOW));
	HPEN oldPen = (HPEN)cDC.SelectObject(pen);

    CRect rcItem;

    cDC.SelectObject (::GetStockObject (NULL_BRUSH));

    for ( int i = 0; i < m_nCount; i++ )
    {
        GetItemRect (i, rcItem);
        cDC.Rectangle (rcItem); 
    }
	cDC.SelectObject (oldPen);
}
Exemplo n.º 23
0
//////////////////
// text changed: resize window to fit
//
LRESULT CPopupText::OnSetText(WPARAM wp, LPARAM lp)
{
	UNREFERENCED_PARAMETER (wp);

	CClientDC dc = this;
	CFont* pOldFont = dc.SelectObject(&m_font);
	CRect rc;
	GetWindowRect(&rc);
	int x = (m_nStyle & JUSTIFYRIGHT) ? rc.right : rc.left;
	int y = rc.top;
	dc.DrawText(CString((LPCTSTR)lp), &rc, DT_CALCRECT);
	rc.InflateRect(m_szMargins);
	if (m_nStyle & JUSTIFYRIGHT)
		x -= rc.Width();
	SetWindowPos(NULL,x,y,rc.Width(),rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
	dc.SelectObject (pOldFont);

	return Default();
}
Exemplo n.º 24
0
//*************************************************************************************
void CBCGPKeyMapDlg::SetColumnsWidth ()
{
	CRect rectList;
	m_KeymapList.GetClientRect (rectList);

	CClientDC dc (this);
	CFont* pOldFont = dc.SelectObject (m_KeymapList.GetFont ());
	ASSERT_VALID (pOldFont);

	int nKeyColumWidth = dc.GetTextExtent (CString (_T("Ctrl+Shift+W"))).cx + 10;

	dc.SelectObject (pOldFont);

	int nRestOfWidth = rectList.Width () - nKeyColumWidth - ::GetSystemMetrics (SM_CXHSCROLL);

	m_KeymapList.SetColumnWidth (iColumnCommand, nRestOfWidth / 3);
	m_KeymapList.SetColumnWidth (iColumnKeys, nKeyColumWidth);
	m_KeymapList.SetColumnWidth (iColumnDescr, nRestOfWidth * 2 / 3);
}
Exemplo n.º 25
0
BOOL CDlgCalcDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	//
	// Set the application's icon.
	//
	SetIcon(m_hIcon, TRUE);
	SetIcon(m_hIcon, FALSE);
	
	//
	// Remove the Size and Maximize commands from the system menu.
	//
	CMenu* pMenu = GetSystemMenu (FALSE);
	pMenu->DeleteMenu (SC_SIZE, MF_BYCOMMAND);
	pMenu->DeleteMenu (SC_MAXIMIZE, MF_BYCOMMAND);

	//
	// Initialize m_rect with the coordinates of the control representing
	// the calculator's output window. Then destroy the control.
	//
	CWnd* pWnd = GetDlgItem (IDC_DISPLAYRECT);
	pWnd->GetWindowRect (&m_rect);
	pWnd->DestroyWindow ();
	ScreenToClient (&m_rect);

	//
	// Initialize m_cxChar and m_cyChar with the average character width
	// and height.
	//
    TEXTMETRIC tm;
    CClientDC dc (this);
    dc.GetTextMetrics (&tm);
    m_cxChar = tm.tmAveCharWidth;
    m_cyChar = tm.tmHeight - tm.tmDescent;

	//
	// Initialize the calculator's output window and return.
	//
    DisplayXRegister ();
	return TRUE;
}
Exemplo n.º 26
0
void CaImMenu::MeasureItem (LPMEASUREITEMSTRUCT lpMeasureItemStruct) {
	MENUITEMINFO iInfo;
	GetMenuItemInfo (lpMeasureItemStruct->CtlID, &iInfo);
	CaImMenuItem* pItem = (CaImMenuItem*)lpMeasureItemStruct->itemData;

	CFont fntDef;
	LOGFONT lfDef;
	CClientDC dc (0);
	CFont* pFont = (CFont *)dc.SelectStockObject (ANSI_VAR_FONT);
	if (pItem->CheckStyle (AMIS_DEFAULT)) {
		CFont* pFnt = dc.GetCurrentFont ();
		pFnt->GetLogFont (&lfDef);
		lfDef.lfWeight = FW_BOLD;
		fntDef.CreateFontIndirect (&lfDef);
		dc.SelectObject (&fntDef);
	}

	if (pItem->CheckStyle (AMIS_BAR))
		lpMeasureItemStruct->itemHeight = 4;
	else
		lpMeasureItemStruct->itemHeight = m_dwHeight;
	lpMeasureItemStruct->itemWidth = 25 + 8 + 8 + 2 + dc.GetTextExtent (pItem->GetText ()).cx;

	dc.SelectObject (pFont);
	if (pItem->CheckStyle (AMIS_DEFAULT))
		fntDef.DeleteObject ();
}
Exemplo n.º 27
0
void CSketcherView::MoveElement(CClientDC & aDC, const CPoint & point)
{
	CSize distance = point - m_CursorPos; // Get move distance
	m_CursorPos = point; // Set current point as 1st for
	// next time
	// If there is an element selected, move it
	if(m_pSelected)
	{
		aDC.SetROP2(R2_NOTXORPEN);
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the element to erase it
		m_pSelected-> Move(distance); // Now move the element
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the moved element
	}
}
Exemplo n.º 28
0
void CSquaresView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CView::OnLButtonDown(nFlags, point);

	//
	// Convert click coordinates to MM_LOENGLISH units.
	//
	CClientDC dc (this);
	dc.SetMapMode (MM_LOENGLISH);
	CPoint pos = point;
	dc.DPtoLP (&pos);

	//
	// If a square was clicked, set its color to the current color.
	//
	if (pos.x >= 35 && pos.x <= 315 && pos.y <= -35 && pos.y >= -315) {
		int i = (-pos.y - 35) / 70;
		int j = (pos.x - 35) / 70;
		CSquaresDoc* pDoc = GetDocument ();
		COLORREF clrCurrentColor = pDoc->GetCurrentColor ();
		pDoc->SetSquare (i, j, clrCurrentColor);
	}
}
Exemplo n.º 29
0
void CPacket::draw(CClientDC &dc)
{
	if (visible||active){
		originalPen = dc.SelectObject(&blackPen);
	}else{
		originalPen = dc.SelectObject(&whitePen);
	}
	dc.Rectangle(x1,y1,x2,y2);
	
	dc.MoveTo(x1+1,y1+1);
	dc.LineTo(x2-1,y2-1);
	dc.MoveTo(x1+1,y2-1);
	dc.LineTo(x2-1,y1+1);

	dc.SelectObject(&originalPen);
}
Exemplo n.º 30
-2
//****************************************************************************************
void CBCGPColorButton::RebuildPalette (CPalette* pPal)
{
	if (m_pPalette != NULL)
	{
		delete m_pPalette;
	}

	m_pPalette = new CPalette ();

	// Create palette:
	CClientDC dc (this);

	if (pPal == NULL)
	{
		int nColors = 256;	// Use 256 first entries
		UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
		LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];

		::GetSystemPaletteEntries (dc.GetSafeHdc (), 0, nColors, pLP->palPalEntry);

		pLP->palVersion = 0x300;
		pLP->palNumEntries = (USHORT) nColors;

		m_pPalette->CreatePalette (pLP);

		delete[] pLP;
	}
	else
	{
		ASSERT_VALID (pPal);
		int nColors = pPal->GetEntryCount ();
		UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
		LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];

		pPal->GetPaletteEntries (0, nColors, pLP->palPalEntry);

		pLP->palVersion = 0x300;
		pLP->palNumEntries = (USHORT) nColors;

		m_pPalette->CreatePalette (pLP);

		delete[] pLP;
	}
}