void main()
{
	std::ifstream instream;

	int cases;

	instream.open("input.txt");
	instream >> cases;

	for (int i = 0; i < cases; i++)
	{
		cross_line cr(instream);
		cr.check();

	}
}
static
void findFloodReach(const RoseBuildImpl &tbi, const RoseVertex v,
                    set<CharReach> &flood_reach) {
    for (u32 lit_id : tbi.g[v].literals) {
        const ue2_literal &s = tbi.literals.right.at(lit_id).s;
        if (s.empty()) {
            continue;
        }
        if (is_flood(s)) {
            CharReach cr(*s.begin());
            DEBUG_PRINTF("flood-prone with reach: %s\n",
                          describeClass(cr).c_str());
            flood_reach.insert(cr);
        }
    }
}
Exemple #3
0
void ChaserRunner_Test::initial()
{
    ChaserRunner cr(m_doc, m_chaser);
    QCOMPARE(cr.m_doc, m_doc);
    QCOMPARE(cr.m_chaser, m_chaser);

    QCOMPARE(cr.m_updateOverrideSpeeds, false);
    QCOMPARE(cr.m_direction, Function::Forward);
    QCOMPARE(cr.m_currentFunction, (Function*) NULL);
    QCOMPARE(cr.m_elapsed, quint32(0));
    QCOMPARE(cr.m_next, false);
    QCOMPARE(cr.m_previous, false);
    QCOMPARE(cr.m_currentStep, 0);
    QCOMPARE(cr.m_newCurrent, -1);
    QCOMPARE(cr.m_intensity, qreal(1.0));
}
bool RenderThemeSymbian::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
    i.context->save();
    IntRect clipRect(intersection(r, i.rect));
    i.context->clip(clipRect);
    EAppearance appearance = o->style()->appearance();    
    IntRect innerRect(r);
    IntSize cr(1,1);
    for (int j = 4; j > 0; --j) {
        innerRect.setSize(innerRect.size() - IntSize(1,1));
        i.context->fillRoundedRect(innerRect, IntSize(1,1), IntSize(1,1), IntSize(1,1), IntSize(1,1), Color(226 - j*10, 226 - j*10, 226 - j*2));
    }

    i.context->restore();
    return false;
}
Exemple #5
0
static void test_scaled(skiatest::Reporter* reporter) {
    int w = 10, h = 10;
    SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h));

    SkBitmap filterResult, paintResult;

    filterResult.allocN32Pixels(w, h);
    SkCanvas canvasFilter(filterResult);
    canvasFilter.clear(0x00000000);

    paintResult.allocN32Pixels(w, h);
    SkCanvas canvasPaint(paintResult);
    canvasPaint.clear(0x00000000);

    SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5));
    SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
    SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
    SkScalar radius = SkIntToScalar(5);

    SkPaint gradientPaint;
    gradientPaint.setShader(SkGradientShader::MakeRadial(
        center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkTileMode::kClamp));

    // Test using the image filter
    {
        SkPaint paint;
        SkImageFilter::CropRect cr(r);
        paint.setImageFilter(SkPaintImageFilter::Make(gradientPaint, &cr));
        canvasFilter.scale(SkIntToScalar(2), SkIntToScalar(2));
        canvasFilter.drawRect(r, paint);
    }

    // Test using the paint directly
    {
        canvasPaint.scale(SkIntToScalar(2), SkIntToScalar(2));
        canvasPaint.drawRect(r, gradientPaint);
    }

    // Assert that both paths yielded the same result
    for (int y = 0; y < r.height(); ++y) {
        const SkPMColor* filterPtr = filterResult.getAddr32(0, y);
        const SkPMColor* paintPtr = paintResult.getAddr32(0, y);
        for (int x = 0; x < r.width(); ++x, ++filterPtr, ++paintPtr) {
            REPORTER_ASSERT(reporter, *filterPtr == *paintPtr);
        }
    }
}
Exemple #6
0
NumericMatrix  Clmbr::cr4R( double CL,  int met, 
	 double incr,  int verboseR ) 
{ 
	if(Model==M3)  {
		Rcout << model_msg << endl << endl;
		return  NumericMatrix(0,0);
	}  

	if(CL <=0. || CL >=1.)  stop( CLmsg );
	const double tmp = SL;
	set_SL(1.-CL);

	METHOD MET;
	if(met==1)  MET=GEO;  else  {
		if(met==2)  MET=AF;  else  { 
			stop( methods2msg );
		}
	}

	double inc;
	if( incr == -1 )  inc= xinc;  else  inc= incr;

	const double  maxwidth = xs[ns-1] - xs[0] + 2;						
	const int  Nmax = maxwidth/inc + ns + 3;

	double*  Btmp= Calloc( Nmax*3, double );

	const bool  verbose = static_cast<bool>( verboseR );
	if( verbose )  
		stop( "dummy argument for dispatch, should be FALSE" );


	const int  nrows = cr( MET, incr, false, Btmp ); 


	set_SL(tmp);

	NumericMatrix  bds( nrows, 3 );
	for(int i=0;i<nrows;i++)  {
		bds(i,0) = *(Btmp + 0*nrows + i);
		bds(i,1) = *(Btmp + 1*nrows + i);
		bds(i,2) = *(Btmp + 2*nrows + i);
	}
	Free( Btmp );

	return bds;
}
wxString KissMangaCom::JSRiddle(wxString Script)
{
    CurlRequest cr(false);
    cr.SetUrl(wxT("http://jsapp.us/ajax"));
    cr.SetPostData(wxT("{\"actions\":[{\"action\":\"test\",\"code\":\"") + Script + wxT("\"}]}"));
    wxString response;
    wxStringOutputStream sos(&response);
    cr.SetOutputStream(&sos);
    cr.ExecuteRequest();

    // open url from response
    cr.SetUrl(response.BeforeLast('"').AfterLast('"'));
    response = wxEmptyString;
    cr.ExecuteRequest();

    return response;
}
void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics,
                              const CFX_RectF* pRect,
                              CFX_Matrix* pMatrix) {
  if (!pGraphics)
    return;
  if (!pRect)
    return;
  pGraphics->SaveGraphState();
  CFX_Color cr(0xFF000000);
  pGraphics->SetStrokeColor(&cr);
  FX_FLOAT DashPattern[2] = {1, 1};
  pGraphics->SetLineDash(0.0f, DashPattern, 2);
  CFX_Path path;
  path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
  pGraphics->StrokePath(&path, pMatrix);
  pGraphics->RestoreGraphState();
}
Exemple #9
0
	eid PhysicsSystem::RayCastIgnore(eid ign) {
		eid cam = 1; // TODO: This hard-coded number should be the active camera id.
		last_rayvalid = false;
		glm::vec3 position;
		if (Entity(cam).Has<Position>()) {
			position = (Entity(cam).Get<Position>())->value;
		}
		glm::quat orientation;
		if (Entity(cam).Has<Orientation>()) {
			orientation = (Entity(cam).Get<Orientation>())->value;
		}
		auto fv = position + glm::rotate(orientation, FORWARD_VECTOR * 300.f);
		btVector3 from(position.x, position.y, position.z), to(fv.x, fv.y, fv.z);
		last_rayfrom = from;
		btDynamicsWorld::AllHitsRayResultCallback cr(from, to);
		this->dynamicsWorld->rayTest(from, to, cr);
		if (cr.hasHit()) {
			int mx = cr.m_collisionObjects.size();
			double lastfrac = 1.1;
			int hc = mx;
			eid entity_hit = 0;
			for (int i = 0; i < mx; i++) {
				eid entity = 0;
				double frc = cr.m_hitFractions.at(i);
				const CollisionBody* coll = (const CollisionBody*)cr.m_collisionObjects.at(i)->getUserPointer();
				if (!coll) continue;
				entity = coll->entity_id;
				if (entity && entity != cam && entity != ign) {
					if (frc < lastfrac) {
						entity_hit = entity;
						hc = i;
						lastfrac = frc;
					}
				}
			}
			if (hc < mx) {
				last_raypos = cr.m_hitPointWorld.at(hc);
				last_raynorm = cr.m_hitNormalWorld.at(hc);
				last_raydist = last_rayfrom.distance(last_raypos);
				last_rayvalid = true;
				return entity_hit;
			}
		}
		return 0;
	}
