Ejemplo n.º 1
0
std::string
AddonManager::scan_for_info(const std::string& archive_os_path) const
{
  std::unique_ptr<char*, decltype(&PHYSFS_freeList)>
    rc2(PHYSFS_enumerateFiles("/"),
        PHYSFS_freeList);
  for(char** j = rc2.get(); *j != 0; ++j)
  {
    if (has_suffix(*j, ".nfo"))
    {
      std::string nfo_filename = FileSystem::join("/", *j);

      // make sure it's in the current archive_os_path
      const char* realdir = PHYSFS_getRealDir(nfo_filename.c_str());
      if (!realdir)
      {
        log_warning << "PHYSFS_getRealDir() failed for " << nfo_filename << ": " << PHYSFS_getLastError() << std::endl;
      }
      else
      {
        if (realdir == archive_os_path)
        {
          return nfo_filename;
        }
      }
    }
  }

  return std::string();
}
Ejemplo n.º 2
0
//Invalidate(); 
void CProgStatusBar::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CDialogBar::OnPaint()
	CDC memDC;  
	memDC.CreateCompatibleDC(&dc);  
	CRect rc;  
	GetClientRect(&rc);  

	BITMAP bm1;
	m_SignalBmpArray[m_nSigIndex].GetObject(sizeof(BITMAP),&bm1);

	int width = bm1.bmWidth; //图片的宽度(逻辑单位)。 
	int height=	bm1.bmHeight; ////图片的高度(逻辑单位)。

	HBITMAP hOldbmp = (HBITMAP)memDC.SelectObject(m_SignalBmpArray[m_nSigIndex]); 
	dc.BitBlt(900-50, 13, rc.Width(), rc.Height(), &memDC, 0, 0, SRCCOPY);  
	CRect rc1(900-50, 13, rc.Width(), rc.Height());
	m_rectSignal = rc1;
	memDC.SelectObject(hOldbmp);  
