Ejemplo n.º 1
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	CFrameWnd::OnCreate(lpCreateStruct);

	m_toolBar.Create(this);
	m_toolBar.LoadToolBar(IDR_TOOLBAR1);
	m_toolBar.SetBarStyle(m_toolBar.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY);

	static UINT indicators[]=
	{
		ID_SEPARATOR,
		ID_INDICATOR_SPEED,
		ID_INDICATOR_GENERATIONS,
		ID_INDICATOR_CURGENERATION
	};

	m_statusBar.Create(this);
	m_statusBar.SetIndicators(indicators, 4);
	m_statusBar.SetPaneInfo(0,m_statusBar.GetItemID(0),SBPS_STRETCH,0);
	m_statusBar.SetPaneText(1,"Speed: 10", TRUE);
	m_statusBar.SetPaneText(2,"Max Gens: 500", TRUE);
	m_statusBar.SetPaneText(3,"Generation: 0", TRUE);

	CClientDC clientDC(this);
	m_pBitmap=new CBitmap;
	m_pBitmap->CreateCompatibleBitmap(&clientDC,1005,740);
	ClearBitmap();
	DrawGrid();

	return 0;
}
Ejemplo n.º 2
0
void CNTU_OCCView::DrawRectangle(const Standard_Integer  MinX    ,
	const Standard_Integer  MinY    ,
	const Standard_Integer  MaxX ,
	const Standard_Integer  MaxY ,
	const Standard_Boolean  Draw , 
	const LineStyle aLineStyle)
{
	static int m_DrawMode;
	if  (!m_Pen && aLineStyle ==Solid )
	{m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
	else if (!m_Pen && aLineStyle ==Dot )
	{m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0));   m_DrawMode = R2_XORPEN;}
	else if (!m_Pen && aLineStyle == ShortDash)
	{m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0));	m_DrawMode = R2_XORPEN;}
	else if (!m_Pen && aLineStyle == LongDash)
	{m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0));	m_DrawMode = R2_NOTXORPEN;}
	else if (aLineStyle == Default) 
	{ m_Pen = NULL;	m_DrawMode = R2_MERGEPENNOT;}

	CPen* aOldPen = NULL;
	CClientDC clientDC(this);
	if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
	clientDC.SetROP2(m_DrawMode);

	static		Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
	static		Standard_Boolean m_IsVisible;

	if ( m_IsVisible && !Draw) // move or up  : erase at the old position 
	{
		clientDC.MoveTo(StoredMinX,StoredMinY); 
		clientDC.LineTo(StoredMinX,StoredMaxY); 
		clientDC.LineTo(StoredMaxX,StoredMaxY); 
		clientDC.LineTo(StoredMaxX,StoredMinY); 
		clientDC.LineTo(StoredMinX,StoredMinY);
		m_IsVisible = false;
	}

	StoredMinX = Min ( MinX, MaxX );
	StoredMinY = Min ( MinY, MaxY );
	StoredMaxX = Max ( MinX, MaxX );
	StoredMaxY = Max ( MinY, MaxY);

	if (Draw) // move : draw
	{
		clientDC.MoveTo(StoredMinX,StoredMinY); 
		clientDC.LineTo(StoredMinX,StoredMaxY); 
		clientDC.LineTo(StoredMaxX,StoredMaxY); 
		clientDC.LineTo(StoredMaxX,StoredMinY); 
		clientDC.LineTo(StoredMinX,StoredMinY);
		m_IsVisible = true;
	}

	if (m_Pen) 
		clientDC.SelectObject(aOldPen);
}
Ejemplo n.º 3
0
void CFreqDial::drawDial()
{
	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

#if defined(__WXMSW__)
	int major, minor;
	::wxGetOsVersion(&major, &minor);

	wxColour bgColour;
	if (major >= 6)
		bgColour = wxColour(0xF0, 0xF0, 0xF0);		// Windows Vista and newer
	else if (major == 5 && minor >= 1)
		bgColour = wxColour(0xEC, 0xE9, 0xD8);		// Windows XP
	else
		bgColour = wxColour(0xD4, 0xD0, 0xC8);		// Windows 2000 and earlier
#elif defined(__WXGTK__)
	wxColour bgColour(0xF0, 0xF1, 0xF2);
	// wxColour bgColour(0xED, 0xE9, 0xE3);
#elif defined(__WXMAC__)
	wxColour bgColour(0xF0, 0xF0, 0xF0);
#else
#error "Unknown platform"
#endif

	wxBrush brush0(bgColour);
	wxPen pen0(bgColour);

	dc.SetPen(pen0);
	dc.SetBrush(brush0);
	dc.DrawRectangle(0, 0, m_width, m_height);

	int middleX = m_width / 2;
	int middleY = m_height / 2;

	dc.SetBrush(*wxLIGHT_GREY_BRUSH);
	wxPen pen1(*wxBLACK, 2, wxSOLID);
	dc.SetPen(pen1);
	dc.DrawCircle(middleX, middleY, (m_width - 2) / 2);

	int x = m_width / 2 - int(double(m_width / 2 - 25) * ::sin(m_angle * (M_PI / 180.0)) + 0.5);
	int y = m_height / 2 + int(double(m_height / 2 - 25) * ::cos(m_angle * (M_PI / 180.0)) + 0.5);

	dc.SetBrush(*wxBLACK_BRUSH);
	wxPen pen2(*wxWHITE, 2, wxSOLID);
	dc.SetPen(pen2);
	dc.DrawCircle(x, y, 20);

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);
}
Ejemplo n.º 4
0
void	RRotateDialog::RotateDisplay( int iPos )
{
	if ( iPos == m_iPrevPos )
		return;

	// We need to use the RBitmap::Rotate() function, so to do that, convert to
	// Renaissance types.
	CClientDC			clientDC( &m_staticDisplay );
	HDC					hClientDC = clientDC.GetSafeHdc();

	RDcDrawingSurface	drawSurface;
	drawSurface.Initialize( hClientDC, hClientDC );

	R2dTransform transform;

	// Prepare the image on an offscreen DC
	RAutoDrawingSurface	drawSurfaceOffscreen;
	RRealRect				rRealStaticRect(m_rectStaticDisplay);
	BOOLEAN					fPrepared = drawSurfaceOffscreen.Prepare( &drawSurface, transform, rRealStaticRect );
	RDrawingSurface*		pSurface	= ( (fPrepared)? &drawSurfaceOffscreen : &drawSurface );

	// Paint the offscreen DC white
	RColor rColor = RSolidColor( kWhite );
	pSurface->SetFillColor( rColor );
	pSurface->SetPenColor( rColor );
	pSurface->FillRectangle( m_rectStaticDisplay );

	YAngle	flRadiansRotation = ::DegreesToRadians( YFloatType( iPos ) );

	// The rotation leaves a black background, so blit with a mask.  The mask
	// has to be created the same size as the original (not rotated) bitmap
	// size, so create it and then rotate it.
	RBitmapImage		bmpRotated;
	RBitmapImage		bmpMaskRotated;
	RImageLibrary rLibrary;
	rLibrary.Rotate( m_rBitmapImage, bmpRotated, bmpMaskRotated, flRadiansRotation );

	RIntSize				sizeBmpRotated;
	sizeBmpRotated.m_dx = bmpRotated.GetWidthInPixels();
	sizeBmpRotated.m_dy = bmpRotated.GetHeightInPixels();

	RIntRect				rectSource;
	RIntRect				rectDest;
	DeriveSourceAndDestinationRects( sizeBmpRotated, rectSource, rectDest );

	bmpRotated.RenderWithMask( *pSurface, bmpMaskRotated, rectSource, rectDest );

	if ( fPrepared )
		drawSurfaceOffscreen.Release();
	drawSurface.DetachDCs();

	m_iPrevPos = iPos;
}
Ejemplo n.º 5
0
void  CEarSliderCtrl::DrawChannel(CDC *pDC, LPNMCUSTOMDRAW lpcd)
{
    CClientDC clientDC(GetParent());
    CRect crect;
    CRect wrect;
    GetClientRect(crect);
    GetWindowRect(wrect);
    GetParent()->ScreenToClient(wrect);
    if (m_dcBk == NULL)
    {
        m_dcBk = CreateCompatibleDC(clientDC.m_hDC);
        m_bmpBk = CreateCompatibleBitmap(clientDC.m_hDC, crect.Width(), crect.Height());
        m_bmpBkOld = (HBITMAP)::SelectObject(m_dcBk, m_bmpBk);
        ::BitBlt(m_dcBk, 0, 0, crect.Width(), crect.Height(), clientDC.m_hDC, wrect.left, wrect.top, SRCCOPY);
    }

    HDC hSaveHDC;
    HBITMAP hSaveBmp;
    int iWidth = crect.Width();
    int iHeight = crect.Height();
    hSaveHDC = ::CreateCompatibleDC(pDC->m_hDC);
    hSaveBmp = ::CreateCompatibleBitmap(hSaveHDC, iWidth, iHeight);
    HBITMAP hSaveCBmpOld = (HBITMAP)::SelectObject(hSaveHDC, hSaveBmp);

    COLORREF crOldBack = ::SetBkColor(pDC->m_hDC, RGB(0,0,0));
    COLORREF crOldText = ::SetTextColor(pDC->m_hDC, RGB(255,255,255));

    ::BitBlt(hSaveHDC, 0, 0, iWidth, iHeight, pDC->m_hDC, crect.left, crect.top, SRCCOPY);
    ::BitBlt(pDC->m_hDC, 0, 0, iWidth, iHeight, m_dcBk, 0, 0, SRCCOPY);
    ::BitBlt(pDC->m_hDC, 0, 0, iWidth, iHeight, hSaveHDC, 0, 0, SRCAND);
    //restore and clean up

    ::SetBkColor(pDC->m_hDC, crOldBack);
    ::SetTextColor(pDC->m_hDC, crOldText);
    ::SelectObject(hSaveHDC, hSaveCBmpOld);
    ::DeleteObject(hSaveBmp);
    ::DeleteDC(hSaveHDC);

    /*	crect = lpcd->rc;
    	if ((crect.bottom - crect.top) > (crect.right - crect.left))
    		crect.InflateRect(1, 0, 1, 0);
    	else								//is there a better way to know vert from horiz sliders??
    		crect.InflateRect(0, 2, 0, 2);
    	DrawEdge(pDC->m_hDC, &crect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
    	*/

}
Ejemplo n.º 6
0
int COglshapeView::OnCreate(LPCREATESTRUCT lpCreateStruct) {
    if (CView::OnCreate(lpCreateStruct) == -1) {
        return -1;
    }

    // TODO: Add your specialized creation code here

    ///////////////////////////////////////
    ///////////////////////////////////////
    // START CUSTOM CODE
    ///////////////////////////////////////
    ///////////////////////////////////////

    PIXELFORMATDESCRIPTOR pfd = {
        sizeof(PIXELFORMATDESCRIPTOR), // Structure size.
        1,                             // Structure version number.
        PFD_DRAW_TO_WINDOW |           // Property flags.
        PFD_SUPPORT_OPENGL,
        PFD_TYPE_RGBA,
        24,                            // 24-bit color.
        0, 0, 0, 0, 0, 0,              // Not concerned with these.
        0, 0, 0, 0, 0, 0, 0,           // No alpha or accum buffer.
        32,                            // 32-bit depth buffer.
        0, 0,                          // No stencil or aux buffer.
        PFD_MAIN_PLANE,                // Main layer type.
        0,                             // Reserved.
        0, 0, 0                        // Unsupported.
    };

    CClientDC clientDC(this);

    int pixelFormat =
        ChoosePixelFormat(clientDC.m_hDC, &pfd);
    BOOL success =
        SetPixelFormat(clientDC.m_hDC, pixelFormat, &pfd);

    m_hRC = wglCreateContext(clientDC.m_hDC);

    ///////////////////////////////////////
    ///////////////////////////////////////
    // END CUSTOM CODE
    ///////////////////////////////////////
    ///////////////////////////////////////

    return 0;
}
Ejemplo n.º 7
0
BOOL CBlist::OnEraseBkgnd(CDC* pDC)
{
	CClientDC clientDC(GetParent());///得到窗口DC 
    CRect crect;
    CRect wrect;
    GetClientRect(crect);//得到DC绘图大小
    GetWindowRect(wrect);//得到窗口大小
    GetParent()->ScreenToClient(wrect);//转化坐标
    if(m_dcBk.m_hDC==NULL)
	{
			CBitmap m_bmpBk,*m_bmpBkOld;
               m_dcBk.CreateCompatibleDC(&clientDC);//创建兼容DC  
               m_bmpBk.CreateCompatibleBitmap(&clientDC, crect.Width(), crect.Height());//创建兼容位图
               m_bmpBkOld = m_dcBk.SelectObject(&m_bmpBk);///将位图选入DC
               m_dcBk.BitBlt(0, 0, crect.Width(), crect.Height(), &clientDC, wrect.left, wrect.top, SRCCOPY);
			   m_bmpBk.DeleteObject();
			m_bmpBkOld->DeleteObject();
	}
	return true;//CButton::OnEraseBkgnd(pDC);
}
Ejemplo n.º 8
0
/////////////////////////////////////////////////////////////////////////////
// CMySliderControl message handlers
//-------------------------------------------------------------------
//
void CMySliderControl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) {
//
// Description	:	Sent by the slider control to notify the parent window 
//					about drawing operations. This notification is sent in 
//					the form of a WM_NOTIFY message.
// Parameters	:	pNMHDR - a pointer to a NM_CUSTOMDRAW structure.
//					pResult - value depends on the current drawing state.

    LPNMCUSTOMDRAW lpcd = (LPNMCUSTOMDRAW)pNMHDR;
    CDC *pDC = CDC::FromHandle(lpcd->hdc);
    switch (lpcd->dwDrawStage) {
    case CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW ;
        break;
        //return;  
    case CDDS_ITEMPREPAINT:
        if (lpcd->dwItemSpec == TBCD_THUMB) {
            *pResult = CDRF_DODEFAULT;
            break;
        }
        if (lpcd->dwItemSpec == TBCD_CHANNEL) {
            CClientDC clientDC(GetParent());
            CRect crect;
            CRect wrect;
            GetClientRect(crect);
            GetWindowRect(wrect);
            GetParent()->ScreenToClient(wrect);
            if (m_dcBk.m_hDC == NULL) {
                m_dcBk.CreateCompatibleDC(&clientDC);
                m_bmpBk.CreateCompatibleBitmap(&clientDC, crect.Width(), crect.Height());
                m_bmpBkOld = m_dcBk.SelectObject(&m_bmpBk);
                m_dcBk.BitBlt(0, 0, crect.Width(), crect.Height(), &clientDC, wrect.left, wrect.top, SRCCOPY);
            }
            //This bit does the tics marks transparently.
            //create a memory dc to hold a copy of the oldbitmap data that includes the tics,
            //because when we add the background in we will lose the tic marks
            CDC SaveCDC;
            CBitmap SaveCBmp, maskBitmap;
            //set the colours for the monochrome mask bitmap
            COLORREF crOldBack = pDC->SetBkColor(RGB(0,0,0));
            COLORREF crOldText = pDC->SetTextColor(RGB(255,255,255));
            CDC maskDC;
            int iWidth = crect.Width();
            int iHeight = crect.Height();
            SaveCDC.CreateCompatibleDC(pDC);
            SaveCBmp.CreateCompatibleBitmap(&SaveCDC, iWidth, iHeight);
            CBitmap* SaveCBmpOld = (CBitmap *)SaveCDC.SelectObject(SaveCBmp);
            //fill in the memory dc for the mask
            maskDC.CreateCompatibleDC(&SaveCDC);
            //create a monochrome bitmap
            maskBitmap.CreateBitmap(iWidth, iHeight, 1, 1, NULL);
            //select the mask bitmap into the dc
            CBitmap* OldmaskBitmap = maskDC.SelectObject(&maskBitmap);
            //copy the oldbitmap data into the bitmap, this includes the tics.
            SaveCDC.BitBlt(0, 0, iWidth, iHeight, pDC, crect.left, crect.top, SRCCOPY);
            //now copy the background into the slider
            BitBlt(lpcd->hdc, 0, 0, iWidth, iHeight, m_dcBk.m_hDC, 0, 0, SRCCOPY);
            // Blit the mask based on background colour
            maskDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCCOPY);
            // Blit the image using the mask
            pDC->BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT);
            pDC->BitBlt(0, 0, iWidth, iHeight, &maskDC, 0, 0, SRCAND);
            pDC->BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT);
            //restore and clean up
            pDC->SetBkColor(crOldBack);
            pDC->SetTextColor(crOldText);
            DeleteObject(SelectObject(SaveCDC, SaveCBmpOld));
            DeleteDC(SaveCDC);
            DeleteObject(maskDC.SelectObject(OldmaskBitmap));
            DeleteDC(maskDC);
            *pResult = 0;
            break;
        }
    }
}
Ejemplo n.º 9
0
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
{
    if (event.LeftDown())
    {
        DragShape* shape = FindShape(event.GetPosition());
        if (shape)
        {
            // We tentatively start dragging, but wait for
            // mouse movement before dragging properly.

            m_dragMode = TEST_DRAG_START;
            m_dragStartPos = event.GetPosition();
            m_draggedShape = shape;
        }
    }
    else if (event.LeftUp() && m_dragMode != TEST_DRAG_NONE)
    {
        // Finish dragging

        m_dragMode = TEST_DRAG_NONE;

        if (!m_draggedShape || !m_dragImage)
            return;

        m_draggedShape->SetPosition(m_draggedShape->GetPosition()
                                    + event.GetPosition() - m_dragStartPos);

        m_dragImage->Hide();
        m_dragImage->EndDrag();
        delete m_dragImage;
        m_dragImage = NULL;

        wxClientDC dc(this);
        if (m_currentlyHighlighted)
        {
            m_currentlyHighlighted->Draw(dc);
        }
        m_draggedShape->SetShow(true);
        m_draggedShape->Draw(dc);

        m_currentlyHighlighted = (DragShape*) NULL;

        m_draggedShape = (DragShape*) NULL;
    }
    else if (event.Dragging() && m_dragMode != TEST_DRAG_NONE)
    {
        if (m_dragMode == TEST_DRAG_START)
        {
            // We will start dragging if we've moved beyond a couple of pixels

            int tolerance = 2;
            int dx = abs(event.GetPosition().x - m_dragStartPos.x);
            int dy = abs(event.GetPosition().y - m_dragStartPos.y);
            if (dx <= tolerance && dy <= tolerance)
                return;

            // Start the drag.
            m_dragMode = TEST_DRAG_DRAGGING;

            if (m_dragImage)
                delete m_dragImage;

            // Erase the dragged shape from the canvas
            m_draggedShape->SetShow(false);
            wxClientDC dc(this);
            EraseShape(m_draggedShape, dc);
            DrawShapes(dc);

            switch (m_draggedShape->GetDragMethod())
            {
                case SHAPE_DRAG_BITMAP:
                {
                    m_dragImage = new wxDragImage(m_draggedShape->GetBitmap(), wxCursor(wxCURSOR_HAND));
                    break;
                }
                case SHAPE_DRAG_TEXT:
                {
                    m_dragImage = new wxDragImage(wxString(_T("Dragging some test text")), wxCursor(wxCURSOR_HAND));
                    break;
                }
                case SHAPE_DRAG_ICON:
                {
                    m_dragImage = new wxDragImage(wxICON(dragicon), wxCursor(wxCURSOR_HAND));
                    break;
                }
            }

            bool fullScreen = wxGetApp().GetUseScreen();

            // The offset between the top-left of the shape image and the current shape position
            wxPoint beginDragHotSpot = m_dragStartPos - m_draggedShape->GetPosition();

            // Now we do this inside the implementation: always assume
            // coordinates relative to the capture window (client coordinates)

            //if (fullScreen)
            //    beginDragHotSpot -= ClientToScreen(wxPoint(0, 0));

            if (!m_dragImage->BeginDrag(beginDragHotSpot, this, fullScreen))
            {
                delete m_dragImage;
                m_dragImage = (wxDragImage*) NULL;
                m_dragMode = TEST_DRAG_NONE;

            } else
            {
                m_dragImage->Move(event.GetPosition());
                m_dragImage->Show();
            }
        }
        else if (m_dragMode == TEST_DRAG_DRAGGING)
        {
            // We're currently dragging. See if we're over another shape.
            DragShape* onShape = FindShape(event.GetPosition());

            bool mustUnhighlightOld = false;
            bool mustHighlightNew = false;

            if (m_currentlyHighlighted)
            {
                if ((onShape == (DragShape*) NULL) || (m_currentlyHighlighted != onShape))
                    mustUnhighlightOld = true;
            }

            if (onShape && (onShape != m_currentlyHighlighted) && onShape->IsShown())
                mustHighlightNew = true;

            if (mustUnhighlightOld || mustHighlightNew)
                m_dragImage->Hide();

            // Now with the drag image switched off, we can change the window contents.

            if (mustUnhighlightOld)
            {
                wxClientDC clientDC(this);
                m_currentlyHighlighted->Draw(clientDC);
                m_currentlyHighlighted = (DragShape*) NULL;
            }
            if (mustHighlightNew)
            {
                wxClientDC clientDC(this);
                m_currentlyHighlighted = onShape;
                m_currentlyHighlighted->Draw(clientDC, wxINVERT);
            }

            // Move and show the image again
            m_dragImage->Move(event.GetPosition());

            if (mustUnhighlightOld || mustHighlightNew)
                 m_dragImage->Show();
        }
    }
}
Ejemplo n.º 10
0
void CFreqDisplay::setFrequency(const CFrequency& frequency)
{
	wxInt64 hz = frequency.get();

	// Only display to 10 Hz
	if ((m_lastFrequency.get() / 10LL) == (hz / 10LL))
		return;

	clearGraph();

	wxMemoryDC memoryDC;
	memoryDC.SelectObject(*m_bitmap);

	int mhzDigits = m_mhzDigits;
	if (mhzDigits == 0) {
		mhzDigits = 1;
		if (hz >= 10000000000LL)		// 10 GHz
			mhzDigits = 5;
		else if (hz >= 1000000000LL)		// 1000 MHz
			mhzDigits = 4;
		else if (hz >= 100000000LL)		// 100 MHz
			mhzDigits = 3;
		else if (hz >= 10000000LL)		// 10 MHz
			mhzDigits = 2;
	}

	const int bigThickness    = 5;
	const int littleThickness = 4;

	int bigHeight    = m_height - 2 * BORDER_SIZE;
	int littleHeight = 3 * bigHeight / 4;

	int bigWidth    = (m_width - 2 * BORDER_SIZE) / (mhzDigits + 5);
	int littleWidth = 3 * bigWidth / 4;

	int bigY    = BORDER_SIZE;
	int littleY = (bigHeight + BORDER_SIZE) - littleHeight;

	int x = BORDER_SIZE + (mhzDigits + 4) * bigWidth;

	wxInt64 rem = hz / 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= littleWidth;
	rem /= 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, true);
	x   -= bigWidth;

	rem = hz / 1000000LL;

	for (int i = 0; i < mhzDigits; i++) {
		wxInt64 n = rem % 10LL;
		rem /= 10LL;

		if (rem != 0LL || (rem == 0LL && n != 0LL))
			drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, n, false);

		x -= bigWidth;
	}

	memoryDC.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);

	m_lastFrequency = frequency;
}
Ejemplo n.º 11
0
void	RAlignDialog::UpdateDisplay()
{
	CRect rcCircle;
	CRect	rcRectangle;

	DeriveCircleRect( rcCircle );
	DeriveRectangleRect( rcRectangle );

	CBitmap*		pOldBitmap	= NULL;
	CPen*			pOldPen		= NULL;
	CBrush*		pOldBrush	= NULL;
	CDC			offscreenDC;

	try
	{
		CClientDC	clientDC( &m_staticDisplay );

		CBitmap		offscreenBitmap;
		offscreenBitmap.CreateCompatibleBitmap( &clientDC, m_sizeStatic.cx, m_sizeStatic.cy );

		offscreenDC.CreateCompatibleDC( &clientDC );
		pOldBitmap = ( CBitmap* )offscreenDC.SelectObject( &offscreenBitmap );

		// Paint the offscreen bitmap white
		offscreenDC.PatBlt( 0, 0, m_sizeStatic.cx, m_sizeStatic.cy, WHITENESS );

		// The shapes will all be outlined in black
		pOldPen		= offscreenDC.SelectObject( &m_penBlack );

		// Draw a blue rectangle (always on the bottom if there's overlap)
		pOldBrush	= offscreenDC.SelectObject( &m_brushGreenBlue );
		offscreenDC.Rectangle( rcRectangle );

		// Draw a red circle (always in the middle if there's overlap)
		offscreenDC.SelectObject( &m_brushRedBlue );
		offscreenDC.Rectangle( rcCircle );

		// Draw a left, right or center horizontal alignment line
		switch (m_eAlignHorz)
		{
		case RAlignSelectionAction::kAlignLeft:
			offscreenDC.MoveTo(rcRectangle.TopLeft().x, m_rcDisplay.top);
			offscreenDC.LineTo(rcRectangle.TopLeft().x, m_rcDisplay.bottom);
			break;
		case RAlignSelectionAction::kAlignRight:
			offscreenDC.MoveTo(rcRectangle.BottomRight().x, m_rcDisplay.top);
			offscreenDC.LineTo(rcRectangle.BottomRight().x, m_rcDisplay.bottom);
			break;
		case RAlignSelectionAction::kAlignCenterHorz:
			offscreenDC.MoveTo(rcRectangle.TopLeft().x + (rcRectangle.Width() / 2), m_rcDisplay.top);
			offscreenDC.LineTo(rcRectangle.TopLeft().x + (rcRectangle.Width() / 2), m_rcDisplay.bottom);
			break;
		case RAlignSelectionAction::kAlignNoneHorz:
		default:
			break;
		}

		// Draw a top, bottom or center vertical alignment line
		switch (m_eAlignVert)
		{
		case RAlignSelectionAction::kAlignTop:
			offscreenDC.MoveTo(m_rcDisplay.left, rcRectangle.TopLeft().y);
			offscreenDC.LineTo(m_rcDisplay.right, rcRectangle.TopLeft().y);
			break;
		case RAlignSelectionAction::kAlignBottom:
			offscreenDC.MoveTo(m_rcDisplay.left, rcRectangle.BottomRight().y);
			offscreenDC.LineTo(m_rcDisplay.right, rcRectangle.BottomRight().y);
			break;
		case RAlignSelectionAction::kAlignCenterVert:
			offscreenDC.MoveTo(m_rcDisplay.left, rcRectangle.TopLeft().y + (rcRectangle.Height() / 2));
			offscreenDC.LineTo(m_rcDisplay.right, rcRectangle.TopLeft().y + (rcRectangle.Height() / 2));
			break;
		case RAlignSelectionAction::kAlignNoneVert:
		default:
			break;
		}

		// Blit the offscreen bitmap onto the static control
		clientDC.SetStretchBltMode( COLORONCOLOR );
		clientDC.StretchBlt(
			0,
			0,
			m_sizeStatic.cx,
			m_sizeStatic.cy,
			&offscreenDC,
			0,
			0,
			m_sizeStatic.cx,
			m_sizeStatic.cy,
			SRCCOPY
		);

		offscreenDC.SelectObject( pOldBitmap );
		offscreenDC.SelectObject( pOldPen );
		offscreenDC.SelectObject( pOldBrush );
	}
	catch( CResourceException* e )
	{
		if ( pOldBitmap )
			offscreenDC.SelectObject( pOldBitmap );

		if ( pOldPen )
			offscreenDC.SelectObject( pOldPen );

		if ( pOldBrush )
			offscreenDC.SelectObject( pOldBrush );

		e->Delete();
	}
}
Ejemplo n.º 12
0
void CSMeter::setLevel(float level)
{
	if (level < 0.0F)
		level = 0.0F;

	if (level == m_lastLevel)
		return;

	wxMemoryDC dcBackground;
	if (m_txOn)
		dcBackground.SelectObject(*m_txBackground);
	else
		dcBackground.SelectObject(*m_rxBackground);

	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

	dc.Blit(0, 0, m_width, m_height, &dcBackground, 0, 0);
	dcBackground.SelectObject(wxNullBitmap);

	// Draw the pointer
	dc.SetBrush(*wxWHITE_BRUSH);
	dc.SetPen(*wxWHITE_PEN);

	int centreX = SMETER_WIDTH / 2;
	int centreY = SMETER_WIDTH / 2 + 20;

	int endX;
	int endY;

	if (m_txOn) {
		if (level <= 0.625F) {
			double angle = (M_PI / 180.0) * double(45.0F - level * 72.0F);;
			endX = centreX - int((SMETER_WIDTH + 15) * ::sin(angle) / 2.0 + 0.5);
			endY = centreY - int((SMETER_WIDTH + 15) * ::cos(angle) / 2.0 + 0.5);
		} else {
			if (level > 1.25F)
				level = 1.25F;

			double angle = (M_PI / 180.0) * double(level - 0.625F) * 72.0;
			endX = centreX + int((SMETER_WIDTH + 15) * ::sin(angle) / 2.0 + 0.5);
			endY = centreY - int((SMETER_WIDTH + 15) * ::cos(angle) / 2.0 + 0.5);
		}
	} else {
		if (level <= 54.0F) {	// S0 to S9
			double angle = (M_PI / 180.0) * double(45.0F - level * 0.833333F);
			endX = centreX - int((SMETER_WIDTH + 15) * ::sin(angle) / 2.0 + 0.5);
			endY = centreY - int((SMETER_WIDTH + 15) * ::cos(angle) / 2.0 + 0.5);
		} else {			// dB over S9
			if (level > 94.0F)	// 40dB over S9
				level = 94.0F;

			double angle = (M_PI / 180.0) * double(level - 54.0F) * 1.125;
			endX = centreX + int((SMETER_WIDTH + 15) * ::sin(angle) / 2.0 + 0.5);
			endY = centreY - int((SMETER_WIDTH + 15) * ::cos(angle) / 2.0 + 0.5);
		}
	}

	dc.DrawLine(centreX, centreY, endX, endY);

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);

	m_lastLevel = level;
}
Ejemplo n.º 13
0
//***********************************************************************************************************
void CBCGPBaseVisualCtrl::OnDrawLayeredPopup()
{
	CRect rect;
	GetClientRect (rect);

	if (rect.Width () == 0 || rect.Height () == 0)
	{
		return;
	}

	CPoint point (0, 0);
	CSize size (rect.Size ());

	LPBYTE pBits = NULL;
	HBITMAP hBitmap = CBCGPDrawManager::CreateBitmap_32 (size, (void**)&pBits);
	if (hBitmap == NULL)
	{
		return;
	}

	CBitmap bitmap;
	bitmap.Attach (hBitmap);

	CClientDC clientDC(this);
	CDC dc;
	dc.CreateCompatibleDC (&clientDC);

	CBitmap* pBitmapOld = (CBitmap*)dc.SelectObject (&bitmap);

	if (m_pGM == NULL)
	{
		CBCGPGraphicsManagerParams params;
		params.bAlphaModePremultiplied = TRUE;

		m_pGM = CBCGPGraphicsManager::CreateInstance(CBCGPGraphicsManager::BCGP_GRAPHICS_MANAGER_DEFAULT, TRUE, &params);
	
		if (m_pGM == NULL)
		{
			return;
		}

		m_pGM->EnableTransparentGradient();
	}

	SetRect(rect);

	m_pGM->BindDC(&dc, rect);

	if (!m_pGM->BeginDraw())
	{
		return;
	}

	OnDraw(m_pGM, rect);

	SetDirty(FALSE);

	m_pGM->EndDraw();

	m_pGM->BindDC(NULL);

	BLENDFUNCTION bf;
	bf.BlendOp             = AC_SRC_OVER;
	bf.BlendFlags          = 0;
	bf.SourceConstantAlpha = (BYTE)bcg_clamp(m_nPopupAlpha, 0, 255);
	bf.AlphaFormat         = LWA_COLORKEY;

#ifndef _BCGSUITE_
	globalData.UpdateLayeredWindow (GetSafeHwnd (), NULL, 0, &size, dc.GetSafeHdc (), 
		&point, 0, &bf, 0x02);
#else
	UpdateLayeredWindow (NULL, 0, &size, &dc, &point, 0, &bf, 0x02);
#endif

	dc.SelectObject (pBitmapOld);
}
Ejemplo n.º 14
0
void CVolumeDial::drawDial()
{
	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

#if defined(__WXMSW__)
	int major, minor;
	::wxGetOsVersion(&major, &minor);

	wxColour bgColour;
	if (major >= 6)
		bgColour = wxColour(0xF0, 0xF0, 0xF0);		// Windows Vista and newer
	else if (major == 5 && minor >= 1)
		bgColour = wxColour(0xEC, 0xE9, 0xD8);		// Windows XP
	else
		bgColour = wxColour(0xD4, 0xD0, 0xC8);		// Windows 2000 and earlier
#elif defined(__WXGTK__)
	wxColour bgColour(0xF0, 0xF1, 0xF2);
	// wxColour bgColour(0xED, 0xE9, 0xE3);
#elif defined(__WXMAC__)
	wxColour bgColour(0xE8, 0xE8, 0xE8);
#else
#error "Unknown platform"
#endif

	wxBrush brush0(bgColour);
	wxPen pen0(bgColour);

	dc.SetPen(pen0);
	dc.SetBrush(brush0);
	dc.DrawRectangle(0, 0, m_width, m_height);

	if (IsEnabled()) {
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		dc.SetPen(wxPen(*wxBLACK, 2, wxSOLID));
	} else {
		dc.SetBrush(brush0);
		dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID));
	}

	dc.DrawEllipse(1, 1, m_width - 2, m_height - 2);

	double incr = 270.0 / double(m_max - m_min); 

	double angle = (double(m_value - m_min) * incr + 45.0) * (M_PI / 180.0);

	double xFrac = ::sin(angle);
	double yFrac = ::cos(angle);

	int startX = m_width / 2 - int(double(m_width / 2 - 10) * xFrac + 0.5);
	int startY = m_height / 2 + int(double(m_height / 2 - 10) * yFrac + 0.5);

	int endX = m_width / 2 - int(double(m_width / 2 - 20) * xFrac + 0.5);
	int endY = m_height / 2 + int(double(m_height / 2 - 20) * yFrac + 0.5);

	if (IsEnabled())
		dc.SetPen(wxPen(*wxBLACK, 5, wxSOLID));
	else
		dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID));

	dc.DrawLine(startX, startY, endX, endY);	

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);
}