Exemple #10
0
void ChaserRunner_Test::writeForwardSingleShotFive()
{
    m_chaser->setDirection(Function::Forward);
    m_chaser->setRunOrder(Function::SingleShot);

    uint dur = MasterTimer::tick() * 5;
    m_chaser->setDuration(dur);

    ChaserRunner cr(m_doc, m_chaser);
    MasterTimer timer(m_doc);

    // Step 1
    for (uint i = 0; i < dur; i += MasterTimer::tick())
    {
        QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
        timer.timerTick();
        QCOMPARE(timer.m_functionList.size(), 1);
        QCOMPARE(timer.m_functionList[0], m_scene1);
    }

    // Step 2
    for (uint i = 0; i < dur; i += MasterTimer::tick())
    {
        QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
        timer.timerTick();
        QCOMPARE(timer.m_functionList.size(), 1);
        QCOMPARE(timer.m_functionList[0], m_scene2);
    }

    // Step 3
    for (uint i = 0; i < dur; i += MasterTimer::tick())
    {
        QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
        timer.timerTick();
        QCOMPARE(timer.m_functionList.size(), 1);
        QCOMPARE(timer.m_functionList[0], m_scene3);
    }

    QVERIFY(cr.write(&timer, QList<Universe*>()) == false);
    timer.timerTick();

    cr.postRun(&timer, QList<Universe*>());
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 0);
}
Exemple #11
0
void ChaserRunner_Test::writeForwardPingPongZero()
{
    m_chaser->setDirection(Function::Forward);
    m_chaser->setRunOrder(Function::PingPong);

    ChaserRunner cr(m_doc, m_chaser);
    MasterTimer timer(m_doc);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene1);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene3);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QVERIFY(m_scene1->stopped() == true);
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene1);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QVERIFY(m_scene1->stopped() == true);
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, QList<Universe*>()) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene3);
}
cairo_t* wxGISDisplay::CreateContext(wxDC* dc)
{
    cairo_t *cr(NULL);
#ifdef __WXMSW__
//#if CAIRO_HAS_WIN32_SURFACE
     HDC hdc = (HDC)dc->GetHDC();
     cr = cairo_create(cairo_win32_surface_create( hdc ));
#endif

#ifdef __WXGTK__
     wxGraphicsRenderer * const renderer = wxGraphicsRenderer::GetCairoRenderer();
     wxWindowDC* pwdc =  wxDynamicCast(dc, wxWindowDC);
     wxGraphicsContext * gc = renderer->CreateContext(*pwdc);
     if(gc)
          cr =  (cairo_t*)gc->GetNativeContext();
#endif
     return cr;
}
Exemple #13
0
// add a single note to spectrum
void play_note(int freq, float adsr, fftw_real* out) {

  int i=1;
  float r, p;

  while ( i*freq < N/2 ) {
	r = cr(i);
	p = cp(i);

	// re{ck}
	out[freq*i]   += adsr * N * r*cos(p);

	// im{ck}
	out[N-freq*i] += adsr * N * r*sin(p);

	i++;
  }
}
Exemple #14
0
int main ( ) {


	//TODO: proper replay finding
	std::string path_replay = "C:\\replay.osr";
	std::string path_beat	= "C:\\beatmap.osu";

#ifdef _DEBUG
	//b.Debug_printhitobj( );
#endif

	CReplay r( path_replay, true );
	CBeatmap b;
	b.ReadFile( path_beat );
	CReplayAnalyze cr( b, r );

    return 0;
}
Exemple #15
0
FWL_ERR CFWL_GridImp::DrawWidget(CFX_Graphics* pGraphics,
                                 const CFX_Matrix* pMatrix) {
  if (!pGraphics)
    return FWL_ERR_Indefinite;
  if ((m_pProperties->m_dwStyleExes & FWL_GRIDSTYLEEXT_ShowGridLines) == 0) {
    return FWL_ERR_Succeeded;
  }
  pGraphics->SaveGraphState();
  if (pMatrix) {
    pGraphics->ConcatMatrix(pMatrix);
  }
  {
    FX_BOOL bDrawLine = FALSE;
    CFX_Path path;
    path.Create();
    int32_t iColumns = m_Columns.GetSize();
    for (int32_t i = 1; i < iColumns; i++) {
      CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
      if (!pColRow) {
        continue;
      }
      bDrawLine = TRUE;
      path.AddLine(pColRow->m_fActualPos, 0, pColRow->m_fActualPos,
                   m_pProperties->m_rtWidget.height);
    }
    int32_t iRows = m_Rows.GetSize();
    for (int32_t j = 1; j < iRows; j++) {
      CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[j]);
      if (!pColRow) {
        continue;
      }
      bDrawLine = TRUE;
      path.AddLine(0, pColRow->m_fActualPos, m_pProperties->m_rtWidget.width,
                   pColRow->m_fActualPos);
    }
    if (bDrawLine) {
      CFX_Color cr(0xFFFF0000);
      pGraphics->SetStrokeColor(&cr);
      pGraphics->StrokePath(&path);
    }
  }
  pGraphics->RestoreGraphState();
  return FWL_ERR_Succeeded;
}
void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
  if (!pParams)
    return;

  switch (pParams->m_iPart) {
    case CFWL_Part::Border: {
      DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
      break;
    }
    case CFWL_Part::Background: {
      CFX_Path path;
      CFX_RectF& rect = pParams->m_rtPart;
      path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
      FX_ARGB argb_color;
      switch (pParams->m_dwStates) {
        case CFWL_PartState_Selected:
          argb_color = FWLTHEME_COLOR_BKSelected;
          break;
        case CFWL_PartState_Disabled:
          argb_color = FWLTHEME_COLOR_EDGERB1;
          break;
        default:
          argb_color = 0xFFFFFFFF;
      }
      pParams->m_pGraphics->SaveGraphState();
      CFX_Color cr(argb_color);
      pParams->m_pGraphics->SetFillColor(&cr);
      pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
      pParams->m_pGraphics->RestoreGraphState();
      break;
    }
    case CFWL_Part::DropDownButton: {
      DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix);
      break;
    }
    case CFWL_Part::StretchHandler: {
      DrawStrethHandler(pParams, 0, &pParams->m_matrix);
      break;
    }
    default:
      break;
  }
}
Exemple #17
0
int main(int argc, char **argv){
//	GtkWidget *window;
//
//	    Mat a;
//	    gtk_init(&argc, &argv);
//
//	    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//	    gtk_widget_show(window);
//
//	    gtk_main();
//
//	    return(0);

    ros::init(argc,argv,"facedetect");
    cv::namedWindow(WINDOW);
    cspm_robot cr("/image/camera");
    ros::spin();
    return 0;
    }
