本文整理汇总了C++中BListView::SetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ BListView::SetFont方法的具体用法?C++ BListView::SetFont怎么用?C++ BListView::SetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BListView
的用法示例。
在下文中一共展示了BListView::SetFont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BListView
AsciiWindow::AsciiWindow(void)
:
DWindow(BRect(0.0f, 0.0f, kWindowWidth, kWindowHeight),
B_TRANSLATE("ASCII table"), B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
fIsZoomed(false),
fLastFrame(Frame())
{
BListView* listView = new BListView("listView", B_MULTIPLE_SELECTION_LIST,
B_WILL_DRAW);
BScrollView* listScrollView = new BScrollView("scrollView", listView, 0,
false, true, B_NO_BORDER);
listView->SetFont(be_fixed_font);
listView->AddItem(new BStringItem(B_TRANSLATE(" Dec Hex Oct Code Description")));
listView->AddItem(new BStringItem(""));
for (int i = 0; i < 128; i++) {
char* row;
asprintf(&row, " %3d %2x %3o %3s %s", i, i, i,
sAsciiTable[i].code, sAsciiTable[i].description.String());
listView->AddItem(new BStringItem(row));
free(row);
}
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(listScrollView)
.SetInsets(-1)
.End();
CenterOnScreen();
}
示例2: stateIcon
void
InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
BListView* list = dynamic_cast<BListView*>(owner);
if (list == NULL)
return;
owner->PushState();
BRect bounds = list->ItemFrame(list->IndexOf(this));
//rgb_color highColor = list->HighColor();
rgb_color lowColor = list->LowColor();
if (IsSelected() || complete) {
if (IsSelected()) {
list->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
list->SetLowColor(list->HighColor());
} else
list->SetHighColor(lowColor);
list->FillRect(bounds);
}
BString interfaceState;
BBitmap* stateIcon(NULL);
if (fSettings->IsDisabled()) {
interfaceState << "disabled";
stateIcon = fIconOffline;
} else if (!fInterface.HasLink()) {
interfaceState << "no link";
stateIcon = fIconOffline;
} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
&& fSettings->IPAddr(AF_INET6).IsEmpty())
&& (fSettings->AutoConfigure(AF_INET)
|| fSettings->AutoConfigure(AF_INET6))) {
interfaceState << "connecting" B_UTF8_ELLIPSIS;
stateIcon = fIconPending;
} else {
interfaceState << "connected";
stateIcon = fIconOnline;
}
// Set the initial bounds of item contents
BPoint iconPt = bounds.LeftTop();
BPoint namePt = bounds.LeftTop();
BPoint line2Pt = bounds.LeftTop();
BPoint line3Pt = bounds.LeftTop();
BPoint statePt = bounds.RightTop();
iconPt += BPoint(4, 4);
statePt += BPoint(0, fFirstlineOffset);
namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
statePt -= BPoint(
be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0);
if (fSettings->IsDisabled()) {
list->SetDrawingMode(B_OP_ALPHA);
list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
list->SetHighColor(0, 0, 0, 32);
} else
list->SetDrawingMode(B_OP_OVER);
list->DrawBitmapAsync(fIcon, iconPt);
list->DrawBitmapAsync(stateIcon, iconPt);
if (fSettings->IsDisabled()) {
rgb_color textColor;
if (IsSelected())
textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
else
textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT));
else
list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT));
} else {
if (IsSelected())
list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
else
list->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
}
list->SetFont(be_bold_font);
list->DrawString(Name(), namePt);
list->SetFont(be_plain_font);
list->DrawString(interfaceState, statePt);
if (!fSettings->IsDisabled()) {
// Render IPv4 Address
BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label"));
if (fSettings->IPAddr(AF_INET).IsEmpty())
ipv4Str << " " << B_TRANSLATE("None");
else
//.........这里部分代码省略.........
示例3: stateIcon
void
InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
BListView* list = dynamic_cast<BListView*>(owner);
if (!list)
return;
owner->PushState();
BRect bounds = list->ItemFrame(list->IndexOf(this));
rgb_color black = {0, 0, 0, 255};
if (IsSelected() || complete) {
if (IsSelected()) {
list->SetHighColor(tint_color(list->ViewColor(),
B_HIGHLIGHT_BACKGROUND_TINT));
} else {
list->SetHighColor(list->LowColor());
}
list->FillRect(bounds);
}
BString interfaceState;
BBitmap* stateIcon(NULL);
if (fSettings->IsDisabled()) {
interfaceState << "disabled";
stateIcon = fIconOffline;
} else if (!fInterface.HasLink()) {
interfaceState << "no link";
stateIcon = fIconOffline;
} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
&& fSettings->IPAddr(AF_INET6).IsEmpty())
&& (fSettings->AutoConfigure(AF_INET)
|| fSettings->AutoConfigure(AF_INET6))) {
interfaceState << "connecting" B_UTF8_ELLIPSIS;
stateIcon = fIconPending;
} else {
interfaceState << "connected";
stateIcon = fIconOnline;
}
// Set the initial bounds of item contents
BPoint iconPt = bounds.LeftTop();
BPoint namePt = bounds.LeftTop();
BPoint v4addrPt = bounds.LeftTop();
BPoint v6addrPt = bounds.LeftTop();
BPoint statePt = bounds.RightTop();
iconPt += BPoint(4, 4);
statePt += BPoint(0, fFirstlineOffset);
namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
statePt
-= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0);
if (fSettings->IsDisabled()) {
list->SetDrawingMode(B_OP_ALPHA);
list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
list->SetHighColor(0, 0, 0, 32);
} else
list->SetDrawingMode(B_OP_OVER);
list->DrawBitmapAsync(fIcon, iconPt);
list->DrawBitmapAsync(stateIcon, iconPt);
if (fSettings->IsDisabled())
list->SetHighColor(tint_color(black, B_LIGHTEN_1_TINT));
else
list->SetHighColor(black);
list->SetFont(be_bold_font);
list->DrawString(Name(), namePt);
list->SetFont(be_plain_font);
list->DrawString(interfaceState, statePt);
if (!fSettings->IsDisabled()) {
// Render IPv4 Address
BString v4str("IPv4: ");
if (fSettings->IPAddr(AF_INET).IsEmpty())
v4str << "none";
else {
v4str << fSettings->IP(AF_INET);
}
if (fSettings->AutoConfigure(AF_INET))
v4str << " (DHCP)";
else
v4str << " (static)";
list->DrawString(v4str.String(), v4addrPt);
// Render IPv6 Address (if present)
//.........这里部分代码省略.........
示例4: sizeString
void
BackupListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
BListView* list = dynamic_cast<BListView*>(owner);
if (list == NULL)
return;
owner->PushState();
BRect bounds = list->ItemFrame(list->IndexOf(this));
rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
rgb_color backgroundColor = ui_color(B_LIST_BACKGROUND_COLOR);
if (fIndex % 2)
backgroundColor = (rgb_color){ 247, 247, 247, 255 };
// draw background
list->SetDrawingMode(B_OP_OVER);
list->SetHighColor(backgroundColor);
list->FillRect(bounds);
// set proper colors for "normal" items
list->SetHighColor(textColor);
list->SetLowColor(backgroundColor);
// Set up points for things in BListItem
BPoint checkboxPt = bounds.LeftTop();
BPoint namePt = bounds.LeftTop();
BPoint descriptionPt = bounds.LeftTop();
BPoint sizePt = bounds.RightTop();
namePt += BPoint(16 + 8, fFirstlineOffset);
sizePt += BPoint(0, fFirstlineOffset);
descriptionPt += BPoint(16 + 8, fSecondlineOffset);
checkboxPt += BPoint(4, 2);
list->SetFont(be_bold_font);
list->DrawString(fName.String(), namePt);
char sizeText[512];
size_to_string(fSize, sizeText, 512);
BString sizeString(sizeText);
list->SetFont(be_plain_font);
sizePt -= BPoint(
be_plain_font->StringWidth(sizeString.String()) + 4.0f, 0);
list->DrawString(sizeString.String(), sizePt);
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT));
else
list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT));
list->SetFontSize(11);
list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
list->DrawString(fDescription.String(), descriptionPt);
if (!fEnabled) {
fEnabled = new BCheckBox(BRect(0, 0, 16, 16), fName.String(),
fName.String(), new BMessage(kMsgUpdateSelection));
list->AddChild(fEnabled);
// First run, set default value
fEnabled->SetValue(gLocationMap[fIndex].defaultValue
? B_CONTROL_ON : B_CONTROL_OFF);
}
fEnabled->SetHighColor(textColor);
fEnabled->SetLowColor(backgroundColor);
fEnabled->MoveTo(checkboxPt.x, checkboxPt.y);
owner->PopState();
}