示例#1
0
JBoolean
JXWidget::ScrollToRectCentered
	(
	const JRect&	origRect,
	const JBoolean	forceScroll
	)
{
	const JRect ap = GetAperture();
	if (!forceScroll && ap.Contains(origRect))
		{
		return kJFalse;
		}

	JRect r = origRect;
	const JCoordinate dw = ap.width() - r.width();
	if (dw > 0)
		{
		r.Shrink(-dw/2, 0);
		}

	const JCoordinate dh = ap.height() - r.height();
	if (dh > 0)
		{
		r.Shrink(0, -dh/2);
		}

	return ScrollToRect(r);
}
示例#2
0
void
JXWidget::FitToEnclosure
	(
	const JBoolean fitHoriz,
	const JBoolean fitVert
	)
{
	const JRect frame      = GetFrame();
	const JPoint oldPt     = frame.topLeft();
	const JRect enclBounds = (GetEnclosure())->GetBounds();

	JCoordinate dx=0, dy=0, dw=0, dh=0;
	if (fitHoriz)
		{
		dx = enclBounds.left - oldPt.x;
		dw = enclBounds.width() - frame.width();
		}
	if (fitVert)
		{
		dy = enclBounds.top - oldPt.y;
		dh = enclBounds.height() - frame.height();
		}

	Move(dx,dy);
	AdjustSize(dw,dh);
}
void
JXExprEditor::EIPBoundsChanged()
{
	const JRect newBounds = (GetRectList())->GetBoundsRect();
	const JRect apG       = GetApertureGlobal();
	const JCoordinate w   = JMax(newBounds.width(),  apG.width());
	const JCoordinate h   = JMax(newBounds.height(), apG.height());
	SetBounds(w,h);
}
void
TestWidget::Print
	(
	JPagePrinter& p
	)
{
	if (!p.OpenDocument())
		{
		return;
		}

	const JCoordinate headerHeight = p.JPainter::GetLineHeight();
	const JCoordinate footerHeight = JRound(1.5 * headerHeight);

	const JString dateStr = JGetTimeStamp();

	JBoolean cancelled = kJFalse;
	for (JIndex i=1; i<=3; i++)
		{
		if (!p.NewPage())
			{
			cancelled = kJTrue;
			break;
			}

		// draw the header

		JRect pageRect = p.GetPageRect();
		p.String(pageRect.left, pageRect.top, "testjx TestWidget");
		p.String(pageRect.left, pageRect.top, dateStr,
				 pageRect.width(), JPainter::kHAlignRight);
		p.LockHeader(headerHeight);

		// draw the footer

		pageRect = p.GetPageRect();
		const JString pageNumberStr = "Page " + JString(i);
		p.String(pageRect.left, pageRect.bottom - footerHeight, pageNumberStr,
				 pageRect.width(), JPainter::kHAlignCenter,
				 footerHeight, JPainter::kVAlignBottom);
		p.LockFooter(footerHeight);

		// draw the page

		DrawStuff(p);
		}

	if (!cancelled)
		{
		p.CloseDocument();
		}
}
void
JXStyleMenuTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	origRect
	)
{
	if (cell.x == kTextColumnIndex && cell.y >= JXStyleMenu::kFirstColorCmd)
		{
		JRect rect = AdjustRectForSeparator(cell.y, origRect);

		JRect colorRect = rect;
		colorRect.Shrink(0, kHilightBorderWidth);
		colorRect.right = colorRect.left + colorRect.height();

		const JBoolean origFill = p.IsFilling();
		p.SetFilling(kJTrue);
		p.SetPenColor(itsStyleMenu->IndexToColor(cell.y));
		p.Rect(colorRect);
		p.SetFilling(origFill);

		rect = origRect;
		rect.left += colorRect.width() + kHMarginWidth;
		JXTextMenuTable::TableDrawCell(p, cell, rect);
		}
	else
		{
		JXTextMenuTable::TableDrawCell(p, cell, origRect);
		}
}
void
JXTabGroup::PlaceCardFile()
{
	const JSize h = kSelMargin + kBorderWidth + 2*kTextMargin +
					(GetFontManager())->GetLineHeight(itsFontName, itsFontSize, itsFontStyle);

	JRect r = GetAperture();
	if (itsEdge == kTop)
		{
		r.top += h;
		}
	else if (itsEdge == kLeft)
		{
		r.left += h;
		}
	else if (itsEdge == kBottom)
		{
		r.bottom -= h;
		}
	else if (itsEdge == kRight)
		{
		r.right -= h;
		}
	else
		{
		assert( 0 );
		}

	r.Shrink(kBorderWidth, kBorderWidth);
	itsCardFile->Place(r.left, r.top);
	itsCardFile->SetSize(r.width(), r.height());
}
void
TestWidget::CreateImageBuffer()
{
	// clear itsImageBuffer so Draw() will work correctly

	jdelete itsImageBuffer;
	itsImageBuffer = NULL;

	// create image

	const JRect bounds = GetBounds();
	JXImage* imageBuffer =
		jnew JXImage(GetDisplay(), bounds.width(), bounds.height());
	assert( imageBuffer != NULL );
	imageBuffer->SetDefaultState(JXImage::kRemoteStorage);

	// draw to image

	JXImagePainter* p = imageBuffer->CreatePainter();
	Draw(*p, GetBounds());
	jdelete p;

	// save object

	itsImageBuffer = imageBuffer;
}
void
JXGetStringDialog::BuildWindow
	(
	const JCharacter*	windowTitle,
	const JCharacter*	prompt,
	const JCharacter*	initialValue,
	const JBoolean		password
	)
{
// begin JXLayout

    JXWindow* window = new JXWindow(this, 310,110, "");
    assert( window != NULL );

    JXTextButton* okButton =
        new JXTextButton(JGetString("okButton::JXGetStringDialog::JXLayout"), window,
                    JXWidget::kFixedRight, JXWidget::kFixedBottom, 190,80, 60,20);
    assert( okButton != NULL );
    okButton->SetShortcuts(JGetString("okButton::JXGetStringDialog::shortcuts::JXLayout"));

    JXTextButton* cancelButton =
        new JXTextButton(JGetString("cancelButton::JXGetStringDialog::JXLayout"), window,
                    JXWidget::kFixedLeft, JXWidget::kFixedBottom, 60,80, 60,20);
    assert( cancelButton != NULL );
    cancelButton->SetShortcuts(JGetString("cancelButton::JXGetStringDialog::shortcuts::JXLayout"));

    itsInputField =
        new JXInputField(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 20,40, 270,20);
    assert( itsInputField != NULL );

    JXStaticText* promptDisplay =
        new JXStaticText(JGetString("promptDisplay::JXGetStringDialog::JXLayout"), window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 20,20, 270,20);
    assert( promptDisplay != NULL );
    promptDisplay->SetToLabel();

// end JXLayout

	window->SetTitle(windowTitle);
	SetButtons(okButton, cancelButton);

	promptDisplay->SetText(prompt);

	if (password)
		{
		const JRect r = itsInputField->GetFrame();
		delete itsInputField;
		itsInputField =
			new JXPasswordInput(window,
				JXWidget::kHElastic, JXWidget::kFixedTop,
				r.left, r.top, r.width(), r.height());
		assert( itsInputField != NULL );
		}
	else if (!JStringEmpty(initialValue))
		{
		itsInputField->SetText(initialValue);
		}
	itsInputField->SetIsRequired();
}
void
JXColorWheel::SetColor
	(
	const JPoint& pt
	)
{
	if (itsImage == NULL)
		{
		Redraw();
		}

	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;

	const JCoordinate dx = - pt.x + center;
	const JCoordinate dy = pt.y - center;

	const JFloat r = JMin(sqrt(dx*dx + dy*dy) / center, 1.0);
	const JFloat a = 0.5 + atan2(dy, dx) / (2.0 * kJPi);

	const JSize b = JRound(itsBrightnessSlider->GetValue());
	SetColor(JHSB(JRound(a * kJMaxHSBValue), JRound(r * kJMaxHSBValue), b));
}
示例#10
0
JBoolean
JXEditTable::CreateInputField
	(
	const JPoint&	cell,
	const JRect&	cellRect
	)
{
	itsInputField = CreateXInputField(cell, cellRect.left, cellRect.top,
									  cellRect.width(), cellRect.height());
	assert( itsInputField != NULL );
	itsInputField->SetTable(this);
	itsInputField->SetFocusColor(GetFocusColor());

	if (itsEditMenuHandler != NULL && itsEditMenuHandler->HasEditMenu())
		{
		itsInputField->ShareEditMenu(itsEditMenuHandler, kJFalse, kJFalse);
		}

	if (itsInputField->Focus())
		{
		return kJTrue;
		}
	else
		{
		DeleteInputField();
		return kJFalse;
		}
}
void
ResizeWidgetDialog::BuildWindow
	(
	const JXWidget* widget
	)
{
// begin JXLayout

	JXWindow* window = new JXWindow(this, 160,120, "");
	assert( window != NULL );

	JXTextButton* cancelButton =
		new JXTextButton(JGetString("cancelButton::ResizeWidgetDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 20,90, 50,20);
	assert( cancelButton != NULL );

	JXTextButton* okButton =
		new JXTextButton(JGetString("okButton::ResizeWidgetDialog::JXLayout"), window,
					JXWidget::kFixedRight, JXWidget::kFixedTop, 90,90, 50,20);
	assert( okButton != NULL );
	okButton->SetShortcuts(JGetString("okButton::ResizeWidgetDialog::shortcuts::JXLayout"));

	itsWidth =
		new JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 70,20, 70,20);
	assert( itsWidth != NULL );

	itsHeight =
		new JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 70,50, 70,20);
	assert( itsHeight != NULL );

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

	JXStaticText* obj2_JXLayout =
		new JXStaticText(JGetString("obj2_JXLayout::ResizeWidgetDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,50, 50,20);
	assert( obj2_JXLayout != NULL );
	obj2_JXLayout->SetToLabel();

// end JXLayout

	window->SetTitle("Change widget size");
	SetButtons(okButton, cancelButton);

	const JRect r = widget->GetBoundsGlobal();

	itsWidth->SetLowerLimit(50);
	itsWidth->SetUpperLimit(2000);
	itsWidth->SetValue(r.width());

	itsHeight->SetLowerLimit(50);
	itsHeight->SetUpperLimit(2000);
	itsHeight->SetValue(r.height());
}
示例#12
0
void
JXWidget::SetBorderWidth
	(
	const JSize width
	)
{
	if (width != itsBorderWidth)
		{
		const JRect origApG = GetApertureGlobal();
		itsBorderWidth = width;
		const JRect newApG = GetApertureGlobal();

		ApertureMoved(newApG.left - origApG.left, newApG.top - origApG.top);
		ApertureResized(newApG.width()  - origApG.width(),
						newApG.height() - origApG.height());
		}
}
示例#13
0
JXImage::JXImage
	(
	JXDisplay*		display,
	Drawable		source,
	const JRect&	rect
	)
	:
	JImage(rect.width(), rect.height(), display->GetColormap())
{
	JXImageFromDrawable(display, source, rect);
}
示例#14
0
JXImage::JXImage
	(
	JXDisplay*		display,
	JXColormap*		colormap,
	Drawable		source,
	const JRect&	rect
	)
	:
	JImage(rect.width(), rect.height(), colormap)
{
	JXImageFromDrawable(display, colormap, source, rect);
}
void
JXTextCheckbox::Draw
	(
	JXWindowPainter&	p,
	const JRect&		rect
	)
{
	const JRect bounds  = GetBounds();
	const JCoordinate y = bounds.ycenter();

	// draw button

	const JRect boxRect(y - kBoxHalfHeight, kMarginWidth,
						y + kBoxHalfHeight, kMarginWidth + kBoxHeight);
	const JBoolean drawChecked = DrawChecked();
	const JBoolean isActive    = IsActive();
	if (drawChecked && isActive)
		{
		JXDrawDownFrame(p, boxRect, kJXDefaultBorderWidth, kJTrue, itsPushedColor);
		}
	else if (isActive)
		{
		JXDrawUpFrame(p, boxRect, kJXDefaultBorderWidth, kJTrue, itsNormalColor);
		}
	else
		{
		p.SetFilling(kJTrue);
		if (drawChecked)
			{
			p.SetPenColor(itsPushedColor);
			}
		else
			{
			p.SetPenColor(itsNormalColor);
			}
		p.JPainter::Rect(boxRect);
		p.SetFilling(kJFalse);

		p.SetLineWidth(kJXDefaultBorderWidth);
		p.SetPenColor((GetColormap())->GetInactiveLabelColor());
		p.RectInside(boxRect);
		}

	// draw text

	JRect textRect  = bounds;
	textRect.left  += 2*kMarginWidth + kBoxHeight;
	p.SetFont(itsFontName, itsFontSize, itsFontStyle);
	p.String(textRect.left, textRect.top, itsLabel, itsULIndex,
			 textRect.width(), JPainter::kHAlignLeft,
			 textRect.height(), JPainter::kVAlignCenter);
}
void
TestFloatTable::DrawPrintHeader
	(
	JPagePrinter&		p,
	const JCoordinate	headerHeight
	)
{
	JRect pageRect = p.GetPageRect();
	p.String(pageRect.left, pageRect.top, "testjx NumberTable");
	const JString dateStr = JGetTimeStamp();
	p.String(pageRect.left, pageRect.top, dateStr,
			 pageRect.width(), JPainter::kHAlignRight);
}
void
TestFloatTable::DrawPrintFooter
	(
	JPagePrinter&		p,
	const JCoordinate	footerHeight
	)
{
	JRect pageRect = p.GetPageRect();
	const JString pageNumberStr = "Page " + JString(p.GetPageIndex());
	p.String(pageRect.left, pageRect.bottom - footerHeight, pageNumberStr,
			 pageRect.width(), JPainter::kHAlignCenter,
			 footerHeight, JPainter::kVAlignBottom);
}
void
CMArray2DTable::DrawPrintHeader
	(
	JPagePrinter&		p,
	const JCoordinate	headerHeight
	)
{
	JRect pageRect = p.GetPageRect();
	p.String(pageRect.left, pageRect.top, itsArrayDir->GetExpression());

	const JString dateStr = JGetTimeStamp();
	p.String(pageRect.left, pageRect.top, dateStr,
			 pageRect.width(), JPainter::kHAlignRight);
}
void
CBSearchDocument::PlaceCmdLineWidgets()
{
	CBExecOutputDocument::PlaceCmdLineWidgets();

	JXWindow* window = GetWindow();

	JXWidget::HSizingOption hSizing;
	JXWidget::VSizingOption vSizing;
	const JRect frame = GetFileDisplayInfo(&hSizing, &vSizing);

	itsIndicator->Place(frame.left, frame.ycenter() - kIndicatorHeight/2);
	itsIndicator->SetSize(frame.width(), kIndicatorHeight);
}
void
JXImageWidget::AdjustBounds()
{
	if (itsAdjustBoundsTask != NULL)
		{
		return;
		}

	JRect newBounds = GetAperture();
	if (itsImage != NULL)
		{
		newBounds = JCovering(newBounds, itsImage->GetBounds());
		}

	SetBounds(newBounds.width(), newBounds.height());
}
void
JXMesaCamera::UpdateViewport()
{
	if (PrepareMesa())
		{
		const JRect bG       = itsWidget->GetBoundsGlobal();
		itsGLViewport.x      = bG.left;
		itsGLViewport.y      = (itsWidget->GetWindow())->GetBoundsHeight() - bG.bottom;
		itsGLViewport.width  = bG.width();
		itsGLViewport.height = bG.height();

		glViewport(itsGLViewport.x,itsGLViewport.y,
				   itsGLViewport.width,itsGLViewport.height);
		glScissor(itsGLViewport.x,itsGLViewport.y,
				  itsGLViewport.width,itsGLViewport.height);
		}
}
示例#22
0
JXImage::JXImage
	(
	const JXImage&	source,
	const JRect&	rect
	)
	:
	JImage(rect.width(), rect.height(), source.GetColormap())
{
	JXImageX(source.itsDisplay, source.itsColormap, source.itsDepth);
	itsDefState = source.itsDefState;

	if (source.itsGC != NULL)
		{
		ForcePrivateGC();
		}

	Pixmap sourcePixmap;
	if (source.itsPixmap != None)
		{
		sourcePixmap = source.itsPixmap;
		}
	else
		{
		sourcePixmap = source.CreatePixmap();
		}

	itsPixmap = XCreatePixmap(*itsDisplay, itsDisplay->GetRootWindow(),
							  GetWidth(), GetHeight(), itsDepth);
	assert( itsPixmap != None );

	(GetGC())->CopyPixels(sourcePixmap, rect.left, rect.top,
						  GetWidth(), GetHeight(), itsPixmap, 0,0);

	if (source.itsPixmap == None)
		{
		XFreePixmap(*itsDisplay, sourcePixmap);
		}

	if (source.itsMask != NULL)
		{
		itsMask = new JXImageMask(*(source.itsMask), rect);
		assert( itsMask != NULL );
		}

	CopyColorList(source);
}
void
JConjugate::Render
	(
	const JExprRenderer& renderer,
	const JExprRectList& rectList
	)
	const
{
	// find ourselves in the list

	JIndex ourIndex;
	const JBoolean found = rectList.FindFunction(this, &ourIndex);
	assert( found );

	const JRect ourRect = rectList.GetRect(ourIndex);

	// draw ourselves

	renderer.DrawHorizBar(ourRect.left, ourRect.top, ourRect.width());
	GetArg()->Render(renderer, rectList);
}
示例#24
0
void
JXImage::JXImageFromDrawable
	(
	JXDisplay*		display,
	Drawable		source,
	const JRect&	origRect
	)
{
	JXImageX(display);

	JRect rect = origRect;
	{
	Window rootWindow;
	int x,y;
	unsigned int w,h, bw, depth;
	XGetGeometry(*itsDisplay, source, &rootWindow, &x, &y, &w, &h, &bw, &depth);

	itsDepth = depth;
	if (rect.IsEmpty())
		{
		SetDimensions(w,h);
		rect = GetBounds();
		}
	}

	itsPixmap = XCreatePixmap(*itsDisplay, itsDisplay->GetRootWindow(),
							  GetWidth(), GetHeight(), itsDepth);
	assert( itsPixmap != None );

	if (itsDepth != itsDisplay->GetDepth())
		{
		itsGC = new JXGC(itsDisplay, itsPixmap);
		assert( itsGC != NULL );
		}

	(GetGC())->CopyPixels(source, rect.left, rect.top,
						  rect.width(), rect.height(), itsPixmap, 0,0);
}
示例#25
0
void
JXWidget::CenterWithinEnclosure
	(
	const JBoolean adjustHoriz,
	const JBoolean adjustVert
	)
{
	const JRect frame      = GetFrame();
	const JPoint oldPt     = frame.topLeft();
	const JRect enclBounds = (GetEnclosure())->GetBounds();

	JCoordinate dx=0, dy=0;
	if (adjustHoriz)
		{
		dx = (enclBounds.xcenter() - frame.width()/2) - oldPt.x;
		}
	if (adjustVert)
		{
		dy = (enclBounds.ycenter() - frame.height()/2) - oldPt.y;
		}

	Move(dx,dy);
}
void
CBExecOutputDocument::PlaceCmdLineWidgets()
{
	JXWindow* window = GetWindow();

	JXWidget::HSizingOption hSizing;
	JXWidget::VSizingOption vSizing;
	const JRect fileRect = GetFileDisplayInfo(&hSizing, &vSizing);

	itsCmdPrompt->Place(fileRect.left, fileRect.top);
	itsCmdPrompt->AdjustSize(0, fileRect.height() - itsCmdPrompt->GetFrameHeight());

	const JCoordinate promptWidth = itsCmdPrompt->GetFrameWidth();

	const JCoordinate eofWidth =
		itsEOFButton->GetFont().GetStringWidth(itsEOFButton->GetLabel()) +
		2 * itsEOFButton->GetPadding().x +
		2 * itsEOFButton->GetBorderWidth();

	itsCmdInput->Place(fileRect.left + promptWidth, fileRect.top);

	JCoordinate cmdInputWidth = fileRect.width() - promptWidth - eofWidth;
	if (cmdInputWidth < kMinCmdInputWidth)
		{
		window->AdjustSize(kMinCmdInputWidth - cmdInputWidth, 0);
		cmdInputWidth = kMinCmdInputWidth;
		}
	itsCmdInput->SetSize(cmdInputWidth, fileRect.height());

	const JPoint p = window->GetMinSize();
	window->SetMinSize(window->GetFrameWidth() - (cmdInputWidth - kMinCmdInputWidth), p.y);

	itsEOFButton->Place(fileRect.right - eofWidth, fileRect.top);
	itsEOFButton->SetSize(eofWidth, fileRect.height());

	UpdateButtons();
}
void
JXRowHeaderWidget::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	JXDrawUpFrame(p, rect, kCellFrameWidth);

	JString str;
	JBoolean hasTitle = kJFalse;
	if (itsTitles != NULL)
		{
		const JString* title = itsTitles->NthElement(cell.y);
		if (title != NULL)
			{
			str      = *title;
			hasTitle = kJTrue;
			}
		}
	if (!hasTitle)
		{
		str = JString(cell.y, JString::kBase10);
		}

	p.SetFont(JGetDefaultFontName(), kJDefaultRowColHeaderFontSize,
			  JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor()));
	p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);

	const JCoordinate wmin = p.GetStringWidth(str) + 2*itsHMarginWidth;
	if (rect.width() < wmin && itsMaxBcastWidth < wmin)
		{
		Broadcast(NeedsToBeWidened(wmin - itsMaxBcastWidth));
		itsMaxBcastWidth = wmin;
		}
}
void
THXKeyPad::CreateButtons()
{
// begin kpLayout

	const JRect kpLayout_Frame    = this->GetFrame();
	const JRect kpLayout_Aperture = this->GetAperture();
	this->AdjustSize(60 - kpLayout_Aperture.width(), 160 - kpLayout_Aperture.height());

	itsDigitButton[7] =
		new JXTextButton(JGetString("itsDigitButton[7]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,0, 20,20);
	assert( itsDigitButton[7] != NULL );

	itsDigitButton[8] =
		new JXTextButton(JGetString("itsDigitButton[8]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,0, 20,20);
	assert( itsDigitButton[8] != NULL );

	itsDigitButton[9] =
		new JXTextButton(JGetString("itsDigitButton[9]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,0, 20,20);
	assert( itsDigitButton[9] != NULL );

	itsDigitButton[4] =
		new JXTextButton(JGetString("itsDigitButton[4]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,20, 20,20);
	assert( itsDigitButton[4] != NULL );

	itsDigitButton[5] =
		new JXTextButton(JGetString("itsDigitButton[5]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 20,20);
	assert( itsDigitButton[5] != NULL );

	itsDigitButton[6] =
		new JXTextButton(JGetString("itsDigitButton[6]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,20, 20,20);
	assert( itsDigitButton[6] != NULL );

	itsDigitButton[1] =
		new JXTextButton(JGetString("itsDigitButton[1]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,40, 20,20);
	assert( itsDigitButton[1] != NULL );

	itsDigitButton[2] =
		new JXTextButton(JGetString("itsDigitButton[2]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,40, 20,20);
	assert( itsDigitButton[2] != NULL );

	itsDigitButton[3] =
		new JXTextButton(JGetString("itsDigitButton[3]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,40, 20,20);
	assert( itsDigitButton[3] != NULL );

	itsDigitButton[0] =
		new JXTextButton(JGetString("itsDigitButton[0]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,60, 20,20);
	assert( itsDigitButton[0] != NULL );

	itsOpButton[kPtOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kPtOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,60, 20,20);
	assert( itsOpButton[kPtOpIndex] != NULL );

	itsOpButton[kExpOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kExpOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,60, 20,20);
	assert( itsOpButton[kExpOpIndex] != NULL );

	itsClearAllButton =
		new JXTextButton(JGetString("itsClearAllButton::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,140, 60,20);
	assert( itsClearAllButton != NULL );

	itsOpButton[kClearOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kClearOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,120, 60,20);
	assert( itsOpButton[kClearOpIndex] != NULL );

	itsOpButton[kEvalOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kEvalOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 40,80, 20,40);
	assert( itsOpButton[kEvalOpIndex] != NULL );

	itsOpButton[kMultiplyOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kMultiplyOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,100, 20,20);
	assert( itsOpButton[kMultiplyOpIndex] != NULL );

	itsOpButton[kDivideOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kDivideOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,100, 20,20);
	assert( itsOpButton[kDivideOpIndex] != NULL );

	itsOpButton[kAddOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kAddOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 0,80, 20,20);
	assert( itsOpButton[kAddOpIndex] != NULL );

	itsOpButton[kSubtractOpIndex] =
		new JXTextButton(JGetString("itsOpButton[kSubtractOpIndex]::THXKeyPad::kpLayout"), this,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,80, 20,20);
	assert( itsOpButton[kSubtractOpIndex] != NULL );

	this->SetSize(kpLayout_Frame.width(), kpLayout_Frame.height());

// end kpLayout

	itsOpButton[kMultiplyOpIndex]->SetLabel("\xD7");
	itsOpButton[kDivideOpIndex]->SetLabel("\xF7");

JIndex i;

	for (i=0; i<10; i++)
		{
		ListenTo(itsDigitButton[i]);
		}

	for (i=0; i<kOpCount; i++)
		{
		ListenTo(itsOpButton[i]);
		}

	ListenTo(itsClearAllButton);
}
示例#29
0
JBoolean
JXWidget::Scroll
	(
	const JCoordinate userdx,
	const JCoordinate userdy
	)
{
	assert( !itsApertureBoundedFlag );

	if (userdx != 0 || userdy != 0)
		{
		const JRect apG = GetApertureGlobal();

		JCoordinate dx = userdx;
		if (itsBoundsG.width() <= apG.width())
			{
			dx = 0;
			}
		else if (dx > 0 && itsBoundsG.left + dx > apG.left)
			{
			dx = apG.left - itsBoundsG.left;
			}
		else if (dx < 0 && itsBoundsG.right + dx < apG.right)
			{
			dx = apG.right - itsBoundsG.right;
			}

		JCoordinate dy = userdy;
		if (itsBoundsG.height() <= apG.height())
			{
			dy = 0;
			}
		else if (dy > 0 && itsBoundsG.top + dy > apG.top)
			{
			dy = apG.top - itsBoundsG.top;
			}
		else if (dy < 0 && itsBoundsG.bottom + dy < apG.bottom)
			{
			dy = apG.bottom - itsBoundsG.bottom;
			}

		if (dx != 0 || dy != 0)
			{
//			const JRect origAp = GetAperture();

			itsBoundsG.Shift(dx,dy);
			NotifyBoundsMoved(dx,dy);

//			const JRect newAp = GetAperture();
//			JRect dest;
//			if (JIntersection(origAp, newAp, &dest))
//				{
//				dest      = JXContainer::LocalToGlobal(dest);
//				JRect src = dest;
//				src.Shift(-dx, -dy);
//				(GetWindow())->UpdateForScroll(JXContainer::LocalToGlobal(newAp), src, dest);
//				}
//			else
//				{
				Refresh();
//				}

			return kJTrue;
			}
		}

	return kJFalse;
}
void
JXMenuDirector::BuildWindow
	(
	const JPoint&		leftPtR,
	const JPoint&		rightPtR,
	const JCoordinate	sourceHeight
	)
{
	(GetDisplay())->ShrinkDisplayBoundsToActiveScreen();

	itsMenuTable = CreateMenuTable();
	itsMenuTable->FitToEnclosure();
	itsMenuTable->SetSingleFocusWidget();

	const JCoordinate bw = itsMenuTable->GetBorderWidth();
	const JRect bounds   = itsMenuTable->GetBoundsGlobal();
	const JCoordinate w  = bounds.width()  + 2*bw;
	const JCoordinate h  = bounds.height() + 2*bw;

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

	JCoordinate windowX, windowWidth = w;
	JPoint usedPtR = rightPtR;
	if (rightPtR.x + w <= rootBounds.right)
		{
		windowX = rightPtR.x;
		}
	else if (leftPtR.x - w >= rootBounds.left)
		{
		windowX = leftPtR.x - w;
		usedPtR = leftPtR;
		}
	else
		{
		windowX = rootBounds.right - w;
		}

	if (windowX + w > rootBounds.right)
		{
		windowX = rootBounds.right - w;
		}
	if (windowX < rootBounds.left)
		{
		windowX = rootBounds.left;
		if (windowX + w > rootBounds.right)
			{
			windowWidth = rootBounds.width();
			}
		}

	JCoordinate windowY, windowHeight = h;
	JBoolean scrollBottom = kJFalse;
	if (usedPtR.y + h <= rootBounds.bottom)
		{
		windowY = usedPtR.y;
		}
	else if (sourceHeight > 0 && rootBounds.top <= usedPtR.y - sourceHeight - h)
		{
		windowY = usedPtR.y - sourceHeight - h;
		}
	else if (sourceHeight > 0 &&
			 rootBounds.bottom - usedPtR.y > usedPtR.y - sourceHeight - rootBounds.top)
		{
		windowY      = usedPtR.y;
		windowHeight = rootBounds.bottom - usedPtR.y;
		}
	else if (sourceHeight > 0)
		{
		windowY      = rootBounds.top;
		windowHeight = usedPtR.y - sourceHeight - rootBounds.top;
		scrollBottom = kJTrue;
		}
	else
		{
		windowY = rootBounds.bottom - h;
		if (windowY < rootBounds.top)
			{
			windowY      = rootBounds.top;
			windowHeight = rootBounds.height();
			}
		}

	JXWindow* window = GetWindow();
	window->Place(windowX, windowY);
	window->SetSize(windowWidth, windowHeight);

	// if menu will scroll, might as well start at the bottom

	if (scrollBottom)
		{
		itsMenuTable->TableScrollToCell(JPoint(1, itsMenuTable->GetRowCount()));
		}

	(GetDisplay())->RestoreDisplayBounds();
}