Exemplo n.º 1
0
void
JXStyleMenu::JXStyleMenuX()
{
	itsChooseColorDialog = NULL;

	if (JXMenu::GetDefaultStyle() == kMacintoshStyle)
		{
		SetMenuItems(kMacMenuStr);
		}
	else
		{
		SetShortcuts(kStyleMenuShortcutStr);
		SetMenuItems(kWinMenuStr);
		}

	JXColormap* colormap = GetColormap();
	const JColorIndex blackColor = colormap->GetBlackColor();

	SetItemFontStyle(
		kBoldStyleCmd,         JFontStyle(kJTrue, kJFalse, 0, kJFalse, blackColor));
	SetItemFontStyle(
		kItalicStyleCmd,       JFontStyle(kJFalse, kJTrue, 0, kJFalse, blackColor));
	SetItemFontStyle(
		kUnderlineStyleCmd,    JFontStyle(kJFalse, kJFalse, 1, kJFalse, blackColor));
	SetItemFontStyle(
		kDblUnderlineStyleCmd, JFontStyle(kJFalse, kJFalse, 2, kJFalse, blackColor));
	SetItemFontStyle(
		kStrikeStyleCmd,       JFontStyle(kJFalse, kJFalse, 0, kJTrue, blackColor));

	assert( kColorCount == 11 );
	itsColorList[ 0] = blackColor;
	itsColorList[ 1] = colormap->GetGray60Color();
	itsColorList[ 2] = colormap->GetBrownColor();
	itsColorList[ 3] = colormap->GetOrangeColor();
	itsColorList[ 4] = colormap->GetRedColor();
	itsColorList[ 5] = colormap->GetDarkRedColor();
	itsColorList[ 6] = colormap->GetDarkGreenColor();
	itsColorList[ 7] = colormap->GetBlueColor();
	itsColorList[ 8] = colormap->GetLightBlueColor();
	itsColorList[ 9] = colormap->GetPinkColor();
	itsColorList[10] = colormap->GetDefaultBackColor();

	ListenTo(this);
}
Exemplo n.º 2
0
void
TestWidget::DrawStuff
	(
	JPainter& p
	)
{
JIndex i;

	JXColormap* colormap = GetColormap();

	p.SetPenColor(colormap->GetGreenColor());
	JRect ellipseRect(100,50,150,300);
	p.Ellipse(ellipseRect);

	p.SetPenColor(colormap->GetBlackColor());

	if (itsFillFlag)
		{
		p.SetFilling(kJTrue);
		}

	JRect ap = GetAperture();
	p.Line(ap.topLeft(), ap.bottomRight());
	p.Line(ap.topRight(), ap.bottomLeft());

	p.SetLineWidth(2);
	p.SetFontName("Times");
	p.SetFontSize(18);

	p.Image(*itsHomeImage, itsHomeImage->GetBounds(), itsHomeRect);

	its2Rect = JRect(150, 5, 200, 30);
	p.SetPenColor(colormap->GetRedColor());
	p.Rect(its2Rect);
	p.SetFontStyle(colormap->GetRedColor());
	p.String(its2Rect.topLeft(), "2",
			 its2Rect.width(),  JPainter::kHAlignCenter,
			 its2Rect.height(), JPainter::kVAlignCenter);

	its3Rect = JRect(10, 150, 40, 200);
	p.SetPenColor(colormap->GetBlueColor());
	p.Rect(its3Rect);
	p.SetFontStyle(colormap->GetBlueColor());
	p.String(its3Rect.topLeft(), "3",
			 its3Rect.width(),  JPainter::kHAlignCenter,
			 its3Rect.height(), JPainter::kVAlignCenter);

	p.SetLineWidth(1);
	p.SetFont(GetFontManager()->GetDefaultFont());

	p.ShiftOrigin(10,10);

	p.Point(0,0);
	for (i=1; i<=itsRandPointCount; i++)
		{
		p.Point(itsRNG.UniformLong(0,200), itsRNG.UniformLong(0,200));
		}

	p.SetPenColor(colormap->GetRedColor());
	p.Line(10,0, 0,10);
	p.SetPenColor(colormap->GetGreenColor());
	p.LineTo(10,20);
	p.SetPenColor(colormap->GetBlueColor());
	p.LineTo(0,30);

	p.ShiftOrigin(2,0);

	JPoint textPt(40,30);
	p.String(  0.0, textPt, "Hello");
	p.String( 90.0, textPt, "Hello");
	p.String(180.0, textPt, "Hello");
	p.String(270.0, textPt, "Hello");

	p.ShiftOrigin(-2, 0);

	p.SetPenColor(colormap->GetBlueColor());
	JRect r(70, 290, 150, 390);
	p.Rect(r);
/*
	for (JCoordinate y=70; y<150; y++)
		{
		p.SetPenColor(colormap->GetGrayColor(y-50));
		p.Line(290,y, 390,y);
		}

	for (JCoordinate x=290; x<390; x++)
		{
		p.SetPenColor(colormap->GetGrayColor(x-290));
		p.Line(x,70, x,150);
		}

	p.SetLineWidth(2);
	for (JCoordinate y=70; y<150; y+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60));
		p.Line(290,y, 390,y);
		}
	p.SetLineWidth(1);

	p.SetLineWidth(2);
	for (JCoordinate x=290; x<390; x+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60));
		p.Line(x,70, x,150);
		}
	p.SetLineWidth(1);
*/
	p.String(  0.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String( 90.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String(180.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);
	p.String(270.0, r, "Hello", JPainter::kHAlignCenter, JPainter::kVAlignCenter);

	p.String(  0.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String( 90.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String(180.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);
	p.String(270.0, r, "Hello", JPainter::kHAlignRight, JPainter::kVAlignBottom);

	p.SetPenColor(colormap->GetBlueColor());
	p.Rect(200, 10, 100, 50);
	p.String(200, 10, "Hello", 100, JPainter::kHAlignLeft);
	p.String(200, 10+p.GetLineHeight(), "Hello", 100, JPainter::kHAlignCenter);
	p.String(200, 10+2*p.GetLineHeight(), "Hello", 100, JPainter::kHAlignRight);

	p.SetPenColor(colormap->GetDarkGreenColor());
	p.SetFilling(kJTrue);
	p.Rect(290, 160, 100, 80);
	p.SetFilling(kJFalse);
/*
	for (JCoordinate y=160; y<240; y++)
		{
		p.SetPenColor(colormap->GetGrayColor(y-140));
		p.Line(290,y, 390,y);
		}

	for (JCoordinate x=290; x<390; x++)
		{
		p.SetPenColor(colormap->GetGrayColor(x-290));
		p.Line(x,160, x,240);
		}

	p.SetLineWidth(2);
	for (JCoordinate y=160; y<240; y+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(y%4 ? 40 : 60));
		p.Line(290,y, 390,y);
		}
	p.SetLineWidth(1);

	p.SetLineWidth(2);
	for (JCoordinate x=290; x<390; x+=2)
		{
		p.SetPenColor(colormap->GetGrayColor(x%4 ? 40 : 60));
		p.Line(x,160, x,240);
		}
	p.SetLineWidth(1);
*/
	textPt.Set(340, 200);
	p.SetFontName("Times");
	p.SetFontStyle(colormap->GetBlueColor());
	p.String(  0.0, textPt, "Hello");
	p.String( 90.0, textPt, "Hello");
	p.SetFontStyle(colormap->GetYellowColor());
	p.String(180.0, textPt, "Hello");
	p.String(270.0, textPt, "Hello");

	p.SetPenColor(colormap->GetYellowColor());
	r.Set(0,11,80,91);
	p.Rect(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetBlueColor());
	p.Ellipse(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetRedColor());
	p.Arc(r, 270.0-45.0, -270.0);

	JPolygon poly;
	poly.AppendElement(JPoint(0,85));
	poly.AppendElement(JPoint(10,85));
	poly.AppendElement(JPoint(5,95));
	p.Polygon(poly);

	p.Line(0,100, 2,98);
	p.LineTo(4,100);
	p.LineTo(2,102);
	p.LineTo(0,100);

	poly.SetElement(1, JPoint(0,5));
	poly.SetElement(2, JPoint(2,0));
	poly.SetElement(3, JPoint(4,5));
	p.Polygon(2,105, poly);

	// test filling rule

	p.SetPenColor(colormap->GetRedColor());
	p.SetFilling(kJTrue);

	JPolygon fillRulePoly;
	fillRulePoly.AppendElement(JPoint(175,45));
	fillRulePoly.AppendElement(JPoint(165,65));
	fillRulePoly.AppendElement(JPoint(190,50));
	fillRulePoly.AppendElement(JPoint(160,50));
	fillRulePoly.AppendElement(JPoint(185,65));
	p.Polygon(fillRulePoly);

	p.SetFilling(kJFalse);

	// dashed lines

	p.DrawDashedLines(kJTrue);

	p.SetPenColor(colormap->GetBlackColor());

	JArray<JSize> dashList;			// pixel rulers
	dashList.AppendElement(1);
	dashList.AppendElement(1);
	p.SetDashList(dashList);
	p.Line(100,110, 200,110);
	p.Line(100,114, 200,114);
	p.Line(100,118, 200,118);

	dashList.SetElement(1, 2);		// simple pattern
	dashList.SetElement(2, 3);
	p.SetDashList(dashList);
	p.Line(100,112, 200,112);

	p.SetFontStyle(JFontStyle(kJFalse, kJFalse, 1, kJFalse));
	p.String(130,155, "underline without dashes");

	p.SetDashList(dashList, 3);		// test offset
	p.Line(100,116, 200,116);

	dashList.SetElement(1, 1);		// example with odd # of values from X manuals
	dashList.SetElement(2, 2);
	dashList.AppendElement(3);
	p.SetDashList(dashList);
	p.Line(100,120, 200,120);

	dashList.SetElement(1, 5);		// dash-dot pattern
	dashList.SetElement(2, 2);
	dashList.SetElement(3, 1);
	dashList.AppendElement(2);
	p.SetDashList(dashList);
	p.Line(100,122, 200,122);

	p.Ellipse(210,110, 20,20);
	p.DrawDashedLines(kJFalse);
	p.Ellipse(213,113, 14,14);
	p.Rect(207,107, 26,26);
	p.SetPenColor(colormap->GetYellowColor());
	p.DrawDashedLines(kJTrue);
	p.Ellipse(213,113, 14,14);

	// icons

	p.Image(*itsXPMImage, itsXPMImage->GetBounds(), 33,110);
	p.Image(*itsPartialXPMImage, itsXPMImage->GetBounds(), 50,121);
}