void testMergeCrossColorSpaceImpl(bool useProjectionColorSpace, bool swapSpaces) { QRect refRect; TestUtil::MaskParent p; KisPaintLayerSP layer1; KisPaintLayerSP layer2; KisPaintLayerSP layer3; const KoColorSpace *cs2 = useProjectionColorSpace ? p.image->colorSpace() : KoColorSpaceRegistry::instance()->lab16(); const KoColorSpace *cs3 = KoColorSpaceRegistry::instance()->rgb16(); if (swapSpaces) { qSwap(cs2, cs3); } dbgKrita << "Testing testMergeCrossColorSpaceImpl:"; dbgKrita << " " << ppVar(cs2); dbgKrita << " " << ppVar(cs3); layer1 = p.layer; layer2 = new KisPaintLayer(p.image, "paint2", OPACITY_OPAQUE_U8, cs2); layer3 = new KisPaintLayer(p.image, "paint3", OPACITY_OPAQUE_U8, cs3); QRect rect1(100, 100, 100, 100); QRect rect2(150, 150, 150, 150); QRect rect3(250, 250, 200, 200); layer1->paintDevice()->fill(rect1, KoColor(Qt::red, layer1->colorSpace())); layer2->paintDevice()->fill(rect2, KoColor(Qt::green, layer2->colorSpace())); layer3->paintDevice()->fill(rect3, KoColor(Qt::blue, layer3->colorSpace())); p.image->addNode(layer2); p.image->addNode(layer3); p.image->initialRefreshGraph(); { KisLayerSP newLayer = p.image->mergeDown(layer3, KisMetaData::MergeStrategyRegistry::instance()->get("Drop")); p.image->waitForDone(); QCOMPARE(newLayer->colorSpace(), p.image->colorSpace()); p.undoStore->undo(); } { layer2->disableAlphaChannel(true); KisLayerSP newLayer = p.image->mergeDown(layer3, KisMetaData::MergeStrategyRegistry::instance()->get("Drop")); p.image->waitForDone(); QCOMPARE(newLayer->colorSpace(), p.image->colorSpace()); p.undoStore->undo(); } }
void Game::CreateMenu() { // Create the scene context->scene->Init(context); // Create the GUI sf::Color invis(0, 0, 0, 0); sf::Color gray(0x22, 0x22, 0x22, 128); sf::Rect<int> rect(200, 200, 600, 250); sf::Rect<int> rect2(200, 275, 600, 325); sf::Rect<int> rect3(200, 350, 600, 400); GUIButton *but = new GUIButton("START GAME", rect, gray, invis); GUIButton *but2 = new GUIButton("OPTIONS", rect2, gray, invis); GUIButton *but3 = new GUIButton("EXIT", rect3, gray, invis); but3->SetOnClick(exitOnClick); but->SetOnClick(startGameOnClick); but->SetFontSize(20.0f); but2->SetFontSize(20.0f); but3->SetFontSize(20.0f); gui->AddElement(but); gui->AddElement(but2); gui->AddElement(but3); }
// ----------------------------------------------------------------------------- // CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL // Masked background context operations. // ----------------------------------------------------------------------------- // TInt CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL( TTestResult& aResult ) { TInt err = KErrNone; TRect initialRect( TSize( 100, 100 ) ); TRect nextRect( TSize( 50, 50 ) ); TRect rect3( TSize( 20, 20 ) ); TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1; TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2; TAknsItemID id3 = KAknsIIDQgnLogoEmpty; CAknsMaskedLayerBackgroundControlContext* myCtx = CAknsMaskedLayerBackgroundControlContext::NewL( id, initialRect, EFalse, 2 ); CleanupStack::PushL( myCtx ); myCtx->SetLayerImage( 0, id2 ); myCtx->SetLayerImage( 1, id3 ); myCtx->SetLayerRect( 0, nextRect ); myCtx->SetLayerRect(1, rect3 ); // Skipped myCtx->SetLayerMaskAndSizeL() since we cannot get CEikEnv::Static() CleanupStack::PopAndDestroy( myCtx ); // Sets test case result and description(Maximum size is KStifMaxResultDes) _LIT( KDescription, "MaskedBackgroundControlContextOps finished" ); aResult.SetResult( err, KDescription ); return err; }
void CThirdoneDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CRect rect1(614,634,835,805); //yirengongsi CRect rect2(1046,631,1257,808); //heziyouxiangongsi CRect rect3(1453,460,1680,520);//tuishangye CRect rect4(1694,460,1893,520);//tuisouye CRect rect5(1135,171,1318,239);//sousuoanniu if (true == isPointInRect( point , rect1)){ CContentListDlg dlg; mynum=1; dlg.totaltypenum=mynum+fromwherenum; dlg.DoModal(); } if (true == isPointInRect( point , rect2)){ CContentListDlg dlg; mynum=2; dlg.totaltypenum=mynum+fromwherenum; dlg.DoModal(); } if (true == isPointInRect( point , rect3)){ CDialogEx::OnCancel(); } if (true == isPointInRect( point , rect4)){ CDialogEx::OnCancel(); } CDialogEx::OnLButtonDown(nFlags, point); }
void HandTranslating::getFeature7To10(int ¤tFeatures) { int halfWidth = imageWidth / 2; int halfHeight = imageHeight / 2; Mat subImage; Rect rect1(0, 0, halfWidth, halfHeight); subImage = binaryMat(rect1); double feature = (double) (subImage.total()-countNonZero(subImage)) / (double) subImage.total(); currentFeatures++; nodeTest[currentFeatures-1].index = currentFeatures; nodeTest[currentFeatures-1].value = feature; Rect rect2(halfWidth, 0, halfWidth, halfHeight); subImage = binaryMat(rect2); feature = (double) (subImage.total()-countNonZero(subImage)) / (double) subImage.total(); currentFeatures++; nodeTest[currentFeatures-1].index = currentFeatures; nodeTest[currentFeatures-1].value = feature; Rect rect3(0, halfHeight, halfWidth, halfHeight); subImage = binaryMat(rect3); feature = (double) (subImage.total()-countNonZero(subImage)) / (double) subImage.total(); currentFeatures++; nodeTest[currentFeatures-1].index = currentFeatures; nodeTest[currentFeatures-1].value = feature; Rect rect4(halfWidth, halfHeight, halfWidth, halfHeight); subImage = binaryMat(rect4); feature = (double) (subImage.total()-countNonZero(subImage)) / (double) subImage.total(); currentFeatures++; nodeTest[currentFeatures-1].index = currentFeatures; nodeTest[currentFeatures-1].value = feature; }
TEST(CollisionTest, Overlap) { Rectangle rect1({10, 10}, {2, 2}); Rectangle rect2({10, 10}, {0, 0}); Rectangle rect3({10, 10}, {2, 2}, M_PI / 4.0); Collision collision1(rect1, rect2); Collision collision2(rect1, rect3); EXPECT_TRUE((bool)collision1); EXPECT_TRUE((bool)collision2); }
TEST(CollisionTest, NoOverlap) { Rectangle rect1({10, 10}, {20, 20}); Rectangle rect2({1, 1}, {0, 0}); Rectangle rect3({1, 1}, {0, 0}, M_PI / 4.0); Collision collision1(rect1, rect2); Collision collision2(rect1, rect3); EXPECT_FALSE((bool)collision1); EXPECT_FALSE((bool)collision2); }
//初始化函数 void CBitmapListCtrl::InitListCtrl(GetOrderName * pOrderFunction, UINT uComType) { CHappyGoDlg::InitListCtrl(pOrderFunction,uComType); //定义数据 m_uComType=uComType; lstrcpy(m_sztitle,TEXT("积分")); if (uComType==TY_MONEY_GAME) lstrcpy(m_sztitle,TEXT("金币")); else if (uComType==TY_MATCH_GAME) lstrcpy(m_sztitle,TEXT("积分")); this->SetBkColor(RGB(203, 211, 227)); CRect rect1(0,0,62,48);//头像 CRect rect2(62,6,192,26);//名字 CRect rect3(62,30,192,48);//等级 CRect rect4(192,6,283,26);//金币 CRect rect5(192,30,283,48);//金币数 CRect rect6(283,6,376,26);//赢 CRect rect7(283,30,376,48);//输 CRect rect8(376,6,408,48);//桌号 //CRect rect9(62,24,192,48); m_rlog=rect1; m_rname=rect2; m_rorder=rect3; m_rcoin=rect4; m_rcoinc=rect5; m_rwin=rect6; m_rloss=rect7; m_rdesk=rect8; //插入数据 SetRedraw(FALSE); //InsertColumn(0,"用户名",LVCFMT_LEFT,120); InsertColumn(0,"昵称",LVCFMT_LEFT,120); // InsertColumn(1,"ID 号码",LVCFMT_LEFT,60); /* InsertColumn(1,"桌号",LVCFMT_LEFT,40); InsertColumn(2,szBuffer,LVCFMT_LEFT,60); InsertColumn(3,"级别",LVCFMT_LEFT,90); InsertColumn(4,"总局数",LVCFMT_LEFT,50); InsertColumn(5,"胜局",LVCFMT_LEFT,50); InsertColumn(6,"输局",LVCFMT_LEFT,50); InsertColumn(7,"和局",LVCFMT_LEFT,50); InsertColumn(8,"逃跑",LVCFMT_LEFT,50);*/ // InsertColumn(12,"游戏社团",LVCFMT_CENTER,100); SetRedraw(TRUE); return; }
// ----------------------------------------------------------------------------- // CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL // Combined background context operations. // ----------------------------------------------------------------------------- // TInt CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL( TTestResult& aResult ) { TInt err = KErrNone; TRect initialRect( TSize( 100, 100 ) ); TRect nextRect( TSize( 50, 50 ) ); TRect rect3( TSize( 20, 20 ) ); TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1; TAknsItemID id3 = KAknsIIDQgnLogoEmpty; CAknsCombinedBackgroundControlContext* myCtx = CAknsCombinedBackgroundControlContext::NewL( EFalse ); CleanupStack::PushL( myCtx ); CAknsBasicBackgroundControlContext* mySubCtx1 = CAknsBasicBackgroundControlContext::NewL( id, initialRect, EFalse ); CAknsBasicBackgroundControlContext* mySubCtx2 = CAknsBasicBackgroundControlContext::NewL( id3, rect3, EFalse ); MAknsControlContext* retrievedCtx = myCtx->GetControlContext( 0 ); if ( retrievedCtx ) { // We haven't add anything to the combined context, so this should fail. err = KErrGeneral; } myCtx->AddControlContext( mySubCtx1 ); retrievedCtx = myCtx->GetControlContext( 0 ); if ( !retrievedCtx ) { // We have added one context, so this should not fail. err = KErrGeneral; } myCtx->AddControlContext( mySubCtx2 ); myCtx->RemoveControlContext( 0 ); myCtx->GetControlContext( 0 ); if ( !retrievedCtx ) { // We added two contexts, then removed one, so this should not fail. err = KErrGeneral; } myCtx->RemoveControlContext( 0 ); // remove the last remaining one. CleanupStack::PopAndDestroy( myCtx ); // Sets test case result and description(Maximum size is KStifMaxResultDes) _LIT( KDescription, "CombinedBackgroundControlContextOps finished" ); aResult.SetResult( err, KDescription ); return err; }
void SkinPainter::draw(int x, int y, int w, int h, QPainter &painter) { QRect rect1(0, 0, m_left, m_top); QRect rect2(m_left, 0, m_source.width() - m_left - m_right, m_top); QRect rect3(m_source.width() - m_right, 0, m_right, m_top); QRect rect4(0, m_top, m_left, m_source.height() - m_top - m_bottom); QRect rect5(m_left, m_top, m_source.width() - m_left - m_right, m_source.height() - m_top - m_bottom); QRect rect6(m_source.width() - m_right, m_top, m_right, m_source.height() - m_top - m_bottom); QRect rect7(0, m_source.height() - m_bottom, m_left, m_bottom); QRect rect8(m_left, m_source.height() - m_bottom, m_source.width() - m_left - m_right, m_bottom); QRect rect9(m_source.width() - m_right, m_source.height() - m_bottom, m_right, m_bottom); QPixmap p1 = m_source.copy(rect1); QPixmap p2 = m_source.copy(rect2); QPixmap p3 = m_source.copy(rect3); QPixmap p4 = m_source.copy(rect4); QPixmap p5 = m_source.copy(rect5); QPixmap p6 = m_source.copy(rect6); QPixmap p7 = m_source.copy(rect7); QPixmap p8 = m_source.copy(rect8); QPixmap p9 = m_source.copy(rect9); painter.drawPixmap(x, y, p1); qDebug("+x = %d, y = %d", x, y); //p2 = p2.scaledToWidth(w - p1.width() - p3.width()); for (int i = 0; i < w - p1.width() - p3.width(); i += p2.width()) { qDebug("x = %d, y = %d", x + p1.width() + i, y); painter.drawPixmap(x + p1.width() + i, y, p2); } qDebug("-x = %d, y = %d", x + w - p3.width(), y); painter.drawPixmap(x + w - p3.width(), y, p3); /* p4 = p4.scaledToHeight(h - p1.height() - p7.height()); painter.drawPixmap(x, y + p1.height(), p4); p5 = p5.scaledToWidth(w - p1.width() - p3.width()); p5 = p5.scaledToHeight(h - p1.height() - p7.height()); painter.drawPixmap(x + p4.width(), y + p1.height(), p5); p6 = p6.scaledToHeight(h - p1.height() - p7.height()); painter.drawPixmap(x + p4.width() + p5.width(), y + p3.height(), p6); painter.drawPixmap(x, y + p1.height() + p4.height(), p7); p8 = p8.scaledToWidth(w - p1.width() - p3.width()); p8 = p8.scaledToHeight(h - p1.height() - p7.height()); painter.drawPixmap(x + p7.width(), y + p2.height() + p5.height(), p8); painter.drawPixmap(x + p7.width() + p8.width(), y + p3.height() + p6.height(), p9); */ }
void JMIDIInObj::draw(JGraphics g, int x, int y, int w, int h) { int dh = h/3; int dy = h/12; JRect rect1(x, y+dy, w, dh); JRect rect2(x, y+h/3, w, dh); JRect rect3(x, y+h*2/3-dy, w, dh); if (!valid) { if (g.getJColor() == JColor::black) g.setJColor(JColor::gray); else return; } drawText(g, "MIDI", rect1); drawText(g, "Input", rect2); drawText(g, name, rect3); }
void object::test<3>() { // // test the LLRect constructor from another LLRect // LLRect rect3(LLRect(1, 6, 7, 2)); ensure_equals("Default rect left", rect3.mLeft, 1); ensure_equals("Default rect top", rect3.mTop, 6); ensure_equals("Default rect right", rect3.mRight, 7); ensure_equals("Default rect bottom", rect3.mBottom, 2); ensure_equals("Default rect width", rect3.getWidth(), 6); ensure_equals("Default rect height", rect3.getHeight(), 4); ensure_equals("Default rect centerx", rect3.getCenterX(), 4); ensure_equals("Default rect centery", rect3.getCenterY(), 4); }
void UBGraphicsRuler::fillBackground(QPainter *painter) { QRectF rect1(rect().topLeft(), QSizeF(rect().width(), rect().height() / 4)); QLinearGradient linearGradient1( rect1.topLeft(), rect1.bottomLeft()); linearGradient1.setColorAt(0, edgeFillColor()); linearGradient1.setColorAt(1, middleFillColor()); painter->fillRect(rect1, linearGradient1); QRectF rect2(rect1.bottomLeft(), QSizeF(rect().width(), rect().height() / 2)); painter->fillRect(rect2, middleFillColor()); QRectF rect3(rect2.bottomLeft(), rect1.size()); QLinearGradient linearGradient3( rect3.topLeft(), rect3.bottomLeft()); linearGradient3.setColorAt(0, middleFillColor()); linearGradient3.setColorAt(1, edgeFillColor()); painter->fillRect(rect3, linearGradient3); }
// ----------------------------------------------------------------------------- // CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL // Listbox background context operations. // ----------------------------------------------------------------------------- // TInt CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL( TTestResult& aResult ) { TInt err = KErrNone; TRect initialRect( TSize( 100, 100 ) ); TRect nextRect( TSize( 50, 50 ) ); TRect rect3( TSize( 20, 20 ) ); TRect rect4( TSize( 200, 200 ) ); TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1; TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2; TAknsItemID id3 = KAknsIIDQgnLogoEmpty; TAknsItemID id4 = KAknsIIDQsnBgColumn0; CAknsListBoxBackgroundControlContext* myCtx = CAknsListBoxBackgroundControlContext::NewL( id, initialRect, EFalse, id2, nextRect ); CleanupStack::PushL( myCtx ); myCtx->SetTiledBitmap( id3 ); myCtx->SetTiledRect( rect3 ); myCtx->SetBottomBitmap( id4 ); myCtx->SetBottomRect( rect4 ); if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) || !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) || !myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) || myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) || myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame )) { err = KErrGeneral; } // Skipped case to update context since we cannot instantiate singleton. CleanupStack::PopAndDestroy( myCtx ); // Sets test case result and description(Maximum size is KStifMaxResultDes) _LIT( KDescription, "ListBoxBackgroundControlContextOps finished" ); aResult.SetResult( err, KDescription ); return err; }
void CropWidget::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); QRect rubberRect = rubberBand->geometry(); QRect useRect; if(rubberRect.width() < 0 && rubberRect.height() < 0) { useRect.setTopLeft(rubberRect.bottomRight()); useRect.setBottomRight(rubberRect.topLeft()); } else if(rubberRect.width() < 0) { useRect.setTopRight(rubberRect.topLeft()); useRect.setBottomLeft(rubberRect.bottomRight()); } else if(rubberRect.height() < 0) { useRect.setTopRight(rubberRect.bottomRight()); useRect.setBottomLeft(rubberRect.topLeft()); } else useRect = rubberRect; QRect rect1(0,0,useRect.x(),this->height()); QRect rect2(useRect.x()+useRect.width(),0,this->width()-useRect.x()-useRect.width(),this->height()); QRect rect3(useRect.x(),0,useRect.width(), useRect.y()); QRect rect4(useRect.x(),useRect.y()+useRect.height(), useRect.width(), this->height()-useRect.y()-useRect.height()); QPainter painter(this); painter.setPen(QPen(QBrush(QColor(0,0,0,180)),1,Qt::NoPen)); painter.setBrush(QBrush(QColor(0,0,0,220))); painter.drawRect(rect1); painter.drawRect(rect2); painter.drawRect(rect3); painter.drawRect(rect4); painter.end(); }
void MainWindow::paintEvent(QPaintEvent *) { QPainter painter(this); QRect rect0(10, 10, 20, 20); painter.setPen(Qt::red); // painter.setClipRect(rect0); painter.drawRect(rect0); QRect rect1(10, 35, 20, 20); painter.setPen(Qt::NoPen); painter.setClipRect(rect1); painter.fillRect(rect1, Qt::red); QRect rect2(10, 60, 20, 20); painter.setClipRect(rect2); painter.fillRect(rect2, Qt::red); QRect rect3(10, 85, 20, 20); painter.setPen(Qt::blue); painter.setClipRect(rect3); painter.drawLine(0, 90, 100, 90); painter.drawLine(20, 0, 20, 200); }
// ----------------------------------------------------------------------------- // CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL // Layered background context operations. // ----------------------------------------------------------------------------- // TInt CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL( TTestResult& aResult ) { TInt err = KErrNone; TRect initialRect( TSize( 100, 100 ) ); TRect nextRect( TSize( 50, 50 ) ); TRect rect3( TSize( 20, 20 ) ); TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1; TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2; TAknsItemID id3 = KAknsIIDQgnLogoEmpty; CAknsLayeredBackgroundControlContext* myCtx = CAknsLayeredBackgroundControlContext::NewL( id, initialRect, EFalse, 2 ); CleanupStack::PushL( myCtx ); myCtx->SetLayerImage( 0, id2 ); myCtx->SetLayerImage( 1, id3 ); myCtx->SetLayerRect( 0, nextRect ); myCtx->SetLayerRect( 1, rect3 ); if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) || !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) || !myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) || myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) || myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame )) { err = KErrGeneral; } CleanupStack::PopAndDestroy( myCtx ); // Sets test case result and description(Maximum size is KStifMaxResultDes) _LIT( KDescription, "LayeredBackgroundControlContextOps finished" ); aResult.SetResult( err, KDescription ); return err; }
void CLineNode::InsertMMLFormulaNode_MTABLE_readAttr( AST_TXML_Tag *node, CFormulaNode *new_node ) { struct HMathMLAttr mml_attr( _T(""), _T("") ); // not one of the predefined tokens mml_attr.set( ::getCurrentFormulatorStyle().getUnit2PX(), node, _T("") /*has no body*/ ); mml_attr.accountAttr( FBL_ATTR_align ); mml_attr.accountAttr( FBL_ATTR_columnalign ); mml_attr.accountAttr( FBL_ATTR_rowalign ); new_node->CNodeInfo_Property::setUnfilteredAttr( mml_attr ); AST_TXML_Attribute *tblAttr = 0; long i, j, idx; tblAttr = node->getAttribute( FBL_ATTR_align ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { idx = -1; i = 0; QString tmp = _T(""), body = tblAttr->getStringValue(); do { while( i < body.length() && body.at(i).isSpace() ) i++; while( i < body.length() && body.at(i).isLetter() ) { tmp.append( body.at(i) ); i++; } if( tmp.length() == 0 ) break; while( i < body.length() && body.at(i).isSpace() ) i++; if( i >= body.length() ) break; if( !(body.at(i).isDigit() || body.at(i) == QChar('-')) ) break; LSDigit ldigit; long result = ldigit.Analisys( body.midRef(i) ); if( result != LSDigit::Integer ) break; if( ldigit.mnt_int >= 1 && ((long) ldigit.mnt_int) <= new_node->GetNumLine() ) { if( ldigit.asign < 0 ) idx = (new_node->GetNumLine() - ldigit.mnt_int) * new_node->GetNumColumn(); else idx = (ldigit.mnt_int - 1) * new_node->GetNumColumn(); } } while( 0 ); if( tmp == FBL_VAL_top ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableTop2Baseline, idx + 1 ); else if( tmp == FBL_VAL_bottom ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableBottom2Baseline, idx + 1 ); else if( tmp == FBL_VAL_center || tmp == FBL_VAL_baseline ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableCenter2Baseline, idx + 1 ); else new_node->setSpecialVerticalCenter( FBtnChildPos::TableAxis, idx + 1 ); } std::vector<long> vAlign, hAlign; long v = TO_BASELINE, h = HORISONTAL_CENTER; ::bb_read_attr_align_horizontal( node, FBL_ATTR_columnalign, hAlign, h ); ::bb_read_attr_align_vertical( node, FBL_ATTR_rowalign, vAlign, v ); if( hAlign.size() > 0 ) h = hAlign[ hAlign.size() - 1 ]; if( vAlign.size() > 0 ) v = vAlign[ vAlign.size() - 1 ]; vAlign.resize( new_node->GetNumLine(), v ); hAlign.resize( new_node->GetNumColumn(), h ); long effV, cellEffV, cellEffH; AST_TXML_Tag *mtr = 0, *mtd = 0; idx = 0; for( i = 0; i < new_node->GetNumLine() && i < (long) vAlign.size(); i++ ) { mtr = ::mml_get_table_tag_mtr( node, i ); std::vector<long> hRowAlign; long rowH = LONG_MAX; ::bb_read_attr_align_horizontal( mtr, FBL_ATTR_columnalign, hRowAlign, LONG_MAX ); if( hRowAlign.size() > 0 ) rowH = hRowAlign[ hRowAlign.size() - 1 ]; hRowAlign.resize( hAlign.size(), rowH ); for( j = 0; j < (long) hRowAlign.size() && j < (long) hAlign.size(); j++ ) if( hRowAlign[ j ] == LONG_MAX ) hRowAlign[ j ] = hAlign[ j ]; effV = LONG_MAX; ::bb_read_attr_align_vertical( mtr, FBL_ATTR_rowalign, effV ); if( effV == LONG_MAX ) effV = vAlign[ i ]; for( j = 0; j < new_node->GetNumColumn() && j < (long) hAlign.size(); j++ ) { mtd = ::mml_get_table_tag_mtd( node, i, j ); cellEffH = LONG_MAX; ::bb_read_attr_align_horizontal( mtd, FBL_ATTR_columnalign, cellEffH ); if( cellEffH == LONG_MAX ) cellEffH = hRowAlign[ j ]; cellEffV = LONG_MAX; ::bb_read_attr_align_vertical( mtd, FBL_ATTR_rowalign, cellEffV ); if( cellEffV == LONG_MAX ) cellEffV = effV; Q_ASSERT( cellEffV != LONG_MAX && cellEffH != LONG_MAX ); new_node->SetChildFrameAlignType( idx, cellEffV | cellEffH ); idx++; } } std::vector<FBtnGraphics> frameLine; RealFde x0 = 0.0; RealFde y0 = 0.0; RealFde x100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; RealFde y100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; tblAttr = node->getAttribute( FBL_ATTR_frame ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { int penStyle = -1; if( tblAttr->getStringValue() == FBL_VAL_solid ) penStyle = Qt::SolidLine; else if ( tblAttr->getStringValue() == FBL_VAL_dashed ) penStyle = Qt::DashLine; if( penStyle != -1 ) { FBtnGraphics oneLine; RectFde rect1( PointFde(x0, y0), PointFde(x100, y0) ); RectFde rect2( PointFde(x100, y0), PointFde(x100, y100) ); RectFde rect3( PointFde(x100, y100), PointFde(x0, y100) ); RectFde rect4( PointFde(x0, y100), PointFde(x0, y0) ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect1 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect2 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect3 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect4 ); frameLine.push_back( oneLine ); } } RealFde pos; std::vector<long> penStyleList; if( new_node->GetNumLine() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_rowlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumLine() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( x0, 0.0, x100, 0.0 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i * new_node->GetNumColumn() ).GetPecentPosition().bottom(); pos += new_node->GetSlot( (i + 1) * new_node->GetNumColumn() ).GetPecentPosition().top(); rc.setTop( pos / 2.0 ); rc.setBottom( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( new_node->GetNumColumn() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_columnlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumColumn() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( 0.0, y0, 0.0, y100 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i ).GetPecentPosition().left(); pos += new_node->GetSlot( i + 1 ).GetPecentPosition().right(); rc.setLeft( pos / 2.0 ); rc.setRight( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( frameLine.size() > 0 ) { CGraphPrimFormula *primList = new CGraphPrimFormula[ frameLine.size() ]; new_node->FlushAltGroup(); for( i = 0; i < (long) frameLine.size(); i++ ) { primList[ i ].Create( frameLine[ i ] ); new_node->AddAltGroup( frameLine[ i ].altGroup ); } new_node->CreateGraphPrimIndirect( (int) frameLine.size(), primList ); delete[] primList; } }
void Menu::init(Game *game) { //////////////////FONTS//////////////////////////////// if(!_font.loadFromFile("data/fonts/caveman.ttf")) std::cout << "Can't load data/fonts/caveman.ttf" <<std::endl; //////////////////TEXTES//////////////////////////////// _titre.setFont(_font); _titre.setString("PUCE"); _titre.setCharacterSize(80); _titre.setPosition((600 - _titre.getGlobalBounds().width) / 2 ,-10); _titre.setColor(sf::Color(195,135,100)); _sousTitre.setFont(_font); _sousTitre.setString(sf::String("& THE LEG STEALER")); _sousTitre.setCharacterSize(20); _sousTitre.setPosition((600 - _titre.getGlobalBounds().width) / 2 , _titre.getGlobalBounds().height ); _sousTitre.setColor(sf::Color(150,90,100)); //////////////////MUSIQUE//////////////////////////////// if(!_music.openFromFile("data/music/8bit.ogg")) std::cout << "Can't load data/music/8bit.ogg" <<std::endl; _music.play(); _music.setLoop(true); _music.setVolume(3); //////////////////NUAGE 1//////////////////////////////// if(!_text.loadFromFile("data/menu/tileset_nuage1.png")) _text.setSmooth(false); _nuage.setTexture(_text); _nuage.setPosition(10,150); sf::IntRect rect(0,0,300,_nuage.getGlobalBounds().height); _nuage.setTextureRect(rect); //////////////////NUAGE 2//////////////////////////////// if(!_text2.loadFromFile("data/menu/tileset_nuage2.png")) _text2.setSmooth(false); _nuage2.setTexture(_text2); _nuage2.setPosition(530,60); sf::IntRect rect2(0,0,262,_nuage2.getGlobalBounds().height); _nuage2.setTextureRect(rect2); //////////////////MONTAGNES//////////////////////////////// if(!_textM.loadFromFile("data/menu/mountains1.png")) _textM.setSmooth(false); _mountain.setTexture(_textM); //////////////////PUCE//////////////////////////////// if(!_textP.loadFromFile("data/menu/puce_volante_tileset.png")) _textP.setSmooth(false); _puce.setTexture(_textP); _puce.setPosition(200,250); sf::IntRect rect3(0,0,300,_puce.getGlobalBounds().height); _puce.setTextureRect(rect3); //////////////////FORET//////////////////////////////// if(!_textF.loadFromFile("data/menu/foret_defilante.png")) _textF.setSmooth(false); _foret1.setTexture(_textF); _foret2.setTexture(_textF); _foret3.setTexture(_textF); _foret1.setTextureRect(sf::IntRect(0,0,400,_foret1.getGlobalBounds().height)); _foret2.setTextureRect(sf::IntRect(400,0,400,_foret2.getGlobalBounds().height)); _foret3.setTextureRect(sf::IntRect(800,0,403,_foret3.getGlobalBounds().height)); _foret1.setPosition(0,0); _foret2.setPosition(400,0); _foret3.setPosition(800,0); //////////////////MENU//////////////////////////////// if(!_textMenu.loadFromFile("data/menu/menu.png")) _textMenu.setSmooth(false); _menu.setTexture(_textMenu); _menu.setPosition(600,200); int _boucle = 0; _montre.restart(); _montre2.restart(); }
void CAlfPerfAppAvkonTestCaseBasic::NextAnimFrameL() { // Begin drawing RWindow& window = static_cast< RWindow& >( *iAvkonControl->DrawableWindow() ); CWindowGc& gc = iAvkonControl->SystemGc(); TRect updateRect(iAvkonControl->Rect()); window.Invalidate( updateRect ); window.BeginRedraw( updateRect ); gc.Activate(window); // Draw background TRgb color (KRgbWhite); gc.SetBrushColor(color); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenSize(TSize(10,10)); gc.SetPenColor(color); gc.DrawRect(updateRect); // Calc timeline TTime now; now.UniversalTime(); TUint millisecondFromCycleStart = now.MicroSecondsFrom(iCycleStartTime).Int64() / 1000; double timelinePercentage = (double)millisecondFromCycleStart / KCycleDurationMs; timelinePercentage *= 0.5; // scale it a bit... // Calc rect TRect fullRect(updateRect); TSize size(fullRect.Width()*(1.0 - timelinePercentage), fullRect.Height()*(1.0 - timelinePercentage)); TPoint windowCenter = fullRect.Center(); TPoint tl(windowCenter.iX - size.iWidth/2, windowCenter.iY - size.iHeight/2); TRect rect(tl, size); // Draw gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); const TPoint Point1(rect.iTl); const TPoint Point2(rect.iBr.iX, rect.iTl.iY); const TPoint Point3(rect.iBr); const TPoint Point4(rect.iTl.iX, rect.iBr.iY); const TPoint center(rect.Center()); switch (iCycleCounter) { case 1: // DrawEllipse { gc.DrawEllipse(rect); break; } case 2: // DrawRect { gc.DrawRect(rect); break; } case 3: // DrawRoundRect { TSize corner(rect.Width()/5, rect.Height()/5); gc.DrawRoundRect(rect, corner); break; } case 4: // Draw lines { gc.SetPenColor(TRgb(255,0,0)); gc.DrawLine(Point1, Point2); gc.SetPenColor(TRgb(200,50,0)); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(150,100,0)); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(100,150,0)); gc.DrawLineBy(TPoint(0, -rect.Height())); gc.SetPenColor(TRgb(50,200,0)); gc.MoveTo(Point2); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(0,255,0)); gc.MoveBy(TPoint(0, -rect.Height())); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(255,0,0)); gc.Plot(center); break; } case 5: // Draw { gc.SetPenColor(TRgb(255,0,0)); gc.DrawArc(rect, Point2, Point1); gc.DrawPie(rect, Point4, Point3); break; } case 6: // Draw polygons { const TInt KNumPoints = 9; TPoint pointList[KNumPoints]; pointList[0] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); pointList[1] = TPoint(Point1.iX+rect.Width()*0.75, Point1.iY); pointList[2] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.25); pointList[3] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.75); pointList[4] = TPoint(Point3.iX-rect.Width()*0.25, Point3.iY); pointList[5] = TPoint(Point3.iX-rect.Width()*0.75, Point3.iY); pointList[6] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.25); pointList[7] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.75); pointList[8] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); CArrayFix<TPoint>* mypoints = new CArrayFixFlat<TPoint>(KNumPoints); CleanupStack::PushL(mypoints); for(TInt i=0; i<KNumPoints; i++) { mypoints->AppendL(pointList[i]); } gc.SetPenColor(TRgb(255,0,0)); gc.SetPenSize(TSize(20,20)); gc.DrawPolyLine(mypoints); gc.SetPenColor(TRgb(0,255,0)); gc.SetPenSize(TSize(15,15)); gc.DrawPolyLine(pointList, KNumPoints); gc.SetPenColor(TRgb(255,255,0)); gc.SetPenSize(TSize(10,10)); gc.DrawPolygon(mypoints); gc.SetPenColor(TRgb(0,0,255)); gc.SetPenSize(TSize(5,5)); gc.DrawPolygon(pointList, KNumPoints); CleanupStack::PopAndDestroy(); // mypoints break; } case 7: // Draw texts { gc.UseFont(iFont); gc.SetDrawMode(CGraphicsContext::EDrawModePEN); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); TInt h = rect.Height() / 3; TInt y = rect.iTl.iY; TRect tinyBox(rect); tinyBox.SetHeight(h); TInt fontDescent=iFont->DescentInPixels(); gc.SetBrushColor(TRgb(0, 0, 255)); // blue gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawText(_L("Ilves"), tinyBox.iTl+TPoint(0, fontDescent)); tinyBox.Move(0,h); TInt posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawText(_L("Tappara"), tinyBox, posY); gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawTextVertical(_L("Ilves"), tinyBox.iTl+TPoint(fontDescent, 0 ), ETrue); tinyBox.Move(0,h); posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawTextVertical(_L("Tappara"), tinyBox, posY, ETrue); break; } case 8: // Draw bitmaps { TPoint pos(rect.iTl); gc.BitBlt(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY); gc.BitBlt(pos, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()*2/3, rect.iTl.iY); gc.BitBltMasked(pos, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()/3); TRect dstRect(pos, TSize(rect.Width()/3, rect.Height()/3)); gc.DrawBitmap(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmap(dstRect, iPictureBm); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()*2/3); gc.DrawBitmap(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()*2/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmapMasked(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); break; } case 9: // Miscellanious { TRect rect1(rect); rect1.SetWidth(rect.Width()/2); rect1.SetHeight(rect.Height()/2); TRect rect2(rect1); rect2.Move(rect1.Width(),0); TRect rect3(rect1); rect3.Move(0, rect1.Height()); TRect rect4(rect1); rect4.Move(rect1.Width(), rect1.Height()); // Clear gc.Clear(); // Brush pattern gc.UseBrushPattern(iPictureBm); gc.SetBrushStyle(CGraphicsContext::EPatternedBrush); gc.DrawRect(rect1); gc.DiscardBrushPattern(); // Fading & copy rect gc.SetFaded(ETrue); gc.CopyRect(rect2.iTl, rect1); gc.SetFadingParameters(255,0); gc.CopyRect(rect3.iTl, rect1); // Map colors gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); gc.DrawRect(rect4); TRgb colors[2] = {KRgbRed, KRgbGreen}; // change brush color gc.MapColors(rect4,colors,1,ETrue); break; } default: gc.DrawRect(rect); } // End drawing gc.Deactivate(); window.EndRedraw(); iTestCaseFrameCount++; }
void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } int32_t leftPadding = 7 * multiple; int32_t leftPosition = 10 * multiple + leftPadding; CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLen = str.GetLength(); FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_ByteString tempStr = str.Mid(1, 5); FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; if (pOutBitmap) geBitmap.Attach(pOutBitmap, false, nullptr, false); iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); matr.Concat(*matrix); matr.TransformRect(rect); FX_RECT re = rect.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect1( (FX_FLOAT)(leftPosition + 40 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), (FX_FLOAT)m_Height); matr1.Concat(*matrix); matr1.TransformRect(rect1); re = rect1.GetOutterRect(); device->FillRect(&re, m_backgroundColor); FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7; CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height); matr2.Concat(*matrix); matr2.TransformRect(rect2); re = rect2.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect3( (FX_FLOAT)(leftPosition + 85 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5), (FX_FLOAT)m_Height); matr3.Concat(*matrix); matr3.TransformRect(rect3); re = rect3.GetOutterRect(); device->FillRect(&re, m_backgroundColor); } if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)leftPosition * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(6, 5); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); ge.FillRect(&rect2, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = (FX_FLOAT)multiple * 7; if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(11, 1); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } FX_Free(pCharPos); }
static void test_CRect() { CRect empty; ok(empty.left == 0, "Expected left to be 0, was %ld\n", empty.left); ok(empty.top == 0, "Expected top to be 0, was %ld\n", empty.top); ok(empty.Width() == 0, "Expected Width to be 0, was %i\n", empty.Width()); ok(empty.Height() == 0, "Expected Height to be 0, was %i\n", empty.Height()); CRect rect(0, 0, 100, 50); ok(rect.Width() == 100, "Expected Width to be 100, was %i\n", rect.Width()); ok(rect.Height() == 50, "Expected Height to be 50, was %i\n", rect.Height()); RECT sdkRect; sdkRect.left = 0; sdkRect.top = 0; sdkRect.right = 100; sdkRect.bottom = 50; CRect rect2(sdkRect); CRect rect3(&sdkRect); ok_rect(rect2, rect); ok_rect(rect3, rect); CPoint pt(0, 0); CSize sz(100, 50); CRect rect4(pt, sz); ok_rect(rect4, rect2); CPoint ptBottomRight(100, 50); CRect rect5(pt, ptBottomRight); ok_rect(rect5, rect4); rect = CRect(210, 150, 350, 900); CPoint ptDown; ptDown = rect.BottomRight(); pt = CPoint(350, 900); ok_point(ptDown, pt); rect2 = CRect(10, 10, 350, 350); CPoint ptLow(180, 180); rect2.BottomRight() = ptLow; rect = CRect(10, 10, 180, 180); ok_rect(rect2, rect); pt = CPoint(95, 95); CPoint pt2 = rect2.CenterPoint(); ok_point(pt2, pt); pt2 = rect2.BottomRight(); pt = CPoint(180, 180); ok_point(pt2, pt); pt2 = rect2.TopLeft(); pt = CPoint(10, 10); ok_point(pt2, pt); rect2.TopLeft().Offset(3, 3); rect3 = CRect(13, 13, 180, 180); ok_rect(rect3, rect2); CRect rectSource(35, 10, 125, 10); CRect rectDest; rectDest.CopyRect(&rectSource); RECT rectSource2; rectSource2.left = 0; rectSource2.top = 0; rectSource2.bottom = 480; rectSource2.right = 640; rectDest.CopyRect(&rectSource2); rect = CRect(10, 10, 50, 50); rect.DeflateRect(1, 2); rect2 = CRect(11, 12, 49, 48); ok_rect(rect2, rect); rect2 = CRect(10, 10, 50, 50); CRect rectDeflate(1, 2, 3, 4); rect2.DeflateRect(&rectDeflate); rect = CRect(11, 12, 47, 46); ok_rect(rect2, rect); rect2.DeflateRect(sz); rect = CRect(111, 62, -53, -4); ok_rect(rect2, rect); rect2.OffsetRect(sz); rect = CRect(211, 112, 47, 46); ok_rect(rect2, rect); CRect rect1(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok(rect1.EqualRect(rect2), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect2)); ok(!rect1.EqualRect(rect3), "Expected EqualRect to return FALSE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect3)); RECT test; test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok(rect1.EqualRect(&test), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&test)); rect = test; rect2 = CRect(35, 150, 10, 25); ok_rect(rect, rect2); rect = CRect(0, 0, 300, 300); rect.InflateRect(50, 200); rect2 = CRect(-50, -200, 350, 500); ok_rect(rect, rect2); rect.InflateRect(sz); rect2 = CRect(-150, -250, 450, 550); ok_rect(rect, rect2); rect = CRect(20, 30, 80, 70); int nHt = rect.Height(); ok(nHt == 40, "Expected nHt to be 40, was %i\n", nHt); CRect rectOne(125, 0, 150, 200); CRect rectTwo(0, 75, 350, 95); CRect rectInter; rectInter.IntersectRect(rectOne, rectTwo); rect = CRect(125, 75, 150, 95); ok_rect(rectInter, rect); CRect rectInter2 = rectOne; rectInter2 &= rectTwo; rect = CRect(125, 75, 150, 95); ok_rect(rectInter2, rect); CRect rectNone(0, 0, 0, 0); CRect rectSome(35, 50, 135, 150); ok(rectNone.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectEmpty(), "Expected IsRectEmpty to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectEmpty(35, 35, 35, 35); ok(rectEmpty.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectEmpty)); ok(rectNone.IsRectNull(), "Expected IsRectNull to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectNotNull(0, 0, 35, 50); ok(!rectNotNull.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectNotNull)); rect1 = CRect(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok_rect(rect1, rect2); test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok_rect(rect1, test); nok_rect(rect1, rect3); nok_rect(rect3, test); rect1 = CRect(100, 235, 200, 335); pt = CPoint(35, 65); rect2 = CRect(135, 300, 235, 400); rect1 += pt; ok_rect(rect1, rect2); rect1 = CRect(100, 235, 200, 335); rect2 = rect1 + pt; CRect rectResult(135, 300, 235, 400); ok_rect(rectResult, rect2); rect2 = rect1 + &test; rectResult = CRect(65, 85, 210, 360); ok_rect(rectResult, rect2); rect2 = rect1 - (LPCRECT)&test; rectResult = CRect(135, 385, 190, 310); ok_rect(rectResult, rect2); rect2 = rect1 - pt; rectResult = CRect(65, 170, 165, 270); ok_rect(rect2, rectResult); rect1 -= pt; ok_rect(rect1, rectResult); rect1 = CRect(100, 0, 200, 300); rect2 = CRect(0, 100, 300, 200); rect3 = rect1 & rect2; rectResult = CRect(100, 100, 200, 200); ok_rect(rectResult, rect3); rect3 = rect1 | rect2; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect3); rect1 |= rect2; ok_rect(rectResult, rect1); rect1 += sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect1); rect1 += &test; rectResult = CRect(65, -100, 410, 375); ok_rect(rectResult, rect1); rect1 -= sz; rectResult = CRect(-35, -150, 310, 325); ok_rect(rectResult, rect1); rect1 -= &test; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect1); rect2 = rect1 + sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect2); rect2 = rect1 - sz; rectResult = CRect(-100, -50, 200, 250); ok_rect(rectResult, rect2); }
int Events::handleOneShot(Event *event) { Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: { TextListEntry entry = *((TextListEntry *)event->data); _vm->_scene->_textList.remove(entry); } break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface = _vm->_render->getBackGroundSurface(); BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayInfo().width || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; #ifdef ENABLE_IHNM if (_vm->getGameId() == GID_IHNM) { PalEntry portraitBgColor = _vm->_interface->_portraitBgColor; byte portraitColor = (_vm->getLanguage() == Common::ES_ESP) ? 253 : 254; // Set the portrait bg color, in case a saved state is restored from the // launcher. In this case, sfSetPortraitBgColor is not called, thus the // portrait color will always be 0 (black). if (portraitBgColor.red == 0 && portraitBgColor.green == 0 && portraitBgColor.blue == 0) portraitBgColor.green = 255; if (_vm->_spiritualBarometer > 255) _vm->_gfx->setPaletteColor(portraitColor, 0xff, 0xff, 0xff); else _vm->_gfx->setPaletteColor(portraitColor, _vm->_spiritualBarometer * portraitBgColor.red / 256, _vm->_spiritualBarometer * portraitBgColor.green / 256, _vm->_spiritualBarometer * portraitBgColor.blue / 256); } #endif _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } _vm->_render->clearFlag(RF_DISABLE_ACTORS); } break; case kPsychicProfileBgEvent: { ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); ByteArray resourceData; _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData); ByteArray image; int width; int height; _vm->decodeBGImage(resourceData, image, &width, &height); const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData); const Rect profileRect(width, height); _vm->_render->getBackGroundSurface()->blit(profileRect, image.getBuffer()); _vm->_render->addDirtyRect(profileRect); _vm->_frameCount++; _vm->_gfx->setPalette(palette); // Draw the scene. It won't be drawn by Render::drawScene(), as a placard is up _vm->_scene->draw(); } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; case kEventResumeAll: _vm->_anim->resumeAll(); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventDraw: { BGInfo bgInfo; _vm->_scene->getBGInfo(bgInfo); _vm->_render->getBackGroundSurface()->blit(bgInfo.bounds, bgInfo.buffer); _vm->_render->addDirtyRect(bgInfo.bounds); _vm->_scene->draw(); } break; case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; case kEventRestoreMode: _vm->_interface->restoreMode(); break; case kEventSetMode: _vm->_interface->setMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: { debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); ScriptThread &sthread = _vm->_script->createThread(event->param, event->param2); sthread._threadVars[kThreadVarAction] = event->param3; sthread._threadVars[kThreadVarObject] = event->param4; sthread._threadVars[kThreadVarWithObject] = event->param5; sthread._threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; } case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; case kEventSetNormalCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorNormal); break; case kEventSetBusyCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorBusy); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; _vm->_gfx->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } #ifdef ENABLE_IHNM case kCutawayEvent: switch (event->op) { case kEventClear: _vm->_anim->clearCutaway(); break; case kEventShowCutawayBg: _vm->_anim->showCutawayBg(event->param); break; default: break; } #endif case kActorEvent: switch (event->op) { case kEventMove: // TODO (check Actor::direct) break; default: break; } default: break; } return kEvStDelete; }
FlattenTestImage() : refRect(0,0,512,512) , p(refRect) { image = p.image; layer1 = p.layer; layer5 = new KisPaintLayer(p.image, "paint5", 0.4 * OPACITY_OPAQUE_U8); layer5->disableAlphaChannel(true); layer2 = new KisPaintLayer(p.image, "paint2", OPACITY_OPAQUE_U8); tmask = new KisTransparencyMask(); // check channel flags // make addition composite op group1 = new KisGroupLayer(p.image, "group1", OPACITY_OPAQUE_U8); layer3 = new KisPaintLayer(p.image, "paint3", OPACITY_OPAQUE_U8); layer4 = new KisPaintLayer(p.image, "paint4", OPACITY_OPAQUE_U8); layer6 = new KisPaintLayer(p.image, "paint6", OPACITY_OPAQUE_U8); layer7 = new KisPaintLayer(p.image, "paint7", OPACITY_OPAQUE_U8); layer8 = new KisPaintLayer(p.image, "paint8", OPACITY_OPAQUE_U8); layer7->setCompositeOp(COMPOSITE_ADD); layer8->setCompositeOp(COMPOSITE_ADD); QRect rect1(100, 100, 100, 100); QRect rect2(150, 150, 150, 150); QRect tmaskRect(200,200,100,100); QRect rect3(400, 100, 100, 100); QRect rect4(500, 100, 100, 100); QRect rect5(50, 50, 100, 100); QRect rect6(50, 250, 100, 100); QRect rect7(50, 350, 50, 50); QRect rect8(50, 400, 50, 50); layer1->paintDevice()->fill(rect1, KoColor(Qt::red, p.image->colorSpace())); layer2->paintDevice()->fill(rect2, KoColor(Qt::green, p.image->colorSpace())); tmask->testingInitSelection(tmaskRect); layer3->paintDevice()->fill(rect3, KoColor(Qt::blue, p.image->colorSpace())); layer4->paintDevice()->fill(rect4, KoColor(Qt::yellow, p.image->colorSpace())); layer5->paintDevice()->fill(rect5, KoColor(Qt::green, p.image->colorSpace())); layer6->paintDevice()->fill(rect6, KoColor(Qt::cyan, p.image->colorSpace())); layer7->paintDevice()->fill(rect7, KoColor(Qt::red, p.image->colorSpace())); layer8->paintDevice()->fill(rect8, KoColor(Qt::green, p.image->colorSpace())); KisPSDLayerStyleSP style(new KisPSDLayerStyle()); style->dropShadow()->setEffectEnabled(true); style->dropShadow()->setDistance(10.0); style->dropShadow()->setSpread(80.0); style->dropShadow()->setSize(10); style->dropShadow()->setNoise(0); style->dropShadow()->setKnocksOut(false); style->dropShadow()->setOpacity(80.0); layer2->setLayerStyle(style); layer2->setCompositeOp(COMPOSITE_ADD); group1->setCompositeOp(COMPOSITE_ADD); p.image->addNode(layer5); p.image->addNode(layer2); p.image->addNode(tmask, layer2); p.image->addNode(group1); p.image->addNode(layer3, group1); p.image->addNode(layer4, group1); p.image->addNode(layer6); p.image->addNode(layer7); p.image->addNode(layer8); p.image->initialRefreshGraph(); // dbgKrita << ppVar(layer1->exactBounds()); // dbgKrita << ppVar(layer5->exactBounds()); // dbgKrita << ppVar(layer2->exactBounds()); // dbgKrita << ppVar(group1->exactBounds()); // dbgKrita << ppVar(layer3->exactBounds()); // dbgKrita << ppVar(layer4->exactBounds()); TestUtil::ExternalImageChecker chk("flatten", "imagetest"); QVERIFY(chk.checkDevice(p.image->projection(), p.image, "00_initial")); }
void CDigitalStatusPrinter::PrintSinglTable(QPainter*p) { int textWidth = p->window().width(); int textHeight = p->window().height(); QFontMetrics metics(m_font); QString strXuhao = QString("序号"); QString strDesc = QString("描述");// : 实际值"); QString strMaohao = QString(":"); QString strActual = QString("实际值"); int nDescWidth = metics.width(strDesc); int nDescHeight = metics.height(); printf("nDescHeight=%d\n",nDescHeight); DigitalStatusList SettingLst = m_pComTrade->GetDigitalStatusList(); /*m_nCurrentY*/ int nActualWidth = textWidth-m_nLeftMargin-m_nRightMargin; int nActualHeight = textHeight-m_nCurrentY-m_nBottomMargin; int nTableCoumn = nActualHeight/(nDescHeight+minStep)-1; m_nTableColum = nTableCoumn; nActualHeight = (nTableCoumn+1)*(nDescHeight+minStep); p->drawLine(m_nLeftMargin,m_nCurrentY,textWidth-m_nRightMargin,m_nCurrentY); p->drawLine(m_nLeftMargin,m_nCurrentY,m_nLeftMargin,nActualHeight+m_nCurrentY); p->drawLine(nActualWidth/2+m_nLeftMargin,m_nCurrentY,nActualWidth/2+m_nLeftMargin, nActualHeight+m_nCurrentY); //下限不要了 p->drawLine(m_nLeftMargin,nActualHeight+m_nCurrentY,m_nLeftMargin+nActualWidth,nActualHeight+m_nCurrentY); int nTitleWidth = metics.width(strXuhao); int nTitleHeight = metics.height(); int nMaohaoWidth = metics.width(strMaohao); p->drawLine(nTitleWidth+minStep+m_nLeftMargin,m_nCurrentY,nTitleWidth+minStep+m_nLeftMargin,nActualHeight+m_nCurrentY/*textHeight*/); p->drawLine(nActualWidth+m_nLeftMargin,m_nCurrentY,nActualWidth+m_nLeftMargin,nActualHeight+m_nCurrentY/*textHeight*/); QRectF rect(m_nLeftMargin+minStep,m_nCurrentY+minStep,minStep+nTitleWidth,minStep+nTitleHeight); p->drawText(rect,strXuhao); QRectF rect2(minStep+nActualWidth/2+m_nLeftMargin,m_nCurrentY+minStep,minStep+nTitleWidth, minStep+nTitleHeight); p->drawText(rect2,strXuhao); p->drawLine(3*minStep+nActualWidth/2+m_nLeftMargin+nTitleWidth,m_nCurrentY, 3*minStep+nActualWidth/2+m_nLeftMargin+nTitleWidth,nActualHeight+m_nCurrentY/*textHeight*/); QRectF rect3(2*minStep+nTitleWidth+m_nLeftMargin,m_nCurrentY+minStep,nDescWidth,nTitleHeight); p->drawText(rect3,strDesc); QRectF rect4(4*minStep+nActualWidth/2+nTitleWidth+m_nLeftMargin,m_nCurrentY+minStep, nDescWidth,nTitleHeight); p->drawText(rect4,strDesc); QRectF rectMao1(3*nActualWidth/8+m_nLeftMargin,m_nCurrentY+minStep, nMaohaoWidth+minStep,nTitleHeight); p->drawText(rectMao1,strMaohao); QRectF rectMao2(7*nActualWidth/8+m_nLeftMargin,m_nCurrentY+minStep, nMaohaoWidth+minStep,nTitleHeight); p->drawText(rectMao2,strMaohao); int nActualWid = metics.width(strActual); QRectF rectActual1(m_nLeftMargin+nActualWidth/2-minStep-nActualWid,m_nCurrentY+minStep, nActualWid,nTitleHeight); p->drawText(rectActual1,strActual); QRectF rectActual2(m_nLeftMargin+nActualWidth-minStep-nActualWid,m_nCurrentY+minStep, nActualWid,nTitleHeight); p->drawText(rectActual2,strActual); m_nCurrentY = m_nCurrentY+2*minStep+nTitleHeight; for(int nIndex=0;nIndex<m_nTableColum*2;nIndex++) { //int SettingNum = nIndex+nPageIndex*m_nTableColum*2; if(m_nCurrentIndex>=SettingLst.count()) { return; } CDigitalStatus settingValue = SettingLst.at(m_nCurrentIndex); QString strNumber = QString::number(m_nCurrentIndex+1/*nIndex+1*/); //int nY =m_nCurrentY+nIndex*(minStep+nDescHeight); QString strDesc = settingValue.m_strName; QString strValue = QString::number(settingValue.m_nValue)+QString(" "); //左边 if(nIndex<m_nTableColum) { QRectF rectNum(m_nLeftMargin+minStep,m_nCurrentY+nIndex*(minStep+nDescHeight), minStep+nTitleWidth,nTitleHeight); p->drawText(rectNum,strNumber); int nDescWid = metics.width(strDesc); QRectF rectDesc(2*minStep+nTitleWidth+m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), nDescWid, nDescHeight); p->drawText(rectDesc,strDesc); QRectF rectMao(3*nActualWidth/8+m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), nMaohaoWidth,nDescHeight); //p->drawText(rectMao,strMaohao); //计算冒号的位置 int nValueWidth = metics.width(strValue); int nStartPoint = nActualWidth/2-nValueWidth+m_nLeftMargin-minStep; QRectF rectValue(nStartPoint,m_nCurrentY+nIndex*(minStep+nDescHeight), nValueWidth,nDescHeight); p->drawText(rectValue,strValue); //如果值太长了,那就不要冒号了 if(!rectValue.contains(rectMao)) { p->drawText(rectMao,strMaohao); } p->drawLine(m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), m_nLeftMargin+nActualWidth,m_nCurrentY+nIndex*(minStep+nDescHeight)); } //右边 else if(nIndex<m_nTableColum*2&&nIndex>=m_nTableColum) { QRectF rectNum(minStep*2+nActualWidth/2+m_nLeftMargin,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nTitleWidth,nTitleHeight); p->drawText(rectNum,strNumber); int nDescWid = metics.width(strDesc); QRectF rectDesc(4*minStep+nTitleWidth+nActualWidth/2+m_nLeftMargin, m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nDescWid, nDescHeight); //QRectF rectDesc(4*minStep+nTitleWidth+textWidth/2,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), // 2*minStep+nTitleWidth+5*textWidth/8,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight)+nDescHeight); p->drawText(rectDesc,strDesc); QRectF rectMao(7*nActualWidth/8+m_nLeftMargin,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nMaohaoWidth,nDescHeight); //p->drawText(rectMao,strMaohao); int nValueWidth = metics.width(strValue); int nStartPoint = m_nLeftMargin+nActualWidth-nValueWidth-minStep; QRectF rectValue(nStartPoint,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nValueWidth,nDescHeight); p->drawText(rectValue,strValue); //如果值太长了,那就不要冒号了 if(!rectValue.contains(rectMao)) { p->drawText(rectMao,strMaohao); } } m_nCurrentIndex++; } //continue print on new page if(m_nCurrentIndex<SettingLst.count()) { m_nCurrentY = m_nTopMargin; m_pPrinter->newPage(); PrintSinglTable(p); } }
int Events::handleOneShot(Event *event) { Surface *backBuffer; ScriptThread *sthread; Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: _vm->_scene->_textList.remove((TextListEntry *)event->data); break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: _vm->_music->stop(); if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface; BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { backBuffer = _vm->_gfx->getBackBuffer(); backGroundSurface = _vm->_render->getBackGroundSurface(); _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); sthread = _vm->_script->createThread(event->param, event->param2); if (sthread == NULL) { _vm->_console->DebugPrintf("Thread creation failed.\n"); break; } sthread->_threadVars[kThreadVarAction] = event->param3; sthread->_threadVars[kThreadVarObject] = event->param4; sthread->_threadVars[kThreadVarWithObject] = event->param5; sthread->_threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; ((Surface *)event->data)->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } default: break; } return kEvStDelete; }
void GraphicTestWindow::onPaint(int width, int height) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); _image.setTextureCoordinate(1, 3); _image.setSize(_image.originalSize()); _image.draw(); _rect.setColor(QColor(0, 255, 0)); _rect.setRect(50, 100, 500, 75); _rect.draw(); _rect.setColor(QColor(0, 255, 255)); _rect.setRect(50, 175, 500, 25); _rect.draw(); int textCount = 1; int quadCount = 1; QString textContent("Change the text from the settings"); if(_settings) { quadCount = _settings->quadCount(); textCount = _settings->textCount(); textContent = _settings->textContent(); } for(int i = 0; i < textCount; i++) { PhGraphicText text1(&_font1, textContent); text1.setRect(i % 200, i / 200, 500, 100); text1.setColor(QColor(128, 255, 0)); text1.setZ(5); text1.draw(); } _font1.setFontFile(_settings->font1File()); _font1.select(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glColor3f(0, 0, 1); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); //Begining the cube's drawing { for(int i = 0; i < quadCount; i++) { glTexCoord3f(0, 0, 1); glVertex3i(0, 0, 0); glTexCoord3f(1, 0, 1); glVertex3i(width, 0, 0); glTexCoord3f(1, 1, 1); glVertex3i(width, height, 0); glTexCoord3f(0, 1, 1); glVertex3i(0, height, 0); } } glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); // _text.setX(_text.getX() + 4); // if(_text.getX() > this.width()) // _text.setX(0); // if((_text.getX()+_text.getWidth()) < 0) // _text.setX(this.width()); PhGraphicSolidRect rect3(0, 800, 400, 300); rect3.setColor(Qt::blue); rect3.draw(); PhGraphicLoop vLoop; vLoop.setPosition(100, 500, 3); vLoop.setSize(220, 200); vLoop.setThickness(30); vLoop.setCrossSize(100); vLoop.setColor(QColor(255, 0, 255)); vLoop.draw(); PhGraphicLoop hLoop; hLoop.setHorizontalLoop(true); hLoop.setPosition(0, 800, 3); hLoop.setSize(300, 50); hLoop.setThickness(20); hLoop.setCrossSize(60); hLoop.setColor(QColor(255, 0, 255)); hLoop.draw(); //_yuvRect.draw(); PhGraphicDisc disc(300, 300, 100); disc.setColor(Qt::yellow); disc.draw(); for (int i = 0; i < 5; ++i) { PhGraphicDashedLine line(i, 0, 50*i, 300, 30); line.setColor(Qt::green); line.setZ(4); line.draw(); } PhGraphicArrow arrow1(PhGraphicArrow::DownLeftToUpRight, 150, 250, 200, 100); arrow1.setColor(Qt::red); arrow1.setZ(5); arrow1.draw(); PhGraphicArrow arrow2(PhGraphicArrow::UpLefToDownRight, 150, 400, 200, 100); arrow2.setColor(Qt::red); arrow2.setZ(5); arrow2.draw(); _yuvRect.draw(); _rgbRect.draw(); _font2.setFontFile(_settings->font2File()); _font2.select(); PhGraphicText text2(&_font2, "eéaàiîoô"); int textWidth = 500; text2.setRect(_x, 300, textWidth, 100); text2.setColor(QColor(255, 0, 0)); text2.setZ(1); text2.draw(); _x += 4; if(_x > width) _x = -textWidth; }
static void draw_graph( QPainter &painter, int w, /* width */ int h, /* height */ int margin, double *X, /* x-values */ double *Y, /* y-values */ unsigned int N /* number of X[], Y[] */ ) { if ((w <= 3*margin) || (h <= 2*margin)) return; /* Qt coordinate system */ int x0 = 2*margin; int x1 = w - margin; int y0 = margin; int y1 = h - margin; if (x0 >= x1) return; if (y0 >= y1) return; /* draw boundary rectangle */ QRectF rectangle(x0, y0, x1-x0, y1-y0); painter.drawRect(rectangle); if (!X || !Y || !N) return; double Ymin = 0.0; double Ymax = 1.0; double Xmin = X[0]; double Xmax = X[0]; for(uint32_t i=1; i < N; i++) { double x = X[i]; if (x < Xmin) Xmin = x; if (x > Xmax) Xmax = x; } if ((Xmax > Xmin) && (Ymax > Ymin)) { /* allocate */ QPoint **points = (QPoint **) malloc(N*sizeof(QPoint *)); /* convert to qt coordinate system */ for(uint32_t i=0; i < N; i++) { int x = (int) (x0 + (x1 - x0) * (X[i] - Xmin) / (Xmax - Xmin)); int y = (int) (y1 - (y1 - y0) * (Y[i] - Ymin) / (Ymax - Ymin)); points[i] = new QPoint(x, y); } /* order along horizontal axis */ qsort((void *)points, N, sizeof(QPoint *), qpoint_cmp); /* draw line */ for(uint32_t i=0; i+1 < N; i++) painter.drawLine(*points[i], *points[i+1]); int labelwidth = 3*margin/2; int labelheight = margin; const char *labelfmtX = "%.0f"; const char *labelfmtY = "%.2f"; char label[32]; uint32_t labelsz = sizeof(label) - 1; /* draw horizontal labels */ snprintf(label, labelsz, labelfmtX, Xmin); QString XminStr = label; QRectF rect0(x0-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect0, Qt::AlignCenter, XminStr); snprintf(label, labelsz, labelfmtX, Xmax); QString XmaxStr = label; QRectF rect1(x1-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect1, Qt::AlignCenter, XmaxStr); /* draw vertical labels */ snprintf(label, labelsz, labelfmtY, Ymin); QString YminStr = label; QRectF rect2(x0-labelwidth, y1-labelheight/2, labelwidth, labelheight); painter.drawText(rect2, Qt::AlignCenter, YminStr); snprintf(label, labelsz, labelfmtY, Ymax); QString YmaxStr = label; QRectF rect3(x0-labelwidth, y0-labelheight/2, labelwidth, labelheight); painter.drawText(rect3, Qt::AlignCenter, YmaxStr); /* clean up */ for(uint32_t i=0; i < N; i++) delete points[i]; free(points); } else if ((Xmin == Xmax) && (Ymin == Ymax)) { /* draw point */ } else if (Xmin == Xmax) { /* draw vertical line */ } else if (Ymin == Ymax) { /* draw horizontal line */ } }