本文整理汇总了C++中JPainter::Line方法的典型用法代码示例。如果您正苦于以下问题:C++ JPainter::Line方法的具体用法?C++ JPainter::Line怎么用?C++ JPainter::Line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPainter
的用法示例。
在下文中一共展示了JPainter::Line方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tableRect
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;
}
}
}
示例2: CreateDragInsidePainter
void
JXHorizPartition::HandleMouseDown
(
const JPoint& pt,
const JXMouseButton button,
const JSize clickCount,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
itsDragType = kInvalidDrag;
if (button != kJXLeftButton)
{
return;
}
if (modifiers.meta())
{
itsDragType = kDragAll;
PrepareToDragAll(pt.x, &itsMinDragX, &itsMaxDragX);
}
else
{
itsDragType = kDragOne;
PrepareToDrag(pt.x, &itsMinDragX, &itsMaxDragX);
}
JPainter* p = CreateDragInsidePainter();
const JRect ap = GetAperture();
p->Line(pt.x, ap.top, pt.x, ap.bottom);
itsPrevPt = pt;
}
示例3: if
void
JXHorizPartition::HandleMouseDrag
(
const JPoint& origPt,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
JPoint pt = origPt;
// keep compartment width larger than minimum
if (pt.x < itsMinDragX)
{
pt.x = itsMinDragX;
}
else if (pt.x > itsMaxDragX)
{
pt.x = itsMaxDragX;
}
// check if we have moved
if (pt.x != itsPrevPt.x)
{
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
JRect ap = GetAperture();
p->Line(itsPrevPt.x, ap.top, itsPrevPt.x, ap.bottom);
p->Line(pt.x, ap.top, pt.x, ap.bottom);
itsPrevPt = pt;
}
}
}
示例4: if
void
JXVertPartition::HandleMouseDrag
(
const JPoint& origPt,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
JPoint pt = origPt;
// keep compartment width larger than minimum
if (pt.y < itsMinDragY)
{
pt.y = itsMinDragY;
}
else if (pt.y > itsMaxDragY)
{
pt.y = itsMaxDragY;
}
// check if we have moved
if (pt.y != itsPrevPt.y)
{
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
JRect ap = GetAperture();
p->Line(ap.left, itsPrevPt.y, ap.right, itsPrevPt.y);
p->Line(ap.left, pt.y, ap.right, pt.y);
itsPrevPt = pt;
}
}
}
示例5: InDragRegion
void
JXRowHeaderWidget::HandleMouseDown
(
const JPoint& pt,
const JXMouseButton button,
const JSize clickCount,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
itsDragType = kInvalidDrag;
if (!itsAllowRowResizingFlag)
{
return;
}
const JBoolean inDragRegion = InDragRegion(pt, &itsDragCell);
if (inDragRegion && button == kJXLeftButton)
{
itsDragCellRect = GetCellRect(itsDragCell);
if (modifiers.meta())
{
itsDragType = kDragAllRows;
}
else
{
itsDragType = kDragOneRow;
}
JPainter* p = CreateDragOutsidePainter();
JRect defClipRect = p->GetDefaultClipRect();
JRect apG = GetApertureGlobal();
defClipRect.top = apG.top;
defClipRect.bottom = apG.bottom;
p->SetDefaultClipRect(defClipRect);
const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal());
p->Line(enclAp.left, pt.y, enclAp.right, pt.y);
itsPrevPt = pt;
}
}
示例6: GetDragPainter
void
JXRowHeaderWidget::HandleMouseUp
(
const JPoint& pt,
const JXMouseButton button,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
// erase the line
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal());
p->Line(enclAp.left, itsPrevPt.y, enclAp.right, itsPrevPt.y);
DeleteDragPainter();
// set the row height(s)
const JCoordinate rowHeight = itsPrevPt.y - itsDragCellRect.top;
if (itsDragType == kDragOneRow)
{
itsTable->SetRowHeight(itsDragCell.y, rowHeight);
}
else
{
assert( itsDragType == kDragAllRows );
itsTable->SetDefaultRowHeight(rowHeight);
itsTable->SetAllRowHeights(rowHeight);
}
}
itsDragType = kInvalidDrag;
}
示例7: GetDragPainter
void
JXColHeaderWidget::HandleMouseUp
(
const JPoint& pt,
const JXMouseButton button,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
// erase the line
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
const JRect enclAp = JXContainer::GlobalToLocal((GetEnclosure())->GetApertureGlobal());
p->Line(itsPrevPt.x, enclAp.top, itsPrevPt.x, enclAp.bottom);
DeleteDragPainter();
// set the column width(s)
const JCoordinate colWidth = itsPrevPt.x - itsDragCellRect.left;
if (itsDragType == kDragOneCol)
{
itsTable->SetColWidth(itsDragCell.x, colWidth);
}
else
{
assert( itsDragType == kDragAllCols );
itsTable->SetDefaultColWidth(colWidth);
itsTable->SetAllColWidths(colWidth);
}
}
itsDragType = kInvalidDrag;
}
示例8: GetDragPainter
void
JXHorizPartition::HandleMouseUp
(
const JPoint& pt,
const JXMouseButton button,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers
)
{
if (itsDragType != kInvalidDrag)
{
// erase the line
JPainter* p = NULL;
const JBoolean ok = GetDragPainter(&p);
assert( ok );
JRect ap = GetAperture();
p->Line(itsPrevPt.x, ap.top, itsPrevPt.x, ap.bottom);
DeleteDragPainter();
// set the compartment widths
if (itsDragType == kDragAll)
{
AdjustCompartmentsAfterDragAll(itsPrevPt.x);
}
else
{
assert( itsDragType == kDragOne );
AdjustCompartmentsAfterDrag(itsPrevPt.x);
}
}
itsDragType = kInvalidDrag;
}
示例9: ellipseRect
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);
//.........这里部分代码省略.........
示例10: if
void
CBCommandTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JPoint editCell;
if (GetEditedCell(&editCell) && cell == editCell)
{
return;
}
HilightIfSelected(p, cell, rect);
const CBCommandManager::CmdInfo info = itsCmdList->GetElement(cell.y);
if (info.separator)
{
JPoint pt1 = rect.bottomLeft(), pt2 = rect.bottomRight();
pt1.y--;
pt2.y--;
p.Line(pt1, pt2);
}
if (cell.x == kOptionsColumn)
{
JString s;
if (info.isMake)
{
s += ",M";
}
if (info.isVCS)
{
s += ",V";
}
if (info.saveAll)
{
s += ",S";
}
if (info.oneAtATime)
{
s += ",O";
}
if (info.useWindow)
{
s += ",W";
}
if (info.raiseWindowWhenStart)
{
s += ",R";
}
if (info.beepWhenFinished)
{
s += ",B";
}
if (!s.IsEmpty())
{
if (s.GetFirstCharacter() == ',')
{
s.RemoveSubstring(1,1);
}
p.String(rect, s, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
}
else
{
const JString* s = NULL;
JFontStyle style;
if (cell.x == kMenuTextColumn)
{
s = info.menuText;
}
else if (cell.x == kMenuShortcutColumn)
{
s = info.menuShortcut;
}
else if (cell.x == kScriptNameColumn)
{
s = info.name;
}
else if (cell.x == kCommandColumn)
{
s = info.cmd;
}
else if (cell.x == kPathColumn)
{
s = info.path;
style.color =
CBCommandPathInput::GetTextColor(*s, itsBasePath, kJFalse, p.GetColormap());
}
assert( s != NULL );
p.SetFont(itsFontName, itsFontSize, style);
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, *s, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
}
//.........这里部分代码省略.........
示例11: ellipseRect
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));
//.........这里部分代码省略.........