Пример #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);
}
Пример #4
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;
		}
}
Пример #5
0
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();
}
Пример #7
0
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
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));
}
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
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());
}
Пример #11
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());
		}
}
Пример #12
0
void
JSummation::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);
	const JCoordinate ourMidline = rectList.GetMidline(ourIndex);
	const JSize fontSize         = rectList.GetFontSize(ourIndex);

	// draw ourselves

	JCoordinate h          = ourRect.left;
	const JSize spaceWidth = renderer.GetStringWidth(fontSize, " ");

	const JSize argCount = GetArgCount();
	for (JIndex i=1; i<=argCount; i++)
		{
		const JFunction* f   = this;
		const JFunction* arg = GetArg(i);
		if (arg->GetType() == kJNegationType)
			{
			renderer.DrawString(h, ourMidline, fontSize, JPGetSubtractionString());
			f = arg;
			const JNegation* neg = dynamic_cast<const JNegation*>(arg);
			assert( neg != NULL );
			arg = neg->GetArg();
			}
		else if (i > 1)
			{
			renderer.DrawString(h, ourMidline, fontSize, JPGetAdditionString());
			}

		arg->Render(renderer, rectList);

		JIndex argIndex;
		const JBoolean found = rectList.FindFunction(arg, &argIndex);
		assert( found );
		const JRect argRect = rectList.GetRect(argIndex);
		h = argRect.right;

		if (ParenthesizeArgForRender(*f, *arg))
			{
			renderer.DrawParentheses(argRect);
			h += renderer.GetParenthesisWidth(argRect.height());
			}

		h += spaceWidth;
		}
}
Пример #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
JAbsValue::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.DrawVertBar(ourRect.left, ourRect.top, ourRect.height());
	(GetArg())->Render(renderer, rectList);
	renderer.DrawVertBar(ourRect.right - renderer.GetVertBarWidth(),
						 ourRect.top, ourRect.height());
}
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();
}
JXTextMenu*
JXMenuBar::InsertTextMenu
	(
	const JIndex		index,
	const JCharacter*	title
	)
{
	const JRect bounds = GetBounds();
	JXTextMenu* theMenu = new JXTextMenu(title, this, kFixedLeft, kVElastic,
										 bounds.left,bounds.top, 10,bounds.height());
	assert( theMenu != NULL );

	InsertMenu(index, theMenu);
	return theMenu;
}
void
JXImageWidget::AdjustBounds()
{
	if (itsAdjustBoundsTask != NULL)
		{
		return;
		}

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

	SetBounds(newBounds.width(), newBounds.height());
}
void
CMLineIndexTable::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	HilightIfSelected(p, cell, rect);

	if (JIndex(cell.x) == kBreakpointColumn)
		{
		DrawBreakpoints(p, cell, rect);
		}

	else if (JIndex(cell.x) == kExecPointColumn && cell.y == itsCurrentLineIndex)
		{
		// We can't use a static polygon because line heights can vary,
		// e.g. due to underlines.

		const JCoordinate delta = rect.height()/2;

		JPolygon poly;
		poly.AppendElement(JPoint(rect.left+kMarginWidth,       rect.top));
		poly.AppendElement(JPoint(rect.left+kMarginWidth+delta, rect.top + delta));
		poly.AppendElement(JPoint(rect.left+kMarginWidth,       rect.top + 2*delta));

		p.SetPenColor(GetCurrentLineMarkerColor());
		p.SetFilling(kJTrue);
		p.Polygon(poly);

		p.SetPenColor(GetColormap()->GetBlackColor());
		p.SetFilling(kJFalse);
		p.Polygon(poly);
		}

	else if (JIndex(cell.x) == kLineNumberColumn)
		{
		p.SetFont(itsText->GetDefaultFont());

		JRect r  = rect;
		r.right -= kMarginWidth;

		const JString str = GetLineText(cell.y);
		p.String(r, str, JPainter::kHAlignRight);
		}
}
Пример #21
0
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);
}
JXTextMenu*
JXMenuBar::InsertTextMenu
	(
	const JIndex	index,
	JXImage*		image,
	const JBoolean	menuOwnsImage
	)
{
	const JRect bounds = GetBounds();
	JXTextMenu* theMenu =
		new JXTextMenu(image, menuOwnsImage, this, kFixedLeft, kVElastic,
					   bounds.left,bounds.top, 10,bounds.height());
	assert( theMenu != NULL );

	InsertMenu(index, theMenu);
	return theMenu;
}
void
JXMenuBar::InsertMenu
	(
	const JIndex	index,
	JXMenu*			theMenu
	)
{
	assert( theMenu != NULL );

	ClearOverflowMenu();

	JIndex origIndex;
	if (itsMenus->Find(theMenu, &origIndex))
		{
		if (origIndex == index)
			{
			WidthChanged();
			return;
			}
		RemoveMenu(origIndex);
		}

	theMenu->SetSizing(kFixedLeft, kVElastic);

	const JRect bounds = GetBounds();
	JCoordinate left   = bounds.left;
	for (JIndex i=1; i<index; i++)
		{
		JXMenu* aMenu = itsMenus->NthElement(i);
		left += aMenu->GetFrameWidth();
		}

	itsMenus->InsertAtIndex(index, theMenu);

	theMenu->Place(left, bounds.top);
	theMenu->AdjustSize(0, bounds.height() - theMenu->GetFrameHeight());
	MenuWidthChanged(index, theMenu->GetFrameWidth());

	theMenu->SetMenuBar(this);
	theMenu->Show();

	WidthChanged();
}
void
CMLineIndexTable::DrawBreakpoints
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	// check for breakpoint(s) on this line

	JBoolean hasMultiple;
	if (!FindNextBreakpoint(cell.y, &hasMultiple))
		{
		return;
		}

	// draw breakpoint(s)

	JRect r = rect;
	r.Shrink(kMarginWidth, kMarginWidth);

	if (hasMultiple)
		{
		if (r.height() < 9)		// to allow concentric circles to be distinguished
			{
			r.top    = rect.ycenter() - 4;
			r.bottom = r.top + 9;
			r.left   = rect.xcenter() - 4;
			r.right  = r.left + 9;
			}

		p.Ellipse(r);
		r.Shrink(3, 3);
		p.Ellipse(r);
		}
	else
		{
		DrawBreakpoint(itsBPList->NthElement(itsBPDrawIndex), p, GetColormap(), r);
		}
}
Пример #26
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);
}
Пример #27
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);
}
Пример #28
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;
}
Пример #29
0
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);
}
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();
}