void
JXInputField::DrawBorder
	(
	JXWindowPainter&	p,
	const JRect&		frame
	)
{
	if (itsTable != NULL)
		{
		if (IsDNDTarget())
			{
			p.SetPenColor((p.GetColormap())->GetDefaultDNDBorderColor());
			}
		else
			{
			p.SetPenColor((GetColormap())->GetBlackColor());
			}
		p.JPainter::Rect(frame);
		}
	else
		{
		JXTEBase::DrawBorder(p, frame);
		}
}
TestWidget::TestWidget
	(
	const JBoolean		isMaster,
	const JBoolean		isImage,
	JXMenuBar*			menuBar,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXScrollableWidget(scrollbarSet, enclosure, hSizing, vSizing, x,y, w,h),
	itsRNG()
{
JIndex i;

	itsFillFlag       = kJFalse;
	itsRandPointCount = 10;
	itsResizeDialog   = NULL;

	SetBackColor(GetColormap()->GetDefaultBackColor());

	// cursors

	JXDisplay* display = GetDisplay();
	itsTrekCursor      = display->CreateBuiltInCursor("XC_trek",     XC_trek);
	itsGumbyCursor     = display->CreateBuiltInCursor("XC_gumby",    XC_gumby);
	itsBogosityCursor  = display->CreateBuiltInCursor("XC_bogosity", XC_bogosity);
	itsFleurCursor     = display->CreateBuiltInCursor("XC_fleur",    XC_fleur);
	SetDefaultCursor(itsTrekCursor);

	// menus

	itsActionsMenu = menuBar->AppendTextMenu(kActionsMenuTitleStr);
	itsActionsMenu->SetTitleFontStyle(GetColormap()->GetWhiteColor());
	itsActionsMenu->SetShortcuts(kActionsMenuShortcutStr);
	itsActionsMenu->SetMenuItems(kActionsMenuStr);
	itsActionsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsActionsMenu);

	itsPointMenu = jnew JXTextMenu(itsActionsMenu, kPointMenuCmd, menuBar);
	assert( itsPointMenu != NULL );
	itsPointMenu->SetMenuItems(kPointMenuStr);
	itsPointMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPointMenu);

	// This tests the JX response to an empty menu.
	JXTextMenu* emptyMenu = jnew JXTextMenu(itsActionsMenu, kEmptyMenuCmd, menuBar);
	assert( emptyMenu != NULL );

	JXMenu* prevMenu     = itsActionsMenu;
	JIndex prevMenuIndex = kAdviceMenuCmd;
	for (i=1; i<=kAdviceMenuCount; i++)
		{
		JXTextMenu* adviceMenu = jnew JXTextMenu(prevMenu, prevMenuIndex, menuBar);
		assert( adviceMenu != NULL );
		adviceMenu->SetMenuItems(kAdviceMenuStr[i-1]);
		adviceMenu->SetUpdateAction(JXMenu::kDisableNone);

		if (i == kAdviceBoldMenuIndex)
			{
			adviceMenu->SetItemFontStyle(2,
				JFontStyle(kJTrue, kJFalse, 0, kJFalse, GetColormap()->GetBlackColor()));
			}

		prevMenu      = adviceMenu;
		prevMenuIndex = 2;
		}

	BuildXlsfontsMenu(itsActionsMenu, menuBar);

	// secret menus are a bad idea because the user can't find them!

	itsSecretMenu = jnew JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10);
	assert( itsSecretMenu != NULL );
	itsSecretMenu->SetMenuItems(kSecretMenuStr);
	itsSecretMenu->SetUpdateAction(JXMenu::kDisableNone);
	itsSecretMenu->SetToHiddenPopupMenu(kJTrue);		// will assert() otherwise
	itsSecretMenu->Hide();
	ListenTo(itsSecretMenu);

	itsSecretSubmenu = jnew JXTextMenu(itsSecretMenu, kSecretSubmenuIndex, this);
	assert( itsSecretSubmenu != NULL );
	itsSecretSubmenu->SetMenuItems(kSecretSubmenuStr);
	itsSecretSubmenu->SetUpdateAction(JXMenu::kDisableNone);
	// we don't ListenTo() it because it's only there for show

	// image from xpm

	itsXPMImage = jnew JXImage(GetDisplay(), JXPM(macapp_xpm));
	assert( itsXPMImage != NULL );

	// partial image from image

	itsPartialXPMImage = jnew JXImage(*itsXPMImage, JRect(5,5,14,16));
	assert( itsPartialXPMImage != NULL );

	// home symbol

	itsHomeImage = jnew JXImage(GetDisplay(), JXPM(home_xpm));
	assert( itsHomeImage != NULL );

	itsHomeRect = itsHomeImage->GetBounds();
	itsHomeRect.Shift(120, 10);

	// buffer contents of Widget in JXImage

	itsImageBuffer = NULL;
	if (isImage)
		{
		CreateImageBuffer();
		}

	// initial size

	SetBounds(400,400);

	// enclosed objects

	itsAnimButton = 
		jnew JXTextButton("Start", this, JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 37,175, 50,30);
	assert( itsAnimButton != NULL );
	itsAnimButton->SetShortcuts("#A");
	ListenTo(itsAnimButton);

	if (isMaster)
		{
		itsQuitButton = 
			jnew JXTextButton(JGetString("Quit::TestWidget"), this, JXWidget::kFixedRight, JXWidget::kFixedBottom,
							 x,y, 50,30);
		assert( itsQuitButton != NULL );

		JXColormap* colormap = GetColormap();
		itsQuitButton->CenterWithinEnclosure(kJTrue, kJTrue);
		itsQuitButton->SetFontStyle(JFontStyle(kJTrue, kJFalse, 0, kJFalse, colormap->GetRedColor()));
		itsQuitButton->SetNormalColor(colormap->GetCyanColor());
		itsQuitButton->SetPushedColor(colormap->GetBlueColor());

		ListenTo(itsQuitButton);
		}
	else
		{
		itsQuitButton = NULL;
		}

	ExpandToFitContent();

	// drops on iconfied window

	JXWindowIcon* windowIcon;
	const JBoolean hasIconWindow = GetWindow()->GetIconWidget(&windowIcon);
	assert( hasIconWindow );
	ListenTo(windowIcon);
}
void
TestInputFieldsDialog::BuildWindow()
{
// begin JXLayout

    JXWindow* window = new JXWindow(this, 620,180, "");
    assert( window != NULL );

    JXTextButton* cancelButton =
        new JXTextButton(JGetString("cancelButton::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 180,150, 70,20);
    assert( cancelButton != NULL );

    JXTextButton* okButton =
        new JXTextButton(JGetString("okButton::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 390,150, 70,20);
    assert( okButton != NULL );
    okButton->SetShortcuts(JGetString("okButton::TestInputFieldsDialog::shortcuts::JXLayout"));

    JXInputField* text1 =
        new JXInputField(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 110,20, 180,20);
    assert( text1 != NULL );

    JXInputField* text2 =
        new JXInputField(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 110,40, 180,20);
    assert( text2 != NULL );

    JXInputField* text3 =
        new JXInputField(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 110,60, 180,20);
    assert( text3 != NULL );

    JXInputField* text4 =
        new JXInputField(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 110,80, 180,20);
    assert( text4 != NULL );

    JXFloatInput* f1 =
        new JXFloatInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 380,20, 90,20);
    assert( f1 != NULL );

    JXFloatInput* f2 =
        new JXFloatInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 380,40, 90,20);
    assert( f2 != NULL );

    JXFloatInput* f3 =
        new JXFloatInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 380,60, 90,20);
    assert( f3 != NULL );

    JXFloatInput* f4 =
        new JXFloatInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 380,80, 90,20);
    assert( f4 != NULL );

    JXIntegerInput* i1 =
        new JXIntegerInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 550,20, 50,20);
    assert( i1 != NULL );

    itsLowerValue =
        new JXIntegerInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 550,40, 50,20);
    assert( itsLowerValue != NULL );

    itsUpperValue =
        new JXIntegerInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 550,60, 50,20);
    assert( itsUpperValue != NULL );

    JXIntegerInput* i4 =
        new JXIntegerInput(window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 550,80, 50,20);
    assert( i4 != NULL );

    JXStaticText* obj1_JXLayout =
        new JXStaticText(JGetString("obj1_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,20, 100,20);
    assert( obj1_JXLayout != NULL );
    obj1_JXLayout->SetToLabel();

    JXStaticText* obj2_JXLayout =
        new JXStaticText(JGetString("obj2_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,40, 100,20);
    assert( obj2_JXLayout != NULL );
    obj2_JXLayout->SetFontName("Times");
    obj2_JXLayout->SetFontSize(8);
    const JFontStyle obj2_JXLayout_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetGreenColor());
    obj2_JXLayout->SetFontStyle(obj2_JXLayout_style);
    obj2_JXLayout->SetToLabel();

    JXStaticText* obj3_JXLayout =
        new JXStaticText(JGetString("obj3_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,60, 100,20);
    assert( obj3_JXLayout != NULL );
    obj3_JXLayout->SetFontName("Times");
    const JFontStyle obj3_JXLayout_style(kJTrue, kJTrue, 0, kJFalse, (GetColormap())->GetBlackColor());
    obj3_JXLayout->SetFontStyle(obj3_JXLayout_style);
    obj3_JXLayout->SetToLabel();

    JXStaticText* obj4_JXLayout =
        new JXStaticText(JGetString("obj4_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,80, 100,20);
    assert( obj4_JXLayout != NULL );
    obj4_JXLayout->SetFontSize(8);
    const JFontStyle obj4_JXLayout_style(kJFalse, kJTrue, 0, kJFalse, (GetColormap())->GetBlackColor());
    obj4_JXLayout->SetFontStyle(obj4_JXLayout_style);
    obj4_JXLayout->SetToLabel();

    JXStaticText* obj5_JXLayout =
        new JXStaticText(JGetString("obj5_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 300,20, 80,20);
    assert( obj5_JXLayout != NULL );
    obj5_JXLayout->SetToLabel();

    JXStaticText* obj6_JXLayout =
        new JXStaticText(JGetString("obj6_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 300,40, 80,20);
    assert( obj6_JXLayout != NULL );
    obj6_JXLayout->SetToLabel();

    JXStaticText* obj7_JXLayout =
        new JXStaticText(JGetString("obj7_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 300,60, 80,20);
    assert( obj7_JXLayout != NULL );
    obj7_JXLayout->SetToLabel();

    JXStaticText* obj8_JXLayout =
        new JXStaticText(JGetString("obj8_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 300,80, 80,20);
    assert( obj8_JXLayout != NULL );
    obj8_JXLayout->SetToLabel();

    JXStaticText* obj9_JXLayout =
        new JXStaticText(JGetString("obj9_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 480,40, 70,20);
    assert( obj9_JXLayout != NULL );
    obj9_JXLayout->SetToLabel();

    JXStaticText* obj10_JXLayout =
        new JXStaticText(JGetString("obj10_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 480,60, 70,20);
    assert( obj10_JXLayout != NULL );
    obj10_JXLayout->SetToLabel();

    JXStaticText* obj11_JXLayout =
        new JXStaticText(JGetString("obj11_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 480,80, 70,20);
    assert( obj11_JXLayout != NULL );
    obj11_JXLayout->SetToLabel();

    JXStaticText* obj12_JXLayout =
        new JXStaticText(JGetString("obj12_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedTop, 480,20, 70,20);
    assert( obj12_JXLayout != NULL );
    obj12_JXLayout->SetToLabel();

    JXPasswordInput* pwInput =
        new JXPasswordInput(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 110,110, 180,20);
    assert( pwInput != NULL );

    JXStaticText* obj13_JXLayout =
        new JXStaticText(JGetString("obj13_JXLayout::TestInputFieldsDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,110, 100,20);
    assert( obj13_JXLayout != NULL );
    obj13_JXLayout->SetToLabel();

// end JXLayout

	window->SetTitle("Testing Input Fields");
	SetButtons(okButton, cancelButton);

	text2->SetText("required");
	text2->SetIsRequired();
	text3->SetMaxLength(5);
	text4->SetText("max 10");
	text4->SetIsRequired();
	text4->SetMaxLength(10);

	f2->SetLowerLimit(-3.2);
	f3->SetUpperLimit(-3.2);
	f4->SetLimits(2.1, 10.3);

	itsLowerValue->SetLowerLimit(-3);
	itsUpperValue->SetUpperLimit(8);
	i4->SetLimits(-2, 24);

	// always set initial values so they don't generate errors

	itsLowerValue->SetValue(-1);

	// never store real passwords as plaintext!

	pwInput->SetText("password");
	pwInput->SetHint("For security, the actual password is not displayed");
}
Esempio n. 4
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(JXGetTimesFontName());
    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(JGetDefaultFontName(), kJXDefaultFontSize, colormap->GetBlackColor());

    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.Rect(310, 70, 80, 80);
    p.String(  0.0, 310, 70, "Hello", 80, JPainter::kHAlignCenter,
               80, JPainter::kVAlignCenter);
    p.String( 90.0, 310,150, "Hello", 80, JPainter::kHAlignCenter,
              80, JPainter::kVAlignCenter);
    p.String(180.0, 390,150, "Hello", 80, JPainter::kHAlignCenter,
             80, JPainter::kVAlignCenter);
    p.String(270.0, 390, 70, "Hello", 80, JPainter::kHAlignCenter,
             80, JPainter::kVAlignCenter);

    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->GetYellowColor());
    JRect r(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);

    // animated colors

    p.SetFilling(kJTrue);

    JCoordinate x = 25;
    const JSize animColorCount = itsAnimColorList->GetElementCount();
    for (i=1; i<=animColorCount; i++)
    {
        p.SetPenColor(itsAnimColorList->GetElement(i));
        p.Rect(x, 150, 10, 10);
        x += 10;
    }

    // icons

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

    // *NEVER* do this in your code!  I do it here ONLY to test JXColormap.
    // (Besides, look at how messy it is!)

    unsigned long xPixel;
    if (colormap->CalcPreallocatedXPixel(62720, 56832, 45824, &xPixel))
    {
        JXDisplay* display = GetDisplay();
        Display* xdisplay  = display->GetXDisplay();
        GC gc = DefaultGC(xdisplay, display->GetScreen());
        XSetForeground(xdisplay, gc, xPixel);
        XFillRectangle(xdisplay, (GetWindow())->GetXWindow(), gc, 110,40, 20,20);
    }
}
Esempio n. 5
0
void
TestWidget::HandleActionsMenu
(
    const JIndex index
)
{
    if (index == kChangeSizeCmd)
    {
        GetNewSize();
    }
    else if (index == kToggleFillCmd)
    {
        itsFillFlag = JNegate(itsFillFlag);
        Refresh();
    }

    else if (index == kShowHideCmd && IsVisible())
    {
        Hide();
        itsActionsMenu->SetItemText(kShowHideCmd, kShowStr);
    }
    else if (index == kShowHideCmd)
    {
        Show();
        itsActionsMenu->SetItemText(kShowHideCmd, kHideStr);
    }

    else if (index == kActDeactCmd && IsActive())
    {
        Deactivate();
        itsActionsMenu->SetItemText(kActDeactCmd, kActivateStr);
    }
    else if (index == kActDeactCmd)
    {
        Activate();
        itsActionsMenu->SetItemText(kActDeactCmd, kDeactivateStr);
    }

    else if (index == kRedGreenCmd)
    {
        JXColormap* colormap  = GetColormap();
        const JIndex redColor = colormap->GetRedColor();
        itsAnimButton->SetFontStyle(itsNextAnimColor);
        if (itsNextAnimColor == redColor)
        {
            itsNextAnimColor = colormap->GetGreenColor();
            itsActionsMenu->SetItemText(kRedGreenCmd, kGreenStr);
        }
        else
        {
            itsNextAnimColor = redColor;
            itsActionsMenu->SetItemText(kRedGreenCmd, kRedStr);
        }
    }

    else if (index == kShowHideQuitCmd && itsQuitButton != NULL &&
             itsQuitButton->WouldBeVisible())
    {
        itsQuitButton->Hide();
        itsActionsMenu->SetItemText(kShowHideQuitCmd, kShowQuitStr);
    }
    else if (index == kShowHideQuitCmd && itsQuitButton != NULL)
    {
        itsQuitButton->Show();
        itsActionsMenu->SetItemText(kShowHideQuitCmd, kHideQuitStr);
    }

    else if (index == kActDeactQuitCmd && itsQuitButton != NULL &&
             itsQuitButton->WouldBeActive())
    {
        itsQuitButton->Deactivate();
        itsActionsMenu->SetItemText(kActDeactQuitCmd, kActivateQuitStr);
    }
    else if (index == kActDeactQuitCmd && itsQuitButton != NULL)
    {
        itsQuitButton->Activate();
        itsActionsMenu->SetItemText(kActDeactQuitCmd, kDeactivateQuitStr);
    }

    else if (index == kPrintSelectionTargetsCmd)
    {
        PrintSelectionTargets(CurrentTime);
    }
    else if (index == kPrintOldSelectionTargetsCmd)
    {
        PrintSelectionTargets((GetDisplay())->GetLastEventTime() - 10000);
    }
}
void
GLFitDirector::BuildWindow()
{
	JCoordinate w = 600;
	JCoordinate h = 420;
	JXWindow* window = new JXWindow(this, w,h, "Fit");
    assert( window != NULL );
	window->SetCloseAction(JXWindow::kDeactivateDirector);
    
	JXMenuBar* menuBar =
		new JXMenuBar(window, JXWidget::kHElastic, JXWidget::kFixedTop, 
			0,0, w,kJXDefaultMenuBarHeight);
	assert( menuBar != NULL );

	itsToolBar =
		new JXToolBar(GetPrefsMgr(), kFitToolBarID,
			menuBar, w, h,
			window, JXWidget::kHElastic, JXWidget::kVElastic, 
			0,kJXDefaultMenuBarHeight, w,h - kJXDefaultMenuBarHeight);
	assert( itsToolBar != NULL );

	JSize newHeight = itsToolBar->GetWidgetEnclosure()->GetBoundsHeight();

	const JCoordinate kPartitionHandleWidth	= 5;
	const JCoordinate kFitListWidth			= 155;

	JArray<JCoordinate> widths(2);
	widths.AppendElement(kFitListWidth);
	widths.AppendElement(w - kFitListWidth - kPartitionHandleWidth);

	JIndex elasticIndex = 2;

	JArray<JCoordinate> minWidths(2);
	minWidths.AppendElement(100);
	minWidths.AppendElement(300);

	itsMainPartition =
		new JXHorizPartition(widths, elasticIndex, minWidths,
							 itsToolBar->GetWidgetEnclosure(), 
							 JXWidget::kHElastic,JXWidget::kVElastic,
							 0, 0, w, newHeight);
	assert( itsMainPartition != NULL );

	// This is the first column the contains the curve and fit lists.
	
	JXContainer* container = itsMainPartition->GetCompartment(1);

	const JCoordinate kCurveListHeight	= 100;
	const JCoordinate kColHeaderHeight	= 20;
	const JCoordinate kExprHeight		= 50;
	const JCoordinate kFitListHeight	= newHeight - kCurveListHeight - 2 * kPartitionHandleWidth - kExprHeight;
	
	JArray<JCoordinate> heights(3);
	heights.AppendElement(kCurveListHeight);
	heights.AppendElement(kFitListHeight);
	heights.AppendElement(kExprHeight);

	elasticIndex = 2;

	JArray<JCoordinate> minHeights(3);
	minHeights.AppendElement(50);	
	minHeights.AppendElement(100);
	minHeights.AppendElement(40);

	itsListPartition =
		new JXVertPartition(heights, elasticIndex, minHeights, container,
			JXWidget::kHElastic, JXWidget::kVElastic, 0, 0, kFitListWidth, newHeight);
    assert( itsListPartition != NULL );

	container = itsListPartition->GetCompartment(1);
	
	JXScrollbarSet* scrollbarSet =
		new JXScrollbarSet(container, 
						   JXWidget::kHElastic,JXWidget::kVElastic,
						   0, kColHeaderHeight,
						   kFitListWidth, kCurveListHeight - kColHeaderHeight);
	assert( scrollbarSet != NULL );

	// This will be the curve list

	itsCurveList	= 
		new GLCurveNameList(itsDir, itsPlot, 
			scrollbarSet, scrollbarSet->GetScrollEnclosure(),
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0,  kFitListWidth, kCurveListHeight - kColHeaderHeight);
	assert(itsCurveList != NULL);
	ListenTo(itsCurveList);

	JXColHeaderWidget* header =
		new JXColHeaderWidget(itsCurveList, scrollbarSet,
			container,
			JXWidget::kHElastic, JXWidget::kFixedTop,
			0, 0,  
			kFitListWidth, 
			kColHeaderHeight);
	assert(header != NULL);

	header->SetColTitle(1, "Curves");
	
	container = itsListPartition->GetCompartment(2);
	
	scrollbarSet =
		new JXScrollbarSet(container, 
						   JXWidget::kHElastic,JXWidget::kVElastic,
						   0, kColHeaderHeight,
						   kFitListWidth, 
						   kFitListHeight - kColHeaderHeight);
	assert( scrollbarSet != NULL );

	// This will be the fit list
	
	itsFitList	= 
		new GLFitDescriptionList(scrollbarSet, scrollbarSet->GetScrollEnclosure(),
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0,  
			kFitListWidth, 
			kFitListHeight - kColHeaderHeight);
	assert(itsFitList != NULL);
	ListenTo(itsFitList);

	header =
		new JXColHeaderWidget(itsFitList, scrollbarSet,
			container,
			JXWidget::kHElastic, JXWidget::kFixedTop,
			0, 0,  
			kFitListWidth, 
			kColHeaderHeight);
	assert(header != NULL);

	header->SetColTitle(1, "Fits");

	// this is the expression widget that displays the current JFunction

	container = itsListPartition->GetCompartment(3);
	
	scrollbarSet =
		new JXScrollbarSet(container, 
						   JXWidget::kHElastic,JXWidget::kVElastic,
						   0, 0,
						   kFitListWidth, 
						   kExprHeight);
	assert( scrollbarSet != NULL );

	itsExprVarList	= new GVarList();
	assert(itsExprVarList != NULL);

	itsExprWidget	= 
		new JXExprWidget(itsExprVarList,
			scrollbarSet, scrollbarSet->GetScrollEnclosure(),
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0, 
			kFitListWidth, 
			kExprHeight);
	assert(itsExprWidget != NULL);
	itsExprWidget->Hide();

	// This is the second column that will contain the parameter table
	// and the plots

	container = itsMainPartition->GetCompartment(2);

	const JCoordinate kParmsTableHeight		= 50;
	const JCoordinate kChiSqHeight			= 20;
	const JCoordinate kTotalParmsHeight		= kParmsTableHeight + kColHeaderHeight + kChiSqHeight;
	const JCoordinate kFirstPlotHeight		= 120;
	const JCoordinate kMinPlotHeight		= 100;

	heights.RemoveAll();
	heights.AppendElement(kTotalParmsHeight);
	heights.AppendElement(kFirstPlotHeight);
	heights.AppendElement(newHeight - kFirstPlotHeight - kTotalParmsHeight - 2 * kPartitionHandleWidth);

	elasticIndex = 2;

	minHeights.RemoveAll();
	minHeights.AppendElement(kTotalParmsHeight - 20);
	minHeights.AppendElement(kMinPlotHeight);
	minHeights.AppendElement(kMinPlotHeight);
	
	itsPlotPartition =
		new JXVertPartition(heights, elasticIndex, minHeights, container,
			JXWidget::kHElastic, JXWidget::kVElastic, 
			0, 0, w - kFitListWidth - kPartitionHandleWidth, newHeight);
    assert( itsPlotPartition != NULL );

	container = itsPlotPartition->GetCompartment(1);
	
	scrollbarSet =
		new JXScrollbarSet(container, 
						   JXWidget::kHElastic,JXWidget::kVElastic,
						   0, kColHeaderHeight,
						   w - kFitListWidth - kPartitionHandleWidth, 
						   kParmsTableHeight);
	assert( scrollbarSet != NULL );

	// this will be the parameter table
	itsParameterTable =
		new GLFitParameterTable(scrollbarSet, scrollbarSet->GetScrollEnclosure(),
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0,  
			w - kFitListWidth - kPartitionHandleWidth, 
			kParmsTableHeight);
	assert(itsParameterTable != NULL);
	ListenTo(itsParameterTable);

	itsParameterColHeader = 
		new GLParmColHeaderWidget(itsParameterTable, scrollbarSet,
			container,
			JXWidget::kHElastic, JXWidget::kFixedTop,
			0, 0,  
			w - kFitListWidth - kPartitionHandleWidth, 
			kColHeaderHeight);
	assert(itsParameterColHeader != NULL);

	itsParameterTable->SetColHeaderWidget(itsParameterColHeader);
	    
	itsFitMenu = menuBar->AppendTextMenu(kFitMenuTitleStr);
	itsFitMenu->SetMenuItems(kFitMenuStr);
	itsFitMenu->SetUpdateAction(JXMenu::kDisableAll);
	ListenTo(itsFitMenu);

	const JCoordinate kChiSqLabelWidth	= 170;

	GLChiSqLabel* label = 
		new GLChiSqLabel(container, 
			JXWidget::kFixedLeft, JXWidget::kFixedBottom,
			0, kParmsTableHeight + kColHeaderHeight,
			kChiSqLabelWidth, kChiSqHeight);
	assert(label != NULL);

	JXDownRect* downRect =
		new JXDownRect(container,
			JXWidget::kHElastic, JXWidget::kFixedBottom,
			kChiSqLabelWidth, kParmsTableHeight + kColHeaderHeight,
			w - kFitListWidth - kPartitionHandleWidth, kChiSqHeight);
	assert(downRect != NULL);

	itsChiSq =
		new JXStaticText("", container,
			JXWidget::kHElastic, JXWidget::kFixedBottom,
			kChiSqLabelWidth + kJXDefaultBorderWidth, 
			kParmsTableHeight + kColHeaderHeight + kJXDefaultBorderWidth,
			w - kFitListWidth - kPartitionHandleWidth - 2 * kJXDefaultBorderWidth, 
			kChiSqHeight - 2 * kJXDefaultBorderWidth);
	assert(itsChiSq != NULL);
	itsChiSq->SetBackColor(GetColormap()->GetWhiteColor());

	// now add the 2 plots

	container = itsPlotPartition->GetCompartment(2);

	itsFitPlot	= 
		new JX2DPlotWidget(menuBar, container,
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0, 
			w - kFitListWidth - kPartitionHandleWidth,
			container->GetApertureHeight());
	assert(itsFitPlot != NULL);
	itsFitPlot->SetTitle(kFitPlotTitle);
	itsFitPlot->SetXLabel(itsPlot->GetXLabel());
	itsFitPlot->SetYLabel(itsPlot->GetYLabel());

	container = itsPlotPartition->GetCompartment(3);

	itsDiffPlot	= 
		new JX2DPlotWidget(itsFitPlot, container,
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 0, 
			w - kFitListWidth - kPartitionHandleWidth,
			newHeight - kFirstPlotHeight - kTotalParmsHeight - 2 * kPartitionHandleWidth);
	assert(itsDiffPlot != NULL);
	itsDiffPlot->SetTitle(kDiffPlotTitle);
	itsDiffPlot->SetXLabel(itsPlot->GetXLabel());
	itsDiffPlot->SetYLabel(itsPlot->GetYLabel());
	itsDiffPlot->ShowFrame(kJFalse);

	itsPrefsMenu = menuBar->AppendTextMenu(kPrefsMenuTitleStr);
	itsPrefsMenu->SetMenuItems(kPrefsMenuStr);
	itsPrefsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPrefsMenu);

	itsHelpMenu = menuBar->AppendTextMenu(kHelpMenuTitleStr);
	itsHelpMenu->SetMenuItems(kHelpMenuStr);
	itsHelpMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsHelpMenu);

	itsHelpMenu->SetItemImage(kTOCCmd, jx_help_toc);
	itsHelpMenu->SetItemImage(kThisWindowCmd, JXPM(jx_help_specific));

	itsCurveList->SetCurrentCurveIndex(1);

	GetPrefsMgr()->ReadFitDirectorSetup(this);
}
void
CBEditTextPrefsDialog::BuildWindow
	(
	CBTextDocument* doc
	)
{
// begin JXLayout

	JXWindow* window = jnew JXWindow(this, 640,530, "");
	assert( window != NULL );

	itsTabCharCountInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,130, 40,20);
	assert( itsTabCharCountInput != NULL );

	itsCRMLineWidthInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,150, 40,20);
	assert( itsCRMLineWidthInput != NULL );

	itsUndoDepthInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,170, 40,20);
	assert( itsUndoDepthInput != NULL );

	JXTextButton* cancelButton =
		jnew JXTextButton(JGetString("cancelButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 40,490, 60,20);
	assert( cancelButton != NULL );

	JXTextButton* okButton =
		jnew JXTextButton(JGetString("okButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 220,490, 60,20);
	assert( okButton != NULL );
	okButton->SetShortcuts(JGetString("okButton::CBEditTextPrefsDialog::shortcuts::JXLayout"));

	itsCreateBackupCB =
		jnew JXTextCheckbox(JGetString("itsCreateBackupCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,230, 300,20);
	assert( itsCreateBackupCB != NULL );

	itsAutoIndentCB =
		jnew JXTextCheckbox(JGetString("itsAutoIndentCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,160, 280,20);
	assert( itsAutoIndentCB != NULL );

	JXStaticText* spacesPerTabLabel =
		jnew JXStaticText(JGetString("spacesPerTabLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,130, 210,20);
	assert( spacesPerTabLabel != NULL );
	spacesPerTabLabel->SetToLabel();

	itsExtraSpaceWindTitleCB =
		jnew JXTextCheckbox(JGetString("itsExtraSpaceWindTitleCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,310, 300,20);
	assert( itsExtraSpaceWindTitleCB != NULL );

	itsOpenComplFileOnTopCB =
		jnew JXTextCheckbox(JGetString("itsOpenComplFileOnTopCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,280, 300,20);
	assert( itsOpenComplFileOnTopCB != NULL );

	itsFontMenu =
		jnew JXChooseMonoFont(window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 280,60);
	assert( itsFontMenu != NULL );

	itsEmulatorMenu =
		jnew JXTextMenu(JGetString("itsEmulatorMenu::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,90, 280,25);
	assert( itsEmulatorMenu != NULL );

	JXStaticText* undoDepthLabel =
		jnew JXStaticText(JGetString("undoDepthLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,170, 210,20);
	assert( undoDepthLabel != NULL );
	undoDepthLabel->SetToLabel();

	itsUseDNDCB =
		jnew JXTextCheckbox(JGetString("itsUseDNDCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,130, 280,20);
	assert( itsUseDNDCB != NULL );

	itsOnlyBackupIfNoneCB =
		jnew JXTextCheckbox(JGetString("itsOnlyBackupIfNoneCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,250, 300,20);
	assert( itsOnlyBackupIfNoneCB != NULL );

	itsLeftToFrontOfTextCB =
		jnew JXTextCheckbox(JGetString("itsLeftToFrontOfTextCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,450, 300,20);
	assert( itsLeftToFrontOfTextCB != NULL );

	itsHelpButton =
		jnew JXTextButton(JGetString("itsHelpButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 130,490, 60,20);
	assert( itsHelpButton != NULL );
	itsHelpButton->SetShortcuts(JGetString("itsHelpButton::CBEditTextPrefsDialog::shortcuts::JXLayout"));

	itsBalanceWhileTypingCB =
		jnew JXTextCheckbox(JGetString("itsBalanceWhileTypingCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,310, 280,20);
	assert( itsBalanceWhileTypingCB != NULL );

	itsScrollToBalanceCB =
		jnew JXTextCheckbox(JGetString("itsScrollToBalanceCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,330, 280,20);
	assert( itsScrollToBalanceCB != NULL );

	itsBeepWhenTypeUnbalancedCB =
		jnew JXTextCheckbox(JGetString("itsBeepWhenTypeUnbalancedCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,350, 280,20);
	assert( itsBeepWhenTypeUnbalancedCB != NULL );

	JXStaticText* cpmLabel =
		jnew JXStaticText(JGetString("cpmLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,150, 210,20);
	assert( cpmLabel != NULL );
	cpmLabel->SetToLabel();

	itsSmartTabCB =
		jnew JXTextCheckbox(JGetString("itsSmartTabCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,220, 280,20);
	assert( itsSmartTabCB != NULL );

	itsPWModRG =
		jnew JXRadioGroup(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 460,350, 160,80);
	assert( itsPWModRG != NULL );

	JXTextRadioButton* ctrlMetaLabel =
		jnew JXTextRadioButton(JXTEBase::kCtrlMetaPWMod, JGetString("ctrlMetaLabel::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,10, 90,20);
	assert( ctrlMetaLabel != NULL );

	JXTextRadioButton* mod2Label =
		jnew JXTextRadioButton(JXTEBase::kMod2PWMod, JGetString("mod2Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,30, 70,20);
	assert( mod2Label != NULL );

	JXTextRadioButton* mod3Label =
		jnew JXTextRadioButton(JXTEBase::kMod3PWMod, JGetString("mod3Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 10,50, 70,20);
	assert( mod3Label != NULL );

	JXTextRadioButton* mod4Label =
		jnew JXTextRadioButton(JXTEBase::kMod4PWMod, JGetString("mod4Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 90,30, 60,20);
	assert( mod4Label != NULL );

	JXTextRadioButton* mod5Label =
		jnew JXTextRadioButton(JXTEBase::kMod5PWMod, JGetString("mod5Label::CBEditTextPrefsDialog::JXLayout"), itsPWModRG,
					JXWidget::kHElastic, JXWidget::kVElastic, 90,50, 60,20);
	assert( mod5Label != NULL );

	JXStaticText* partialWordTitle =
		jnew JXStaticText(JGetString("partialWordTitle::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,360, 120,60);
	assert( partialWordTitle != NULL );

	itsCopyWhenSelectCB =
		jnew JXTextCheckbox(JGetString("itsCopyWhenSelectCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,250, 280,20);
	assert( itsCopyWhenSelectCB != NULL );

	itsColorButton[CBPrefsManager::kTextColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kTextColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,50, 40,20);
	assert( itsColorButton[CBPrefsManager::kTextColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kBackColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kBackColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 440,50, 80,20);
	assert( itsColorButton[CBPrefsManager::kBackColorIndex-1] != NULL );

	JXStaticText* changeColorLabel =
		jnew JXStaticText(JGetString("changeColorLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 310,50, 90,20);
	assert( changeColorLabel != NULL );
	changeColorLabel->SetToLabel();

	itsColorButton[CBPrefsManager::kSelColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kSelColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 560,50, 60,20);
	assert( itsColorButton[CBPrefsManager::kSelColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kSelLineColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kSelLineColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,70, 50,20);
	assert( itsColorButton[CBPrefsManager::kSelLineColorIndex-1] != NULL );

	itsColorButton[CBPrefsManager::kCaretColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kCaretColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 520,50, 40,20);
	assert( itsColorButton[CBPrefsManager::kCaretColorIndex-1] != NULL );

	itsDefColorsButton =
		jnew JXTextButton(JGetString("itsDefColorsButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 400,95, 100,20);
	assert( itsDefColorsButton != NULL );

	itsInvColorsButton =
		jnew JXTextButton(JGetString("itsInvColorsButton::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 500,95, 100,20);
	assert( itsInvColorsButton != NULL );

	JXStaticText* colorSetsLabel =
		jnew JXStaticText(JGetString("colorSetsLabel::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 310,95, 90,20);
	assert( colorSetsLabel != NULL );
	colorSetsLabel->SetToLabel();

	itsTabToSpacesCB =
		jnew JXTextCheckbox(JGetString("itsTabToSpacesCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,190, 280,20);
	assert( itsTabToSpacesCB != NULL );

	itsHomeEndCB =
		jnew JXTextCheckbox(JGetString("itsHomeEndCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 330,470, 300,20);
	assert( itsHomeEndCB != NULL );

	itsScrollCaretCB =
		jnew JXTextCheckbox(JGetString("itsScrollCaretCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 330,490, 300,20);
	assert( itsScrollCaretCB != NULL );

	itsSortFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsSortFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,390, 280,20);
	assert( itsSortFnMenuCB != NULL );

	itsPackFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsPackFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,430, 280,20);
	assert( itsPackFnMenuCB != NULL );

	itsColorButton[CBPrefsManager::kRightMarginColorIndex-1] =
		jnew JXTextButton(JGetString("itsColorButton[CBPrefsManager::kRightMarginColorIndex-1]::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 450,70, 160,20);
	assert( itsColorButton[CBPrefsManager::kRightMarginColorIndex-1] != NULL );

	itsRightMarginCB =
		jnew JXTextCheckbox(JGetString("itsRightMarginCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 330,190, 210,20);
	assert( itsRightMarginCB != NULL );

	itsRightMarginInput =
		jnew JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 540,190, 40,20);
	assert( itsRightMarginInput != NULL );

	itsSampleText =
		jnew CBSampleText(window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 310,20, 310,25);
	assert( itsSampleText != NULL );

	itsNSInFnMenuCB =
		jnew JXTextCheckbox(JGetString("itsNSInFnMenuCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,410, 280,20);
	assert( itsNSInFnMenuCB != NULL );

	JXStaticText* wordWrapHint =
		jnew JXStaticText(JGetString("wordWrapHint::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 40,460, 250,20);
	assert( wordWrapHint != NULL );
	wordWrapHint->SetFontSize(JGetDefaultFontSize()-2);
	wordWrapHint->SetToLabel();

	itsMiddleButtonPasteCB =
		jnew JXTextCheckbox(JGetString("itsMiddleButtonPasteCB::CBEditTextPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,270, 280,20);
	assert( itsMiddleButtonPasteCB != NULL );

// end JXLayout

	window->SetTitle("Text Editor Preferences");
	SetButtons(okButton, cancelButton);

	ListenTo(itsHelpButton);

	itsEmulatorMenu->SetMenuItems(kEmulatorMenuStr);
	itsEmulatorMenu->SetUpdateAction(JXMenu::kDisableNone);
	itsEmulatorMenu->SetToPopupChoice(kJTrue, itsEmulatorIndex);
	ListenTo(itsEmulatorMenu);

	itsCreateBackupCB->SetState(doc->WillMakeBackupFile());
	itsOnlyBackupIfNoneCB->SetState(!doc->WillMakeNewBackupEveryOpen());
	itsExtraSpaceWindTitleCB->SetState(doc->WillAllocateTitleSpace());
	itsOpenComplFileOnTopCB->SetState(doc->WillOpenComplFileOnTop());

	CBTextEditor* te = doc->GetTextEditor();

	itsAutoIndentCB->SetState(te->WillAutoIndent());
	itsUseDNDCB->SetState(te->CBAllowsDragAndDrop());
	itsLeftToFrontOfTextCB->SetState(te->WillMoveToFrontOfText());

	itsBalanceWhileTypingCB->SetState(te->WillBalanceWhileTyping());
	itsScrollToBalanceCB->SetState(te->WillScrollToBalance());
	itsBeepWhenTypeUnbalancedCB->SetState(te->WillBeepWhenTypeUnbalanced());

	CBFnMenuUpdater* updater = CBGetFnMenuUpdater();
	itsSortFnMenuCB->SetState(updater->WillSortFnNames());
	itsNSInFnMenuCB->SetState(updater->WillIncludeNamespace());
	itsPackFnMenuCB->SetState(updater->WillPackFnNames());

	itsSmartTabCB->SetState(te->TabIsSmart());
	itsTabToSpacesCB->SetState(te->TabInsertsSpaces());
	itsCopyWhenSelectCB->SetState(te->WillCopyWhenSelect());
	itsMiddleButtonPasteCB->SetState(te->MiddleButtonWillPaste());

	const JFont& font = te->GetDefaultFont();
	itsFontMenu->SetFont(font.GetName(), font.GetSize());

	itsTabCharCountInput->SetValue(te->GetTabCharCount());
	itsTabCharCountInput->SetLowerLimit(1);

	itsCRMLineWidthInput->SetValue(te->GetCRMLineWidth());
	itsCRMLineWidthInput->SetLowerLimit(1);

	itsUndoDepthInput->SetValue(te->GetUndoDepth());
	itsUndoDepthInput->SetLowerLimit(1);

	JSize margin;
	itsRightMarginCB->SetState(te->GetRightMarginWidth(&margin));
	itsRightMarginInput->SetValue(margin);
	itsRightMarginInput->SetLowerLimit(1);

	itsPWModRG->SelectItem(te->GetPartialWordModifier());
	itsHomeEndCB->SetState(JXTEBase::WillUseWindowsHomeEnd());
	itsScrollCaretCB->SetState(CBTextEditor::CaretWillFollowScroll());

	ListenTo(itsCreateBackupCB);
	ListenTo(itsBalanceWhileTypingCB);
	UpdateDisplay();

	// must do this after SetWindow()

	CBPrefsManager* prefsMgr = CBGetPrefsManager();
	JXColormap* colormap     = GetColormap();
	for (JIndex i=0; i<CBPrefsManager::kColorCount; i++)
		{
		itsColor[i] = prefsMgr->GetColor(i+1);
		ListenTo(itsColorButton[i]);
		}

	ListenTo(itsDefColorsButton);
	ListenTo(itsInvColorsButton);
	ListenTo(itsFontMenu);
	ListenTo(itsRightMarginCB);

	UpdateSampleText();
}
void
JXColorWheel::Draw
	(
	JXWindowPainter&	p,
	const JRect&		rect
	)
{
	JXColormap* colormap    = GetColormap();
	const JColorIndex black = colormap->GetBlackColor();

	const JRect bounds       = GetBoundsGlobal();
	const JCoordinate max    = JMin(bounds.height(), bounds.width() - kSliderWidth - kSliderMargin);
	const JCoordinate size   = max - 2*kWheelMargin - 1;
	const JCoordinate center = size/2 + kWheelMargin;
	if (itsImage == NULL || itsImage->GetWidth() != max || itsColor.brightness != itsLastDrawBrightness)
		{
		p.SetFilling(kJTrue);
		p.SetPenColor(black);
		p.Ellipse(kWheelMargin, kWheelMargin, size, size);
		p.SetFilling(kJFalse);

		JRect r  = bounds;
		r.bottom = r.top  + max;
		r.right  = r.left + max;

		jdelete itsImage;
		itsImage = jnew JXImage(GetDisplay(), p.GetDrawable(), r);
		assert( itsImage != NULL );

		itsLastDrawBrightness = itsColor.brightness;
		for (JCoordinate x=0; x<max; x++)
			{
			const JCoordinate dx = - x + center;

			for (JCoordinate y=0; y<max; y++)
				{
				if (itsImage->GetColor(x,y) == black)
					{
					const JCoordinate dy = y - center;
					const JFloat r = sqrt(dx*dx + dy*dy) / center;
					const JFloat a = 0.5 + atan2(dy, dx) / (2.0 * kJPi);

					JHSB color(JRound(a * kJMaxHSBValue), JRound(r * kJMaxHSBValue), itsLastDrawBrightness);
					itsImage->SetColor(x,y, colormap->JColormap::GetColor(color));
					}
				}
			}

		itsImage->ConvertToRemoteStorage();
		}

	p.JPainter::Image(*itsImage, itsImage->GetBounds(), 0,0);

	const JFloat r = (itsColor.saturation / kJMaxHSBValueF) * size/2;
	const JFloat a = ((itsColor.hue / kJMaxHSBValueF) - 0.5) * 2.0 * kJPi;

	const JCoordinate x = center - JRound(r * cos(a));
	const JCoordinate y = center + JRound(r * sin(a));

	JRect mark(y-kWheelMargin, x-kWheelMargin, y+kWheelMargin+1, x+kWheelMargin+1);

	p.SetPenColor(colormap->GetWhiteColor());
	p.SetFilling(kJTrue);
	p.JPainter::Rect(mark);
	p.SetFilling(kJFalse);
	p.SetPenColor(black);
	p.JPainter::Rect(mark);
}
Esempio n. 9
0
JColorIndex	JXTable::GetSelectionColor() const
{
	return GetColormap()->GetDefaultSelectionColor();
}
void
JXHintDirector::BuildWindow
	(
	const JRect&		frameR,
	const JCharacter*	text
	)
{
	// create window and contents

	JXWindow* window = jnew JXWindow(this, 10,10, "", kJTrue);
	assert( window != NULL );

	window->SetWMWindowType(JXWindow::kWMTooltipType);

	JXBorderRect* border =
		jnew JXBorderRect(window, JXWidget::kHElastic, JXWidget::kVElastic,
						 0,0, 10,10);
	assert( border != NULL );
	border->FitToEnclosure();

	JXStaticText* textWidget =
		jnew JXStaticText(text, border,
						 JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 kHMargin, kVMargin, 0,0);
	assert( textWidget != NULL );

	JCoordinate ascent = 0, descent = 0;
	if (!JStringEmpty(text))
		{
		(textWidget->GetFont(1)).GetLineHeight(&ascent, &descent);
		}

	const JCoordinate w = 2*kHMargin + textWidget->GetFrameWidth();
	const JCoordinate h = 2*kVMargin + ascent + descent;
	window->SetSize(w,h);

	// place window

	const JRect rootBounds = GetDisplay()->GetBounds();

	JCoordinate x = frameR.left + 1;
	JCoordinate y = frameR.bottom + 1;

	if (x + w > rootBounds.right)
		{
		x = rootBounds.right - w - 1;
		}
	if (x < 0)
		{
		x = rootBounds.left + 1;
		}

	if (y + h > rootBounds.bottom)
		{
		y = frameR.top - h - 1;
		}

	window->Place(x,y);

	// use standard background color

	JColorIndex backColorIndex = GetColormap()->JColormap::GetColor(kBackColor);
	window->SetBackColor(backColorIndex);
	border->SetBackColor(backColorIndex);
	textWidget->SetBackgroundColor(backColorIndex);
}
void
GCLAlarmDialog::BuildWindow()
{

// begin JXLayout

    JXWindow* window = new JXWindow(this, 390,250, "");
    assert( window != NULL );
    SetWindow(window);

    itsHelpButton =
        new JXTextButton(JGetString("itsHelpButton::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 80,220, 70,20);
    assert( itsHelpButton != NULL );

    JXTextButton* okButton =
        new JXTextButton(JGetString("okButton::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 230,220, 70,20);
    assert( okButton != NULL );
    okButton->SetShortcuts(JGetString("okButton::GCLAlarmDialog::shortcuts::JXLayout"));

    itsStatusText =
        new JXStaticText(JGetString("itsStatusText::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 20,140, 350,20);
    assert( itsStatusText != NULL );
    itsStatusText->SetFontSize(14);

    itsRG =
        new JXRadioGroup(window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 20,170, 350,45);
    assert( itsRG != NULL );

    JXTextRadioButton* obj1_JXLayout =
        new JXTextRadioButton(1, JGetString("obj1_JXLayout::GCLAlarmDialog::JXLayout"), itsRG,
                    JXWidget::kHElastic, JXWidget::kVElastic, 10,0, 140,20);
    assert( obj1_JXLayout != NULL );

    JXTextRadioButton* obj2_JXLayout =
        new JXTextRadioButton(2, JGetString("obj2_JXLayout::GCLAlarmDialog::JXLayout"), itsRG,
                    JXWidget::kHElastic, JXWidget::kVElastic, 10,20, 150,20);
    assert( obj2_JXLayout != NULL );

    itsAmountInput =
        new JXIntegerInput(itsRG,
                    JXWidget::kHElastic, JXWidget::kVElastic, 160,0, 80,20);
    assert( itsAmountInput != NULL );

    itsTimeUnitMenu =
        new JXTextMenu(JGetString("itsTimeUnitMenu::GCLAlarmDialog::JXLayout"), itsRG,
                    JXWidget::kHElastic, JXWidget::kVElastic, 240,0, 100,20);
    assert( itsTimeUnitMenu != NULL );

    JXStaticText* obj3_JXLayout =
        new JXStaticText(JGetString("obj3_JXLayout::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 20,10, 350,20);
    assert( obj3_JXLayout != NULL );

    JXStaticText* obj4_JXLayout =
        new JXStaticText(JGetString("obj4_JXLayout::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 20,40, 70,20);
    assert( obj4_JXLayout != NULL );
    obj4_JXLayout->SetFontSize(14);
    const JFontStyle obj4_JXLayout_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetBlackColor());
    obj4_JXLayout->SetFontStyle(obj4_JXLayout_style);

    itsSubjectText =
        new JXStaticText(JGetString("itsSubjectText::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 90,40, 280,20);
    assert( itsSubjectText != NULL );
    itsSubjectText->SetFontSize(14);
    const JFontStyle itsSubjectText_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetBlackColor());
    itsSubjectText->SetFontStyle(itsSubjectText_style);

    JXStaticText* obj5_JXLayout =
        new JXStaticText(JGetString("obj5_JXLayout::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 20,70, 70,20);
    assert( obj5_JXLayout != NULL );
    obj5_JXLayout->SetFontSize(14);
    const JFontStyle obj5_JXLayout_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetBlackColor());
    obj5_JXLayout->SetFontStyle(obj5_JXLayout_style);

    itsTimeText =
        new JXStaticText(JGetString("itsTimeText::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 90,70, 280,20);
    assert( itsTimeText != NULL );
    itsTimeText->SetFontSize(14);
    const JFontStyle itsTimeText_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetBlackColor());
    itsTimeText->SetFontStyle(itsTimeText_style);

    itsDateText =
        new JXStaticText(JGetString("itsDateText::GCLAlarmDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 90,100, 280,20);
    assert( itsDateText != NULL );
    itsDateText->SetFontSize(14);
    const JFontStyle itsDateText_style(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetBlackColor());
    itsDateText->SetFontStyle(itsDateText_style);

// end JXLayout

	SetButtons(okButton, NULL);
	window->SetTitle("Appointment Reminder");

	itsAmountInput->SetLowerLimit(0);
	itsTimeUnitMenu->SetMenuItems(kTimeUnitMenuString);
	itsTimeUnitMenu->SetUpdateAction(JXMenu::kDisableNone);
	itsTimeUnitMenu->SetTitleText("Minute(s)");

	itsTimeUnit	= kMinute;

	ListenTo(itsTimeUnitMenu);

	itsRG->SelectItem(kRemindAgain);
	itsAmountInput->SetValue(kTimeDefault);

	BuildText();
}
Esempio n. 12
0
JXStyleMenu::~JXStyleMenu()
{
	(GetColormap())->DeallocateColor(itsColorList[ kColorCount-1 ]);
}
void
JXTextMenuTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	origRect
	)
{
	JRect rect = AdjustRectForSeparator(cell.y, origRect);

	if (cell.x == kCheckboxColumnIndex)
		{
		rect.left += kHilightBorderWidth;
		DrawCheckbox(p, cell.y, rect);
		}

	else if (cell.x == kImageColumnIndex)
		{
		const JXImage* image;
		if (itsTextMenuData->GetImage(cell.y, &image))
			{
			p.Image(*image, image->GetBounds(), rect);
			}
		}

	else if (cell.x == kTextColumnIndex)
		{
		JIndex ulIndex;
		JFontID id;
		JSize size;
		JFontStyle style;
		const JString& text =
			itsTextMenuData->GetText(cell.y, &ulIndex, &id, &size, &style);

		if (!itsTextMenuData->IsEnabled(cell.y))
			{
			style.color = (GetColormap())->GetInactiveLabelColor();
			}
		p.SetFont(id, size, style);

		rect.left += kHMarginWidth;

		JXWindowPainter* xp = dynamic_cast<JXWindowPainter*>(&p);
		assert( xp != NULL );
		xp->String(rect.left, rect.top, text, ulIndex,
				   rect.width(), JPainter::kHAlignLeft,
				   rect.height(), JPainter::kVAlignCenter);
		}

	else if (cell.x == kSubmenuColumnIndex && itsTextMenuData->HasSubmenu(cell.y))
		{
		rect.right -= kHilightBorderWidth;
		rect.left   = rect.right - JXMenuTable::kSubmenuColWidth;
		DrawSubmenuIndicator(p, cell.y, rect,
							 JConvertToBoolean(((JIndex) cell.y) == itsHilightRow));
		}

	else if (cell.x == kSubmenuColumnIndex)
		{
		const JString* nmShortcut;
		JFontID id;
		JSize size;
		JFontStyle style;
		if (itsTextMenuData->GetNMShortcut(cell.y, &nmShortcut, &id, &size, &style))
			{
			if (!itsTextMenuData->IsEnabled(cell.y))
				{
				style.color = (GetColormap())->GetInactiveLabelColor();
				}
			p.SetFont(id, size, style);

			rect.left  += kHNMSMarginWidth;
			rect.right -= kHilightBorderWidth;
			p.String(rect, *nmShortcut, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
			}
		}
}
void
JXTipOfTheDayDialog::BuildWindow
	(
	const JBoolean showStartupCB,
	const JBoolean showAtStartup
	)
{
// begin JXLayout

	JXWindow* window = new JXWindow(this, 410,260, "");
	assert( window != NULL );

	JXFlatRect* sideBar =
		new JXFlatRect(window,
					JXWidget::kFixedLeft, JXWidget::kVElastic, 10,10, 50,200);
	assert( sideBar != NULL );
    sideBar->SetColor((GetColormap())->GetInactiveLabelColor());

	itsCloseButton =
		new JXTextButton(JGetString("itsCloseButton::JXTipOfTheDayDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedBottom, 340,225, 60,20);
	assert( itsCloseButton != NULL );

	itsNextTipButton =
		new JXTextButton(JGetString("itsNextTipButton::JXTipOfTheDayDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedBottom, 260,225, 60,20);
	assert( itsNextTipButton != NULL );
	itsNextTipButton->SetShortcuts(JGetString("itsNextTipButton::JXTipOfTheDayDialog::shortcuts::JXLayout"));

	JXImageWidget* icon =
		new JXImageWidget(sideBar,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,15, 30,30);
	assert( icon != NULL );

	JXScrollbarSet* scrollbarSet =
		new JXScrollbarSet(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 60,60, 340,150);
	assert( scrollbarSet != NULL );

	JXStaticText* title =
		new JXStaticText(JGetString("title::JXTipOfTheDayDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 60,10, 340,50);
	assert( title != NULL );

	itsShowAtStartupCB =
		new JXTextCheckbox(JGetString("itsShowAtStartupCB::JXTipOfTheDayDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedBottom, 10,225, 140,20);
	assert( itsShowAtStartupCB != NULL );

// end JXLayout

	window->SetTitle("Tip of the Day");
	window->LockCurrentMinSize();
	window->PlaceAsDialogWindow();

	JXDisplay* display = GetDisplay();
	JXImage* wIcon     = new JXImage(display, jx_tip_of_the_day);
	assert( wIcon != NULL );
	window->SetIcon(wIcon);

	sideBar->SetColor((GetColormap())->GetGrayColor(50));
	icon->SetXPM(jx_tip_of_the_day, (GetColormap())->GetGrayColor(50));

	title->SetBorderWidth(kJXDefaultBorderWidth);
	title->TESetLeftMarginWidth(5);
	title->SetBackColor(title->GetFocusColor());
	title->JTextEditor::SetFont(1, title->GetTextLength(), "Times", 18,
								JFontStyle(kJTrue, kJFalse, 0, kJFalse), kJTrue);
	title->SetCaretLocation(1);
	title->Paste("\n");

	itsText =
		new JXStaticText("", kJTrue, kJFalse,
						 scrollbarSet, scrollbarSet->GetScrollEnclosure(),
						 JXWidget::kHElastic, JXWidget::kVElastic, 0,0, 100,100);
	assert( itsText != NULL );
	itsText->FitToEnclosure();
	itsText->TESetLeftMarginWidth(5);

	itsShowAtStartupCB->SetVisible(showStartupCB);
	itsShowAtStartupCB->SetState(showAtStartup);

	ListenTo(itsNextTipButton);
	ListenTo(itsCloseButton);
}
JColorIndex
CMLineAddressTable::GetCurrentLineMarkerColor()
	const
{
	return GetColormap()->GetMagentaColor();
}
Esempio n. 16
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);
}
Esempio n. 17
0
void
CBHTMLStyler::UpgradeTypeList
	(
	const JFileVersion	vers,
	JArray<JFontStyle>*	typeStyles
	)
{
	JColormap* cmap = GetColormap();

	if (vers < 1)
		{
		typeStyles->InsertElementAtIndex(2, JFontStyle(cmap->GetDarkRedColor()));
		}

	if (vers < 2)
		{
		typeStyles->InsertElementAtIndex(1, JFontStyle());

		for (JIndex i=1; i<=16; i++)
			{
			typeStyles->InsertElementAtIndex(6, JFontStyle());
			}
		}

	if (vers < 3)
		{
		typeStyles->InsertElementAtIndex(22, JFontStyle());
		typeStyles->InsertElementAtIndex(22, JFontStyle());

		typeStyles->InsertElementAtIndex(17, JFontStyle());
		typeStyles->InsertElementAtIndex(17, JFontStyle());
		typeStyles->InsertElementAtIndex(17, JFontStyle());
		typeStyles->InsertElementAtIndex(17, JFontStyle());
		typeStyles->InsertElementAtIndex(17, JFontStyle());
		}

	if (vers < 4)
		{
		typeStyles->InsertElementAtIndex(22, JFontStyle(cmap->GetDarkGreenColor()));
		}

	if (vers < 5)
		{
		for (JIndex i=1; i<=9; i++)
			{
			typeStyles->InsertElementAtIndex(17, JFontStyle());
			}
		}

	if (vers < 6)
		{
		typeStyles->InsertElementAtIndex(6, JFontStyle());
		}

	if (vers < 7)
		{
		typeStyles->InsertElementAtIndex(6, JFontStyle());
		}

	// set new values after all new slots have been created

	if (vers < 2)
		{
		InitPHPTypeStyles();
		}

	if (vers < 3)
		{
		InitJavaScriptTypeStyles();
		}

	if (vers < 5)
		{
		InitJSPTypeStyles();
		}

	if (vers < 6)
		{
		InitMustacheTypeStyles();
		}
}
void
JXPathInput::AdjustStylesBeforeRecalc
	(
	const JString&		buffer,
	JRunArray<Font>*	styles,
	JIndexRange*		recalcRange,
	JIndexRange*		redrawRange,
	const JBoolean		deletion
	)
{
	const JColormap* colormap = GetColormap();
	const JSize totalLength   = buffer.GetLength();

	JString fullPath = buffer;
	if ((JIsRelativePath(buffer) && !HasBasePath()) ||
		!JExpandHomeDirShortcut(buffer, &fullPath))
		{
		fullPath.Clear();
		}

	// Last clause because if JConvertToAbsolutePath() succeeds, we don't
	// want to further modify fullName.

	else if (JIsRelativePath(buffer) &&
			 !JConvertToAbsolutePath(buffer, itsBasePath, &fullPath))
		{
		if (HasBasePath())
			{
			fullPath = JCombinePathAndName(itsBasePath, buffer);
			}
		else
			{
			fullPath.Clear();
			}
		}

	JSize errLength;
	if (fullPath.IsEmpty())
		{
		errLength = totalLength;
		}
	else
		{
		const JString closestDir = JGetClosestDirectory(fullPath, itsRequireWriteFlag);
		if (fullPath.BeginsWith(closestDir))
			{
			errLength = fullPath.GetLength() - closestDir.GetLength();
			}
		else
			{
			errLength = totalLength;
			}
		}

	if (errLength > 0 && buffer.EndsWith(kThisDirSuffix))
		{
		errLength++;	// trailing . is trimmed
		}

	Font f = styles->GetFirstElement();

	styles->RemoveAll();
	if (errLength >= totalLength)
		{
		f.style.color = colormap->GetRedColor();
		styles->AppendElements(f, totalLength);
		}
	else
		{
		f.style.color = colormap->GetBlackColor();
		styles->AppendElements(f, totalLength - errLength);

		if (errLength > 0)
			{
			f.style.color = colormap->GetRedColor();
			styles->AppendElements(f, errLength);
			}
		}

	*redrawRange += JIndexRange(1, totalLength);
}