本文整理汇总了C++中JRect类的典型用法代码示例。如果您正苦于以下问题:C++ JRect类的具体用法?C++ JRect怎么用?C++ JRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AdjustRectForSeparator
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);
}
}
示例2: HilightIfSelected
void
JXFSBindingTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JPoint editCell;
if (GetEditedCell(&editCell) && cell == editCell)
{
return;
}
HilightIfSelected(p, cell, rect);
const JFSBinding* b = itsBindingList->GetBinding(cell.y);
JFSBinding::CommandType type;
JBoolean singleFile;
const JString& cmd = b->GetCommand(&type, &singleFile);
if (cell.x == kPatternColumn)
{
p.SetFont(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle());
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, b->GetPattern(), JPainter::kHAlignLeft, JPainter::kVAlignCenter);
p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle());
}
else if (cell.x == kCommandColumn)
{
p.SetFont(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle());
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, cmd, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle());
}
else if (cell.x == kTypeColumn)
{
const JString& str = itsTypeMenu->GetItemText(kCmdTypeToMenuIndex[type]);
p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
else if (cell.x == kSingleFileColumn && singleFile)
{
JRect r;
r.top = rect.ycenter();
r.left = rect.xcenter();
r.bottom = r.top+1;
r.right = r.left+1;
r.Expand(3, 3);
p.SetFilling(kJTrue);
p.Ellipse(r);
p.SetFilling(kJFalse);
}
}
示例3: Redraw
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));
}
示例4: GetBounds
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;
}
示例5: GetCellRect
void
CBCommandTable::HandleDNDHere
(
const JPoint& pt,
const JXWidget* source
)
{
JIndex newRowIndex = itsDNDRowIndex;
JPoint cell;
if (GetCell(JPinInRect(pt, GetBounds()), &cell))
{
const JRect r = GetCellRect(cell);
if (pt.y <= r.ycenter())
{
newRowIndex = cell.y;
}
else
{
newRowIndex = cell.y + 1;
}
}
if (newRowIndex != itsDNDRowIndex)
{
itsDNDRowIndex = newRowIndex;
Refresh();
}
}
示例6: GetBounds
void
JXSearchTextButton::Draw
(
JXWindowPainter& p,
const JRect& rect
)
{
const JRect bounds = GetBounds();
JRect r;
r.top = bounds.ycenter() - kArrowHalfHeight;
r.bottom = r.top + 2*kArrowHalfHeight + 1;
r.left = bounds.xcenter() - kArrowHalfWidth;
r.right = r.left + 2*kArrowHalfWidth;
const JColorIndex colorIndex =
IsActive() ? (p.GetColormap())->GetGrayColor(40) :
(p.GetColormap())->GetInactiveLabelColor();
if (itsFwdFlag)
{
r.right++;
JXFillArrowRight(p, r, colorIndex);
}
else
{
r.left--;
JXFillArrowLeft(p, r, colorIndex);
}
}
示例7: GetAperture
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());
}
示例8: getIExtent
void JBtnObj::update(JGraphics g, double dx, double dy, JRegion& rgn, double scale) {
JRect rect = getIExtent(dx, dy, scale), thumb;
JRegion frgn(rect.shrinkBy(depth, depth));
if ((rect.width > 0) && (rect.height > 0)) {
g.setJColor(bkgnd);
g.fillJRect(rect);
thumb = rect.shrink(depth, depth);
if ((thumb.width > 0) && (thumb.height > 0)) {
switch (type) {
case TYPE_RECT:
g.draw3DJRect(thumb, ((value) ? -depth : depth));
break;
case TYPE_LEFT:
case TYPE_RIGHT:
case TYPE_UP:
case TYPE_DOWN:
g.draw3DJTriangle(thumb,
((value) ? -depth : depth), type-1);
break;
}
if (label.length()) {
g.setJColor(color);
drawText(g, label, thumb.shrink(depth, depth));
}
}
}
}
示例9: PrepareToRender
JIndex
JNamedConstant::PrepareToRender
(
const JExprRenderer& renderer,
const JPoint& upperLeft,
const JSize fontSize,
JExprRectList* rectList
)
{
if (strcmp(JPGetStdNamedConstName(itsNameIndex), JPGetPiString()) == 0)
{
JRect ourRect;
ourRect.top = upperLeft.y;
ourRect.left = upperLeft.x;
ourRect.bottom = upperLeft.y + renderer.GetLineHeight(fontSize);
ourRect.right = upperLeft.x + renderer.GetGreekCharWidth(fontSize, kGreekPiChar);
const JCoordinate ourMidline = ourRect.ycenter();
return rectList->AddRect(ourRect, ourMidline, fontSize, this);
}
else
{
return JFunction::PrepareToRender(renderer, upperLeft, fontSize, rectList);
}
}
示例10: GetApertureWidth
void
JXTextMenuTable::Draw
(
JXWindowPainter& p,
const JRect& rect
)
{
JXMenuTable::Draw(p, rect);
const JCoordinate w = GetApertureWidth();
const JSize rowCount = GetRowCount();
for (JIndex i=1; i<rowCount; i++) // ignore separator after last item
{
if (itsTextMenuData->HasSeparator(i))
{
JRect r = GetCellRect(JPoint(1,i));
r.top = r.bottom - kSeparatorHeight;
r.right = r.left + w;
// JXDrawDownFrame(p, r, kSeparatorHeight/2);
r.top = r.ycenter() - 1;
r.bottom = r.top + 2;
JXDrawDownFrame(p, r, 1);
}
}
if (itsHilightRow != 0)
{
const JRect r = GetCellRect(JPoint(1, itsHilightRow));
JRect r1 = AdjustRectForSeparator(itsHilightRow, r);
r1.right = r1.left + w;
JXDrawUpFrame(p, r1, kHilightBorderWidth);
}
}
示例11: GetDragPainter
void
JXRowHeaderWidget::HandleMouseDrag
(
const JPoint& origPt,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
JPoint pt = origPt;
// keep col width larger than minimum
if (pt.y < itsDragCellRect.top + itsMinRowHeight)
{
pt.y = itsDragCellRect.top + itsMinRowHeight;
}
// check if we have moved
if (pt.y != itsPrevPt.y)
{
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
const JRect enclApG = (GetEnclosure())->GetApertureGlobal();
JRect enclAp = JXContainer::GlobalToLocal(enclApG);
// scroll, if necessary
const JPoint ptG = JXContainer::LocalToGlobal(pt);
const JPoint ptT = JPinInRect(itsTable->JXContainer::GlobalToLocal(ptG),
itsTable->GetBounds());
const JRect tableAp = itsTable->GetAperture();
const JCoordinate x = tableAp.xcenter();
const JRect tableRect(ptT.y-1, x-1, ptT.y+1, x+1);
if (itsTable->ScrollToRect(tableRect))
{
(GetWindow())->Update();
enclAp = JXContainer::GlobalToLocal(enclApG); // local coords changed
}
else
{
// erase the old line
p->Line(enclAp.left, itsPrevPt.y, enclAp.right, itsPrevPt.y);
}
// draw the new line
p->Line(enclAp.left, pt.y, enclAp.right, pt.y);
// ready for next call
itsPrevPt = pt;
}
}
}
示例12: GetBorderWidth
void
JXButton::DrawBorder
(
JXWindowPainter& p,
const JRect& origFrame
)
{
JSize borderWidth = GetBorderWidth();
if (borderWidth > 0 && IsActive())
{
JRect frame = origFrame;
if (itsIsReturnButtonFlag)
{
p.JPainter::Rect(frame);
frame.Shrink(1,1);
borderWidth--;
}
if (itsIsPushedFlag)
{
JXDrawDownFrame(p, frame, borderWidth);
}
else
{
JXDrawUpFrame(p, frame, borderWidth);
}
}
else if (borderWidth > 0)
{
p.SetLineWidth(borderWidth);
p.SetPenColor((GetColormap())->GetInactiveLabelColor());
p.RectInside(origFrame);
}
}
示例13: JXWindow
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();
}
示例14:
JBoolean
GetEnclosure
(
const JArray<JRect>& rectList,
const JIndex rectIndex,
JIndex* enclIndex
)
{
const JRect theRect = rectList.GetElement(rectIndex);
JBoolean found = kJFalse;
*enclIndex = 0;
JSize minArea = 0;
const JSize count = rectList.GetElementCount();
for (JIndex i=1; i<=count; i++)
{
if (i != rectIndex)
{
const JRect r = rectList.GetElement(i);
const JSize a = r.area();
if (r.Contains(theRect) && (a < minArea || minArea == 0))
{
minArea = a;
found = kJTrue;
*enclIndex = i;
}
}
}
return found;
}
示例15: CreateXInputField
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;
}
}