本文整理汇总了C++中DataSource::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSource::Print方法的具体用法?C++ DataSource::Print怎么用?C++ DataSource::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backgroundFrame
void
ActivityView::Draw(BRect updateRect)
{
bool drawBackground = true;
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
drawBackground = false;
_DrawHistory(drawBackground);
if (!fShowLegend)
return;
// draw legend
BRect legendFrame = _LegendFrame();
if (LowUIColor() == B_NO_COLOR)
SetLowColor(fLegendBackgroundColor);
if (drawBackground) {
BRect backgroundFrame(legendFrame);
backgroundFrame.bottom += kDraggerSize;
FillRect(backgroundFrame, B_SOLID_LOW);
}
BAutolock _(fSourcesLock);
font_height fontHeight;
GetFontHeight(&fontHeight);
for (int32 i = 0; i < fSources.CountItems(); i++) {
DataSource* source = fSources.ItemAt(i);
DataHistory* values = fValues.ItemAt(i);
BRect frame = _LegendFrameAt(legendFrame, i);
// draw color box
BRect colorBox = _LegendColorFrameAt(legendFrame, i);
BRect rect = colorBox;
uint32 flags = BControlLook::B_BLEND_FRAME;
be_control_look->DrawTextControlBorder(this, rect,
rect, fLegendBackgroundColor, flags);
SetHighColor(source->Color());
FillRect(rect);
// show current value and label
float y = frame.top + ceilf(fontHeight.ascent);
int64 value = values->ValueAt(values->End());
BString text;
source->Print(text, value);
float width = StringWidth(text.String());
BString label = source->Label();
float possibleLabelWidth = frame.right - colorBox.right - 12 - width;
// TODO: TruncateString() is broken... remove + 5 when fixed!
if (ceilf(StringWidth(label.String()) + 5) > possibleLabelWidth)
label = source->ShortLabel();
TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth);
if (drawBackground)
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
if (be_control_look == NULL) {
DrawString(label.String(), BPoint(6 + colorBox.right, y));
DrawString(text.String(), BPoint(frame.right - width, y));
} else {
be_control_look->DrawLabel(this, label.String(),
Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y));
be_control_look->DrawLabel(this, text.String(),
Parent()->ViewColor(), 0, BPoint(frame.right - width, y));
}
}
}
示例2: backgroundFrame
void
ActivityView::Draw(BRect updateRect)
{
bool drawBackground = true;
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
drawBackground = false;
_DrawHistory(drawBackground);
if (!fShowLegend)
return;
// draw legend
BRect legendFrame = _LegendFrame();
SetLowColor(fLegendBackgroundColor);
if (drawBackground) {
BRect backgroundFrame(legendFrame);
backgroundFrame.bottom += kDraggerSize;
FillRect(backgroundFrame, B_SOLID_LOW);
}
BAutolock _(fSourcesLock);
font_height fontHeight;
GetFontHeight(&fontHeight);
for (int32 i = 0; i < fSources.CountItems(); i++) {
DataSource* source = fSources.ItemAt(i);
DataHistory* values = fValues.ItemAt(i);
BRect frame = _LegendFrameAt(legendFrame, i);
// draw color box
BRect colorBox = _LegendColorFrameAt(legendFrame, i);
BRect rect = colorBox;
uint32 flags = BControlLook::B_BLEND_FRAME;
be_control_look->DrawTextControlBorder(this, rect,
rect, fLegendBackgroundColor, flags);
SetHighColor(source->Color());
FillRect(rect);
// show current value and label
float y = frame.top + ceilf(fontHeight.ascent);
int64 value = values->ValueAt(values->End());
BString text;
source->Print(text, value);
float width = StringWidth(text.String());
BString label = source->Label();
float possibleLabelWidth = frame.right - colorBox.right - 12 - width;
// TODO: TruncateString() is broken... remove + 5 when fixed!
if (ceilf(StringWidth(label.String()) + 5) > possibleLabelWidth)
label = source->ShortLabel();
TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth);
if (drawBackground)
SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
else {
rgb_color c = Parent()->ViewColor();
rgb_color textColor = c.red + c.green * 1.5f + c.blue * 0.50f
>= 300 ? kBlack : kWhite;
int32 mask;
bool tmpOutline = false;
bool outline = fCachedOutline;
int8 indice = 0;
if (fCachedWorkspace != current_workspace()) {
while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
indice, &mask) == B_OK
&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
indice, &tmpOutline) == B_OK) {
if (((1 << current_workspace()) & mask) != 0) {
outline = tmpOutline;
fCachedWorkspace = current_workspace();
fCachedOutline = outline;
break;
}
indice++;
}
}
if (outline) {
SetDrawingMode(B_OP_ALPHA);
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
BFont font;
GetFont(&font);
if (textColor == kBlack) {
// Black text with white halo/glow
rgb_color glowColor = kWhite;
font.SetFalseBoldWidth(2.0);
SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
glowColor.alpha = 30;
SetHighColor(glowColor);
DrawString(label.String(), BPoint(6 + colorBox.right, y));
DrawString(text.String(), BPoint(frame.right - width, y));
font.SetFalseBoldWidth(1.0);
//.........这里部分代码省略.........