void QnSkinDialog::DrawBorder(CDC* pDC, CRect rcDest, CRect rcSrc, BOOL bActive) { CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap* bitmap = memDC.SelectObject(bActive?m_pThemeDialog->m_pBmpActiveBorder : m_pThemeDialog->m_pBmpInActiveBorder); if (bitmap == 0) return; // left CRect rc1(0, m_pThemeDialog->m_nToTop, m_pThemeDialog->m_nToLeft, rcDest.Height()-m_pThemeDialog->m_nToBottom); CRect rc2(0, m_pThemeDialog->m_nToTop, m_pThemeDialog->m_nToLeft, rcSrc.Height()-m_pThemeDialog->m_nToBottom); StretchDraw(pDC, &memDC, rc1, rc2); //right rc1 = CRect(rcDest.right-m_pThemeDialog->m_nToRight, m_pThemeDialog->m_nToTop, rcDest.right, rcDest.bottom-m_pThemeDialog->m_nToBottom); rc2 = CRect(rcSrc.right-m_pThemeDialog->m_nToRight, m_pThemeDialog->m_nToTop, rcSrc.right, rcSrc.bottom-m_pThemeDialog->m_nToBottom); StretchDraw(pDC, &memDC, rc1, rc2); //bottom rc1 = CRect(m_pThemeDialog->m_nBottomLeft, rcDest.Height()-m_pThemeDialog->m_nToBottom, rcDest.Width()-m_pThemeDialog->m_nBottomRight, rcDest.Height()); rc2 = CRect(m_pThemeDialog->m_nBottomLeft, rcSrc.Height()-m_pThemeDialog->m_nToBottom, rcSrc.Width()-m_pThemeDialog->m_nBottomRight, rcSrc.Height()); StretchDraw(pDC, &memDC, rc1, rc2); //bottomLeft pDC->BitBlt(0, rcDest.Height()-m_pThemeDialog->m_nToBottom, m_pThemeDialog->m_nBottomLeft, m_pThemeDialog->m_nToBottom, &memDC, 0, rcSrc.Height()-m_pThemeDialog->m_nToBottom, SRCCOPY); //bottomRight pDC->BitBlt(rcDest.right-m_pThemeDialog->m_nBottomRight, rcDest.Height()-m_pThemeDialog->m_nToBottom, m_pThemeDialog->m_nBottomRight, m_pThemeDialog->m_nToBottom, &memDC, rcSrc.right-m_pThemeDialog->m_nBottomRight, rcSrc.Height()-m_pThemeDialog->m_nToBottom, SRCCOPY); memDC.SelectObject(bitmap); memDC.DeleteDC(); }
void QnSkinDialog::DrawCaption(CDC* pDC, CRect rcDest, CRect rcSrc, BOOL bActive) { // 画背景 CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = memDC.SelectObject(bActive ? m_pThemeDialog->m_pBmpActiveBorder : m_pThemeDialog->m_pBmpInActiveBorder); if (pOldBitmap == NULL) return; //topLeft pDC->BitBlt(0, 0, m_pThemeDialog->m_nTopLeft, m_pThemeDialog->m_nToTop, &memDC, 0, 0, SRCCOPY); //top CRect rc1(m_pThemeDialog->m_nTopLeft, 0, rcDest.Width()-m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop); CRect rc2(m_pThemeDialog->m_nTopLeft, 0, rcSrc.Width()-m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop); StretchDraw(pDC, &memDC, rc1, rc2); //topRight pDC->BitBlt(rcDest.right-m_pThemeDialog->m_nTopRight, 0, m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop, &memDC, rcSrc.right-m_pThemeDialog->m_nTopRight, 0, SRCCOPY); memDC.SelectObject(pOldBitmap); memDC.DeleteDC(); // 画其他 Graphics graph(pDC->m_hDC); // 画图标 if (m_pIconImage) { if (m_rtIconImage.Width() <= 0) { m_rtIconImage.left = 0; m_rtIconImage.right = m_pIconImage->GetWidth(); } if (m_rtIconImage.Height() <= 0) { m_rtIconImage.top = 0; m_rtIconImage.bottom = m_pIconImage->GetHeight(); } int dcy = m_rtIconImage.Height()>=24?4:(24-m_rtIconImage.Height())/2+4; graph.DrawImage(m_pIconImage, RectF(m_pThemeDialog->m_nToLeft, dcy, m_rtIconImage.Width(), m_rtIconImage.Height()), m_rtIconImage.left, m_rtIconImage.top, m_rtIconImage.Width(), m_rtIconImage.Height(), UnitPixel); } // 写标题 if (_tcslen(m_strTitle)) { // CString str; // GetWindowText( str ); LOGFONT lf; GetFont()->GetLogFont(&lf); lf.lfWeight = m_bTitleBold?FW_BOLD:FW_NORMAL; lf.lfHeight = 12; CFont boldFont; boldFont.CreateFontIndirect(&lf); CFont *pOldFont = pDC->SelectObject(&boldFont); pDC->SetTextColor(m_clTitle); // RGB(158,11,11) // RGB(0,70,213) pDC->SetBkMode(TRANSPARENT); CRect rText = rcDest; rText.right -= m_pThemeDialog->m_nToRight; if (m_ptTitle.x < 0 || m_ptTitle.y < 0) { rText.top += 4; rText.left += m_pThemeDialog->m_nToLeft+m_rtIconImage.Width()+2; } else { rText.top = m_ptTitle.y; rText.left = m_ptTitle.x; } pDC->DrawText( m_strTitle, rText, DT_SINGLELINE | DT_LEFT | DT_VCENTER |DT_END_ELLIPSIS); pDC->SelectObject(pOldFont); } //画最小与最大与关闭按钮 DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE); if (dwStyle & WS_SYSMENU) { UINT nHitTest = 0; UINT nButtonState = 0; if (m_nDownHitTest) { if (m_nDownHitTest == m_nMoveHitTest) { nHitTest = m_nDownHitTest; nButtonState = 1; } } else if (m_nMoveHitTest) { nHitTest = m_nMoveHitTest; nButtonState = 2; } Image* pObjImage; CRect rc; GetCaptionButtonRect(rc, SC_CLOSE); pObjImage = m_pThemeDialog->m_pImageCloseBtn; if (nHitTest == HTCLOSE) { graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel); } else { graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 0, 0, rc.Width(), rc.Height(), UnitPixel); } if ( dwStyle & WS_MAXIMIZEBOX ) { if (IsZoomed()) pObjImage = m_pThemeDialog->m_pImageRestoreBtn; else pObjImage = m_pThemeDialog->m_pImageMaxBtn; GetCaptionButtonRect(rc, SC_MAXIMIZE); if (nHitTest == HTMAXBUTTON) graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel); else graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 0, 0, rc.Width(), rc.Height(), UnitPixel); } if ( dwStyle & WS_MINIMIZEBOX ) { pObjImage = m_pThemeDialog->m_pImageMinBtn; GetCaptionButtonRect(rc, SC_MINIMIZE); if (nHitTest == HTMINBUTTON) graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel); else graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 0, 0, rc.Width(), rc.Height(), UnitPixel); } } graph.ReleaseHDC(pDC->m_hDC); }
void CFrameWnd::OnPaint( wxPaintEvent& x_wxPe ) {_STT(); wxPaintDC dc( this ); wxSize sizeClient = GetClientSize(); wxRect rect; rect.x = 0; rect.y = 0; rect.width = sizeClient.GetWidth(); rect.height = sizeClient.GetHeight(); if ( !m_cCapture.IsOpen() || !m_cCapture.WaitForFrame( 3000 ) || !m_cCapture.GetBuffer() ) { dc.SetBrush( wxBrush( wxColor( 255, 0, 0 ) ) ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); return; } // end if // dc.SetBrush( wxBrush( wxColor( 0, 255, 0 ) ) ); // dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); wxImage imgMem( m_cCapture.GetWidth(), m_cCapture.GetHeight(), (unsigned char*)m_cCapture.GetBuffer(), true ); // Go ahead and release the video buffer m_cCapture.ReleaseFrame(); StretchDraw( dc, imgMem, rect ); /* wxBitmap bmMem( imgMem ); // Create a memory DC wxMemoryDC dcMem; dcMem.SelectObject( bmMem ); dc.Blit( 0, 0, dcMem.GetSize().GetWidth(), dcMem.GetSize().GetHeight(), &dcMem, 0, 0 ); / * // Attempt to open the device int dev = open( "/dev/video0" / *oexStrToMbPtr( oex::CStr().Fmt( oexT( "/dev/video%d" ), 0 ).Ptr() ) * /, O_RDONLY ); if ( -1 == dev ) { dc.SetBrush( wxBrush( wxColor( 255, 255, 0 ) ) ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); return; } // end if close( dev ); * / / * video_capability vc; oexZeroMemory( &vc, sizeof( vc ) ); if( -1 == ioctl( dev, VIDIOCGCAP, &vc ) ) { dc.SetBrush( wxBrush( wxColor( 255, 0, 0 ) ) ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); return; } // end if // Video buffer video_buffer vb; oexZeroMemory( &vb, sizeof( vb ) ); if( -1 == ioctl( dev, VIDIOCGMBUF, &vb ) ) { dc.SetBrush( wxBrush( wxColor( 255, 0, 255 ) ) ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); return; } // end if // char vbuf[ 320 * 240 * 3 ]; // read( video_window vw; oexZeroMemory( &vw, sizeof( vw ) ); vw.width = 320; vw.height = 240; vw. if( -1 == ioctl( dev, VIDIOCSWIN, &vw ) ) { dc.SetBrush( wxBrush( wxColor( 255, 0, 255 ) ) ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); return; } // end if * / // struct video_picture vid_pic; // struct video_window vid_win; // struct video_mbuf vid_buf; // struct video_mmap vid_map; / * wxImage imgMem( 100, 100, (unsigned char*)pData, true ); wxBitmap bmMem( imgMem ); // Create a memory DC wxMemoryDC dcMem; dcMem.SelectObject( bmMem ); dc.Blit( 0, 0, 100, 100, &dcMem, 0, 0 ); */ // StretchDraw( dc, m_cWxImg, rect ); }