コード例 #1
0
void
JXFixLenPGDirector::BuildWindow
	(
	JXProgressDisplay*	pg,
	const JCharacter*	message,
	const JBoolean		allowCancel
	)
{
// begin JXLayout

	JXWindow* window = new JXWindow(this, 270,80, "");
	assert( window != NULL );

	JXTextButton* cancelButton =
		new JXTextButton(JGetString("cancelButton::JXFixLenPGDirector::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 190,10, 60,20);
	assert( cancelButton != NULL );
	cancelButton->SetShortcuts(JGetString("cancelButton::JXFixLenPGDirector::shortcuts::JXLayout"));

	JXStaticText* text =
		new JXStaticText(JGetString("text::JXFixLenPGDirector::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,10, 160,20);
	assert( text != NULL );
	text->SetToLabel();

	JXProgressIndicator* indicator =
		new JXProgressIndicator(window,
					JXWidget::kHElastic, JXWidget::kFixedBottom, 20,50, 230,10);
	assert( indicator != NULL );

// end JXLayout

	if (!allowCancel)
		{
		// expand text to fill window because Cancel button will be hidden

		text->AdjustSize(indicator->GetFrameWidth() - text->GetFrameWidth(), 0);
		}

	Init(window, text, message, allowCancel, cancelButton);

	pg->SetItems(cancelButton, NULL, indicator);
}
コード例 #2
0
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);
}
コード例 #3
0
void
JXRadioGroupDialog::BuildWindow
	(
	const JCharacter*			windowTitle,
	const JCharacter*			prompt,
	const JPtrArray<JString>&	choiceList,
	const JPtrArray<JString>*	shortcutList
	)
{
JIndex i;

	const JSize actionCount = choiceList.GetElementCount();

	JXWindow* window = new JXWindow(this, 10,10, windowTitle);
	assert( window != NULL );

	JCoordinate y = kFirstItemTop;

	// instructions

	JXStaticText* instrText =
		new JXStaticText(prompt, window,
						 JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 kHMarginWidth,y, 0,0);
	assert( instrText != NULL );

	y += instrText->GetFrameHeight() + kItemVDelta;

	// radio group

	const JCoordinate kInitRGWidth = 10;	// arbitrary, >0

	itsRG =
		new JXRadioGroup(window, JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 kHMarginWidth,y,
						 kInitRGWidth, kItemVDelta + actionCount * kItemVSeparation);
	assert( itsRG != NULL );

	// choices

	JCoordinate wmin = 0;
	JPtrArray<JXRadioButton> buttonList(JPtrArrayT::kForgetAll, actionCount);
	for (i=1; i<=actionCount; i++)
		{
		JXTextRadioButton* button =
			new JXTextRadioButton(i, *(choiceList.NthElement(i)), itsRG,
								  JXWidget::kFixedLeft, JXWidget::kFixedTop,
								  kRGHLMarginWidth, kItemVDelta + (i-1) * kItemVSeparation,
								  10,kTextHeight);
		assert( button != NULL );

		if (shortcutList != NULL)
			{
			button->SetShortcuts(*(shortcutList->NthElement(i)));
			}

		buttonList.Append(button);
		wmin = JMax(button->GetPreferredWidth(), wmin);
		}

	// all choices should be the same width

	for (i=1; i<=actionCount; i++)
		{
		(buttonList.NthElement(i))->SetSize(wmin, kTextHeight);
		}

	wmin += kRGHLMarginWidth + kRGHRMarginWidth;
	itsRG->AdjustSize(wmin - kInitRGWidth, 0);

	const JCoordinate wminInstr = instrText->GetFrameWidth();
	if (wmin < wminInstr)
		{
		const JCoordinate delta = (wminInstr - wmin)/2;
		itsRG->Move(delta, 0);
		wmin = wminInstr;
		}

	y = (itsRG->GetFrame()).bottom + kRGButtonVDelta;

	// OK and Cancel buttons

	wmin += 2*kHMarginWidth;
	const JCoordinate wminButton = 3*kMinButtonHMargin + 2*kButtonWidth;
	if (wmin < wminButton)
		{
		const JCoordinate delta = (wminButton - wmin)/2;
		instrText->Move(delta, 0);
		itsRG->Move(delta, 0);
		wmin = wminButton;
		}

	const JCoordinate buttonX = (wmin - 2*kButtonWidth)/3;

	JXTextButton* cancelButton =
		new JXTextButton("Cancel", window,
						 JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 buttonX,y, kButtonWidth,kTextHeight);
	assert( cancelButton != NULL );

	JXTextButton* okButton =
		new JXTextButton("OK", window,
						 JXWidget::kFixedLeft, JXWidget::kFixedTop,
						 wmin - buttonX - (kButtonWidth+2), y-1,
						 kButtonWidth+2, kTextHeight+2);
	assert( okButton != NULL );
	okButton->SetShortcuts("^M");

	SetButtons(okButton, cancelButton);

	// window size

	window->SetSize(wmin, y + kItemVSeparation);
}