当前位置: 首页>>代码示例>>C++>>正文


C++ pt函数代码示例

本文整理汇总了C++中pt函数的典型用法代码示例。如果您正苦于以下问题:C++ pt函数的具体用法?C++ pt怎么用?C++ pt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
#ifdef CONSOLE_APPLICATION
    QApplication app(argc, argv, QApplication::Tty);
#else
    QApplication app(argc, argv);
#endif
#ifdef DO_QWS_DEBUGGING
    qt_show_painter_debug_output = false;
#endif

    DeviceType type = WidgetType;
    bool checkers_background = true;

    QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;

    QLocale::setDefault(QLocale::c());

    QStringList files;

    bool interactive = false;
    bool printdlg = false;
    bool highres = false;
    bool show_cmp = false;
    int width = 800, height = 800;
    int scaledWidth = width, scaledHeight = height;
    qreal scalefactor = 1.0;
    bool verboseMode = false;

#ifndef QT_NO_OPENGL
    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    f.setStencil(true);
    f.setAlpha(true);
    f.setAlphaBufferSize(8);
    QGLFormat::setDefaultFormat(f);
#endif

    char *arg;
    for (int i=1; i<argc; ++i) {
        arg = argv[i];
        if (*arg == '-') {
            QString option = QString(arg + 1).toLower();
            if (option == "widget")
                type = WidgetType;
            else if (option == "bitmap")
                type = BitmapType;
            else if (option == "pixmap")
                type = PixmapType;
            else if (option == "image")
                type = ImageType;
            else if (option == "imageformat") {
                Q_ASSERT_X(i + 1 < argc, "main", "-imageformat must be followed by a value");
                QString format = QString(argv[++i]).toLower();

                imageFormat = QImage::Format_Invalid;
                static const int formatCount =
                    sizeof(imageFormats) / sizeof(imageFormats[0]);
                for (int ff = 0; ff < formatCount; ++ff) {
                    if (QLatin1String(imageFormats[ff].name) == format) {
                        imageFormat = imageFormats[ff].format;
                        break;
                    }
                }

                if (imageFormat == QImage::Format_Invalid) {
                    printf("Invalid image format.  Available formats are:\n");
                    for (int ff = 0; ff < formatCount; ++ff)
                        printf("\t%s\n", imageFormats[ff].name);
                    return -1;
                }
            } else if (option == "imagemono")
                type = ImageMonoType;
            else if (option == "imagewidget")
                type = ImageWidgetType;
#ifndef QT_NO_OPENGL
            else if (option == "opengl")
                type = OpenGLType;
            else if (option == "glbuffer")
                type = OpenGLBufferType;
#endif
#ifdef USE_CUSTOM_DEVICE
            else if (option == "customdevice")
                type = CustomDeviceType;
            else if (option == "customwidget")
                type = CustomWidgetType;
#endif
            else if (option == "pdf")
                type = PdfType;
            else if (option == "ps")
                type = PsType;
            else if (option == "picture")
                type = PictureType;
            else if (option == "printer")
                type = PrinterType;
            else if (option == "highres") {
                type = PrinterType;
                highres = true;
            } else if (option == "printdialog") {
                type = PrinterType;
//.........这里部分代码省略.........
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:101,代码来源:main.cpp

示例2: GetCompareData

void CCompareResultsDlg::OnItemChanging(NMHDR *pNMHDR, LRESULT *pLResult)
{
  *pLResult = FALSE;  // Allow change

  NMLISTVIEW *pNMLV = reinterpret_cast<NMLISTVIEW *>(pNMHDR);
  int irow = pNMLV->iItem;
  
  // Check if state unchanged - unchanged == not interested
  if ((pNMLV->uChanged & LVIF_STATE) != LVIF_STATE)
    return;

  // Has the selected state changed?
  // Was selected and now not or Wasn't selected and still isn't - ignore
  if (((pNMLV->uOldState & LVIS_SELECTED)!= 0 && (pNMLV->uNewState & LVIS_SELECTED) == 0) ||
      ((pNMLV->uOldState & LVIS_SELECTED) == 0 && (pNMLV->uNewState & LVIS_SELECTED) == 0)) {
    return;
  }

  DWORD_PTR dwItemData = m_LCResults.GetItemData(irow);
  st_CompareData *pst_data = GetCompareData(dwItemData);
  ASSERT(pst_data != NULL);

  CPoint pt(GetMessagePos());
  m_LCResults.ScreenToClient(&pt);

  LVHITTESTINFO hti = {0};
  hti.pt = pt;
  int iItem = m_LCResults.SubItemHitTest(&hti);
  
  // Ignore any clicks not on an item
  if (iItem == -1 ||
      hti.flags & (LVHT_NOWHERE |
                   LVHT_ABOVE   | LVHT_BELOW |
                   LVHT_TORIGHT | LVHT_TOLEFT)) {
      return;
  }

  
  if ((GetKeyState(VK_CONTROL) & 0x8000)) {
    // Control key pressed - multi-select
    /*
       Since we only allow multi-select for Copy or Synchronise from Compare DB
       to the original Db, we won't allow if row entry is not in the Compare DB
       ...  pst_data->indatabase == CURRENT

       We also won't allow if entry is in the original DB and protected.
       ...  pst_data->bIsProtected0

       or if the first of the multiple selection was not in the Compare DB
       ... m_bFirstInCompare

       or if user changes column
       ... m_LCResults.GetColumn() == pNMLV->iSubItem

       No point if original is R-O or if already equal to original
       ... !m_bOriginalDBReadOnly || pst_data->indatabase == IDENTICAL
    */

    if (pst_data->indatabase == CURRENT || pst_data->indatabase == IDENTICAL ||
        pst_data->bIsProtected0 ||
        !m_bFirstInCompare || m_bOriginalDBReadOnly ||
        m_LCResults.GetColumn() != hti.iSubItem) {
      *pLResult = TRUE; // Deny change
      return;
    }
  } else {
    // Single-select or first selection
    m_bFirstInCompare = pst_data->indatabase != CURRENT;  // Not in Current DB only
  }
}
开发者ID:NonPlayerCharactor,项目名称:PasswordSafeFork,代码行数:70,代码来源:CompareResultsDlg.cpp

示例3: switch

LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    BOOL bProcessed = FALSE;
	//CCLog("wParam:%d", wParam);
    switch (message)
    {
        case WM_MOUSEWHEEL:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			ScreenToClient(m_hWnd, &point);
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			float zDelta = (short)HIWORD(wParam);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
			{
				m_bCaptured = true;
				SetCapture(m_hWnd);

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::middleMouseEvent);
				handleScrollWheel(pt.x, pt.y, 0, zDelta, event);
				event->release();
			}
		}
		break;

        case WM_MOUSEMOVE:
#if(_MSC_VER >= 1600)
            // Don't process message generated by Windows Touch
            if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */
            if (MK_LBUTTON == wParam && m_bCaptured)
            {
                POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
                DPoint pt(point.x, point.y);
                int id = 0;
                pt.x /= m_fFrameZoomFactor;
                pt.y /= m_fFrameZoomFactor;
                
                CrossApp::CAEvent* event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::leftMouseEvent);
                handleTouchesMove(1, &id, &pt.x, &pt.y, event);
                event->release();
                
                event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::movedMouseEvent);
                handleMouseMoved(pt.x, pt.y, event);
                event->release();
            }
            break;
            
	case WM_MBUTTONDOWN:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate && MK_MBUTTON == wParam)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
			{
				m_bCaptured = true;
				SetCapture(m_hWnd);
				int id = 0;

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::middleMouseEvent);
				handleOtherMouseDown(1, &id, &pt.x, &pt.y, event);
				event->release();
			}
		}
		break;

	case WM_MBUTTONUP:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
