本文整理汇总了C++中JPainter::SetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ JPainter::SetFont方法的具体用法?C++ JPainter::SetFont怎么用?C++ JPainter::SetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPainter
的用法示例。
在下文中一共展示了JPainter::SetFont方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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);
}
}
示例2: JString
void
JXColHeaderWidget::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.x);
if (title != NULL)
{
str = *title;
hasTitle = kJTrue;
}
}
if (!hasTitle)
{
str = JString(cell.x, 0);
}
p.SetFont(JGetDefaultFontName(), kFontSize,
JFontStyle(kJTrue, kJFalse, 0, kJFalse, (p.GetColormap())->GetBlackColor()));
p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
示例3: JString
void
GPMTreeHeaderWidget::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JXDrawUpFrame(p, rect, kJXDefaultBorderWidth);
JString str;
if (!GetColTitle(cell.x, &str))
{
str = JString(cell.x, JString::kBase10);
}
JSize underLines = 0;
if (itsList->TreeColIsSelected(cell.x))
{
underLines = 1;
}
const JFont font = GetFontManager()->GetFont(
JGetDefaultFontName(), JGetDefaultRowColHeaderFontSize(),
JFontStyle(kJTrue, kJFalse, underLines, kJFalse, (p.GetColormap())->GetBlackColor()));
p.SetFont(font);
p.String(rect, str, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
示例4: if
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);
}
}
示例5:
void
GMAccountList::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
HilightIfSelected(p, cell, rect);
JFontStyle fontstyle;
if (itsDialog->GetDefaultIndex() == (JIndex)cell.y)
{
fontstyle.bold = kJTrue;
}
p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, fontstyle);
JString str = itsAccountInfo->NthElement(cell.y)->GetNickname();
// check that column is wide enough
const JCoordinate w = p.GetStringWidth(str) + 2*kHMarginWidth;
if (w > GetColWidth(1))
{
itsMinColWidth = w;
}
// draw string
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, str, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
if (cell.y == JCoordinate(itsAccountInfo->GetElementCount()))
{
AdjustColWidth();
}
}
示例6: JString
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;
}
}
示例7:
void
FitParmsTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JString* str;
p.SetFont(GetFontManager()->GetDefaultFont());
JRect r = rect;
if (cell.x == 1)
{
r.right -= kHMarginWidth;
str = itsCol1->NthElement(cell.y);
p.String(r, *str, JPainter::kHAlignRight, JPainter::kVAlignCenter);
}
else
{
r.left += kHMarginWidth;
str = itsCol2->NthElement(cell.y);
p.String(r, *str, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
}
}
示例8: GetFont
void
JXStringTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JPoint editCell;
if (!GetEditedCell(&editCell) || cell != editCell)
{
HilightIfSelected(p, cell, rect);
JSize fontSize;
const JString& fontName = GetFont(&fontSize);
p.SetFont(fontName, fontSize, GetCellStyle(cell));
const JString& str = itsStringData->GetString(cell);
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, str, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
}
}
示例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));
//.........这里部分代码省略.........
示例12: if
void
JXTextMenuTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& origRect
)
{
JRect rect = AdjustRectForSeparator(cell.y, origRect);
if (cell.x == kCheckboxColumnIndex)
{
rect.left += kHilightBorderWidth;
DrawCheckbox(p, cell.y, rect);
}
else if (cell.x == kImageColumnIndex)
{
const JXImage* image;
if (itsTextMenuData->GetImage(cell.y, &image))
{
p.Image(*image, image->GetBounds(), rect);
}
}
else if (cell.x == kTextColumnIndex)
{
JIndex ulIndex;
JFontID id;
JSize size;
JFontStyle style;
const JString& text =
itsTextMenuData->GetText(cell.y, &ulIndex, &id, &size, &style);
if (!itsTextMenuData->IsEnabled(cell.y))
{
style.color = (GetColormap())->GetInactiveLabelColor();
}
p.SetFont(id, size, style);
rect.left += kHMarginWidth;
JXWindowPainter* xp = dynamic_cast<JXWindowPainter*>(&p);
assert( xp != NULL );
xp->String(rect.left, rect.top, text, ulIndex,
rect.width(), JPainter::kHAlignLeft,
rect.height(), JPainter::kVAlignCenter);
}
else if (cell.x == kSubmenuColumnIndex && itsTextMenuData->HasSubmenu(cell.y))
{
rect.right -= kHilightBorderWidth;
rect.left = rect.right - JXMenuTable::kSubmenuColWidth;
DrawSubmenuIndicator(p, cell.y, rect,
JConvertToBoolean(((JIndex) cell.y) == itsHilightRow));
}
else if (cell.x == kSubmenuColumnIndex)
{
const JString* nmShortcut;
JFontID id;
JSize size;
JFontStyle style;
if (itsTextMenuData->GetNMShortcut(cell.y, &nmShortcut, &id, &size, &style))
{
if (!itsTextMenuData->IsEnabled(cell.y))
{
style.color = (GetColormap())->GetInactiveLabelColor();
}
p.SetFont(id, size, style);
rect.left += kHNMSMarginWidth;
rect.right -= kHilightBorderWidth;
p.String(rect, *nmShortcut, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
}
}
}