void CBrowser::DrawItems(const SRect RectUpdate, const std::list<SItem*>& Items, SPos& Pos) { SSize SizeBitmap; mpArrow->GetRealSize(SizeBitmap); tint32 iNrOfItems = Items.size(); std::list<SItem*>::const_iterator it = Items.begin(); tint32 iItem; for (iItem = 0; iItem < iNrOfItems; iItem++, it++) { SItem* pItem = *it; if (pItem->bFolder) { // Item is folder DrawBitmapFrame(mpArrow, RectUpdate, SRect(Pos, SizeBitmap), pItem->bFolderIsOpen ? 1 : 0, 2); } SPos PosText = Pos + mTextPosition; SSize SizeText; SizeText.iCY = mpFont->GetTextHeight(); SizeText.iCX = mpFont->GetTextWidth((tchar*)(pItem->sNameModified.c_str())); DrawFont(mpFont, RectUpdate, SRect(PosText, SizeText), (const tchar*)(pItem->sNameModified.c_str())); if (pItem == mpItemSelected) { // This is the selected item SRect RectInvert(GetPos(), SizeText); RectInvert.iY = PosText.iY - 1; RectInvert.iCY += 1; RectInvert.iCX = GetSize().iCX; mpPrimitives->InvertRect(RectUpdate, RectInvert); } Pos.iY += miSpaceBetweenItems; if (pItem->bFolder) { if (pItem->bFolderIsOpen) { tint iX = Pos.iX; Pos.iX += miSpaceBetweenFolders; DrawItems(RectUpdate, pItem->SubItems, Pos); Pos.iX = iX; } } } }
void EldritchFramework::SetMainViewTransform( const Vector& Location, const Angles& Orientation ) { m_MainView->m_Location = Location; m_MainView->m_Rotation = Orientation; m_FGView->m_Location = Location; m_FGView->m_Rotation = Orientation; m_Audio3DListener->SetLocation( Location ); m_Audio3DListener->SetRotation( Orientation ); #if COOL_SIDE_VIEW_THING new( m_FGView ) View( Vector(), Vector(), SRect(), 0.0f, 0.0f ); new( m_MainView ) View( Vector( 25.0f, 25.0f, 13.0f ), Vector( 0.0f, 1.0f, 0.0f ), SRect( -25.0f, 13.0f, 25.0f, -13.0f ), 0.0f, 50.0f ); #endif }
void CBitmap::OnDraw(const SRect &rUpdate) { if( !IsVisible() ) return; if (mSize == mSizeBitmap) { // Size of control equals size of bitmap DrawBitmapFrame(GetBitmapResource(), rUpdate, SRect(GetPos(), mSizeBitmap), miFrameCur, miFrames); } else { if (mSize.iCX < mSizeBitmap.iCX) { DrawBitmapFrame(GetBitmapResource(), rUpdate, SRect(GetPos(), mSize), miFrameCur, miFrames); } else if (mSize.iCY < mSizeBitmap.iCY) { DrawBitmapFrame(GetBitmapResource(), rUpdate, SRect(GetPos(), mSize), miFrameCur, miFrames); } else { SPos PosThis; GetPos(PosThis); // Size of control doesn't equal size of bitmap, so tiling is needed tint32 iYPos = rUpdate.iY - PosThis.iY - mSizeBitmap.iCY; if (iYPos < 0) { iYPos = 0; } while ((iYPos < mSize.iCY) && (PosThis.iY + iYPos < rUpdate.iY + rUpdate.iCY)) { tint32 iXPos = rUpdate.iX - PosThis.iX - mSizeBitmap.iCX; if (iXPos < 0) { iXPos = 0; } while ((iXPos < mSize.iCX) && (PosThis.iX + iXPos < rUpdate.iX + rUpdate.iCX)) { DrawBitmapFrame(GetBitmapResource(), rUpdate, SRect(PosThis + SPos(iXPos, iYPos), mSizeBitmap), miFrameCur, miFrames); iXPos += mSizeBitmap.iCX; } iYPos += mSizeBitmap.iCY; } } } }
void UIWidgetText::UpdatePosition() { MAKEHASH( m_Archetype ); MAKEHASH( m_Name ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; STATICHASH( PixelX ); STATICHASH( PixelOffsetX ); STATICHASH( ScreenX ); float X = ConfigManager::GetArchetypeFloat( sPixelOffsetX, sm_Archetype, 0.0f, sm_Name ) + Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sm_Name ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sm_Name ) ); STATICHASH( PixelY ); STATICHASH( PixelOffsetY ); STATICHASH( ScreenY ); float Y = ConfigManager::GetArchetypeFloat( sPixelOffsetY, sm_Archetype, 0.0f, sm_Name ) + Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sm_Name ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sm_Name ) ); // Get dimensions so we can do different origins Array<STypesetGlyph> UnusedTypesetting; Vector2 Dimensions; Array<unicode_t> CodePoints; GetString().UTF8ToUnicode( CodePoints ); m_Font->Arrange( CodePoints, SRect( 0.0f, 0.0f, m_WrapWidth, 0.0f ), UnusedTypesetting, Dimensions ); AdjustDimensionsToParent( X, Y, Dimensions.x, Dimensions.y, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Dimensions.x, Dimensions.y ); STATICHASH( ClampToPixelGrid ); m_ClampToPixelGrid = ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sm_Name ); if( m_ClampToPixelGrid ) { // Add 0.5 to compensate for font UVs being on half pixel intervals. m_TopLeft.x = Round( m_TopLeft.x ) + 0.5f; m_TopLeft.y = Round( m_TopLeft.y ) + 0.5f; } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; }
SRect Character::GetBoundingBox(const SVector2& renderOffset) const { return SRect ( mPosition.x - 16.0f + renderOffset.x, mPosition.y - 16.0f + renderOffset.y, mPosition.x + 16.0f + renderOffset.x, mPosition.y + 16.0f + renderOffset.y ); }
SRect Character::GetBoundingBox() const { return SRect ( mPosition.x - 16.0f, mPosition.y - 56.0f, mPosition.x + 16.0f, mPosition.y ); }
SRect CharacterJump::GetBoundingBox() const { const SVector2 pos(mpOwner->GetPosition()); return SRect ( pos.x - 16.0f, pos.y - 56.0f, pos.x + 16.0f, pos.y ); }
View::View( const Vector& Location, const Angles& Rotation, float VerticalFOV, float AspectRatio, float NearClip, float FarClip ) : m_Location( Location ) , m_Rotation( Rotation ) , m_NearClip( NearClip ) , m_FarClip( FarClip ) , m_InvRange( 0.0f ) , m_VerticalFOV( VerticalFOV ) , m_AspectRatio( AspectRatio ) , m_OrthoMode( false ) , m_Bounds( SRect( 0, 0, 640, -480 ) ) { UpdateInvRange(); }
View::View() : m_Location( 0.f, 0.f, 0.f ) , m_Rotation( 0.f, 0.f, 0.f ) , m_NearClip( .01f ) , m_FarClip( 3000.f ) , m_InvRange( 0.0f ) , m_VerticalFOV( 90.f ) , m_AspectRatio( kAspect_4_3 ) , m_OrthoMode( false ) , m_Bounds( SRect( 0, 0, 640, -480 ) ) { UpdateInvRange(); }
void EldritchFramework::CreateHUDView() { PRINTF( "EldritchFramework::CreateHUDView\n" ); SafeDelete( m_HUDView ); const float fDisplayWidth = static_cast<float>( m_DisplayWidth ); const float fDisplayHeight = static_cast<float>( m_DisplayHeight ); const Vector EyePosition = Vector( 0.0f, -1.0f, 0.0f ); const Vector EyeDirection = Vector( 0.0f, 1.0f, 0.0f ); const float NearClip = 0.01f; const float FarClip = 2.0f; m_HUDView = new View( EyePosition, EyeDirection, SRect( 0.0f, 0.0f, fDisplayWidth, fDisplayHeight ), NearClip, FarClip ); }
void UIWidgetText::UpdateRender() { // This will fail if UpdateRender is called between submitting UI meshes to the renderer and actually // rendering the scene. It may actually be safe if this widget was not submitted to the renderer. DEBUGASSERT( m_UIManager->DEBUGIsSafeToUpdateRender( m_LastRenderedTime ) ); SafeDelete( m_Mesh ); SafeDelete( m_DropShadowMesh ); IRenderer* pRenderer = m_UIManager->GetRenderer(); m_Mesh = m_Font->Print( m_String.CStr(), SRect( 0.0f, 0.0f, m_WrapWidth, 0.0f ), m_FontPrintFlags ); ASSERT( m_Mesh ); m_Mesh->m_Location = Vector( m_TopLeft.x, 0.0f, m_TopLeft.y ); m_Mesh->m_AABB.m_Min.x += m_TopLeft.x; m_Mesh->m_AABB.m_Min.z += m_TopLeft.y; m_Mesh->m_AABB.m_Max.x += m_TopLeft.x; m_Mesh->m_AABB.m_Max.z += m_TopLeft.y; m_Mesh->SetMaterialDefinition( "Material_HUD", pRenderer ); m_Mesh->SetMaterialFlags( m_RenderInWorld ? MAT_INWORLDHUD : MAT_HUD ); m_Mesh->m_ConstantColor = m_Color; if( m_HasDropShadow ) { m_DropShadowMesh = new Mesh; m_DropShadowMesh->Initialize( m_Mesh->m_VertexBuffer, m_Mesh->m_VertexDeclaration, m_Mesh->m_IndexBuffer, NULL ); m_DropShadowMesh->m_Material = m_Mesh->m_Material; m_DropShadowMesh->m_Location = m_Mesh->m_Location; m_DropShadowMesh->m_Location.x += m_DropShadowOffset.x; m_DropShadowMesh->m_Location.z += m_DropShadowOffset.y; m_DropShadowMesh->m_AABB = m_Mesh->m_AABB; m_DropShadowMesh->m_AABB.m_Min.x += m_DropShadowOffset.x; m_DropShadowMesh->m_AABB.m_Min.z += m_DropShadowOffset.y; m_DropShadowMesh->m_AABB.m_Max.x += m_DropShadowOffset.x; m_DropShadowMesh->m_AABB.m_Max.z += m_DropShadowOffset.y; m_DropShadowMesh->m_ConstantColor = m_DropShadowColor; } }
//バッファの再描画 //渡される無効エリアの座標はコンテンツ座標系 void SXBSchView::drawBuffer(int x,int y,int clipx,int clipy, int clipw, int cliph ) { // qDebug("SXBSchView::drawBuffer\n"); QPainter painter; QRect rcClip = QRect(clipx,clipy,clipw,cliph); QRect rcClipSheet = ContentsToSheet(rcClip); SRect srcClipSheet =SRect(rcClipSheet.left(),rcClipSheet.top(),rcClipSheet.width(),rcClipSheet.height()); //qDebug() << m_viewBuffer.size(); painter.begin(&m_viewBuffer); painter.setRenderHint(QPainter::TextAntialiasing); painter.translate(-x,-y); painter.eraseRect(clipx,clipy,clipw,cliph); // painter.setClipping(true); clipx -= x; clipy -= y; // painter.setClipRect(clipx,clipy,clipw,cliph); SSize size = m_pDoc->SheetSize(); g_drawFrame(&painter,size,rcClip,QColor("#7E2020"),m_viewScale,m_viewScaleMul); if(m_bDisplayGrid) { drawGrid(&painter,rcClipSheet,QColor("#FC4343")); } drawMainXBSchObj(&painter,DRAW_ON,&srcClipSheet,m_fEditHighLight, m_viewScale,m_viewScaleMul); if((m_moveOption == MOVE_OPTION_COMPONENT_NAME) || (m_moveOption == MOVE_OPTION_COMPONENT_NUM)) { int modeOption = 0; if(m_moveOption == MOVE_OPTION_COMPONENT_NAME) { modeOption = DRAW_INH_PARTNAME; } else { modeOption = DRAW_INH_PARTNUM; } drawTempXBSchObj(&painter,DRAW_TEMP|modeOption,&srcClipSheet); } painter.end(); }
SRect Map::GetBoundingBoxFromSegment(const SLineSegment& line) const { // Validate the line segment if (line.from.x < 0.0f || line.from.x > GetWidth() || line.from.y < 0.0f || line.from.y > GetHeight() || line.to.x < 0.0f || line.to.x > GetWidth() || line.to.y < 0.0f || line.to.y > GetHeight()) { // Line segement is out of bound! return SRect(); } // Convert position to indices const int fromX = static_cast<int>(line.from.x) / mTileSize; const int fromY = static_cast<int>(line.from.y) / mTileSize; const int toX = static_cast<int>(line.to.x) / mTileSize; const int toY = static_cast<int>(line.to.y) / mTileSize; // Calculate tile count const int countX = toX - fromX + 1; const int countY = toY - fromY + 1; // Get region SRect region; for (int y = 0; y < countY; ++y) { for (int x = 0; x < countX; ++x) { const int index = (fromX + x) + ((fromY + y) * mColumns); if (!mTiles[index].IsWalkable()) { region += mTiles[index].GetBoundingBox(); } } } return region; }
void C2D::OnDraw(const SRect &rUpdate) { if (IsVisible() == false) { return; } SPos BitmapPos; BitmapPos.iX = GetValue() >> 16; if (BitmapPos.iX < 0) { BitmapPos.iX = 0; } if (BitmapPos.iX >= (tint)muiXPositions) { BitmapPos.iX = muiXPositions - 1; } BitmapPos.iY = GetValue() & 0xffff; if (BitmapPos.iY < 0) { BitmapPos.iY = 0; } if (BitmapPos.iY >= (tint)muiYPositions) { BitmapPos.iY = muiYPositions - 1; } DrawBitmap(GetBitmapResource(), rUpdate, SRect(GetPos() + BitmapPos, mSizeBitmap)); }
SRect NPC::GetBoundingBox() const { return SRect(mNPCData.mPosition.x + 5, mNPCData.mPosition.y, mNPCData.mPosition.x + 25, mNPCData.mPosition.y + 50); }
SRect Map::GetBoundingBoxFromSegment(SLineSegment line, Character& character) { // Validate that the line segment is within the maps range if (line.from.x < 0.0f || line.from.x > mMapData.GetWidth() || line.from.y < 0.0f || line.from.y > mMapData.GetHeight() || line.to.x < 0.0f || line.to.x > mMapData.GetWidth() || line.to.y < 0.0f || line.to.y > mMapData.GetHeight()) { return SRect(); } // Convert position to indices const int fromX = static_cast<int>(line.from.x) / 32; const int fromY = static_cast<int>(line.from.y) / 32; const int toX = static_cast<int>(line.to.x) / 32; const int toY = static_cast<int>(line.to.y) / 32; // Calculate Tile Count const int countX = toX - fromX + 1; const int countY = toY - fromY + 1; // Get Region SRect region; #if _DEBUG for(int a = 0; a < mNumberOfNPCS; ++a) { SRect region2 = mNPCS[a]->GetBoundingBox(); Graphics_DebugRect(region2 + sOffset, 0XFF00FF); Graphics_DebugRect(character.GetBoundingBox() + sOffset, 0X00FFFF); } for(int a = 0; a < mMapData.GetTileAmount(); ++a) { if(!mMapData.mLayer1[a].IsWalkable()) { SRect region2 = mMapData.mLayer1[a].GetBoundingBox(); Graphics_DebugRect(region2 + sOffset, 0XFF00FF); } } #endif int width = GetWidth(); for (int y = 0; y < countY; ++y) { for (int x = 0; x < countX; ++x) { const int index = (fromX + x) + ((fromY + y) * (width)); character.SetTileIndex(index); // Block Tile if (!mMapData.mLayer1[index].IsWalkable()) { region += mMapData.mLayer1[index].GetBoundingBox(); Graphics_DebugRect(region + sOffset, 0XFF0000); } for (int a = 0; a < mNumberOfNPCS; ++a) { bool npcIntersect = PointInRect(line.to, mNPCS[a]->GetBoundingBox()); if (npcIntersect) { return region += mNPCS[a]->GetBoundingBox(); } } // Item Tile if (mMapData.mLayer1[index].GetItemImageNumber()) { SRect debug = region + mMapData.mLayer1[index].GetBoundingBox(); character.SetOnItem(mMapData.mLayer1[index].GetItemID()); character.SetOnItemIndex(index); Graphics_DebugRect(debug + sOffset, 0XFFFF00); } else { character.SetOnItem(0); } } } return region; }
void UIWidgetText::GetBounds( SRect& OutBounds ) { OutBounds = SRect( m_Mesh->m_AABB.m_Min.x, m_Mesh->m_AABB.m_Min.z, m_Mesh->m_AABB.m_Max.x, m_Mesh->m_AABB.m_Max.z ); }
void SXBSchView::print(QPrinter* pPrinter) { m_pDoc->resetSelect(); updateViewBuffer(true); QPainter paint; if(paint.begin(pPrinter ) ) { int dpi; #ifdef Q_WS_MACX int dpix,dpiy;; dpix = pPrinter->logicalDpiX(); dpiy = pPrinter->logicalDpiY(); dpi=((dpix < dpiy) ? dpix : dpiy); #else dpi = pPrinter->resolution(); #endif paint.setRenderHint(QPainter::Antialiasing, true); // QRect rcPaper = pPrinter->paperRect(); // printf("paperRect %d,%d,%d,%d\n",rcPaper.left(),rcPaper.top(),rcPaper.width(),rcPaper.height()); QRect rcVp = paint.viewport(); QRect rcPg = pPrinter->pageRect(); // printf("pageRect %d,%d,%d,%d\n",rcPg.left(),rcPg.top(),rcPg.width(),rcPg.height()); // int orientation = pPrinter->orientation(); // printf("orientation %d\n",orientation); int vpWidth, vpHeight; int pgLeft, pgTop, pgWidth, pgHeight; vpWidth =rcVp.width(); vpHeight = rcVp.height(); pgLeft =rcPg.left(); pgTop =rcPg.top(); pgWidth =rcPg.width(); pgHeight = rcPg.height(); //印刷時に印刷の向きを変えてもpageRect()の返す値が変わらないQtのバグ(?)の対策 if( (vpWidth > vpHeight && pgWidth < pgHeight) || (vpWidth < vpHeight && pgWidth > pgHeight) ) { int swapn; swapn = pgLeft; pgLeft = pgTop; pgTop = swapn; swapn = pgWidth; pgWidth = pgHeight; pgHeight = swapn; } QSettings *settings = g_cfg.getSettings(); int leftMargin = 15; int topMargin = 15; int rightMargin = 15; int bottomMargin = 15; settings->beginGroup("PrintOption"); bool color = settings->value("Color",true).toBool(); settings->endGroup(); settings->beginGroup("PrintMargin"); topMargin = settings->value("Top",15).toInt(); bottomMargin = settings->value("Bottom",15).toInt(); leftMargin = settings->value("Left",15).toInt(); rightMargin = settings->value("Right",15).toInt(); settings->endGroup(); if (topMargin < 0) topMargin = 0; else if (topMargin > 50) topMargin = 50; if (bottomMargin < 0) bottomMargin = 0; else if (bottomMargin > 50) bottomMargin = 50; if (leftMargin < 0) leftMargin = 0; else if (leftMargin > 50) leftMargin = 50; if (rightMargin < 0) rightMargin = 0; else if (rightMargin > 50) rightMargin = 50; topMargin = dpi * 10 * topMargin / 254; bottomMargin = dpi * 10 * bottomMargin / 254; leftMargin = dpi * 10 * leftMargin / 254; rightMargin = dpi * 10 * rightMargin / 254; // printf("SXBSchView::print() dpi:%d\n",dpi); paint.save(); paint.setViewTransformEnabled (true); paint.resetMatrix(); SSize size = m_pDoc->SheetSize(); int w = size.w(); int h = size.h(); int dw = w*10; int dh = h*10; // p->setWindow( 0,0, dw, dh ); // QRect rc = paint.viewport(); int rightWidth = vpWidth-(pgLeft+pgWidth); if(rightWidth < 0) rightWidth = 0; int bottomWidth = vpHeight-(pgTop+pgHeight); if(bottomWidth < 0) bottomWidth = 0; leftMargin -= pgLeft; if(leftMargin < 0)leftMargin = 0; topMargin -= pgTop; if(topMargin < 0) topMargin = 0; rightMargin -= rightWidth; if(rightMargin < 0) rightMargin = 0; bottomMargin -= bottomWidth; if(bottomMargin < 0) bottomMargin = 0; int vw = pgWidth-(leftMargin+rightMargin); int vh = pgHeight-(topMargin+bottomMargin); double sheetRatio=(double)w / (double)h; double viewRatio=(double)vw / (double)vh; int newW; int newH; if(sheetRatio > viewRatio) { newW = vw; newH = (int)(vw / sheetRatio); } else { newH = vh; newW = (int)(vh * sheetRatio); } // printf("newW,H=%d,%d\n",newW,newH); // p->setViewport( rc.left() + (vw-newW)/2, // rc.top() + (vh-newH)/2, // newW, newH ); // QRect rcvp = p->viewport(); // printf("x,y,w,h %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height()); paint.setViewport( leftMargin+ (vw-newW)/2, topMargin + (vh-newH)/2, newW, newH ); paint.setWindow( 0,0, dw, dh ); // rcvp = p->viewport(); // printf("x,y,w,h %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height()); QRect rcClip = QRect(0,0,dw,dh); SRect srcClip =SRect(0,0,w,h); paint.setBackground(Qt::white); paint.eraseRect(0,0,dw,dh); g_drawFrame(&paint,size,rcClip,Qt::black,1,10); drawMainXBSchObj(&paint,(color ? DRAW_ON : DRAW_MONO)|DRAW_FOR_PRINT,&srcClip,false,1,10); paint.restore(); paint.end(); } }
SRect CScrollBar::GetHandleRect() { SRect rctHandle; if (mpScrollPane) mpScrollPane->GetScrollPos(mScrollPos); switch(mType) { case TypeHorizontal: { // The leftmost top-left point is 1 pixel to the right of the top-right point of the left arrow std::list<IControl*>::iterator it = mControls.begin(); if (mControls.size() > 2) { it++; } IControl* pControl = *it++; SRect RctArrow; pControl->GetRect(RctArrow); SPos Pos(RctArrow.iX + RctArrow.iCX, RctArrow.iY); // Calculate the relative position (top-left point) tint iDiff = mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX; tfloat64 fPositionRelative; if (iDiff == 0) { fPositionRelative = 0; } else { fPositionRelative = (double)mScrollPos.VisibleRect.iX / iDiff; } // Calculate the maximum width of the handle pControl = *it; SPos PosRightArrow; pControl->GetPos(PosRightArrow); tint iMaxWidth = PosRightArrow.iX - Pos.iX; // Calculate the relative width we occupy tfloat64 fWidthRelative = mScrollPos.VisibleRect.iCX / (double)mScrollPos.AreaSize.iCX; // Calculate the absolute size rctHandle = SRect(Pos, SSize(0, 0)); rctHandle.iCY = mpBitmapSizes[BitmapCenterHandle].iCY; rctHandle.iCX = (int)((fWidthRelative * iMaxWidth) + 0.5); // Calculate the absolute position rctHandle.iX += (int)((fPositionRelative * (iMaxWidth - rctHandle.iCX)) + 0.5); if (rctHandle.iCX < mpBitmapSizes[BitmapLeftTopHandle].iCX + mpBitmapSizes[BitmapRightDownHandle].iCX) { rctHandle.iCX = mpBitmapSizes[BitmapLeftTopHandle].iCX + mpBitmapSizes[BitmapRightDownHandle].iCX; } } break; case TypeVertical: { // The topmost top-left point is 1 pixel below the bottom-left point of the up arrow std::list<IControl*>::iterator it = mControls.begin(); if (mControls.size() > 2) { it++; } IControl* pControl = *it++; SRect RctArrow; pControl->GetRect(RctArrow); SPos Pos(RctArrow.iX, RctArrow.iY + RctArrow.iCY); // Calculate the relative position (top-left point) tint iDiff = mScrollPos.AreaSize.iCY - mScrollPos.VisibleRect.iCY; tfloat64 fPositionRelative; if (iDiff == 0) { fPositionRelative = 0; } else { fPositionRelative = (double)mScrollPos.VisibleRect.iY / iDiff; } // Calculate the maximum height of the handle pControl = *it; SPos PosDownArrow; pControl->GetPos(PosDownArrow); tint iMaxHeight = PosDownArrow.iY - Pos.iY; // Calculate the relative height we occupy tfloat64 fHeightRelative = mScrollPos.VisibleRect.iCY / (double)mScrollPos.AreaSize.iCY; // Calculate the absolute size rctHandle = SRect(Pos, SSize(0, 0)); rctHandle.iCX = mpBitmapSizes[BitmapCenterHandle].iCX; rctHandle.iCY = (int)((fHeightRelative * iMaxHeight) + 0.5); // Calculate the absolute position rctHandle.iY += (int)((fPositionRelative * (iMaxHeight - rctHandle.iCY)) + 0.5); if (rctHandle.iCY < mpBitmapSizes[BitmapLeftTopHandle].iCY + mpBitmapSizes[BitmapRightDownHandle].iCY) { rctHandle.iCY = mpBitmapSizes[BitmapLeftTopHandle].iCY + mpBitmapSizes[BitmapRightDownHandle].iCY; } } break; } return rctHandle; }
void UIWidgetImage::GetBounds( SRect& OutBounds ) { OutBounds = SRect( m_TopLeft.x, m_TopLeft.y, m_TopLeft.x + m_Dimensions.x, m_TopLeft.y + m_Dimensions.y ); }
void CGM_ControlDescBase::SetDefault() { ID = -1; Rect = SRect( 0, 0, 2, 2 ); }
SNode* Insert(const SCharData& data) { if (m_pChild[0] != NULL && m_pChild[1] != NULL) { // try inserting into first child SNode* pNewNode = m_pChild[0]->Insert(data); if (pNewNode != NULL) { return pNewNode; } // no room, insert into second return m_pChild[1]->Insert(data); } else { // if there's already a glyph here, return if (m_CharIndex >= 0) { return NULL; } int width = m_Rect.m_Right - m_Rect.m_Left; int height = m_Rect.m_Bottom - m_Rect.m_Top; // if we're too small, return if (data.m_Width > width || data.m_Height > height) { return NULL; } // if we're just right, accept if (data.m_Width == width && data.m_Height == height) { return this; } // otherwise, gotta split this node and create some kids m_pChild[0] = new SNode(); m_pChild[1] = new SNode(); // decide which way to split int dw = width - data.m_Width; int dh = height - data.m_Height; if (dw > dh) { m_pChild[0]->m_Rect = SRect(m_Rect.m_Left, m_Rect.m_Left + data.m_Width, m_Rect.m_Top, m_Rect.m_Bottom); m_pChild[1]->m_Rect = SRect(m_Rect.m_Left + data.m_Width + 1, m_Rect.m_Right, m_Rect.m_Top, m_Rect.m_Bottom); } else { m_pChild[0]->m_Rect = SRect(m_Rect.m_Left, m_Rect.m_Right, m_Rect.m_Top, m_Rect.m_Top + data.m_Height); m_pChild[1]->m_Rect = SRect(m_Rect.m_Left, m_Rect.m_Right, m_Rect.m_Top + data.m_Height + 1, m_Rect.m_Bottom); } // insert into first child we created return m_pChild[0]->Insert(data); } return NULL; }
//再描画 void SXBSchView::drawContents(QPainter*p,int clipx,int clipy,int clipw,int cliph) { // qDebug("SXBSchView::drawContents\n"); updateViewBuffer();// clipx, clipy, clipw, cliph ); QRect rcClip = QRect(clipx,clipy,clipw,cliph); QRect rcClipSheet = ContentsToSheet(rcClip); SRect srcClipSheet =SRect(rcClipSheet.left(),rcClipSheet.top(),rcClipSheet.width(),rcClipSheet.height()); //int vclipx,vclipy; // p->setClipping(true); //contentsToViewport ( clipx,clipy,vclipx,vclipy); // p->setClipRect(vclipx,vclipy,clipw,cliph); p->drawPixmap(0,0,m_viewBuffer); // p->drawPixmap(clipx,clipy,m_viewBuffer,vclipx,vclipy,clipw,cliph); //Qt4 bitBlt(viewport(),clipx,clipy,&m_viewBuffer,clipx,clipy,clipw,cliph);//,Qt::CopyROP,false); ////////////////////////////////////////////////////////////// /* p->eraseRect(clipx,clipy,clipw,cliph); SSize size = m_pDoc->SheetSize(); g_drawFrame(p,size,rcClip,QColor("black"),m_viewScale,m_viewScaleMul); if(m_bDisplayGrid){ drawGrid(p,rcClipSheet,QColor("green4")); } drawMainXBSchObj(p,DRAW_ON,&srcClipSheet, m_viewScale,m_viewScaleMul); if((m_moveOption == MOVE_OPTION_COMPONENT_NAME) || (m_moveOption == MOVE_OPTION_COMPONENT_NUM)){ int modeOption = 0; if(m_moveOption == MOVE_OPTION_COMPONENT_NAME){ modeOption = DRAW_INH_PARTNAME; }else{ modeOption = DRAW_INH_PARTNUM; } drawTempXBSchObj(p,DRAW_TEMP|modeOption,&srcClipSheet); } */ ////////////////////////////////////////////////////////////// //他のすべての描画が終わってからTempデータの描画を行う int modeOption = 0; if(m_pDoc->m_listTemp.size()>0) { if(m_bCompleteDrawTemp) { if(m_moveOption == MOVE_OPTION_COMPONENT_NAME) { modeOption = (DRAW_INH_PARTNUM | DRAW_INH_PARTBODY); } else if(m_moveOption == MOVE_OPTION_COMPONENT_NUM) { modeOption = (DRAW_INH_PARTNAME | DRAW_INH_PARTBODY); } drawTempXBSchObj(p,DRAW_TEMP|modeOption,&srcClipSheet); } if(m_clearTempRect) { m_pDoc->setupRcTempArea(); m_pDoc->setupRotateRect(); m_clearTempRect = false; } if(!modeOption) { drawTempDataFrame(p); } } if(m_bDrawSelectFrame) drawSelectFrame(p); if(m_bDrawTempLine) drawTempLine(p); if(m_pCursorObj) drawCursorObj(p); }