//.........这里部分代码省略.........
开发者ID:9miao,项目名称:CrossApp,代码行数:101,代码来源:CCEGLView.cpp

示例4: ASSERT

bool CGdiPlusImage::DrawImage(CDC* pDC)
{
    //´´½¨ÆÁÄ»
    ASSERT(pDC!=NULL); 
    if ( !pDC ) return false; 

    Bitmap bmp(m_rcDest.Width(), m_rcDest.Height()); 
    Graphics* pGraphics = Graphics::FromImage(&bmp); 
    if ( !pGraphics ) return false;

    GraphicsContainer Containter = pGraphics->BeginContainer();
    pGraphics->SetSmoothingMode(SmoothingModeHighQuality); 

    SolidBrush bgbrush(Color(238, 243, 250));
    pGraphics->FillRectangle(&bgbrush, 0, 0, m_rcDest.Width(), m_rcDest.Height());
    
    if ( m_pImage )
    {
        //»ñÈ¡ÊôÐÔ 
        INT nImageWidth  = m_pImage->GetWidth();
        INT nImageHeight = m_pImage->GetHeight(); 


        float fMin = 1.0F; 
        float fZoomRate = 1.0F; 
        bool bZoomOut = false; 
        int nXSrc = 0;
        int nYSrc = 0; 

        if ( nImageWidth >= m_rcDest.Width() || nImageHeight >= m_rcDest.Height() )
        { 
            float fXRate = 1.0F * m_rcDest.Width() / nImageWidth;
            float fYRate = 1.0F * m_rcDest.Height() / nImageHeight;
            fMin = min(fXRate, fYRate);   
            fZoomRate = max(nImageWidth * 1.0F / m_rcDest.Width(), nImageHeight * 1.0F / m_rcDest.Height()); 
            bZoomOut = true;
        } 


        int nDestWidth  = fMin * nImageWidth;
        int nDestHeight = fMin * nImageHeight;


        //¹¹ÔìλÖÃ
        RectF rcDrawRect;  
        rcDrawRect.X = m_rcDest.left + (m_rcDest.Width() - nDestWidth ) / 2;   
        rcDrawRect.Y = m_rcDest.top + (m_rcDest.Height() - nDestHeight ) / 2; 
        rcDrawRect.Width = nDestWidth;
        rcDrawRect.Height = nDestHeight; 

        Matrix matrix;

        CPoint pt(m_rcDest.Width() / 2, m_rcDest.Height() / 2);
        PointF ptBase((float)pt.x, (float)pt.y);  

        //¾ØÕó±ä»»Òª×¢Òâ˳Ðò£¬ÏÈƽÒÆÔÚËõ·ÅºóÐýת
        matrix.Translate((REAL)m_rcDest.left,(REAL)m_rcDest.top,MatrixOrderAppend);

        //Ëõ·Å
        if ( m_szZoom.cx != 1.0f || m_szZoom.cy != 1.0f )
        {
            ptBase.X += m_szZoom.cx;
            ptBase.Y += m_szZoom.cy;

            matrix.Translate(-ptBase.X,-ptBase.Y,MatrixOrderAppend);
            matrix.Scale(m_szZoom.cx,m_szZoom.cy,MatrixOrderAppend);
            matrix.Translate(ptBase.X,ptBase.Y,MatrixOrderAppend);
        }

        //Ðýת
        if (m_nRotateAngle)
        {
            matrix.RotateAt((REAL)m_nRotateAngle,ptBase,MatrixOrderAppend);
        }

        pGraphics->SetTransform(&matrix);

        //͸Ã÷¾ØÕó
        ColorMatrix Matrix=
        {
            1.0f,0.0f,0.0f,0.0f,0.0f, 
            0.0f,1.0f,0.0f,0.0f,0.0f, 
            0.0f,0.0f,1.0f,0.0f,0.0f,
            0.0f,0.0f,0.0f,m_cbAlphaDepth/255.0f,0.0f, 
            0.0f,0.0f,0.0f,0.0f,1.0f
        };

        //ÉèÖÃÊôÐÔ
        ImageAttributes Attributes; 
        Attributes.SetColorMatrix(&Matrix,ColorMatrixFlagsDefault,ColorAdjustTypeBitmap); 

        //»æ»­Í¼Ïñ
        pGraphics->DrawImage(m_pImage, rcDrawRect, nXSrc, nYSrc, (REAL)nImageWidth - nXSrc * 2, (REAL)nImageHeight - nYSrc * 2, UnitPixel,&Attributes);  
        pGraphics->ResetTransform();   
        pGraphics->EndContainer(Containter);

    } // if ( m_pImage )
   
    // ´ÓÄڴ濽±´ÖÁÉ豸
    Graphics graphicsreal(pDC->GetSafeHdc()); 
//.........这里部分代码省略.........
开发者ID:cuihao0532,项目名称:PhotoViewer,代码行数:101,代码来源:GdiPlusImage.cpp

示例5: paintDC

void CProgressCtrlEx::OnPaint()
{
	CPaintDC paintDC(this);

	int nMin = 0;
	int nMax = 0;

	GetRange(nMin, nMax);
	ASSERT(nMin <= nMax);

	int nPos = GetPos();
	ASSERT(nPos >= nMin && nPos <= nMax);

	DWORD dwStyle = GetStyle();

	BOOL bVertical = FALSE;
	if (dwStyle & PBS_VERTICAL)
	{
		bVertical = TRUE;
	}

	CDC dc;
	dc.CreateCompatibleDC(&paintDC);
	ASSERT(dc.GetSafeHdc());

	CRect rect;
	GetClientRect(&rect);

	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&paintDC, rect.Width(), rect.Height());
	ASSERT(bmp.GetSafeHandle());

	CBitmap* pOldBitmap = (CBitmap*)dc.SelectObject(&bmp);

	CFont* pOldFont = NULL;
	CWnd* pParent = GetParent();
	ASSERT(pParent);

	CFont* pFont = pParent->GetFont();
	ASSERT(pFont);
	if (bVertical)
	{
		if (NULL == m_font.GetSafeHandle())
		{
			LOGFONT lf = { 0 };
			pFont->GetLogFont(&lf);
			lf.lfEscapement = 900;
			m_font.CreateFontIndirect(&lf);
		}
		ASSERT(m_font.GetSafeHandle());
		pOldFont = (CFont*)dc.SelectObject(&m_font);
	}
	else
	{
		pOldFont = (CFont*)dc.SelectObject(pFont);
	}

	double dPercent = (double)(nPos - nMin) / ((double)(nMax - nMin));

	dc.DrawEdge(rect, EDGE_SUNKEN, BF_RECT | BF_FLAT);

	CRect rc(rect);
	rc.DeflateRect(CSize(2, 2));
	dc.FillSolidRect(&rc, m_clrBarBkColor);

	CString strText(_T(""));
	GetWindowText(strText);

	if (m_bShowPercent)
	{
		strText.AppendFormat(_T("%d%% "), static_cast<int>((dPercent * 100.0) + 0.5));
	}

	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(m_clrTextColor);

	CPoint pt(0, 0);
	CSize size = dc.GetOutputTextExtent(strText);

	if (!bVertical)
	{
		switch (m_AlignText)
		{
		case ALIGN_LEFT:
			pt.x = rc.left;
			break;

		case ALIGN_RIGHT:
			pt.x = rc.right - size.cx;
			break;

		case ALIGN_CENTER:
		default:
			pt.x = rc.left + (rc.Width() - size.cx) / 2;
			break;
		}
		pt.y = rc.top + (rc.Height() - size.cy) / 2;

		CRect rcPos(rc);

//.........这里部分代码省略.........
开发者ID:HoCheung1993,项目名称:Jovi-s-Software,代码行数:101,代码来源:ProgressCtrlEx.cpp

示例6: sampleLine

int sampleLine(const String &line, int y, String &code)
{
	double mean = 0;
	int i=0, x=0, w=line.size();
	// find quiet zones:
	Point sl = detail::quietZone(line, 0,   w/2,  1, mean );
	Point sr = detail::quietZone(line, w-1, w/2, -1, mean );
	int distance = sr.x - sl.x;
	if ( distance < 58 )
	{
		return 1; // too short
	}
	// try to sample a square wave from the grayscale data
	// between the quiet zones,
	// start at first black pixel
	bool last_state = true;
	vector<Point> pt(1,Point(0,0)); // pos,length, pos,length, ..
	for ( i = sl.x+1; i<sr.x; i++  )
	{
		// todo : proper nms
		bool state = (line[i] < mean);
		// toggle state:
		if ( state != last_state )
		{
			pt.push_back(Point(i, 1));
			last_state = state;
			continue;
		}
		// state unchanged, increase length of current section
		pt.back().y ++;
	}
	// ean13 has 95 bits and 58 state toggles,
	// ean8  has 67 bits and 42 state toggles.
	double siz = distance;
	if ( pt.size() == 58 )
	{
		siz /= 95.0; // ean13
	}
	else
	if ( pt.size() == 42 )
	{
		siz /= 67.0; // ean8
	}
	else
	{
		return 2; // no match to either ean8 or ean13
	}
	// scale pattern down to 1 pixel per bit:
	int sum = 0;
	double last = (sl.x+1);
	for( i=0; i<pt.size(); i++  )
	{
		double d = pt[i].x - last;
		last = pt[i].x;
		d = int( 0.5 + d/siz ); // floor ?
		sum += d;
		pt[i].y = d; // now holds bit count
	}
	if ( sum > 95 )
	{
		return 3; // too long
	}
	// make bitstring:
	bool bit = true;
	String bits = "";
	for( int i=0; i<pt.size(); i++ )
	{
		for( int j=0; j<pt[i].y; j++ )
		{
			bits += ( bit ? '1' : '0' );
			if ( bits.size() > 95 )
			{
				return 4; // still too long
			}
		}
		bit = ! bit;
	}
	bits += '1';
	if ( bits.size() == 67 )
		return decode8( bits, code );
	if ( bits.size() == 95 )
		return decode13( bits, code );
	return 4; // no match to either ean8 or ean13
}
开发者ID:berak,项目名称:opencv_smallfry,代码行数:84,代码来源:ean.cpp

示例7: rcItem

void CSchemaCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if ( lpDrawItemStruct->itemID == (UINT)-1 ) return;
	if ( ( lpDrawItemStruct->itemAction & ODA_SELECT ) == 0 &&
		 ( lpDrawItemStruct->itemAction & ODA_DRAWENTIRE ) == 0 ) return;

	CRect rcItem( &lpDrawItemStruct->rcItem );
	CPoint pt( rcItem.left + 1, rcItem.top + 1 );
	CDC dc;

	dc.Attach( lpDrawItemStruct->hDC );
	if ( Settings.General.LanguageRTL )
		SetLayout( dc.m_hDC, LAYOUT_RTL );

	dc.SetTextColor( ( lpDrawItemStruct->itemState & ODS_SELECTED )
		? CoolInterface.m_crHiText : CoolInterface.m_crDropdownText );

	CSchemaPtr pSchema = (CSchemaPtr)lpDrawItemStruct->itemData;

	if ( pSchema != NULL )
	{
		/*dc.FillSolidRect( &rcItem,
			GetSysColor( ( lpDrawItemStruct->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHT : COLOR_WINDOW ) );*/
		if ( IsWindowEnabled() )
		{
			if ( lpDrawItemStruct->itemState & ODS_SELECTED )
				dc.FillSolidRect( &rcItem, CoolInterface.m_crHighlight );
			else
				dc.FillSolidRect( &rcItem, CoolInterface.m_crDropdownBox );
		}
		else
			dc.FillSolidRect( &rcItem, GetBkColor(lpDrawItemStruct->hDC) );

		dc.SetBkMode( TRANSPARENT );

		ShellIcons.Draw( &dc, pSchema->m_nIcon16, 16, pt.x, pt.y, CLR_NONE,
			( lpDrawItemStruct->itemState & ODS_SELECTED ) );

		rcItem.left += 20; rcItem.right -= 2;

		CFont* pOldFont = (CFont*)dc.SelectObject( &theApp.m_gdiFont );
		CString strURI = pSchema->GetURI();

		if ( dc.GetTextExtent( pSchema->m_sTitle + strURI ).cx > rcItem.Width() - 20
			 && strURI.GetLength() > 8 )
		{
			LPCTSTR pszLeft = _tcschr( (LPCTSTR)strURI + 7, '/' );
			int nRight		= strURI.ReverseFind( '/' );

			if ( pszLeft && nRight >= 0 )
			{
				int nLeft = static_cast< int >( pszLeft - (LPCTSTR)strURI );  // !!! (TODO)
				strURI = strURI.Left( nLeft ) + _T("/\x2026") + strURI.Mid( nRight );
			}
		}

		if ( dc.GetTextExtent( pSchema->m_sTitle + strURI ).cx <= rcItem.Width() - 20 )
		{
			// COLORREF crBackup = dc.SetTextColor( GetSysColor( COLOR_GRAYTEXT ) );
			dc.DrawText( strURI, &rcItem, DT_SINGLELINE|DT_RIGHT|DT_VCENTER|DT_NOPREFIX );
			// dc.SetTextColor( crBackup );
		}

		dc.SelectObject( &theApp.m_gdiFontBold );
		dc.DrawText( pSchema->m_sTitle, &rcItem, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX );
		dc.SelectObject( pOldFont );
	}
	else if ( lpDrawItemStruct->itemID == 0 )
	{
		/*dc.FillSolidRect( &rcItem,
			GetSysColor( ( lpDrawItemStruct->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHT : COLOR_WINDOW ) );*/
		if ( IsWindowEnabled() )
		{
			if ( lpDrawItemStruct->itemState & ODS_SELECTED )
				dc.FillSolidRect( &rcItem, CoolInterface.m_crHighlight );
			else
				dc.FillSolidRect( &rcItem, CoolInterface.m_crDropdownBox );
		}
		else
			dc.FillSolidRect( &rcItem, GetBkColor(lpDrawItemStruct->hDC) );
		dc.SetBkMode( TRANSPARENT );

		CoolInterface.Draw( &dc, IDR_SEARCHFRAME, 16,
			pt.x, pt.y, CLR_NONE, ( lpDrawItemStruct->itemState & ODS_SELECTED ) );

		rcItem.left += 20; rcItem.right -= 2;

		CFont* pOldFont = (CFont*)dc.SelectObject( &theApp.m_gdiFontBold );
		dc.DrawText( m_sNoSchemaText, &rcItem, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX );
		dc.SelectObject( pOldFont );
	}
	else
	{
		dc.Draw3dRect( &rcItem, CoolInterface.m_crDropdownBox , CoolInterface.m_crDropdownBox );
		rcItem.DeflateRect( 1, 1 );

		if ( lpDrawItemStruct->itemState & ODS_SELECTED )
		{
			dc.Draw3dRect( &rcItem, CoolInterface.m_crBorder, CoolInterface.m_crBorder );
			rcItem.DeflateRect( 1, 1 );
//.........这里部分代码省略.........
开发者ID:ivan386,项目名称:Shareaza,代码行数:101,代码来源:CtrlSchemaCombo.cpp

示例8: pt

xs::Point GroundEyeshot::getViewLeftTop()
{
	xs::Point pt (m_Eyeshot.getViewTopX(),m_Eyeshot.getViewTopY());
	return pt;
}
开发者ID:lorichen,项目名称:xgame,代码行数:5,代码来源:GroundEyeshot.cpp

示例9: switch

BOOL CCoolMenuBarCtrl::OnMenuMessage(MSG* pMsg)
{
	if ( theApp.m_bClosing )
		return FALSE;

	switch ( pMsg->message )
	{
	case WM_MOUSEMOVE:
		{
			//CPoint pt( LOWORD( pMsg->lParam ), HIWORD( pMsg->lParam ) );
			CPoint pt( pMsg->lParam );
			ScreenToClient( &pt );

			if ( m_pMouse == pt ) return TRUE;
			m_pMouse = pt;

			CCoolBarItem* pHit = HitTest( pt );

			if ( pHit && pHit != m_pDown )
			{
				if ( Settings.WINE.MenuFix )
					PostMessage( WM_CANCELMODE, 0, 0 );
				else
					SendMessage( WM_CANCELMODE, 0, 0 );
				m_pHot	= pHit;
				m_pDown	= NULL;
				PostMessage( WM_TIMER, 4 );
				return TRUE;
			}
		}
		break;
	case WM_LBUTTONDOWN:
		{
			//CPoint pt( LOWORD( pMsg->lParam ), HIWORD( pMsg->lParam ) );
			CPoint pt( pMsg->lParam );

			CWnd* pWnd = CWnd::WindowFromPoint( pt );

			if ( pWnd )
			{
				TCHAR szClass[2];
				GetClassName( pWnd->GetSafeHwnd(), szClass, 2 );
				if ( szClass[0] == '#' ) return FALSE;
			}

			ScreenToClient( &pt );

			CCoolBarItem* pHit = HitTest( pt );

			if ( pHit == NULL )
			{
				m_pHot = m_pDown = NULL;
				if ( Settings.WINE.MenuFix )
					PostMessage( WM_CANCELMODE, 0, 0 );
				else
					SendMessage( WM_CANCELMODE, 0, 0 );
				return TRUE;
			}
			else if ( pHit == m_pDown )
			{
				m_pDown = NULL;
				PostMessage( WM_CANCELMODE, 0, 0 );
				return TRUE;
			}
		}
		break;
	case WM_KEYDOWN:
		switch ( pMsg->wParam )
		{
		case VK_LEFT:
			ShiftMenu( -1 );
			return TRUE;
		case VK_RIGHT:
			ShiftMenu( 1 );
			return TRUE;
		case VK_ESCAPE:
			PostMessage( WM_CANCELMODE, 0, 0 );
			m_pHot = m_pDown = NULL;
			return TRUE;
		}
		break;
	default:
		break;
	}

	return FALSE;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:87,代码来源:CtrlCoolMenuBar.cpp

示例10: check_bg_collision

/* Can probably be made more efficient - like only checking one area */
static level_mask_t check_bg_collision(game_t *p_game, sprite_t *p_sprite, dir_t dir, point_t new_pt, point_t *p_overlap)
{
  rect_t rect;
  int16_t x,y;

  rect = rect_add_pt(p_sprite->p_bounds[p_sprite->frame], new_pt);

  switch (dir)
    {
    case LEFT:
      rect.bottom_right.x = rect.top_left.x + TILE_W;
      rect.bottom_right.y-=TILE_H;
      break;
    case RIGHT:
      rect.top_left.x = rect.bottom_right.x - TILE_W;
      rect.bottom_right.y-=TILE_H; /* FIXME! Better with allow left/right */
      break;
    case UP:
      rect.bottom_right.y = rect.top_left.y + TILE_W;
      break;
    case DOWN:
      rect.top_left.y = rect.bottom_right.y - TILE_W;
      break;
    }

#ifndef NDEBUG
  {
    rect_t rect2 = rect_add_pt(p_sprite->p_bounds[p_sprite->frame], p_sprite->pt);

    draw_rect(p_game, rect2, vRGB(255,255,255));
  }
#endif
  draw_rect(p_game, rect, vRGB(255,0,0));

  for (y = rect.top_left.y/TILE_H; y <= rect.bottom_right.y/TILE_H; y++)
    {
      for (x = rect.top_left.x/TILE_W; x <= rect.bottom_right.x/TILE_W; x++)
	{
	  level_mask_t tile = tile_at(p_game, pt(x,y));

	  if (tile > 1)
	    {
	      rect_t tile_rect = rect_add_pt(tile_bounds[tile-1], pt_to_sprite(pt(x,y)));

	      draw_rect(p_game, tile_rect, vRGB(0,255,0));
	      if (rect_overlap(tile_rect, rect, p_overlap))
		{
		  assert(tile != 0);

#ifndef NDEBUG
		  DbgPrintf("  %d:%d Tile %d rect %d:%d -> %d:%d (overlap %d,%d)\n\n", dir, p_sprite->state, tile,
			    tile_rect.top_left.x,tile_rect.top_left.y,
			    tile_rect.bottom_right.x, tile_rect.bottom_right.y,
			    p_overlap->x, p_overlap->y
			    );
		  vFlipScreen(0);
#endif
		  return tile;
		}
	    }
	}
    }
  /* TMP! */
  DbgPrintf("\n");

#ifndef NDEBUG
  vFlipScreen(0);
#endif

  return 0;
}
开发者ID:SimonKagstrom,项目名称:old-projects,代码行数:72,代码来源:main.c

示例11: handle_input

static void handle_input(game_t *p_game, uint32_t keys)
{
  sprite_t *p_sprite = &p_game->player.sprite;

  if (!keys)
    {
      if (p_sprite->state == SPRITE_CROUCH)
	sprite_set_state(p_sprite, SPRITE_IDLE);
    }

  /* Handle running and jumping */
  if (p_sprite->state == SPRITE_IDLE ||
      p_sprite->state == SPRITE_RUN)
    {
      if (keys & KEY_LEFT)
	{
	  p_sprite->state = SPRITE_RUN;
	  p_sprite->dir = LEFT;
	}
      else if (keys & KEY_RIGHT)
	{
	  p_sprite->state = SPRITE_RUN;
	  p_sprite->dir = RIGHT;
	}
      if (keys & KEY_DOWN)
	sprite_set_state(p_sprite, SPRITE_CROUCH);

      /* Handle jumping */
      if (p_sprite->state == SPRITE_IDLE &&
	  (keys & KEY_UP))
	sprite_set_state(p_sprite, SPRITE_JUMP);
      else if (p_sprite->state == SPRITE_RUN &&
	       (keys & KEY_UP))
	sprite_set_state(p_sprite, SPRITE_JUMP_RUN);
    }
  else if (p_sprite->state == SPRITE_CLIMB)
    {
      anim_table_t *p_cur = p_sprite->p_anims[SPRITE_CLIMB];

      if (!keys)
	p_cur->entries[0].pt_offset = pt(0, 0);
      else
	{
	  if (p_game->player.sprite.move_table_idx == 0)
	    {
	      if (p_cur->entries[0].anim_frame == FRAME_BRUCE_CLIMB)
		{
		  p_cur->entries[0].anim_frame = FRAME_BRUCE_CLIMB+1;
		  p_cur->entries[1].anim_frame = FRAME_BRUCE_CLIMB+1;
		}
	      else
		{
		  p_cur->entries[0].anim_frame = FRAME_BRUCE_CLIMB;
		  p_cur->entries[1].anim_frame = FRAME_BRUCE_CLIMB;
		}
	    }

	  p_sprite->dir = RIGHT;

	  if (keys & KEY_UP)
	    p_cur->entries[0].pt_offset = pt(0, -4);
	  else if (keys & KEY_DOWN)
	    p_cur->entries[0].pt_offset = pt(0, 4);
	  else if (keys & KEY_LEFT)
	    p_cur->entries[0].pt_offset = pt(-4, 0);
	  else if (keys & KEY_RIGHT)
	    p_cur->entries[0].pt_offset = pt(4, 0);
	}

      /* Cannot hit etc when climbing */
      return;
    }

  if (keys & KEY_FIRE)
    {
      if (p_sprite->state == SPRITE_RUN)
	sprite_set_state(p_sprite, SPRITE_KICK);
      else if (p_sprite->state == SPRITE_IDLE &&
	       p_sprite->state != SPRITE_HIT)
	sprite_set_state(p_sprite, SPRITE_HIT);
    }
}
开发者ID:SimonKagstrom,项目名称:old-projects,代码行数:82,代码来源:main.c

示例12: pointTest

bool
pointTest(const std::vector<Path>& paths,
        const std::vector<LineStyle>& lineStyles, std::int32_t x,
        std::int32_t y, const SWFMatrix& wm)
{

    /*
    Principle:
    For the fill of the shape, we project a ray from the test point to the left
    side of the shape counting all crossings. When a line or curve segment is
    crossed we add 1 if the left fill style is set. Regardless of the left fill
    style we subtract 1 from the counter then the right fill style is set.
    This is true when the line goes in downward direction. If it goes upward,
    the fill styles are reversed.

    The final counter value reveals if the point is inside the shape (and
    depends on filling rule, see below).
    This method should not depend on subshapes and work for some malformed
    shapes situations:
    - wrong fill side (eg. left side set for a clockwise drawen rectangle)
    - intersecting paths
    */
    point pt(x, y);

    // later we will need non-zero for glyphs... (TODO)
    bool even_odd = true;  

    unsigned npaths = paths.size();
    int counter = 0;

    // browse all paths
    for (unsigned pno=0; pno<npaths; pno++)
    {
        const Path& pth = paths[pno];
        unsigned nedges = pth.m_edges.size();

        float next_pen_x = pth.ap.x;
        float next_pen_y = pth.ap.y;
        float pen_x, pen_y;

        if (pth.empty()) continue;

        // If the path has a line style, check for strokes there
        if (pth.m_line != 0 )
        {
            assert(lineStyles.size() >= pth.m_line);
            const LineStyle& ls = lineStyles[pth.m_line-1];
            double thickness = ls.getThickness();
            if (! thickness )
            {
                thickness = 20; // at least ONE PIXEL thick.
            }
            else if ((!ls.scaleThicknessVertically()) &&
                    (!ls.scaleThicknessHorizontally()) )
            {
                // TODO: pass the SWFMatrix to withinSquareDistance instead ?
                double xScale = wm.get_x_scale();
                double yScale = wm.get_y_scale();
                thickness *= std::max(xScale, yScale);
            }
            else if (ls.scaleThicknessVertically() != 
                    ls.scaleThicknessHorizontally())
            {
                LOG_ONCE(log_unimpl(_("Collision detection for "
                                      "unidirectionally scaled strokes")));
            }

            double dist = thickness / 2.0;
            double sqdist = dist * dist;
            if (pth.withinSquareDistance(pt, sqdist))
                return true;
        }

        // browse all edges of the path
        for (unsigned eno=0; eno<nedges; eno++)
        {
            const Edge& edg = pth.m_edges[eno];
            pen_x = next_pen_x;
            pen_y = next_pen_y;
            next_pen_x = edg.ap.x;
            next_pen_y = edg.ap.y;

            float cross1 = 0.0, cross2 = 0.0;
            int dir1 = 0, dir2 = 0; // +1 = downward, -1 = upward
            int crosscount = 0;

            if (edg.straight())
            {
                // ignore horizontal lines
                // TODO: better check for small difference?
                if (edg.ap.y == pen_y)  
                {
                    continue;
                }
                // does this line cross the Y coordinate?
                if ( ((pen_y <= y) && (edg.ap.y >= y))
                    || ((pen_y >= y) && (edg.ap.y <= y)) )
                {

                    // calculate X crossing
//.........这里部分代码省略.........
开发者ID:aopui,项目名称:gnash,代码行数:101,代码来源:Geometry.cpp

示例13: atoi

void CDlg_Chat_Clt::OnlineUserInfo(DWORD dwUserId, CStringArrayEx *pstrUserInfo)
{
    if (NULL == pstrUserInfo) return;

    int nImageId = atoi((LPCTSTR)(*pstrUserInfo)[3]);
    m_wndOutlookBar.InsertItem(0, m_wndOutlookBar.GetItemCount(0), (LPCTSTR)(*pstrUserInfo)[1], nImageId, dwUserId);

    CString strCount;
    strCount.Format(_T("在线用户 (%d)"), m_wndOutlookBar.GetItemCount(0));
    m_wndOutlookBar.SetFolderText(0, (LPCTSTR)strCount);

    if (m_dwMyId == dwUserId)
    {
        IMAGEINFO ImageInfo = {0};
        g_ProFile.m_ImageList.GetImageInfo(nImageId, &ImageInfo);
        CSize szImage = CRect(ImageInfo.rcImage).Size();
        CPoint pt(10, 50-szImage.cy-1);
        CDC dc;
        dc.Attach(m_hCompDC);
        g_ProFile.m_ImageList.Draw(&dc, nImageId, pt, ILD_NORMAL);
        dc.Detach();

        RECT rcText = {15+szImage.cx, 30, 180, 50};
        ::DrawText(m_hCompDC, (LPCTSTR)(*pstrUserInfo)[1], (*pstrUserInfo)[1].GetLength(), &rcText, DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS);
    }

    m_OnlineUserIdArray.Add(dwUserId);

    if (NULL == m_pFriendIdArray) return;

    for (int i = 0; i < m_pFriendIdArray->GetCount(); i++)
    {
        if (dwUserId == (*m_pFriendIdArray)[i])
        {
            int j = 0;
            for (; j < m_OnlineFriendIdArray.GetCount(); j++)
            {
                if (dwUserId == m_OnlineFriendIdArray[j]) break;
            }

            if (j == m_OnlineFriendIdArray.GetCount())
            {
                m_OnlineFriendIdArray.Add(dwUserId);

                int nImageId = atoi((LPCTSTR)(*pstrUserInfo)[3]);
                m_wndOutlookBar.InsertItem(1, j, (LPCTSTR)(*pstrUserInfo)[1], nImageId, dwUserId);

                strCount.Format(_T("我的好友 (%d/%d)"), m_OnlineFriendIdArray.GetCount(), m_pFriendIdArray->GetCount());
                m_wndOutlookBar.SetFolderText(1, (LPCTSTR)strCount);
            }
/*
            m_wndOutlookBar.RemoveItem(1, i);

            int nImageId = atoi((LPCTSTR)(*pstrUserInfo)[3]);
            m_wndOutlookBar.InsertItem(1, i, (LPCTSTR)(*pstrUserInfo)[1], nImageId, dwUserId);

            strCount.Format(_T("我的好友 (%d/%d)"), ++m_nOnlineFriends, m_wndOutlookBar.GetItemCount(1));
            m_wndOutlookBar.SetFolderText(1, (LPCTSTR)strCount);
*/
            break;
        }
    }

    m_wndOutlookBar.Invalidate();
}
开发者ID:tempbottle,项目名称:TestSet,代码行数:65,代码来源:Dlg_Chat_Clt.cpp

示例14: setFlags

void Button::init() {
    setFlags(ItemIsFocusable);

    setAcceptHoverEvents(true);
    setAcceptedMouseButtons(Qt::LeftButton);

    title = new QPixmap(size.toSize());
    title->fill(QColor(0, 0, 0, 0));
    QPainter pt(title);
    pt.setFont(font);
    pt.setPen(Config.TextEditColor);
    pt.setRenderHint(QPainter::TextAntialiasing);
    pt.drawText(boundingRect(), Qt::AlignCenter, label);

    title_item = new QGraphicsPixmapItem(this);
    title_item->setPixmap(*title);
    title_item->show();

    QGraphicsDropShadowEffect *de = new QGraphicsDropShadowEffect;
    de->setOffset(0);
    de->setBlurRadius(12);
    de->setColor(QColor(255, 165, 0));

    title_item->setGraphicsEffect(de);

    QImage bgimg("image/system/button/button.png");
    outimg = new QImage(size.toSize(), QImage::Format_ARGB32);

    qreal pad = 10;

    int w = bgimg.width();
    int h = bgimg.height();

    int tw = outimg->width();
    int th = outimg->height();

    qreal xc = (w - 2 * pad) / (tw - 2 * pad);
    qreal yc = (h - 2 * pad) / (th - 2 * pad);

    for (int i = 0; i < tw; i++) {
        for (int j = 0; j < th; j++) {
            int x = i;
            int y = j;

            if (x >= pad && x <= (tw - pad))
                x = pad + (x - pad) * xc;
            else if (x >= (tw - pad))
                x = w - (tw - x);

            if (y >= pad && y <= (th - pad))
                y = pad + (y - pad) * yc;
            else if (y >= (th - pad))
                y = h - (th - y);


            QRgb rgb = bgimg.pixel(x, y);
            outimg->setPixel(i, j, rgb);
        }
    }

    QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
    effect->setBlurRadius(5);
    effect->setOffset(this->boundingRect().height() / 7.0);
    effect->setColor(QColor(0, 0, 0, 200));
    this->setGraphicsEffect(effect);

    glow = 0;
    timer_id = 0;
}
开发者ID:tangjs520,项目名称:QSanguoshaForDadao,代码行数:69,代码来源:button.cpp

示例15: evaluateDataDefinedProperty


//.........这里部分代码省略.........
    double offsetX = 0;
    double offsetY = 0;
    markerOffset( *context, offsetX, offsetY );
    QPointF off( offsetX, offsetY );

    //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
    double rotation = 0.0;
    if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) )
    {
        context->setOriginalValueVariable( mAngle );
        rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, *context, mAngle ).toDouble() + mLineAngle;
    }
    else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
    {
        rotation = mAngle + mLineAngle;
    }
    rotation = -rotation; //rotation in Qt is counterclockwise
    if ( rotation )
        off = _rotatedOffset( off, rotation );

    QTransform t;
    t.translate( shift.x() + offsetX, shift.y() + offsetY );

    if ( !qgsDoubleNear( rotation, 0.0 ) )
        t.rotate( rotation );

    double halfWidth = symbolWidth / 2.0;
    double halfHeight = symbolHeight / 2.0;

    if ( symbolName == "circle" )
    {
        if ( qgsDoubleNear( halfWidth, halfHeight ) )
        {
            QPointF pt( t.map( QPointF( 0, 0 ) ) );
            e.writeFilledCircle( layerName, oc, pt, halfWidth );
        }
        else
        {
            QgsPolyline line;
            line.reserve( 40 );
            double stepsize = 2 * M_PI / 40;
            for ( int i = 0; i < 39; ++i )
            {
                double angle = stepsize * i;
                double x = halfWidth * cos( angle );
                double y = halfHeight * sin( angle );
                QPointF pt( t.map( QPointF( x, y ) ) );
                line.push_back( pt );
            }
            //close ellipse with first point
            line.push_back( line.at( 0 ) );
            if ( mBrush.style() != Qt::NoBrush )
                e.writePolygon( QgsPolygon() << line, layerName, "SOLID", fc );
            if ( mPen.style() != Qt::NoPen )
                e.writePolyline( line, layerName, "CONTINUOUS", oc, outlineWidth );
        }
    }
    else if ( symbolName == "rectangle" )
    {
        QgsPolygon p( 1 );
        p[0].resize( 5 );
        p[0][0] = t.map( QPointF( -halfWidth, -halfHeight ) );
        p[0][1] = t.map( QPointF( halfWidth, -halfHeight ) );
        p[0][2] = t.map( QPointF( halfWidth, halfHeight ) );
        p[0][3] = t.map( QPointF( -halfWidth, halfHeight ) );
        p[0][4] = p[0][0];
开发者ID:ar-jan,项目名称:QGIS,代码行数:67,代码来源:qgsellipsesymbollayerv2.cpp


注:本文中的pt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。