本文整理汇总了C++中BStringField类的典型用法代码示例。如果您正苦于以下问题:C++ BStringField类的具体用法?C++ BStringField怎么用?C++ BStringField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BStringField类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
NetPrefsServerView::RemoveServer ()
{
BAutolock lock (Looper ());
if (!lock.IsLocked ())
return;
BRow *row (fServerList->CurrentSelection ());
if (row)
{
BStringField *field ((BStringField *) row->GetField (1));
int32 count;
ssize_t size;
type_code type;
fActiveNetwork->GetInfo ("server", &type, &count);
const ServerData *data;
for (int32 i = 0; i < count; i++)
{
fActiveNetwork->FindData ("server", B_ANY_TYPE, i, reinterpret_cast < const void **>(&data),
&size);
if (!strcmp (data->serverName, field->String ()))
{
fActiveNetwork->RemoveData ("server", i);
break;
}
}
fServerList->RemoveRow (row);
delete row;
}
}
示例2: max_c
float
TeamsColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
BBitmapStringField* bitmapField
= dynamic_cast<BBitmapStringField*>(_field);
BStringField* stringField = dynamic_cast<BStringField*>(_field);
float parentWidth = Inherited::GetPreferredWidth(_field, parent);
float width = 0.0;
if (bitmapField) {
const BBitmap* bitmap = bitmapField->Bitmap();
BFont font;
parent->GetFont(&font);
width = font.StringWidth(bitmapField->String()) + 3 * sTextMargin;
if (bitmap)
width += bitmap->Bounds().Width();
else
width += 16;
} else if (stringField) {
BFont font;
parent->GetFont(&font);
width = font.StringWidth(stringField->String()) + 2 * sTextMargin;
}
return max_c(width, parentWidth);
}
示例3: switch
void
NotificationsView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case kApplicationSelected:
{
BRow* row = fApplications->CurrentSelection();
if (row == NULL)
return;
BStringField* appName
= dynamic_cast<BStringField*>(row->GetField(kAppIndex));
if (appName == NULL)
break;
appusage_t::iterator it = fAppFilters.find(appName->String());
if (it != fAppFilters.end())
_Populate(it->second);
break;
}
case kNotificationSelected:
break;
default:
BView::MessageReceived(msg);
break;
}
}
示例4: max_c
float
BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
BStringField* field = static_cast<BStringField*>(_field);
BFont font;
parent->GetFont(&font);
float width = font.StringWidth(field->String()) + 2 * kTEXT_MARGIN;
float parentWidth = BTitledColumn::GetPreferredWidth(_field, parent);
return max_c(width, parentWidth);
}
示例5: getColumnListView
/**
* @brief Gets a string at specified index from the control.
* @param[in] rowIndex row index
* @param[in] columnIndex column index
* @param[out] text a string value is returned.
*/
void BeColumnListViewAdapter::GetItemText(SInt32 rowIndex, SInt32 columnIndex, MBCString& text)
{
BColumnListView* listView = getColumnListView();
BRow* row = listView->RowAt(rowIndex);
BStringField* field = dynamic_cast<BStringField*>(row->GetField(columnIndex));
if (NULL != field)
{
text = field->String();
}
}
示例6:
void
ResView::UpdateRow(BRow *row)
{
TypeCodeField *typeField = (TypeCodeField*) row->GetField(1);
ResourceData *resData = typeField->GetResourceData();
BStringField *strField = (BStringField *)row->GetField(0);
if (strcmp("(attr)", strField->String()) != 0)
strField->SetString(resData->GetIDString());
strField = (BStringField *)row->GetField(2);
if (strField)
strField->SetString(resData->GetName());
PreviewField *preField = (PreviewField*)row->GetField(3);
if (preField)
preField->SetData(resData->GetData(), resData->GetLength());
BSizeField *sizeField = (BSizeField*)row->GetField(4);
if (sizeField)
sizeField->SetSize(resData->GetLength());
}
示例7: out_string
void
BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
float width = rect.Width() - (2 * kTEXT_MARGIN);
BStringField* field = static_cast<BStringField*>(_field);
float fieldWidth = field->Width();
bool updateNeeded = width != fieldWidth;
if (updateNeeded) {
BString out_string(field->String());
float preferredWidth = parent->StringWidth(out_string.String());
if (width < preferredWidth) {
parent->TruncateString(&out_string, fTruncate, width + 2);
field->SetClippedString(out_string.String());
} else
field->SetClippedString("");
field->SetWidth(width);
}
DrawString(field->HasClippedString() ? field->ClippedString()
: field->String(), parent, rect);
}
示例8: out_string
void
BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
float width = rect.Width() - (2 * kTEXT_MARGIN);
BStringField* field = static_cast<BStringField*>(_field);
bool clipNeeded = width < field->Width();
if (clipNeeded) {
BString out_string(field->String());
parent->TruncateString(&out_string, fTruncate, width + 2);
field->SetClippedString(out_string.String());
field->SetWidth(width);
}
DrawString(clipNeeded ? field->ClippedString() : field->String(), parent, rect);
}
示例9: truncatedString
void
TeamsColumn::DrawField(BField* field, BRect rect, BView* parent)
{
BBitmapStringField* bitmapField
= dynamic_cast<BBitmapStringField*>(field);
BStringField* stringField = dynamic_cast<BStringField*>(field);
if (bitmapField) {
const BBitmap* bitmap = bitmapField->Bitmap();
// figure out the placement
float x = 0.0;
BRect r = bitmap ? bitmap->Bounds() : BRect(0, 0, 15, 15);
float y = rect.top + ((rect.Height() - r.Height()) / 2);
float width = 0.0;
switch (Alignment()) {
default:
case B_ALIGN_LEFT:
case B_ALIGN_CENTER:
x = rect.left + sTextMargin;
width = rect.right - (x + r.Width()) - (2 * sTextMargin);
r.Set(x + r.Width(), rect.top, rect.right - width, rect.bottom);
break;
case B_ALIGN_RIGHT:
x = rect.right - sTextMargin - r.Width();
width = (x - rect.left - (2 * sTextMargin));
r.Set(rect.left, rect.top, rect.left + width, rect.bottom);
break;
}
if (width != bitmapField->Width()) {
BString truncatedString(bitmapField->String());
parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
bitmapField->SetClippedString(truncatedString.String());
bitmapField->SetWidth(width);
}
// draw the bitmap
if (bitmap) {
parent->SetDrawingMode(B_OP_ALPHA);
parent->DrawBitmap(bitmap, BPoint(x, y));
parent->SetDrawingMode(B_OP_OVER);
}
// draw the string
DrawString(bitmapField->ClippedString(), parent, r);
} else if (stringField) {
float width = rect.Width() - (2 * sTextMargin);
if (width != stringField->Width()) {
BString truncatedString(stringField->String());
parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
stringField->SetClippedString(truncatedString.String());
stringField->SetWidth(width);
}
DrawString(stringField->ClippedString(), parent, rect);
}
}
示例10:
float
BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
BStringField* field = static_cast<BStringField*>(_field);
return parent->StringWidth(field->String()) + 2 * kTEXT_MARGIN;
}
示例11: switch
void BudgetWindow::SetPeriod(const BudgetPeriod &period)
{
BRow *row = fCategoryList->CurrentSelection();
if(!row)
return;
BudgetEntry entry;
BStringField *strfield = (BStringField*)row->GetField(0);
if(!gDatabase.GetBudgetEntry(strfield->String(),entry))
return;
// Convert the amount to reflect the change in period
switch(entry.period)
{
case BUDGET_WEEKLY:
{
entry.amount *= 52;
break;
}
case BUDGET_QUARTERLY:
{
entry.amount *= 4;
break;
}
case BUDGET_ANNUALLY:
{
break;
}
default:
{
entry.amount *= 12;
break;
}
}
entry.period = period;
switch(entry.period)
{
case BUDGET_WEEKLY:
{
entry.amount /= 52;
break;
}
case BUDGET_QUARTERLY:
{
entry.amount /= 4;
break;
}
case BUDGET_ANNUALLY:
{
break;
}
default:
{
entry.amount /= 12;
break;
}
}
// yeah, yeah, I know about rounding errors. It's not that big of a deal,
// so deal with it. *famous last words*
entry.amount.Round();
gDatabase.AddBudgetEntry(entry);
RefreshBudgetGrid();
RefreshBudgetSummary();
BString str;
gDefaultLocale.CurrencyToString(entry.amount,str);
str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal()));
str.RemoveFirst(gDefaultLocale.CurrencySymbol());
row->SetField(new BStringField(str.String()),1);
fAmountBox->SetText(str.String());
row->SetField(new BStringField(BudgetPeriodToString(entry.period).String()),2);
fCategoryList->UpdateRow(row);
}
示例12: BStringField
void BudgetWindow::HandleCategorySelection(void)
{
BRow *row = fCategoryList->CurrentSelection();
if(!row)
{
fAmountBox->SetText("");
fMonthly->SetValue(B_CONTROL_ON);
fStatAverageRow->SetField(new BStringField(""),1);
fStatHighestRow->SetField(new BStringField(""),1);
fStatLowestRow->SetField(new BStringField(""),1);
}
BudgetEntry entry;
BStringField *strfield = (BStringField*)row->GetField(0);
if(!gDatabase.GetBudgetEntry(strfield->String(),entry))
return;
switch(entry.period)
{
case BUDGET_WEEKLY:
{
fWeekly->SetValue(B_CONTROL_ON);
break;
}
case BUDGET_QUARTERLY:
{
fQuarterly->SetValue(B_CONTROL_ON);
break;
}
case BUDGET_ANNUALLY:
{
fAnnually->SetValue(B_CONTROL_ON);
break;
}
default:
{
fMonthly->SetValue(B_CONTROL_ON);
break;
}
}
BString str;
gDefaultLocale.CurrencyToString(entry.amount.AbsoluteValue(),str);
str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal()));
str.RemoveFirst(gDefaultLocale.CurrencySymbol());
fAmountBox->SetText(str.String());
Fixed high,low,avg;
CalcStats(entry.name.String(),high,low,avg);
gDefaultLocale.CurrencyToString(high.AbsoluteValue(),str);
str.RemoveFirst(gDefaultLocale.CurrencySymbol());
fStatHighestRow->SetField(new BStringField(str.String()),1);
gDefaultLocale.CurrencyToString(low.AbsoluteValue(),str);
str.RemoveFirst(gDefaultLocale.CurrencySymbol());
fStatLowestRow->SetField(new BStringField(str.String()),1);
gDefaultLocale.CurrencyToString(avg.AbsoluteValue(),str);
str.RemoveFirst(gDefaultLocale.CurrencySymbol());
fStatAverageRow->SetField(new BStringField(str.String()),1);
fCatStat->Invalidate();
}
示例13: switch
//.........这里部分代码省略.........
listView->SetSortingEnabled (true);
listView->SetSortColumn (channelColumn, true, true);
if (!IsHidden())
vision_app->pClientWin()->pStatusView()->SetItemValue (1, statusStr.String(), true);
mFind->SetEnabled (true);
mFindAgain->SetEnabled (true);
mFilter->SetEnabled (true);
processing = false;
// empty out any remaining channels that fell below the batch cut off
AddBatch();
BString cString;
cString << listView->CountRows();
if (!IsHidden())
vision_app->pClientWin()->pStatusView()->SetItemValue (0, cString.String(), true);
}
break;
case M_LIST_EVENT:
{
const char *channel, *users, *topic;
msg->FindString ("channel", &channel);
msg->FindString ("users", &users);
msg->FindString ("topic", &topic);
BRow *row (new BRow ());
BStringField *channelField (new BStringField (channel));
BIntegerField *userField (new BIntegerField (atoi(users)));
BStringField *topicField (new BStringField (topic));
row->SetField (channelField, channelColumn->LogicalFieldNum());
row->SetField (userField, usersColumn->LogicalFieldNum());
row->SetField (topicField, topicColumn->LogicalFieldNum());
fBuildList.AddItem (row);
if (fBuildList.CountItems() == LIST_BATCH_SIZE)
AddBatch();
}
break;
#ifdef __INTEL__
case M_LIST_FILTER:
if (msg->HasString ("text"))
{
const char *buffer;
msg->FindString ("text", &buffer);
if (filter != buffer)
{
filter = buffer;
if (!IsHidden())
vision_app->pClientWin()->pStatusView()->SetItemValue (2, filter.String(), true);
regfree (&re);
memset (&re, 0, sizeof (re));
regcomp (