Пример #1
0
void stCurveView::Draw(BRect area)
{
	uint32 i;
	for (i=0;i<knob_count;i++)
		points[i] = knob[i]->Position();

	points[i++]=BPoint(width,knob[knob_count-1]->Position().y);
	points[i++]=BPoint(width,0);
	points[i]=BPoint(0,0);
	
	FillPolygon(points,knob_count+3,B_SOLID_LOW);

	i=knob_count;
	points[i++]=BPoint(width,knob[knob_count-1]->Position().y);
	points[i++]=BPoint(width,m_height);
	points[i]=BPoint(0,m_height);
	
	FillPolygon(points,knob_count+3);

	points[0] = BPoint(0,0);
	points[1] = BPoint(0,m_height);
	points[2] = knob[0]->Position();
	
	SetHighColor(175,175,217);
	
	FillPolygon(points,3);

	SetHighColor(0,0,0,60);
	SetDrawingMode(B_OP_ALPHA);
	DrawString(m_name, m_name_pos);
	DrawString("time", BPoint(width - StringWidth("time"), m_height - 8));
	SetDrawingMode(B_OP_COPY);
	SetHighColor(136,136,234,255);
}
Пример #2
0
void Renderer::FillPolygon(const std::vector<Vector2D> vecPoints, bool close) 
{
	Vector2D* points = new Vector2D[(int)vecPoints.size()];
	for (int i = 0; i < (int)vecPoints.size(); ++i) points[i] = vecPoints[i];

	FillPolygon(points, (int)vecPoints.size(), close);
}
Пример #3
0
void DrawConnectedComp1(string SVGfname, Matrix<int> m, char *StrokeColor, double StrokeWidth, double opacity, Matrix<double> lon, Matrix<double> lat, double xmin, double ymin, bool smooth){
    Matrix<int> mask = getCCLabeling(m, false);
    WriteMatrixFile(mask,"CC_CC.txt");
    int maxVal = 0;
    maxVal = mask.getMax();
    //cout << "CC max val: " << maxVal << endl;
    vector<IntPairVector> contour;
    Matrix<int> temp;

    //string ff = "b";
    for(int k=1; k<=maxVal; k++){
        contour.clear();
        temp = Matrix<int>(m.getXdim(), m.getYdim(), 0);
        for(int i=0; i<temp.getXdim(); i++)
            for(int j=0; j<temp.getYdim(); j++)
                if(mask(i,j) == k)
                    temp(i,j) = 1;
        //if(k==6){
        //    WriteMatrixFile(temp, "check.txt");
        //if(CCWithHole(temp))
            //cout << "HOOOOOLE: " << k << endl;
        //}

        contour = MooreNeighborTracingIndx(temp);
        FillPolygon(SVGfname, contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
    }
}
Пример #4
0
void RenderHelper::DrawCylinder(const Vector3 & center, float32 radius, bool useFilling)
{
	Polygon3 pts;
    float32 angle = SEGMENT_LENGTH / radius;
	int32 ptsCount = (int32)(PI_2 / (DegToRad(angle))) + 1;

	Vector<Vector2> vertexes;
	for(int32 i = 0; i <= ptsCount; i++)
 	{
		float32 seta = i * 360.0f / (float32)ptsCount;
  		float32 x = sin(DegToRad(seta)) * radius;
  		float32 y = cos(DegToRad(seta)) * radius;

		vertexes.push_back(Vector2(x, y));
	}
	
	for(int32 i = 0; i < ptsCount; ++i)
	{
		pts.AddPoint((Vector3(vertexes[i].x,  vertexes[i].y,  1) * radius) + center);
		pts.AddPoint((Vector3(vertexes[i].x,  vertexes[i].y,  -1) * radius) + center);
		pts.AddPoint((Vector3(vertexes[i+1].x, vertexes[i+1].y,  -1) * radius) + center);
		pts.AddPoint((Vector3(vertexes[i].x,  vertexes[i].y,  1) * radius) + center);
		pts.AddPoint((Vector3(vertexes[i+1].x, vertexes[i+1].y,  1) * radius) + center);
		pts.AddPoint((Vector3(vertexes[i+1].x, vertexes[i+1].y,  -1) * radius) + center);
	}
	
	if (useFilling)
	{
		FillPolygon(pts);
	}
	else
	{
		DrawPolygon(pts, true);
	}
}
Пример #5
0
void MonocularManhattanBnb::TransferBuilding(const SE3<>& new_pose,
                                             double floor_z,
                                             MatI& orients) {
	// Compute scaling (TODO: actually use this)
	DiagonalMatrix<3> Mscale(makeVector(1.0*orients.Cols()/pc->image_size()[0],
																			1.0*orients.Rows()/pc->image_size()[1],
																			1.0));

	// Invert the pose
	const SE3<> orig_inv = pc->pose().inverse();

	orients.Fill(vert_axis);
	for (ManhattanBuilding::ConstCnrIt left_cnr = soln.cnrs.begin();
			successor(left_cnr) != soln.cnrs.end();
			left_cnr++) {
		ManhattanBuilding::ConstCnrIt right_cnr = successor(left_cnr);

		//TITLE("Next corner");
		int axis = OtherHorizAxis(left_cnr->right_axis);

		// Compute vertices in the 3D camera frame
		Vec3 bl = FloorPoint(left_cnr->right_floor, floor_z);
		Vec3 br = FloorPoint(right_cnr->left_floor, floor_z);
		Vec3 tl = CeilPoint(left_cnr->right_ceil, bl);
		Vec3 tr = CeilPoint(right_cnr->left_ceil, br);
		if (bl[2] < 0) {
			bl = -bl;
			br = -br;
			tl = -tl;
			tr = -tr;
		}
		// Compute vertices in the 3D global frame
		Vec3 world_tl = orig_inv * tl;
		Vec3 world_tr = orig_inv * tr;
		Vec3 world_bl = orig_inv * bl;
		Vec3 world_br = orig_inv * br;

		// Compute the wall corners in the other camera
		Vec3 ret_tl = new_pose * world_tl;
		Vec3 ret_tr = new_pose * world_tr;
		Vec3 ret_bl = new_pose * world_bl;
		Vec3 ret_br = new_pose * world_br;
		ClipToFront(ret_tr, ret_tl);
		ClipToFront(ret_br, ret_bl);

		// Compute the wall corners in the other image
		Vec3 im_tl = pc->RetToIm(ret_tl);
		Vec3 im_tr = pc->RetToIm(ret_tr);
		Vec3 im_bl = pc->RetToIm(ret_bl);
		Vec3 im_br = pc->RetToIm(ret_br);

		// Build the polygon and fill
		vector<Vec3 > poly;
		poly.push_back(im_tl);
		poly.push_back(im_bl);
		poly.push_back(im_br);
		poly.push_back(im_tr);
		FillPolygon(poly, orients, axis);
	}
}
Пример #6
0
void ACanvasSkia::FillTrigle(APoint pt1,APoint pt2,APoint pt3)
{
	APoint pts[4];
	pts[0] = pt1;
	pts[1] = pt2;
	pts[2] = pt3;
	pts[3] = pt1;
	FillPolygon(pts,4);
}
Пример #7
0
// This is an example of an exported function.
extern "C" CPPLIB_API void DrawFigure(int bitmapArray[], int rowCount, int columnCount, int color, Vertex vertexTab[], int verticesCount)
{
	//tabela z wyznaczonymi przeciêciami w danym rzedzie.
	//maksymalna liczba przeciêæ w danym rzêdzie wynosi 200
	int intersections[200];
	
	for (int row = 0; row < rowCount; row++)
	{
		int numberOfIntersectionInRow = CalculateIntersection(row, verticesCount, vertexTab, intersections);
		SortIntersections(numberOfIntersectionInRow, intersections);
		FillPolygon(numberOfIntersectionInRow, intersections, columnCount, bitmapArray, color, row);
	}
}
Пример #8
0
void RenderHelper::DrawCircle3D(const Vector3 & center, const Vector3 &emissionVector, float32 radius, bool useFilling)
{
	Polygon3 pts;
    float32 angle = SEGMENT_LENGTH / radius;
	int ptsCount = (int)(PI_2 / (DegToRad(angle))) + 1;

	for (int k = 0; k < ptsCount; ++k)
	{
		float32 angleA = ((float)k / (ptsCount - 1)) * PI_2;
		float sinAngle = 0.0f;
		float cosAngle = 0.0f;
		SinCosFast(angleA, sinAngle, cosAngle);

		Vector3 directionVector(radius * cosAngle,
								radius * sinAngle,
								0.0f);
		
		// Rotate the direction vector according to the current emission vector value.
		Vector3 zNormalVector(0.0f, 0.0f, 1.0f);
		Vector3 curEmissionVector = emissionVector;
		curEmissionVector.Normalize();
		
		// This code rotates the (XY) plane with the particles to the direction vector.
		// Taking into account that a normal vector to the (XY) plane is (0,0,1) this
		// code is very simplified version of the generic "plane rotation" code.
		float32 length = curEmissionVector.Length();
		if (FLOAT_EQUAL(length, 0.0f) == false)
		{
			float32 cosAngleRot = curEmissionVector.z / length;
			float32 angleRot = acos(cosAngleRot);
			Vector3 axisRot(curEmissionVector.y, -curEmissionVector.x, 0);

			Matrix3 planeRotMatrix;
			planeRotMatrix.CreateRotation(axisRot, angleRot);
			Vector3 rotatedVector = directionVector * planeRotMatrix;
			directionVector = rotatedVector;
		}
		
		Vector3 pos = center - directionVector;
		pts.AddPoint(pos);
	}
	
	if (useFilling)
	{
		FillPolygon(pts);
	}
	else
	{
    	DrawPolygon(pts, false);
	}
}
Пример #9
0
void VisualColorControl::AttachedToWindow()
{
	BPoint *points = new BPoint[3];
	points[0] = BPoint(0,0);
	points[1] = BPoint(-4,-4);
	points[2] = BPoint(4,-4);

	// calculate the initial ramps
	CalcRamps();

	// create the arrow-pictures
	BeginPicture(new BPicture());
		SetHighColor(100,100,255);
		FillPolygon(points,3);
		SetHighColor(0,0,0);
		StrokePolygon(points,3);
	down_arrow = EndPicture();

	if (Parent() != NULL)
		SetViewColor(Parent()->ViewColor());

	BStringView *sv = new BStringView(BRect(0,COLOR_HEIGHT/2,1,COLOR_HEIGHT/2),"label view",label1);
	AddChild(sv);
	float sv_width = sv->StringWidth(label1);
	sv_width = max_c(sv_width,sv->StringWidth(label2));
	sv_width = max_c(sv_width,sv->StringWidth(label3));
	font_height fHeight;
	sv->GetFontHeight(&fHeight);
	sv->ResizeTo(sv_width,fHeight.ascent+fHeight.descent);
	sv->MoveBy(0,-(fHeight.ascent+fHeight.descent)/2.0);
	BRect sv_frame = sv->Frame();
	sv_frame.OffsetBy(0,COLOR_HEIGHT);
	sv->SetAlignment(B_ALIGN_CENTER);
	sv = new BStringView(sv_frame,"label view",label2);
	AddChild(sv);
	sv->SetAlignment(B_ALIGN_CENTER);
	sv_frame.OffsetBy(0,COLOR_HEIGHT);
	sv = new BStringView(sv_frame,"label view",label3);
	AddChild(sv);
	sv->SetAlignment(B_ALIGN_CENTER);
	sv_frame.OffsetBy(0,COLOR_HEIGHT);
	sv = new BStringView(sv_frame,"label view",label4);
	AddChild(sv);
	sv->SetAlignment(B_ALIGN_CENTER);

	ramp_left_edge = sv->Bounds().IntegerWidth()+2;

	ResizeBy(ramp_left_edge,0);

	delete[] points;
}
Пример #10
0
// Draw
void
FontValueView::Draw(BRect updateRect)
{
	BRect b(Bounds());
	// focus indication
	if (IsFocus()) {
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
		StrokeRect(b);
		b.InsetBy(1.0, 1.0);
		BRegion clipping;
		clipping.Include(b);
		ConstrainClippingRegion(&clipping);
		b.left --;
	}
	// background
	FillRect(b, B_SOLID_LOW);

	rgb_color labelColor = LowColor();
	if (fEnabled)
		labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
	else
		labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);

	SetHighColor(labelColor);

	b.InsetBy(2.0, 1.0);

	float center = floorf(b.top + b.Height() / 2.0);

	BPoint arrow[3];
	arrow[0] = BPoint(b.left, center - 3.0);
	arrow[1] = BPoint(b.left, center + 3.0);
	arrow[2] = BPoint(b.left + 3.0, center);

	FillPolygon(arrow, 3);

	b.left += 6.0;

	BFont font;
	GetFont(&font);

	font_height fh;
	font.GetHeight(&fh);

	BString truncated(fCurrentFont);
	font.TruncateString(&truncated, B_TRUNCATE_END, b.Width());

	DrawString(truncated.String(),
			   BPoint(b.left, floorf(center + fh.ascent / 2.0)));
}
Пример #11
0
// Draws the given model with solid shading.
void Rasterizer::DrawSolidFlat(Model3D& model)
{
	std::vector<Polygon3D> _polygonList = model.GetPolygonList();
	std::vector<Vertex> _vertexList = model.GetTransformedVertexList();
	
	// Iterate over and render each of the polygons in the list.
	for (unsigned int i = 0; i < _polygonList.size(); i++)
	{
		Polygon3D poly = _polygonList[i];
		if (poly.GetBackfacing() == true)
			continue;

		Vertex v1 = _vertexList[poly.GetVertexIndex(0)];
		Vertex v2 = _vertexList[poly.GetVertexIndex(1)];
		Vertex v3 = _vertexList[poly.GetVertexIndex(2)];

		// Fill the polygon using the polygons colour.
		FillPolygon(v1, v2, v3, v1.GetColor());
	}
}
Пример #12
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::SolidFillPolyPolygon( )
//
//  Description:		Fills a solid poly polygon
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RGpDrawingSurface::SolidFillPolyPolygon( const RIntPoint* pPoints, YPointCount* pointCountArray, YPolygonCount polygonCount )
{
    PolyHandle		hPoly;
    int				k = *pointCountArray;

    if ( polygonCount > 1 )
    {
        hPoly = CreatePolygon( pPoints, k );
        for ( int i = 1; i < polygonCount; i++ )
        {
            pPoints += k;
            k = pointCountArray[i];
            AppendPolygonToPolygon( hPoly, pPoints, k );
        }

        ::FillPoly( hPoly, &qd.black );

        ::DisposeHandle( (Handle)hPoly );
    }
    else
        FillPolygon( pPoints, k );
}
Пример #13
0
void
PowerStatusView::_DrawBattery(BRect rect)
{
	float quarter = floorf((rect.Height() + 1) / 4);
	rect.top += quarter;
	rect.bottom -= quarter;

	rect.InsetBy(2, 0);

	float left = rect.left;
	rect.left += rect.Width() / 11;

	if (LowColor().Brightness() > 100)
		SetHighColor(0, 0, 0);
	else
		SetHighColor(128, 128, 128);

	float gap = 1;
	if (rect.Height() > 8) {
		gap = ceilf((rect.left - left) / 2);

		// left
		FillRect(BRect(rect.left, rect.top, rect.left + gap - 1, rect.bottom));
		// right
		FillRect(BRect(rect.right - gap + 1, rect.top, rect.right,
			rect.bottom));
		// top
		FillRect(BRect(rect.left + gap, rect.top, rect.right - gap,
			rect.top + gap - 1));
		// bottom
		FillRect(BRect(rect.left + gap, rect.bottom + 1 - gap,
			rect.right - gap, rect.bottom));
	} else
		StrokeRect(rect);

	FillRect(BRect(left, floorf(rect.top + rect.Height() / 4) + 1,
		rect.left - 1, floorf(rect.bottom - rect.Height() / 4)));

	int32 percent = fPercent;
	if (percent > 100)
		percent = 100;
	else if (percent < 0 || !fHasBattery)
		percent = 0;

	if (percent > 0) {
		rect.InsetBy(gap, gap);
		rgb_color base = (rgb_color){84, 84, 84, 255};
		if (LowColor().Brightness() < 128)
			base = (rgb_color){172, 172, 172, 255};

		if (be_control_look != NULL) {
			BRect empty = rect;
			if (fHasBattery && percent > 0)
				empty.left += empty.Width() * percent / 100.0;

			be_control_look->DrawButtonBackground(this, empty, empty, base,
				fHasBattery
					? BControlLook::B_ACTIVATED : BControlLook::B_DISABLED,
				fHasBattery && percent > 0
					? (BControlLook::B_ALL_BORDERS
						& ~BControlLook::B_LEFT_BORDER)
					: BControlLook::B_ALL_BORDERS);
		}

		if (fHasBattery) {
			if (percent <= kLowBatteryPercentage)
				base.set_to(180, 0, 0);
			else if (percent <= kNoteBatteryPercentage)
				base.set_to(200, 140, 0);
			else
				base.set_to(20, 180, 0);

			rect.right = rect.left + rect.Width() * percent / 100.0;

			if (be_control_look != NULL) {
				be_control_look->DrawButtonBackground(this, rect, rect, base,
					fHasBattery ? 0 : BControlLook::B_DISABLED);
			} else
				FillRect(rect);
		}
	}

	if (fOnline) {
		// When charging, draw a lightning symbol over the battery.
		SetHighColor(255, 255, 0, 180);
		SetDrawingMode(B_OP_ALPHA);
		SetScale(std::min(Bounds().Width(), Bounds().Height()) / 16);

		static const BPoint points[] = {
			BPoint(2, 13),
			BPoint(9, 5),
			BPoint(9, 7),
			BPoint(16, 2),
			BPoint(8, 11),
			BPoint(8, 9)
		};
		FillPolygon(points, 6);

		SetScale(1);
		SetDrawingMode(B_OP_OVER);
	}

	SetHighColor(0, 0, 0);
}
Пример #14
0
void DrawConnectedComp(string SVGfname, Matrix<int> m, char *StrokeColor, double StrokeWidth, double opacity, Matrix<double> lon, Matrix<double> lat, double xmin, double ymin, bool smooth){
    Matrix<int> mask = getCCLabeling(m, false);
    WriteMatrixFile(mask,"CC_CC.txt");
    Matrix<int> recip_mask = Matrix<int>(m.getXdim(), m.getYdim(), 0);
    int maxVal = 0, recip_max = 0;
    maxVal = mask.getMax();
    //cout << "CC max val: " << maxVal << endl;
    vector<IntPairVector> contour, inner_contour;
    Matrix<int> temp, recip_temp;

    //string ff = "b";
    for(int k=1; k<=maxVal; k++){
        contour.clear();
        temp = Matrix<int>(m.getXdim(), m.getYdim(), 0);
        for(int i=0; i<temp.getXdim(); i++)
            for(int j=0; j<temp.getYdim(); j++)
                if(mask(i,j) == k)
                    temp(i,j) = 1;
        contour = MooreNeighborTracingIndx(temp);
        //if(!ContourHitsEdge(contour, temp.getXdim(), temp.getYdim())){
        bool WithHole = false;
        if(CCWithHole(temp)){
            //FillPolygon(SVGfname, contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
            cout << "**HOOOOOLE: " << k << endl;
            recip_mask = getCCLabeling(temp, true);
            recip_max = recip_mask.getMax();
            if(k==2)
            WriteMatrixFile(recip_mask, "recip_mask.txt");
            for(int l=1; l<=recip_max; l++){
                inner_contour.clear();
                recip_temp = Matrix<int>(m.getXdim(), m.getYdim(), 0);
                for(int i=0; i<recip_temp.getXdim(); i++)
                    for(int j=0; j<recip_temp.getYdim(); j++)
                        if(recip_mask(i,j) == l)
                            recip_temp(i,j) = 1;
                inner_contour = MooreNeighborTracingIndx(recip_temp);
                if(!ContourHitsEdge(inner_contour, temp.getXdim(), temp.getYdim())){
                    WithHole = true;
                }
            }
            if(WithHole){
                for(int l=1; l<=recip_max; l++){
                    inner_contour.clear();
                    recip_temp = Matrix<int>(m.getXdim(), m.getYdim(), 0);
                    for(int i=0; i<recip_temp.getXdim(); i++)
                        for(int j=0; j<recip_temp.getYdim(); j++)
                            if(recip_mask(i,j) == l)
                                recip_temp(i,j) = 1;
                    inner_contour = MooreNeighborTracingIndx(recip_temp);
                    if(!ContourHitsEdge(inner_contour, temp.getXdim(), temp.getYdim())){
                        //cout << "about to cut polygon: " << l << ", " << k<< endl;
                        //cout << "CC hole-----" << endl;
                        double dist = 0.0, min_dist = 1000.0;
                         int min_indx = 0;
                         contour.push_back(contour[0]);
                         for(int h=0; h<contour.size(); h++){
                             dist = sqrt((inner_contour[0].first-contour[h].first)*(inner_contour[0].first-contour[h].first)+
                                         (inner_contour[0].second-contour[h].second)*(inner_contour[0].second-contour[h].second));
                             if(dist<min_dist){
                                 min_dist = dist;
                                 min_indx = h;
                             }
                             //cout << contour[h].first << ", " << contour[h].second << ", " << dist << endl;
                         }
                         /*
                         cout<<inner_contour[0].first << ", " << inner_contour[0].second << endl;
                         cout<<inner_contour.back().first << ", " << inner_contour.back().second << endl;
                         cout << contour[min_indx].first << ", " << contour[min_indx].second << endl;
                         cout << "min index: " << min_indx << ", " << contour.size() << endl;
                         cout << "inner_contour size: " << inner_contour.size() << ", " << contour.size() << endl;
                         */

                         inner_contour.push_back(inner_contour[0]);

                         // to add smoothnes
                         inner_contour.push_back(make_pair(int((inner_contour[0].first+contour[min_indx].first)/2), int((inner_contour[0].second+contour[min_indx].second)/2)));

                         for(int h=min_indx; h>=0; h--)
                             inner_contour.push_back(contour[h]);
                         for(int h=contour.size()-1; h>=min_indx; h--)
                            inner_contour.push_back(contour[h]);

                         // to add smoothnes
                         inner_contour.push_back(make_pair(int((inner_contour[0].first+contour[min_indx].first)/2), int((inner_contour[0].second+contour[min_indx].second)/2)));

                         inner_contour.push_back(inner_contour[0]);
                         //for(int i=0; i<inner_contour.size(); i++)
                         //    cout << inner_contour[i].first << ", " << inner_contour[i].second << endl;
                         FillPolygon(SVGfname, inner_contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
                        break;

                    }
                }
            }else{
                FillPolygon(SVGfname, contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
            }
        }else{
            contour = MooreNeighborTracingIndx(temp);
            FillPolygon(SVGfname, contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
        }
    //}else{
    //        FillPolygon(SVGfname, contour, StrokeColor, StrokeColor, StrokeWidth, opacity,lon, lat, xmin, ymin, smooth);
    //    }
    }
}
Пример #15
0
void
SeekSlider::Draw(BRect updateRect)
{
    BRect r(Bounds());

    // draw both sides (the original from Be doesn't seem
    // to make a difference for enabled/disabled state)
//	DrawBitmapAsync(fLeftSideBits, r.LeftTop());
//	DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
    // colors for the slider area between the two bitmaps
    rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
    rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
    rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
    rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
    rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
    rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
    rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
    rgb_color green = kSeekGreen;
    rgb_color greenShadow = kSeekGreenShadow;
    rgb_color black = kBlack;
    rgb_color dotGrey = midShadow;
    rgb_color dotGreen = greenShadow;
    // draw frame
    _StrokeFrame(r, softShadow, softShadow, light, light);
    r.InsetBy(1.0, 1.0);
    _StrokeFrame(r, black, black, softShadow, softShadow);
    if (IsEnabled()) {
        // *** enabled look ***
        r.InsetBy(1.0, 1.0);
        // inner shadow
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
        r.top++;
        r.left++;
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
        // inside area
        r.InsetBy(1.0, 1.0);
        SetHighColor(green);
        FillRect(r);
        // dots
        int32 dotCount = (int32)(r.Width() / 6.0);
        BPoint dotPos;
        dotPos.y = r.top + 2.0;
        SetHighColor(dotGreen);

        float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
        float sliderStart = (r.left + knobWidth2);

        for (int32 i = 0; i < dotCount; i++) {
            dotPos.x = sliderStart + i * 6.0;
            StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 6.0));
        }
        // slider handle
        r.top -= 4.0;
        r.bottom += 3.0;
        r.left = fKnobPos - knobWidth2;
        r.right = fKnobPos + knobWidth2;
        // black outline
        float handleBottomSize = 2.0;
        float handleArrowSize = 6.0;
        BeginLineArray(10);
        // upper handle
        AddLine(BPoint(r.left, r.top + handleBottomSize),
                BPoint(r.left, r.top), black);
        AddLine(BPoint(r.left + 1.0, r.top),
                BPoint(r.right, r.top), black);
        AddLine(BPoint(r.right, r.top + 1.0),
                BPoint(r.right, r.top + handleBottomSize), black);
        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
                BPoint(fKnobPos, r.top + handleArrowSize), black);
        AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0),
                BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), black);
        // lower handle
        AddLine(BPoint(r.left, r.bottom),
                BPoint(r.left, r.bottom - handleBottomSize), black);
        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
                BPoint(fKnobPos, r.bottom - handleArrowSize), black);
        AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0),
                BPoint(r.right, r.bottom - handleBottomSize), black);
        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
                BPoint(r.right, r.bottom), black);
        AddLine(BPoint(r.right - 1.0, r.bottom),
                BPoint(r.left + 1.0, r.bottom), black);
        EndLineArray();
        // inner red light and shadow lines
        r.InsetBy(1.0, 1.0);
        handleBottomSize--;
        handleArrowSize -= 2.0;
        BeginLineArray(10);
        // upper handle
        AddLine(BPoint(r.left, r.top + handleBottomSize),
                BPoint(r.left, r.top), kSeekRedLight);
        AddLine(BPoint(r.left + 1.0, r.top),
                BPoint(r.right, r.top), kSeekRedLight);
        AddLine(BPoint(r.right, r.top + 1.0),
                BPoint(r.right, r.top + handleBottomSize), kSeekRedShadow);
        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
                BPoint(fKnobPos, r.top + handleArrowSize), kSeekRedShadow);
        AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0),
                BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), kSeekRedLight);
        // lower handle
        AddLine(BPoint(r.left, r.bottom),
                BPoint(r.left, r.bottom - handleBottomSize), kSeekRedLight);
        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
                BPoint(fKnobPos, r.bottom - handleArrowSize), kSeekRedLight);
        AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0),
                BPoint(r.right, r.bottom - handleBottomSize), kSeekRedShadow);
        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
                BPoint(r.right, r.bottom), kSeekRedShadow);
        AddLine(BPoint(r.right - 1.0, r.bottom),
                BPoint(r.left + 1.0, r.bottom), kSeekRedShadow);
        EndLineArray();
        // fill rest of handles with red
        SetHighColor(kSeekRed);
        r.InsetBy(1.0, 1.0);
        handleArrowSize -= 2.0;
        BPoint arrow[3];
        // upper handle arrow
        arrow[0].x = r.left;
        arrow[0].y = r.top;
        arrow[1].x = r.right;
        arrow[1].y = r.top;
        arrow[2].x = fKnobPos;
        arrow[2].y = r.top + handleArrowSize;
        FillPolygon(arrow, 3);
        // lower handle arrow
        arrow[0].x = r.left;
        arrow[0].y = r.bottom;
        arrow[1].x = r.right;
        arrow[1].y = r.bottom;
        arrow[2].x = fKnobPos;
        arrow[2].y = r.bottom - handleArrowSize;
        FillPolygon(arrow, 3);
    } else {
        // *** disabled look ***
        r.InsetBy(1.0, 1.0);
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
        r.InsetBy(1.0, 1.0);
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
        r.InsetBy(1.0, 1.0);
        SetHighColor(darkShadow);
        SetLowColor(shadow);
        // stripes
        float width = floorf(StringWidth(fDisabledString.String()));
        float textPos = r.left + r.Width() / 2.0 - width / 2.0;
        pattern stripes = { { 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 } };
        BRect stripesRect(r);
        stripesRect.right = textPos - 5.0;
        FillRect(stripesRect, stripes);
        stripesRect.left = textPos + width + 3.0;
        stripesRect.right = r.right;
        FillRect(stripesRect, stripes);
        // info text
        r.left = textPos - 4.0;
        r.right = textPos + width + 2.0;
        FillRect(r);
        SetHighColor(shadow);
        SetLowColor(darkShadow);
        font_height fh;
        GetFontHeight(&fh);
        DrawString(fDisabledString.String(),
                   BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
    }
}
Пример #16
0
/*=============================================================================================*\
|	Draw																						|
+-----------------------------------------------------------------------------------------------+
|	Effet: Redessiner une partie de la view.													|
|	Entre: 																						|
|		BRect frame: Rectagle qui a besoin d'etre redessine.									|
\*=============================================================================================*/
void ShrinkView::Draw(BRect updateRect)
{
	BPoint pPointList[8];		//Utilise pour dessiner les polygone.
	rgb_color color = {0,0,0,0};
	rgb_color colorHigh = {0,0,0,0};
	
	SetDrawingMode(B_OP_COPY);
	if(m_pBmp)
	{
		uint32 * uiBits = (uint32*)m_pBmp->Bits();
		uint32 uiColor = uiBits[141];
		uint32 uiColorHigh = uiBits[289];
		
		color.red = ( uiColor & 0xFF0000) / 0x10000;
		color.green = (uiColor & 0xFF00) / 0x100;
		color.blue = (uiColor & 0xFF) ;
		colorHigh.red = ( uiColorHigh & 0xFF0000) / 0x10000;
		colorHigh.green = (uiColorHigh & 0xFF00) / 0x100;
		colorHigh.blue = (uiColorHigh & 0xFF) ;
			
	}

	//if(updateRect.left < 10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,15,147,15), BRect(Bounds().Width() - 7, 16, Bounds().Width(), Bounds().Height() - 7));				 
		}

	}
	//if(updateRect.right > Bounds().Width()-10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,14,147,14), BRect(0, 16, 7, Bounds().Height() - 7));

		}
	}
	
	
	//Dessiner l'etiquette si necessaire.
	if(updateRect.top < 16 && updateRect.right >= 16)
	{
		
		if(m_pBmp)
		{
			
			if(m_bShrink && m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(80,0,95,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(137,0,137,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bShrink)
			{
				DrawBitmap(m_pBmp, BRect(64,0,79,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(136,0,136,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(112,0,127,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(139,0,139,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else
			{
				DrawBitmap(m_pBmp, BRect(96,0,111,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(138,0,138,15), BRect(16, 0, Bounds().Width() - 15 , 15)); 
			}
			SetFont(be_bold_font);
					
			if(m_bMouseOver)
			{
				SetHighColor(colorHigh);
			}
			else
			{
				SetHighColor(color);
			}	
			SetDrawingMode(B_OP_OVER);
			DrawString(m_pzLabel, BPoint(18,12), NULL);	
			SetDrawingMode(B_OP_COPY);	
		}
		else
		{
			if(m_bShrink)
			{
				DrawDegrader(BRect(16,0,Bounds().Width(),4), 255, 192);
				DrawDegrader(BRect(16,11,Bounds().Width(),15), 192, 128);
			
				//Remplir le milieu de l'etiquette en gris
				SetHighColor(192, 192, 192, 0);
				FillRect(BRect(16, 5, Bounds().Width(), 10));
			}
			else	//Degrader du blanc au gris
			{
				DrawDegrader(BRect(16,0,Bounds().Width(),15), 255, 192);
			}
			SetFont(be_bold_font);
			SetHighColor(0, 0, 0, 0);
			SetDrawingMode(B_OP_OVER);
			DrawString(m_pzLabel, BPoint(18,12), NULL);
		}
	}
		
	//Redessiner le boutton si nessesaire.
	if(updateRect.left < 16 && updateRect.top < 16)
	{
		if(m_pBmp)
		{
			if(m_bShrink && m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(16,0,31,15), BRect(0,0,15,15));
			}
			else if(m_bShrink)
			{
				DrawBitmap(m_pBmp, BRect(0,0,15,15), BRect(0,0,15,15));
			}
			else if(m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(48,0,63,15), BRect(0,0,15,15));
			}
			else
			{
				DrawBitmap(m_pBmp, BRect(32,0,47,15), BRect(0,0,15,15));
			}
		
		}
		else
		{
			//Redessiner le degrader
			if(m_bShrink)
			{
				DrawDegrader(BRect(0, 0, 16, 4), 255, 192);
				DrawDegrader(BRect(0, 11, 16, 15), 192, 128);
			
				//Remplir le milieu de l'etiquette en gris
				SetHighColor(192, 192, 192, 0);
				FillRect(BRect(0, 5, 15, 10));
			}
			else	//Degrader du blanc au gris
			{
				DrawDegrader(BRect(0,0,15,15), 255, 192);
			}
		
			//Dessiner le Boutton si le curseur est au dessus du triangle.
			if( m_bMouseOver)
			{	
			SetHighColor(64, 64, 64, 0);
				pPointList[0] = BPoint(1,3);
				pPointList[1] = BPoint(3,1);
				pPointList[2] = BPoint(12,1);
				pPointList[3] = BPoint(14,3);
				pPointList[4] = BPoint(14,12);
				pPointList[5] = BPoint(12,14);
				pPointList[6] = BPoint(3,14);
				pPointList[7] = BPoint(1,12);
				StrokePolygon(pPointList, 8, true,  B_SOLID_HIGH);	
		
				SetHighColor(255, 255, 255, 0);
				pPointList[0] = BPoint(2,12);
				pPointList[1] = BPoint(2,3);
				pPointList[2] = BPoint(3,2);
				pPointList[3] = BPoint(12,2);
				StrokePolygon(pPointList, 4, false,  B_SOLID_HIGH);	
		
				SetHighColor(192, 192, 192, 0);
				pPointList[0] = BPoint(3,3);
				pPointList[1] = BPoint(12,3);
				pPointList[2] = BPoint(12,12);
				pPointList[3] = BPoint(3,12);
				FillPolygon(pPointList, 4,  B_SOLID_HIGH);	
		
				SetHighColor(128, 128, 128, 0);
				pPointList[0] = BPoint(13,3);
				pPointList[1] = BPoint(13,12);
				pPointList[2] = BPoint(12,13);
				pPointList[3] = BPoint(3,13);
				StrokePolygon(pPointList, 4, false,  B_SOLID_HIGH);	
			}
	
			//Dessiner le triangle vers la droite.
			// La View est reduite.
			if(m_bShrink)
			{
			SetHighColor(0, 0, 0, 256);
				pPointList[0] = BPoint(9,7);
				pPointList[1] = BPoint(6,4);
				pPointList[2] = BPoint(6,11);
				pPointList[3] = BPoint(9,8);
				FillPolygon(pPointList, 4, B_SOLID_HIGH);
			}
			//Dessiner le triangle vers le bas.
			// La View est agrandi.
			else
			{
				SetHighColor(0, 0, 0, 256);
				pPointList[0] = BPoint(7,9);
				pPointList[1] = BPoint(4,6);
				pPointList[2] = BPoint(11,6);
				pPointList[3] = BPoint(8,9);
				FillPolygon(pPointList, 4, B_SOLID_HIGH);
			}
		}
	}
	
	//Redessiner le degrader du bas si necessaire
	if(!m_bShrink && updateRect.bottom > Bounds().Height() - 8)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(128,0,135,7), BRect(0,Bounds().Height()-7,7,Bounds().Height()));
			DrawBitmap(m_pBmp, BRect(128,8,135,15), BRect(Bounds().Width() - 7,Bounds().Height()-7,Bounds().Width(),Bounds().Height()));
			DrawBitmap(m_pBmp, BRect(140,0,140,7), BRect(8, Bounds().Height()-7, Bounds().Width() - 7, Bounds().Height())); 
		}
		else
		{
			DrawDegrader(BRect(0,Bounds().bottom - 8,Bounds().Width(),Bounds().bottom), 192, 128);
		}
	} 
}//End of Draw.
Пример #17
0
// this is highly hacked from W32kPolygon...
BOOL
Polygon ( CONST PPOINT UnsafePoints, int Count, int polyFillMode )
{
  BOOL ret;
  RECTL DestRect;
  int CurrentPoint;
  PPOINT Points;
  SURFOBJ* SurfObj = 0;
  DC dc;
  PBRUSHOBJ OutBrushObj = 0;

  dc.CombinedClip = 0;
  dc.w.polyFillMode = polyFillMode;

  DPRINT1("In W32kPolygon()\n");

  if ( NULL == UnsafePoints || Count < 2)
    {
      DPRINT1("ERROR_INVALID_PARAMETER\n");
      return FALSE;
    }

  /* Copy points from userspace to kernelspace */
  Points = (PPOINT)EngAllocMem(0, Count * sizeof(POINT));
  if (NULL == Points)
    {
      DPRINT1("ERROR_NOT_ENOUGH_MEMORY\n");
      return FALSE;
    }
  MmCopyFromCaller(Points, UnsafePoints, Count * sizeof(POINT));
  if ( memcmp ( Points, UnsafePoints, Count * sizeof(POINT) ) )
    {
      free(Points);
      return FALSE;
    }

  DestRect.left   = Points[0].x;
  DestRect.right  = Points[0].x;
  DestRect.top    = Points[0].y;
  DestRect.bottom = Points[0].y;

  for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint)
    {
      DestRect.left     = MIN(DestRect.left, Points[CurrentPoint].x);
      DestRect.right    = MAX(DestRect.right, Points[CurrentPoint].x);
      DestRect.top      = MIN(DestRect.top, Points[CurrentPoint].y);
      DestRect.bottom   = MAX(DestRect.bottom, Points[CurrentPoint].y);
    }

  // Draw the Polygon Edges with the current pen
  for (CurrentPoint = 0; CurrentPoint < Count; ++CurrentPoint)
    {
      POINT To, From; //, Next;

      /* Let CurrentPoint be i
       * if i+1 > Count, Draw a line from Points[i] to Points[0]
       * Draw a line from Points[i] to Points[i+1]
       */
      From = Points[CurrentPoint];
      if ( CurrentPoint + 1 >= Count)
	{
	  To = Points[0];
	}
      else
	{
	  To = Points[CurrentPoint + 1];
	}

      DPRINT1("Polygon Making line from (%ld,%ld) to (%ld,%ld)\n", From.x, From.y, To.x, To.y );
      IntEngLineTo(SurfObj,
	           dc.CombinedClip,
	           OutBrushObj,
	           From.x,
	           From.y,
	           To.x,
	           To.y,
	           &DestRect,
	           EDGE_CHAR); /* MIX */
    }
  /* determine the fill mode to fill the polygon. */
  ret = FillPolygon(&dc, SurfObj, OutBrushObj, FILL_CHAR, Points, Count, DestRect );
  free(Points);

  return ret;
}
Пример #18
0
void
WebSafeSelector::Draw(BRect updateRect)
{
	ColorSelector::Draw(updateRect);

	if (fIsHidden) {
		SetHighColor(ViewColor());
		FillRect(updateRect);
		return;
	}

	if (updateRect.Intersects(INDICATOR_RECT)) {
		rgb_color black = (rgb_color){ 0, 0, 0 };
		rgb_color light;
		rgb_color medium;
		rgb_color dark;

		if (fMouseOver) {
			light  = (rgb_color){ 0, 255, 0, 255 };
			medium = (rgb_color){ 255, 0, 0, 255 };
			dark   = (rgb_color){ 0, 0, 255, 255 };
		} else {
			light  = tint_color(black, B_LIGHTEN_MAX_TINT);
			medium = tint_color(black, B_LIGHTEN_2_TINT);
			dark   = tint_color(black, B_LIGHTEN_1_TINT);
		}

		BRect bounds = INDICATOR_RECT;

		BPoint pointList[4];
		pointList[0] = bounds.LeftTop() + BPoint(0, 3);
		pointList[1] = bounds.LeftTop() + BPoint(0, 9);
		pointList[2] = bounds.LeftTop() + BPoint(5, 12);
		pointList[3] = bounds.LeftTop() + BPoint(5, 6);

		BPolygon* rhombus1 = new BPolygon(pointList, 4);
		SetHighColor(dark);
		FillPolygon(rhombus1);
		SetHighColor(black);
		StrokePolygon(rhombus1);
		delete rhombus1;

		pointList[0] = bounds.LeftTop() + BPoint(5, 6);
		pointList[1] = bounds.LeftTop() + BPoint(5, 12);
		pointList[2] = bounds.LeftTop() + BPoint(10, 9);
		pointList[3] = bounds.LeftTop() + BPoint(10, 3);

		BPolygon* rhombus2 = new BPolygon(pointList, 4);
		SetHighColor(light);
		FillPolygon(rhombus2);
		SetHighColor(black);
		StrokePolygon(rhombus2);
		delete rhombus2;

		pointList[0] = bounds.LeftTop() + BPoint(0, 3);
		pointList[1] = bounds.LeftTop() + BPoint(5, 6);
		pointList[2] = bounds.LeftTop() + BPoint(10, 3);
		pointList[3] = bounds.LeftTop() + BPoint(5, 0);

		BPolygon* rhombus3 = new BPolygon(pointList, 4);
		SetHighColor(medium);
		FillPolygon(rhombus3);
		SetHighColor(black);
		StrokePolygon(rhombus3);
		delete rhombus3;
	}
}