WinPoint GetClusterPoint(CMapPVCluster* pcluster) { WinPoint pt = WinPoint( (int)(m_rectMap.XMin() + ((pcluster->GetScreenX() - m_xMin)/(m_xMax - m_xMin))*(m_rectMap.XSize() - 2*c_nXBorder) + c_nXBorder), (int)(m_rectMap.YMin() + ((pcluster->GetScreenY() - m_yMin)/(m_yMax - m_yMin))*(m_rectMap.YSize() - 2*c_nYBorder) + c_nYBorder) ); return pt; }
void DrawItem(Surface* pSurface, const WinRect& rect, bool fSelected, int iFirstSlot) { IEngineFont* pfont = m_pchatInfo->IsFromLeader() ? TrekResources::SmallBoldFont() : TrekResources::SmallFont(); WinPoint pt(rect.Min() + WinPoint(3,3)); for ( int i = iFirstSlot; i < m_vMsgLines.GetCount() && pt.Y() < rect.YMax(); i++ ) { pSurface->DrawString(pfont, m_pchatInfo->GetColor(), pt, m_vMsgLines[i]); pt += WinPoint(0, m_ptLineSize.Y()); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// // GenerateFillVerticesD3DColor() // //////////////////////////////////////////////////////////////////////////////////////////////////// void CVertexGenerator::GenerateFillVerticesD3DColor( const WinRect & rectToFill, const bool bSetStream, D3DCOLOR d3dColor ) { UICOLOURFILLVERTEX * pVertArray; if( CVBIBManager::Get()->LockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB], 4, (void**) &pVertArray ) == false ) { // Failed to lock the vertex buffer. _ASSERT( false ); return; } // 2d texturing, adjust the vertex positions slightly. float fMinX, fMinY, fMaxX, fMaxY; fMinX = (float) rectToFill.Min().X() - 0.5f; fMinY = (float) rectToFill.Min().Y() - 0.5f; fMaxX = (float) rectToFill.Max().X() - 0.5f; fMaxY = (float) rectToFill.Max().Y() - 0.5f; pVertArray[0].x = fMinX; pVertArray[0].y = fMinY; pVertArray[0].z = 0.5f; pVertArray[0].rhw = 1.0f; pVertArray[0].color = d3dColor; pVertArray[1].x = fMaxX; pVertArray[1].y = fMinY; pVertArray[1].z = 0.5f; pVertArray[1].rhw = 1.0f; pVertArray[1].color = d3dColor; pVertArray[2].x = fMinX; pVertArray[2].y = fMaxY; pVertArray[2].z = 0.5f; pVertArray[2].rhw = 1.0f; pVertArray[2].color = d3dColor; pVertArray[3].x = fMaxX; pVertArray[3].y = fMaxY; pVertArray[3].z = 0.5f; pVertArray[3].rhw = 1.0f; pVertArray[3].color = d3dColor; // Finished adding verts, unlock. CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] ); if( bSetStream == true ) { CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] ); } }
void Paint(Surface* pSurface) { if (m_pImageBkgnd) pSurface->BitBlt(WinPoint(0, 0), m_pImageBkgnd->GetSurface(), WinRect(m_ptImgOrigin.X(), m_ptImgOrigin.Y(), m_ptImgOrigin.X() + XSize(), m_ptImgOrigin.Y() + YSize())); // calc num Items to draw int iLastVisibleItem = LastVisibleItem(); int iLastItem = m_vItems.GetCount() - 1; if (iLastVisibleItem > iLastItem) iLastVisibleItem = iLastItem; // draw each Item WinRect rectPaint = WinRect(0, 0, m_nItemWidth, YSize()); WinRect rectItem = rectPaint; rectItem.bottom = rectItem.top; ZAssert(m_iTopItem >= 0); // count the number of slots for the first item which we are not drawing int nNumHiddenSlots = 0; if (m_vItems.GetCount() > 0) { while (m_iTopItem - nNumHiddenSlots > 0 && m_vItems[m_iTopItem - (nNumHiddenSlots + 1)] == m_vItems[m_iTopItem]) nNumHiddenSlots++; for (int iItem = m_iTopItem; iItem <= iLastVisibleItem; iItem += m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots, nNumHiddenSlots = 0) { rectItem.top = rectItem.bottom; int nLinesLeft = (iLastVisibleItem - iItem) + 1; int nLines = m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots; rectItem.bottom += m_nItemHeight * (nLines > nLinesLeft ? nLinesLeft : nLines); // draw highlight if selected bool bItemSel = (m_iSelItem == iItem); if (bItemSel && m_pImageBkgndSel) pSurface->BitBlt(rectItem.Min(), m_pImageBkgndSel->GetSurface(), rectItem); // draw item m_vItems[iItem]->DrawItem(pSurface, rectItem, bItemSel, nNumHiddenSlots); } } }
void SetImage(Image* pimage, const WinRect& rect) { m_pimage = pimage; if (rect.Size() != GetSize()) NeedLayout(); NeedPaint(); }
void DrawItem(Surface* pSurface, const WinRect& rect, bool fSelected, int iFirstSlot) { int data = (int)this; char buf[30]; sprintf(buf,"%d", data); pSurface->DrawString(TrekResources::SmallFont(), Color::White(), rect.Min(), buf); }
void MouseMove(IInputProvider* pprovider, const Point& point, bool bCaptured, bool bInside) { if (bCaptured) { ZAssert(m_bDragging && m_bCanDrag); float fScale = (m_xMax - m_xMin)/m_rectMap.XSize(); float fDeltaX = fScale * (m_pointLastDrag.X() - point.X()); float fDeltaY = fScale * (m_pointLastDrag.Y() - point.Y()); // make sure we don't drag the map off of the screen m_xDrag = max(min((m_xClusterMax - m_xClusterMin) - (m_xMax - m_xMin), m_xDrag + fDeltaX), 0); m_yDrag = max(min((m_yClusterMax - m_yClusterMin) - (m_yMax - m_yMin), m_yDrag + fDeltaY), 0); m_pointLastDrag = point; GetWindow()->SetCursor(AWF_CURSOR_DRAG); Changed(); } else { if (m_bCanDrag) { GetWindow()->SetCursor(AWF_CURSOR_DRAG); } else { GetWindow()->SetCursor(AWF_CURSOR_DEFAULT); } } Changed(); }
void ImagemapDlg::SetDPI(SelectionType stExportArea, double dDPI) { //First we need to get the bounding box of the area to export DocRect rectBounds=ImagemapFilterOptions::GetSizeOfExportArea(stExportArea); //And scale it by the DPI we have been given. The easiest //way to do this is to use this function Matrix Identity; WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, rectBounds, dDPI ); //Then set the result into the width and height fields ImagemapDlg::DontHandleNextMessage=TRUE; SetLongGadgetValue(_R(IDC_IMAGEMAP_WIDTH), Rect.Width()); ImagemapDlg::DontHandleNextMessage=TRUE; SetLongGadgetValue(_R(IDC_IMAGEMAP_HEIGHT), Rect.Height()); }
//////////////////////////////////////////////////////////////////////////////////////////////////// // PaintAll() // Paint this panes surface, then paint any children. // Note: the function ::Paint(), is overloaded by any class derived from Pane. // Added: pass the clip rect round, as with the others, pass by copy, as this can then be modified // and passed to child panes. //////////////////////////////////////////////////////////////////////////////////////////////////// void Pane::PaintAll( Surface * psurface ) { // Clipping test - TBD: reinstate. /* if( ( rectClip.XMax() <= rectClip.XMin() ) || ( rectClip.YMax() <= rectClip.YMin() ) || ( rectClip.XMax() < 0 ) || ( rectClip.YMax() < 0 ) ) { return; }*/ if( !m_bHidden ) { Paint( psurface ); for(Pane* ppane = m_pchild; ppane != NULL; ppane = ppane->m_pnext) { WinRect rectClipOld = psurface->GetClipRect(); psurface->Offset(ppane->m_offset); psurface->SetClipRect(WinRect(WinPoint(0, 0), ppane->GetSize())); D3DVIEWPORT9 newViewport, oldViewport; CD3DDevice9::Get()->GetViewport( &oldViewport ); WinRect surfClip = psurface->GetClipRect(); WinPoint surfOffset = psurface->GetOffset(); newViewport.X = surfClip.XMin() + surfOffset.X(); newViewport.Y = surfClip.YMin() + surfOffset.Y(); newViewport.Width = surfClip.XMax() - surfClip.XMin(); newViewport.Height = surfClip.YMax() - surfClip.YMin(); newViewport.MinZ = oldViewport.MinZ; newViewport.MaxZ = oldViewport.MaxZ; newViewport.X = (int) newViewport.X < 0 ? 0 : newViewport.X; newViewport.Y = (int) newViewport.Y < 0 ? 0 : newViewport.Y; newViewport.Width = (int) newViewport.Width < 0 ? 0 : newViewport.Width; newViewport.Height = (int) newViewport.Height < 0 ? 0 : newViewport.Height; if( ( newViewport.Width > 0 ) && ( newViewport.Height > 0 ) ) { CD3DDevice9::Get()->SetViewport( &newViewport ); ppane->PaintAll( psurface ); } psurface->Offset(-ppane->m_offset); psurface->RestoreClipRect(rectClipOld); if( ( newViewport.Width > 0 ) && ( newViewport.Height > 0 ) ) { CD3DDevice9::Get()->SetViewport( &oldViewport ); } } m_bNeedPaint = false; m_bPaintAll = false; } }
void UpdateLayout() { InternalSetSize(m_rect.Size()); Pane::UpdateLayout(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// // GenerateUITexturedVertices() // //////////////////////////////////////////////////////////////////////////////////////////////////// void CVertexGenerator::GenerateUITexturedVertices( const TEXHANDLE hTexture, const WinRect & rectToDraw, const bool bSetStream ) { _ASSERT( hTexture != INVALID_TEX_HANDLE ); float fMinX, fMinY, fMaxX, fMaxY; float fU1, fV1; DWORD dwWidth, dwHeight; UIVERTEX * pVertArray; CVRAMManager::Get()->GetOriginalDimensions( hTexture, &dwWidth, &dwHeight ); if( CVBIBManager::Get()->LockDynamicVertexBuffer( // &m_sVGState.hUITexVertsVB, &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB], 4, (void**) &pVertArray ) == false ) { // Failed to lock the vertex buffer. _ASSERT( false ); return; } // 2d texturing, adjust the vertex positions slightly. fMinX = (float) rectToDraw.Min().X() - 0.5f; fMinY = (float) rectToDraw.Min().Y() - 0.5f; fMaxX = (float) rectToDraw.Max().X() - 0.5f; fMaxY = (float) rectToDraw.Max().Y() - 0.5f; // Calculate our uv coords. fU1 = 1.0f; fV1 = 1.0f; if( rectToDraw.XSize() < (int)dwWidth ) { fU1 = (float) rectToDraw.XSize() / (float) dwWidth; } if( rectToDraw.YSize() < (int)dwHeight ) { fV1 = (float) rectToDraw.YSize() / (float) dwHeight; } pVertArray[0].x = fMinX; pVertArray[0].y = fMinY; pVertArray[0].z = 0.5f; pVertArray[0].rhw = 1.0f; pVertArray[0].fU = 0.0f; pVertArray[0].fV = 0.0f; pVertArray[1].x = fMaxX; pVertArray[1].y = fMinY; pVertArray[1].z = 0.5f; pVertArray[1].rhw = 1.0f; pVertArray[1].fU = fU1; pVertArray[1].fV = 0.0f; pVertArray[2].x = fMinX; pVertArray[2].y = fMaxY; pVertArray[2].z = 0.5f; pVertArray[2].rhw = 1.0f; pVertArray[2].fU = 0.0f; pVertArray[2].fV = fV1; pVertArray[3].x = fMaxX; pVertArray[3].y = fMaxY; pVertArray[3].z = 0.5f; pVertArray[3].rhw = 1.0f; pVertArray[3].fU = fU1; pVertArray[3].fV = fV1; // Finished adding verts, unlock. CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] ); if( bSetStream == true ) { CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] ); } }
void CalculateScreenMinAndMax() { // map the sector data bool bFirstCluster = true; const ClusterPVList* clusters = m_missionpv.GetClusters(); for (ClusterPVLink* cLink = clusters->first(); cLink != NULL; cLink = cLink->next()) { CMapPVCluster* pCluster = cLink->data(); if (true) // pCluster->GetModels()->n() != 0 { float x = pCluster->GetScreenX(); float y = pCluster->GetScreenY(); if (bFirstCluster) { bFirstCluster = false; m_xClusterMin = m_xClusterMax = x; m_yClusterMin = m_yClusterMax = y; } else { if (x < m_xClusterMin) m_xClusterMin = x; else if (x > m_xClusterMax) m_xClusterMax = x; if (y < m_yClusterMin) m_yClusterMin = y; else if (y > m_yClusterMax) m_yClusterMax = y; } } } const float c_bfr = 0.1f * max(0.0001, max(m_xClusterMax - m_xClusterMin, m_yClusterMax - m_yClusterMin)); m_xClusterMin -= c_bfr; m_xClusterMax += c_bfr; m_yClusterMin -= c_bfr; m_yClusterMax += c_bfr; // figure out the minimum and maximum screen coordinates m_xMin = m_xClusterMin; m_xMax = m_xClusterMax; m_yMin = m_yClusterMin; m_yMax = m_yClusterMax; float fDesiredAspectRatio = float(m_rectMap.XSize() - 2*c_nXBorder)/(m_rectMap.YSize() - 2*c_nYBorder); // scale it so that a map with height 2 will fit exactly const float fMapmakerHeight = 2.2f; // 10% fudge factor const float fMaxHeight = fMapmakerHeight; const float fMaxWidth = fMaxHeight * fDesiredAspectRatio; // if the map is bigger than we want to display, clip the view to the max size if (m_xMax - m_xMin > fMaxWidth || m_yMax - m_yMin > fMaxHeight) { m_bCanDrag = true; m_xMax = m_xMin + min(m_xMax - m_xMin, fMaxWidth); m_yMax = m_yMin + min(m_yMax - m_yMin, fMaxHeight); } else { m_bCanDrag = false; } //Preserve the aspect ratio float fAspectRatio = (m_xMax - m_xMin) / (m_yMax - m_yMin); if (fAspectRatio < fDesiredAspectRatio) { // grow the X size to correct the aspect ratio float fXGrowth = (fDesiredAspectRatio / fAspectRatio - 1) * (m_xMax - m_xMin); m_xMax += fXGrowth / 2; m_xMin -= fXGrowth / 2; } else if (fAspectRatio > fDesiredAspectRatio) { // grow the Y size to correct the aspect ratio float fYGrowth = (fAspectRatio / fDesiredAspectRatio - 1) * (m_yMax - m_yMin); m_yMax += fYGrowth / 2; m_yMin -= fYGrowth / 2; } // translate by the current drag offset m_xMin += m_xDrag; m_xMax += m_xDrag; m_yMin += m_yDrag; m_yMax += m_yDrag; }
void Window::SetClientSize(const WinPoint& point) { WinRect rect = GetClientRect(); rect.SetSize(point); SetClientRect(rect); }
void Window::SetRect(const WinRect& rect) { MoveWindow(m_hwnd, rect.XMin(), rect.YMin(), rect.XSize(), rect.YSize(), true); }