Exemple #18
0
void
HGSetBrush(int mode)
{
  register int printed = 0;

  if (linmod != style[--mode]) {
    /* Groff doesn't understand \Ds, so we take it out */
    /* printf ("\\D's %du'", linmod = style[mode]); */
    linmod = style[mode];
    printed = 1;
  }
  if (linethickness != thick[mode]) {
    linethickness = thick[mode];
    printf("\\h'-%.2fp'\\D't %.2fp'", linethickness, linethickness);
    printed = 1;
  }
  if (printed)
    cr();
}
void ChaserRunner_Test::writeBackwardPingPongZero()
{
    m_chaser->setDirection(Function::Backward);
    m_chaser->setRunOrder(Function::PingPong);

    ChaserRunner cr(m_doc, m_chaser);
    MasterTimer timer(m_doc);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene3);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene1);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene3);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene2);

    QVERIFY(cr.write(&timer, NULL) == true);
    timer.timerTick();
    QCOMPARE(timer.m_functionList.size(), 1);
    QCOMPARE(timer.m_functionList[0], m_scene1);
}
Exemple #20
0
void Membrane::computeNodalDisplacements(Real dt, bool rotIncr){
	assert(hasRefConf());
	// supposes node is updated already
	for(int i:{0,1,2}){
		Vector3r xy=node->glob2loc(nodes[i]->pos);
		// relative tolerance of 1e-6 was too little, in some cases?!
		#ifdef MEMBRANE_DEBUG_ROT
			if(xy[2]>1e-5*(max(abs(xy[0]),abs(xy[1])))){
				LOG_ERROR("local z-coordinate is not zero for node "<<i<<": node->ori="<<AngleAxisr(node->ori).axis()<<" !"<<AngleAxisr(node->ori).angle()<<", xy="<<xy<<", position in global-oriented centroid-origin CS "<<(nodes[i]->pos-node->pos).transpose());
			}
		#else
			assert(xy[2]<1e-5*(max(abs(xy[0]),abs(xy[1]))));
		#endif
		// displacements
		uXy.segment<2>(2*i)=xy.head<2>()-refPos.segment<2>(2*i);
		// rotations
		if(rotIncr){
			// incremental
			Vector3r angVelL=node->glob2loc(nodes[i]->getData<DemData>().angVel); // angular velocity in element coords
			phiXy.segment<2>(2*i)-=dt*angVelL.head<2>();
			// throw std::runtime_error("Incremental rotation (In2_ElastMat_Membrane.rotIncr) is not yet implemented properly.");
		} else {
			// from total rotation difference
			AngleAxisr aa(refRot[i].conjugate()*(nodes[i]->ori.conjugate()*node->ori));
			/* aa sometimes gives angle close to 2π for rotations which are actually small and negative;
				I posted that question at http://forum.kde.org/viewtopic.php?f=74&t=110854 .
				Such a result is fixed by conditionally subtracting 2π:
			*/
			if(aa.angle()>M_PI) aa.angle()-=2*M_PI;
			Vector3r rot=Vector3r(aa.angle()*aa.axis()); // rotation vector in local coords
			// if(aa.angle()>3)
			if(rot.head<2>().squaredNorm()>3.1*3.1) LOG_WARN("Membrane's in-plane rotation in a node is > 3.1 radians, expect unstability!");
			phiXy.segment<2>(2*i)=rot.head<2>(); // drilling rotation discarded
			#ifdef MEMBRANE_DEBUG_ROT
				AngleAxisr rr(refRot[i]);
				AngleAxisr cr(nodes[i]->ori.conjugate()*node->ori);
				LOG_TRACE("node "<<i<<"\n   refRot : "<<rr.axis()<<" !"<<rr.angle()<<"\n   currRot: "<<cr.axis()<<" !"<<cr.angle()<<"\n   diffRot: "<<aa.axis()<<" !"<<aa.angle());
				drill[i]=rot[2];
				currRot[i]=nodes[i]->ori.conjugate()*node->ori;
			#endif
		}
	}
};
Exemple #21
0
void EventWidget::resizeEvent( QResizeEvent *re )
{
  // outta here if no changes necessary
  if (re && (re->size() == re->oldSize()))
    return;

  register int xOff, yOff;
  register int w, h;
  QRect cr(contentsRect());
  QRect fr(frameRect());

  xOff = fr.left(); yOff = fr.top();
  if (useHandle) {
    handleFrame->setGeometry(xOff, yOff, 
			     HANDLESIZE, fr.height());
    xOff += HANDLESIZE;
  } else {
    handleFrame->hide();
  }

  yOff = cr.top();
  w = fr.width() - (HANDLESIZE + frameWidth());
  // we need to do this initial resize to the new width of the window so
  // we see how many lines of text it will take up.  Then we can adjust the
  // height based on this.
  textBox->resize(w, textBox->height());
  textBox->fitText();

  h = textBox->lines() * textBox->fontMetrics().height();
  textBox->setGeometry(xOff, yOff, w, 
		       h <= cr.height() ? h : cr.height());
  yOff += h <= cr.height() ? h : cr.height();

  h = textBox->height() + MAXPMSIZE;
  if (useIcons) {
    iconBox->setGeometry(xOff, yOff, 
			 w, h <= cr.height() ? 
			 MAXPMSIZE : cr.height() - textBox->height());
  } else {
    iconBox->hide();
  }
}
void CDittoWindow::DrawMinimizeBtn(CWindowDC &dc)
{
	if(m_bDrawMinimize == false)
	{
		return;
	}

	//rows first then columns
	int Points[5][6] =
	{
			0,0,0,0,0,0,
			0,0,0,0,0,0,
			0,0,0,0,0,0,
			1,1,1,1,1,0,
			1,1,1,1,1,0
	};

	CPoint ptShift = m_crMinimizeBT.TopLeft();
	ptShift.Offset(3, 3);

	if(m_bMouseDownOnMinimize)
	{
		dc.Draw3dRect(m_crMinimizeBT, RGB(255, 255, 255), RGB(255, 255, 255));
		CRect cr(m_crMinimizeBT);
		cr.DeflateRect(1, 1, 1, 1);
		dc.Draw3dRect(cr, RGB(255, 255, 255), RGB(255, 255, 255));
	}
	else if(m_bMouseOverMinimize)
	{
		dc.Draw3dRect(m_crMinimizeBT, RGB(255, 255, 255), RGB(255, 255, 255));
	}

	for (int iRow = 0; iRow < 5; iRow++)
	{
		for (int iCol = 0; iCol < 6; iCol++)
		{
			if (Points[iRow][iCol] == 1)
				dc.SetPixel(ptShift+CPoint(iCol, iRow), RGB(255, 255, 255));
		}
	}
}
static void PaintHDC(LabelWithCloseWnd *w, HDC hdc, const PAINTSTRUCT& ps)
{
    HBRUSH br = CreateSolidBrush(w->bgCol);
    FillRect(hdc, &ps.rcPaint, br);

    ClientRect cr(w->hwnd);

    int x = win::DpiAdjust(w->hwnd, w->padL);
    int y = win::DpiAdjust(w->hwnd, w->padT);
    UINT opts = ETO_OPAQUE;
    if (IsRtl(w->hwnd)) {
        opts = opts | ETO_RTLREADING;
    }

    HGDIOBJ prevFont = NULL;
    if (w->font) {
        prevFont = SelectObject(hdc, w->font);
    }
    SetTextColor(hdc, w->txtCol);
    SetBkColor(hdc, w->bgCol);

    WCHAR *s = win::GetText(w->hwnd);
    ExtTextOut(hdc, x, y, opts, NULL, s, (UINT)str::Len(s), NULL);
    free(s);

    // Text might be too long and invade close button area. We just re-paint
    // the background, which is not the pretties but works.
    // A better way would be to intelligently truncate text or shrink the font
    // size (within reason)
    x = w->closeBtnPos.x - win::DpiAdjust(w->hwnd, LABEL_BUTTON_SPACE_DX);
    RectI ri(x, 0, cr.dx - x, cr.dy);
    RECT r = ri.ToRECT();
    FillRect(hdc, &r, br);

    DrawCloseButton(hdc, w->closeBtnPos, IsMouseOverClose(w));
    DeleteObject(br);

    if (w->font) {
        SelectObject(hdc, prevFont);
    }
}
Exemple #24
0
void LibreFM::handshake(QString user, QString password)
{
	if(connected || delayed) return;
	if(httpPostId) {
		QList<QVariant> item;
		stack << item;
		return;
	}
	if(proxy->hasVariable("proxyEnabled") && proxy->getVariable("proxyEnabled") == "true") {
		http.setProxy(proxy->getVariable("proxyHost"),
					  proxy->getVariable("proxyPort").toInt(),
					  proxy->getVariable("proxyUser"),
					  proxy->getVariable("proxyPassword"));
	}

	try_count ++;
	if(try_count > 3) {
		delayed = true;
		QTimer::singleShot(300000, this, SLOT(timerConnect()));  // 5 minutes before continue
		return;
	}

	uint time = QDateTime::currentDateTime().toTime_t();
	QCryptographicHash cr_p(QCryptographicHash::Md5);
	cr_p.addData(password.toLocal8Bit());
	QCryptographicHash cr(QCryptographicHash::Md5);
	cr.addData((QString(cr_p.result().toHex())+QString::number(time)).toLocal8Bit());
	QString token = QString(cr.result().toHex());

	QUrl url("http://"+HOST+"/?");
	url.addQueryItem("hs", "true");
	url.addQueryItem("p", "1.2.1");
	url.addQueryItem("c", "cub");
	url.addQueryItem("v", CUBEROK_VERSION);
	url.addQueryItem("u", user);
	url.addQueryItem("t", QString::number(time));
	url.addQueryItem("a", token);

	http.setHost(HOST, QHttp::ConnectionModeHttp, 80);
	httpGetId = http.get(QString(url.toEncoded()));
}
void WindowPointer::GtkPointerDrawingArea::draw_on_window(Glib::RefPtr<Gdk::Window> window, GdkEventExpose *event) {
	Cairo::RefPtr<Cairo::Context> cr(new Cairo::Context(gdk_cairo_create(window->gobj()), true));
	if (event) {
		//cout << "WIDTH, HEIGHT: " << event->area.width << ", " << event->area.height << endl;
		//cout << "GET WIDTH, HEIGHT: " << get_width() << ", " << get_height() << endl;
	    cr->rectangle(event->area.x, event->area.y,
				event->area.width, event->area.height);
	    cr->clip();
		//cout << "AFTER GET WIDTH, HEIGHT: " << get_width() << ", " << get_height() << endl;
	}
	
	cr->set_source_rgb(0.647, 0.7294, 0.8314);//(1.0, 1.0, 1.0);
	cr->paint();
	cr->set_source_rgb(spec.red, spec.green, spec.blue);
	cr->arc(get_width()/2, get_height()/2, get_height()/3, 0, 2*M_PI);
	cr->fill();
// 	Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);
// 	color.set_blue(100);
// 	gc->set_foreground(color);
// 	window->draw_arc(gc, true, 0, 0, get_width(), get_height(), 0, 360*64);
}
Exemple #26
0
void Table::paintEvent(QPaintEvent *event)
{
	Super::paintEvent(event);
	if(m_rowCount == 0)
		return;
	ClassCellRenderer cr(m_cellSize, this);
	ResultsCellRenderer rr(m_cellSize, this);
	int ix = 0;
	for (int j = 0; j < m_columnCount; ++j) {
		for (int i = 0; i < m_rowCount; ++i) {
			QPoint pos(j * m_cellSize.width(), i * m_cellSize.height());
			QVariantMap data = model()->data(ix);
			QString data_type = data.value(QStringLiteral("type")).toString();
			if(data_type == QLatin1String("classInfo"))
				cr.draw(pos, data, this);
			else
				rr.draw(pos, data, this);
			ix++;
		}
	}
}
Exemple #27
0
void ChaserRunner_Test::roundCheckSingleShotBackward()
{
    m_chaser->setDirection(Function::Backward);
    m_chaser->setRunOrder(Function::SingleShot);
    m_chaser->setDuration(Function::infiniteSpeed());
    ChaserRunner cr(m_doc, m_chaser);

    QCOMPARE(cr.currentStep(), 2);
    QVERIFY(cr.roundCheck() == true);
    cr.m_currentStep = 1;
    QVERIFY(cr.roundCheck() == true);
    cr.m_currentStep = 0;
    QVERIFY(cr.roundCheck() == true);
    cr.m_currentStep = 3; // Over list.size
    QVERIFY(cr.roundCheck() == false);
    cr.m_currentStep = -1; // Under list.size
    QVERIFY(cr.roundCheck() == false);

    cr.reset();
    QCOMPARE(cr.currentStep(), 2);
}
Exemple #28
0
void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics,
                                    FX_ARGB fillColor,
                                    const CFX_RectF* pRect,
                                    FX_FLOAT fRingWidth,
                                    CFX_Matrix* pMatrix) {
  if (!pGraphics)
    return;
  if (!pRect)
    return;
  pGraphics->SaveGraphState();
  CFX_Color cr(fillColor);
  pGraphics->SetFillColor(&cr);
  CFX_Path path;
  path.Create();
  CFX_RectF rtInner(*pRect);
  rtInner.Deflate(fRingWidth, fRingWidth);
  path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
  path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
  pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
  pGraphics->RestoreGraphState();
}
Exemple #29
0
bool tcOptionsView::ButtonContainingPoint(wxPoint point, int& rnOption, int& rnValue) 
{
	int nx, ny;

	point.y = mnHeight - point.y;

    for (size_t k=0; k<buttonInfo.size(); k++)
    {
        nx = buttonInfo[k].buttonX;
        ny = buttonInfo[k].buttonY;
        wxRect cr(nx, ny, mnButtonWidth, mnButtonHeight);
        if (cr.Contains(point)) 
        {
            rnOption = buttonInfo[k].optionIdx;
            rnValue = buttonInfo[k].valueIdx;
            return true;
        }
    }

	return false;
}
Exemple #30
0
// http://www.codeproject.com/KB/GDI-plus/measurestring.aspx
RectF MeasureTextAccurate(Graphics *g, Font *f, const WCHAR *s, int len)
{
    if (0 == len)
        return RectF(0, 0, 0, 0); // TODO: should set height to font's height
    // note: frankly, I don't see a difference between those StringFormat variations
    StringFormat sf(StringFormat::GenericTypographic());
    sf.SetFormatFlags(sf.GetFormatFlags() | StringFormatFlagsMeasureTrailingSpaces);
    //StringFormat sf(StringFormat::GenericDefault());
    //StringFormat sf;
    RectF layoutRect;
    CharacterRange cr(0, len);
    sf.SetMeasurableCharacterRanges(1, &cr);
    Region r;
    Status status = g->MeasureCharacterRanges(s, len, f, layoutRect, &sf, 1, &r);
    CrashIf(status != Ok);
    RectF bbox;
    r.GetBounds(&bbox, g);
    if (bbox.Width != 0)
        bbox.Width += PER_STR_DX_ADJUST + (PER_CHAR_DX_ADJUST * (float)len);
    return bbox;
}