CRect CXFrame::GetScreenRect() { CPoint pt(m_rcPaint.TopLeft()); ::ClientToScreen(GetHwnd(),&pt); CRect rcScreen(pt.x,pt.y,pt.x + m_rcPaint.Width(),pt.y + m_rcPaint.Height()); return rcScreen; }
void CInvestigatorPopupWnd::MoveIntoPosition() { //get the various window rectangles CRect rcClientArea; ::GetWindowRect( ((CMainFrame*)AfxGetMainWnd())->m_hWndMDIClient, &rcClientArea ); CRect rcScreen( 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) ); //calculate the size of the font to be used CalcFontSizes(); m_nWidth = m_nMaxCharWidth * 16; m_nHeight = m_nCharHeight * 8; //set up window size int x, y; x = rcClientArea.right - m_nWidth - 16; y = rcClientArea.bottom - m_nHeight - 16; //load previous position x = AfxGetApp()->GetProfileInt( "WindowPos", "InvestigatorInfoX", x ); y = AfxGetApp()->GetProfileInt( "WindowPos", "InvestigatorInfoY", y ); //don't let it go off the screen if( x < 0 ) x = 0; if( y < 0 ) y = 0; if( x + m_nWidth > rcScreen.right ) x = rcScreen.right - m_nWidth; if( y + m_nHeight > rcScreen.bottom ) y = rcScreen.bottom - m_nHeight; //set the new window size and position CRect rc( 0, 0, m_nWidth, m_nHeight ); rc.OffsetRect( x, y ); //move the window MoveWindow( rc ); }
bool ListPage::Show() { if (m_osdRegionIndex == 0) { Rect rcScreen(0,0,720, 576); m_osdRegionIndex = rcScreen.CreateRegion(true); TRACE1("Created OSD region, index = %d\n", m_osdRegionIndex); } if (m_osdRegionIndex == 0) return false; return Draw(); }
////////////////// // Restore window placement from profile key BOOL CWindowPlacement::Restore(LPCTSTR lpKeyName, CWnd* pWnd) { GetProfileWP(lpKeyName); // Only restore if window intersets the screen. // CRect rcTemp, rcScreen(0,0,GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); if (!::IntersectRect(&rcTemp, &rcNormalPosition, &rcScreen)) return FALSE; pWnd->SetWindowPlacement(this); // set placement return TRUE; }
////////////////// // Create bitmap from contents of screen rectangle // This must be called right after creating a bitmap using the // default constructor; e.g. // WPBitmap foo; // foo.copyScreen(myrect); // void WPBitmap::copyScreen(WPRect &rc) { WPDisplay dcScreen; // the whole display // Intersect rectangle with screen dimensions WPRect rcScreen((WPWin*)NULL); rc &= rcScreen; // Initialize bitmap to appropriate size destroy(); hobj = CreateCompatibleBitmap(dcScreen, rc.width(), rc.height()); assert(hobj); del = TRUE; init(); // Copy the bits WPMemDC dcMem(&dcScreen, this); WPRect rcDst(0,0,rc.width(),rc.height()); dcMem.bitBlt(rcDst, dcScreen, rc.origin()); }
//----------------------------- FUNCTION -------------------------------------* BOOL CWindowPlacement::Restore(LPCTSTR pszKeyName, CWnd* pWnd) /*>>>> Restore window placement from profile key Result TRUE if restore was ok <<<<*/ { GetProfileWP(pszKeyName); // Only restore if window intersects the screen. // CRect rcTemp, rcScreen(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); if (!::IntersectRect(&rcTemp, &rcNormalPosition, &rcScreen)) { return FALSE; } showCmd = SW_HIDE; pWnd->SetWindowPlacement(this); // set placement return TRUE; }
void CCoolMenu::OnDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CRect rcItem, rcText; CString strText; int nIcon = -1; CDC dc; BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED; BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED; BOOL bKeyboard = FALSE; BOOL bEdge = TRUE; dc.Attach( lpDrawItemStruct->hDC ); if ( CWnd* pWnd = dc.GetWindow() ) { CRect rcScreen( &lpDrawItemStruct->rcItem ); CPoint ptCursor; GetCursorPos( &ptCursor ); pWnd->ClientToScreen( &rcScreen ); bKeyboard = ! rcScreen.PtInRect( ptCursor ); } rcItem.CopyRect( &lpDrawItemStruct->rcItem ); rcItem.OffsetRect( -rcItem.left, -rcItem.top ); if ( m_hMsgHook != NULL ) rcItem.bottom += ( bEdge = m_bPrinted ); rcText.CopyRect( &rcItem ); rcText.left += 32; rcText.right -= 2; CDC* pDC = CoolInterface.GetBuffer( dc, rcItem.Size() ); if ( m_bmWatermark.m_hObject != NULL ) { DrawWatermark( pDC, &rcItem, lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top ); } else { pDC->FillSolidRect( rcItem.left, rcItem.top, 24, rcItem.Height(), CoolInterface.m_crMargin ); pDC->FillSolidRect( rcItem.left + 24, rcItem.top, rcItem.Width() - 24, rcItem.Height(), CoolInterface.m_crBackNormal ); } if ( m_pStrings.Lookup( lpDrawItemStruct->itemData, strText ) == FALSE ) { int nMiddle = rcText.top + 1; pDC->FillSolidRect( rcText.left, nMiddle, rcText.Width() + 2, 1, CoolInterface.m_crDisabled ); dc.BitBlt( lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top, rcItem.Width(), rcItem.Height(), pDC, 0, 0, SRCCOPY ); dc.Detach(); return; } if ( bSelected ) { if ( ! bDisabled ) { pDC->Draw3dRect( rcItem.left + 1, rcItem.top + 1, rcItem.Width() - 2, rcItem.Height() - 1 - bEdge, CoolInterface.m_crBorder, CoolInterface.m_crBorder ); pDC->FillSolidRect( rcItem.left + 2, rcItem.top + 2, rcItem.Width() - 4, rcItem.Height() - 3 - bEdge, CoolInterface.m_crBackSel ); pDC->SetBkColor( CoolInterface.m_crBackSel ); } else if ( bKeyboard ) { pDC->Draw3dRect( rcItem.left + 1, rcItem.top + 1, rcItem.Width() - 2, rcItem.Height() - 1 - bEdge, CoolInterface.m_crBorder, CoolInterface.m_crBorder ); pDC->FillSolidRect( rcItem.left + 2, rcItem.top + 2, rcItem.Width() - 4, rcItem.Height() - 3 - bEdge, CoolInterface.m_crBackNormal ); pDC->SetBkColor( CoolInterface.m_crBackNormal ); } } else { pDC->SetBkColor( CoolInterface.m_crBackNormal ); } if ( bChecked ) { pDC->Draw3dRect( rcItem.left + 2, rcItem.top + 2, 20, rcItem.Height() - 3 - bEdge, CoolInterface.m_crBorder, CoolInterface.m_crBorder ); pDC->FillSolidRect( rcItem.left + 3, rcItem.top + 3, 18, rcItem.Height() - 5 - bEdge, ( bSelected && !bDisabled ) ? CoolInterface.m_crBackCheckSel : CoolInterface.m_crBackCheck ); } nIcon = CoolInterface.ImageForID( (DWORD)lpDrawItemStruct->itemID ); if ( bChecked && nIcon < 0 ) nIcon = m_nCheckIcon; if ( nIcon >= 0 ) { CPoint pt( rcItem.left + 4, rcItem.top + 4 ); if ( bDisabled ) { ImageList_DrawEx( CoolInterface.m_pImages.m_hImageList, nIcon, pDC->GetSafeHdc(), pt.x, pt.y, 0, 0, CLR_NONE, CoolInterface.m_crDisabled, CM_DISABLEDBLEND ); } else if ( bChecked ) { CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_TRANSPARENT ); } else if ( bSelected ) { pt.Offset( 1, 1 ); pDC->SetTextColor( CoolInterface.m_crShadow ); CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_MASK ); pt.Offset( -2, -2 ); CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_TRANSPARENT ); } else { ImageList_DrawEx( CoolInterface.m_pImages.m_hImageList, nIcon, pDC->GetSafeHdc(), pt.x, pt.y, 0, 0, CLR_NONE, CoolInterface.m_crMargin, ILD_BLEND25 ); } } CFont* pOld = (CFont*)pDC->SelectObject( ( lpDrawItemStruct->itemState & ODS_DEFAULT ) && ! bDisabled ? &CoolInterface.m_fntBold : &CoolInterface.m_fntNormal ); pDC->SetBkMode( TRANSPARENT ); pDC->SetTextColor( bDisabled ? CoolInterface.m_crDisabled : ( bSelected ? CoolInterface.m_crCmdTextSel : CoolInterface.m_crCmdText ) ); DrawMenuText( pDC, &rcText, strText ); pDC->SelectObject( pOld ); dc.BitBlt( lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top, rcItem.Width(), rcItem.Height(), pDC, 0, 0, SRCCOPY ); dc.Detach(); }
QSoftKeyDesignToolWidget::QSoftKeyDesignToolWidget(QVector<CSoftkey*>* pSelectedKeys, QWidget *parent) : QDialog(parent), ui(new Ui::SoftKeyDesignToolWidget) { ui->setupUi(this); setWindowFlags( Qt::Tool | Qt::WindowStaysOnTopHint ); m_dD2PScaleWidth = 0.0; m_dD2PScaleHeight = 0.0; m_eUnit = UnitRes; m_pvSelectedKeys = pSelectedKeys; ui->BtnRemove->setEnabled( false ); ui->BtnGroup->setEnabled( false ); ui->BtnUngroup->setEnabled( false ); ui->BtnReorder->setEnabled( false ); ui->EditName->setEnabled( false ); ui->CBVisible->setEnabled( false ); ui->EditPosX->setEnabled( false ); ui->EditPosY->setEnabled( false ); ui->EditWidth->setEnabled( false ); ui->EditHeight->setEnabled( false ); m_pLayoutToolWidget = new QLayoutToolWidget( pSelectedKeys, this ); m_pLayoutToolWidget->hide(); connect( m_pLayoutToolWidget, &QLayoutToolWidget::generateKeys, this, &QSoftKeyDesignToolWidget::generateKeys ); connect( m_pLayoutToolWidget, &QLayoutToolWidget::alignSelectedKeys, this, &QSoftKeyDesignToolWidget::alignSelectedKeys ); connect( m_pLayoutToolWidget, &QLayoutToolWidget::adjustSizeSelectedKeys, this, &QSoftKeyDesignToolWidget::adjustSizeSelectedKeys ); connect( m_pLayoutToolWidget, &QLayoutToolWidget::distribSelectKeys, this, &QSoftKeyDesignToolWidget::distribSelectKeys ); connect( m_pLayoutToolWidget, &QLayoutToolWidget::reorderKeys, this, &QSoftKeyDesignToolWidget::reorderKeys ); connect( m_pLayoutToolWidget, &QLayoutToolWidget::updateLayoutButton, this, &QSoftKeyDesignToolWidget::onUpdateLayoutButton ); connect( this, &QSoftKeyDesignToolWidget::closeWidget, m_pLayoutToolWidget, &QLayoutToolWidget::close ); QSettings settings( "Habilience", "T3kSoftlogic" ); settings.beginGroup( "Windows" ); QString strPos = settings.value( "SoftkeyDesignTool_Pos" ).toString(); settings.endGroup(); QDesktopWidget desktop; QRect rcScreen( desktop.screenGeometry( desktop.primaryScreen() ) ); if( !strPos.isEmpty() ) { QRect rcWin; QString str; int nD; do { nD = strPos.indexOf(','); if ( nD <= 0 ) break; str = strPos.left(nD); strPos = strPos.mid(nD + 1); rcWin.setLeft( str.toLong() ); nD = strPos.indexOf(','); if ( nD <= 0 ) break; str = strPos.left(nD); strPos = strPos.mid(nD + 1); rcWin.setTop( str.toLong() ); nD = strPos.indexOf(','); if ( nD <= 0 ) break; str = strPos.left(nD); strPos = strPos.mid(nD + 1); rcWin.setRight( str.toLong() ); rcWin.setBottom( strPos.toLong() ); rcWin = rcWin.normalized(); if ( rcScreen.intersects( rcWin ) ) move( rcWin.left(), rcWin.top() ); else move( rcScreen.center() - QRect(0,0,width(),height()).center() ); } while ( false ); } else { move( rcScreen.center() - QRect(0,0,width(),height()).center() ); } ui->CBUnit->clear(); ui->CBUnit->addItem( "res", UnitRes ); ui->CBUnit->addItem( "mm", UnitMM ); if ( (m_dD2PScaleWidth != 0.0) && (m_dD2PScaleHeight != 0.0) ) { ui->CBUnit->setVisible( true ); ui->CBUnit->setCurrentIndex( 1 ); m_eUnit = UnitMM; } else { ui->CBUnit->setVisible( false ); m_eUnit = UnitRes; } m_pLayoutToolWidget->setUnit( m_eUnit, m_dD2PScaleWidth, m_dD2PScaleHeight ); ui->CBVisible->addItem( "True" ); ui->CBVisible->addItem( "False" ); ui->CBVisible->setEnabled( false ); ui->EditName->setEnabled( false ); ui->BtnShowToolbar->setText( m_pLayoutToolWidget->isVisible() ? "Hide Layout ToolBar" : "Show Layout ToolBar" ); ui->EditPosX->setInputMethodHints( Qt::ImhDialableCharactersOnly ); ui->EditPosY->setInputMethodHints( Qt::ImhDialableCharactersOnly ); ui->EditWidth->setInputMethodHints( Qt::ImhDialableCharactersOnly ); ui->EditHeight->setInputMethodHints( Qt::ImhDialableCharactersOnly ); updateUnit(); }
bool CNetLayer::NetEnd(Node *node, int tag) { Point ptNet; Point ptTNet; Point ptFish; Size szFish; Point ptDifference; Rect rcScreen(0,0,1280,738); float sint, cost; CGameScene *pGameScene = (CGameScene *)parent(); CNetObjectExtend *pNetObjectExtend = (CNetObjectExtend *)node->node_extend(); if (pNetObjectExtend->wChairID == pGameScene->GetMeChairID() || pGameScene->IsAndroidLogicChairID()) { CMD_C_Cast_Net CastNet; CastNet.wChairID = pNetObjectExtend->wChairID; CastNet.cbCount = 0; ptNet = node->position(); Nodes::iterator j=pGameScene->m_layFishObject->child_begin(); for (; j!=pGameScene->m_layFishObject->child_end(); ++j) { if (CastNet.cbCount >= MAX_FISH_IN_NET) break; CFishObjectExtend *pFishObjectExtend = (CFishObjectExtend *)(*j)->node_extend(); if (pFishObjectExtend->wID == INVALID_WORD) continue; ptFish = (*j)->position(); szFish = pFishObjectExtend->GetFishObjectSize(); cost = std::cosf((*j)->rotation()); sint = std::sinf((*j)->rotation()); ptTNet.x_ = (ptNet.x_-ptFish.x_)*cost + (ptNet.y_-ptFish.y_)*sint; ptTNet.y_ = -(ptNet.x_-ptFish.x_)*sint + (ptNet.y_-ptFish.y_)*cost; if (CFishObjectExtend::ComputeCollision(szFish.width_, szFish.height_, pNetObjectExtend->GetNetRadius(), ptTNet.x_, ptTNet.y_ )) { CastNet.FishNetObjects[CastNet.cbCount].wID = pFishObjectExtend->wID; CastNet.FishNetObjects[CastNet.cbCount].wRoundID = pFishObjectExtend->wRoundID; CastNet.FishNetObjects[CastNet.cbCount].wType = pFishObjectExtend->FishType; CastNet.FishNetObjects[CastNet.cbCount].dwTime = pFishObjectExtend->dwTime; CastNet.cbCount++; } } CClientKernel *pClientKernel = pGameScene->GetClientKernel(); if (pClientKernel != NULL) pClientKernel->SendSocketData(MDM_GF_GAME, SUB_C_CAST_NET, &CastNet, sizeof(CMD_C_Cast_Net)-(MAX_FISH_IN_NET-CastNet.cbCount)*sizeof(Fish_Net_Object)); } remove_child(node); return true; }