Exemple #1
0
void  TVolumenob::Update(){
	rgb_color color = {128, 128, 128};
	rgb_color color2= {100, 100, 100}; 
	rgb_color color3= {150, 150, 150};
	SetHighColor( color );
	FillEllipse(nbcenter,r+1,r+1,B_SOLID_HIGH);
	SetHighColor( color2 );
	FillArc(nbcenter,r+1,r+1,225,180,B_SOLID_HIGH);
	SetHighColor( color3 );
	FillEllipse(nbcenter,r-3,r-3,B_SOLID_HIGH);
	SetPenSize(3);
	StrokeLine(nbcenter,nbpoint,B_SOLID_LOW);
	SetPenSize(1);
}
NS_IMETHODIMP nsRenderingContextQt::FillArc(const nsRect &aRect,
                                            float aStartAngle,float aEndAngle)
{
  return FillArc(aRect.x,aRect.y,aRect.width,aRect.height,
                 aStartAngle,aEndAngle);
}
Exemple #3
0
/*****
* Name:			drawBalloonShaped
* Return Type:	void
* Description:	pops up the balloon widget as a shaped window
* In:
*	w:			XmBalloon Widget id;
*	x:			absolute x popup position;
*	y:			absolute y popup position;
*	width:		desired widget width;
* Returns:
*	nothing
* Note:
*	This routine composes a *clipmask* for the widget to use when
*	it is displayed. The clipmask is initially empty and gets filled
*	according to the selected options. Once it is filled, the text
*	is rendered in the selected color.
*****/
static void
drawBalloonShaped(Widget w, Position x, Position y, int width)
{
	BALLOON = (XmBalloonWidget)w;
	XGCValues xgc;
	int face_width, face_height, x_offset, y_offset;
	Dimension bwidth, bheight;
	Pixmap shape_mask;
	Display *dpy = XtDisplay(w);
	Window win = XtWindow(w);

	/* horizontal offset for text rendering */
	x_offset = ATTR(margin_width) + ATTR(font_width);
	y_offset = 0.25 * ATTR(font_height);

	bwidth = 2*ATTR(margin_width) + width + 2*x_offset;
	bheight = 2*ATTR(margin_height) + ATTR(font_height) + 2*y_offset;

	/* resize to fit */
	XtResizeWidget(w, bwidth, bheight, balloon->core.border_width);

	/* compute desired border size */
	setTransform(&ATTR(maskt), 0, bwidth, bheight, 0, -1.0, 1.0, -1.0, 1.0);

	face_width = abs(Xwidth(BORDER_SIZE(balloon), BORDER_SIZE(balloon),
		&(ATTR(maskt))));
	face_height = abs(Xheight(BORDER_SIZE(balloon), BORDER_SIZE(balloon),
		&(ATTR(maskt))));

	setTransform(&ATTR(t), face_width, bwidth - face_width,
		bheight - face_height, face_height, 
		-WINDOW_WIDTH(balloon)/2, WINDOW_WIDTH(balloon)/2,
		-WINDOW_HEIGHT(balloon)/2, WINDOW_HEIGHT(balloon)/2);

	/* Free up previous clipmask if the size differs */
	if(ATTR(shape_mask) &&
		ATTR(shape_width) != w->core.width &&
		ATTR(shape_height) != w->core.height)
	{
		XFreePixmap(dpy, ATTR(shape_mask));
		ATTR(shape_mask) = None;
	}

	/* allocate a clipmask (bitmap of depth one) */
	if(!(ATTR(shape_mask)))
	{
		ATTR(shape_mask) = XCreatePixmap(dpy, win, bwidth, bheight, 1);
		ATTR(shape_width) = bwidth;
		ATTR(shape_height) = bheight;
	}
	shape_mask = ATTR(shape_mask);

	/* simple gc */
	if(!(ATTR(shape_gc)))
		ATTR(shape_gc) = XCreateGC(dpy, shape_mask, 0, &xgc);

	/* make it fully transparent */
	XSetForeground(dpy, ATTR(shape_gc), 0);
	XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight);
	XSetForeground(dpy, ATTR(shape_gc), 1);

	/*****
	* Fill in the border bits if we have a border. If we aren't transparent
	* a filled arc is created.
	*****/
	if(ATTR(border_size) > 0.0 || !ATTR(transparent))
	{
		FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)),
			-1.0, -1.0, 2.0, 2.0, 0, 360*64);
	}

	/*****
	* if we are being transparent, erase the inner part of the disk
	* and fill the bits for the text. If we aren't transparent we don't
	* have to do this 'cause the bits set for the disk already cover the
	* bits that cover the text.
	*****/
	if(ATTR(transparent))
	{
		if(ATTR(border_size) > 0.0)
		{
			XSetForeground(dpy, ATTR(shape_gc), 0);
			FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(maskt)),
				-WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2,
				WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon),
				0, 360*64);
			XSetForeground(dpy, ATTR(shape_gc), 1);
		}
		drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset);
	}
	/* the highest enclosing widget is the widget itself */
	XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, shape_mask, ShapeSet);

	/* erase clipmask */
	XSetForeground(dpy, ATTR(shape_gc), 0); 
	XFillRectangle(dpy, shape_mask, ATTR(shape_gc), 0, 0, bwidth, bheight);
	XSetForeground(dpy, ATTR(shape_gc), 1);

	/* draw clip shape */
	if(ATTR(transparent))
	{
		drawText(dpy, balloon, shape_mask, ATTR(shape_gc), x_offset, y_offset);
	}
	else
	{
		FillArc(dpy, shape_mask, ATTR(shape_gc), &(ATTR(t)),
			-WINDOW_WIDTH(balloon)/2, -WINDOW_HEIGHT(balloon)/2,
			WINDOW_WIDTH(balloon), WINDOW_HEIGHT(balloon),
			0, 360*64);
	}

	/* compose final clipmask */
	XShapeCombineMask(dpy, win, ShapeClip, 0, 0, shape_mask, ShapeSet);

	/* move to correct location */
	XtMoveWidget((Widget)balloon, x + 4, y + 4);

	/*****
	* pop it up.
	* Note that the label can change when the widget is already popped.
	*****/
	if(!ATTR(popped))
		XtPopup((Widget)balloon, XtGrabNone);
	ATTR(popped) = True;

	/* draw the text */
	drawText(dpy, balloon, win, ATTR(gc), x_offset, y_offset);

	/* if we have got a popdown timeout, add it */
	if(ATTR(popdown_delay))
	{
		ATTR(popdown_id) = XtAppAddTimeOut(ATTR(context),
			ATTR(popdown_delay), popdownBalloon, (XtPointer)balloon);
	}

}
Exemple #4
0
float
PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan,
	float beginAngle, int colorIdx, int level)
{
	if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
		+ kPieOuterMargin + kPieInnerMargin)) {
		return 0.0;
	}

	if (info != NULL && info->color >= 0 && level == 0)
		colorIdx = info->color % kBasePieColorCount;
	else if (info != NULL)
		info->color = colorIdx;

	VolumeSnapshot* snapshot = fScanner->Snapshot();

	float cx = floorf(b.left + b.Width() / 2.0 + 0.5);
	float cy = floorf(b.top + b.Height() / 2.0 + 0.5);

	float mySpan;

	if (level == 0) {
		// Make room for mouse over info.
		fMouseOverInfo.clear();
		fMouseOverInfo[0] = SegmentList();

		// Draw the center circle.
		const char* displayName;
		if (info == NULL) {
			// NULL represents the entire volume.  Show used and free space in
			// the center circle, with the used segment representing the
			// volume's root directory.
			off_t volCapacity = snapshot->capacity;
			mySpan = 360.0 * (volCapacity - snapshot->freeBytes) / volCapacity;

			SetHighColor(kEmptySpcColor);
			FillEllipse(BPoint(cx, cy), kPieCenterSize, kPieCenterSize);

			SetHighColor(kBasePieColor[0]);
			FillArc(BPoint(cx, cy), kPieCenterSize, kPieCenterSize, 0.0,
				mySpan);

			// Show total volume capacity.
			char label[B_PATH_NAME_LENGTH];
			size_to_string(volCapacity, label, sizeof(label));
			SetHighColor(kPieBGColor);
			SetDrawingMode(B_OP_OVER);
			DrawString(label, BPoint(cx - StringWidth(label) / 2.0,
				cy + fFontHeight + kSmallVMargin));
			SetDrawingMode(B_OP_COPY);

			displayName = snapshot->name.c_str();

			// Record in-use space and free space for use during MouseMoved().
			info = snapshot->rootDir;
			info->color = colorIdx;
			fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info));
			if (mySpan < 360.0 - kMinSegmentSpan) {
				fMouseOverInfo[0].push_back(Segment(mySpan, 360.0,
					snapshot->freeSpace));
			}
		} else {
			// Show a normal directory.
			SetHighColor(kBasePieColor[colorIdx]);
			FillEllipse(BRect(cx - kPieCenterSize, cy - kPieCenterSize,
				cx + kPieCenterSize + 0.5, cy + kPieCenterSize + 0.5));
			displayName = info->ref.name;
			mySpan = 360.0;

			// Record the segment for use during MouseMoved().
			fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info));
		}

		SetPenSize(1.0);
		SetHighColor(kOutlineColor);
		StrokeEllipse(BPoint(cx, cy), kPieCenterSize + 0.5,
			kPieCenterSize + 0.5);

		// Show the name of the volume or directory.
		BString label(displayName);
		BFont font;
		GetFont(&font);
		font.TruncateString(&label, B_TRUNCATE_END,
			2.0 * (kPieCenterSize - kSmallHMargin));
		float labelWidth = font.StringWidth(label.String());

		SetHighColor(kPieBGColor);
		SetDrawingMode(B_OP_OVER);
		DrawString(label.String(), BPoint(cx - labelWidth / 2.0, cy));
		SetDrawingMode(B_OP_COPY);
		beginAngle = 0.0;
	} else {
		// Draw an exterior segment.
		float parentSize;
		if (info->parent == NULL)
			parentSize = (float)snapshot->capacity;
		else
			parentSize = (float)info->parent->size;

		mySpan = parentSpan * (float)info->size / parentSize;
		if (mySpan >= kMinSegmentSpan) {
			const float tint = 1.4f - level * 0.08f;
			float radius = kPieCenterSize + level * kPieRingSize
				- kPieRingSize / 2.0;

			// Draw the grey border
			SetHighColor(tint_color(kOutlineColor, tint));
			SetPenSize(kPieRingSize + 1.5f);
			StrokeArc(BPoint(cx, cy), radius, radius,
				beginAngle - 0.001f * radius, mySpan  + 0.002f * radius);

			// Draw the colored area
			rgb_color color = tint_color(kBasePieColor[colorIdx], tint);
			SetHighColor(color);
			SetPenSize(kPieRingSize);
			StrokeArc(BPoint(cx, cy), radius, radius, beginAngle, mySpan);

			// Record the segment for use during MouseMoved().
			if (fMouseOverInfo.find(level) == fMouseOverInfo.end())
				fMouseOverInfo[level] = SegmentList();

			fMouseOverInfo[level].push_back(
				Segment(beginAngle, beginAngle + mySpan, info));
		}
	}

	// Draw children.
	vector<FileInfo*>::iterator i = info->children.begin();
	while (i != info->children.end()) {
		float childSpan
			= _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1);
		if (childSpan >= kMinSegmentSpan) {
			beginAngle += childSpan;
			colorIdx = (colorIdx + 1) % kBasePieColorCount;
		}
		i++;
	}

	return mySpan;
}