//	memDC.DeleteDC();  
	if (theApp.m_bIsHaveLocked)
	{
		HBITMAP hlockbmp = (HBITMAP)memDC.SelectObject(m_LockBmpArray[m_nLockIndex]); 
		dc.BitBlt(900-50-30, 10, rc.Width(), rc.Height(), &memDC, 0, 0, SRCCOPY);  
		CRect rc2(900-50-30, 10, rc.Width(), rc.Height());
		m_rectLock = rc2;
		memDC.SelectObject(hlockbmp);  
	}
	memDC.DeleteDC();  
}
Ejemplo n.º 3
0
main(int argc, char *argv[]) {
    node gnd;
    node n1("n1");
    node n2("n2");
    node n3("n3");
    node n4("n4");
    node n5("n5");
    node n6("n6");

    vdc vcc("vcc", n6, gnd, 5.0);
    vpulse vin("vin", n1, gnd, 0, 5, 2e-9, 2e-9, 2e-9, 10e-9);
    r rb1("rb1", n1, n2, 10e3);
    r rc1("rc1", n6, n3, 1e3);
    qnd q1("q1", n3, n2, gnd);
    r rb2("rb2", n3, n4, 10e3);
    qnd q2("q2", n5, n4, gnd);
    r rc2("rc2", n6, n5, 1e3);

    op::monitor = 1;
    op();

    plot::output = *argv;
    plot::add("n1", "n3", "n5");

    tran::tsmin = 1.0e-30;
    tran::monitor = 1;
    tran(0.2e-9, 20.0e-9);
}
Ejemplo n.º 4
0
void SItemPanel::OnRedraw(const CRect &rc)
{
    if(m_pFrmHost->IsUpdateLocked()) return;

    CRect rcItem=GetItemRect();
    if(!rcItem.IsRectNull() && m_pFrmHost->IsVisible(TRUE))
    {
        if(m_pItemContainer->IsItemRedrawDelay())
        {
            CRect rc2(rc);
            rc2.OffsetRect(rcItem.TopLeft());
            rc2.IntersectRect(rc2,rcItem);
            CRect rcHostClient = m_pFrmHost->GetClientRect();
            rc2.IntersectRect(rc2,rcHostClient);
            m_pFrmHost->InvalidateRect(rc2);
        }else
        {
            IRenderTarget *pRT=OnGetRenderTarget(rc,OLEDC_PAINTBKGND);
            CAutoRefPtr<IRegion> rgn;
            GETRENDERFACTORY->CreateRegion(&rgn);
            rgn->CombineRect(&rc,RGN_COPY);
            RedrawRegion(pRT,rgn);
            OnReleaseRenderTarget(pRT,rc,OLEDC_PAINTBKGND);
        }
    }
}
Ejemplo n.º 5
0
TEST(RcTest, All) {
    {
        w_rc_t rc;
        rc = _testing();
    }

    std::cout << "Expect another 'error not checked' message" << std::endl;
    _testing_ok();
    EXPECT_FALSE(_testing_ok().is_error()) << "FAILURE: This should never happen!";

    std::cout << "Expect 3 forms of the string of errors" << std::endl;
    {
        w_rc_t rc = _testing();
        std::cout << std::endl << rc << std::endl;
    }

    {
        w_rc_t rc = _testing1();
        EXPECT_TRUE(rc.is_error());
        std::cout << " ORIG:" << rc << std::endl;

        w_rc_t rc2(rc);
        std::cout << " COPY CONSTRUCTOR: " << rc2 << std::endl;

        rc2 = rc;
        EXPECT_TRUE(rc2.is_error());
        std::cout << " COPY OPERATOR: " << rc2 << std::endl;
    }
}
Ejemplo n.º 6
0
void InitCharTables(){
	ResStrCollection rc(*ResFile, 4);

	int sz;
	for(int i = 0; i < NumberChars; i++){
		BaseChDataType *p = (BaseChDataType *)rc.Next(sz);
		memcpy(&SortedCharNames[i], p, sz);
	};

	for(i = 0; i <= HighCharacterCode; i++){rc.NextC(CharacterNameSet[i].Name);};

	rc.NextC(UpperCharList);
	rc.NextC(LowerCharList);

/*RES OLD DTA 3
KEYBOARD SCREEN FILE PRINTER INTERNAL MODE
*/
	ResStrCollection rc2(*ResFile, 3);
	rc2.NextC(FILEText); // ignore first one: KEYBOARDText
	rc2.NextC(FILEText); // ditto 2nd one: SCREENText
	rc2.NextC(FILEText);
	rc2.NextC(INTERNALText); // ignore: PRINTER
	rc2.NextC(INTERNALText);
	rc2.NextC(MODEText);
};
Ejemplo n.º 7
0
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();
}
Ejemplo n.º 8
0
void CQTTDemoView::InitSillyObjects(void)
{
	CString s(_T("Test"));
	CString sFont(_T("Georgia"));
	FontFamily ff(sFont.AllocSysString());
	StringFormat sf;
	Point p(200, 200);

	MakeStarPath(m_Paths[PATH_MULTI_STAR], 7, 40, 120);
	//Matrix mat;
	m_Matrixs[PATH_MULTI_STAR] = new Matrix();
	//mat.Translate(700, 150);
	m_Matrixs[PATH_MULTI_STAR]->Translate(700, 150);
	m_Paths[PATH_MULTI_STAR].Transform(m_Matrixs[PATH_MULTI_STAR]);

	MakeSmiley(m_Paths[PATH_SMILE]);	
	//mat.Reset();
	m_Matrixs[PATH_SMILE] = new Matrix();
	//mat.Translate(400, 300);
	m_Matrixs[PATH_SMILE]->Translate(400, 300);
	//mat.Scale(0.2f, 0.2f);
	m_Matrixs[PATH_SMILE]->Scale(0.2f, 0.2f);
	//mat.Rotate(- 15.0f);
	m_Matrixs[PATH_SMILE]->Rotate(- 15.0f);
	m_Paths[PATH_SMILE].Transform(m_Matrixs[PATH_SMILE]);

	Rect rc2(120, 80, 160, 65);
	m_Matrixs[PATH_RECTANGLE] = new Matrix();
	m_Paths[PATH_RECTANGLE].Reset();
	m_Paths[PATH_RECTANGLE].AddRectangle(rc2);

	m_Matrixs[PATH_TEXT] = new Matrix();
	m_Paths[PATH_TEXT].Reset();
	m_Paths[PATH_TEXT].AddString(s.AllocSysString(), s.GetLength(), &ff, FontStyleBold, 100.0F, p, & sf);

	Rect rc4(420, -240, 120, 265);	
	m_Paths[PATH_ELLIPSE].Reset();	
	m_Paths[PATH_ELLIPSE].AddEllipse(rc4);	
	//mat.Reset();
	m_Matrixs[PATH_ELLIPSE] = new Matrix();
	//mat.Rotate(30.0f);
	m_Matrixs[PATH_ELLIPSE]->Rotate(30.0f);
	m_Paths[PATH_ELLIPSE].Transform(m_Matrixs[PATH_ELLIPSE]);

	MakeStarPath(m_Paths[PATH_STAR], 5, 12, 60);
	//mat.Reset();
	m_Matrixs[PATH_STAR] = new Matrix();
	//mat.Translate(224, 320);
	m_Matrixs[PATH_STAR]->Translate(224, 320);
	m_Paths[PATH_STAR].Transform(m_Matrixs[PATH_STAR]);

	MakeImagePath(m_Paths[PATH_IMAGE]);
	m_Matrixs[PATH_IMAGE] = new Matrix();	
	m_Matrixs[PATH_IMAGE]->Translate(0,0);
	//m_Matrixs[PATH_IMAGE]->Translate(106/2,76/2);
	//m_Matrixs[PATH_IMAGE]->Translate(34,59);
}
Ejemplo n.º 9
0
void real_smartptr() {
	{
		std::shared_ptr<int> rc0;
	}
	
	std::shared_ptr<int> rc1(new int(10));
	std::shared_ptr<int> rc2(rc1);
	rc1.reset();
	std::cout << rc1.use_count() << std::endl;
}
Ejemplo n.º 10
0
void CGpApp::DrawEnergyBar()
{
	LC_RECTF	rc1(0,0,  (FLOAT)INT(1.5F * ENERGYBARmax), 16);
	LC_RECTF	rc2(0,0,  (FLOAT)INT(1.5F * ENERGYBARmax * m_ShieldEnergy / SHIELDENERGYmax), 16);
	LCXVECTOR2	vcTrn(0, m_nScnH - 20.0F);
	LCXCOLOR	col2(1,0,0,0.7F);
	LCXCOLOR	col1(0,0,1,0.7F);

	m_pSpt->DrawEx(NULL, &rc1, &vcTrn, NULL, NULL, 0, &col1);
	m_pSpt->Draw(NULL, &rc2, &vcTrn, &col2);
}
Ejemplo n.º 11
0
void CProgressStatusBar::DrawItem(LPDRAWITEMSTRUCT pDIS)
{
    //TRACE("CProgressStatusBar::DrawItem: %d percent!\n", m_Percent);
    CDC dc;
    dc.Attach(pDIS->hDC);
    CRect rc(pDIS->rcItem);
    CRect rc2(rc);
    rc.right = rc.left + MulDiv(rc.Width(), m_Percent, 100);
    rc2.left = rc.right;
    dc.FillSolidRect(&rc, GetSysColor(COLOR_BTNTEXT));
    dc.FillSolidRect(&rc2, GetSysColor(COLOR_BTNFACE));
    dc.Detach();
}
Ejemplo n.º 12
0
FlowTextManager::FlowTextManager()
{
	xs::Rect rc1 (0,-200,100,-150);
	mFlowArea[FlowArea_Top].create(rc1, 0.03, 0.7,true,true,true);

	xs::Rect rc2 (-50,0,100,200);
	mFlowArea[FlowArea_Bottom].create(rc2, 0.05, 0.8);

	xs::Rect rc3 (100,100,400,200);
	mFlowArea[FlowArea_Right].create(rc3, 0.05, 1,true,false,false,false);

	//xs::Rect rc4 = {-100,-220,100,-20};
	//mFlowArea[FlowArea_Mouse].create(rc4, 0.0005, 0.8, false);
}
Ejemplo n.º 13
0
void CSimplePanelDlg::InitPannel()
{
	CDC* pDC = GetDC();

	char curDir[160] = {0};
	WCHAR wcurDir[160] = {0};

	GetCurrentDirectory(160, curDir);
	ZeroMemory(wcurDir, sizeof(wcurDir));

	CString strImPath = curDir;
	strImPath += _T("\\Res\\linepannel_simple.png");

	MultiByteToWideChar(CP_ACP, 0, (char*)(LPCTSTR)strImPath, strImPath.GetLength(), wcurDir, 160);

	m_pImLineBK = new Gdiplus::Image(wcurDir);

	int nHeight = m_pImLineBK->GetHeight();
	int nWidth = m_pImLineBK->GetWidth();


	CRect rc1(0, 46, 539, nHeight + 46);
	CEsayMemDC* pMemDC =  new CEsayMemDC(*pDC, rc1);
	m_vecMemDC.push_back(pMemDC);

	CRect rc2(542, 46, 1080, nHeight + 46);
	pMemDC =  new CEsayMemDC(*pDC, rc2);
	m_vecMemDC.push_back(pMemDC);

	CRect rc3(0, nHeight + 52, 540, nHeight*2 + 52);
	pMemDC =  new CEsayMemDC(*pDC, rc3);
	m_vecMemDC.push_back(pMemDC);

	CRect rc4(542, nHeight + 52, 1080, nHeight*2 + 52);
	pMemDC =  new CEsayMemDC(*pDC, rc4);
	m_vecMemDC.push_back(pMemDC);

	CRect rc5(0, nHeight*2 + 58, 540, nHeight*3 + 58);
	pMemDC =  new CEsayMemDC(*pDC, rc5);
	m_vecMemDC.push_back(pMemDC);

	CRect rc6(542, nHeight*2 + 58, 1080, nHeight*3 + 58);
	pMemDC =  new CEsayMemDC(*pDC, rc6);
	m_vecMemDC.push_back(pMemDC);

	ReleaseDC(pDC);
}
Ejemplo n.º 14
0
void CMemoryDC::FromHdc(HDC hdc, RECT rc)
{
	m_hdcSrc = hdc;
	m_rcClip = rc;

	m_hdcMemory = ::CreateCompatibleDC(m_hdcSrc);
	//::BitBlt(m_hdcMemory, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, m_hdcSrc, 0, 0, SRCCOPY);
	m_hbmpPlaceHolder = ::CreateCompatibleBitmap(m_hdcSrc, m_rcClip.right - m_rcClip.left, m_rcClip.bottom - m_rcClip.top);
	m_hbmpOld = (HBITMAP)::SelectObject(m_hdcMemory, m_hbmpPlaceHolder);

	::SetBkColor(m_hdcMemory, 0xffffff);
	CRect rc2(rc);
	rc2.OffsetRect(-rc2.TopLeft());
	::ExtTextOut(m_hdcMemory, 0, 0, ETO_OPAQUE, &rc2, NULL, 0, NULL);

	HFONT h = (HFONT)::GetCurrentObject(hdc, OBJ_FONT);
	m_hfontOld = (HFONT)::SelectObject(m_hdcMemory, h);
}
static void did_dx_affect(skiatest::Reporter* reporter, const SkScalar dx[],
                          size_t count, bool changed) {
    SkIRect ir = { 0, 0, 10, 10 };

    for (size_t i = 0; i < count; ++i) {
        SkRect r;
        r.set(ir);

        SkRasterClip rc0(ir);
        SkRasterClip rc1(ir);
        SkRasterClip rc2(ir);

        rc0.op(r, SkRegion::kIntersect_Op, false);
        r.offset(dx[i], 0);
        rc1.op(r, SkRegion::kIntersect_Op, true);
        r.offset(-2*dx[i], 0);
        rc2.op(r, SkRegion::kIntersect_Op, true);

        REPORTER_ASSERT(reporter, changed != (rc0 == rc1));
        REPORTER_ASSERT(reporter, changed != (rc0 == rc2));
    }
}
Ejemplo n.º 16
0
void DisplayView::OnMouseMove(UINT nFlags, CPoint point)
{
    point += GetScrollPosition();
    bool need_invalidate = false;

    // loop through the filters...
    if (nFlags & MK_LBUTTON) {


        switch (drag_mode) {
        case DisplayView::DRAG_GROUP:
        {
            // we are dragging now
            int	deltax = point.x - start_drag_point.x;
            int deltay = point.y - start_drag_point.y;

            // verify the deltas
            int i, selected_count = 0;
            for (i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];
                if (filter->selected) {
                    selected_count ++;
                    filter->VerifyDrag(&deltax, &deltay);
                }
            }

            // exit if there's no selected filter
            if (selected_count == 0) return ;

            // update their position
            for (i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];
                if (filter->selected) {
                    int px = filter->start_drag_pos.x + deltax;
                    int py = filter->start_drag_pos.y + deltay;

                    // snap to grid
                    px = (px+7)&~0x07;
                    py = (py+7)&~0x07;

                    if (px != filter->posx || py != filter->posy) {
                        filter->posx = px;
                        filter->posy = py;
                        need_invalidate = true;
                    }
                }
            }
        }
        break;

        case DisplayView::DRAG_CONNECTION:
        {
            new_connection_end = point;

            Filter	*current = graph.FindFilterByPos(point);
            if (current) {
                Pin *drop_end = current->FindPinByPos(point);
                if (drop_end) {
                    drop_end->GetCenterPoint(&new_connection_end);
                }
            }

            need_invalidate = true;
        }
        break;
        case DisplayView::DRAG_SELECTION:
        {
            int	minx = start_drag_point.x;
            int miny = start_drag_point.y;
            int maxx = point.x;
            int maxy = point.y;

            if (minx > maxx) {
                minx = point.x;
                maxx = start_drag_point.x;
            }
            if (miny > maxy) {
                miny = point.y;
                maxy = start_drag_point.y;
            }

            end_drag_point = point;
            CRect	rc(minx, miny, maxx, maxy);

            for (int i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];

                CRect	rc2(filter->posx, filter->posy,
                            filter->posx+filter->width,
                            filter->posy+filter->height);
                CRect	rc3;

                rc3.IntersectRect(&rc, &rc2);
                bool sel = (rc3.IsRectEmpty() ? false : true);

                if (sel != filter->selected) {
                    filter->Select(sel);
                    need_invalidate = true;
                }
            }

            if (!need_invalidate) {
                Invalidate();
            }
        }
        break;
        }

        if (need_invalidate) {
            graph.Dirty();
            Invalidate();
        }
    } else {

        /*
        	No buttons are pressed. We only check for overlay icons
        */

        Filter	*current = graph.FindFilterByPos(point);

        // if there was a filter active before
        if (overlay_filter) {
            // which was not ours
            if (overlay_filter != current) {
                // make it's overlay icon disappear
                overlay_filter->overlay_icon_active = -1;
                need_invalidate = true;
            }
        }

        overlay_filter = current;

        if (current) {
            int	cur_icon = current->overlay_icon_active;

            int ret = current->CheckIcons(point);
            if (ret != cur_icon) {
                need_invalidate = true;
            }
        }

        if (need_invalidate) {
            graph.Dirty();
            Invalidate();
        }
    }
}
Ejemplo n.º 17
0
void CChildView::OnPaint() 
{
CPaintDC dcPaint( this );
	CExtPaintManager::stat_ExcludeChildAreas(
		dcPaint.GetSafeHdc(),
		GetSafeHwnd()
		);
CExtMemoryDC dc( &dcPaint );

CGdiObject * pOld0, * pOld1;
CExtWndShadow _shadow;

WORD _PatternBits0[8],_PatternBits1[8];
	for( INT iPatternLine=0; iPatternLine < 8; iPatternLine++ )
	{
		_PatternBits0[iPatternLine] =
			( iPatternLine & 1 )
				? WORD(0xFFFF)
				: WORD( ~ ( 5<<iPatternLine ) )
				;
		_PatternBits1[iPatternLine] =
			( iPatternLine & 1 )
				? WORD(0xFFFF)
				: WORD( ~ ( 1<<(8-iPatternLine) ) )
				;
	}
CBitmap bmpPattern0,bmpPattern1;
CBrush brPattern0,brPattern1;
	VERIFY( bmpPattern0.CreateBitmap(8,8,1,1,_PatternBits0) );
	VERIFY( bmpPattern1.CreateBitmap(8,8,1,1,_PatternBits1) );
	VERIFY( brPattern0.CreatePatternBrush(&bmpPattern0) );
	VERIFY( brPattern1.CreatePatternBrush(&bmpPattern1) );

CRect rcPattern0(10,10,180,150), rcPattern1(40,30,80,200);

	dc.FillRect(rcPattern0,&brPattern0);
	_shadow.Paint(
		dc, rcPattern0, CRect(0,0,0,0), CRect(0,0,0,0),
		CExtWndShadow::DEF_SHADOW_SIZE,
		CExtWndShadow::DEF_BRIGHTNESS_MIN, CExtWndShadow::DEF_BRIGHTNESS_MAX,
		false
		);
	pOld0 = dc.SelectStockObject( NULL_BRUSH );
	pOld1 = dc.SelectStockObject( BLACK_PEN );
	dc.Rectangle( rcPattern0 );
	if( pOld0 != NULL )
		dc.SelectObject( pOld0 );
	if( pOld1 != NULL )
		dc.SelectObject( pOld1 );
	
	dc.FillRect(rcPattern1,&brPattern1);
	_shadow.Paint(
		dc, rcPattern1, CRect(0,0,0,0), CRect(0,0,0,0),
		CExtWndShadow::DEF_SHADOW_SIZE,
		CExtWndShadow::DEF_BRIGHTNESS_MIN, CExtWndShadow::DEF_BRIGHTNESS_MAX,
		false
		);
	pOld0 = dc.SelectStockObject( NULL_BRUSH );
	pOld1 = dc.SelectStockObject( BLACK_PEN );
	dc.Rectangle( rcPattern1 );
	if( pOld0 != NULL )
		dc.SelectObject( pOld0 );
	if( pOld1 != NULL )
		dc.SelectObject( pOld1 );

CRect rc0(20,50,160,80);
CRect rc1(160,50,210,80);
CRect rc2(rc0.left,rc0.top,rc1.right,rc1.bottom);
COLORREF clrLeft = RGB(0,255,0);
COLORREF clrMiddle = RGB(255,255,0);
COLORREF clrRight = RGB(255,0,0);
	CExtPaintManager::stat_PaintGradientRect(
		dc, rc0, clrLeft, clrMiddle );
	CExtPaintManager::stat_PaintGradientRect(
		dc, rc1, clrMiddle,clrRight );
	_shadow.Paint(
		dc, rc2, CRect(0,0,0,0), CRect(0,0,0,0),
		CExtWndShadow::DEF_SHADOW_SIZE,
		CExtWndShadow::DEF_BRIGHTNESS_MIN, CExtWndShadow::DEF_BRIGHTNESS_MAX,
		false
		);
	pOld0 = dc.SelectStockObject( NULL_BRUSH );
	pOld1 = dc.SelectStockObject( BLACK_PEN );
	dc.Rectangle(rc2);
	if( pOld0 != NULL )
		dc.SelectObject( pOld0 );
	if( pOld1 != NULL )
		dc.SelectObject( pOld1 );

CRect rc3(120,40,150,80);
CRect rc4(120,80,150,160);
CRect rc5(rc3.left,rc3.top,rc4.right,rc4.bottom);
COLORREF clrUpper = RGB(255,0,255);
COLORREF clrMiddleV = RGB(255,255,255);
COLORREF clrLower = RGB(0,0,255);
	CExtPaintManager::stat_PaintGradientRect(
		dc, rc3, clrMiddleV, clrUpper, TRUE );
	CExtPaintManager::stat_PaintGradientRect(
		dc, rc4, clrLower, clrMiddleV, TRUE );
	_shadow.Paint(
		dc, rc5, CRect(0,0,0,0), CRect(0,0,0,0),
		CExtWndShadow::DEF_SHADOW_SIZE,
		CExtWndShadow::DEF_BRIGHTNESS_MIN, CExtWndShadow::DEF_BRIGHTNESS_MAX,
		false
		);
	pOld0 = dc.SelectStockObject( NULL_BRUSH );
	pOld1 = dc.SelectStockObject( BLACK_PEN );
	dc.Rectangle(rc5);
	if( pOld0 != NULL )
		dc.SelectObject( pOld0 );
	if( pOld1 != NULL )
		dc.SelectObject( pOld1 );
}
Ejemplo n.º 18
0
void ControlPointsWidget::mouseMoveEvent ( QMouseEvent * evnt )
{
    QPoint pt = evnt->pos();

    if ( !m_bDragging )
    {
	SetMouseCursor( pt );
    }
    else
    {
	QRect rcBounds = m_rcChartPlotArea.adjusted(0,0,1,1);
	if ( !rcBounds.contains(pt) )
	{
	    // Cursor trying to move out of area
	    pt = ClipPoint( rcBounds, pt );
	}

	// Invalidate the rectangle that bounds the old point and joining line segments.
	//int x = ScaleX(m_Points[m_nFocusPoint].lP);
	//int y = ScaleY(m_Points[m_nFocusPoint].dwLog);
	//x += m_ptDragOffset.x;
	//y += m_ptDragOffset.y;
	//x = SnapScreenX(x);
	//y = SnapY(y);
	int x = ScaleX(m_ptDragCPoint.x());
	int y = ScaleY(m_ptDragCPoint.y());

	QRect rcInvalid;
	if ( m_nFocusPoint == 0 )
	{
	    int x1 = ScaleX(m_Points[1].lP);
	    int y1 = ScaleY(m_Points[1].dwLog);
	    QRect rc1(x-3,y-3,x+3,y+3 );
	    QRect rc2(x1-3,y1-3,x1+3,y1+3 );

	    rc1 = rc1.normalized();
	    rc2 = rc2.normalized();

	    rc1.adjust(-1,-1,1,1);
	    rc2.adjust(-1,-1,1,1);
	    rcInvalid = rc1.united( rc2 );
	}
	else if ( m_nFocusPoint == (int)m_Points.size()-1 )
	{
	    int x1 = ScaleX(m_Points[m_nFocusPoint-1].lP);
	    int y1 = ScaleY(m_Points[m_nFocusPoint-1].dwLog);

	    QRect rc1(x-3,y-3,x+3,y+3 );
	    QRect rc2(x1-3,y1-3,x1+3,y1+3 );

	    rc1 = rc1.normalized();
	    rc2 = rc2.normalized();

	    rc1.adjust(-1,-1,1,1);
	    rc2.adjust(-1,-1,1,1);
	    rcInvalid = rc1.united( rc2 );
	}
	else
	{
	    QRect rc1(x-3,y-3,x+3,y+3 );
	    rc1 = rc1.normalized();
	    rc1.adjust(-1,-1,1,1);

	    int x1 = ScaleX(m_Points[m_nFocusPoint-1].lP);
	    int y1 = ScaleY(m_Points[m_nFocusPoint-1].dwLog);
	    QRect rc2(x1-3,y1-3,x1+3,y1+3 );
	    rc2 = rc2.normalized();
	    rc2.adjust(-1,-1,1,1);

	    x1 = ScaleX(m_Points[m_nFocusPoint+1].lP);
	    y1 = ScaleY(m_Points[m_nFocusPoint+1].dwLog);
	    QRect rc3(x1-3,y1-3,x1+3,y1+3 );
	    rc3 = rc3.normalized();
	    rc3.adjust(-1,-1,1,1);

	    QRect temp;
	    temp = rc1.united(rc2);
	    rcInvalid = temp.united( rc3 );
	}

	// Update the drag offset.  This will be repainted in the paint routine.
	//m_ptDragOffset = pt - m_ptDragPickup;
	m_ptDragCPoint.setX( SnapX(UnscaleX(pt.x())) );
	m_ptDragCPoint.setY( SnapY(UnscaleY(pt.y())) );
	update( rcInvalid );
    }

    //CRect rcBounds(m_rcChartPlotArea.left, m_rcChartPlotArea.top, m_rcChartPlotArea.right+1, m_rcChartPlotArea.bottom + 1 );
    //if ( rcBounds.PtInRect(pt) )
    //{
    //	int x = UnscaleX( SnapScreenX(pt.x ));
    //	int y = UnscaleY( SnapY(pt.y ));
    //	TRACE("%d, %d\n", x, y );
    //}


    if ( m_rcChartPlotArea.contains( pt ) )
	emit mousePositionChanged( SnapX(UnscaleX(pt.x())), SnapX(UnscaleY(pt.y())) );
}
Ejemplo n.º 19
0
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);
}